Scripts: shared helpers in common.py, no tool imports another; CLI and outputs unchanged
data.py stays the reader (METRIC_RE now also captures the file date, same matches); common.py holds columns, steps, noise, sensor list, runs, file names. Duplicated run grouping, pose gaps, step bucketing, --table/--outside parsing removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c1719cbd1d
commit
6ed4c420e1
13 files changed
+308
-359
No files matched your search
+8
-15
@@ -34,8 +34,8 @@ import bisect
|
||||
import statistics
|
||||
import sys
|
||||
|
||||
from data import filter_window, is_reference, iso, load, parse_time, rejected
|
||||
from summary import COLUMNS, duration, own_noise
|
||||
from common import COLUMNS, check, duration, outside, own_noise, sensors
|
||||
from data import filter_window, is_reference, iso, parse_time, rejected
|
||||
|
||||
ABBREV = {"corr_x": "cx", "corr_y": "cy", "error_value": "ev"}
|
||||
|
||||
@@ -68,18 +68,11 @@ def main():
|
||||
a.add_argument("--end", type=parse_time)
|
||||
o = a.parse_args()
|
||||
|
||||
by = load(o.folder)
|
||||
if not by:
|
||||
sys.exit(f'No "advanced" export in {o.folder} (see inventory.py).')
|
||||
names = o.sensors.split(",") if o.sensors else sorted(by, key=lambda s: (not is_reference(by[s]), s))
|
||||
by, names = sensors(o.folder, o.sensors)
|
||||
columns = o.columns.split(",")
|
||||
outside = tuple(parse_time(x) for x in o.outside.split("/")) if o.outside else None
|
||||
if outside and len(outside) != 2:
|
||||
sys.exit("--outside expects T1/T2.")
|
||||
for requested, known, what in ((names, by, "sensors"), (columns, COLUMNS, "columns")):
|
||||
missing = [x for x in requested if x not in known]
|
||||
if missing:
|
||||
sys.exit(f"Unknown {what}: {', '.join(missing)}. Known: {', '.join(sorted(known))}.")
|
||||
kept = outside(o.outside)
|
||||
check("sensors", names, by)
|
||||
check("columns", columns, COLUMNS)
|
||||
series = {s: filter_window(by[s], o.start, o.end) for s in names}
|
||||
if not any(series.values()):
|
||||
sys.exit("No measurement in the requested window.")
|
||||
@@ -96,7 +89,7 @@ def main():
|
||||
if len(ms) < 2:
|
||||
print(f"{s:9}{len(ms):5} (fewer than 2 values)")
|
||||
continue
|
||||
ref = [x for x in ms if not outside or not outside[0] <= x[0] <= outside[1]]
|
||||
ref = [x for x in ms if kept(x[0])]
|
||||
if len(ref) < 2:
|
||||
print(f"{s:9}{len(ms):5} (fewer than 2 values outside --outside)")
|
||||
continue
|
||||
@@ -123,7 +116,7 @@ def main():
|
||||
ranges.append((s, group, noise, rej))
|
||||
total = len(ranges)
|
||||
ranges = [p for p in ranges if len(p[1]) >= o.min_measurements]
|
||||
print(f"\n{col}: ranges more than {o.k:g} noises from the level{' rolling ±' + roll + ' (median of the neighbours)' if roll else ''}{' (level outside ' + o.outside + ')' if outside and not roll else ''}{' (noise outside ' + o.outside + ')' if outside and roll else ''} (merge {int(o.merge.total_seconds() // 60)} min)"
|
||||
print(f"\n{col}: ranges more than {o.k:g} noises from the level{' rolling ±' + roll + ' (median of the neighbours)' if roll else ''}{' (level outside ' + o.outside + ')' if o.outside and not roll else ''}{' (noise outside ' + o.outside + ')' if o.outside and roll else ''} (merge {int(o.merge.total_seconds() // 60)} min)"
|
||||
+ (f"; {len(ranges)} of at least {o.min_measurements} measurements out of {total}" if o.min_measurements > 1 else ""))
|
||||
print(f"{'sensor':9}{'start':<18}{'end':<18}{'measurements':>13}{'extreme':>10}{'(noises)':>9} {'at':<17}{'rejected':>9}")
|
||||
for s, g, noise, rej in ranges:
|
||||
|
||||
Reference in new issue
Block a user