Absorption

class gammapy.modeling.models.Absorption(energy, param, data, filename=None, interp_kwargs=None)[source]

Bases: object

Gamma-ray absorption models.

Parameters:
energy : Quantity

Energy node values

param : Quantity

Parameter node values

data : Quantity

Model value

Examples

Create and plot EBL absorption models for a redshift of 0.5:

import matplotlib.pyplot as plt
import astropy.units as u
from gammapy.modeling.models import Absorption

# Load tables for z=0.5
redshift = 0.5
dominguez = Absorption.read_builtin('dominguez').table_model(redshift)
franceschini = Absorption.read_builtin('franceschini').table_model(redshift)
finke = Absorption.read_builtin('finke').table_model(redshift)

# start customised plot
energy_range = [0.08, 3] * u.TeV
ax = plt.gca()
opts = dict(energy_range=energy_range, energy_unit='TeV', ax=ax, flux_unit='')
franceschini.plot(label='Franceschini 2008', **opts)
finke.plot(label='Finke 2010', **opts)
dominguez.plot(label='Dominguez 2011', **opts)

# tune plot
ax.set_ylabel(r'Absorption coefficient [$\exp{(-\tau(E))}$]')
ax.set_xlim(energy_range.value)  # we get ride of units
ax.set_ylim([1.e-4, 2.])
ax.set_yscale('log')
ax.set_title('EBL models (z=' + str(redshift) + ')')
plt.grid(which='both')
plt.legend(loc='best') # legend

# show plot
plt.show()

(png, hires.png, pdf)

../_images/gammapy-modeling-models-Absorption-1.png

Attributes Summary

tag

Methods Summary

evaluate(self, energy, parameter) Evaluate model for energy and parameter value.
from_dict(data)
read(filename) Build object from an XSPEC model.
read_builtin(name) Read one of the built-in absorption models.
table_model(self, parameter) Table model for a given parameter (TemplateSpectralModel).
to_dict(self)

Attributes Documentation

tag = 'Absorption'

Methods Documentation

evaluate(self, energy, parameter)[source]

Evaluate model for energy and parameter value.

classmethod from_dict(data)[source]
classmethod read(filename)[source]

Build object from an XSPEC model.

Todo: Format of XSPEC binary files should be referenced at https://gamma-astro-data-formats.readthedocs.io/en/latest/

Parameters:
filename : str

File containing the model.

classmethod read_builtin(name)[source]

Read one of the built-in absorption models.

Parameters:
name : {‘franceschini’, ‘dominguez’, ‘finke’}

name of one of the available model in gammapy-data

References

[1]Franceschini et al., “Extragalactic optical-infrared background radiation, its time evolution and the cosmic photon-photon opacity”, Link
[2]Dominguez et al., ” Extragalactic background light inferred from AEGIS galaxy-SED-type fractions” Link
[3]Finke et al., “Modeling the Extragalactic Background Light from Stars and Dust” Link
table_model(self, parameter)[source]

Table model for a given parameter (TemplateSpectralModel).

Parameters:
parameter : float

Parameter value.

to_dict(self)[source]