TimeBins¶
- class gdt.core.data_primitives.TimeBins(counts, lo_edges, hi_edges, exposure, **kwargs)[source]¶
Bases:
ExposureBinsA class defining a set of Time History (lightcurve) bins.
- Parameters:
counts (np.array) – The array of counts 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
count_uncerts (np.array, optional) – An array the same length as counts if the uncertainty is not Poisson.
precalc_good_segments (bool, optional) – If True, calculates contiguous bin segments on initialization. Default is True.
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
counts/exposure
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)Merge multiple ExposureBins together.
rebin(method, *args[, tstart, tstop])Rebin the ExposureBins object in given a binning function and return a new ExposureBins object
slice(tstart, tstop)Perform a slice over a range and return a new ExposureBins object.
sum(histos)Sum multiple ExposureBins together if they have the same bin edges.
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)
- rates¶
counts/exposure
- Type:
(np.array)
- Type:
The count rate of each bin
- 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:
- classmethod merge(histos, **kwargs)¶
Merge multiple ExposureBins together. Note that the ExposureBins to merged must be strictly non-overlapping. The end of the range for one ExposureBins may be equal to the start of the range for another, or there may be a gap between the end of one or beginning of another, but there cannot be an overlap. If you need to sum the counts between multiple ExposureBins with the same bin edges, see the
sum()method.- Parameters:
histos (list of
ExposureBins) – A list containing the ExposureBins to be merged- Returns:
- rebin(method, *args, tstart=None, tstop=None)¶
Rebin the ExposureBins object in given a binning function and return a new ExposureBins object
The binning function should take as input an array of counts, array of exposures, and an array of bin edges. Additional arguments specific to the function are allowed. The function should return an array of the new counts, new exposure, and new edges.
- Parameters:
method (<function>) – A binning function
*args – Arguments to be passed to the binning function
tstart (float, optional) – If set, defines the start time of the ExposureBins to be binned, otherwise binning will begin at the time of the first bin edge.
tstop (float, optional) – If set, defines the end time of the ExposureBins to be binned, otherwise binning will end at the time of the last bin edge.
- Returns:
- slice(tstart, tstop)¶
Perform a slice over a range and return a new ExposureBins object. Note that tstart and tstop values that fall inside a bin will result in that bin being included.
- Parameters:
tstart (float) – The start of the slice
tstop (float) – The end of the slice
- Returns:
- classmethod sum(histos)¶
Sum multiple ExposureBins together if they have the same bin edges. If the exposures are different between the histograms, they will be averaged.
Note
Count uncertainties are summed in quadrature.
- Parameters:
histos (list of
ExposureBins) – A list containing the ExposureBins to be summed- Returns: