Loading bin/dlog-viewer +15 −29 Changes for bin/dlog-viewer: 15 added lines, 29 removed lines. Original line number Original line Diff line number Diff line Loading @@ -3,10 +3,6 @@ """dlog-viewer - View and Convert Keysight .dlog Files """dlog-viewer - View and Convert Keysight .dlog Files USAGE dlog-viewer [--csv-export <file.csv>] [--plot] [--stat] <file.dlog> DESCRIPTION DESCRIPTION dlog-viewer loads voltage, current, and/or power measurements from .dlog files dlog-viewer loads voltage, current, and/or power measurements from .dlog files Loading @@ -17,19 +13,10 @@ This program is not affiliated with Keysight and has not been thoroughly tested yet. Use at your own risk. tested yet. Use at your own risk. OPTIONS OPTIONS --csv-export <file.csv> Export measurements as CSV to <file.csv> --plot Draw plots of voltage/current/power over time --stat Print mean voltage, current, and power """ """ import argparse import argparse import csv import csv import lzma import matplotlib.pyplot as plt import matplotlib.pyplot as plt import numpy as np import numpy as np import os import os Loading Loading @@ -75,6 +62,7 @@ class DLog: with open(filename, "rb") as f: with open(filename, "rb") as f: if ".xz" in filename: if ".xz" in filename: import lzma f = lzma.open(f) f = lzma.open(f) while line != "</dlog>\n": while line != "</dlog>\n": Loading Loading @@ -157,6 +145,19 @@ class DLog: def print_stats(dlog): def print_stats(dlog): if dlog.duration_deviates: print( "Measurement duration: {:f} of {:d} seconds at {:f} µs per sample".format( dlog.observed_duration, dlog.planned_duration, dlog.interval * 1000000 ) ) else: print( "Measurement duration: {:d} seconds at {:f} µs per sample".format( dlog.planned_duration, dlog.interval * 1000000 ) ) for channel in dlog.channels: for channel in dlog.channels: min_data = np.min(channel.data) min_data = np.min(channel.data) max_data = np.max(channel.data) max_data = np.max(channel.data) Loading Loading @@ -245,7 +246,7 @@ def export_csv(dlog, filename): with open(filename, "w", newline="") as f: with open(filename, "w", newline="") as f: writer = csv.writer(f) writer = csv.writer(f) channel_header = list( channel_header = list( map(lambda x: f"Slot {x.slot} {x.unit} ({x.smu})", dlog.channels) map(lambda x: f"{x.smu} in slot {x.slot} [{x.unit}]", dlog.channels) ) ) writer.writerow(["Timestamp [s]"] + channel_header) writer.writerow(["Timestamp [s]"] + channel_header) for row in range(rows): for row in range(rows): Loading Loading @@ -273,23 +274,8 @@ def main(): args = parser.parse_args() args = parser.parse_args() print(args) dlog = DLog(args.dlog_file) dlog = DLog(args.dlog_file) if dlog.duration_deviates: print( "Measurement duration: {:f} of {:d} seconds at {:f} µs per sample".format( dlog.observed_duration, dlog.planned_duration, dlog.interval * 1000000 ) ) else: print( "Measurement duration: {:d} seconds at {:f} µs per sample".format( dlog.planned_duration, dlog.interval * 1000000 ) ) if args.stat: if args.stat: print_stats(dlog) print_stats(dlog) Loading Loading
bin/dlog-viewer +15 −29 Changes for bin/dlog-viewer: 15 added lines, 29 removed lines. Original line number Original line Diff line number Diff line Loading @@ -3,10 +3,6 @@ """dlog-viewer - View and Convert Keysight .dlog Files """dlog-viewer - View and Convert Keysight .dlog Files USAGE dlog-viewer [--csv-export <file.csv>] [--plot] [--stat] <file.dlog> DESCRIPTION DESCRIPTION dlog-viewer loads voltage, current, and/or power measurements from .dlog files dlog-viewer loads voltage, current, and/or power measurements from .dlog files Loading @@ -17,19 +13,10 @@ This program is not affiliated with Keysight and has not been thoroughly tested yet. Use at your own risk. tested yet. Use at your own risk. OPTIONS OPTIONS --csv-export <file.csv> Export measurements as CSV to <file.csv> --plot Draw plots of voltage/current/power over time --stat Print mean voltage, current, and power """ """ import argparse import argparse import csv import csv import lzma import matplotlib.pyplot as plt import matplotlib.pyplot as plt import numpy as np import numpy as np import os import os Loading Loading @@ -75,6 +62,7 @@ class DLog: with open(filename, "rb") as f: with open(filename, "rb") as f: if ".xz" in filename: if ".xz" in filename: import lzma f = lzma.open(f) f = lzma.open(f) while line != "</dlog>\n": while line != "</dlog>\n": Loading Loading @@ -157,6 +145,19 @@ class DLog: def print_stats(dlog): def print_stats(dlog): if dlog.duration_deviates: print( "Measurement duration: {:f} of {:d} seconds at {:f} µs per sample".format( dlog.observed_duration, dlog.planned_duration, dlog.interval * 1000000 ) ) else: print( "Measurement duration: {:d} seconds at {:f} µs per sample".format( dlog.planned_duration, dlog.interval * 1000000 ) ) for channel in dlog.channels: for channel in dlog.channels: min_data = np.min(channel.data) min_data = np.min(channel.data) max_data = np.max(channel.data) max_data = np.max(channel.data) Loading Loading @@ -245,7 +246,7 @@ def export_csv(dlog, filename): with open(filename, "w", newline="") as f: with open(filename, "w", newline="") as f: writer = csv.writer(f) writer = csv.writer(f) channel_header = list( channel_header = list( map(lambda x: f"Slot {x.slot} {x.unit} ({x.smu})", dlog.channels) map(lambda x: f"{x.smu} in slot {x.slot} [{x.unit}]", dlog.channels) ) ) writer.writerow(["Timestamp [s]"] + channel_header) writer.writerow(["Timestamp [s]"] + channel_header) for row in range(rows): for row in range(rows): Loading Loading @@ -273,23 +274,8 @@ def main(): args = parser.parse_args() args = parser.parse_args() print(args) dlog = DLog(args.dlog_file) dlog = DLog(args.dlog_file) if dlog.duration_deviates: print( "Measurement duration: {:f} of {:d} seconds at {:f} µs per sample".format( dlog.observed_duration, dlog.planned_duration, dlog.interval * 1000000 ) ) else: print( "Measurement duration: {:d} seconds at {:f} µs per sample".format( dlog.planned_duration, dlog.interval * 1000000 ) ) if args.stat: if args.stat: print_stats(dlog) print_stats(dlog) Loading