Example #1
0
def test_fermi_isotropic():
    filename = "$GAMMAPY_DATA/fermi_3fhl/iso_P8R2_SOURCE_V6_v06.txt"
    model = TemplateSpectralModel.read_fermi_isotropic_model(filename)
    assert_quantity_allclose(model(50 * u.GeV),
                             1.463 * u.Unit("1e-13 MeV-1 cm-2 s-1 sr-1"),
                             rtol=1e-3)
Example #2
0
plt.ylabel("Flux (cm-2 s-1 MeV-1 sr-1)")

# In[ ]:

# TODO: show how one can fix the extrapolate to high energy
# by computing and padding an extra plane e.g. at 1e3 TeV
# that corresponds to a linear extrapolation

# ## Isotropic diffuse background
#
# To load the isotropic diffuse model with Gammapy, use the [gammapy.modeling.models.TemplateSpectralModel](https://docs.gammapy.org/dev/api/gammapy.modeling.models.TemplateSpectralModel.html). We are using `'fill_value': 'extrapolate'` to extrapolate the model above 500 GeV:

# In[ ]:

diffuse_iso = TemplateSpectralModel.read_fermi_isotropic_model(
    filename="$GAMMAPY_DATA/fermi_3fhl/iso_P8R2_SOURCE_V6_v06.txt",
    interp_kwargs={"fill_value": None},
)

# We can plot the model in the energy range between 50 GeV and 2000 GeV:

# In[ ]:

erange = [50, 2000] * u.GeV
diffuse_iso.plot(erange, flux_unit="1 / (cm2 MeV s sr)")

# ## PSF
#
# Next we will tke a look at the PSF. It was computed using ``gtpsf``, in this case for the Galactic center position. Note that generally for Fermi-LAT, the PSF only varies little within a given regions of the sky, especially at high energies like what we have here. We use the [gammapy.irf.EnergyDependentTablePSF](https://docs.gammapy.org/dev/api/gammapy.irf.EnergyDependentTablePSF.html) class to load the PSF and use some of it's methods to get some information about it.

# In[ ]: