Files
aimsight-labeling/auto/analyses/NEBRASKA_2026-10-03T0000_2026-10-13T0000/scripts/night_dev.py
T

45 lines
2.3 KiB
Python
Raw Normal View History

"""Requalification of the thermal labels: deviation of each target from its night level, in its own noises.
Noise: own_noise (median of consecutive differences) over a calm-ish window before the 9 October jump.
Night level: median of the start-bound measurement and the one before it (the evening/night before the cycle).
Prints, per label, the largest deviations (px, mm, noises) of the targets inside the label (bounds excluded).
"""
import statistics
import sys
from datetime import datetime, timezone
sys.path.insert(0, "tools/scripts")
from common import own_noise # noqa: E402
from data import load, is_reference # noqa: E402
T = lambda s: datetime.strptime(s, "%Y-%m-%dT%H:%MZ").replace(tzinfo=timezone.utc)
NOISE_WIN = (T("2026-10-03T00:00Z"), T("2026-10-09T08:00Z"))
LABELS = [("NEBRASKA-12", "2026-10-04T00:00Z", "2026-10-04T16:00Z"),
("NEBRASKA-13", "2026-10-04T20:00Z", "2026-10-05T16:00Z"),
("NEBRASKA-14", "2026-10-05T20:00Z", "2026-10-06T20:00Z")]
by = load("data/NEBRASKA")
for lid, s, e in LABELS:
s, e = T(s), T(e)
rows = []
for name, ms in by.items():
if is_reference(ms):
continue
for col in ("corr_x", "corr_y"):
win = [m[col] for m in ms if NOISE_WIN[0] <= m["t"] <= NOISE_WIN[1] and m[col] is not None]
noise = own_noise(win)
before = [m for m in ms if m["t"] <= s and m[col] is not None][-2:]
if not noise or len(before) < 2:
continue
lvl = statistics.median(m[col] for m in before)
lvl_mm = statistics.median(m[col + "_mm"] for m in before) if all(m[col + "_mm"] is not None for m in before) else None
for m in ms:
if s < m["t"] < e and m[col] is not None:
d = m[col] - lvl
dmm = m[col + "_mm"] - lvl_mm if lvl_mm is not None and m[col + "_mm"] is not None else None
rows.append((abs(d) / noise, name, col, m["t"].strftime("%d/%m %H:%M"), d, dmm))
rows.sort(reverse=True)
print(f"== {lid} {s:%d/%m %H:%M} -> {e:%d/%m %H:%M}: top deviations from the night level")
for k, name, col, t, d, dmm in rows[:8]:
mm = f"{dmm:+.2f} mm" if dmm is not None else " ? mm"
print(f" {name:8} {col:6} {t} {d:+.4f} px {mm} {d / abs(d) * k:+.1f} noises")