Add error bars for all the method of the plots residual function
@@ -953,7 +953,6 @@ class MapDataset(Dataset):
npred_spec = npred.get_spectrum(region)
residuals = self._compute_residuals(counts_spec, npred_spec, method)
- if method == "diff":
if self.stat_type == "wstat":
counts_off = (self.counts_off * mask).get_spectrum(region)
@@ -969,9 +968,14 @@ class MapDataset(Dataset):
)
elif self.stat_type == "cash":
stat = CashCountsStatistic(counts_spec.data, npred_spec.data)
- yerr = stat.error
+ excess_error = stat.error
+
+ if method == "diff":
+ yerr = excess_error
+ elif method == "diff/model":
+ yerr = excess_error/npred_spec.data
elif method == "diff/sqrt(model)":
- yerr = np.ones_like(residuals.data)
+ yerr = excess_error/np.sqrt(npred_spec.data)
else:
raise ValueError(
'Invalid method, choose between "diff" and "diff/sqrt(model)"'
