EnergyDispersion¶
-
class
gammapy.irf.EnergyDispersion(e_true_lo, e_true_hi, e_reco_lo, e_reco_hi, data, interp_kwargs=None, meta=None)[source]¶ Bases:
objectEnergy dispersion matrix.
see RMF file
Parameters: e_true_lo :
QuantityLower bin edges of true energy axis
e_true_hi :
QuantityUpper bin edges of true energy axis
e_reco_lo :
QuantityLower bin edges of reconstruced energy axis
e_reco_hi :
QuantityUpper bin edges of reconstruced energy axis
data : array_like
2-dim energy dispersion matrix
Attributes Summary
default_interp_kwargsDefault Interpolation kwargs for NDDataArray.e_recoe_truepdf_matrixPDF matrix ndarrayMethods Summary
apply(data[, e_reco, e_true])Apply energy dispersion. from_gauss(e_true, e_reco[, sigma, ...])Create Gaussian EnergyDispersionmatrix.from_hdulist(hdulist[, hdu1, hdu2])Create EnergyDispersionobject fromHDUList.get_bias(e_true)Get reconstruction bias for a given true energy get_resolution(e_true)Get energy resolution for a given true energy pdf_in_safe_range(lo_threshold, hi_threshold)PDF matrix with bins outside threshold set to 0 plot_bias([ax])Plot reconstruction bias. plot_matrix([ax, show_energy, add_cbar])Plot PDF matrix. read(filename[, hdu1, hdu2])Read from file to_hdulist(**kwargs)Convert RM to FITS HDU list format. to_sherpa(name)Return DataARFto_table()Convert to Table.write(filename, **kwargs)Attributes Documentation
-
default_interp_kwargs= {'fill_value': 0, 'method': 'nearest', 'bounds_error': False}¶ Default Interpolation kwargs for
NDDataArray. Fill zeros and do not interpolate
-
e_reco¶
-
e_true¶
Methods Documentation
-
apply(data, e_reco=None, e_true=None)[source]¶ Apply energy dispersion.
Computes the matrix product of
data(which typically is model flux or counts in true energy bins) with the energy dispersion matrix.Parameters: data : array_like
1-dim data array.
Returns: convolved_data : array
1-dim data array after multiplication with the energy dispersion matrix
-
classmethod
from_gauss(e_true, e_reco, sigma=0.2, pdf_threshold=1e-06)[source]¶ Create Gaussian
EnergyDispersionmatrix.The output matrix will be Gaussian in log(e_true / e_reco)
TODO: extend to have a vector of bias various true energies. TODO: extend to have vector of resolution for various true energies. TODO: give formula: Gaussian in log(e_reco) TODO: add option to add poisson noise
Parameters: e_true :
Quantity,BinnedDataAxisBin edges of true energy axis
e_reco :
Quantity,BinnedDataAxisBin edges of reconstructed energy axis
sigma : float, optional
RMS width of Gaussian energy dispersion, resolution
pdf_threshold : float, optional
Zero suppression threshold
-
classmethod
from_hdulist(hdulist, hdu1='MATRIX', hdu2='EBOUNDS')[source]¶ Create
EnergyDispersionobject fromHDUList.Parameters: hdulist :
HDUListHDU list with
MATRIXandEBOUNDSextensions.hdu1 : str, optional
HDU containing the energy dispersion matrix, default: MATRIX
hdu2 : str, optional
HDU containing the energy axis information, default, EBOUNDS
-
get_bias(e_true)[source]¶ Get reconstruction bias for a given true energy
Bias is defined as
\[\frac{E_{reco}-E_{true}}{E_{true}}\]Parameters: e_true :
QuantityTrue energy
-
get_resolution(e_true)[source]¶ Get energy resolution for a given true energy
Resolution is the 1 sigma containment of the energy dispersion PDF.
Parameters: e_true :
QuantityTrue energy
-
pdf_in_safe_range(lo_threshold, hi_threshold)[source]¶ PDF matrix with bins outside threshold set to 0
Parameters: lo_threshold :
QuantityLow reco energy threshold
hi_threshold :
QuantityHigh reco energy threshold
-
plot_bias(ax=None, **kwargs)[source]¶ Plot reconstruction bias.
see
get_bias()Parameters: ax :
Axes, optionalAxis
-
plot_matrix(ax=None, show_energy=None, add_cbar=False, **kwargs)[source]¶ Plot PDF matrix.
Parameters: ax :
Axes, optionalAxis
show_energy :
Quantity, optionalShow energy, e.g. threshold, as vertical line
add_cbar : bool
Add a colorbar to the plot.
Returns: ax :
AxesAxis
-
classmethod
read(filename, hdu1='MATRIX', hdu2='EBOUNDS', **kwargs)[source]¶ Read from file
Parameters: filename :
Path, strFile to read
hdu1 : str, optional
HDU containing the energy dispersion matrix, default: MATRIX
hdu2 : str, optional
HDU containing the energy axis information, default, EBOUNDS
-
to_hdulist(**kwargs)[source]¶ Convert RM to FITS HDU list format.
Parameters: header :
HeaderHeader to be written in the fits file.
energy_unit : str
Unit in which the energy is written in the HDU list
Returns: hdulist :
HDUListRMF in HDU list format.
Notes
For more info on the RMF FITS file format see: http://heasarc.gsfc.nasa.gov/docs/heasarc/caldb/docs/summary/cal_gen_92_002_summary.html
-
to_table()[source]¶ Convert to
Table.The output table is in the OGIP RMF format. http://heasarc.gsfc.nasa.gov/docs/heasarc/caldb/docs/memos/cal_gen_92_002/cal_gen_92_002.html#Tab:1
-