- 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>
64 lines
2.7 KiB
Python
64 lines
2.7 KiB
Python
"""Bords d'étiquettes : les courbes bougent-elles avant le début ou après la fin ?
|
|
|
|
Pour une étiquette (STATION#ligne) : niveau (médiane) et bruit (MAD) de chaque cible sur [debut-6h, debut-3h] (avant)
|
|
et [fin+3h, fin+6h] (après) ; puis, mesure par mesure de debut-3h à debut et de fin à fin+3h,
|
|
le nombre de cibles dont corr_x ou corr_y sort de K bruits de ce niveau ('r' ajouté s'il y a des rejets
|
|
de plus qu'au niveau). Une suite qui monte vers le début, ou qui ne retombe pas après la fin,
|
|
dit une borne posée trop tard ou trop tôt.
|
|
|
|
Usage (depuis la racine) : python3 bords.py [--k 5] [--h 3] ID [ID ...]
|
|
"""
|
|
import sys, json, statistics as st
|
|
from datetime import timedelta
|
|
sys.path.insert(0, "agent-tools")
|
|
import donnees as d
|
|
|
|
args = sys.argv[1:]
|
|
K = float(args[args.index("--k") + 1]) if "--k" in args else 5
|
|
H = float(args[args.index("--h") + 1]) if "--h" in args else 3
|
|
ids = [a for a in args if "#" in a]
|
|
cache = {}
|
|
for i in ids:
|
|
nom, n = i.split("#")
|
|
e = json.loads(open(f"labeling/auto/{nom}.jsonl").readlines()[int(n) - 1])
|
|
t1, t2 = d.instant(e["debut"]), d.instant(e["fin"])
|
|
if nom not in cache:
|
|
cache[nom] = d.charger(f"data/{nom}")
|
|
par = cache[nom]
|
|
cib = {s: ms for s, ms in par.items() if not d.est_reference(ms)}
|
|
idx = {s: {m["t"]: m for m in ms} for s, ms in cib.items()}
|
|
h = timedelta(hours=H)
|
|
|
|
def niveau(a, b):
|
|
out = {}
|
|
for s, ms in cib.items():
|
|
w = [m for m in d.filtrer(ms, a, b) if m["corr_x"] is not None]
|
|
if len(w) >= 4:
|
|
out[s] = {}
|
|
for q in ("corr_x", "corr_y"):
|
|
med = st.median(m[q] for m in w) # bruit : MAD de la fenêtre (une dérive thermique lente y tient)
|
|
out[s][q] = (med, max(st.median(abs(m[q] - med) for m in w), 1e-4))
|
|
return out
|
|
|
|
def suite(a, b, niv):
|
|
inst = sorted({m["t"] for ms in cib.values() for m in d.filtrer(ms, a, b)})
|
|
txt = []
|
|
for t in inst:
|
|
n = r = 0
|
|
for s, ms in cib.items():
|
|
m = idx[s].get(t)
|
|
if m is None or s not in niv:
|
|
continue
|
|
if m["corr_x"] is None:
|
|
r += 1
|
|
elif any(abs(m[q] - niv[s][q][0]) > K * niv[s][q][1] for q in ("corr_x", "corr_y")):
|
|
n += 1
|
|
txt.append(f"{min(n, 9)}{'r' if r else ''}")
|
|
return " ".join(txt)
|
|
|
|
av = niveau(t1 - 2 * h, t1 - h)
|
|
ap = niveau(t2 + h, t2 + 2 * h)
|
|
print(f"{i} {e['debut']} -> {e['fin']} ({len(cib)} cibles, K={K:g})")
|
|
print(f" avant ({H:g} h) : {suite(t1 - h, t1, av)} | début")
|
|
print(f" après ({H:g} h) : fin | {suite(t2, t2 + h, ap or av)}")
|