SpectrumDatasetOnOff¶
-
class
gammapy.spectrum.SpectrumDatasetOnOff(model=None, counts=None, counts_off=None, livetime=None, mask_fit=None, aeff=None, edisp=None, mask_safe=None)[source]¶ Bases:
gammapy.utils.fitting.DatasetCompute spectral model fit statistic on a ON OFF Spectrum.
Parameters: - model :
SpectralModel Fit model
- counts :
PHACountsSpectrum ON Counts spectrum
- counts_off :
PHACountsSpectrum OFF Counts spectrum
- livetime :
Quantity Livetime
- mask_fit :
array Mask to apply to the likelihood for fitting.
- aeff :
EffectiveAreaTable Effective area
- edisp :
EnergyDispersion Energy dispersion
- mask_safe :
array Mask defining the safe data range.
Attributes Summary
alphaExposure ratio between signal and background regions data_shapeShape of the counts data energy_rangeEnergy range defined by the safe mask. hi_thresholdHigh energy threshold livetimelo_thresholdLow energy threshold maskCombined fit and safe mask mask_safeThe mask defined by the counts PHACountsSpectrum modelobs_idThe observation ID of the dataset parameterstotal_statsReturn total SpectrumStatstotal_stats_safe_rangeReturn total SpectrumStatswithin the tresholdsMethods Summary
copy(self)A deep copy. excess(self)Excess (counts - alpha * counts_off) from_ogip_files(filename)Read SpectrumDatasetOnOfffrom OGIP files.likelihood(self)Total likelihood given the current model parameters. likelihood_per_bin(self)Likelihood per bin given the current model parameters npred(self)Predicted counts vector. peek(self[, figsize])Quick-look summary plots. plot_counts(self[, ax])Plot predicted and detected counts. plot_fit(self)Plot counts and residuals in two panels. plot_residuals(self[, ax])Plot residuals. read(filename)Read from file reset_thresholds(self)Reset energy thresholds (i.e. residuals(self)Residuals (npred - excess). set_fit_energy_range(self[, emin, emax])Set the energy range for the fit. stats_in_range(self, bin_min, bin_max)Compute stats for a range of energy bins. to_ogip_files(self[, outdir, use_sherpa, …])Write OGIP files. Attributes Documentation
-
alpha¶ Exposure ratio between signal and background regions
-
data_shape¶ Shape of the counts data
-
energy_range¶ Energy range defined by the safe mask.
-
hi_threshold¶ High energy threshold
-
livetime¶
-
lo_threshold¶ Low energy threshold
-
mask¶ Combined fit and safe mask
-
mask_safe¶ The mask defined by the counts PHACountsSpectrum
-
model¶
-
obs_id¶ The observation ID of the dataset
-
parameters¶
-
total_stats¶ Return total
SpectrumStats
-
total_stats_safe_range¶ Return total
SpectrumStatswithin the tresholds
Methods Documentation
-
copy(self)¶ A deep copy.
-
classmethod
from_ogip_files(filename)[source]¶ Read
SpectrumDatasetOnOfffrom OGIP files.BKG file, ARF, and RMF must be set in the PHA header and be present in the same folder.
Parameters: - filename : str
OGIP PHA file to read
-
likelihood(self)¶ Total likelihood given the current model parameters.
-
plot_counts(self, ax=None)[source]¶ Plot predicted and detected counts.
Parameters: - ax :
Axes Axes object.
Returns: - ax :
Axes Axes object.
- ax :
-
plot_fit(self)[source]¶ Plot counts and residuals in two panels.
Calls
plot_countsandplot_residuals.
-
plot_residuals(self, ax=None)[source]¶ Plot residuals.
Parameters: - ax :
Axes Axes object.
Returns: - ax :
Axes Axes object.
- ax :
-
classmethod
read(filename)[source]¶ Read from file
For now, filename is assumed to the name of a PHA file where BKG file, ARF, and RMF names must be set in the PHA header and be present in the same folder
Parameters: - filename : str
OGIP PHA file to read
-
set_fit_energy_range(self, emin=None, emax=None)[source]¶ Set the energy range for the fit.
Parameters:
-
stats_in_range(self, bin_min, bin_max)[source]¶ Compute stats for a range of energy bins.
Parameters: - bin_min, bin_max: int
Bins to include
Returns: - stats :
SpectrumStats Stacked stats
-
to_ogip_files(self, outdir=None, use_sherpa=False, overwrite=False)[source]¶ Write OGIP files.
If you want to use the written files with Sherpa you have to set the
use_sherpaflag. Then all files will be written in units ‘keV’ and ‘cm2’.Parameters: - outdir :
pathlib.Path output directory, default: pwd
- use_sherpa : bool, optional
Write Sherpa compliant files, default: False
- overwrite : bool
Overwrite existing files?
- outdir :
- model :