Skip to main content

CI codecov Ruff pre-commit.ci status Docs

PyPI Version Conda Version

Gammapy Plugin

A gammapy plugin for threeML

threeML plugin to use gammapy datasets in your threeML analysis.

Docs

You can find the docs containg also example notebooks either on readthedocs or on the github pages.

Installation

pip

The following should be sufficient and install all the relevant dependencies.

pip install gammapy-plugin

conda-forge

The gamampy-plugin is available at conda-forge, however be aware that threeML and astromodels from conda-forge are not officially supported, e.g. lacking XSPEC support. Please check out the installation instructions for threeML and astromodels beforehand.

In most cases this should suffice:

conda install -c threeml -c conda-forge gammapy-plugin

Testing your installation

You can test the installation using pytest. To get all the dependencies it is recommeneded to run

# install test dependenices
pip install "gammapy_plugin[tests]"

# equivalent to gammapy download datasets - no need to do that if you already have them
# downloaded and stored in  $GAMMAPY_DATA
export GAMMAPY_DATA=/path/to/gammapy_datasets/
git clone https://github.com/gammapy/gammapy-data.git $GAMMAPY_DATA

# run pytests
python -m pytest --pyargs gammapy_plugin -n auto --dist worksteal 

The first part is equivalent to running gammapy download datasets (see the gammapy installation instructions).

These data are required by the pytest tests.

Requirements

Python 3.12 or 3.13 together with gammapy>=v2.0.0

Usage and Examples

The basic procedure after creating a gammapy dataset is

gl = GammapyLike(name="name_of_the_plugin")  # initializing the plugin
gl.set_datasets(datasets, mode="individual")  # adding the gammapy dataset
gl.set_sources("name_of_the_source")  # setting the source
gl.set_model(model)  # setting the astromodels model

When using MapDataset with FoVBackgroundModel you can also include them in a fit. The parameters of the background models are currently treated as nuisance parameters during the fitting/sampling.

This might then look like this for example:

datasets = Datasets()
gls = []
for o in observations:
    dataset = MapDataset.create(
        geom=geom, energy_axis_true=energy_axis_true, name=f"HESS_{o.obs_id}"
    )
    dataset = maker.run(dataset, o)
    dataset = safe_mask_maker.run(dataset, o)
    bkg_model = FoVBackgroundModel(name=f"{o.obs_id}_bkg", dataset_name=dataset.name)
    dataset.models = [bkg_model]
    dataset = fov_bkg_maker.run(dataset)
    datasets.append(dataset)
    gl = GammapyLike(dataset.name, frame="galactic")
    gl.set_datasets(dataset)
    gl.set_background_models(bkg_model)
    gls.append(gl)

Notes

This current version is based on previous work by J. Michael Burgess, Sajan Kumar and AnjanaTel.

Metadata

Release files for gammapy-plugin 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gammapy-plugin 0.0.3
File Size Uploaded Provenance Actions
gammapy_plugin-0.0.3.tar.gz 56.8 kB With provenance Details for gammapy_plugin-0.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gammapy-plugin 0.0.3
File Interpreter ABI Platform Actions
gammapy_plugin-0.0.3-py3-none-any.whl Python 3 none any Details for gammapy_plugin-0.0.3-py3-none-any.whl

Total release size: 103.4 kB

Release files / gammapy_plugin-0.0.3.tar.gz

Download URL gammapy_plugin-0.0.3.tar.gz
Size 56.8 kB
Tags Source
SHA-256 checksum
How to use checksums
aba82035078ddf1b72af635393e94881ec1ab7c9182537cb7ca2eb95af6c4f24
BLAKE2b-256 checksum
How to use checksums
ce46f159eaab2cbfa9c787f0b1dc582b1ff8ef6275f335e6d7f673477a7c23a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Release files / gammapy_plugin-0.0.3-py3-none-any.whl

Download URL gammapy_plugin-0.0.3-py3-none-any.whl
Size 46.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
640435cfbcaf254b290a341870095eec89fa7e134738a5ac9f5d0638c09e65b2
BLAKE2b-256 checksum
How to use checksums
f45911fc23454c3893a9044804bf259f16ec8e67858d56567ee7bbda89143fc8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Security for gammapy-plugin 0.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for gammapy_plugin-0.0.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page