TableModel

class gammapy.spectrum.models.TableModel(energy, values, amplitude=1, scale_logy=True)[source]

Bases: gammapy.spectrum.models.SpectralModel

A model generated from a table of energy and value arrays.

The units returned will be the units of the values array provided at initialization. The model will return values interpolated in log-space, returning 0 for energies outside of the limits of the provided energy array.

Class implementation follows closely what has been done in naima.models.TableModel

Parameters:

energy : Quantity array

Array of energies at which the model values are given

values : array

Array with the values of the model at energies energy.

amplitude : float

Model amplitude that is multiplied to the supplied arrays. Defaults to 1.

scale_logy : boolean

interpolation can be done linearly or in logarithm

Methods Summary

evaluate(energy, amplitude)
plot(energy_range[, ax, energy_unit, n_points]) Plot TableModel
read_xspec_model(filename, param) A Table containing absorbed values from a XSPEC model as a function of energy.

Methods Documentation

evaluate(energy, amplitude)[source]
plot(energy_range, ax=None, energy_unit='TeV', n_points=100, **kwargs)[source]

Plot TableModel

kwargs are forwarded to errorbar()

Parameters:

energy_range : Quantity

Plot range

ax : Axes, optional

Axis

energy_unit : str, Unit, optional

Unit of the energy axis

n_points : int, optional

Number of evaluation nodes

Returns:

ax : Axes, optional

Axis

classmethod read_xspec_model(filename, param)[source]

A Table containing absorbed values from a XSPEC model as a function of energy. Todo: Format of the file should be described and discussed in https://gamma-astro-data-formats.readthedocs.io/en/latest/index.html

Parameters:

filename : str

File containing the XSPEC model

param : float

Model parameter value

Examples

Fill table from an EBL model (Franceschini, 2008)

>>> from gammapy.spectrum.models import TableModel
>>> filename = '$GAMMAPY_EXTRA/datasets/ebl/ebl_franceschini.fits.gz'
>>> table_model = TableModel.read_xspec_model(filename=filename, param=0.3)