threeML.utils.spectrum.binned_spectrum module
- class threeML.utils.spectrum.binned_spectrum.BinnedSpectrum(counts, exposure, ebounds: ndarray | ChannelSet, count_errors: ndarray | None = None, sys_errors: ndarray | None = None, quality: Quality | None = None, scale_factor: float = 1.0, is_poisson: bool = False, mission: str | None = None, instrument: str | None = None, tstart: float | None = None, tstop: float | None = None)
Bases:
Histogram
- add_inverse_variance_weighted(other)
- clone(new_counts=None, new_count_errors=None, new_exposure=None, new_scale_factor=None)
make a new spectrum with new counts and errors and all other parameters the same
- Parameters:
new_counts – new counts for the spectrum
new_count_errors – new errors from the spectrum
- Returns:
- property count_errors: ndarray | None
count error per channel
- Type:
return
- property counts: ndarray
counts per channel
- Type:
return
- property exposure: float
Exposure in seconds
- Returns:
exposure
- classmethod from_pandas(pandas_dataframe, exposure, scale_factor=1.0, is_poisson=False, mission=None, instrument=None)
Build a spectrum from data contained within a pandas data frame.
The required columns are:
‘emin’: low energy bin edge ‘emax’: high energy bin edge ‘counts’: the counts in each bin
Optional column names are:
‘count_errors’: errors on the counts for non-Poisson data ‘sys_errors’: systematic error per channel ‘quality’ list of 3ML quality flags ‘good’, ‘warn’, ‘bad’
- Parameters:
pandas_dataframe – data frame containing information to be read into spectrum
exposure – the exposure of the spectrum
scale_factor – the scale factor of the spectrum
is_poisson – if the data are Poisson distributed
mission – (optional) the mission name
instrument – (optional) the instrument name
- Returns:
- classmethod from_time_series(time_series, use_poly=False, from_model=False, **kwargs)
- Parameters:
time_series
use_poly
- Returns:
- property instrument: str
- property is_poisson: bool
- property mission: str
- property n_channel: int
- property n_channels: int
- property rate_errors: ndarray | None
If the spectrum has no Poisson error (POISSER is False in the header), this will return the STAT_ERR column :return: errors on the rates
- property rates: ndarray
rates per channel
- Type:
return
- property scale_factor: float
- property sys_errors: ndarray
Systematic errors per channel. This is nonzero only if the SYS_ERR column is present in the input file.
- Returns:
the systematic errors stored in the input spectrum
- to_pandas(use_rate=True)
make a pandas table from the spectrum.
- Parameters:
use_rate – if the table should use rates or counts
- Returns:
- property total_count: float
total counts
- Type:
return
- property total_count_error: float | None
total count error
- Type:
return
- property total_rate: float
total rate
- Type:
return
- property total_rate_error: float
total rate error
- Type:
return
- property tstart: float
- property tstop: float
- class threeML.utils.spectrum.binned_spectrum.BinnedSpectrumWithDispersion(counts, exposure, response: InstrumentResponse, count_errors: ndarray | None = None, sys_errors: ndarray | None = None, quality=None, scale_factor: float = 1.0, is_poisson: bool = False, mission: str | None = None, instrument: str | None = None, tstart: float | None = None, tstop: float | None = None)
Bases:
BinnedSpectrum
- clone(new_counts=None, new_count_errors=None, new_sys_errors=None, new_exposure=None, new_scale_factor=None)
make a new spectrum with new counts and errors and all other parameters the same
- Parameters:
new_sys_errors
new_exposure
new_scale_factor
new_counts – new counts for the spectrum
new_count_errors – new errors from the spectrum
- Returns:
- classmethod from_time_series(time_series, response=None, use_poly=False, extract=False)
- Parameters:
time_series
use_poly
- Returns:
- property response: InstrumentResponse
- class threeML.utils.spectrum.binned_spectrum.Channel(start: float, stop: float, swap_if_inverted: bool = False)
Bases:
Interval
- property channel_width
- class threeML.utils.spectrum.binned_spectrum.ChannelSet(list_of_intervals=())
Bases:
IntervalSet
- property channels_widths
- classmethod from_instrument_response(instrument_response)
Build EBOUNDS interval from an instrument response
- Parameters:
instrument_response
- Returns:
- class threeML.utils.spectrum.binned_spectrum.Quality(quality: ndarray)
Bases:
object
- property bad: ndarray
- classmethod create_all_good(n_channels)
construct a quality object with all good channels :param n_channels: :return:
- classmethod from_ogip(ogip_quality)
Read in quality from an OGIP file
- Parameters:
cls
ogip_quality
- Returns:
- get_slice(idx)
- property good: ndarray
- property n_elements: int
- to_ogip() ndarray
makes a quality array following the OGIP standards: 0 = good 2 = warn 5 = bad
- Returns:
- property warn: ndarray