# Gammapy tutorial notebooks¶

## What is this?¶

- This is an overview of tutorial Jupyter notebooks for Gammapy, a Python package for gamma-ray astronomy.
- The notebooks complement the Gammapy Sphinx-based documentation at http://docs.gammapy.org
- The notebooks and example datasets are available at https://github.com/gammapy/gammapy-extra

## Set up¶

The Gammapy installation instructions are here: Installation

One quick way to get set up, that works the same on Linux, Mac and Windows is this:

Install Anaconda or Miniconda (see https://www.anaconda.com/download/ )

Get the following repository that contains the Gammapy tutorial notebooks:

git clone https://github.com/gammapy/gammapy-extra.git export GAMMAPY_EXTRA=$PWD/gammapy-extra

Create a Python conda environment that contains all software used in the tutorials:

cd gammapy-extra conda env create -f environment.yml

If you already have that environment, but want to update:

conda env update -f environment.yml

Activate the environment and start Jupyter:

source activate gammapy-tutorial cd notebooks jupyter notebook

Select and start the notebook you want in your webbrowser.

If you have any questions, ask for help. See http://gammapy.org/contact.html

## The basics¶

Gammapy is a Python package built on Numpy and Astropy, and the tutorials are Jupyter notebooks. If you’re already familar with those, you can skip to the next section and start learning about Gammapy.

To learn the basics, here are a few good resources.

### Python¶

- A Whirlwind tour of Python (learn Python)

### Scientific Python¶

- Python data science handbook (learn IPython, Numpy, matplotlib)

### Astropy¶

- Astropy introduction for Gammapy users |
*astropy_introduction.ipynb* - Astropy Hands On (1st ASTERICS-OBELICS International School)

Other useful resources:

## Notebooks¶

For a quick introduction to Gammapy, go here:

- First steps with Gammapy |
*first_steps.ipynb*

Interested to do a first analysis of simulated CTA data?

- CTA first data challenge (1DC) with Gammapy |
*cta_1dc_introduction.ipynb* - CTA data analysis with Gammapy |
*cta_data_analysis.ipynb*

To learn how to work with gamma-ray data with Gammapy:

- IACT DL3 data with Gammapy (H.E.S.S data example) |
*data_iact.ipynb* - Fermi-LAT data with Gammapy (Fermi-LAT data example) |
*data_fermi_lat.ipynb*

2-dimensional sky image analysis:

- Image analysis with Gammapy (run pipeline) (H.E.S.S. data example) |
*image_pipe.ipynb* - Image analysis with Gammapy (individual steps) (H.E.S.S. data example) |
*image_analysis.ipynb* - Source detection with Gammapy (Fermi-LAT data example) |
*detect_ts.ipynb* - CTA 2D source fitting with Sherpa |
*image_fitting_with_sherpa.ipynb*

1-dimensional spectral analysis:

- Spectral models in Gammapy |
*spectrum_models.ipynb* - Spectral analysis with Gammapy (run pipeline) (H.E.S.S. data example) |
*spectrum_pipe.ipynb* - Spectral analysis with Gammapy (individual steps) (H.E.S.S. data example) |
*spectrum_analysis.ipynb* - Spectrum simulation and fitting (CTA data example with AGN / EBL) |
*cta_simulation.ipynb* - Fitting gammapy spectra with sherpa |
*spectrum_fitting_with_sherpa.ipynb* - Flux point fitting with Gammapy |
*sed_fitting_gammacat_fermi.ipynb*

3-dimensional cube analysis:

- Cube analysis with Gammapy (part 1) (compute cubes and mean PSF / EDISP) |
*cube_analysis_part1.ipynb* - Cube analysis with Gammapy (part 2) (likelihood fit) |
*cube_analysis_part2.ipynb*

Time-related analysis:

- Light curve estimation with Gammapy |
*light_curve.ipynb*

### Extra topics¶

These notebooks contain examples on some more specialised functionality in Gammapy.

Most users will not need them. It doesn’t make much sense that you read through all of them, but maybe browse the list and see if there’s something that could be interesting for your work (or contribute to Gammapy if something is missing!).

- Template background model production with Gammapy |
*background_model.ipynb* - Continuous wavelet transform on gamma-ray images |
*cwt.ipynb* - Interpolation using the NDDataArray class |
*nddata_demo.ipynb* - Rapid introduction on using numpy, scipy, matplotlib |
*using_numpy.ipynb*

### Work in progress¶

The following notebooks are work in progress or broken.

Please help make these better, or write new, better ones!

- Astrophysical source population modeling with Gammapy |
*source_population_model.ipynb* - Source catalogs (working with gamma-ray source catalogs) |
*source_catalogs.ipynb* - Diffuse model computation (diffuse model computation) |
*diffuse_model_computation.ipynb* - Fermi Vela model (Fermi Vela model) |
*fermi_vela_model.ipynb* - Simulating and analysing sources and diffuse emission |
*source_diffuse_estimation.ipynb* - Time analysis with Gammapy (not written yet) |
*time_analysis.ipynb*