threeML plugin to use gammapy datasets in your threeML analysis.
You can find the docs containg also example notebooks either on readthedocs or on the github pages.
The following should be sufficient and install all the relevant dependencies.
pip install gammapy-pluginYou 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
export GAMMAPY_DATA=/path/to/gammapy_datasets/
git clone https://github.com/gammapy/gammapy-data.git $GAMMAPY_DATA
# run pytests
python -m pytest -n auto --dist worksteal gammapy_pluginThe first part is equivalent to running gammapy download datasets (see the gammapy installation
instructions).
These data are required by the pytest tests.
Python 3.12 or 3.13 together with gammapy>=v2.0.0
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 modelWhen 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)This current version is based on previous work by J. Michael Burgess, Sajan Kumar and AnjanaTel.