Après l'audit du scan du 2026-11-06 : error_value des capteurs acceptés, 12 capteurs nommés, consignes du scanner (passage non couvert, doublon gardé, image par doute de famille) ; outils/ : non_couverts.py par capteur, rejets_instants.py, ev_fenetres.py, horaire_jours.py
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d5ee63a118
commit
7e24df09a0
6 files changed
+93
-36
No files matched your search
@@ -0,0 +1,16 @@
|
||||
# ev/seuil médian et part rejetée par capteur sur des fenêtres horaires du jour : STATION "HH-HH,HH-HH,..." (JOUR=AAAA-MM-JJ).
|
||||
import statistics, sys
|
||||
import os
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) # outils.py, à côté
|
||||
from outils import D, station, rejected
|
||||
from datetime import timedelta
|
||||
nom, fen = sys.argv[1], [tuple(int(h) for h in f.split("-")) for f in sys.argv[2].split(",")]
|
||||
m, refs = station(nom)
|
||||
print("capteur".ljust(18), *[f"{a:02d}-{b:02d}h".rjust(12) for a, b in fen])
|
||||
for s in sorted(m, key=lambda s: (s not in refs, s)):
|
||||
cells = []
|
||||
for a, b in fen:
|
||||
xs = [x for x in m[s] if D + timedelta(hours=a) <= x["t"] < D + timedelta(hours=b)]
|
||||
ev = [x["error_value"] / x["error_threshold"] for x in xs if x["error_value"] is not None and x["error_threshold"]]
|
||||
cells.append(f"{statistics.median(ev) if ev else float('nan'):.2f} r{sum(map(rejected, xs))}/{len(xs)}".rjust(12))
|
||||
print((s + (" (R)" if s in refs else "")).ljust(18), *cells)
|
||||
@@ -0,0 +1,18 @@
|
||||
# Médiane horaire d'une colonne pour quelques capteurs, sur plusieurs jours (STATION COL CAPTEUR[,CAPTEUR] J0 J1 [H0 H1]) : le même motif revient-il chaque jour ?
|
||||
import statistics, sys
|
||||
from datetime import datetime, timezone
|
||||
import os
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) # outils.py, à côté
|
||||
from outils import station
|
||||
nom, col, caps, j0, j1 = sys.argv[1:6]
|
||||
h0, h1 = (int(x) for x in sys.argv[6:8]) if len(sys.argv) > 7 else (0, 24)
|
||||
m, _ = station(nom)
|
||||
for s in caps.split(","):
|
||||
par = {}
|
||||
for x in m[s]:
|
||||
j = x["t"].strftime("%m-%d")
|
||||
if j0 <= j <= j1 and h0 <= x["t"].hour < h1 and x[col] is not None:
|
||||
par.setdefault(j, {}).setdefault(x["t"].hour, []).append(x[col])
|
||||
print(s, col, "heures", h0, "à", h1 - 1)
|
||||
for j in sorted(par):
|
||||
print(" ", j, " ".join(f"{statistics.median(par[j][h]):+.3f}" if h in par[j] else " - " for h in range(h0, h1)))
|
||||
+35
-29
@@ -1,21 +1,28 @@
|
||||
# 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
|
||||
# Les instants anormaux (rejets non habituels, cibles qui sautent face à leur niveau local) qu'aucune étiquette de la vérité ne couvre, toutes stations (JOUR=AAAA-MM-JJ) ; une étiquette ne couvre que ses capteurs (lus dans « Détecteurs : variété, capteurs ») ; « N capteurs », « tous » ou une ligne du scanner couvrent tout ; une référence rejetée couverte couvre les sauts de l'instant. Hors Thermal. STATION... (JOUR=AAAA-MM-JJ).
|
||||
import json, re, statistics, sys
|
||||
import os
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) # outils.py, à côté
|
||||
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:
|
||||
K, N = 10, 3
|
||||
|
||||
def capteurs(e):
|
||||
m = re.match(r"Détecteurs : [^,]+, (.*?)(, grisé)?\. ", e["description"])
|
||||
if not m or re.fullmatch(r"\d+ capteurs|tous les capteurs", m.group(1)):
|
||||
return None # tout
|
||||
return set(m.group(1).split(", "))
|
||||
|
||||
for nom in sys.argv[1:]:
|
||||
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",)]
|
||||
labels = [(e, capteurs(e)) for e in labels if e["categorie"] != "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 = {}
|
||||
sauts, 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)
|
||||
if s in refs:
|
||||
continue
|
||||
for col in ("corr_x", "corr_y"):
|
||||
@@ -23,22 +30,21 @@ for nom in stations:
|
||||
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:
|
||||
v = [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(v) >= 4 and abs(x[col] - statistics.median(v)) > K * b:
|
||||
sauts.setdefault(x["t"], set()).add(s)
|
||||
print(f"== {nom} (rejet habituel : {sorted(habituel)})")
|
||||
for t in sorted(set(sauts) | set(rej)):
|
||||
S, r = set(sauts.get(t, ())), set(rej.get(t, ()))
|
||||
if len(S) < 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)
|
||||
for e, c in labels:
|
||||
if e["debut"] <= iso(t) <= e["fin"]:
|
||||
if c is None:
|
||||
S, r = set(), set()
|
||||
break
|
||||
if c & r & refs:
|
||||
S = set()
|
||||
S -= c; r -= c
|
||||
if len(S) >= N or r:
|
||||
print(f" {hhmm(t)} sauts={len(S)} rejets={sorted(r)[:5]}")
|
||||
@@ -0,0 +1,16 @@
|
||||
# Par instant d'une plage (STATION HH:MM HH:MM) : capteurs rejetés (noms abrégés, R = référence) et nombre de capteurs mesurés (JOUR=AAAA-MM-JJ).
|
||||
import sys
|
||||
import os
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) # outils.py, à côté
|
||||
from outils import D, B, station, rejected, hhmm
|
||||
nom, de, a = sys.argv[1:4]
|
||||
m, refs = station(nom)
|
||||
par = {}
|
||||
for s, ms in m.items():
|
||||
for x in ms:
|
||||
if D <= x["t"] < B and de <= hhmm(x["t"]) <= a:
|
||||
par.setdefault(x["t"], {})[s] = x
|
||||
court = lambda s: s.replace("28DEF_RERA_CAM01_", "") + ("(R)" if s in refs else "")
|
||||
for t in sorted(par):
|
||||
r = sorted(court(s) for s, x in par[t].items() if rejected(x))
|
||||
print(hhmm(t), f"n={len(par[t])}", f"rej={len(r)}", " ".join(r))
|
||||
Reference in new issue
Block a user