remove mask safe handling from MapDatasetMaker
@@ -17,6 +17,7 @@ from .fit import (
MIGRA_AXIS_DEFAULT,
RAD_AXIS_DEFAULT,
MapDataset,
+ MapDatasetOnOff
)
from .psf_map import make_psf_map
@@ -274,42 +275,6 @@ class MapDatasetMaker:
exposure_map=exposure,
)
- def make_mask_safe(self, observation):
- """Make offset mask.
-
- Parameters
- ----------
- observation : `DataStoreObservation`
- Observation container.
-
- Returns
- -------
- mask : `Map`
- Mask
- """
- geom = self._cutout_geom(self.geom.to_image(), observation)
- offset = geom.separation(observation.pointing_radec)
- data = offset >= self.offset_max
- return Map.from_geom(geom, data=data)
-
- def make_mask_safe_irf(self, observation):
- """Make offset mask with irf geometry.
-
- Parameters
- ----------
- observation : `DataStoreObservation`
- Observation container.
-
- Returns
- -------
- mask : `Map`
- Mask
- """
- geom = self._cutout_geom(self.geom_exposure_irf.to_image(), observation)
- offset = geom.separation(observation.pointing_radec)
- data = offset >= self.offset_max
- return Map.from_geom(geom, data=data)
-
def run(self, observation, selection=None):
"""Make map dataset.
@@ -329,48 +294,29 @@ class MapDatasetMaker:
"""
selection = _check_selection(selection)
- mask_safe = self.make_mask_safe(observation)
- energy_axis = self.geom.get_axis_by_name("energy")
- mask_safe_3d = (
- ~mask_safe.data
- & np.ones(energy_axis.nbin, dtype=bool)[:, np.newaxis, np.newaxis]
- )
- mask_map = Map.from_geom(
- mask_safe.geom.to_cube([energy_axis]), data=mask_safe_3d
- )
- mask_safe_irf = self.make_mask_safe_irf(observation)
-
kwargs = {
"name": f"obs_{observation.obs_id}",
"gti": observation.gti,
- "mask_safe": mask_map,
}
if "counts" in selection:
counts = self.make_counts(observation)
- # TODO: remove masking out the values here and instead handle the safe mask only when
- # fitting and / or stacking datasets?
- counts.data[..., mask_safe.data] = 0
kwargs["counts"] = counts
if "exposure" in selection:
exposure = self.make_exposure(observation)
- exposure.data[..., mask_safe.data] = 0
kwargs["exposure"] = exposure
if "background" in selection:
background_map = self.make_background(observation)
- background_map.data[..., mask_safe.data] = 0
kwargs["background_model"] = BackgroundModel(background_map)
if "psf" in selection:
psf = self.make_psf(observation)
- psf.exposure_map.data[..., mask_safe_irf.data] = 0
kwargs["psf"] = psf
if "edisp" in selection:
edisp = self.make_edisp(observation)
- edisp.exposure_map.data[..., mask_safe_irf.data] = 0
kwargs["edisp"] = edisp
return MapDataset(**kwargs)
@@ -523,5 +469,8 @@ class SafeMaskMaker:
if "edisp-bias" in self.methods:
mask_safe &= self.make_mask_energy_edisp_bias(dataset)
+ if isinstance(dataset, (MapDataset, MapDatasetOnOff)):
+ mask_safe = Map.from_geom(dataset.counts.geom, data=mask_safe)
+
dataset.mask_safe = mask_safe
return dataset
