diff --git a/measure.py b/measure.py index 3033b3c5748af102cae1ff210a5a8bce5695d422..6102f7a9cc2042030ac55bd4d9ab3585410bb546 100644 --- a/measure.py +++ b/measure.py @@ -62,6 +62,15 @@ class OhmPiHardware: self.tx.voltage_pulse(length=duration) self.tx_sync.clear() + @property + def pulses(self): + pulses = {} + for i in np.unique(self.readings[:,1]): + r = self.readings[self.readings[:, 1] == i, :] + assert np.all(np.isclose(r[:,2], r[0, 2])) # Polarity cannot change within a pulse + pulses.update({i: {'polarity': int(r[0, 2]), 'iab': r[:,3], 'vmn' : r[:,4]}}) # TODO: check how to generalize in case of multi-channel RX + return pulses + def _read_values(self, sampling_rate, append=False): # noqa if not append: self._clear_values() diff --git a/test_measure_with_ohmpi_card_3_15.py b/test_measure_with_ohmpi_card_3_15.py index c2b9576ce7397dc2a4c20d8842648be6a7c72f91..da5436c02b7d5d319a226d9183fa1da85ad7995a 100644 --- a/test_measure_with_ohmpi_card_3_15.py +++ b/test_measure_with_ohmpi_card_3_15.py @@ -42,5 +42,8 @@ plt.show() print(f'SP: {k.sp} mV') r = ((k.readings[:,4]-k.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} %') +print('\nTesting with pulses') +r = np.array([(k.pulses[i]['vmn']-k.sp)/k.pulses[i]['iab'] for i in k.pulses.keys()]) +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)