MapMakerRing

class gammapy.cube.MapMakerRing(geom, offset_max, exclusion_mask=None, background_estimator=None)[source]

Bases: gammapy.cube.MapMaker

Make maps from IACT observations.

The main motivation for this class in addition to the MapMaker is to have the common image background estimation methods, like RingBackgroundEstimator, that work using on and off maps.

To ensure adequate statistics, only observations that are fully contained within the reference geometry will be analysed

Parameters:
geom : WcsGeom

Reference image geometry

offset_max : Angle

Maximum offset angle

exclusion_mask : Map

Exclusion mask

background_estimator : RingBackgroundEstimator

or AdaptiveRingBackgroundEstimator Ring background estimator or something with an equivalent API.

Examples

Here is an example how to ise the MapMakerRing with H.E.S.S. DL3 data:

import numpy as np
import astropy.units as u
from astropy.coordinates import SkyCoord
from regions import CircleSkyRegion
from gammapy.maps import Map, WcsGeom, MapAxis
from gammapy.cube import MapMakerRing
from gammapy.data import DataStore
from gammapy.background import RingBackgroundEstimator

# Create observation list
data_store = DataStore.from_file(
    "$GAMMAPY_DATA/hess-dl3-dr1/hess-dl3-dr3-with-background.fits.gz"
)
data_sel = data_store.obs_table["TARGET_NAME"] == "MSH 15-52"
obs_table = data_store.obs_table[data_sel]
observations = data_store.get_observations(obs_table["OBS_ID"])

# Define the geom
pos = SkyCoord(228.32, -59.08, unit="deg")
energy_axis = MapAxis.from_edges(np.logspace(0, 5.0, 5), unit="TeV", name="energy")
geom = WcsGeom.create(skydir=pos, binsz=0.02, width=(5, 5), axes=[energy_axis])

# Make a region mask
regions = CircleSkyRegion(center=pos, radius=0.3 * u.deg)
mask = Map.from_geom(geom)
mask.data = mask.geom.region_mask([regions], inside=False)

# Run map maker with ring background estimation
ring_bkg = RingBackgroundEstimator(r_in="0.5 deg", width="0.3 deg")
maker = MapMakerRing(
    geom=geom, offset_max="2 deg", exclusion_mask=mask, background_estimator=ring_bkg
)
images = maker.run_images(observations)

Methods Summary

run(observations) Run map making.
run_images(observations[, spectrum, keepdims]) Run image making.

Methods Documentation

run(observations)[source]

Run map making.

Parameters:
observations : Observations

Observations to process

Returns:
maps : dict of Map

Dictionary containing the following maps:

  • "on": counts map
  • "exposure_on": on exposure map, which is just the template background map from the IRF
  • "exposure_off": off exposure map convolved with the ring
  • "off": off map
run_images(observations, spectrum=None, keepdims=False)[source]

Run image making.

The maps are summed over on the energy axis for a classical image analysis.

Parameters:
observations : Observations

Observations to process

spectrum : SpectralModel, optional

Spectral model to compute the weights. Default is power-law with spectral index of 2.

keepdims : bool, optional

If this is set to True, the energy axes is kept with a single bin. If False, the energy axes is removed

Returns:
maps : dict of Map

Dictionary containing the following maps:

  • "on": counts map
  • "exposure_on": on exposure map, which is just the template background map from the IRF
  • "exposure_off": off exposure map convolved with the ring
  • "off": off map