Constant Spatial Model

This model is a spatially constant model.

Example plot

Here is an example plot of the model:

from gammapy.maps import WcsGeom
from gammapy.modeling.models import (
    ConstantSpatialModel,
    Models,
    PowerLawSpectralModel,
    SkyModel,
)

geom = WcsGeom.create(npix=(100, 100), binsz=0.1)
model = ConstantSpatialModel(value="42 sr-1")
model.plot(geom=geom, add_cbar=True)
../../../_images/sphx_glr_plot_constant_001.png

YAML representation

Here is an example YAML file using the model:

pwl = PowerLawSpectralModel()
constant = ConstantSpatialModel()

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

print(models.to_yaml())

Out:

components:
-   name: pwl-constant-model
    type: SkyModel
    spectral:
        type: PowerLawSpectralModel
        parameters:
        - {name: index, value: 2.0, unit: '', min: .nan, max: .nan, frozen: false}
        - {name: amplitude, value: 1.0e-12, unit: cm-2 s-1 TeV-1, min: .nan, max: .nan,
            frozen: false}
        - {name: reference, value: 1.0, unit: TeV, min: .nan, max: .nan, frozen: true}
    spatial:
        type: ConstantSpatialModel
        parameters:
        - {name: value, value: 1.0, unit: sr-1, min: .nan, max: .nan, frozen: true}

Gallery generated by Sphinx-Gallery