create_crab_spectral_model#

gammapy.modeling.models.create_crab_spectral_model(reference='meyer')[source]#

Create a Crab nebula reference spectral model.

The Crab nebula is often used as a standard candle in gamma-ray astronomy. Fluxes and sensitivities are often quoted relative to the Crab spectrum.

The following references are available:

Parameters
reference{‘meyer’, ‘hegra’, ‘hess_pl’, ‘hess_ecpl’, ‘magic_lp’, ‘magic_ecpl’}

Which reference to use for the spectral model.

Examples

Let’s first import what we need:

import astropy.units as u
from gammapy.modeling.models import PowerLaw, create_crab_spectral_model

Plot the ‘hess_ecpl’ reference Crab spectrum between 1 TeV and 100 TeV:

crab_hess_ecpl = create_crab_spectral_model('hess_ecpl')
crab_hess_ecpl.plot([1, 100] * u.TeV)

Use a reference crab spectrum as unit to measure a differential flux (at 10 TeV):

>>> pwl = PowerLawSpectralModel(index=2.3, amplitude=1e-12 * u.Unit('1 / (cm2 s TeV)'), reference=1 * u.TeV)
>>> crab = create_crab_spectral_model('hess_pl')
>>> energy = 10 * u.TeV
>>> dnde_cu = (pwl(energy) / crab(energy)).to('%')
>>> print(dnde_cu)
6.196991563774588 %

And the same for integral fluxes (between 1 and 10 TeV):

>>> # compute integral flux in crab units
>>> emin, emax = [1, 10] * u.TeV
>>> flux_int_cu = (pwl.integral(emin, emax) / crab.integral(emin, emax)).to('%')
>>> print(flux_int_cu)
3.535058216604496 %