EnergyDispersion2D¶
-
class
gammapy.irf.
EnergyDispersion2D
(energy_axis_true, migra_axis, offset_axis, data, interp_kwargs=None, meta=None)[source]¶ Bases:
object
Offset-dependent energy dispersion matrix.
Data format specification: EDISP_2D
- Parameters
- energy_axis_true
MapAxis
True energy axis
- migra_axis
MapAxis
Energy migration axis
- offset_axis
MapAxis
Field of view offset axis
- data
ndarray
Energy dispersion probability density
- energy_axis_true
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_edisp_kernel(offset='1.2 deg', e_reco=energy, energy_true=energy)
Attributes Summary
Default Interpolation kwargs for
NDDataArray
.Methods Summary
from_gauss
(energy_true, migra, bias, sigma, …)Create Gaussian energy dispersion matrix (
EnergyDispersion2D
).from_hdulist
(hdulist[, hdu])Create from
HDUList
.from_table
(table)Create from
Table
.get_response
(offset, energy_true[, energy])Detector response R(Delta E_reco, E_true)
peek
([figsize])Quick-look summary plots.
plot_bias
([ax, offset, add_cbar])Plot migration as a function of true energy for a given offset.
plot_migration
([ax, offset, energy_true, migra])Plot energy dispersion for given offset and true energy.
read
(filename[, hdu])Read from FITS file.
to_edisp_kernel
(offset[, energy_true, energy])Detector response R(Delta E_reco, Delta E_true)
to_table
()Convert to
Table
.to_table_hdu
([name])Convert to
BinTable
.Attributes Documentation
-
default_interp_kwargs
= {'bounds_error': False, 'fill_value': None}¶ Default Interpolation kwargs for
NDDataArray
. Extrapolate.
-
tag
= 'edisp_2d'¶
Methods Documentation
-
classmethod
from_gauss
(energy_true, migra, bias, sigma, offset, pdf_threshold=1e-06)[source]¶ Create Gaussian energy dispersion matrix (
EnergyDispersion2D
).The output matrix will be Gaussian in (energy_true / energy).
The
bias
andsigma
should be either floats or arrays of same dimension thanenergy_true
.bias
refers to the mean value of themigra
distribution minus one, i.e.bias=0
means no bias.Note that, the output matrix is flat in offset.
- Parameters
- energy_true
Quantity
Bin edges of true energy axis
- migra
Quantity
Bin edges of migra axis
- biasfloat or
ndarray
Center of Gaussian energy dispersion, bias
- sigmafloat or
ndarray
RMS width of Gaussian energy dispersion, resolution
- offset
Quantity
Bin edges of offset
- pdf_thresholdfloat, optional
Zero suppression threshold
- energy_true
-
get_response
(offset, energy_true, energy=None)[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.
-
peek
(figsize=(15, 5))[source]¶ Quick-look summary plots.
- Parameters
- figsize(float, float)
Size of the resulting plot
-
plot_bias
(ax=None, offset=None, add_cbar=False, **kwargs)[source]¶ Plot migration as a function of true energy for a given offset.
- Parameters
- ax
Axes
, optional Axis
- offset
Angle
, optional Offset
- add_cbarbool
Add a colorbar to the plot.
- kwargsdict
Keyword arguments passed to
pcolormesh
.
- ax
- Returns
- ax
Axes
Axis
- ax
-
plot_migration
(ax=None, offset=None, energy_true=None, migra=None, **kwargs)[source]¶ Plot energy dispersion for given offset and true energy.
-
classmethod
read
(filename, hdu='edisp_2d')[source]¶ Read from FITS file.
- Parameters
- filenamestr
File name
-
to_edisp_kernel
(offset, energy_true=None, energy=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
- Returns
- edisp
EDispKernel
Energy dispersion matrix
- edisp