summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2020-08-27 10:45:56 +0200
committerDaniel Friesel <daniel.friesel@uos.de>2020-08-27 10:45:56 +0200
commita3c8589105bee5f1d1c49b1e365a978e58451b3e (patch)
treeada1ddbd694d40688aa563fb47cd206c470d9402 /bin
parenta474830ceed996fd659fcbe21e2c5d903197fa0f (diff)
code cleanup
Diffstat (limited to 'bin')
-rwxr-xr-xbin/dlog-viewer19
1 files changed, 9 insertions, 10 deletions
diff --git a/bin/dlog-viewer b/bin/dlog-viewer
index 8270705..f567772 100755
--- a/bin/dlog-viewer
+++ b/bin/dlog-viewer
@@ -63,6 +63,7 @@ class DLog:
with open(filename, "rb") as f:
if ".xz" in filename:
import lzma
+
f = lzma.open(f)
while line != "</dlog>\n":
@@ -98,11 +99,6 @@ class DLog:
0, self.observed_duration, num=int(len(raw_data) / (4 * num_channels))
)
- if int(self.observed_duration) != self.planned_duration:
- self.duration_deviates = True
- else:
- self.duration_deviates = False
-
self.data = np.ndarray(
shape=(num_channels, int(len(raw_data) / (4 * num_channels))),
dtype=np.float32,
@@ -137,6 +133,9 @@ class DLog:
return True
return False
+ def observed_duration_equals_expectation(self):
+ return int(self.observed_duration) == self.planned_duration
+
def all_data_slots_have_power(self):
for slot in range(4):
if self.slot_has_data(slot) and not self.slot_has_power(slot):
@@ -145,16 +144,16 @@ class DLog:
def print_stats(dlog):
- if dlog.duration_deviates:
+ if dlog.observed_duration_equals_expectation():
print(
- "Measurement duration: {:f} of {:d} seconds at {:f} µs per sample".format(
- dlog.observed_duration, dlog.planned_duration, dlog.interval * 1000000
+ "Measurement duration: {:d} seconds at {:f} µs per sample".format(
+ dlog.planned_duration, dlog.interval * 1000000
)
)
else:
print(
- "Measurement duration: {:d} seconds at {:f} µs per sample".format(
- dlog.planned_duration, dlog.interval * 1000000
+ "Measurement duration: {:f} of {:d} seconds at {:f} µs per sample".format(
+ dlog.observed_duration, dlog.planned_duration, dlog.interval * 1000000
)
)