Add countsstatistic on MapDataset
@@ -1228,23 +1228,19 @@ class MapDataset(Dataset):
mask = slice(None)
counts = 0
-
+ background, excess, sqrt_ts = np.nan, np.nan, np.nan
+ if self.counts and self.background:
sum_stat = self._counts_statistic[mask].sum()
-
- if self.counts:
counts = sum_stat.n_on
-
- info["counts"] = int(counts)
-
- background = np.nan
- if self.background:
background = sum_stat.n_bkg
+ excess = sum_stat.n_sig
+ sqrt_ts = sum_stat.sqrt_ts
+ info["counts"] = int(counts)
+ info["excess"] = float(excess)
+ info["sqrt_ts"] = sqrt_ts
info["background"] = float(background)
- info["excess"] = sum_stat.n_sig
- info["sqrt_ts"] = sum_stat.sqrt_ts
-
npred = np.nan
if self.models or not np.isnan(background):
npred = self.npred().data[mask].sum()
@@ -1991,6 +1987,11 @@ class MapDatasetOnOff(MapDataset):
)
return np.nan_to_num(on_stat_)
+ @property
+ def _counts_statistic(self):
+ """Counts statistics of the dataset."""
+ return WStatCountsStatistic(self.counts, self.counts_off, self.alpha)
+
@classmethod
def from_geoms(
cls,
