Log parabola spectral norm model#

This model parametrises a log parabola spectral correction with a norm parameter.

Example plot#

Here is an example plot of the model:

from astropy import units as u
import matplotlib.pyplot as plt
from gammapy.modeling.models import (
    LogParabolaNormSpectralModel,
    LogParabolaSpectralModel,
    Models,
    SkyModel,
    TemplateSpectralModel,
)

energy_bounds = [0.1, 100] * u.TeV

energy = [0.3, 1, 3, 10, 30] * u.TeV
values = [40, 30, 20, 10, 1] * u.Unit("TeV-1 s-1 cm-2")
template = TemplateSpectralModel(energy, values)
norm = LogParabolaNormSpectralModel(
    norm=1.5,
    reference=1 * u.TeV,
)

template.plot(energy_bounds=energy_bounds, label="Template model")
lp_norm = template * norm
lp_norm.plot(energy_bounds, label="Template model with LogParabola norm correction")
plt.legend(loc="best")
plt.grid(which="both")
plot logparabola norm spectral
/home/runner/work/gammapy-docs/gammapy-docs/gammapy/.tox/build_docs/lib/python3.9/site-packages/gammapy/modeling/models/spectral.py:1678: GammapyDeprecationWarning: The default alpha value changed from 2 to 0 since v1.2
  warnings.warn(
/home/runner/work/gammapy-docs/gammapy-docs/gammapy/.tox/build_docs/lib/python3.9/site-packages/gammapy/modeling/models/spectral.py:1684: GammapyDeprecationWarning: The default beta value changed from 1 to 0 since v1.2
  warnings.warn(

YAML representation#

Here is an example YAML file using the model:

model = SkyModel(spectral_model=lp_norm, name="log-parabola-norm-model")
models = Models([model])

print(models.to_yaml())
components:
-   name: log-parabola-norm-model
    type: SkyModel
    spectral:
        type: CompoundSpectralModel
        model1:
            type: TemplateSpectralModel
            parameters: []
            energy:
                data:
                - 0.3
                - 1.0
                - 3.0
                - 10.0
                - 30.0
                unit: TeV
            values:
                data:
                - 40.0
                - 30.0
                - 20.0
                - 10.0
                - 1.0
                unit: 1 / (cm2 s TeV)
        model2:
            type: LogParabolaNormSpectralModel
            parameters:
            -   name: norm
                value: 1.5
            -   name: reference
                value: 1.0
                unit: TeV
            -   name: alpha
                value: 0.0
            -   name: beta
                value: 0.0
        operator: mul
metadata:
    creator: Gammapy 1.3.dev198+g3e7db144f
    date: '2024-04-26T21:23:01.208106'
    origin: null

Gallery generated by Sphinx-Gallery