Adapt cube/test_make.py
@@ -5,7 +5,7 @@ from numpy.testing import assert_allclose
import astropy.units as u
from astropy.coordinates import SkyCoord
from regions import CircleSkyRegion
-from gammapy.cube import MapDataset, MapDatasetMaker, RingBackgroundMaker
+from gammapy.cube import MapDataset, MapDatasetMaker, RingBackgroundMaker, SafeMaskMaker
from gammapy.cube.fit import MapDatasetOnOff
from gammapy.data import DataStore
from gammapy.maps import Map, MapAxis, WcsGeom
@@ -103,14 +103,17 @@ def test_map_maker(pars, observations):
margin_irf=pars["margin_irf"],
)
- for obs in observations:
maker = MapDatasetMaker(
geom=pars["geom"],
energy_axis_true=pars["e_true"],
offset_max="2 deg",
background_oversampling=pars.get("background_oversampling"),
)
+ safe_mask_maker = SafeMaskMaker(methods=["offset-max"], offset_max="2 deg")
+
+ for obs in observations:
dataset = maker.run(obs)
+ dataset = safe_mask_maker.run(dataset, obs)
stacked.stack(dataset)
counts = stacked.counts
@@ -144,6 +147,8 @@ def test_map_maker(pars, observations):
def test_map_maker_ring(observations):
geomd = geom(ebounds=[0.1, 10])
map_dataset_maker = MapDatasetMaker(geom=geomd, offset_max="2 deg")
+ safe_mask_maker = SafeMaskMaker(methods=["offset-max"], offset_max="2 deg")
+
stacked = MapDatasetOnOff.create(geomd)
regions = CircleSkyRegion(
@@ -158,6 +163,8 @@ def test_map_maker_ring(observations):
for obs in observations:
dataset = map_dataset_maker.run(obs)
+ dataset = safe_mask_maker.run(dataset, obs)
+
dataset = dataset.to_image()
dataset_on_off = ring_bkg.run(dataset)
