MapDatasetMaker#

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

Bases: gammapy.makers.core.Maker

Make binned maps for a single IACT observation.

Parameters
selectionlist

List of str, selecting which maps to make. Available: ‘counts’, ‘exposure’, ‘background’, ‘psf’, ‘edisp’ By default, all maps are made.

background_oversamplingint

Background evaluation oversampling factor in energy.

background_interp_missing_data: bool

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

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 geom
>>> 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 info 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 geom.

observationObservation

Observation container.

Returns
backgroundMap

Background map.

static make_counts(geom, observation)[source]#

Make counts map.

NOTE for 1D analysis: if the Geom is built from a CircleSkyRegion, the latter will be directly used to extract the counts. If instead the Geom is built from a PointSkyRegion, the size of the ON region is taken from the RAD_MAX_2D table containing energy-dependent theta2 cuts.

Parameters
geomGeom

Reference map geom.

observationObservation

Observation container.

Returns
countsMap

Counts map.

make_edisp(geom, observation)[source]#

Make energy dispersion map.

Parameters
geomGeom

Reference geom.

observationObservation

Observation container.

Returns
edispEDispMap

Edisp map.

make_edisp_kernel(geom, observation)[source]#

Make energy dispersion kernel map.

Parameters
geomGeom

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

observationObservation

Observation container.

Returns
edispEDispKernelMap

EdispKernel map.

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

Make exposure map.

Parameters
geomGeom

Reference map geom.

observationObservation

Observation container.

Returns
exposureMap

Exposure map.

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

Make exposure map with irf geometry.

Parameters
geomGeom

Reference geom.

observationObservation

Observation container.

Returns
exposureMap

Exposure map.

static make_meta_table(observation)[source]#

Make info meta table.

Parameters
observationObservation

Observation

Returns
meta_table: Table
make_psf(geom, observation)[source]#

Make psf map.

Parameters
geomGeom

Reference geom.

observationObservation

Observation container.

Returns
psfPSFMap

Psf map.

run(dataset, observation)[source]#

Make map dataset.

Parameters
datasetMapDataset

Reference dataset.

observationObservation

Observation

Returns
datasetMapDataset

Map dataset.