Gammapy: A Python package for gamma-ray astronomy

Donath A, Terrier R, Remy Q, Sinha A, Nigro C, Pintore F, Khélifi B, Olivera-Nieto L, Ruiz JE, Brügge K, Linhoff M, Contreras JL, Acero F, Aguasca-Cabot A, Berge D, Bhattacharjee P, Buchner J, Boisson C, Carreto Fidalgo D, Chen A, De Bony De Lavergne M, De Miranda Cardoso JV, Deil C, Füling M, Funk S, Giunti L, Hinton J, Jouvin L, King J, Lefaucheur J, Lemoine-Goumard M, Lenain JP, López-Coto R, Mohrmann L, Morcuende D, Panny S, Regeard M, Saha L, Siejkowski H, Siemiginowska A, Sipocz BM, Unbehaun T, van Eldik C, Vuillaume T, Zanin R (2023)

Publication Type: Journal article

Publication year: 2023


Book Volume: 678

Article Number: A157

DOI: 10.1051/0004-6361/202346488


Context. Traditionally, TeV-γ-ray astronomy has been conducted by experiments employing proprietary data and analysis software. However, the next generation of γ-ray instruments, such as the Cherenkov Telescope Array Observatory (CTAO), will be operated as open observatories. Alongside the data, they will also make the associated software tools available to a wider community. This necessity prompted the development of open, high-level, astronomical software customized for high-energy astrophysics. Aims. In this article, we present Gammapy, an open-source Python package for the analysis of astronomical γ-ray data, and illustrate the functionalities of its first long-term-support release, version 1.0. Built on the modern Python scientific ecosystem, Gammapy provides a uniform platform for reducing and modeling data from different γ-ray instruments for many analysis scenarios. Gammapy complies with several well-established data conventions in high-energy astrophysics, providing serialized data products that are interoperable with other software packages. Methods. Starting from event lists and instrument response functions, Gammapy provides functionalities to reduce these data by binning them in energy and sky coordinates. Several techniques for background estimation are implemented in the package to handle the residual hadronic background affecting γ-ray instruments. After the data are binned, the flux and morphology of one or more γ-ray sources can be estimated using Poisson maximum likelihood fitting and assuming a variety of spectral, temporal, and spatial models. Estimation of flux points, likelihood profiles, and light curves is also supported. Results. After describing the structure of the package, we show, using publicly available gamma-ray data, the capabilities of Gammapy in multiple traditional and novel γ-ray analysis scenarios, such as spectral and spectro-morphological modeling and estimations of a spectral energy distribution and a light curve. Its flexibility and its power are displayed in a final multi-instrument example, where datasets from different instruments, at different stages of data reduction, are simultaneously fitted with an astrophysical flux model.

Authors with CRIS profile

Involved external institutions

Universidad Complutense de Madrid (UCM) ES Spain (ES) Institut de Fisica d'Altes Energies (IFAE) / The Institute for High Energy Physics ES Spain (ES) National Institute for Astrophysics / Istituto Nazionale Astrofisica (INAF) IT Italy (IT) Technische Universität Dortmund DE Germany (DE) Université Paris-Saclay FR France (FR) Universitat de Barcelona (UB) / University of Barcelona ES Spain (ES) Smithsonian Institution US United States (USA) (US) University of Paris 7 - Denis Diderot / Université Paris VII Denis Diderot FR France (FR) Max-Planck-Institut für Kernphysik (MPIK) / Max Planck Institute for Nuclear Physics DE Germany (DE) University of Savoy Mont Blanc / Université Savoie Mont Blanc FR France (FR) Laboratoire Univers et Théories (LUTH) / Laboratory of the Universe and Theories FR France (FR) Rechenzentrum Garching der Max-Planck-Gesellschaft (MPCDF) / Max Planck Computing & Data Facility DE Germany (DE) University of the Witwatersrand (WITS) ZA South Africa (ZA) Hong Kong University of Science and Technology (HKUST) / 香港科技大學 CN China (CN) Ruprecht-Karls-Universität Heidelberg DE Germany (DE) Sorbonne Université FR France (FR) Akademickie Centrum Komputerowe CYFRONET AGH PL Poland (PL) California Institute of Technology (Caltech) US United States (USA) (US) Institute of Astrophysics of Andalusia / Instituto de Astrofísica de Andalucía (IAA-CSIC) ES Spain (ES) Point 8 GmbH DE Germany (DE) Deutsches Elektronen-Synchrotron DESY DE Germany (DE) Max-Planck-Institut für extraterrestrische Physik (MPE) / Max Planck Institute for Extraterrestrial Physics DE Germany (DE) Université de Bordeaux FR France (FR) Leopold-Franzens-Universität Innsbruck / University of Innsbruck AT Austria (AT)

How to cite


Donath, A., Terrier, R., Remy, Q., Sinha, A., Nigro, C., Pintore, F.,... Zanin, R. (2023). Gammapy: A Python package for gamma-ray astronomy. Astronomy & Astrophysics, 678.


Donath, Axel, et al. "Gammapy: A Python package for gamma-ray astronomy." Astronomy & Astrophysics 678 (2023).

BibTeX: Download