BackgroundChannelRates

class gdt.core.background.primitives.BackgroundChannelRates(rates, rate_uncertainty, tstart, tstop, chan_nums, exposure=None)[source]

Bases: TimeChannelBins

Class containing the background rate data for non-energy calibrated data.

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

  • tstart (np.array) – The low-value edges of the time bins

  • tstop (np.array) – The high-value edges of the time bins

  • chan_nums (np.array) – The channel numbers in ascending order

  • exposure (np.array, optional) – The exposure of each bin

Attributes Summary

chan_nums

The channel numbers

channel_range

The channel number range

count_uncertainty

The counts uncertainty in each bin

counts

The array of counts in each bin

exposure

The exposure of each bin

num_chans

The number of energy channels along the energy axis

num_times

The number of bins along the time axis

quality

The spectrum quality flag

rate_uncertainty

The rate uncertainty in each bin

rates

The rates in each Time-Energy Bin

size

The number of bins along both axes (num_times, num_chans)

time_centroids

The bin centroids along the time axis

time_range

The range of the data along the time axis

time_widths

The bin widths along the time axis

tstart

The low-value edges of the time bins

tstop

The high-value edges of the time bins

Methods Summary

apply_ebounds(ebounds)

Apply an energy bounds calibration and return a TimeEnergyBins object.

closest_time_edge(val[, which])

Return the closest time bin edge

contiguous_channel_bins()

Return a list of TimeChannelBins, each one containing a contiguous channel segment of data.

contiguous_time_bins()

Return a list of TimeChannelBins, each one containing a contiguous time segment of data.

from_rates(rates, rate_uncerts, tstart, ...)

Create an TimeChannelBins object from count rates and uncertainties.

get_exposure([time_ranges, scale])

Calculate the total exposure of a time range or time ranges of data

integrate_channels([chan_min, chan_max])

Integrate the rates over the energy channels.

integrate_time([tstart, tstop])

Integrate the background over the time axis (producing a count rate channel spectrum).

merge_channels(histos, **kwargs)

Merge multiple TimeChannelBins together along the channel axis.

merge_time(histos)

Merge multiple BackroundChannelRates together along the time axis.

rebin_channels(method, *args[, chan_min, ...])

Not implemented for BackgroundChannelRates

rebin_time(method, *args[, tstart, tstop])

Not implemented for BackgroundChannelRates

slice_channels(chan_min, chan_max)

Perform a slice over the channel range and return a new BackgroundChannelRates object.

slice_time(tstart, tstop)

Perform a slice over a time range and return a new BackgroundChannelRates object.

sum_time(bkgds)

Sum multiple BackgroundChannelRates together if they have the same time range.

to_bak([time_range])

Not implemented for BackgroundChannelRates

Attributes Documentation

chan_nums

The channel numbers

Type:

(np.array)

channel_range

The channel number range

Type:

(int, int)

count_uncertainty

The counts uncertainty in each bin

Type:

(np.array)

counts

The array of counts in each bin

Type:

(np.array)

exposure

The exposure of each bin

Type:

(np.array)

num_chans

The number of energy channels along the energy axis

Type:

(int)

num_times

The number of bins along the time axis

Type:

(int)

quality

The spectrum quality flag

Type:

(np.array)

rate_uncertainty

The rate uncertainty in each bin

Type:

(np.array)

rates

The rates in each Time-Energy Bin

Type:

(np.array)

size

The number of bins along both axes (num_times, num_chans)

Type:

(int, int)

time_centroids

The bin centroids along the time axis

Type:

(np.array)

time_range

The range of the data along the time axis

Type:

(float, float)

time_widths

The bin widths along the time axis

Type:

(np.array)

tstart

The low-value edges of the time bins

Type:

(np.array)

tstop

The high-value edges of the time bins

Type:

(np.array)

Methods Documentation

apply_ebounds(ebounds)

Apply an energy bounds calibration and return a TimeEnergyBins object.

Parameters:

ebounds (Ebounds) – The energy bounds. Must match the number of channels as this object.

Returns:

(TimeEnergyBins)

closest_time_edge(val, which='either')

Return the closest time bin edge

