# Multimessenger Astrophysics School 2026 - Gammapy analysis

Material for the high-level analysis sessions using [Gammapy](https://gammapy.org/).

Lecturers:
 - Ruben Lopez-Coto, IAA-CSIC (rlopezcoto@iaa.es)
 - Enrique Mestre, ICE-CSIC (mestre@ice.csic.es)

## Lectures
- Introduction to Gammapy
- Hands-on on Gammapy 1D analysis
- Hands-on on LST-1 DL3 analysis

## Installation
We will use the latest release of Gammapy, v2.1. 
The recommended setup is described in the [Gammapy documentation](https://docs.gammapy.org/2.1/getting-started/#recommended-setup). 
The steps are also summarised here:

The recommended setup is through conda (with i.e. Miniconda, Anaconda or mamba):
```
curl -O https://gammapy.org/download/install/gammapy-2.1-environment.yml
conda env create -f gammapy-2.1-environment.yml
conda activate gammapy-2.1
```

Then, set `GAMMAPY_DATA` either for the environment through:
```
conda activate gammapy-2.1
conda env config vars set GAMMAPY_DATA=$PWD/gammapy-datasets/2.1
conda activate gammapy-2.1
```

or otherwise add it to your .bashrc/bash_profile:
```
export GAMMAPY_DATA=$PWD/gammapy-datasets/2.1
```

**Check your installation**

To check that the gammapy environment is working, open a new terminal and type

```
conda activate gammapy-2.1
gammapy info
```
To further check that you have correctly set up the data folder type

## Datasets
Download the following datasets to be used in the hands-on sessions.

- **Gammapy datasets** should be downloaded through:

```
conda activate gammapy-2.1
gammapy download datasets
```

- **LST-1 dataset** can be downloaded from [Zenodo](https://zenodo.org/records/11445184) and place it inside `$GAMMAPY_DATA/lst1_crab`

Alternatively, via command line:

```
for f in dl3_LST-1.Run07253.fits dl3_LST-1.Run07254.fits dl3_LST-1.Run07255.fits dl3_LST-1.Run07256.fits dl3_LST-1.Run07274.fits dl3_LST-1.Run07275.fits dl3_LST-1.Run07276.fits dl3_LST-1.Run07277.fits hdu-index.fits.gz obs-index.fits.gz; do     echo "Downloading $f...";     curl -L -o "$f" "https://zenodo.org/records/11445184/files/$f?download=1"; done
curl -o lst1_crab.zip https://zenodo.org/api/records/11445184/files-archive

mv *.fits $GAMMAPY_DATA/lst1_crab
```
