.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "user-guide/model-gallery/spectral/plot_exp_cutoff_powerlaw_norm_spectral.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. or to run this example in your browser via Binder .. rst-class:: sphx-glr-example-title .. _sphx_glr_user-guide_model-gallery_spectral_plot_exp_cutoff_powerlaw_norm_spectral.py: .. _exp-cutoff-powerlaw-norm-spectral-model: Exponential cutoff power law norm spectral model ================================================ This model parametrises a cutoff power law spectral correction with a norm parameter. .. GENERATED FROM PYTHON SOURCE LINES 12-15 Example plot ------------ Here is an example plot of the model: .. GENERATED FROM PYTHON SOURCE LINES 15-43 .. code-block:: Python from astropy import units as u import matplotlib.pyplot as plt from gammapy.modeling.models import ( ExpCutoffPowerLawNormSpectralModel, 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 = ExpCutoffPowerLawNormSpectralModel( norm=2, reference=1 * u.TeV, ) template.plot(energy_bounds=energy_bounds, label="Template model") ecpl_norm = template * norm ecpl_norm.plot( energy_bounds, label="Template model with ExpCutoffPowerLaw norm correction" ) plt.legend(loc="best") plt.grid(which="both") .. image-sg:: /user-guide/model-gallery/spectral/images/sphx_glr_plot_exp_cutoff_powerlaw_norm_spectral_001.png :alt: plot exp cutoff powerlaw norm spectral :srcset: /user-guide/model-gallery/spectral/images/sphx_glr_plot_exp_cutoff_powerlaw_norm_spectral_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none /home/runner/work/gammapy-docs/gammapy-docs/gammapy/.tox/build_docs/lib/python3.9/site-packages/gammapy/modeling/models/spectral.py:1394: GammapyDeprecationWarning: The default index value changed from 1.5 to 0 since v1.3 warnings.warn( .. GENERATED FROM PYTHON SOURCE LINES 44-47 YAML representation ------------------- Here is an example YAML file using the model: .. GENERATED FROM PYTHON SOURCE LINES 47-52 .. code-block:: Python model = SkyModel(spectral_model=ecpl_norm, name="exp-cutoff-power-law-norm-model") models = Models([model]) print(models.to_yaml()) .. rst-class:: sphx-glr-script-out .. code-block:: none components: - name: exp-cutoff-power-law-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: ExpCutoffPowerLawNormSpectralModel parameters: - name: index value: 0.0 - name: norm value: 2.0 - name: reference value: 1.0 unit: TeV - name: lambda_ value: 0.1 unit: TeV-1 - name: alpha value: 1.0 operator: mul metadata: creator: Gammapy 1.3 date: '2024-11-26T10:08:52.198617' origin: null .. _sphx_glr_download_user-guide_model-gallery_spectral_plot_exp_cutoff_powerlaw_norm_spectral.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/gammapy/gammapy-webpage/v1.3?urlpath=lab/tree/notebooks/1.3/user-guide/model-gallery/spectral/plot_exp_cutoff_powerlaw_norm_spectral.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_exp_cutoff_powerlaw_norm_spectral.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_exp_cutoff_powerlaw_norm_spectral.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_exp_cutoff_powerlaw_norm_spectral.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_