- 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>
60 lines
3.1 KiB
Python
60 lines
3.1 KiB
Python
"""Par jour et par cible : écart de corr_x, corr_y (mesures acceptées) au niveau de la nuit précédente (18 h → 2 h UTC),
|
|
médiane de 06:00 à 13:00 (en bruits), et bornes du jour où la médiane glissante sur 5 mesures dépasse K bruits
|
|
(premier et dernier instant, avec la mesure juste avant et juste après).
|
|
Usage : python3 jour_ecarts.py DEBUT FIN [K] [--capteurs A,B] (DEBUT, FIN : AAAA-MM-JJ)
|
|
"""
|
|
import csv, os, sys, statistics as st
|
|
from datetime import date, datetime, timedelta
|
|
|
|
DATA = "data/WILDSTRUBEL"
|
|
a = sys.argv[1:]
|
|
d0, d1 = date.fromisoformat(a[0]), date.fromisoformat(a[1])
|
|
K = float(a[2]) if len(a) > 2 and not a[2].startswith("--") else 5
|
|
cibles = a[a.index("--capteurs") + 1].split(",") if "--capteurs" in a else ["PA2_2", "PA3_2", "PA_9", "PB1_2", "PB2_2", "PB4", "PB_5"]
|
|
|
|
ser = {} # (capteur, col) -> [(t, v)]
|
|
d = d0 - timedelta(days=1)
|
|
while d <= d1:
|
|
f = f"{DATA}/displacement/WILDSTRUBEL_advanced_{d:%Y%m%d}.csv"
|
|
if os.path.exists(f):
|
|
for r in csv.DictReader(open(f)):
|
|
if r["sensor_name"] not in cibles or float(r["error_value"]) > float(r["error_threshold"]) or not r["corr_x"]:
|
|
continue
|
|
t = datetime.fromisoformat(r["time_utc"][:16].replace(" ", "T"))
|
|
t = t.replace(minute=(t.minute + 7) // 15 * 15 % 60) + (timedelta(hours=1) if t.minute >= 53 else timedelta())
|
|
for c in ("corr_x", "corr_y"):
|
|
ser.setdefault((r["sensor_name"], c), []).append((t, float(r[c])))
|
|
d += timedelta(days=1)
|
|
|
|
for (s, c), v in sorted(ser.items()):
|
|
v.sort()
|
|
bruit = st.median(abs(x[1] - y[1]) for x, y in zip(v, v[1:]))
|
|
print(f"== {s} {c} bruit {bruit:.4f}")
|
|
d = d0
|
|
while d <= d1:
|
|
n0 = datetime.combine(d - timedelta(days=1), datetime.min.time()) + timedelta(hours=18)
|
|
nuit = [x for t, x in v if n0 <= t < n0 + timedelta(hours=8)]
|
|
jour = [(t, x) for t, x in v if n0 + timedelta(hours=8) <= t < n0 + timedelta(hours=24)]
|
|
if len(nuit) < 5 or len(jour) < 10:
|
|
print(f" {d:%d/%m} pas assez de mesures (nuit {len(nuit)}, jour {len(jour)})")
|
|
d += timedelta(days=1)
|
|
continue
|
|
niv = st.median(nuit)
|
|
mid = [x - niv for t, x in jour if 6 <= t.hour < 13]
|
|
med = st.median(mid) / bruit if mid else float("nan")
|
|
gl = []
|
|
for i in range(len(jour)):
|
|
w = [x for _, x in jour[max(0, i - 2): i + 3]]
|
|
gl.append((st.median(w) - niv) / bruit)
|
|
hors = [i for i, z in enumerate(gl) if abs(z) > K]
|
|
if hors:
|
|
i0, i1 = hors[0], hors[-1]
|
|
av = jour[i0 - 1][0] if i0 > 0 else None
|
|
ap = jour[i1 + 1][0] if i1 + 1 < len(jour) else None
|
|
ext = max(gl, key=abs)
|
|
borne = f"{jour[i0][0]:%H:%M} (avant {av:%H:%M} ) → {jour[i1][0]:%H:%M} (après {ap:%H:%M} ) ; {len(hors)} mes. ; extrême glissant {ext:+.1f}" if av and ap else f"{jour[i0][0]:%H:%M} → {jour[i1][0]:%H:%M} ; {len(hors)} mes."
|
|
else:
|
|
borne = "jamais"
|
|
print(f" {d:%d/%m} niveau nuit {niv:+.3f} ; médiane 06-13h {med:+.1f} bruits ; > {K:g} bruits (glissant 5) : {borne}")
|
|
d += timedelta(days=1)
|