This commit is contained in:
matthias@arch 2023-08-17 01:19:03 +02:00
parent 8b8880a6e9
commit a672ab3dc2
2 changed files with 45 additions and 6 deletions

View File

@ -66,7 +66,9 @@ from m_teng.utility.data import load_dataframe
from m_teng.utility import file_io from m_teng.utility import file_io
from m_teng.update_funcs import _Monitor, _ModelPredict, _update_print from m_teng.update_funcs import _Monitor, _ModelPredict, _update_print
config_path = path.expanduser("~/.config/k-teng.json") from m_teng.backends import keithley as _keithley
config_path = path.expanduser("~/.config/m-teng.json")
_runtime_vars = { _runtime_vars = {
"last-measurement": "" "last-measurement": ""
@ -75,7 +77,7 @@ _runtime_vars = {
settings = { settings = {
"datadir": path.expanduser("~/data"), "datadir": path.expanduser("~/data"),
"name": "measurement", "name": "measurement",
"interval": 0.05, "interval": 0.02,
"beep": True, "beep": True,
} }

View File

@ -1,11 +1,13 @@
import pandas as pd import pandas as pd
import numpy as np import numpy as np
from os import path from os import path
import matplotlib.pyplot as plt
def buffer2dataframe(buffer): # deprecated
df = pd.DataFrame(buffer) # def buffer2dataframe(buffer):
df.colums = ["Time [s]", "Voltage [V]"] # df = pd.DataFrame(buffer)
return df # df.colums = ["Time [s]", "Voltage [V]"]
# return df
def buffers2dataframe(ibuffer, vbuffer): def buffers2dataframe(ibuffer, vbuffer):
""" """
@ -30,3 +32,38 @@ def load_dataframe(p:str):
else: else:
df = pd.read_pickle(p) df = pd.read_pickle(p)
return df return df
def plot(data: str or pd.DataFrame or np.ndarray, title="", U=True, I=False):
"""
Plot recorded data
@param data: filepath, dataframe or numpy array
"""
if type(data) == str:
_data = load_dataframe(data).to_numpy()
elif type(data) == pd.DataFrame:
_data = data.to_numpy()
else:
_data = data
print(_data[0])
plt.ion()
fig, ax = plt.subplots()
ax.set_xlabel("t [s]")
vax = ax
iax = ax
if U and I:
iax = ax.twinx()
if U:
vax = ax
vax.set_ylabel("U [V]")
vax.plot(_data[:,0], _data[:,2], color="blue", label="voltage")
if I:
iax.set_ylabel("I [A]")
iax.plot(_data[:,0], _data[:,1], color="orange", label="current")
if U and I:
plt.legend()
return fig