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:
energyQuantity

Array of energies at which the model values are given

valuesndarray

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 pass interp_kwargs={'extrapolate': True, 'method': 'linear'}. If you want to choose the interpolation scaling applied to values, you can use interp_kwargs={"values_scale": "log"}.

metadict, optional

Meta information, meta[‘filename’] will be used for serialisation.

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

evaluate(energy)[source]#

Evaluate the model (static function).

classmethod from_dict(data, **kwargs)[source]#
classmethod from_region_map(map, **kwargs)[source]#

Create model from region map.

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)
to_dict(full_output=False)[source]#

Create dictionary for YAML serialisation.

__init__(energy, values, interp_kwargs=None, meta=None)[source]#
classmethod __new__(*args, **kwargs)#