summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2020-10-29 08:56:47 +0100
committerDaniel Friesel <daniel.friesel@uos.de>2020-10-29 08:56:47 +0100
commitffed53f80fc9cd6441496a16b58bc627bb24b270 (patch)
tree259540cf078239f4b5f73300a8ccf3ce5828220a
parenta9c77c356588203399d9ef62963c965676b7e413 (diff)
--skip: use seconds instead of raw samples
-rwxr-xr-xbin/msp430-etv22
1 files changed, 12 insertions, 10 deletions
diff --git a/bin/msp430-etv b/bin/msp430-etv
index 424a077..51c9013 100755
--- a/bin/msp430-etv
+++ b/bin/msp430-etv
@@ -252,10 +252,10 @@ def main():
)
parser.add_argument(
"--skip",
- metavar="COUNT",
+ metavar="N",
type=int,
default=0,
- help="Skip COUNT data samples. This is useful to avoid startup code influencing the results of a long-running measurement",
+ 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",
@@ -324,14 +324,13 @@ def main():
data_count = sum(map(lambda x: len(x) > 0 and x[0] != "#", lines))
data_lines = filter(lambda x: len(x) > 0 and x[0] != "#", lines)
- data = np.empty((data_count - args.skip, 4))
+ data = np.empty((data_count, 4))
+ skip_offset = 0
+ limit_index = data_count
energy_overflow_count = 0
prev_total_energy = 0
for i, line in enumerate(data_lines):
- if i < args.skip:
- continue
-
fields = line.split(" ")
if len(fields) == 4:
timestamp, current, voltage, total_energy = map(int, fields)
@@ -345,14 +344,17 @@ def main():
prev_total_energy = total_energy
total_energy += energy_overflow_count * (2 ** 32)
+ if args.skip is not None and timestamp * 1e-6 < args.skip:
+ skip_offset = i + 1
+ continue
+
if args.limit is not None and timestamp * 1e-6 > args.limit:
- final_index = i - args.skip - 1
+ limit_index = i - 1
break
- data[i - args.skip] = [timestamp, current, voltage, total_energy]
+ data[i] = [timestamp, current, voltage, total_energy]
- if args.limit is not None:
- data = data[:final_index]
+ data = data[skip_offset:limit_index]
m_duration_us = data[-1, 0] - data[0, 0]
m_energy_nj = data[-1, 3] - data[0, 3]