Fix to_spectrum_dataset test fail
@@ -1052,13 +1052,7 @@ class MapDataset(Dataset):
)
if self.exposure is not None:
- exposure = self.exposure.get_spectrum(on_region, np.mean)
- energy = exposure.geom.axes[0].edges
- kwargs["aeff"] = EffectiveAreaTable(
- energy_lo=energy[:-1],
- energy_hi=energy[1:],
- data=exposure.quantity[:, 0, 0] / kwargs["livetime"],
- )
+ kwargs["aeff"] = self.exposure.get_spectrum(on_region, np.mean) / kwargs["livetime"]
if containment_correction:
if not isinstance(on_region, CircleSkyRegion):
@@ -1070,10 +1064,9 @@ class MapDataset(Dataset):
raise ValueError("No PSFMap set. Containement correction impossible")
else:
psf = self.psf.get_energy_dependent_table_psf(on_region.center)
- containment = psf.containment(
- kwargs["aeff"].energy.center, on_region.radius
- )
- kwargs["aeff"].data.data *= containment.squeeze()
+ energy = kwargs["aeff"].geom.get_axis_by_name("energy_true").center
+ containment = psf.containment(energy, on_region.radius)
+ kwargs["aeff"].data *= containment[:, np.newaxis]
if self.edisp is not None:
energy_axis = self._geom.get_axis_by_name("energy")
