BackgroundSpectrum¶
- class gdt.core.background.primitives.BackgroundSpectrum(rates, rate_uncertainty, lo_edges, hi_edges, exposure)[source]¶
Bases:
EnergyBinsA class defining a Background 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
lo_edges (np.array) – The low-value edges of the bins
hi_edges (np.array) – The high-value edges of the bins
exposure (np.array) – The exposure of each bin
Attributes Summary
The centroids of the bins
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 range of the bin edges
The count rate uncertainty of each bin
Differential rate uncertainty
count rate of each bin
Differential count rate
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.
from_rates(rates, rate_uncerts, lo_edges, ...)Create an ExposureBins object from count rates and uncertainties.
merge(histos, **kwargs)Not implemented for BackgroundSpectrum
rebin(method, *args[, emin, emax])Not implemented for BackgroundSpectrum
slice(emin, emax)Perform a slice over an energy range and return a new BackgroundSpectrum object.
sum(histos)Sum multiple BackgroundSpectrums together if they have the same energy range (support).
Attributes Documentation
- centroids¶
The centroids of the bins
- 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 range of the bin edges
- Type:
(float, float)
- rate_uncertainty¶
The count rate uncertainty of each bin
- Type:
(np.array)
- rate_uncertainty_per_kev¶
Differential rate uncertainty
- Type:
(np.array)
- rates¶
count rate of each bin
- Type:
(np.array)
- rates_per_kev¶
Differential count rate
- 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 from_rates(rates, rate_uncerts, lo_edges, hi_edges, exposure, **kwargs)¶
Create an ExposureBins object from count rates and uncertainties.
- Parameters:
rates (np.array) – The count rates
rate_uncerts (np.array) – The count rate uncertainties
lo_edges (np.array) – The low-value edges of the bins
hi_edges (np.array) – The high-value edges of the bins
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:
(
ExposureBins)
- slice(emin, emax)[source]¶
Perform a slice over an energy range and return a new BackgroundSpectrum object. Note that the emin and emax values that fall inside a bin will result in that bin being included.
- Parameters:
emin (float) – The low energy edge of the slice
emax (float) – The high energy of the slice
- Returns:
- classmethod sum(histos)[source]¶
Sum multiple BackgroundSpectrums together if they have the same energy range (support).
- Parameters:
histos (list of
BackgroundSpectrum) – A list containing the background spectra to be summed- Returns: