Files
Support-Agent/labeling/auto/etiqueteur/CLARIDEN_2026-10-01/outils/vue.py
T
maximeandClaude Opus 5.5 6fbd7510b7 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>
2026-11-03 16:33:41 +01:00

71 lines
2.6 KiB
Python

"""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)