batches/2026-11-05/ : détecteurs, vérité, rapport du scanner, improve/ (mesures, modification, validation, bilan, tools/instants.py de l'upgrader) ; docs/essais/ : le journal de l'essai et l'audit ; outils/ : les scripts de lecture de l'audit, réutilisables (JOUR=AAAA-MM-JJ). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
45 lines
2.1 KiB
Python
45 lines
2.1 KiB
Python
# Les instants anormaux qu'aucune étiquette de la vérité (hors Thermal) ne couvre, toutes stations : rejets non habituels, ou cibles qui sautent face à leur niveau local (±6 mesures), en bruits.
|
|
import json
|
|
import statistics
|
|
import sys
|
|
from pathlib import Path
|
|
from outils import D, B, RACINE, station, bruit, hhmm, rejected, iso
|
|
|
|
BATCH = RACINE / "batches" / iso(D)[:10]
|
|
K, N = 10, 3 # un saut : au moins N cibles à plus de K bruits de leur niveau local
|
|
stations = sys.argv[1:] or sorted(p.stem for p in (BATCH / "verite").glob("*.jsonl"))
|
|
for nom in stations:
|
|
labels = [json.loads(l) for l in open(BATCH / "verite" / f"{nom}.jsonl") if l.strip()]
|
|
labels = [e for e in labels if e["categorie"] not in ("Thermal displacement",)]
|
|
m, refs = station(nom)
|
|
jour = {s: [x for x in ms if D <= x["t"] < B] for s, ms in m.items()}
|
|
habituel = {s for s, ms in jour.items() if ms and sum(map(rejected, ms)) > 0.5 * len(ms)}
|
|
par = {}
|
|
for s, ms in jour.items():
|
|
if s in refs:
|
|
continue
|
|
for col in ("corr_x", "corr_y"):
|
|
b = bruit(m[s], col, 10)
|
|
if not b:
|
|
continue
|
|
for i, x in enumerate(ms):
|
|
voisins = [y[col] for y in ms[max(0, i - 6):i] + ms[i + 1:i + 7] if y[col] is not None]
|
|
if x[col] is not None and len(voisins) >= 4 and abs(x[col] - statistics.median(voisins)) > K * b:
|
|
par.setdefault(x["t"], set()).add(s)
|
|
rej = {}
|
|
for s, ms in jour.items():
|
|
for x in ms:
|
|
if rejected(x) and s not in habituel:
|
|
rej.setdefault(x["t"], set()).add(s)
|
|
sorties = []
|
|
for t in sorted(set(par) | set(rej)):
|
|
sauts, r = par.get(t, set()), rej.get(t, set())
|
|
if len(sauts) < N and not r:
|
|
continue
|
|
if any(e["debut"] <= iso(t) <= e["fin"] for e in labels):
|
|
continue
|
|
sorties.append(f"{hhmm(t)} sauts={len(sauts)} rejets={sorted(r)[:4]}{'…' if len(r) > 4 else ''}")
|
|
print(f"== {nom} (rejet habituel : {sorted(habituel)}) : {len(sorties)} instants non couverts")
|
|
for l in sorties[:80]:
|
|
print(" ", l)
|