From 68455010010960eceacffacfd75b57dddfa74f89 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 1 Sep 2020 18:13:06 +0200 Subject: Handle invalid data --- bin/dlog-viewer | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bin/dlog-viewer b/bin/dlog-viewer index f567772..24657b2 100755 --- a/bin/dlog-viewer +++ b/bin/dlog-viewer @@ -108,7 +108,13 @@ class DLog: channel_offset = 0 measurement_offset = 0 for value in iterator: - self.data[channel_offset, measurement_offset] = value[0] + if value[0] < -1e6 or value[0] > 1e6: + print( + f"Invalid data value {value[0]} at channel {channel_offset}, measurement {measurement_offset}. Replacing with 0." + ) + self.data[channel_offset, measurement_offset] = 0 + else: + self.data[channel_offset, measurement_offset] = value[0] if channel_offset + 1 == num_channels: channel_offset = 0 measurement_offset += 1 -- cgit v1.2.3