<commit_before>"""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=3)

plt.title('Crab spectral energy distribution (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)')
plt.legend(loc='upper center', ncol=3)
plt.grid()
plt.loglog()
plt.show()
#plt.savefig('crab_mwl.png')<commit_msg>change of point size<commit_after>"""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=7)

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)')
plt.legend(loc='upper center', ncol=3)
plt.grid()
plt.loglog()
plt.show()
#plt.savefig('crab_mwl.png')
{'fraction_non_alphanumeric': 0.16845582163501238, 'fraction_numerical': 0.02477291494632535, 'mean_word_length': 5.19693094629156, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3262736', 'n_tokens_mistral': 1039, 'n_tokens_neox': 952, 'n_words': 203}