Emit warning when computing containment radii on un-normalized PSFs
@@ -165,6 +165,10 @@ class TablePSF:
rad_max = Angle(np.linspace(0, self.rad[-1].value, 10 * len(self.rad)), "rad")
containment = self.containment(rad_max=rad_max)
+ if not np.allclose(containment.max(), 1, atol=0.01):
+ log.warn("PSF does not integrate to unity within a precision of 1%."
+ " Containment radius computation might give biased results.")
+
fraction = np.atleast_1d(fraction)
fraction_idx = np.argmin(np.abs(containment - fraction[:, np.newaxis]), axis=1)
@@ -456,6 +460,10 @@ class EnergyDependentTablePSF:
rad_max = Angle(np.linspace(0, self.rad[-1].value, 10 * len(self.rad)), "rad")
containment = self.containment(energy=energy, rad_max=rad_max)
+ if not np.allclose(containment.max(axis=1), 1, atol=0.01):
+ log.warn("PSF does not integrate to unity within a precision of 1% in each energy bin."
+ " Containment radius computation might give biased results.")
+
# find nearest containment value
fraction_idx = np.argmin(np.abs(containment - fraction), axis=1)
return rad_max[fraction_idx].to("deg")
