threeML.utils.spectrum package¶
Submodules¶
threeML.utils.spectrum.binned_spectrum module¶
-
class
threeML.utils.spectrum.binned_spectrum.
BinnedSpectrum
(counts, exposure, ebounds, count_errors=None, sys_errors=None, quality=None, scale_factor=1.0, is_poisson=False, mission=None, instrument=None, tstart=None, tstop=None)[source]¶ Bases:
threeML.utils.histogram.Histogram
-
clone
(new_counts=None, new_count_errors=None, new_exposure=None, new_scale_factor=None)[source]¶ 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
¶ - Returns
count error per channel
-
property
counts
¶ - Returns
counts per channel
-
property
exposure
¶ Exposure in seconds
- Returns
exposure
-
classmethod
from_pandas
(pandas_dataframe, exposure, scale_factor=1.0, is_poisson=False, mission=None, instrument=None)[source]¶ 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)[source]¶ - Parameters
time_series –
use_poly –
- Returns
-
property
instrument
¶
-
property
is_poisson
¶
-
property
mission
¶
-
property
n_channel
¶
-
property
n_channels
¶
-
property
quality
¶
-
property
rate_errors
¶ 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
¶ - Returns
rates per channel
-
property
scale_factor
¶
-
property
sys_errors
¶ 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)[source]¶ make a pandas table from the spectrum.
- Parameters
use_rate – if the table should use rates or counts
- Returns
-
property
total_count
¶ - Returns
total counts
-
property
total_count_error
¶ - Returns
total count error
-
property
total_rate
¶ - Returns
total rate
-
property
total_rate_error
¶ - Returns
total rate error
-
property
tstart
¶
-
property
tstop
¶
-
-
class
threeML.utils.spectrum.binned_spectrum.
BinnedSpectrumWithDispersion
(counts, exposure, response, count_errors=None, sys_errors=None, quality=None, scale_factor=1.0, is_poisson=False, mission=None, instrument=None, tstart=None, tstop=None)[source]¶ Bases:
threeML.utils.spectrum.binned_spectrum.BinnedSpectrum
-
clone
(new_counts=None, new_count_errors=None, new_sys_errors=None, new_exposure=None, new_scale_factor=None)[source]¶ 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)[source]¶ - Parameters
time_series –
use_poly –
- Returns
-
property
response
¶
-
-
class
threeML.utils.spectrum.binned_spectrum.
Channel
(start, stop, swap_if_inverted=False)[source]¶ Bases:
threeML.utils.interval.Interval
-
property
channel_width
¶
-
property
-
class
threeML.utils.spectrum.binned_spectrum.
ChannelSet
(list_of_intervals=())[source]¶ Bases:
threeML.utils.interval.IntervalSet
-
property
channels_widths
¶
-
property
-
class
threeML.utils.spectrum.binned_spectrum.
Quality
(quality)[source]¶ Bases:
object
-
property
bad
¶
-
classmethod
create_all_good
(n_channels)[source]¶ construct a quality object with all good channels :param n_channels: :return:
-
property
good
¶
-
property
n_elements
¶
-
to_ogip
()[source]¶ makes a quality array following the OGIP standards: 0 = good 2 = warn 5 = bad
- Returns
-
property
warn
¶
-
property
threeML.utils.spectrum.binned_spectrum_set module¶
-
class
threeML.utils.spectrum.binned_spectrum_set.
BinnedSpectrumSet
(binned_spectrum_list, reference_time=0.0, time_intervals=None)[source]¶ Bases:
object
-
property
count_errors_per_bin
¶
-
property
counts_per_bin
¶
-
property
exposure_per_bin
¶
-
property
n_channels
¶
-
property
quality_per_bin
¶
-
property
rate_errors_per_bin
¶
-
property
rates_per_bin
¶
-
property
reference_time
¶
-
property
sys_errors_per_bin
¶
-
property
time_intervals
¶
-
property
threeML.utils.spectrum.pha_spectrum module¶
-
class
threeML.utils.spectrum.pha_spectrum.
PHASpectrum
(pha_file_or_instance, spectrum_number=None, file_type='observed', rsp_file=None, arf_file=None)[source]¶ Bases:
threeML.utils.spectrum.binned_spectrum.BinnedSpectrumWithDispersion
-
property
ancillary_file
¶ Returns the ancillary file definied in the header, or None if there is none defined
- Returns
a path to a file, or None
-
property
background_file
¶ Returns the background file definied in the header, or None if there is none defined
- p
- return
a path to a file, or None
-
clone
(new_counts=None, new_count_errors=None, new_exposure=None, new_scale_factor=None)[source]¶ make a new spectrum with new counts and errors and all other parameters the same
- Parameters
new_exposure – the new exposure for the clone
new_scale_factor – the new scale factor for the clone
new_counts – new counts for the spectrum
new_count_errors – new errors from the spectrum
- Returns
new pha spectrum
-
property
filename
¶
-
classmethod
from_dispersion_spectrum
(dispersion_spectrum: threeML.utils.spectrum.binned_spectrum.BinnedSpectrumWithDispersion, file_type: str = 'observed') → threeML.utils.spectrum.pha_spectrum.PHASpectrum[source]¶
-
property
grouping
¶
-
property
response_file
¶ Returns the response file definied in the header, or None if there is none defined
- Returns
a path to a file, or None
-
property
scale_factor
¶ This is a scale factor (in the BACKSCAL keyword) which must be used to rescale background and source regions
- Returns
-
property
-
class
threeML.utils.spectrum.pha_spectrum.
PHASpectrumSet
(pha_file_or_instance, file_type='observed', rsp_file=None, arf_file=None)[source]¶ Bases:
threeML.utils.spectrum.binned_spectrum_set.BinnedSpectrumSet
-
property
ancillary_file
¶ Returns the ancillary file definied in the header, or None if there is none defined
- Returns
a path to a file, or None
-
property
background_file
¶ Returns the background file definied in the header, or None if there is none defined
- p
- return
a path to a file, or None
-
clone
(new_counts=None, new_count_errors=None)[source]¶ 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
new pha spectrum
-
property
filename
¶
-
classmethod
from_dispersion_spectrum
(dispersion_spectrum: threeML.utils.spectrum.binned_spectrum.BinnedSpectrumWithDispersion, file_type: str = 'observed') → threeML.utils.spectrum.pha_spectrum.PHASpectrum[source]¶
-
property
grouping
¶
-
property
response_file
¶ Returns the response file definied in the header, or None if there is none defined
- Returns
a path to a file, or None
-
property
scale_factor
¶ This is a scale factor (in the BACKSCAL keyword) which must be used to rescale background and source regions
- Returns
-
property
threeML.utils.spectrum.spectrum_likelihood module¶
-
class
threeML.utils.spectrum.spectrum_likelihood.
BinnedStatistic
(spectrum_plugin)[source]¶ Bases:
object
-
class
threeML.utils.spectrum.spectrum_likelihood.
GaussianObservedStatistic
(spectrum_plugin)[source]¶ Bases:
threeML.utils.spectrum.spectrum_likelihood.BinnedStatistic
-
class
threeML.utils.spectrum.spectrum_likelihood.
PoissonObservedGaussianBackgroundStatistic
(spectrum_plugin)[source]¶ Bases:
threeML.utils.spectrum.spectrum_likelihood.BinnedStatistic
-
class
threeML.utils.spectrum.spectrum_likelihood.
PoissonObservedIdealBackgroundStatistic
(spectrum_plugin)[source]¶ Bases:
threeML.utils.spectrum.spectrum_likelihood.BinnedStatistic
-
class
threeML.utils.spectrum.spectrum_likelihood.
PoissonObservedModeledBackgroundStatistic
(spectrum_plugin)[source]¶ Bases:
threeML.utils.spectrum.spectrum_likelihood.BinnedStatistic
-
property
synthetic_background_plugin
¶
-
property
-
class
threeML.utils.spectrum.spectrum_likelihood.
PoissonObservedNoBackgroundStatistic
(spectrum_plugin)[source]¶ Bases:
threeML.utils.spectrum.spectrum_likelihood.BinnedStatistic
-
class
threeML.utils.spectrum.spectrum_likelihood.
PoissonObservedPoissonBackgroundStatistic
(spectrum_plugin)[source]¶ Bases:
threeML.utils.spectrum.spectrum_likelihood.BinnedStatistic