From 16f530f4e6ba774302da09c021a40618033568a6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lo=C3=AFc=20Le=20Guyader?= <loic.le.guyader@xfel.eu>
Date: Sat, 28 Aug 2021 04:19:42 +0200
Subject: [PATCH] Change sum to mean such that horizontal and vertical t
 threshold above dark level should be the same

---
 src/toolbox_scs/routines/boz.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/toolbox_scs/routines/boz.py b/src/toolbox_scs/routines/boz.py
index 61c1fbd..4f1110f 100644
--- a/src/toolbox_scs/routines/boz.py
+++ b/src/toolbox_scs/routines/boz.py
@@ -346,9 +346,9 @@ def find_rois(data_mean, threshold):
     rois: dictionnary of rois
     """
     # compute vertical and horizontal projection
-    pX = data_mean.sum(axis=0)
+    pX = data_mean.mean(axis=0)
     pX = pX[:256]  # half the ladder since there is a gap in the middle
-    pY = data_mean.sum(axis=1)
+    pY = data_mean.mean(axis=1)
 
     # along X
     lowX = int(np.argmax(pX[:64] > threshold))  # 1st occurrence returned
@@ -438,9 +438,9 @@ def inspect_rois(data_mean, rois, threshold=None, allrois=False):
     matplotlib figure
     """
     # compute vertical and horizontal projection
-    pX = data_mean.sum(axis=0)
+    pX = data_mean.mean(axis=0)
     pX = pX[:256]  # half the ladder since there is a gap in the middle
-    pY = data_mean.sum(axis=1)
+    pY = data_mean.mean(axis=1)
 
     # Set up the axes with gridspec
     fig = plt.figure(figsize=(5, 3))
@@ -605,6 +605,8 @@ def load_dssc_module(proposalNB, runNB, moduleNB=15,
     arr[arr == 0] = 256
 
     ppt = run[source, key][subset].data_counts()
+    # ignore train with no pulses, can happen in burst mode acquisition
+    ppt = ppt[ppt > 0]
     tid = ppt.index.to_numpy()
 
     ppt = np.unique(ppt)
-- 
GitLab