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,111 @@
"""Dérive des corr face à la pose de la caméra et à la température, BREITHORN, octobre 2026.
Lancer depuis la racine : .venv/bin/python labeling/auto/etiqueteur/BREITHORN_2026-10-01/outils/derive.py"""
import csv, glob, statistics as st
from datetime import datetime
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
D = "data/BREITHORN"
OUT = "labeling/auto/etiqueteur/BREITHORN_2026-10-01"
T0, T1 = "2026-10-03", "2026-11-01T00:01"
def t(s):
return s[:16].replace(" ", "T")
mes = {} # capteur -> list of (t, x, y, err, thr, cx, cy, rx, ry)
for f in sorted(glob.glob(f"{D}/displacement/*.csv")):
for r in csv.DictReader(open(f)):
k = t(r["time_utc"])
if not (T0 <= k <= T1):
continue
fl = lambda c: float(r[c]) if r[c] not in ("", None) else None
err, thr = fl("error_value"), fl("error_threshold")
ok = err <= thr
mes.setdefault(r["sensor_name"], []).append(
(k, fl("x"), fl("y"), err, ok, fl("corr_x") if ok else None, fl("corr_y") if ok else None, fl("relative_x"), fl("relative_y")))
cam = {}
for f in sorted(glob.glob(f"{D}/camera/*.csv")):
for r in csv.DictReader(open(f)):
k = t(r["time_utc"])
if T0 <= k <= T1:
cam[k] = (float(r["median_pan"]), float(r["median_tilt"]), float(r["median_rotation"]), float(r["median_scale"]))
temp = {}
for f in sorted(glob.glob(f"{D}/metrics/*sensor_thermal_deg_c*.csv")):
for r in csv.DictReader(open(f)):
k = t(r["time_utc"])
if T0 <= k <= T1 and r["metric"]:
temp[k] = float(r["metric"])
def corr(a, b):
if len(a) < 10:
return float("nan")
ma, mb = st.mean(a), st.mean(b)
sa = sum((x - ma) ** 2 for x in a) ** .5
sb = sum((y - mb) ** 2 for y in b) ** .5
return sum((x - ma) * (y - mb) for x, y in zip(a, b)) / (sa * sb) if sa and sb else float("nan")
print("capteur x_img y_img | r(corr_x,tilt) r(corr_y,tilt) r(corr_x,rot) r(corr_y,rot) | corr_x début->fin corr_y début->fin (médianes 03-05/10 et 29-31/10)")
for s, L in sorted(mes.items()):
xs = [v for v in L if v[5] is not None and v[0] in cam]
tl = [cam[v[0]][1] for v in xs]
rt = [cam[v[0]][2] for v in xs]
cx = [v[5] for v in xs]; cy = [v[6] for v in xs]
deb = [v for v in xs if v[0] < "2026-10-06"]; fin = [v for v in xs if v[0] >= "2026-10-29"]
print(f"{s:9s} {st.median(v[1] for v in L):7.0f} {st.median(v[2] for v in L):7.0f} | {corr(cx,tl):6.2f} {corr(cy,tl):6.2f} {corr(cx,rt):6.2f} {corr(cy,rt):6.2f} | "
f"{st.median(v[5] for v in deb):+.3f}->{st.median(v[5] for v in fin):+.3f} {st.median(v[6] for v in deb):+.3f}->{st.median(v[6] for v in fin):+.3f}"
f" raw x {st.median(v[1] for v in deb):.2f}->{st.median(v[1] for v in fin):.2f} y {st.median(v[2] for v in deb):.2f}->{st.median(v[2] for v in fin):.2f}")
# température : médiane par jour, min, max
print("\njour T_thermal médiane min max ; tilt fin de jour ; rotation")
jours = sorted({k[:10] for k in temp})
for j in jours:
v = [temp[k] for k in temp if k.startswith(j)]
c = [cam[k] for k in cam if k.startswith(j)]
print(j, f"{st.median(v):5.1f} {min(v):5.1f} {max(v):5.1f}", f"{c[-1][1]:.4f} {c[-1][2]:.4f}" if c else "")
# figure : corr_x, corr_y des cibles qui dérivent et des autres, face à tilt, rotation, température
derivent = ["COLH20", "COLI20", "COLI21", "COLJ19", "POUI19", "POUI20"]
autres = ["POUH21", "COLI22", "COLH20'''", "COLI24", "POUI22", "POUI24"]
fig, ax = plt.subplots(6, 1, figsize=(14, 18), sharex=True)
tt = lambda ks: [datetime.fromisoformat(k) for k in ks]
for i, col in enumerate((5, 6)):
for grp, a in ((derivent, ax[i]), (autres, ax[2 + i])):
for s in grp:
L = [v for v in mes[s] if v[col] is not None]
m = st.median(v[col] for v in L)
a.plot(tt([v[0] for v in L]), [v[col] - m for v in L], ".-", ms=2, lw=.7, label=s)
a.set_ylabel(("corr_x", "corr_y")[i] + (" (dérivent)" if grp is derivent else " (autres)"))
a.legend(fontsize=7, ncol=6); a.grid(alpha=.3)
ks = sorted(cam)
ax[4].plot(tt(ks), [cam[k][1] for k in ks], "g.-", ms=2, label="tilt")
a2 = ax[4].twinx(); a2.plot(tt(ks), [cam[k][2] for k in ks], "r.-", ms=2, label="rotation"); a2.set_ylabel("rotation [deg]", color="r")
ax[4].set_ylabel("tilt [deg]", color="g"); ax[4].grid(alpha=.3)
kt = sorted(temp)
ax[5].plot(tt(kt), [temp[k] for k in kt], "k-", lw=.6); ax[5].set_ylabel("sensor_thermal [°C]"); ax[5].grid(alpha=.3)
fig.suptitle("BREITHORN : corr des cibles (moins leur médiane) face à la pose de la caméra et à la température")
fig.tight_layout(); p = f"{OUT}/derive-pose-temperature.png"; fig.savefig(p, dpi=80); print(p)
# Ajout après les précisions de l'expert : r avec pan, et nuages corr face à tilt, pan, rotation
print("\ncapteur r(corr_x,pan) r(corr_y,pan)")
for s in derivent + autres:
xs = [v for v in mes[s] if v[5] is not None and v[0] in cam]
print(f"{s:9s} {corr([v[5] for v in xs],[cam[v[0]][0] for v in xs]):6.2f} {corr([v[6] for v in xs],[cam[v[0]][0] for v in xs]):6.2f}")
fig, ax = plt.subplots(2, 3, figsize=(15, 8))
for i, col in enumerate((5, 6)):
for j, (pi, nom) in enumerate(((1, "tilt"), (0, "pan"), (2, "rotation"))):
a = ax[i][j]
for s in derivent:
L = [v for v in mes[s] if v[col] is not None and v[0] in cam]
m = st.median(v[col] for v in L)
a.plot([cam[v[0]][pi] for v in L], [v[col] - m for v in L], ".", ms=3, label=s)
L = [v for v in mes["POUH21"] if v[col] is not None and v[0] in cam]
m = st.median(v[col] for v in L)
a.plot([cam[v[0]][pi] for v in L], [v[col] - m for v in L], "k+", ms=4, label="POUH21 (témoin)")
a.set_xlabel(nom + " [deg]"); a.set_ylabel(("corr_x", "corr_y")[i]); a.grid(alpha=.3)
a.set_ylim(-0.3, 0.3)
ax[0][0].legend(fontsize=7)
fig.suptitle("BREITHORN 03-31/10 : corr des cibles qui dérivent (moins leur médiane) face à la pose de la caméra ; POUH21 en témoin")
fig.tight_layout(); p = f"{OUT}/derive-face-a-la-pose.png"; fig.savefig(p, dpi=75); print(p)
@@ -0,0 +1,20 @@
"""Médianes par 12 h des corr des cibles qui dérivent et de la pose."""
import csv, glob, statistics as st
D="data/BREITHORN"; S=["COLH20","COLI20","COLI21","COLJ19","POUI19","POUI20","COLI24","COLH20'''"]
v={}
for f in sorted(glob.glob(f"{D}/displacement/*.csv")):
for r in csv.DictReader(open(f)):
if r["sensor_name"] in S and float(r["error_value"])<=float(r["error_threshold"]):
k=r["time_utc"][:10]+("a" if r["time_utc"][11:13]<"12" else "b")
v.setdefault(k,{}).setdefault(r["sensor_name"],[]).append((float(r["corr_x"]),float(r["corr_y"])))
c={}
for f in sorted(glob.glob(f"{D}/camera/*.csv")):
for r in csv.DictReader(open(f)):
k=r["time_utc"][:10]+("a" if r["time_utc"][11:13]<"12" else "b")
c.setdefault(k,[]).append((float(r["median_pan"]),float(r["median_tilt"]),float(r["median_rotation"])))
print("demi-jour tilt rot pan | corr_x: "+" ".join(f"{s[:7]:>7}" for s in S)+" | corr_y COLI24")
for k in sorted(v):
if k>"2026-11-01": break
p=[st.median(z[i] for z in c[k]) for i in range(3)]
print(k,f"{p[1]:.4f} {p[2]:.4f} {p[0]:.4f} |",*(f"{st.median(z[0] for z in v[k][s]):+.3f}" if s in v[k] else " - " for s in S),
"|",f"{st.median(z[1] for z in v[k]['COLI24']):+.3f}" if "COLI24" in v[k] else "-")
@@ -0,0 +1,27 @@
"""Par instant : capteurs dont corr s'écarte de leur médiane glissante (±1 j) de plus de K bruits, rejets, error_value des références."""
import csv, glob, statistics as st
D="data/BREITHORN"; K=5
rows={}
for f in sorted(glob.glob(f"{D}/displacement/*.csv")):
for r in csv.DictReader(open(f)):
k=r["time_utc"][:16].replace(" ","T")
if "2026-10-03"<=k<="2026-11-01T00:01": rows.setdefault(r["sensor_name"],{})[k]=r
inst=sorted({k for s in rows.values() for k in s})
ref={s for s,d in rows.items() if next(iter(d.values()))["pattern_type"]=="global_ref"}
res={}
for s,d in rows.items():
for c in ("corr_x","corr_y"):
ser=[(k,float(d[k][c])) if k in d and d[k][c] and float(d[k]["error_value"])<=float(d[k]["error_threshold"]) else (k,None) for k in inst]
vals=[v for _,v in ser]
noise=st.median(abs(vals[i+1]-vals[i]) for i in range(len(vals)-1) if vals[i] is not None and vals[i+1] is not None)
for i,(k,v) in enumerate(ser):
if v is None: continue
w=[x for x in vals[max(0,i-6):i+7] if x is not None]
dv=v-st.median(w)
if abs(dv)>K*noise: res.setdefault(k,[]).append(f"{s}.{c[-1]}{dv/noise:+.0f}")
for k in inst:
rej=[s for s in rows if k in rows[s] and float(rows[s][k]["error_value"])>float(rows[s][k]["error_threshold"])]
re=" ".join(f"{s}:{float(rows[s][k]['error_value']):.2f}/{rows[s][k]['inlier'] or '-'}" for s in sorted(ref) if k in rows[s])
sg=next(iter(rows.values()))[k]["sigma0"] if k in next(iter(rows.values())) else ""
if res.get(k) or rej:
print(k,"| rej:",",".join(rej) or "-","| corr:"," ".join(res.get(k,[])),"| refs:",re,"| sigma0",sg[:7])
@@ -0,0 +1,15 @@
"""Planche de la zone basse de la scène (où passent les véhicules) à plusieurs heures. usage: scene.py NOM H1,H2,... (AAAAMMJJTHHMM)"""
import sys, glob
import matplotlib; matplotlib.use("Agg")
import matplotlib.pyplot as plt, matplotlib.image as mpimg
D="data/BREITHORN/images"; nom=sys.argv[1]; hs=sys.argv[2].split(",")
X0,X1,Y0,Y1=[int(v) for v in (sys.argv[3] if len(sys.argv)>3 else "0,2700,950,1750").split(",")]
n=len(hs); c=4; r=(n+c-1)//c
fig,ax=plt.subplots(r,c,figsize=(5*c,3.4*r)); ax=ax.ravel()
for a,h in zip(ax,hs):
f=glob.glob(f"{D}/{h}Z_*.jpg"); a.axis("off")
if not f: a.set_title(h+" : pas d'image"); continue
im=mpimg.imread(f[0])[Y0:Y1,X0:X1]
a.imshow(im,cmap="gray",vmin=0,vmax=90,extent=(X0,X1,Y1,Y0)); a.set_title(h+"Z",fontsize=9)
for a in ax[n:]: a.axis("off")
fig.tight_layout(); p=f"labeling/auto/etiqueteur/BREITHORN_2026-10-01/scene-{nom}.png"; fig.savefig(p,dpi=80); print(p)
@@ -0,0 +1,14 @@
"""Table corr_x/corr_y (ou autre colonne) de tous les capteurs sur une fenêtre. usage: table.py DEBUT FIN [colonne]"""
import csv, glob, sys
D="data/BREITHORN"; a,b=sys.argv[1],sys.argv[2]; cols=sys.argv[3].split(",") if len(sys.argv)>3 else ["corr_x","corr_y"]
v={}; S=[]
for f in sorted(glob.glob(f"{D}/displacement/*.csv")):
for r in csv.DictReader(open(f)):
k=r["time_utc"][:16].replace(" ","T")
if a<=k<=b:
if r["sensor_name"] not in S: S.append(r["sensor_name"])
rej=float(r["error_value"])>float(r["error_threshold"])
v.setdefault(k,{})[r["sensor_name"]]=[("R" if rej and c.startswith("corr") else (f"{float(r[c]):+.3f}" if r[c] else "-")) for c in cols]
for c_i,c in enumerate(cols):
print(f"== {c}"); print("instant "+" ".join(f"{s[:8]:>8}" for s in S))
for k in sorted(v): print(k[5:]," "+" ".join(f"{v[k].get(s,['?']*len(cols))[c_i]:>8}" for s in S))
@@ -0,0 +1,25 @@
"""Signature des nuits froides : température, échelle, rotation, et corr_y de COLH20, REFPOU22, COLI21, POUI24 (moins médiane glissante ±1 j)."""
import csv, glob, statistics as st
D="data/BREITHORN"; S=["COLH20","REFPOU22","COLI21","POUI24","COLI24"]
temp={}
for f in glob.glob(f"{D}/metrics/*sensor_thermal_deg_c*.csv"):
for r in csv.DictReader(open(f)):
if r["metric"]: temp[r["time_utc"][:13]]=float(r["metric"])
cam={}
for f in glob.glob(f"{D}/camera/*.csv"):
for r in csv.DictReader(open(f)): cam[r["time_utc"][:16]]=(float(r["median_scale"]),float(r["median_rotation"]))
v={}
for f in sorted(glob.glob(f"{D}/displacement/*.csv")):
for r in csv.DictReader(open(f)):
if r["sensor_name"] in S and float(r["error_value"])<=float(r["error_threshold"]):
v.setdefault(r["sensor_name"],{})[r["time_utc"][:16]]=float(r["corr_y"])
ks=sorted(k for k in cam if "2026-10-03"<=k<="2026-11-01 00:00")
def dev(s,i):
k=ks[i]
if k not in v[s]: return " R "
w=[v[s][x] for x in ks[max(0,i-6):i+7] if x in v[s]]
return f"{v[s][k]-st.median(w):+.3f}"
print("instant T scale rot | "+" ".join(f"{s:>8}" for s in S))
for i,k in enumerate(ks):
t=temp.get(k[:13]); flag=" *" if t is not None and t<26.5 else ""
print(k[5:], f"{t if t is not None else float('nan'):5.2f} {cam[k][0]:.5f} {cam[k][1]:.4f} |", " ".join(f"{dev(s,i):>8}" for s in S), flag)