.. 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_point.py:
.. _point-spatial-model:
Point Spatial Model
===================
This model is a delta function centered in *lon_0* and *lat_0* parameters provided:
.. math:: \phi(lon, lat) = \delta{(lon - lon_0, lat - lat_0)}
The model is defined on the celestial sphere in the coordinate frame provided by the user.
If the point source is not centered on a pixel, the flux is re-distributed
across 4 neighbouring pixels. This ensured that the center of mass position
is conserved.
Example plot
------------
Here is an example plot of the model:
.. code-block:: default
from astropy.coordinates import SkyCoord
from gammapy.maps import WcsGeom
from gammapy.modeling.models import (
Models,
PointSpatialModel,
PowerLawSpectralModel,
SkyModel,
)
model = PointSpatialModel(lon_0="0.01 deg", lat_0="0.01 deg", frame="galactic",)
geom = WcsGeom.create(
skydir=SkyCoord("0d 0d", frame="galactic"), width=(1, 1), binsz=0.1
)
model.plot(geom=geom, add_cbar=True)
.. image:: /modeling/gallery/spatial/images/sphx_glr_plot_point_001.png
:class: sphx-glr-single-img
YAML representation
-------------------
Here is an example YAML file using the model:
.. code-block:: default
pwl = PowerLawSpectralModel()
point = PointSpatialModel()
model = SkyModel(spectral_model=pwl, spatial_model=point, name="pwl-point-model")
models = Models([model])
print(models.to_yaml())
.. rst-class:: sphx-glr-script-out
Out:
.. code-block:: none
components:
- name: pwl-point-model
type: SkyModel
spectral:
type: PowerLawSpectralModel
parameters:
- {name: index, value: 2.0, unit: '', min: .nan, max: .nan, frozen: false,
error: 0}
- {name: amplitude, value: 1.0e-12, unit: cm-2 s-1 TeV-1, min: .nan, max: .nan,
frozen: false, error: 0}
- {name: reference, value: 1.0, unit: TeV, min: .nan, max: .nan, frozen: true,
error: 0}
spatial:
type: PointSpatialModel
frame: icrs
parameters:
- {name: lon_0, value: 0.0, unit: deg, min: .nan, max: .nan, frozen: false,
error: 0}
- {name: lat_0, value: 0.0, unit: deg, min: -90.0, max: 90.0, frozen: false,
error: 0}
.. _sphx_glr_download_modeling_gallery_spatial_plot_point.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_point.py `
.. container:: sphx-glr-download sphx-glr-download-jupyter
:download:`Download Jupyter notebook: plot_point.ipynb `
.. only:: html
.. rst-class:: sphx-glr-signature
`Gallery generated by Sphinx-Gallery `_