From 5d9c8d25a03577a6ee5394ea22f4c05486388eb5 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 29 Oct 2020 08:57:51 +0100 Subject: add --skip option --- bin/dlog-viewer | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/bin/dlog-viewer b/bin/dlog-viewer index aa3e256..298c6fc 100755 --- a/bin/dlog-viewer +++ b/bin/dlog-viewer @@ -158,7 +158,8 @@ class DLogChannel: class DLog: - def __init__(self, filename, limit=None): + def __init__(self, filename, skip=None, limit=None): + self.skip_duration = skip self.limit_duration = limit self.load_dlog(filename) @@ -205,6 +206,18 @@ class DLog: 0, self.observed_duration, num=int(len(raw_data) / (4 * num_channels)) ) + if ( + self.skip_duration is not None + and self.observed_duration >= self.skip_duration + ): + start_offset = 0 + for i, ts in enumerate(self.timestamps): + if ts >= self.skip_duration: + start_offset = i + break + self.timestamps = self.timestamps[start_offset:] + raw_data = raw_data[start_offset * 4 * num_channels :] + if ( self.limit_duration is not None and self.observed_duration > self.limit_duration @@ -471,6 +484,13 @@ def main(): type=str, help="Export analysis results (e.g. changepoints) to JSON file", ) + parser.add_argument( + "--skip", + metavar="N", + type=int, + default=0, + help="Skip the first N seconds of data. This is useful to avoid startup code influencing the results of a long-running measurement", + ) parser.add_argument( "--limit", type=float, @@ -494,7 +514,7 @@ def main(): args = parser.parse_args() - dlog = DLog(args.dlog_file, args.limit) + dlog = DLog(args.dlog_file, args.skip, args.limit) if args.stat: print_stats(dlog) -- cgit v1.2.3