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:
maximeandClaude Opus 5.5 committed 2026-11-03 16:33:41 +01:00
1 parent 2bba388290
commit 6fbd7510b7
112 files changed
+8951 -6

No files matched your search

@@ -0,0 +1,14 @@
"""Ajoute à labeling/auto/JUNGFRAU.jsonl les étiquettes d'un fichier TSV (debut, fin, categorie, description)."""
import json, sys
FAM = {"Visibility", "Obstruction", "Thermal displacement", "Displacement", "Target issue", "No data"}
lignes = []
for l in open(sys.argv[1], encoding="utf-8"):
if not l.strip():
continue
d, f, c, t = l.rstrip("\n").split("\t")
assert c in FAM and d < f, l
lignes.append(json.dumps({"debut": d, "fin": f, "categorie": c, "description": t}, ensure_ascii=False))
with open("labeling/auto/JUNGFRAU.jsonl", "a", encoding="utf-8") as o:
for x in lignes:
o.write(x + "\n")
print(len(lignes), "étiquettes ajoutées")
@@ -0,0 +1,11 @@
"""Max du matin (03-12h) et min de l'après-midi (12-21h) de la médiane des cibles corr_y, lissée sur 1 h.
usage : vue.py --table --pas15 > f ; python3 extremes.py f"""
import sys, statistics as st
L = [l.split() for l in open(sys.argv[1]) if l[:2].isdigit()]
s = [(l[0], l[1], float(l[3])) for l in L if l[3] != "-"]
lis = [(d, h, st.median(v for _, _, v in s[max(0, i-2):i+3])) for i, (d, h, _) in enumerate(s)]
for d in sorted({d for d, _, _ in lis}, key=lambda x: x[3:]+x[:2]):
m = [x for x in lis if x[0] == d and "03:00" <= x[1] < "12:00"]
n = [x for x in lis if x[0] == d and "12:00" <= x[1] < "21:00"]
f = lambda x: f"{x[1]} {x[2]:+.3f}"
print(d, "max matin", f(max(m, key=lambda x: x[2])) if m else "-", "| min aprem", f(min(n, key=lambda x: x[2])) if n else "-")
@@ -0,0 +1,53 @@
"""Pas où plusieurs cibles sautent ensemble sur corr_x/corr_y (|delta| > K bruits).
usage : python3 sauts.py DEBUT FIN [K] [NMIN]"""
import csv, glob, sys, statistics as st
from datetime import datetime, timedelta
D = "data/JUNGFRAU"
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
NMIN = int(sys.argv[4]) if len(sys.argv) > 4 else 3
def t15(s):
t = datetime.fromisoformat(s)
return t.replace(second=0, microsecond=0, minute=t.minute // 15 * 15)
rows = {}
d = deb.date() - timedelta(days=1)
while d <= fin.date():
for f in glob.glob(f"{D}/displacement/JUNGFRAU_advanced_{d:%Y%m%d}.csv"):
for r in csv.DictReader(open(f)):
t = t15(r["time_utc"])
if deb <= t <= fin:
rows[(t, r["sensor_name"])] = r
d += timedelta(days=1)
temps = sorted({t for t, _ in rows})
cibles = sorted({c for _, c in rows if not c.startswith("REF")})
refs = sorted({c for _, c in rows if c.startswith("REF")})
def v(t, c, k):
r = rows.get((t, c))
return float(r[k]) if r and r[k] != "" else None
bruit = {}
for c in cibles:
for k in ("corr_x", "corr_y"):
dd = [abs(v(b, c, k) - v(a, c, k)) for a, b in zip(temps, temps[1:])
if v(a, c, k) is not None and v(b, c, k) is not None]
bruit[(c, k)] = st.median(dd) if dd else 1
for a, b in zip(temps, temps[1:]):
out = []
for k in ("corr_x", "corr_y"):
s = []
for c in cibles:
if v(a, c, k) is None or v(b, c, k) is None:
continue
z = (v(b, c, k) - v(a, c, k)) / bruit[(c, k)]
if abs(z) > K:
s.append(f"{c}{z:+.0f}")
if len(s) >= NMIN:
out.append(f"{k}[{len(s)}] " + " ".join(s))
if out:
ev = " ".join(f"{r}={v(b, r, 'error_value'):.2f}/{rows[(b, r)]['inlier'] or '-'}" for r in refs if (b, r) in rows)
print(b.strftime("%d/%m %H:%M"), "|", " | ".join(out), "|", ev)
@@ -0,0 +1,103 @@
"""Vue du lot : médiane des cibles corr_x/corr_y, cibles une à une, température, pose.
usage : .venv/bin/python vue.py DEBUT FIN SORTIE [--table]"""
import csv, glob, sys, statistics as st
from datetime import datetime, timedelta, timezone
import matplotlib; matplotlib.use("Agg")
import matplotlib.pyplot as plt
import matplotlib.dates as md
D = "data/JUNGFRAU"
deb = datetime.fromisoformat(sys.argv[1].replace("Z", "+00:00"))
fin = datetime.fromisoformat(sys.argv[2].replace("Z", "+00:00"))
out = sys.argv[3]
def t15(s):
t = datetime.fromisoformat(s)
return t.replace(second=0, microsecond=0, minute=t.minute // 15 * 15)
def jours(a, b):
d = a.date() - timedelta(days=1)
while d <= b.date():
yield d.strftime("%Y%m%d"), d.strftime("%Y_%m_%d")
d += timedelta(days=1)
rows = {} # (t, capteur) -> dict
for j, _ in jours(deb, fin):
for f in glob.glob(f"{D}/displacement/JUNGFRAU_advanced_{j}.csv"):
for r in csv.DictReader(open(f)):
t = t15(r["time_utc"])
if deb <= t <= fin:
rows[(t, r["sensor_name"])] = r
temps = sorted({t for t, _ in rows})
caps = sorted({c for _, c in rows})
cibles = [c for c in caps if not c.startswith("REF") and c != "PM_G"]
def val(t, c, k):
r = rows.get((t, c))
if not r or r[k] == "":
return None
return float(r[k])
# niveau de chaque cible sur le lot
niv = {}
for c in caps:
for k in ("corr_x", "corr_y"):
v = [val(t, c, k) for t in temps]
v = [x for x in v if x is not None]
niv[(c, k)] = st.median(v) if v else 0
def med(t, k):
v = [val(t, c, k) for c in cibles]
v = [x - niv[(c, k)] for x, c in zip(v, cibles) if x is not None]
return st.median(v) if v else None
temp = {}
for _, j in jours(deb, fin):
for f in glob.glob(f"{D}/metrics/JUNGFRAU_sensor_thermal_deg_c_{j}_*"):
for r in csv.DictReader(open(f)):
t = datetime.fromisoformat(r["time_utc"])
if r["metric"] and deb - timedelta(hours=1) <= t <= fin:
temp[t] = float(r["metric"])
cam = {}
for j, _ in jours(deb, fin):
for f in glob.glob(f"{D}/camera/JUNGFRAU_camera_{j}.csv"):
for r in csv.DictReader(open(f)):
t = t15(r["time_utc"])
if deb <= t <= fin:
cam[t] = (float(r["median_pan"]), float(r["median_tilt"]), float(r["median_scale"]))
fig, ax = plt.subplots(6, 1, figsize=(22, 20), sharex=True)
for k, a in zip(("corr_x", "corr_y"), ax[:2]):
a.plot(temps, [med(t, k) for t in temps], "k-", lw=1)
a.set_ylabel(f"médiane cibles {k}")
for k, a in zip(("corr_x", "corr_y"), ax[2:4]):
for c in cibles:
a.plot(temps, [(val(t, c, k) - niv[(c, k)]) if val(t, c, k) is not None else None for t in temps], lw=0.7, label=c)
a.set_ylabel(k + " par cible")
a.legend(ncol=6, fontsize=7)
ts = sorted(temp)
ax[4].plot(ts, [temp[t] for t in ts], "r.-")
ax[4].set_ylabel("sensor_thermal °C")
tc = sorted(cam)
ax[5].plot(tc, [cam[t][1] for t in tc], "g.-", ms=2)
ax[5].set_ylabel("tilt caméra")
for a in ax:
a.grid(alpha=.4)
a.xaxis.set_major_locator(md.HourLocator(byhour=[0, 6, 12, 18]))
a.xaxis.set_major_formatter(md.DateFormatter("%d/%m\n%Hh"))
fig.tight_layout()
nom = f"{out}/vue_{deb:%m%d%H%M}_{fin:%m%d%H%M}.png"
fig.savefig(nom, dpi=70)
print(nom)
if "--table" in sys.argv:
print("heure medX medY temp tilt n_cibles_corr")
for t in temps:
if t.minute % 30 and "--pas15" not in sys.argv:
continue
mx, my = med(t, "corr_x"), med(t, "corr_y")
tt = temp.get(t.replace(minute=0))
n = sum(val(t, c, "corr_y") is not None for c in cibles)
f = lambda x: " - " if x is None else f"{x:+.3f}"
print(t.strftime("%d/%m %H:%M"), f(mx), f(my), tt if tt is not None else "-",
f"{cam[t][1]:.4f}" if t in cam else "-", n)