Commit da7690f4 authored by Olivier Kaufmann's avatar Olivier Kaufmann
Browse files

Adds save_fig option to _plot_readings

Showing with 7 additions and 4 deletions
+7 -4
......@@ -59,5 +59,5 @@ if within_ohmpi:
# k._hw._plot_readings()
print(f'Resistance: {k._hw.last_rho :.2f} ohm, dev. {k._hw.last_dev:.2f} %, rx bias: {k._hw.rx._bias:.2f} mV')
k._hw._plot_readings()
plot_exec_log('ohmpi/logs/exec.log')
# plot_exec_log('ohmpi/logs/exec.log')
change_config('../configs/config_default.py', verbose=False)
......@@ -313,7 +313,7 @@ class OhmPiHardware:
polarity = 1
return vab, polarity, rab
def _plot_readings(self):
def _plot_readings(self, save_fig=False):
# Plot graphs
fig, ax = plt.subplots(nrows=3, sharex=True)
ax[0].plot(self.readings[:, 0], self.readings[:, 3], '-r', marker='.', label='iab')
......@@ -323,7 +323,10 @@ class OhmPiHardware:
ax[2].plot(self.readings[:, 0], self.readings[:, 2], '-g', marker='.', label='polarity')
ax[2].set_ylabel('polarity [-]')
fig.legend()
plt.show()
if save_fig:
fig.savefig(f'figures/test.png')
else:
plt.show()
def calibrate_rx_bias(self):
self.rx._bias += (np.mean(self.readings[self.readings[:, 2] == 1, 4])
......
......@@ -460,7 +460,7 @@ class OhmPi(object):
delay = 0.
x = np.where((self._hw.readings[:, 0] >= delay) & (self._hw.readings[:, 2] != 0))
R = np.mean(self._hw.readings[x, 2]*self._hw.readings[x, 4])/np.median(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
R_std = 100. * np.std(self._hw.readings[x, 2] * (self._hw.readings[x, 4] - self._hw.sp) / self._hw.readings[x, 3]) / R
d = {
"time": datetime.now().isoformat(),
"A": quad[0],
......
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