From 4fc0e714bdc651c7e7afc663b2962bb87e9a9815 Mon Sep 17 00:00:00 2001
From: su530201 <olivier.kaufmann@umons.ac.be>
Date: Sun, 23 Apr 2023 11:01:40 +0200
Subject: [PATCH] Adds pulse number in readings

---
 test_measure_with_ohmpi_card_3_15.py | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/test_measure_with_ohmpi_card_3_15.py b/test_measure_with_ohmpi_card_3_15.py
index f48f4c70..da60b4cb 100644
--- a/test_measure_with_ohmpi_card_3_15.py
+++ b/test_measure_with_ohmpi_card_3_15.py
@@ -16,7 +16,7 @@ print(f'sampling rate: {k.rx.sampling_rate:.1f} ms, mean sample spacing: {np.mea
 
 # Test #2:
 print('\n\nTesting vab_square_wave')
-k.vab_square_wave(vab=12, cycle_length=2., sampling_rate=k.rx.sampling_rate, cycles=3)
+k.vab_square_wave(vab=12, cycle_length=1., sampling_rate=k.rx.sampling_rate, cycles=3)
 r = k.readings[:,4]/k.readings[:,3]
 print(f'Mean resistance: {np.mean(r):.3f} Ohms, Dev. {100*np.std(r)/np.mean(r):.1f} %')
 print(f'sampling rate: {k.rx.sampling_rate:.1f} ms, mean sample spacing: {np.mean(np.diff(k.readings[:,0]))*1000.:.1f} ms')
@@ -31,4 +31,19 @@ ax2.plot(k.readings[:,0], k.readings[:,2]*k.readings[:,4], '-b', marker='.', lab
 ax2.set_ylabel('Vmn [mV]')
 fig.legend()
 plt.show()
+# compote mean voltages inside pulses
+pulses = k.readings[:,1]
+mean_vmn=[]
+mean_iab=[]
+for i in range(int(np.min(pulses)), int(np.max(pulses))+1):
+    mean_vmn.append(np.mean(k.readings[k.readings[:,1]==i, 4]))
+    mean_iab.append(np.mean(k.readings[k.readings[:,1]==i, 3]))
+mean_vmn = np.array(mean_vmn)
+mean_iab = np.array(mean_iab)
+print(f'Vmn: {mean_vmn}, Iab: {mean_iab}')
+sp = np.mean(mean_vmn[np.ix_([0,2,4])]-mean_vmn[np.ix_([1,3,5])])/2
+print(f'SP: {sp} mV')
+r = ((k.readings[:,4]+k.readings[:,1]*sp)/k.readings[:,3])
+print(f'Mean resistance with sp correction : {np.mean(r):.3f} Ohms, Dev. {100*np.std(r)/np.mean(r):.1f} %')
 change_config('config_default.py', verbose=False)
+
-- 
GitLab