EnergyDispersion2D

class gammapy.irf.EnergyDispersion2D(e_true_lo, e_true_hi, migra_lo, migra_hi, offset_lo, offset_hi, data, interp_kwargs=None, meta=None)[source]

Bases: object

Offset-dependent energy dispersion matrix.

Data format specification: EDISP_2D

Parameters
e_true_lo, e_true_hiQuantity

True energy axis binning

migra_lo, migra_hindarray

Energy migration axis binning

offset_lo, offset_hiAngle

Field of view offset axis binning

datandarray

Energy dispersion probability density

See also

EnergyDispersion

Examples

Read energy dispersion IRF from disk:

>>> from gammapy.maps import MapAxis
>>> from gammapy.irf import EnergyDispersion2D
>>> filename = '$GAMMAPY_DATA/hess-dl3-dr1/data/hess_dl3_dr1_obs_id_020136.fits.gz'
>>> edisp2d = EnergyDispersion2D.read(filename, hdu="EDISP")

Create energy dispersion matrix (EnergyDispersion) for a given field of view offset and energy binning:

>>> energy = MapAxis.from_bounds(0.1, 20, nbin=60, unit="TeV", interp="log").edges
>>> edisp = edisp2d.to_energy_dispersion(offset='1.2 deg', e_reco=energy, e_true=energy)

Attributes Summary

default_interp_kwargs

Default Interpolation kwargs for NDDataArray.

Methods Summary

from_gauss(e_true, migra, bias, sigma, offset)

Create Gaussian energy dispersion matrix (EnergyDispersion2D).

from_hdulist(hdulist[, hdu])

Create from HDUList.

from_table(table)

Create from Table.

get_response(self, offset, e_true[, e_reco, …])

Detector response R(Delta E_reco, E_true)

peek(self[, figsize])

Quick-look summary plots.

plot_bias(self[, ax, offset, add_cbar])

Plot migration as a function of true energy for a given offset.

plot_migration(self[, ax, offset, e_true, migra])

Plot energy dispersion for given offset and true energy.

read(filename[, hdu])

Read from FITS file.

to_energy_dispersion(self, offset[, e_true, …])

Detector response R(Delta E_reco, Delta E_true)

to_fits(self[, name])

Convert to BinTable.

to_table(self)

Convert to Table.

Attributes Documentation

default_interp_kwargs = {'bounds_error': False, 'fill_value': None}

Default Interpolation kwargs for NDDataArray. Extrapolate.

Methods Documentation

classmethod from_gauss(e_true, migra, bias, sigma, offset, pdf_threshold=1e-06)[source]

Create Gaussian energy dispersion matrix (EnergyDispersion2D).

The output matrix will be Gaussian in (e_true / e_reco).

The bias and sigma should be either floats or arrays of same dimension than e_true. bias refers to the mean value of the migra distribution minus one, i.e. bias=0 means no bias.

Note that, the output matrix is flat in offset.

Parameters
e_trueQuantity

Bin edges of true energy axis

migraQuantity

Bin edges of migra axis

biasfloat or ndarray

Center of Gaussian energy dispersion, bias

sigmafloat or ndarray

RMS width of Gaussian energy dispersion, resolution

offsetQuantity

Bin edges of offset

pdf_thresholdfloat, optional

Zero suppression threshold

classmethod from_hdulist(hdulist, hdu='edisp_2d')[source]

Create from HDUList.

classmethod from_table(table)[source]

Create from Table.

get_response(self, offset, e_true, e_reco=None, migra_step=0.005)[source]

Detector response R(Delta E_reco, E_true)

Probability to reconstruct a given true energy in a given reconstructed energy band. In each reco bin, you integrate with a riemann sum over the default migra bin of your analysis.

Parameters
e_trueQuantity

True energy

e_recoQuantity, None

Reconstructed energy axis

offsetAngle

Offset

migra_stepfloat

Integration step in migration

Returns
rvndarray

Redistribution vector

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

Quick-look summary plots.

Parameters
figsize(float, float)

Size of the resulting plot

plot_bias(self, ax=None, offset=None, add_cbar=False, **kwargs)[source]

Plot migration as a function of true energy for a given offset.

Parameters
axAxes, optional

Axis

offsetAngle, optional

Offset

add_cbarbool

Add a colorbar to the plot.

kwargsdict

Keyword arguments passed to pcolormesh.

Returns
axAxes

Axis

plot_migration(self, ax=None, offset=None, e_true=None, migra=None, **kwargs)[source]

Plot energy dispersion for given offset and true energy.

Parameters
axAxes, optional

Axis

offsetAngle, optional

Offset

e_trueQuantity, optional

True energy

migrandarray, optional

Migration nodes

Returns
axAxes

Axis

classmethod read(filename, hdu='edisp_2d')[source]

Read from FITS file.

Parameters
filenamestr

File name

to_energy_dispersion(self, offset, e_true=None, e_reco=None)[source]

Detector response R(Delta E_reco, Delta E_true)

Probability to reconstruct an energy in a given true energy band in a given reconstructed energy band

Parameters
offsetAngle

Offset

e_trueQuantity, None

True energy axis

e_recoQuantity

Reconstructed energy axis

Returns
edispEnergyDispersion

Energy dispersion matrix

to_fits(self, name='ENERGY DISPERSION')[source]

Convert to BinTable.

to_table(self)[source]

Convert to Table.