summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2020-10-29 08:57:51 +0100
committerDaniel Friesel <daniel.friesel@uos.de>2020-10-29 08:57:51 +0100
commit5d9c8d25a03577a6ee5394ea22f4c05486388eb5 (patch)
tree4f88020371ec58927a44704f469dcd15d8f89371
parent3ba277bb4b722e25aa9b06f42be77b1773a9d8b9 (diff)
add --skip option
-rwxr-xr-xbin/dlog-viewer24
1 files 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)
@@ -206,6 +207,18 @@ class DLog:
)
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
):
@@ -472,6 +485,13 @@ def main():
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,
metavar="N",
@@ -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)