From 0f7ac258651943a242c38508e680253422c201e8 Mon Sep 17 00:00:00 2001
From: awatlet <arnaud.watlet@umons.ac.be>
Date: Tue, 10 Oct 2023 11:48:08 +0200
Subject: [PATCH] Adds Vmn and I readings in ohmpi.py

---
 ohmpi/ohmpi.py | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/ohmpi/ohmpi.py b/ohmpi/ohmpi.py
index 44c70738..894419eb 100644
--- a/ohmpi/ohmpi.py
+++ b/ohmpi/ohmpi.py
@@ -465,6 +465,10 @@ class OhmPi(object):
             print(f'length of series: {len(x)}')
             R = np.mean((self._hw.readings[x, 2] * (self._hw.readings[x, 4] - self._hw.sp)) / self._hw.readings[x, 3])
             R_std = 100. * np.std((self._hw.readings[x, 2] * (self._hw.readings[x, 4] - self._hw.sp)) / self._hw.readings[x, 3]) / R
+            Vmn = np.mean(self._hw.readings[x, 2] * (self._hw.readings[x, 4] - self._hw.sp))
+            Vmn_std = 100. * np.std(self._hw.readings[x, 2] * (self._hw.readings[x, 4] - self._hw.sp))
+            I = np.mean(self._hw.readings[x, 3])
+            I = 100. * np.std(self._hw.readings[x, 3])
             d = {
                 "time": datetime.now().isoformat(),
                 "A": quad[0],
@@ -472,8 +476,8 @@ class OhmPi(object):
                 "M": quad[2],
                 "N": quad[3],
                 "inj time [ms]": injection_duration,  # NOTE: check this
-                # "Vmn [mV]": sum_vmn / (2 * nb_stack),
-                # "I [mA]": sum_i / (2 * nb_stack),
+                "Vmn [mV]": Vmn,
+                "I [mA]": I,
                 "R [ohm]": R,
                 "R_std [%]": R_std,
                 "Ps [mV]": self._hw.sp,
@@ -483,10 +487,10 @@ class OhmPi(object):
                 "Nb samples [-]": len(self._hw.readings),  # TODO: use only samples after a delay in each pulse
                 "fulldata": self._hw.readings[:, [0, -2, -1]],
                 # "I_stack [mA]": i_stack_mean,
-                # "I_std [mA]": i_std,
+                "I_std [mA]": I_std,
                 # "I_per_stack [mA]": np.array([np.mean(i_stack[i*2:i*2+2]) for i in range(nb_stack)]),
                 # "Vmn_stack [mV]": vmn_stack_mean,
-                # "Vmn_std [mV]": vmn_std,
+                "Vmn_std [mV]": Vmn_std,
                 # "Vmn_per_stack [mV]": np.array([np.diff(np.mean(vmn_stack[i*2:i*2+2], axis=1))[0] / 2 for i in range(nb_stack)]),
                 # "R_stack [ohm]": r_stack_mean,
                 # "R_std [ohm]": r_stack_std,
-- 
GitLab