Fix print in spectral dataset
@@ -110,6 +110,11 @@ class SpectrumDataset(Dataset):
counts_off = np.sum(self.counts_off.data)
str_ += "\t{:32}: {:.2f}\n\n".format("Total off counts", counts_off)
+ background = np.nan
+ if getattr(self, "background", None) is not None:
+ background = np.sum(self.background.data)
+ str_ += "\t{:32}: {:.2f}\n\n".format("Total background counts", background)
+
aeff_min, aeff_max, aeff_unit = np.nan, np.nan, ""
if self.aeff is not None:
aeff_min = np.min(self.aeff.data.data.value[self.aeff.data.data.value > 0])
@@ -141,7 +146,7 @@ class SpectrumDataset(Dataset):
str_ += "\t{:32}: {}\n".format("Fit statistic type", self.likelihood_type)
stat = np.nan
- if self.model is not None:
+ if self.model is not None and self.counts is not None:
stat = self.stat_sum()
str_ += "\t{:32}: {:.2f}\n\n".format("Fit statistic value (-2 log(L))", stat)
