From 03539eaea665f676842b5912d7e8ba1531102c61 Mon Sep 17 00:00:00 2001 From: jochenstahn Date: Fri, 5 Sep 2025 10:42:31 +0200 Subject: [PATCH] division by zero in ts mode fixed --- libeos/file_reader.py | 5 ++++- libeos/reduction.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/libeos/file_reader.py b/libeos/file_reader.py index 68db5dd..d90c075 100644 --- a/libeos/file_reader.py +++ b/libeos/file_reader.py @@ -333,7 +333,10 @@ class AmorData: self.wallTime_e = self.wallTime_e[filter_e] logging.info(f' low-beam (<{self.config.lowCurrentThreshold} mC) rejected pulses: {np.shape(self.monitorPerPulse)[0]-1-np.shape(goodTimeS)[0]} out of {np.shape(self.monitorPerPulse)[0]-1}') logging.info(f' with {np.shape(filter_e)[0]-np.shape(self.tof_e)[0]} events') - logging.info(f' average counts per pulse = {np.shape(self.tof_e)[0] / np.shape(goodTimeS[goodTimeS!=0])[0]:7.1f}') + if np.shape(goodTimeS[goodTimeS!=0])[0]: + logging.info(f' average counts per pulse = {np.shape(self.tof_e)[0] / np.shape(goodTimeS[goodTimeS!=0])[0]:7.1f}') + else: + logging.info(f' average counts per pulse = undefined') def filter_strange_times(self): # 'strange' tof times are those with t > 2 tau (originating from the efu) diff --git a/libeos/reduction.py b/libeos/reduction.py index f928b43..f41a946 100644 --- a/libeos/reduction.py +++ b/libeos/reduction.py @@ -465,7 +465,7 @@ class AmorReduction: if self.monitor > 1e-6 : ref_lz *= self.normMonitor / self.monitor else: - logging.info(' too small monitor value for normalisation -> ignoring monitors') + logging.info(' low monitor -> zero output') err_lz = ref_lz * np.sqrt( 1/(int_lz+.1) + 1/norm_lz ) # TODO: allow for non-ideal Delta lambda / lambda (rather than 2.2%)