From 8fc556dcf46a46c801f2c78f9fd35647f6760f64 Mon Sep 17 00:00:00 2001
From: su530201 <olivier.kaufmann@umons.ac.be>
Date: Thu, 31 Aug 2023 13:52:39 +0200
Subject: [PATCH] Updates a test in dev for 2 muxes 2024

---
 ohmpi/hardware_system.py | 2 +-
 ohmpi/ohmpi.py           | 7 ++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/ohmpi/hardware_system.py b/ohmpi/hardware_system.py
index 335e56cd..d0f08e87 100644
--- a/ohmpi/hardware_system.py
+++ b/ohmpi/hardware_system.py
@@ -213,7 +213,7 @@ class OhmPiHardware:
     @property
     def last_dev(self):
         if len(self.readings) > 1:
-            v = self.readings[:,2] != 0
+            v = self.readings[:, 2] != 0  # exclude sample where the is no injection
             return 100. * np.std(self.readings[v, 2] * (self.readings[v, 4] - self.sp) / self.readings[v, 3])/self.last_rho
         else:
             return np.nan
diff --git a/ohmpi/ohmpi.py b/ohmpi/ohmpi.py
index 24e6d96f..432d199b 100644
--- a/ohmpi/ohmpi.py
+++ b/ohmpi/ohmpi.py
@@ -454,6 +454,11 @@ class OhmPi(object):
         bypass_check = kwargs['bypass_check'] if 'bypass_check' in kwargs.keys() else False
         if self.switch_mux_on(quad, bypass_check=bypass_check, cmd_id=cmd_id):
             self._hw.vab_square_wave(tx_volt, cycle_duration=injection_duration*2, cycles=nb_stack)
+            if 'delay' in kwargs.keys():
+                delay = kwargs['delay']
+            else:
+                delay = 0.
+            x = np.where(self._hw.readings[:, 0] >= delay)
             d = {
                 "time": datetime.now().isoformat(),
                 "A": quad[0],
@@ -463,7 +468,7 @@ class OhmPi(object):
                 "inj time [ms]": injection_duration,  # NOTE: check this
                 # "Vmn [mV]": sum_vmn / (2 * nb_stack),
                 # "I [mA]": sum_i / (2 * nb_stack),
-                "R [ohm]": np.mean(self._hw.readings[:, 2]*self._hw.readings[:, 4])/np.median(self._hw.readings[:, 3]),
+                "R [ohm]": np.mean(self._hw.readings[x, 2]*self._hw.readings[x, 4])/np.median(self._hw.readings[x, 3]),
                 "Ps [mV]": self._hw.sp,
                 "nbStack": nb_stack,
                 "Tx [V]": tx_volt,
-- 
GitLab