SpectrumDataset#

class gammapy.datasets.SpectrumDataset[source]#

Bases: PlotMixin, MapDataset

Main dataset for spectrum fitting (1D analysis).

It bundles together binned counts, background, IRFs into RegionNDMap (a Map with only one spatial bin). A safe mask and a fit mask can be added to exclude bins during the analysis. If models are assigned to it, it can compute the predicted number of counts and the statistic function, here the Cash statistic (see cash).

For more information see Datasets (DL4).

Attributes Summary

tag

Methods Summary

create(geom[, energy_axis_true, migra_axis, ...])

Create a SpectrumDataset object with zero filled maps.

cutout(*args, **kwargs)

Not supported for SpectrumDataset.

plot_residuals_spatial(*args, **kwargs)

Not supported for SpectrumDataset.

to_spectrum_dataset(*args, **kwargs)

Not supported for SpectrumDataset.

Attributes Documentation

tag = 'SpectrumDataset'#

Methods Documentation

classmethod create(geom, energy_axis_true=None, migra_axis=None, reference_time='2000-01-01', name=None, meta_table=None, **kwargs)[source]#

Create a SpectrumDataset object with zero filled maps.

Parameters:
geomRegionGeom

Reference target geometry in reco energy, used for counts and background maps.

energy_axis_trueMapAxis, optional

True energy axis used for IRF maps. Default is None.

migra_axisMapAxis, optional

If set, this provides the migration axis for the energy dispersion map. If not set, an EDispKernelMap is produced instead. Default is None.

reference_timeTime

The reference time to use in GTI definition. Default is “2000-01-01”.

namestr, optional

Name of the returned dataset. Default is None.

meta_tableTable, optional

Table listing information on observations used to create the dataset. One line per observation for stacked datasets. Default is None.

Returns:
empty_mapsSpectrumDataset

A SpectrumDataset containing zero filled maps.

Examples

>>> from gammapy.datasets import SpectrumDataset
>>> from gammapy.maps import RegionGeom, MapAxis
>>> energy_axis = MapAxis.from_energy_bounds(1.0, 10.0, 4, unit="TeV")
>>> energy_axis_true = MapAxis.from_energy_bounds(
...            0.5, 20, 10, unit="TeV", name="energy_true"
...        )
>>> geom = RegionGeom.create(
...            region=None,
...            axes=[energy_axis],
...        )
>>> empty = SpectrumDataset.create(geom=geom, energy_axis_true=energy_axis_true, name="empty")
cutout(*args, **kwargs)[source]#

Not supported for SpectrumDataset.

plot_residuals_spatial(*args, **kwargs)[source]#

Not supported for SpectrumDataset.

to_spectrum_dataset(*args, **kwargs)[source]#

Not supported for SpectrumDataset.

__init__(models=None, counts=None, exposure=None, background=None, psf=None, edisp=None, mask_safe=None, mask_fit=None, gti=None, meta_table=None, name=None, meta=None, stat_type='cash')#
classmethod __new__(*args, **kwargs)#