Files
aimsight-labeling/auto/etiqueteur/NORDEND_2026-08-16/outils/table.py
T
maximeandClaude Opus 5.5 14ad6ea3f9 Auto labels reviewed per station and cross-reviewed; all labeling knowledge in labeling/ (D-130)
- Every station's auto labels reviewed by an analyst (/review-auto-labels), then a
  cross-review per family across all stations (new skill /cross-review-labels),
  a finishing pass, and descriptions rewritten in words (no numeric values).
- The three never-labeled ranges (WILDSTRUBEL 07/09-01/10, NORDEND 16/08-01/10)
  labeled and reviewed: 991 auto labels on 11 stations, labeling/controle.py at 0 errors.
- Labeling knowledge gathered in labeling/: regles-d-etiquetage.md (new), familles.md
  (settled boundaries), connaissances/ (notes moved from docs/, links updated),
  the label map rebuilt from reviewed labels, events and cases; events tied to their
  stations (PS_DES_COUDRES is JUNGFRAU). The labeler and reviewers read only labeling/.
- labels-map reads auto labels and events; decision D-130; living plan points 73-75.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 08:21:57 +01:00

80 lines
3.4 KiB
Python

"""Table au pas natif de plusieurs capteurs, NORDEND, lot 16/08-09/09 (marges 14/08-10/09).
Par capteur : corr_x et corr_y en bruits, écart à la médiane de la nuit (20-03 h) qui précède ; R = rejetée ; e = error_value (si --err).
Puis la pose : pan, tilt (écart à la nuit, en bruits de la pose), temps sans mesure.
Usage (depuis la racine) :
python3 labeling/auto/etiqueteur/NORDEND_2026-08-16/outils/table.py PR18,PR16 2026-08-17T04:00 2026-08-17T09:00 [--err] [--brut]
--brut : x, y bruts au lieu de corr (écart à la nuit, en px)
"""
import csv, glob, statistics as st, sys
from datetime import datetime, timedelta, timezone
caps = sys.argv[1].split(",")
deb, fin = (datetime.fromisoformat(a).replace(tzinfo=timezone.utc) for a in sys.argv[2:4])
ERR, BRUT = "--err" in sys.argv, "--brut" in sys.argv
J0, J1 = (deb - timedelta(days=2)).strftime("%Y%m%d"), (fin + timedelta(days=1)).strftime("%Y%m%d")
def q(t):
t = datetime.fromisoformat(t).replace(second=0, microsecond=0)
return t - timedelta(minutes=t.minute % 15)
rows = {c: {} for c in caps}
for p in sorted(glob.glob("data/NORDEND/displacement/NORDEND_advanced_*.csv")):
if J0 <= p[-12:-4] <= J1:
for r in csv.DictReader(open(p)):
if r["sensor_name"] in rows:
rej = float(r["error_value"]) > float(r["error_threshold"])
g = lambda k: None if rej or not r[k] else float(r[k])
a, b = ("x", "y") if BRUT else ("corr_x", "corr_y")
rows[r["sensor_name"]][q(r["time_utc"])] = (float(r["error_value"]), g(a) if not BRUT else float(r[a]),
g(b) if not BRUT else float(r[b]), rej)
cam = {}
for p in sorted(glob.glob("data/NORDEND/camera/NORDEND_camera_*.csv")):
if J0 <= p[-12:-4] <= J1:
for r in csv.DictReader(open(p)):
cam[q(r["time_utc"])] = (float(r["median_pan"]), float(r["median_tilt"]))
def bruit(d, k):
ts = sorted(d)
v = [abs(d[b][k] - d[a][k]) for a, b in zip(ts, ts[1:]) if d[a][k] is not None and d[b][k] is not None and b - a == timedelta(minutes=15)]
return st.median(v) or 1e-9
def niveau(d, k, t):
d0 = t.replace(hour=0, minute=0) - (timedelta(days=1) if t.hour < 20 else timedelta(0))
v = [d[u][k] for u in d if d0 + timedelta(hours=20) <= u < d0 + timedelta(hours=27) and d[u][k] is not None]
return st.median(v) if v else None
B = {c: {k: bruit(rows[c], k) for k in (1, 2)} for c in caps}
BC = {k: bruit(cam, k) for k in (0, 1)}
hdr = "instant " + "".join(f"{c:>20}" for c in caps) + " pan tilt"
print(hdr)
t, n = deb, 0
while t <= fin:
if not any(t in rows[c] for c in caps):
print(f"{t:%m-%d %H:%M} (pas de mesure)")
else:
s = f"{t:%m-%d %H:%M} "
for c in caps:
r = rows[c].get(t)
if r is None:
s += f"{'-':>20}"
continue
f = []
for k in (1, 2):
nv = niveau(rows[c], k, t)
f.append(" ." if r[k] is None or nv is None else f"{(r[k] - nv) / B[c][k]:+5.0f}")
e = f"{r[0]:.2f}" if ERR else ""
s += f"{f[0]:>6}{f[1]:>6}{'R' if r[3] else ' '}{e:>5} "
if t in cam:
nv = [niveau(cam, k, t) for k in (0, 1)]
s += "".join(f"{(cam[t][k] - nv[k]) / BC[k]:+7.0f}" for k in (0, 1))
print(s)
n += 1
if n % 24 == 0:
print(hdr)
t += timedelta(minutes=15)