TemplateSpectralModel#
- class gammapy.modeling.models.TemplateSpectralModel[source]#
Bases:
SpectralModel
A model generated from a table of energy and value arrays.
For more information see Template spectral model.
- Parameters:
- energy
Quantity
Array of energies at which the model values are given
- values
ndarray
Array with the values of the model at energies
energy
.- interp_kwargsdict
Interpolation option passed to
ScaledRegularGridInterpolator
. By default, all values outside the interpolation range are set to NaN. If you want to apply linear extrapolation you can passinterp_kwargs={'extrapolate': True, 'method': 'linear'}
. If you want to choose the interpolation scaling applied to values, you can useinterp_kwargs={"values_scale": "log"}
.- metadict, optional
Meta information, meta[‘filename’] will be used for serialisation.
- energy
Attributes Summary
Methods Summary
evaluate
(energy)Evaluate the model (static function).
from_dict
(data, **kwargs)from_region_map
(map, **kwargs)Create model from region map.
read_xspec_model
(filename, param, **kwargs)Read XSPEC table model.
to_dict
([full_output])Create dictionary for YAML serialisation.
Attributes Documentation
- default_parameters = <gammapy.modeling.parameter.Parameters object>#
- tag = ['TemplateSpectralModel', 'template']#
Methods Documentation
- classmethod read_xspec_model(filename, param, **kwargs)[source]#
Read XSPEC table model.
The input is a table containing absorbed values from a XSPEC model as a function of energy.
- Parameters:
- filenamestr
File containing the XSPEC model.
- paramfloat
Model parameter value.
Examples
Fill table from an EBL model (Franceschini, 2008)
>>> from gammapy.modeling.models import TemplateSpectralModel >>> filename = '$GAMMAPY_DATA/ebl/ebl_franceschini.fits.gz' >>> table_model = TemplateSpectralModel.read_xspec_model(filename=filename, param=0.3)
- classmethod __new__(*args, **kwargs)#