29 lines
1.5 KiB
Python
29 lines
1.5 KiB
Python
"""Instants where at least MIN sensors deviate by >= 0.02 px from the median of their +-3 neighbours (corr_x or corr_y),
|
|||
|
|
or a sensor is rejected, outside the non-thermal labels of a file. Usage: forgotten.py LABELS [MIN]"""
|
||
|
|
import sys, json, statistics as st
|
||
|
|
sys.path.insert(0, __file__.rsplit('/', 1)[0]); sys.path.insert(0, 'tools/scripts')
|
||
|
|
from scan import load
|
||
|
|
import data
|
||
|
|
by, refs, cam = load()
|
||
|
|
labs = [json.loads(l) for l in open(sys.argv[1])]
|
||
|
|
MIN = int(sys.argv[2]) if len(sys.argv) > 2 else 5
|
||
|
|
t0, t1 = data.parse_time('2026-10-23T23:55Z'), data.parse_time('2026-11-01T11:40Z')
|
||
|
|
iv = [(data.parse_time(l['start']), data.parse_time(l['end'])) for l in labs if l['family'] != 'Thermal displacement']
|
||
|
|
dev = {}
|
||
|
|
for s, ms in by.items():
|
||
|
|
for col in ('corr_x', 'corr_y'):
|
||
|
|
pts = [(m['t'], m[col]) for m in ms if m[col] is not None]
|
||
|
|
for i, (t, v) in enumerate(pts):
|
||
|
|
if not t0 <= t <= t1: continue
|
||
|
|
nb = [p[1] for p in pts[max(0, i-3):i] + pts[i+1:i+4]]
|
||
|
|
d = v - st.median(nb)
|
||
|
|
if abs(d) >= 0.02: dev.setdefault(t, []).append((abs(d), f"{s}{col[-1]}{d:+.3f}"))
|
||
|
|
rej = {}
|
||
|
|
for s, ms in by.items():
|
||
|
|
for m in ms:
|
||
|
|
if t0 <= m['t'] <= t1 and data.rejected(m): rej.setdefault(m['t'], []).append(s)
|
||
|
|
for t in sorted(set(dev) | set(rej)):
|
||
|
|
if any(a < t < b for a, b in iv): continue
|
||
|
|
d = sorted(dev.get(t, []), reverse=True)
|
||
|
|
if len(d) >= MIN or t in rej:
|
||
|
|
print(data.iso(t), 'REJ:' + ','.join(rej[t]) if t in rej else '', len(d), ' '.join(x for _, x in d[:10]))
|