EDispKernelMap#

class gammapy.irf.EDispKernelMap(edisp_kernel_map, exposure_map=None)[source]#

Bases: gammapy.irf.core.IRFMap

Energy dispersion kernel map.

Parameters
edisp_kernel_mapMap

The input energy dispersion kernel map. Should be a Map with 2 non spatial axes. Reconstructed and and true energy axes should be given in this specific order.

exposure_mapMap, optional

Associated exposure map. Needs to have a consistent map geometry.

Attributes Summary

edisp_map

mask_safe_image

Mask safe for the map

required_axes

tag

Methods Summary

copy()

Copy IRF map

cutout(position, width[, mode])

Cutout IRF map.

downsample(factor[, axis_name, weights])

Downsample the spatial dimension by a given factor.

from_diagonal_response(energy_axis, ...[, geom])

Create an energy dispersion map with diagonal response.

from_edisp_kernel(edisp[, geom])

Create an energy dispersion map from the input 1D kernel.

from_gauss(energy_axis, energy_axis_true, ...)

Create an energy dispersion map from the input 1D kernel.

from_geom(geom)

Create edisp map from geom.

from_hdulist(hdulist[, hdu, hdu_bands, ...])

Create from HDUList.

get_edisp_kernel([position, energy_axis])

Get energy dispersion at a given position.

peek([figsize])

Quick-look summary plots.

read(filename[, format, hdu])

Read an IRF_map from file and create corresponding object"

resample_energy_axis(energy_axis[, weights])

Returns a resampled EdispKernelMap

slice_by_idx(slices)

Slice sub dataset.

stack(other[, weights, nan_to_num])

Stack IRF map with another one in place.

to_hdulist([format])

Convert to HDUList.

to_image([weights])

"Return a 2D EdispKernelMap by summing over the reconstructed energy axis.

to_region_nd_map(region)

Extract IRFMap in a given region or position

write(filename[, overwrite, format])

Write IRF map to fits

Attributes Documentation

edisp_map#
mask_safe_image#

Mask safe for the map

required_axes = ['energy', 'energy_true']#
tag = 'edisp_kernel_map'#

Methods Documentation

copy()#

Copy IRF map

cutout(position, width, mode='trim')#

Cutout IRF map.

Parameters
positionSkyCoord

Center position of the cutout region.

widthtuple of Angle

Angular sizes of the region in (lon, lat) in that specific order. If only one value is passed, a square region is extracted.

mode{‘trim’, ‘partial’, ‘strict’}

Mode option for Cutout2D, for details see Cutout2D.

Returns
cutoutIRFMap

Cutout IRF map.

downsample(factor, axis_name=None, weights=None)#

Downsample the spatial dimension by a given factor.

Parameters
factorint

Downsampling factor.

axis_namestr

Which axis to downsample. By default spatial axes are downsampled.

weightsMap

Map with weights downsampling.

Returns
mapIRFMap

Downsampled irf map.

classmethod from_diagonal_response(energy_axis, energy_axis_true, geom=None)[source]#

Create an energy dispersion map with diagonal response.

Parameters
energy_axisMapAxis

Energy axis.

energy_axis_trueMapAxis

True energy axis

geomGeom

The (2D) geom object to use. Default creates an all sky geometry with 2 bins.

Returns
edisp_mapEDispKernelMap

Energy dispersion kernel map.

classmethod from_edisp_kernel(edisp, geom=None)[source]#

Create an energy dispersion map from the input 1D kernel.

The kernel will be duplicated over all spatial bins.

Parameters
edispEDispKernel

the input 1D kernel.

geomGeom

The (2D) geom object to use. Default creates an all sky geometry with 2 bins.

Returns
edisp_mapEDispKernelMap

Energy dispersion kernel map.

classmethod from_gauss(energy_axis, energy_axis_true, sigma, bias, pdf_threshold=1e-06, geom=None)[source]#

Create an energy dispersion map from the input 1D kernel.

The kernel will be duplicated over all spatial bins.

Parameters
energy_axis_trueQuantity

Bin edges of true energy axis

energy_axisQuantity

Bin edges of reconstructed energy axis

