Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
6ab6aba43b | ||
|
6a8c05eec0 | ||
|
8621a18169 | ||
|
d479830a76 | ||
|
849730be09 | ||
|
a672ab3dc2 |
@ -1,2 +0,0 @@
|
|||||||
include regina/package-data/*
|
|
||||||
include regina/sql/*.sql
|
|
@ -66,7 +66,7 @@ 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")
|
config_path = path.expanduser("~/.config/m-teng.json")
|
||||||
|
|
||||||
_runtime_vars = {
|
_runtime_vars = {
|
||||||
"last-measurement": ""
|
"last-measurement": ""
|
||||||
@ -75,7 +75,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,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +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
|
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):
|
||||||
"""
|
"""
|
||||||
@ -32,22 +33,37 @@ def load_dataframe(p:str):
|
|||||||
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):
|
||||||
def plot(data):
|
"""
|
||||||
|
Plot recorded data
|
||||||
|
@param data: filepath, dataframe or numpy array
|
||||||
|
"""
|
||||||
if type(data) == str:
|
if type(data) == str:
|
||||||
data = load_dataframe(data)
|
_data = load_dataframe(data).to_numpy()
|
||||||
if type(data) == pd.Dataframe:
|
elif type(data) == pd.DataFrame:
|
||||||
data = data.to_numpy()
|
_data = data.to_numpy()
|
||||||
fig1, (vax, iax) = plt.subplots(2, 1, figsize=(8, 5))
|
else:
|
||||||
# todo
|
_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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
vline, = vax.plot(index, vdata, color="m")
|
|
||||||
vax.set_ylabel("Voltage [V]")
|
|
||||||
vax.grid(True)
|
|
||||||
|
|
||||||
vax.plot()
|
|
||||||
|
|
||||||
iline, = iax.plot(index, idata, color="m")
|
|
||||||
iax.set_ylabel("Current [A]")
|
|
||||||
iax.grid(True)
|
|
||||||
|
@ -20,6 +20,7 @@ classifiers = [
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"matplotlib>=3.6",
|
"matplotlib>=3.6",
|
||||||
"numpy",
|
"numpy",
|
||||||
|
"pandas",
|
||||||
]
|
]
|
||||||
|
|
||||||
[project.optional-dependencies]
|
[project.optional-dependencies]
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
# m-TENG
|
# m-TENG
|
||||||
Helper scripts and shell for measuring **T**ribo**e**lectric **N**ano**g**enerator-based sensor output with a Keithley 2600B SMU or an Arduino
|
Helper scripts and shell for measuring **T**ribo**e**lectric **N**ano**g**enerator-based sensor output with a Keithley 2600B SMU or an Arduino
|
||||||
|
|
||||||
|
This project was written for my bachelor's thesis.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
### Interactive (shell) mode
|
### Interactive (shell) mode
|
||||||
@ -33,7 +35,7 @@ Helper scripts and shell for measuring **T**ribo**e**lectric **N**ano**g**enerat
|
|||||||
## Shell mode
|
## Shell mode
|
||||||
It is recommended to run the shell with ipython:
|
It is recommended to run the shell with ipython:
|
||||||
```shell
|
```shell
|
||||||
ipython -i k_teng_interactive.py -- -*X*
|
ipython -i m_teng_interactive.py -- -*X*
|
||||||
```
|
```
|
||||||
Substitute *X* for `-k` for keithley backend, `-a` for arduino backend or `-t` for testing backend.
|
Substitute *X* for `-k` for keithley backend, `-a` for arduino backend or `-t` for testing backend.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user