.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "user-guide/model-gallery/spatial/plot_shell.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_spatial_plot_shell.py: .. _shell-spatial-model: Shell spatial model =================== This is a spatial model parametrizing a projected radiating shell. The shell spatial model is defined by the following equations: .. math:: \phi(lon, lat) = \frac{3}{2 \pi (r_{out}^3 - r_{in}^3)} \cdot \begin{cases} \sqrt{r_{out}^2 - \theta^2} - \sqrt{r_{in}^2 - \theta^2} & \text{for } \theta \lt r_{in} \\ \sqrt{r_{out}^2 - \theta^2} & \text{for } r_{in} \leq \theta \lt r_{out} \\ 0 & \text{for } \theta > r_{out} \end{cases} where :math:`\theta` is the sky separation and :math:`r_{\text{out}} = r_{\text{in}}` + width Note that the normalization is a small angle approximation, although that approximation is still very good even for 10 deg radius shells. .. GENERATED FROM PYTHON SOURCE LINES 29-32 Example plot ------------ Here is an example plot of the model: .. GENERATED FROM PYTHON SOURCE LINES 32-50 .. code-block:: Python from gammapy.modeling.models import ( Models, PowerLawSpectralModel, ShellSpatialModel, SkyModel, ) model = ShellSpatialModel( lon_0="10 deg", lat_0="20 deg", radius="2 deg", width="0.5 deg", frame="galactic", ) model.plot(add_cbar=True) .. image-sg:: /user-guide/model-gallery/spatial/images/sphx_glr_plot_shell_001.png :alt: plot shell :srcset: /user-guide/model-gallery/spatial/images/sphx_glr_plot_shell_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 51-54 YAML representation ------------------- Here is an example YAML file using the model: .. GENERATED FROM PYTHON SOURCE LINES 54-62 .. code-block:: Python pwl = PowerLawSpectralModel() shell = ShellSpatialModel() model = SkyModel(spectral_model=pwl, spatial_model=shell, name="pwl-shell-model") models = Models([model]) print(models.to_yaml()) .. rst-class:: sphx-glr-script-out .. code-block:: none components: - name: pwl-shell-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 spatial: type: ShellSpatialModel frame: icrs parameters: - name: lon_0 value: 0.0 unit: deg - name: lat_0 value: 0.0 unit: deg - name: radius value: 1.0 unit: deg - name: width value: 0.2 unit: deg metadata: creator: Gammapy 1.3.dev241+g0271bebfc date: '2024-05-03T15:02:20.746088' origin: null .. _sphx_glr_download_user-guide_model-gallery_spatial_plot_shell.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/main?urlpath=lab/tree/notebooks/dev/user-guide/model-gallery/spatial/plot_shell.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_shell.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_shell.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_