biasfloat or ndarray

Center of Gaussian energy dispersion, bias

sigmafloat or ndarray

RMS width of Gaussian energy dispersion, resolution

pdf_thresholdfloat, optional

Zero suppression threshold

geomGeom

The (2D) geom object to use. Default creates an all sky geometry with 2 bins.

Returns
edisp_mapEDispKernelMap

Energy dispersion kernel map.

classmethod from_geom(geom)[source]#

Create edisp map from geom.

By default a diagonal edisp matrix is created.

Parameters
geomGeom

Edisp map geometry.

Returns
edisp_mapEDispKernelMap

Energy dispersion kernel map.

classmethod from_hdulist(hdulist, hdu=None, hdu_bands=None, exposure_hdu=None, exposure_hdu_bands=None, format='gadf')#

Create from HDUList.

Parameters
hdulistHDUList

HDU list.

hdustr

Name or index of the HDU with the IRF map.

hdu_bandsstr

Name or index of the HDU with the IRF map BANDS table.

exposure_hdustr

Name or index of the HDU with the exposure map data.

exposure_hdu_bandsstr

Name or index of the HDU with the exposure map BANDS table.

format{“gadf”, “gtpsf”}

File format

Returns
irf_mapIRFMap

IRF map.

get_edisp_kernel(position=None, energy_axis=None)[source]#

Get energy dispersion at a given position.

Parameters
positionSkyCoord or SkyRegion

The target position. Should be a single coordinates

energy_axisMapAxis

Reconstructed energy axis, only used for checking.

Returns
edispEnergyDispersion

the energy dispersion (i.e. rmf object)

peek(figsize=(15, 5))[source]#

Quick-look summary plots. Plots corresponding to the center of the map.

Parameters
figsizetuple

Size of figure.

classmethod read(filename, format='gadf', hdu=None)#

Read an IRF_map from file and create corresponding object”

Parameters
filenamestr or Path

File name

format{“gadf”, “gtpsf”}

File format

hdustr or int

HDU location

Returns
irf_mapPSFMap, EDispMap or EDispKernelMap

IRF map

resample_energy_axis(energy_axis, weights=None)[source]#

Returns a resampled EdispKernelMap

Bins are grouped according to the edges of the reconstructed energy axis provided. The true energy is left unchanged.

Parameters
energy_axisMapAxis

The reco energy axis to use for the reco energy grouping

weights: `~gammapy.maps.Map`, optional

Weights to be applied

Returns
edispEDispKernelMap

Edisp kernel map

slice_by_idx(slices)#

Slice sub dataset.

The slicing only applies to the maps that define the corresponding axes.

Parameters
slicesdict

Dict of axes names and integers or slice object pairs. Contains one element for each non-spatial dimension. For integer indexing the corresponding axes is dropped from the map. Axes not specified in the dict are kept unchanged.

Returns
map_outIRFMap

Sliced irf map object.

stack(other, weights=None, nan_to_num=True)#

Stack IRF map with another one in place.

Parameters
otherIRFMap

IRF map to be stacked with this one.

weightsMap

Map with stacking weights.

nan_to_num: bool

Non-finite values are replaced by zero if True (default).

to_hdulist(format='gadf')#

Convert to HDUList.

Parameters
format{“gadf”, “gtpsf”}

File format

Returns
hdu_listHDUList

HDU list.

to_image(weights=None)[source]#

“Return a 2D EdispKernelMap by summing over the reconstructed energy axis.

Parameters
weights: `~gammapy.maps.Map`, optional

Weights to be applied

Returns
edispEDispKernelMap

Edisp kernel map

to_region_nd_map(region)#

Extract IRFMap in a given region or position

If a region is given a mean IRF is computed, if a position is given the IRF is interpolated.

Parameters
regionSkyRegion or SkyCoord

Region or position where to get the map.

Returns
irfIRFMap

IRF map with region geometry.

write(filename, overwrite=False, format='gadf')#

Write IRF map to fits

Parameters
filenamestr or Path

Filename to write to

overwritebool

Whether to overwrite

format{“gadf”, “gtpsf”}

File format