Etiqueteur: October labels for 8 stations; its folder moves to labeling/auto/etiqueteur/, analyses and scripts versioned (D-126)
Labels for CLARIDEN, FLORIDA, JUNGFRAU (gaps 06-20.10, 26.10-01.11), LENZSPITZE, NIEDERHORN, NORDEND, SNCF01, WILDSTRUBEL. Figures and tool outputs stay out of git. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2bba388290
commit
6fbd7510b7
112 files changed
+8951
-6
No files matched your search
@@ -0,0 +1,56 @@
|
||||
"""Par instant, cibles/réfs dont corr_x ou corr_y s'écarte de son niveau local (médiane de la fenêtre)
|
||||
de plus de K bruits (bruit = médiane |écart entre deux mesures|) ; + nb de rejetées et error_value hautes.
|
||||
Usage : python3 out/.../outils/pas.py DEBUT FIN [K]
|
||||
"""
|
||||
import csv, glob, sys
|
||||
from datetime import datetime
|
||||
from statistics import median
|
||||
|
||||
ST = "data/CLARIDEN"
|
||||
deb = datetime.fromisoformat(sys.argv[1].replace("Z", "+00:00"))
|
||||
fin = datetime.fromisoformat(sys.argv[2].replace("Z", "+00:00"))
|
||||
K = float(sys.argv[3]) if len(sys.argv) > 3 else 5
|
||||
rows = []
|
||||
for f in sorted(glob.glob(f"{ST}/displacement/CLARIDEN_advanced_2026*.csv")):
|
||||
d = f[-12:-4]
|
||||
if not (deb.strftime("%Y%m%d") <= d <= fin.strftime("%Y%m%d")):
|
||||
continue
|
||||
for r in csv.DictReader(open(f)):
|
||||
t = datetime.fromisoformat(r["time_utc"].replace(" ", "T"))
|
||||
if deb <= t <= fin:
|
||||
rows.append((t.strftime("%m-%d %H:%M"), r))
|
||||
ser = {}
|
||||
for t, r in rows:
|
||||
s = r["sensor_name"]
|
||||
rej = float(r["error_value"]) > float(r["error_threshold"])
|
||||
for c in ("corr_x", "corr_y", "error_value"):
|
||||
v = r[c]
|
||||
if c != "error_value" and (rej or not v):
|
||||
continue
|
||||
ser.setdefault((s, c), {})[t] = float(v)
|
||||
stat = {}
|
||||
for k, d in ser.items():
|
||||
ts = sorted(d); vs = [d[t] for t in ts]
|
||||
if len(vs) < 5:
|
||||
continue
|
||||
stat[k] = (median(vs), median(abs(a - b) for a, b in zip(vs, vs[1:])) or 1e-9)
|
||||
inst = sorted({t for t, _ in rows})
|
||||
rej = {}
|
||||
for t, r in rows:
|
||||
if float(r["error_value"]) > float(r["error_threshold"]):
|
||||
rej.setdefault(t, []).append(r["sensor_name"])
|
||||
for t in inst:
|
||||
out = []
|
||||
for c in ("corr_x", "corr_y"):
|
||||
for (s, cc), (m, b) in stat.items():
|
||||
if cc == c and t in ser[(s, c)]:
|
||||
z = (ser[(s, c)][t] - m) / b
|
||||
if abs(z) > K:
|
||||
out.append(f"{s}:{c[-1]}{z:+.0f}")
|
||||
ev = []
|
||||
for (s, cc), (m, b) in stat.items():
|
||||
if cc == "error_value" and t in ser[(s, cc)]:
|
||||
z = (ser[(s, cc)][t] - m) / b
|
||||
if z > 10:
|
||||
ev.append(s)
|
||||
print(t, f"n={len(out)}", " ".join(sorted(out)), "| ev+", len(ev), "| rej", ",".join(r for r in rej.get(t, []) if r != "P-300-B"))
|
||||
@@ -0,0 +1,70 @@
|
||||
"""Vue par capteur de corr_x, corr_y (mesures acceptées), + température et métriques.
|
||||
Usage : .venv/bin/python out/.../outils/vue.py DEBUT FIN NOM [capteurs,separes,par,virgule]
|
||||
"""
|
||||
import csv, glob, sys
|
||||
from datetime import datetime, timezone
|
||||
import matplotlib
|
||||
matplotlib.use("Agg")
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
ST = "data/CLARIDEN"
|
||||
OUT = "labeling/auto/etiqueteur/CLARIDEN_2026-10-01"
|
||||
deb = datetime.fromisoformat(sys.argv[1].replace("Z", "+00:00"))
|
||||
fin = datetime.fromisoformat(sys.argv[2].replace("Z", "+00:00"))
|
||||
nom = sys.argv[3]
|
||||
sel = sys.argv[4].split(",") if len(sys.argv) > 4 else None
|
||||
|
||||
|
||||
def t(s):
|
||||
return datetime.fromisoformat(s.replace(" ", "T"))
|
||||
|
||||
|
||||
data = {}
|
||||
for f in sorted(glob.glob(f"{ST}/displacement/CLARIDEN_advanced_*.csv")):
|
||||
d = f[-12:-4]
|
||||
day = datetime(int(d[:4]), int(d[4:6]), int(d[6:]), tzinfo=timezone.utc)
|
||||
if (day - fin).days > 0 or (deb - day).days > 1:
|
||||
continue
|
||||
for r in csv.DictReader(open(f)):
|
||||
ti = t(r["time_utc"])
|
||||
if not (deb <= ti <= fin):
|
||||
continue
|
||||
s = r["sensor_name"]
|
||||
if sel and s not in sel:
|
||||
continue
|
||||
rej = float(r["error_value"]) > float(r["error_threshold"])
|
||||
g = data.setdefault(s, {"t": [], "cx": [], "cy": [], "ev": [], "x": [], "y": []})
|
||||
g["t"].append(ti)
|
||||
cx = r["corr_x"]; cy = r["corr_y"]
|
||||
g["cx"].append(float(cx) if cx and not rej else float("nan"))
|
||||
g["cy"].append(float(cy) if cy and not rej else float("nan"))
|
||||
g["ev"].append(float(r["error_value"]))
|
||||
g["x"].append(float(r["x"])); g["y"].append(float(r["y"]))
|
||||
|
||||
temp = []
|
||||
for f in sorted(glob.glob(f"{ST}/metrics/CLARIDEN_sensor_thermal_deg_c_*.csv")):
|
||||
for r in csv.DictReader(open(f)):
|
||||
ti = t(r["time_utc"])
|
||||
if deb <= ti <= fin and r["metric"]:
|
||||
temp.append((ti, float(r["metric"])))
|
||||
|
||||
caps = sorted(data)
|
||||
n = len(caps) + 1
|
||||
fig, axs = plt.subplots(n, 1, figsize=(16, 1.3 * n), sharex=True)
|
||||
for ax, s in zip(axs, caps):
|
||||
g = data[s]
|
||||
ax.plot(g["t"], g["cx"], ".", ms=1.5, color="tab:blue")
|
||||
ax2 = ax.twinx()
|
||||
ax2.plot(g["t"], g["cy"], ".", ms=1.5, color="tab:red")
|
||||
ax.set_ylabel(s, rotation=0, ha="right", fontsize=7)
|
||||
ax.tick_params(labelsize=6); ax2.tick_params(labelsize=6)
|
||||
ax.grid(alpha=.3)
|
||||
if temp:
|
||||
axs[-1].plot([a for a, _ in temp], [b for _, b in temp], color="k")
|
||||
axs[-1].set_ylabel("thermal °C", rotation=0, ha="right", fontsize=7)
|
||||
axs[-1].grid(alpha=.3)
|
||||
fig.suptitle(f"CLARIDEN corr_x (bleu, gauche) corr_y (rouge, droite) {sys.argv[1]} → {sys.argv[2]}")
|
||||
fig.tight_layout()
|
||||
p = f"{OUT}/vue_{nom}.png"
|
||||
fig.savefig(p, dpi=80)
|
||||
print(p)
|
||||
Reference in new issue
Block a user