CrabSpectrum¶
-
class
gammapy.spectrum.
CrabSpectrum
(reference='meyer')[source]¶ Bases:
object
Crab spectral model.
The following references are available:
- ‘meyer’, 2010arXiv1008.4524M
- ‘hegra’, 2004ApJ...614..897A
- ‘hess_pl’, 2006A&A...457..899A
- ‘hess_ecpl’, 2006A&A...457..899A
Parameters: reference : {‘meyer’, ‘hegra’, ‘hess_pl’, ‘hess_ecpl’}
Which reference to use for the spectral model.
Examples
Plot the ‘hess_ecpl’ reference crab spectrum between 1 TeV and 100 TeV:
>>> from gammapy.spectrum import CrabSpectrum >>> import astropy.units as u >>> crab_hess_ecpl = CrabSpectrum('hess_ecpl') >>> crab_hess_ecpl.model.plot([1, 100] * u.TeV)
Use a reference crab spectrum as unit to measure flux:
>>> from astropy import units as u >>> from gammapy.spectrum import CrabSpectrum >>> from gammapy.spectrum.models import PowerLaw >>> >>> # define power law model >>> amplitude = 1e-12 * u.Unit('1 / (cm2 s TeV)') >>> index = 2.3 >>> reference = 1 * u.TeV >>> pwl = PowerLaw(index, amplitude, reference) >>> >>> # define crab reference >>> crab = CrabSpectrum('hess_pl').model >>> >>> # compute flux at 10 TeV in crab units >>> energy = 10 * u.TeV >>> flux_cu = (pwl(energy) / crab(energy)).to('%') >>> print(flux_cu) 6.19699156377 %
And the same for integral fluxes:
>>> # 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.5350582166 %