예제 #1
0
def plot_points():
    papers = [
        dict(tag='hegra', label='HEGRA (2004)'),
        dict(tag='magic', label='MAGIC (TODO)'),
        # 'veritas',
        dict(tag='hess', label='H.E.S.S. (2006)')
    ]
    table_all = load_crab_flux_points()
    # import IPython; IPython.embed()
    # Plot flux points
    for paper in papers:
        mask = table_all['paper'] == paper['tag']
        table = table_all[mask]
        print('paper: {}, points: {}'.format(paper, len(table)))
        x = table['energy'].to('TeV').data
        y = table['energy_flux'].data
        yerr_lo = table['energy_flux_err_lo'].data
        yerr_hi = table['energy_flux_err_hi'].data
        plt.errorbar(
            x,
            y,
            yerr=(yerr_lo, yerr_hi),
            linewidth=2,
            fmt='o',
            capsize=0,
            label=paper['label'],
        )
예제 #2
0
    def __init__(self):
        table = load_crab_flux_points(component='nebula')
        table = table[table['paper'] == 'fermi_33months']

        self.name = 'fermi'
        self.x = Quantity(table['energy']).to('TeV').value
        self.y = Quantity(table['energy_flux']).to('erg cm-2 s-1').value
        self.staterror = Quantity(table['energy_flux_err']).to('erg cm-2 s-1').value
예제 #3
0
"""Plot Crab pulsar and nebula spectral energy distribution (SED).

http://gammapy.readthedocs.org/en/latest/tutorials/crab_mwl_sed/index.html

"""
import numpy as np
import matplotlib.pyplot as plt
import astropy.units as u
from gammapy.datasets import load_crab_flux_points
from gammapy.spectrum import crab_flux

# Plot flux points
for component in ['pulsar', 'nebula']:
    table = load_crab_flux_points(component=component)
    x = table['energy'].data
    y = table['energy_flux'].data
    yerr_lo = table['energy_flux_err_lo'].data
    yerr_hi = table['energy_flux_err_hi'].data
    plt.errorbar(x, y, yerr=(yerr_lo, yerr_hi), fmt='o', label=component)

# Plot SED model
energy = np.logspace(2, 8, 100) * u.MeV
flux = u.Quantity(crab_flux(energy.to('TeV').value), 'cm^-2 s^-1 TeV^-1')
energy_flux = (energy ** 2 * flux).to('erg cm^-2 s^-1')
plt.plot(energy.value, energy_flux.value, label='Meyer (2010) model', lw=666)

plt.title('Crab (SED)')
plt.xlim((3e-14, 3e8))
plt.ylim((3e-13, 3e-7))
plt.xlabel('Energy (MeV)')
plt.ylabel('E^2 dN/dE (erg cm^-2 s^-1)')