Files
Support-Agent/labeling/auto/etiqueteur/NORDEND_2026-08-16/outils/matins.py
T
maximeandClaude Opus 5.5 35b5ed4d74 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

72 lines
3.6 KiB
Python

"""Départ du cycle thermique chaque matin, NORDEND, lot 16/08-09/09.
Indice : médiane, sur PR14..PR18, de corr_x moins le niveau de la nuit (20-03 h) qui précède, en bruits (le cycle y creuse corr_x).
Par jour : premier instant après 04:00 où l'indice passe sous -3 bruits et y reste deux mesures sur les trois suivantes (et la mesure d'avant),
premier instant où le tilt de la caméra dépasse son niveau de nuit de 5 bruits (et la mesure d'avant), minimum de l'indice et son heure,
dernier instant de la journée (avant 03:00 le lendemain) où l'indice est sous -3, et la température max du boîtier (sensor_thermal) du jour.
Usage : python3 labeling/auto/etiqueteur/NORDEND_2026-08-16/outils/matins.py [PR16,PR18]
"""
import csv, glob, statistics as st
from datetime import datetime, timedelta, timezone
import sys
CAPS = sys.argv[1].split(",") if len(sys.argv) > 1 else ["PR14", "PR15", "PR16", "PR17", "PR18"]
D0, D1 = datetime(2026, 8, 15, tzinfo=timezone.utc), datetime(2026, 9, 9, tzinfo=timezone.utc)
def q(t):
t = datetime.fromisoformat(t).replace(second=0, microsecond=0)
return t - timedelta(minutes=t.minute % 15)
cx = {c: {} for c in CAPS}
for p in sorted(glob.glob("data/NORDEND/displacement/NORDEND_advanced_*.csv")):
if "20260814" <= p[-12:-4] <= "20260909":
for r in csv.DictReader(open(p)):
if r["sensor_name"] in cx and r["corr_x"] and float(r["error_value"]) <= float(r["error_threshold"]):
cx[r["sensor_name"]][q(r["time_utc"])] = float(r["corr_x"])
tilt = {}
for p in sorted(glob.glob("data/NORDEND/camera/NORDEND_camera_*.csv")):
if "20260814" <= p[-12:-4] <= "20260909":
for r in csv.DictReader(open(p)):
tilt[q(r["time_utc"])] = float(r["median_tilt"])
temp = {}
for p in glob.glob("data/NORDEND/metrics/NORDEND_sensor_thermal_deg_c_2026_0[89]_*.csv"):
for r in csv.DictReader(open(p)):
try:
temp[datetime.fromisoformat(r["time_utc"])] = float(r["metric"])
except (ValueError, IndexError):
pass
def bruit(d):
ts = sorted(d)
return st.median(abs(d[b] - d[a]) for a, b in zip(ts, ts[1:]) if b - a == timedelta(minutes=15))
B = {c: bruit(cx[c]) for c in CAPS}
BT = bruit(tilt)
ts_all = sorted(set().union(*[set(cx[c]) for c in CAPS]) | set(tilt))
day = D0 + timedelta(days=1)
while day < D1:
n0, n1 = day - timedelta(hours=4), day + timedelta(hours=3)
niv = {c: st.median(v for t, v in cx[c].items() if n0 <= t < n1) for c in CAPS}
nt = st.median(v for t, v in tilt.items() if n0 <= t < n1)
w = [t for t in ts_all if day + timedelta(hours=4) <= t < day + timedelta(hours=27)]
idx = {}
for t in w:
v = [(cx[c][t] - niv[c]) / B[c] for c in CAPS if t in cx[c]]
if len(v) >= min(3, len(CAPS)):
idx[t] = st.median(v)
wi = [t for t in w if t in idx]
dep = next((t for i, t in enumerate(wi) if idx[t] <= -3 and sum(idx[u] <= -3 for u in wi[i + 1:i + 4]) >= 2), None)
av = lambda t, L: L[L.index(t) - 1] if t and L.index(t) > 0 else None
wt = [t for t in w if t in tilt]
td = next((t for t in wt if (tilt[t] - nt) / BT >= 5), None)
mn = min(wi, key=lambda t: idx[t]) if wi else None
last = max((t for t in wi if idx[t] <= -3), default=None)
tm = max((v for t, v in temp.items() if day <= t < day + timedelta(days=1)), default=float("nan"))
f = lambda t: f"{t:%d/%m %H:%M}" if t else " - "
print(f"{day:%d/%m} départ corr {f(dep)} (avant {f(av(dep, wi))}) tilt {f(td)} (avant {f(av(td, wt))}) "
f"min {idx[mn] if mn else 0:+6.1f} à {f(mn)} dernier<-3 {f(last)} Tmax {tm:.1f}")
day += timedelta(days=1)