Parameters:
  • val (float) – Input value

  • which (str, optional) –

    Options are:

    • ’either’ - closest edge to val;

    • ’low’ - closest edge lower than val;

    • ’high’ - closest edge higher than val. Default is ‘either’

Returns:

(float)

contiguous_channel_bins()

Return a list of TimeChannelBins, each one containing a contiguous channel segment of data. This is done by comparing adjacent channel numbers, and if there is a gap between channels, the data is split into separate TimeChannelBins objects, each containing a channel-contiguous set of data.

Returns:

(list of TimeChannelBins)

contiguous_time_bins()

Return a list of TimeChannelBins, each one containing a contiguous time segment of data. This is done by comparing the edges of each time bin, and if thereis a gap between edges, the data is split into separate TimeChannelBins objects, each containing a time-contiguous set of data.

Returns:

(list of TimeChannelBins)

classmethod from_rates(rates, rate_uncerts, tstart, tstop, exposure, chan_nums, **kwargs)

Create an TimeChannelBins object from count rates and uncertainties.

Parameters:
  • rates (np.array) – The count rates

  • rate_uncerts (np.array) – The count rate uncertainties

  • tstart (np.array) – The low-value edges of the time bins

  • tstop (np.array) – The high-value edges of the time bins

  • exposure (np.array) – The exposure of each bin

  • chan_nums (np.array) – The channel numbers in ascending order

  • quality (np.array, optional) – The spectrum quality flag

  • precalc_good_segments (bool, optional) – If True, calculates the good time and energy segments on initialization.

Returns:

(TimeChannelBins)

get_exposure(time_ranges=None, scale=False)

Calculate the total exposure 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

  • scale (bool, optional) – If True and the time ranges don’t match up with the data binning, will scale the exposure based on the requested time range. Default is False.

Returns:

(float)

integrate_channels(chan_min=None, chan_max=None)[source]

Integrate the rates over the energy channels. Limits on the integration smaller than the full range of channels can be set.

Parameters:
  • chan_min (int, optional) – The low end of the integration range (inclusive). If not set, uses the lowest energy channel of the histogram

  • chan_max (int, optional) – The high end of the integration range (inclusive). If not set, uses the highest energy channel of the histogram

Returns:

(BackgroundChannelRates)

integrate_time(tstart=None, tstop=None)[source]

Integrate the background over the time axis (producing a count rate channel spectrum). Limits on the integration smaller than the full range can be set.

Parameters:
  • tstart (float, optional) – The low end of the integration range. If not set, uses the lowest time edge of the histogram

  • tstop (float, optional) – The high end of the integration range. If not set, uses the highest time edge of the histogram

Returns:

(BackgroundChannelSpectrum)

classmethod merge_channels(histos, **kwargs)

Merge multiple TimeChannelBins together along the channel axis.

Parameters:

histos (list of TimeChannelBins) – A list containing the TimeChannelBins to be merged

Returns:

(TimeChannelBins)

classmethod merge_time(histos)[source]

Merge multiple BackroundChannelRates together along the time axis.

Parameters:

histos (list of BackgroundChannelRates) – A list containing the BackgroundChannelRates to be merged

Returns:

(BackgroundChannelRates)

rebin_channels(method, *args, chan_min=None, chan_max=None)[source]

Not implemented for BackgroundChannelRates

rebin_time(method, *args, tstart=None, tstop=None)[source]

Not implemented for BackgroundChannelRates

slice_channels(chan_min, chan_max)[source]

Perform a slice over the channel range and return a new BackgroundChannelRates object. Note that chan_min and chan_max values that fall inside a bin will result in that bin being included.

Parameters:
  • chan_min (int) – The start of the slice

  • chan_max (int) – The end of the slice

Returns:

(BackgroundChannelRates)

slice_time(tstart, tstop)[source]

Perform a slice over a time range and return a new BackgroundChannelRates 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:

(BackgroundChannelRates)

classmethod sum_time(bkgds)[source]

Sum multiple BackgroundChannelRates together if they have the same time range. Example use would be summing two backgrounds from two detectors.

Parameters:

bkgds (list of BackgroundChannelRates) – A list containing the BackgroundChannelRates to be summed

Returns:

(BackgroundChannelRates)

to_bak(time_range=None, **kwargs)[source]

Not implemented for BackgroundChannelRates