Note

You are not reading the most up to date version of Gammapy documentation.
Access the latest stable version v1.3 or the list of Gammapy releases.

Template Spatial Model

This is a spatial model based on a 2D sky map provided as a template.

Example plot

Here is an example plot of the model:

from gammapy.maps import Map
from gammapy.modeling.models import (
    Models,
    PowerLawSpectralModel,
    SkyModel,
    TemplateSpatialModel,
)

filename = "$GAMMAPY_DATA/catalogs/fermi/Extended_archive_v18/Templates/RXJ1713_2016_250GeV.fits"

m = Map.read(filename)
model = TemplateSpatialModel(m)

model.plot(add_cbar=True)
../../../_images/sphx_glr_plot_template_001.png

Out:

/Users/terrier/Code/anaconda3/envs/gammapy-dev/lib/python3.7/site-packages/astropy/wcs/wcs.py:466: FITSFixedWarning: RADECSYS= 'FK5'
the RADECSYS keyword is deprecated, use RADESYSa.
  colsel=colsel)
/Users/terrier/Code/anaconda3/envs/gammapy-dev/lib/python3.7/site-packages/astropy/wcs/wcs.py:682: FITSFixedWarning: 'datfix' made the change 'Invalid DATE-OBS format ' ' is too short'.
  FITSFixedWarning)
/Users/terrier/Code/anaconda3/envs/gammapy-dev/lib/python3.7/site-packages/astropy/wcs/wcs.py:682: FITSFixedWarning: 'celfix' made the change 'Success'.
  FITSFixedWarning)

YAML representation

Here is an example YAML file using the model:

pwl = PowerLawSpectralModel()
template = TemplateSpatialModel(m)

model = SkyModel(spectral_model=pwl, spatial_model=template, name="pwl-template-model")
models = Models([model])

print(models.to_yaml())

Out:

components:
-   name: pwl-template-model
    type: SkyModel
    spectral:
        type: PowerLawSpectralModel
        parameters:
        - {name: index, value: 2.0, unit: '', min: .nan, max: .nan, frozen: false,
            error: 0}
        - {name: amplitude, value: 1.0e-12, unit: cm-2 s-1 TeV-1, min: .nan, max: .nan,
            frozen: false, error: 0}
        - {name: reference, value: 1.0, unit: TeV, min: .nan, max: .nan, frozen: true,
            error: 0}
    spatial:
        type: TemplateSpatialModel
        frame: fk5
        parameters:
        - {name: norm, value: 1.0, unit: '', min: .nan, max: .nan, frozen: false,
            error: 0}
        filename: null
        normalize: true

Gallery generated by Sphinx-Gallery