EventList¶
- class gdt.core.data_primitives.EventList(times=None, channels=None, ebounds=None)[source]¶
Bases:
objectA primitive class defining an event list.
- Parameters:
times (np.array) – The array of event times
channels (np.array) – The corresponding array of associated energy channel
ebounds (
Ebounds, optional) – The energy bounds mapped to energy channels
Attributes Summary
The range of the channels in the list
The PHA channel array
The energy bounds of the energy channels.
The maximum energy
The minimum energy
The energy range of the channels
The number of energy channels.
The number of events in the list
The range of the times in the list
The event times
Methods Summary
bin(method, *args[, tstart, tstop, ...])Bin the EventList in time given a binning function and return a 2D time-energy channel histogram.
channel_slice(chanlo, chanhi)Perform a slice in energy channels of the EventList and return a new EventList
count_spectrum(**kwargs)Extract a count spectrum for the EventList or for a segment of the EventList.
energy_slice(emin, emax)Perform a slice in energy of the EventList and return a new EventList.
get_exposure([time_ranges, event_deadtime, ...])Calculate the total exposure, in seconds, of a time range or time ranges of data.
merge(eventlists[, sort, force_unique])Merge multiple EventLists together in time and optionally sort.
rebin_energy(method, *args, **kwargs)Rebin the energy channels using the specified binning algorithm.
In-place sort by channel number.
In-place sort by time.
time_slice(tstart, tstop)Perform a slice in time of the EventList and return a new EventList
Attributes Documentation
- channel_range¶
The range of the channels in the list
- Type:
(int, int)
- channels¶
The PHA channel array
- Type:
(np.array)
- emax¶
The maximum energy
- Type:
(float)
- emin¶
The minimum energy
- Type:
(float)
- energy_range¶
The energy range of the channels
- Type:
(float, float)
- num_chans¶
The number of energy channels. Note that not all channels will necessarily have events, especially if a slice is made over energy.
- Type:
(int)
- size¶
The number of events in the list
- Type:
(int)
- time_range¶
The range of the times in the list
- Type:
(float, float)
- times¶
The event times
- Type:
(np.array)
Methods Documentation
- bin(method, *args, tstart=None, tstop=None, event_deadtime=2.6e-06, overflow_deadtime=1e-05, **kwargs)[source]¶
Bin the EventList in time given a binning function and return a 2D time-energy channel histogram. If the ebounds energy calibration is set, returns a
TimeEnergyBinsobject, otherwise returns aTimeChannelBinsobject.The binning function should take as input an array of times as well as a tstart and tstop keywords for partial list binning. Additional arguments and keyword arguments specific to the function are allowed. The function should return an array of time edges for the bins, such that, for n bins, there are n + 1 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 EventList to be binned, otherwise binning will begin at the time of the first event.
tstop (float, optional) – If set, defines the end time of the EventList to be binned, otherwise binning will end at the time of the last event.
event_deadtime (float, optional) – The deadtime per event in seconds. Default is 2.6e-6.
overflow_deadtime (float, optional) – The deadtime per event in the overflow channel in seconds. Default is 1e-5.
**kwargs – Options to be passed to the binning function
- Returns:
- channel_slice(chanlo, chanhi)[source]¶
Perform a slice in energy channels of the EventList and return a new EventList
- Parameters:
chanlo (int) – The start of the channel slice
chanhi (int) – The end of the channel slice
- Returns:
- count_spectrum(**kwargs)[source]¶
Extract a count spectrum for the EventList or for a segment of the EventList. If the ebounds energy calibration is set, returns an
EnergyBinsobject, otherwise returns aChannelBinsobject.- Parameters:
time_ranges ([(float, float), ...], optional) – The time range or time ranges over which to calculate the exposure. If omitted, calculates the total exposure of the data.
event_deadtime (float, optional) – The deadtime per event in seconds. Default is 0.
overflow_deadtime (float, optional) – The deadtime per event in the overflow channel in seconds. Default is 0.
- Returns:
(
EnergyBinsorChannelBins)
- energy_slice(emin, emax)[source]¶
Perform a slice in energy of the EventList and return a new EventList. Since energies are binned, an emin or emax falling inside of an energy channel bin will include that bin in the slice.
- Parameters:
emin (float) – The start of the energy slice
emax (float) – The end of the energy slice
- Returns:
- get_exposure(time_ranges=None, event_deadtime=0.0, overflow_deadtime=0.0)[source]¶
Calculate the total exposure, in seconds, of a time range or time ranges of data.
- Parameters:
time_ranges ([(float, float), ...], optional) – The time range or time ranges over which to calculate the exposure. If omitted, calculates the total exposure of the data.
event_deadtime (float, optional) – The deadtime per event in seconds. Default is 0.
overflow_deadtime (float, optional) – The deadtime per event in the overflow channel in seconds. Default is 0.
- Returns:
(float)
- classmethod merge(eventlists, sort=False, force_unique=True)[source]¶
Merge multiple EventLists together in time and optionally sort.
- Parameters:
eventlist (list of
EventList) – A list containing the EventLists to be mergedsort (bool, optional) – If True, sorts by time after the merge. Default is False.
force_unique (bool, optional) – If True, force all events to be unique via brute force sorting. If False, the EventLists will only be checked and masked for overlapping time ranges. Events can potentially be lost if the merged EventLists contain overlapping times (but not necessarily duplicate events), however this method is much faster. Default is True.
- Returns:
- rebin_energy(method, *args, **kwargs)[source]¶
Rebin the energy channels using the specified binning algorithm. This does not change the number of events in the EventList, but changes their assignment to a channel and bins the energy bounds mapping to those channels (if applicable). A new EventList object is returned.
- Parameters:
method (<function>) – A binning function
*args – Arguments to be passed to the binning function
**kwargs – Deadtime arguments passed to get_exposure
- Returns: