SpectrumDatasetOnOff#
- class gammapy.datasets.SpectrumDatasetOnOff[source]#
Bases:
PlotMixin
,MapDatasetOnOff
Spectrum dataset for 1D on-off likelihood fitting.
It bundles together the binned on and off counts, the binned IRFs as well as the on and off acceptances.
A fit mask can be added to exclude bins during the analysis.
It uses the Wstat statistic (see
wstat
).For more information see Datasets (DL4).
Attributes Summary
Methods Summary
cutout
(*args, **kwargs)Not supported for
SpectrumDatasetOnOff
.from_dict
(data, **kwargs)Create spectrum dataset from dictionary.
from_spectrum_dataset
(**kwargs)Create a SpectrumDatasetOnOff from a
SpectrumDataset
dataset.plot_residuals_spatial
(*args, **kwargs)Not supported for
SpectrumDatasetOnOff
.read
(filename[, format, checksum, name])Read from file.
to_dict
()Convert to dict for YAML serialization.
to_spectrum_dataset
([name])Convert a SpectrumDatasetOnOff to a SpectrumDataset.
write
(filename[, overwrite, format, checksum])Write spectrum dataset on off to file.
Attributes Documentation
- tag = 'SpectrumDatasetOnOff'#
Methods Documentation
- cutout(*args, **kwargs)[source]#
Not supported for
SpectrumDatasetOnOff
.
- classmethod from_dict(data, **kwargs)[source]#
Create spectrum dataset from dictionary.
Reads file from the disk as specified in the dict.
- Parameters:
- datadict
Dictionary containing data to create dataset from.
- Returns:
- dataset
SpectrumDatasetOnOff
Spectrum dataset on off.
- dataset
- classmethod from_spectrum_dataset(**kwargs)[source]#
Create a SpectrumDatasetOnOff from a
SpectrumDataset
dataset.- Parameters:
- dataset
SpectrumDataset
Spectrum dataset defining counts, edisp, exposure etc.
- acceptance
array
or float Relative background efficiency in the on region.
- acceptance_off
array
or float Relative background efficiency in the off region.
- counts_off
RegionNDMap
Off counts spectrum. If the dataset provides a background model, and no off counts are defined. The off counts are deferred from counts_off / alpha.
- dataset
- Returns:
- dataset
SpectrumDatasetOnOff
Spectrum dataset on off.
- dataset
- plot_residuals_spatial(*args, **kwargs)[source]#
Not supported for
SpectrumDatasetOnOff
.
- classmethod read(filename, format='ogip', checksum=False, name=None, **kwargs)[source]#
Read from file.
For OGIP formats, filename is the name of a PHA file. The BKG, ARF, and RMF file names must be set in the PHA header and the files must be present in the same folder. For details, see
OGIPDatasetReader.read
.For the GADF format, a MapDataset serialisation is used.
- Parameters:
- filename
Path
or str OGIP PHA file to read.
- format{“ogip”, “ogip-sherpa”, “gadf”}
Format to use. Default is “ogip”.
- checksumbool, optional
If True checks both DATASUM and CHECKSUM cards in the file headers. Default is False.
- name: str, optional
Name of the dataset. If None, dataset name will be set to the written one. Default is None.
- kwargsdict, optional
Keyword arguments passed to
MapDataset.read
.
- filename
- to_spectrum_dataset(name=None)[source]#
Convert a SpectrumDatasetOnOff to a SpectrumDataset.
The background model template is taken as alpha*counts_off.
- Parameters:
- namestr, optional
Name of the new dataset. Default is None.
- Returns:
- dataset
SpectrumDataset
SpectrumDataset with Cash statistic.
- dataset
- write(filename, overwrite=False, format='ogip', checksum=False)[source]#
Write spectrum dataset on off to file.
Can be serialised either as a
MapDataset
with aRegionGeom
following the GADF specifications, or as per the OGIP format. For OGIP formats specs, seeOGIPDatasetWriter
.- Parameters:
- filename
Path
or str Filename to write to.
- overwritebool, optional
Overwrite existing file. Default is False.
- format{“ogip”, “ogip-sherpa”, “gadf”}
Format to use. Default is “ogip”.
- checksumbool
When True adds both DATASUM and CHECKSUM cards to the headers written to the file. Default is False.
- filename
- __init__(models=None, counts=None, counts_off=None, acceptance=None, acceptance_off=None, exposure=None, mask_fit=None, psf=None, edisp=None, name=None, mask_safe=None, gti=None, meta_table=None, meta=None, stat_type='wstat')#
- classmethod __new__(*args, **kwargs)#