File: plot_shell.py

package info (click to toggle)
gammapy 2.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,800 kB
  • sloc: python: 81,999; makefile: 211; sh: 11; javascript: 10
file content (61 lines) | stat: -rw-r--r-- 1,519 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
r"""
.. _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.

"""

# %%
# Example plot
# ------------
# Here is an example plot of the model:

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)

# %%
# YAML representation
# -------------------
# Here is an example YAML file using the model:

pwl = PowerLawSpectralModel()
shell = ShellSpatialModel()

model = SkyModel(spectral_model=pwl, spatial_model=shell, name="pwl-shell-model")
models = Models([model])

print(models.to_yaml())