.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "modeling/gallery/spatial/plot_constant.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_modeling_gallery_spatial_plot_constant.py: .. _constant-spatial-model: Constant spatial model ====================== This model is a spatially constant model. .. GENERATED FROM PYTHON SOURCE LINES 11-14 Example plot ------------ Here is an example plot of the model: .. GENERATED FROM PYTHON SOURCE LINES 14-27 .. code-block:: default 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) .. image-sg:: /modeling/gallery/spatial/images/sphx_glr_plot_constant_001.png :alt: plot constant :srcset: /modeling/gallery/spatial/images/sphx_glr_plot_constant_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 28-31 YAML representation ------------------- Here is an example YAML file using the model: .. GENERATED FROM PYTHON SOURCE LINES 31-39 .. code-block:: default pwl = PowerLawSpectralModel() constant = ConstantSpatialModel() model = SkyModel(spectral_model=pwl, spatial_model=constant, name="pwl-constant-model") models = Models([model]) print(models.to_yaml()) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none components: - name: pwl-constant-model type: SkyModel spectral: type: PowerLawSpectralModel parameters: - name: index value: 2.0 - name: amplitude value: 1.0e-12 unit: cm-2 s-1 TeV-1 - name: reference value: 1.0 unit: TeV frozen: true spatial: type: ConstantSpatialModel parameters: [] .. _sphx_glr_download_modeling_gallery_spatial_plot_constant.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_constant.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_constant.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_