Piecewise norm spatial model#

This model parametrises a piecewise spatial correction with a free norm parameter at each fixed node in longitude, latitude and optionaly energy.

Example plot#

Here is an example plot of the model:

import numpy as np
from astropy import units as u
from gammapy.maps import MapCoord, WcsGeom
from gammapy.modeling.models import (
    FoVBackgroundModel,
    Models,
    PiecewiseNormSpatialModel,
)

geom = WcsGeom.create(skydir=(50, 0), npix=(120, 120), binsz=0.03, frame="galactic")
coords = MapCoord.create(geom.footprint)
coords["lon"] *= u.deg
coords["lat"] *= u.deg

model = PiecewiseNormSpatialModel(
    coords, norms=np.array([0.5, 3, 2, 1]), frame="galactic"
)

model.plot(geom=geom)
plot piecewise norm spatial
<WCSAxes: >

YAML representation#

Here is an example YAML file using the model:

bkg_model = FoVBackgroundModel(spatial_model=model, dataset_name="dataset")
models = Models([bkg_model])

print(models.to_yaml())
components:
-   type: FoVBackgroundModel
    datasets_names:
    - dataset
    spectral:
        type: PowerLawNormSpectralModel
        parameters:
        -   name: norm
            value: 1.0
        -   name: tilt
            value: 0.0
        -   name: reference
            value: 1.0
            unit: TeV
    spatial:
        type: PiecewiseNormSpatialModel
        frame: galactic
        parameters:
        -   name: norm_0
            value: 0.5
        -   name: norm_1
            value: 3.0
        -   name: norm_2
            value: 2.0
        -   name: norm_3
            value: 1.0
        lon:
            data:
            - 51.785
            - 51.785
            - 48.215
            - 48.215
            unit: deg
        lat:
            data:
            - -1.785
            - 1.785
            - 1.785
            - -1.785
            unit: deg

Gallery generated by Sphinx-Gallery