apply_edisp#

gammapy.datasets.apply_edisp(input_map, edisp)[source]#

Apply energy dispersion to map. Requires “energy_true” axis.

Parameters:
input_mapMap

The map to be convolved with the energy dispersion. It must have an axis named “energy_true”.

edispEDispKernel

Energy dispersion matrix.

Returns:
mapMap

Map with energy dispersion applied.

Examples

>>> from gammapy.irf.edisp import EDispKernel
>>> from gammapy.datasets.utils import apply_edisp
>>> from gammapy.maps import MapAxis, Map
>>> import numpy as np
>>>
>>> axis = MapAxis.from_energy_bounds("1 TeV", "10 TeV", nbin=6, name="energy_true")
>>> m = Map.create(
...     skydir=(0.8, 0.8),
...     width=(1, 1),
...     binsz=0.02,
...     axes=[axis],
...     frame="galactic"
... )
>>> e_true = m.geom.axes[0]
>>> e_reco = MapAxis.from_energy_bounds("1 TeV", "10 TeV", nbin=3)
>>> edisp = EDispKernel.from_diagonal_response(energy_axis_true=e_true, energy_axis=e_reco)
>>> map_edisp = apply_edisp(m, edisp)
>>> print(map_edisp)
WcsNDMap

    geom  : WcsGeom
    axes  : ['lon', 'lat', 'energy']
    shape : (np.int64(50), np.int64(50), 3)
    ndim  : 3
    unit  :
    dtype : float64