:orphan:
.. include:: ../references.txt
.. _tutorials:
=========
Tutorials
=========
**Notice :** it is
advised to first read :ref:`package_structure` of the User Guide before using the
tutorials.
This page lists the Gammapy tutorials that are available as `Jupyter`_ notebooks.
You can read them here, or execute them using a temporary cloud server in Binder.
To execute them locally, you have to first install Gammapy locally (see
:ref:`installation`) and download the tutorial notebooks and example datasets (see
:ref:`getting-started`). Once Gammapy is installed, remember that you can always
use ``gammapy info`` to check your setup.
Gammapy is a Python package built on `Numpy`_ and `Astropy`_, so to use it
effectively, you have to learn the basics. Many good free resources are
available, e.g. `A Whirlwind tour of Python`_, the `Python data science
handbook`_ and the `Astropy Hands-On Tutorial`_.
.. raw:: html
.. thumbnail-parent-div-open
.. thumbnail-parent-div-close
.. raw:: html
Introduction
============
The following three tutorials show different ways of how to use Gammapy to perform a complete data analysis,
from data selection to data reduction and finally modeling and fitting.
The first tutorial is an overview on how to perform a standard analysis workflow using the high level interface
in a configuration-driven approach, whilst the second deals with the same use-case using the low level API
and showing what is happening *under-the-hood*. The third tutorial shows a glimpse of how to handle different
basic data structures like event lists, source catalogs, sky maps, spectral models and flux points tables.
.. raw:: html
.. thumbnail-parent-div-open
.. raw:: html
.. only:: html
.. image:: /tutorials/starting/images/thumb/sphx_glr_overview_thumb.png
:alt:
:ref:`sphx_glr_tutorials_starting_overview.py`
.. raw:: html
Data structures
.. raw:: html
.. only:: html
.. image:: /tutorials/starting/images/thumb/sphx_glr_analysis_1_thumb.png
:alt:
:ref:`sphx_glr_tutorials_starting_analysis_1.py`
.. raw:: html
High level interface
.. raw:: html
.. only:: html
.. image:: /tutorials/starting/images/thumb/sphx_glr_analysis_2_thumb.png
:alt:
:ref:`sphx_glr_tutorials_starting_analysis_2.py`
.. raw:: html
Low level API
.. thumbnail-parent-div-close
.. raw:: html
.. toctree::
:hidden:
/tutorials/starting/overview
/tutorials/starting/analysis_1
/tutorials/starting/analysis_2
Data exploration
================
These tutorials show how to perform data exploration with Gammapy, providing an introduction to the CTA, HAWC,
H.E.S.S. and Fermi-LAT data and instrument response functions (IRFs). You will be able to explore and filter
event lists according to different criteria, as well as to get a quick look of the multidimensional IRFs files.
.. raw:: html
.. thumbnail-parent-div-open
.. raw:: html
.. only:: html
.. image:: /tutorials/data/images/thumb/sphx_glr_hess_thumb.png
:alt:
:ref:`sphx_glr_tutorials_data_hess.py`
.. raw:: html
H.E.S.S. with Gammapy
.. raw:: html
.. only:: html
.. image:: /tutorials/data/images/thumb/sphx_glr_cta_thumb.png
:alt:
:ref:`sphx_glr_tutorials_data_cta.py`
.. raw:: html
CTAO with Gammapy
.. raw:: html
.. only:: html
.. image:: /tutorials/data/images/thumb/sphx_glr_fermi_lat_thumb.png
:alt:
:ref:`sphx_glr_tutorials_data_fermi_lat.py`
.. raw:: html
Fermi-LAT with Gammapy
.. raw:: html
.. only:: html
.. image:: /tutorials/data/images/thumb/sphx_glr_hawc_thumb.png
:alt:
:ref:`sphx_glr_tutorials_data_hawc.py`
.. raw:: html
HAWC with Gammapy
.. thumbnail-parent-div-close
.. raw:: html
.. toctree::
:hidden:
/tutorials/data/hess
/tutorials/data/cta
/tutorials/data/fermi_lat
/tutorials/data/hawc
Data analysis
=============
The following set of tutorials are devoted to data analysis, and grouped according to the specific covered use
cases in spectral analysis and flux fitting, image and cube analysis modelling and fitting, as well as
time-dependent analysis with light-curves.
1D Spectral
-----------
.. raw:: html
.. thumbnail-parent-div-open
.. raw:: html
.. only:: html
.. image:: /tutorials/analysis-1d/images/thumb/sphx_glr_cta_sensitivity_thumb.png
:alt:
:ref:`sphx_glr_tutorials_analysis-1d_cta_sensitivity.py`
.. raw:: html
Point source sensitivity
.. raw:: html
.. only:: html
.. image:: /tutorials/analysis-1d/images/thumb/sphx_glr_spectral_analysis_thumb.png
:alt:
:ref:`sphx_glr_tutorials_analysis-1d_spectral_analysis.py`
.. raw:: html
Spectral analysis
.. raw:: html
.. only:: html
.. image:: /tutorials/analysis-1d/images/thumb/sphx_glr_spectral_analysis_hli_thumb.png
:alt:
:ref:`sphx_glr_tutorials_analysis-1d_spectral_analysis_hli.py`
.. raw:: html
Spectral analysis with the HLI
.. raw:: html
.. only:: html
.. image:: /tutorials/analysis-1d/images/thumb/sphx_glr_spectral_analysis_rad_max_thumb.png
:alt:
:ref:`sphx_glr_tutorials_analysis-1d_spectral_analysis_rad_max.py`
.. raw:: html
Spectral analysis with energy-dependent directional cuts
.. raw:: html
.. only:: html
.. image:: /tutorials/analysis-1d/images/thumb/sphx_glr_extended_source_spectral_analysis_thumb.png
:alt:
:ref:`sphx_glr_tutorials_analysis-1d_extended_source_spectral_analysis.py`
.. raw:: html
Spectral analysis of extended sources
.. raw:: html
.. only:: html
.. image:: /tutorials/analysis-1d/images/thumb/sphx_glr_spectrum_simulation_thumb.png
:alt:
:ref:`sphx_glr_tutorials_analysis-1d_spectrum_simulation.py`
.. raw:: html
1D spectrum simulation
.. raw:: html
.. only:: html
.. image:: /tutorials/analysis-1d/images/thumb/sphx_glr_sed_fitting_thumb.png
:alt:
:ref:`sphx_glr_tutorials_analysis-1d_sed_fitting.py`
.. raw:: html
Flux point fitting
.. raw:: html
.. only:: html
.. image:: /tutorials/analysis-1d/images/thumb/sphx_glr_ebl_thumb.png
:alt:
:ref:`sphx_glr_tutorials_analysis-1d_ebl.py`
.. raw:: html
Account for spectral absorption due to the EBL
.. thumbnail-parent-div-close
.. raw:: html
.. toctree::
:hidden:
/tutorials/analysis-1d/cta_sensitivity
/tutorials/analysis-1d/spectral_analysis
/tutorials/analysis-1d/spectral_analysis_hli
/tutorials/analysis-1d/spectral_analysis_rad_max
/tutorials/analysis-1d/extended_source_spectral_analysis
/tutorials/analysis-1d/spectrum_simulation
/tutorials/analysis-1d/sed_fitting
/tutorials/analysis-1d/ebl
2D Image
--------
.. raw:: html
.. thumbnail-parent-div-open
.. raw:: html
.. only:: html
.. image:: /tutorials/analysis-2d/images/thumb/sphx_glr_detect_thumb.png
:alt:
:ref:`sphx_glr_tutorials_analysis-2d_detect.py`
.. raw:: html
Source detection and significance maps
.. raw:: html
.. only:: html
.. image:: /tutorials/analysis-2d/images/thumb/sphx_glr_ring_background_thumb.png
:alt:
:ref:`sphx_glr_tutorials_analysis-2d_ring_background.py`
.. raw:: html
Ring background map
.. raw:: html
.. only:: html
.. image:: /tutorials/analysis-2d/images/thumb/sphx_glr_modeling_2D_thumb.png
:alt:
:ref:`sphx_glr_tutorials_analysis-2d_modeling_2D.py`
.. raw:: html
2D map fitting
.. thumbnail-parent-div-close
.. raw:: html
.. toctree::
:hidden:
/tutorials/analysis-2d/detect
/tutorials/analysis-2d/ring_background
/tutorials/analysis-2d/modeling_2D
3D Cube
-------
.. raw:: html
.. thumbnail-parent-div-open
.. raw:: html
.. only:: html
.. image:: /tutorials/analysis-3d/images/thumb/sphx_glr_analysis_3d_thumb.png
:alt:
:ref:`sphx_glr_tutorials_analysis-3d_analysis_3d.py`
.. raw:: html
3D detailed analysis
.. raw:: html
.. only:: html
.. image:: /tutorials/analysis-3d/images/thumb/sphx_glr_cta_data_analysis_thumb.png
:alt:
:ref:`sphx_glr_tutorials_analysis-3d_cta_data_analysis.py`
.. raw:: html
Basic image exploration and fitting
.. raw:: html
.. only:: html
.. image:: /tutorials/analysis-3d/images/thumb/sphx_glr_energy_dependent_estimation_thumb.png
:alt:
:ref:`sphx_glr_tutorials_analysis-3d_energy_dependent_estimation.py`
.. raw:: html
Morphological energy dependence estimation
.. raw:: html
.. only:: html
.. image:: /tutorials/analysis-3d/images/thumb/sphx_glr_analysis_mwl_thumb.png
:alt:
:ref:`sphx_glr_tutorials_analysis-3d_analysis_mwl.py`
.. raw:: html
Multi instrument joint 3D and 1D analysis
.. raw:: html
.. only:: html
.. image:: /tutorials/analysis-3d/images/thumb/sphx_glr_simulate_3d_thumb.png
:alt:
:ref:`sphx_glr_tutorials_analysis-3d_simulate_3d.py`
.. raw:: html
3D map simulation
.. raw:: html
.. only:: html
.. image:: /tutorials/analysis-3d/images/thumb/sphx_glr_event_sampling_thumb.png
:alt:
:ref:`sphx_glr_tutorials_analysis-3d_event_sampling.py`
.. raw:: html
Event sampling
.. raw:: html
.. only:: html
.. image:: /tutorials/analysis-3d/images/thumb/sphx_glr_event_sampling_nrg_depend_models_thumb.png
:alt:
:ref:`sphx_glr_tutorials_analysis-3d_event_sampling_nrg_depend_models.py`
.. raw:: html
Sample a source with energy-dependent temporal evolution
.. raw:: html
.. only:: html
.. image:: /tutorials/analysis-3d/images/thumb/sphx_glr_flux_profiles_thumb.png
:alt:
:ref:`sphx_glr_tutorials_analysis-3d_flux_profiles.py`
.. raw:: html
Flux Profile Estimation
.. thumbnail-parent-div-close
.. raw:: html
.. toctree::
:hidden:
/tutorials/analysis-3d/analysis_3d
/tutorials/analysis-3d/cta_data_analysis
/tutorials/analysis-3d/energy_dependent_estimation
/tutorials/analysis-3d/analysis_mwl
/tutorials/analysis-3d/simulate_3d
/tutorials/analysis-3d/event_sampling
/tutorials/analysis-3d/event_sampling_nrg_depend_models
/tutorials/analysis-3d/flux_profiles
Time
----
.. raw:: html
.. thumbnail-parent-div-open
.. raw:: html
.. only:: html
.. image:: /tutorials/analysis-time/images/thumb/sphx_glr_light_curve_thumb.png
:alt:
:ref:`sphx_glr_tutorials_analysis-time_light_curve.py`
.. raw:: html
Light curves
.. raw:: html
.. only:: html
.. image:: /tutorials/analysis-time/images/thumb/sphx_glr_light_curve_flare_thumb.png
:alt:
:ref:`sphx_glr_tutorials_analysis-time_light_curve_flare.py`
.. raw:: html
Light curves for flares
.. raw:: html
.. only:: html
.. image:: /tutorials/analysis-time/images/thumb/sphx_glr_variability_estimation_thumb.png
:alt:
:ref:`sphx_glr_tutorials_analysis-time_variability_estimation.py`
.. raw:: html
Estimation of time variability in a lightcurve
.. raw:: html
.. only:: html
.. image:: /tutorials/analysis-time/images/thumb/sphx_glr_time_resolved_spectroscopy_thumb.png
:alt:
:ref:`sphx_glr_tutorials_analysis-time_time_resolved_spectroscopy.py`
.. raw:: html
Time resolved spectroscopy estimator
.. raw:: html
.. only:: html
.. image:: /tutorials/analysis-time/images/thumb/sphx_glr_light_curve_simulation_thumb.png
:alt:
:ref:`sphx_glr_tutorials_analysis-time_light_curve_simulation.py`
.. raw:: html
Simulating and fitting a time varying source
.. raw:: html
.. only:: html
.. image:: /tutorials/analysis-time/images/thumb/sphx_glr_pulsar_analysis_thumb.png
:alt:
:ref:`sphx_glr_tutorials_analysis-time_pulsar_analysis.py`
.. raw:: html
Pulsar analysis
.. thumbnail-parent-div-close
.. raw:: html
.. toctree::
:hidden:
/tutorials/analysis-time/light_curve
/tutorials/analysis-time/light_curve_flare
/tutorials/analysis-time/variability_estimation
/tutorials/analysis-time/time_resolved_spectroscopy
/tutorials/analysis-time/light_curve_simulation
/tutorials/analysis-time/pulsar_analysis
Package / API
=============
The following tutorials demonstrate different dimensions of the Gammapy API or
expose how to perform more specific use cases.
.. raw:: html
.. thumbnail-parent-div-open
.. raw:: html
.. only:: html
.. image:: /tutorials/api/images/thumb/sphx_glr_irfs_thumb.png
:alt:
:ref:`sphx_glr_tutorials_api_irfs.py`
.. raw:: html
Using Gammapy IRFs
.. raw:: html
.. only:: html
.. image:: /tutorials/api/images/thumb/sphx_glr_models_thumb.png
:alt:
:ref:`sphx_glr_tutorials_api_models.py`
.. raw:: html
Models
.. raw:: html
.. only:: html
.. image:: /tutorials/api/images/thumb/sphx_glr_priors_thumb.png
:alt:
:ref:`sphx_glr_tutorials_api_priors.py`
.. raw:: html
Priors
.. raw:: html
.. only:: html
.. image:: /tutorials/api/images/thumb/sphx_glr_astro_dark_matter_thumb.png
:alt:
:ref:`sphx_glr_tutorials_api_astro_dark_matter.py`
.. raw:: html
Dark matter spatial and spectral models
.. raw:: html
.. only:: html
.. image:: /tutorials/api/images/thumb/sphx_glr_maps_thumb.png
:alt:
:ref:`sphx_glr_tutorials_api_maps.py`
.. raw:: html
Maps
.. raw:: html
.. only:: html
.. image:: /tutorials/api/images/thumb/sphx_glr_mask_maps_thumb.png
:alt:
:ref:`sphx_glr_tutorials_api_mask_maps.py`
.. raw:: html
Mask maps
.. raw:: html
.. only:: html
.. image:: /tutorials/api/images/thumb/sphx_glr_datasets_thumb.png
:alt:
:ref:`sphx_glr_tutorials_api_datasets.py`
.. raw:: html
Datasets - Reduced data, IRFs, models
.. raw:: html
.. only:: html
.. image:: /tutorials/api/images/thumb/sphx_glr_makers_thumb.png
:alt:
:ref:`sphx_glr_tutorials_api_makers.py`
.. raw:: html
Makers - Data reduction
.. raw:: html
.. only:: html
.. image:: /tutorials/api/images/thumb/sphx_glr_catalog_thumb.png
:alt:
:ref:`sphx_glr_tutorials_api_catalog.py`
.. raw:: html
Source catalogs
.. raw:: html
.. only:: html
.. image:: /tutorials/api/images/thumb/sphx_glr_observation_clustering_thumb.png
:alt:
:ref:`sphx_glr_tutorials_api_observation_clustering.py`
.. raw:: html
Observational clustering
.. raw:: html
.. only:: html
.. image:: /tutorials/api/images/thumb/sphx_glr_model_management_thumb.png
:alt:
:ref:`sphx_glr_tutorials_api_model_management.py`
.. raw:: html
Modelling
.. raw:: html
.. only:: html
.. image:: /tutorials/api/images/thumb/sphx_glr_fitting_thumb.png
:alt:
:ref:`sphx_glr_tutorials_api_fitting.py`
.. raw:: html
Fitting
.. raw:: html
.. only:: html
.. image:: /tutorials/api/images/thumb/sphx_glr_estimators_thumb.png
:alt:
:ref:`sphx_glr_tutorials_api_estimators.py`
.. raw:: html
Estimators
.. thumbnail-parent-div-close
.. raw:: html
.. toctree::
:hidden:
/tutorials/api/irfs
/tutorials/api/models
/tutorials/api/priors
/tutorials/api/astro_dark_matter
/tutorials/api/maps
/tutorials/api/mask_maps
/tutorials/api/datasets
/tutorials/api/makers
/tutorials/api/catalog
/tutorials/api/observation_clustering
/tutorials/api/model_management
/tutorials/api/fitting
/tutorials/api/estimators
Scripts
=======
For interactive use, IPython and Jupyter are great, and most Gammapy examples use those.
However, for long-running, non-interactive tasks like data reduction or survey maps,
you might prefer a Python script.
The following example shows how to run Gammapy within a Python script.
.. raw:: html
.. thumbnail-parent-div-open
.. raw:: html
.. only:: html
.. image:: /tutorials/scripts/images/thumb/sphx_glr_survey_map_thumb.png
:alt:
:ref:`sphx_glr_tutorials_scripts_survey_map.py`
.. raw:: html
Survey Map Script
.. thumbnail-parent-div-close
.. raw:: html
.. toctree::
:hidden:
/tutorials/scripts/survey_map
.. only:: html
.. container:: sphx-glr-footer sphx-glr-footer-gallery
.. container:: sphx-glr-download sphx-glr-download-python
:download:`Download all examples in Python source code: tutorials_python.zip `
.. container:: sphx-glr-download sphx-glr-download-jupyter
:download:`Download all examples in Jupyter notebooks: tutorials_jupyter.zip `
.. only:: html
.. rst-class:: sphx-glr-signature
`Gallery generated by Sphinx-Gallery `_