Commit 3a8c5bb1 authored by Olivier Kaufmann's avatar Olivier Kaufmann
Browse files

Add last_rho and last_std properties

Showing with 5 additions and 1 deletion
+5 -1
......@@ -48,6 +48,7 @@ if within_ohmpi:
k._hw.switch_mux([1, 4, 2, 3], state='on')
k._hw.vab_square_wave(12,1)
k._hw.switch_mux([1, 4, 2, 3], state='off')
print(f'Resistance: {k._hw.last_rho :.2f}, dev. {k._hw.last_dev:.2f} %')
k._hw._plot_readings()
plot_exec_log('ohmpi/logs/exec.log')
change_config('../configs/config_default.py', verbose=False)
\ No newline at end of file
......@@ -172,7 +172,8 @@ class OhmPiHardware:
sampling_rate = self.rx.sampling_rate
sample = 0
self.exec_logger.info(f'values when starting pulse {self._pulse} : {self.tx.current} mA, {self.rx.voltage} mV')
self.rx.voltage
_ = self.rx.voltage
lap = datetime.datetime.utcnow() # just in case tx_sync is not set immediately after passing wait
self.tx_sync.wait() #
if not append or self._start_time is None:
self._start_time = datetime.datetime.utcnow()
......@@ -196,12 +197,14 @@ class OhmPiHardware:
self._pulse += 1
self.exec_logger.event(f'OhmPiHardware\tread_values\tend\t{datetime.datetime.utcnow()}')
@property
def last_rho(self):
if len(self.readings) > 1:
return np.mean(self.readings[:, 2] * self.readings[:, 4] / self.readings[:, 3])
else:
return np.nan
@property
def last_dev(self):
if len(self.readings) > 1:
return 100. * np.std(self.readings[:, 2] * self.readings[:, 4] / self.readings[:, 3])/self.last_rho()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment