BackgroundChannelSpectrum¶
- class gdt.core.background.primitives.BackgroundChannelSpectrum(rates, rate_uncertainty, chan_nums, exposure)[source]¶
Bases:
ChannelBinsA class defining a Background Channel Spectrum.
- Parameters:
rates (np.array) – The array of background rates in each bin
rate_uncertainty (np.array) – The array of background rate uncertainties in each bin
chan_nums (np.array) – The channel numbers in ascending order
exposure (np.array) – The exposure of each bin
Attributes Summary
The centroids of the bins
The channel numbers
The count uncertainty in each bin
The counts in each bin
The exposure of each bin
The high-value edges of the bins
The low-value edges of the bins
The channel range
The count rate uncertainty of each bin
count rate of each bin
Number of bins
The widths of the bins
Methods Summary
closest_edge(val[, which])Return the closest bin edge
Return a list of ExposureBins, each one containing a continuous segment of data.
create(counts, chan_nums, exposure[, continuous])Create a
ChannelBinsobject from a list of channel numbers.from_rates(rates, rate_uncerts, chan_nums, ...)Create an ChannelBins object from count rates and uncertainties.
merge(histos, **kwargs)Not implemented for BackgroundChannelSpectrum
rebin(method, *args[, emin, emax])Not implemented for BackgroundChannelSpectrum
slice(chan_min, chan_max)Perform a slice over an energy range and return a new BackgroundChannelSpectrum object.
sum(histos)Sum multiple BackgroundChannelSpectrums together if they have the same channel range (support).
Attributes Documentation
- centroids¶
The centroids of the bins
- Type:
(np.array)
- chan_nums¶
The channel numbers
- Type:
(np.array)
- count_uncertainty¶
The count uncertainty in each bin
- Type:
(np.array)
- counts¶
The counts in each bin
- Type:
(np.array)
- exposure¶
The exposure of each bin
- Type:
(np.array)
- hi_edges¶
The high-value edges of the bins
- Type:
(np.array)
- lo_edges¶
The low-value edges of the bins
- Type:
(np.array)
- range¶
The channel range
- Type:
(int, int)
- rate_uncertainty¶
The count rate uncertainty of each bin
- Type:
(np.array)
- rates¶
count rate of each bin
- Type:
(np.array)
- size¶
Number of bins
- Type:
(int)
- widths¶
The widths of the bins
- Type:
(np.array)
Methods Documentation
- closest_edge(val, which='either')¶
Return the closest bin edge
- Parameters:
val (float) – Input value
which (str, optional) –
Options are:
’either’ - closest edge to val;
’low’ - closest edge lower than val; or
’high’ - closest edge higher than val. Default is ‘either’
- Returns:
(float)
- contiguous_bins()¶
Return a list of ExposureBins, each one containing a continuous segment of data. This is done by comparing the edges of each bin, and if there is a gap between edges, the data is split into separate ExposureBin objects, each containing a contiguous set of data.
- Returns
(list of
ExposureBins)
- classmethod create(counts, chan_nums, exposure, continuous=True, **kwargs)¶
Create a
ChannelBinsobject from a list of channel numbers.- Parameters:
counts (np.array) – The array of counts in each bin
chan_nums (np.array) – The energy channel numbers
exposure (np.array) – The exposure of each bin
count_uncerts (np.array, optional) – An array the same length as counts if the uncertainty is not Poisson.
continuous (bool, optional) – [Experimental] Whether the bins are continuous (meaning no gaps between channels).
precalc_good_segments (bool, optional) – If True, calculates contiguous bin segments on initialization. Default is True.
- Returns:
(
ChannelBins)
- classmethod from_rates(rates, rate_uncerts, chan_nums, exposure, **kwargs)¶
Create an ChannelBins object from count rates and uncertainties.
- Parameters:
rates (np.array) – The count rates
rate_uncerts (np.array) – The count rate uncertainties
chan_nums (np.array) – The energy channel numbers
exposure (np.array) – The exposure of each bin
precalc_good_segments (bool, optional) – If True, calculates contiguous bin segments on initialization. Default is True.
- Returns:
(
ChannelBins)
- slice(chan_min, chan_max)[source]¶
Perform a slice over an energy range and return a new BackgroundChannelSpectrum object. Note inclusive of chan_min and chan_max.
- Parameters:
chan_min (int) – Minimum channel number to be included
chan_max (int) – Maximum channel number to be included
- Returns:
- classmethod sum(histos)[source]¶
Sum multiple BackgroundChannelSpectrums together if they have the same channel range (support).
- Parameters:
histos (list of
BackgroundChannelSpectrum) – A list containing the background channel spectra to be summed- Returns: