Files
aimsight-labeling/auto/analyses/NORDEND_2026-09-04T0615_2026-09-17T0545/scripts/others.py
T

22 lines
1.2 KiB
Python

"""Per sensor, corr minus the median of the other targets at the same instant, hourly median. Usage: others.py START END SENSORS"""
import sys, statistics
sys.path.insert(0, 'tools/scripts')
import data
S, E = data.parse_time(sys.argv[1]), data.parse_time(sys.argv[2])
want = sys.argv[3].split(',')
by = {s: {m['t']: m for m in data.filter_window(ms, S, E)} for s, ms in data.load('data/NORDEND').items()}
tg = [s for s in by if s.startswith('PR') and s != 'PR04']
times = sorted(set().union(*[set(d) for d in by.values()]))
rows = {}
for t in times:
for c in ('corr_x', 'corr_y'):
vals = {s: by[s][t][c] for s in tg if t in by[s] and by[s][t][c] is not None}
for w in want:
if w in vals and len(vals) > 5:
o = statistics.median(v for s, v in vals.items() if s != w)
rows.setdefault((t.replace(minute=0), w, c), []).append(vals[w] - o)
hours = sorted({k[0] for k in rows})
print('hour', *[f"{w}:{c[-1]}" for w in want for c in ('corr_x', 'corr_y')], sep='\t')
for h in hours:
print(data.iso(h)[5:16], *[f"{statistics.median(rows[(h,w,c)]):+.3f}" if (h,w,c) in rows else '' for w in want for c in ('corr_x','corr_y')], sep='\t')