summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2020-09-02 09:24:47 +0200
committerDaniel Friesel <daniel.friesel@uos.de>2020-09-02 09:24:47 +0200
commit5d71b3b646ee5910724383891e102e291215733d (patch)
treecf50aa4a8aff47d0ce793f3a5da759aa2c3e4f50 /bin
parent68455010010960eceacffacfd75b57dddfa74f89 (diff)
Allow voltage and current to be plotted individually
Diffstat (limited to 'bin')
-rwxr-xr-xbin/dlog-viewer61
1 files changed, 54 insertions, 7 deletions
diff --git a/bin/dlog-viewer b/bin/dlog-viewer
index 24657b2..bdbf81c 100755
--- a/bin/dlog-viewer
+++ b/bin/dlog-viewer
@@ -183,14 +183,14 @@ def show_power_plot(dlog):
handles = list()
for slot in dlog.slots:
- if "W" in slot:
+ if "A" in slot:
(handle,) = plt.plot(
- dlog.timestamps, slot["W"].data, "b-", label="P", markersize=1
+ dlog.timestamps, slot["A"].data, "b-", label="P", markersize=1
)
handles.append(handle)
(handle,) = plt.plot(
dlog.timestamps,
- running_mean(slot["W"].data, 10),
+ running_mean(slot["A"].data, 10),
"r-",
label="mean(P, 10)",
markersize=1,
@@ -221,6 +221,51 @@ def show_power_plot(dlog):
plt.show()
+def show_unit_plot(dlog, metric):
+
+ handles = list()
+
+ if metric == "U":
+ unit = "V"
+ elif metric == "I":
+ unit = "A"
+ elif metric == "P":
+ unit = "W"
+
+ for slot in dlog.slots:
+ if unit in slot:
+ channel = slot[unit]
+ (handle,) = plt.plot(
+ dlog.timestamps,
+ slot[unit].data,
+ "b-",
+ label=f"slot {channel.slot} ({channel.smu})",
+ markersize=1,
+ )
+ handles.append(handle)
+ (handle,) = plt.plot(
+ dlog.timestamps,
+ running_mean(slot[unit].data, 10),
+ "r-",
+ label=f"slot {channel.slot} mean",
+ markersize=1,
+ )
+ handles.append(handle)
+
+ plt.legend(handles=handles)
+ plt.xlabel("Time [s]")
+ if unit == "V":
+ plt.ylabel("Voltage [V]")
+ elif unit == "A":
+ plt.ylabel("Current [A]")
+ elif unit == "W":
+ plt.ylabel("Power [W]")
+ else:
+ plt.ylabel(f"??? [{unit}]")
+ plt.grid(True)
+ plt.show()
+
+
def show_raw_plot(dlog):
handles = list()
@@ -267,8 +312,8 @@ def main():
)
parser.add_argument(
"--plot",
- help="Draw plots of voltage/current/power overtime",
- action="store_true",
+ choices=["U", "I", "P", "all"],
+ help="Plot voltage/current/power over time",
)
parser.add_argument(
"--stat", help="Print mean voltage, current, and power", action="store_true"
@@ -288,10 +333,12 @@ def main():
export_csv(dlog, args.csv_export)
if args.plot:
- if dlog.all_data_slots_have_power():
+ if args.plot == "P" and dlog.all_data_slots_have_power():
show_power_plot(dlog)
- else:
+ elif args.plot == "all":
show_raw_plot(dlog)
+ else:
+ show_unit_plot(dlog, args.plot)
if __name__ == "__main__":