MapDatasetMaker#

class gammapy.makers.MapDatasetMaker(selection=None, background_oversampling=None, background_interp_missing_data=True, background_pad_offset=True)[source]#

Bases: gammapy.makers.core.Maker

Make binned maps for a single IACT observation.

Parameters
selectionlist of str, optional

Select which maps to make, the available options are: ‘counts’, ‘exposure’, ‘background’, ‘psf’, ‘edisp’. By default, all maps are made.

background_oversamplingint

Background evaluation oversampling factor in energy.

background_interp_missing_databool, optional

Interpolate missing values in background 3d map. Default is True, have to be set to True for CTA IRF.

background_pad_offsetbool, optional

Pad one bin in offset for 2d background map. This avoids extrapolation at edges and use the nearest value. Default is True.

Examples

This example shows how to run the MapMaker for a single observation.

>>> from gammapy.data import DataStore
>>> from gammapy.datasets import MapDataset
>>> from gammapy.maps import WcsGeom, MapAxis
>>> from gammapy.makers import MapDatasetMaker
>>> # Load an observation
>>> data_store = DataStore.from_dir("$GAMMAPY_DATA/hess-dl3-dr1")
>>> obs = data_store.obs(23523)
>>> # Prepare the geometry
>>> 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 = WcsGeom.create(
...        skydir=(83.633, 22.014),
...        binsz=0.02,
...        width=(2, 2),
...        frame="icrs",
...        proj="CAR",
...        axes=[energy_axis],
...    )
>>> # Run the maker
>>> empty = MapDataset.create(geom=geom, energy_axis_true=energy_axis_true, name="empty")
>>> maker = MapDatasetMaker()
>>> dataset = maker.run(empty, obs)
>>> print(dataset)
MapDataset
----------

  Name                            : empty

  Total counts                    : 787
  Total background counts         : 684.52
  Total excess counts             : 102.48

  Predicted counts                : 684.52
  Predicted background counts     : 684.52
  Predicted excess counts         : nan

  Exposure min                    : 7.01e+07 m2 s
  Exposure max                    : 1.10e+09 m2 s

  Number of total bins            : 40000
  Number of fit bins              : 40000

  Fit statistic type              : cash
  Fit statistic value (-2 log(L)) : nan

  Number of models                : 0
  Number of parameters            : 0
  Number of free parameters       : 0

Attributes Summary

available_selection

tag

Methods Summary

make_background(geom, observation)

Make background map.

make_counts(geom, observation)

Make counts map.

make_edisp(geom, observation)

Make energy dispersion map.

make_edisp_kernel(geom, observation)

Make energy dispersion kernel map.

make_exposure(geom, observation[, ...])

Make exposure map.

make_exposure_irf(geom, observation[, ...])

Make exposure map with IRF geometry.

make_meta_table(observation)

Make information meta table.

make_psf(geom, observation)

Make PSF map.

run(dataset, observation)

Make map dataset.

Attributes Documentation

available_selection = ['counts', 'exposure', 'background', 'psf', 'edisp']#
tag = 'MapDatasetMaker'#

Methods Documentation

make_background(geom, observation)[source]#

Make background map.

Parameters
geomGeom

Reference geometry.

observationObservation

Observation container.

Returns
backgroundMap

Background map.

static make_counts(geom, observation)[source]#

Make counts map.

Parameters
geomGeom

Reference map geometry.

observationObservation

Observation container.

Returns
countsMap

Counts map.

make_edisp(geom, observation)[source]#

Make energy dispersion map.

Parameters
geomGeom

Reference geometry.

observationObservation

Observation container.

Returns
edispEDispMap

Energy dispersion map.

make_edisp_kernel(geom, observation)[source]#

Make energy dispersion kernel map.

Parameters
geomGeom

Reference geometry. Must contain “energy” and “energy_true” axes in that order.

observationObservation

Observation container.

Returns
edispEDispKernelMap

Energy dispersion kernel map.

static make_exposure(geom, observation, use_region_center=True)[source]#

Make exposure map.

Parameters
geomGeom

Reference map geometry.

observationObservation

Observation container.

use_region_centerbool, optional

For geom as a RegionGeom. If True, consider the values at the region center. If False, average over the whole region. Default is True.

Returns
exposureMap

Exposure map.

static make_exposure_irf(geom, observation, use_region_center=True)[source]#

Make exposure map with IRF geometry.

Parameters
geomGeom

Reference geometry.

observationObservation

Observation container.

use_region_centerbool, optional

For geom as a RegionGeom. If True, consider the values at the region center. If False, average over the whole region. Default is True.

Returns
exposureMap

Exposure map.

static make_meta_table(observation)[source]#

Make information meta table.

Parameters
observationObservation

Observation.

Returns
meta_tableTable

Meta table.

make_psf(geom, observation)[source]#

Make PSF map.

Parameters
geomGeom

Reference geometry.

observationObservation

Observation container.

Returns
psfPSFMap

PSF map.

run(dataset, observation)[source]#

Make map dataset.

Parameters
datasetMapDataset

Reference dataset.

observationObservation

Observation.

Returns
datasetMapDataset

Map dataset.