SciPy 2023

Gammapy: a Python Package for Gamma-Ray Astronomy Version v1.0
07-12, 13:15–13:45 (America/Chicago), Grand Salon C

In this contribution we will present the first stable version v1.0 of Gammapy, an openly developed Python package for gamma-ray astronomy. Gammapy provides methods for the analysis of astronomical gamma-ray data, such as measurement of spectra, images and light curves. By relying on standardized data formats and a joint likelihood framework, it allows astronomers to combine data from multiple instruments and constrain underlying astrophysical emission processes across large parts of the electromagnetic spectrum. Finally we will share lessons learned during the journey towards version v1.0 for an openly developed scientific Python package.


By observing the very high energy (VHE) range of the electromagnetic spectrum we can gain valuable insight into to the extreme universe, including remnants of supernova explosions and surroundings of black holes. In the past VHE gamma-ray astronomy was typically conducted by small, closed collaborations as a subfield of particle physics. However, with hundreds of sources now identified,
VHE gamma-ray astronomy has emerged as a new branch of Astronomy. This field provides us with the high energy context for understanding the physical processes occurring throughout the universe, across the entire electromagnetic spectrum.

The next generation of ground based gamma-ray instruments, particularly the Cherenkov Telescope Array Observatory (CTA)), is set to revolutionize gamma-ray astronomy. With an anticipated sensitivity ten times greater than current telescopes, it has the potential to attract a community of thousands of gamma-ray astronomers. Furthermore, it will operate as an open observatory, making both data and analysis tools readily available to the public.

In this contribution we introduce the inaugural stable version (v1.0) of Gammapy, a Python package for gamma-ray astronomy and the primary library for the future CTAO science tools. Leveraging the scientific Python ecosystem, including Numpy, Scipy, and Astropy, Gammapy offers a comprehensive set of standard data analysis tools, making it an indispensable resource for (not only) gamma-ray astronomers. By utilizing common open data formats, Gammapy also enables existing instruments such as VERITAS, H.E.S.S., or HAWC to export and archive their data, preserving it for future analysis using improved methods. Additionally, it facilitates the combination of data from multiple instruments, resulting in more sensitive analyses with greater statistics and a larger energy range.

Gammapy tackles the varied structure of gamma-ray data and science analysis cases by implementing a uniform API for N-dimensional sky maps. This API is independent of the underlying pixelization scheme and supports local WCS, allsky HEALPix, and region-based projections. These data structures prove useful for a broad range of applications as well as astronomers observing in other wavelength.

Building on these core data structures, Gammapy features a maximum likelihood fitting framework that enables simultaneous modeling of gamma-ray emission in four dimensions: space, energy, and time. By providing a general likelihood interface, Gammapy enables science users to integrate gamma-ray data with astronomical data from other wavelengths, as well as with neutrino data. Thanks to its straightforward Python API, Gammapy can be paired with other Python-based broadband emission modeling packages, allowing for direct measurement of parameters pertaining to common underlying astrophysical processes. This feature is crucial to realizing the full potential of future multi-wavelength and multi-messenger Astronomy.

Lastly, we will discuss the valuable lessons learned during our journey to achieve v1.0 quality for an openly developed package. This will involve addressing concerns regarding maintainability, selection of dependencies, handling high dimensional data structures and API design. We believe that sharing our experience will be helpful to other scientific Python projects in the future.

I'm a Postdoc researcher at the Center for Astrophysics. My research interests include the Galactic X-Ray and Gamma-Ray source populations as well as statistical methods for analysis of low counts data in general. I'm also interested in methods to combine data from multiple instruments. I'm the lead developer of the open source software package Gammapy, sub-package maintainer of Astropy and a member of the CHASC astro-statistics collaboration. I'm also editor for the Astronomy and Astrophysics track of the Journal of Open Source Software JOSS.

This speaker also appears in: