Constant Spectral Model

This model takes a constant value along the spectral range.

\[\phi(E) = k\]

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 ConstantSpectralModel, Models, SkyModel

energy_range = [0.1, 100] * u.TeV
model = ConstantSpectralModel(const="1 / (cm2 s TeV)")
model.plot(energy_range)
plt.grid(which="both")
../../../_images/sphx_glr_plot_constant_spectral_001.png

YAML representation

Here is an example YAML file using the model:

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

print(models.to_yaml())

Out:

components:
-   name: constant-model
    type: SkyModel
    spectral:
        type: ConstantSpectralModel
        parameters:
        - {name: const, value: 1.0, unit: cm-2 s-1 TeV-1, min: .nan, max: .nan, frozen: false,
            error: 0}

Gallery generated by Sphinx-Gallery