From ac42fc7c3cd7b998bdf947e7631341e4ead20720 Mon Sep 17 00:00:00 2001 From: Arnaud Watlet <arnaud.watlet@umons.ac.be> Date: Mon, 11 Dec 2023 12:03:36 +0100 Subject: [PATCH] updates select samples to avoid pulse not recorded due to Rpi lag --- ohmpi/hardware_system.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ohmpi/hardware_system.py b/ohmpi/hardware_system.py index 0028e61b..634e3b8c 100644 --- a/ohmpi/hardware_system.py +++ b/ohmpi/hardware_system.py @@ -296,9 +296,9 @@ class OhmPiHardware: x = [] for pulse in range(int(max(self.readings[:, 1]))): v = np.where((self.readings[:, 1] == pulse))[0] - - t_start_pulse = min(self.readings[v, 0]) - x.append(np.where((self.readings[:, 0] >= t_start_pulse + delay) & (self.readings[:, 2] != 0) & ( + if len(v) > 0: # to avoid pulse not recorded due to Raspberry Pi lag... + t_start_pulse = min(self.readings[v, 0]) + x.append(np.where((self.readings[:, 0] >= t_start_pulse + delay) & (self.readings[:, 2] != 0) & ( self.readings[:, 1] == pulse))[0]) x = np.concatenate(np.array(x, dtype='object')) return x -- GitLab