Forked from HYCAR-Hydro / airGR
Source project has a limited visibility.
Measurement.ipynb 11.69 KiB
In [1]:
# %matplotlib nbagg
from IPython.display import display, HTML
display(HTML(""))
display(HTML(""))
display(HTML(""))

import random

def hide_toggle(for_next=False):
    this_cell = """$('div.cell.code_cell.rendered.selected')"""
    next_cell = this_cell + '.next()'

    toggle_text = 'Toggle show/hide'  # text shown on toggle link
    target_cell = this_cell  # target cell to control with toggle
    js_hide_current = ''  # bit of JS to permanently hide code in current cell (only when toggling next cell)

    if for_next:
        target_cell = next_cell
        toggle_text += ' next cell'
        js_hide_current = this_cell + '.find("div.input").hide();'

    js_f_name = 'code_toggle_{}'.format(str(random.randint(1,2**64)))

    html = """
        

        {toggle_text}
    """.format(
        f_name=js_f_name,
        cell_selector=target_cell,
        js_hide_current=js_hide_current, 
        toggle_text=toggle_text
    )

    return HTML(html)

hide_toggle()
Out [1]:
In [2]:
from ohmpi import OhmPi
import matplotlib.pyplot as plt
Out [2]:
 ________________________________
|  _  | | | ||  \/  || ___ \_   _|
| | | | |_| || .  . || |_/ / | |
| | | |  _  || |\/| ||  __/  | |
\ \_/ / | | || |  | || |    _| |_
 \___/\_| |_/\_|  |_/\_|    \___/ 
Version: 2.1.5
☑ Running on raspberry pi 3 model b rev 1.2 platform
local date and time : 2023-04-26 08:20:07
In [3]:
from OhmPi_ML import run_measurement_new, append_and_save_new

setattr(OhmPi,"run_measurement",run_measurement_new)
k = OhmPi(idps=False,use_mux=False)

k.append_and_save = append_and_save_new

hide_toggle()
Out [3]:
2023-04-26 08:20:07 UTC | 1495 | INFO: 
2023-04-26 08:20:07 UTC | 1495 | INFO: ****************************
2023-04-26 08:20:07 UTC | 1495 | INFO: *** NEW SESSION STARTING ***
2023-04-26 08:20:07 UTC | 1495 | INFO: ****************************
2023-04-26 08:20:07 UTC | 1495 | INFO: 
2023-04-26 08:20:07 UTC | 1495 | INFO: Remaining disk space : 7244.7 MB
2023-04-26 08:20:07 UTC | 1495 | INFO: Saving data log to /home/pi/OhmPi/data/data.log
2023-04-26 08:20:07 UTC | 1495 | INFO: Starting_session

☑ Publishes execution as ohmpi_0001/exec topic on the localhost broker
☑ Publishes data as ohmpi_0001/data topic on the localhost broker
☑ Subscribed to control topic ohmpi_0001/ctrl on localhost broker
In [5]:
quad = [1,4,2,3]


k = OhmPi(idps=False,use_mux=False)
k.reset_mux()
k.switch_mux_on(quad)
out = k.run_measurement(quad,tx_volt=12,injection_duration=1,strategy='constant',nb_stack=3,autogain=False,duty_cycle=0.8)
k.switch_mux_off(quad)
k.reset_mux()

data = out['fulldata']
fig, (ax1,ax2) = plt.subplots(2, sharex=True)
ax1.plot(data[:, 2], data[:, 0], 'r.-', label='current [mA]')
ax1.set_ylabel('Current (mA)')
ax1.set_title('Current')
ax2.plot(data[:, 2], data[:, 1], '.-', label='Voltage [mV]',alpha=.5)
ax2.set_xlabel('Time (s)')
ax2.set_ylabel('Voltage (mV)')
ax2.set_title('Voltage')
plt.show()
Out [5]:
2023-04-26 08:21:17 UTC | 1495 | INFO: 
2023-04-26 08:21:17 UTC | 1495 | INFO: 
2023-04-26 08:21:17 UTC | 1495 | INFO: 
2023-04-26 08:21:17 UTC | 1495 | INFO: ****************************
2023-04-26 08:21:17 UTC | 1495 | INFO: ****************************
2023-04-26 08:21:17 UTC | 1495 | INFO: ****************************
2023-04-26 08:21:17 UTC | 1495 | INFO: *** NEW SESSION STARTING ***
2023-04-26 08:21:17 UTC | 1495 | INFO: *** NEW SESSION STARTING ***
2023-04-26 08:21:17 UTC | 1495 | INFO: *** NEW SESSION STARTING ***
2023-04-26 08:21:17 UTC | 1495 | INFO: ****************************
2023-04-26 08:21:17 UTC | 1495 | INFO: ****************************
2023-04-26 08:21:17 UTC | 1495 | INFO: ****************************
2023-04-26 08:21:18 UTC | 1495 | INFO: 
2023-04-26 08:21:18 UTC | 1495 | INFO: 
2023-04-26 08:21:18 UTC | 1495 | INFO: 
2023-04-26 08:21:18 UTC | 1495 | INFO: Remaining disk space : 7244.6 MB
2023-04-26 08:21:18 UTC | 1495 | INFO: Remaining disk space : 7244.6 MB
2023-04-26 08:21:18 UTC | 1495 | INFO: Remaining disk space : 7244.6 MB
2023-04-26 08:21:18 UTC | 1495 | INFO: Saving data log to /home/pi/OhmPi/data/data.log
2023-04-26 08:21:18 UTC | 1495 | INFO: Saving data log to /home/pi/OhmPi/data/data.log
2023-04-26 08:21:18 UTC | 1495 | INFO: Saving data log to /home/pi/OhmPi/data/data.log
2023-04-26 08:21:18 UTC | 1495 | INFO: Starting_session
2023-04-26 08:21:18 UTC | 1495 | INFO: Starting_session
2023-04-26 08:21:18 UTC | 1495 | INFO: Starting_session

☑ Publishes execution as ohmpi_0001/exec topic on the localhost broker
☑ Publishes data as ohmpi_0001/data topic on the localhost broker
☑ Subscribed to control topic ohmpi_0001/ctrl on localhost broker
Out [5]:
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
Cell In[5], line 5
      1 quad = [[1,4,2,3],[1,4,2,3]]
      4 k = OhmPi(idps=False,use_mux=False)
----> 5 k.sequence = quad
      6 k.reset_mux()
      7 k.switch_mux_on(quad)

File ~/OhmPi/ohmpi.py:1688, in OhmPi.sequence(self, sequence)
   1686 """Sets sequence"""
   1687 if sequence is not None:
-> 1688     assert isinstance(sequence, np.ndarray)
   1689     self.use_mux = True
   1690 else:

AssertionError: