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,21 @@
|
||||
"""Écarts brefs : chaque cible face à la médiane de ses 2 mesures d'avant et 2 d'après ; instants où beaucoup de cibles s'écartent ensemble."""
|
||||
import csv, glob, statistics as st
|
||||
d = {}
|
||||
for f in sorted(glob.glob("data/NEBRASKA/displacement/*.csv")):
|
||||
for r in csv.DictReader(open(f)):
|
||||
if r["pattern_type"] != "target" or r["corr_x"] == "" or float(r["error_value"]) > float(r["error_threshold"]): continue
|
||||
k = r["time_utc"][:16]
|
||||
if k > "2026-11-01T00:01": continue
|
||||
d.setdefault(r["sensor_name"], {})[k] = (float(r["corr_x"]), float(r["corr_y"]))
|
||||
ks = sorted({k for c in d for k in d[c]})
|
||||
for j, col in enumerate(("corr_x", "corr_y")):
|
||||
dev = {}
|
||||
for c in d:
|
||||
s = [d[c][k][j] for k in ks]
|
||||
e = [s[i] - st.median(s[max(0, i - 2):i] + s[i + 1:i + 3]) for i in range(len(s))]
|
||||
b = st.median([abs(x) for x in e]) or 1e-9
|
||||
for k, x in zip(ks, e): dev.setdefault(k, []).append(x / b)
|
||||
print(f"== {col} : instants où ≥ 6 cibles sur 12 s'écartent de > 3 bruits du même côté (bruit = médiane |écart|)")
|
||||
for k in ks:
|
||||
up = sum(x > 3 for x in dev[k]); dn = sum(x < -3 for x in dev[k])
|
||||
if max(up, dn) >= 6: print(f" {k} +{up} -{dn} médiane {st.median(dev[k]):+.1f}")
|
||||
@@ -0,0 +1,15 @@
|
||||
"""Médiane par demi-journée de corr_x, corr_y par cible (moins sa médiane 03-06.10) ; usage : parjour.py corr_x|corr_y"""
|
||||
import csv, glob, statistics as st, sys
|
||||
col = sys.argv[1]
|
||||
d = {}
|
||||
for f in sorted(glob.glob("data/NEBRASKA/displacement/*.csv")):
|
||||
for r in csv.DictReader(open(f)):
|
||||
if r["pattern_type"] != "target" or r[col] == "" or float(r["error_value"]) > float(r["error_threshold"]): continue
|
||||
k = r["time_utc"][:10] + ("a" if r["time_utc"][11:13] < "12" else "b")
|
||||
if k > "2026-11-01": continue
|
||||
d.setdefault(r["sensor_name"], {}).setdefault(k, []).append(float(r[col]))
|
||||
cs = sorted(d); ks = sorted({k for c in cs for k in d[c]})
|
||||
base = {c: st.median([v for k in ks if "2026-10-03" <= k < "2026-10-07" for v in d[c].get(k, [])]) for c in cs}
|
||||
print("demi-j " + " ".join(f"{c:>7}" for c in cs))
|
||||
for k in ks:
|
||||
print(k[5:] + " " + " ".join(f"{st.median(d[c][k]) - base[c]:+7.3f}" if k in d[c] else " ." for c in cs))
|
||||
@@ -0,0 +1,44 @@
|
||||
"""Régressions : tilt ~ température (+ temps) ; cx ~ tilt, cx ~ température ; résidus par jour."""
|
||||
import csv, statistics as st
|
||||
from datetime import datetime
|
||||
import matplotlib; matplotlib.use("Agg")
|
||||
import matplotlib.pyplot as plt
|
||||
OUT = "labeling/auto/etiqueteur/NEBRASKA_2026-10-01"
|
||||
R = [r for r in csv.DictReader(open(f"{OUT}/table.tsv"), delimiter="\t")]
|
||||
f = lambda r, c: float(r[c]) if r[c] not in ("", "None", "nan") else None
|
||||
R = [r for r in R if f(r, "A0_24h") is not None and f(r, "tilt") is not None]
|
||||
day = lambda r: (datetime.fromisoformat(r["t"]) - datetime(2026, 10, 3)).total_seconds() / 86400
|
||||
|
||||
def ols(X, y): # moindres carrés par équations normales (petites dimensions)
|
||||
n = len(X[0]); A = [[sum(a[i] * a[j] for a in X) for j in range(n)] for i in range(n)]; b = [sum(a[i] * v for a, v in zip(X, y)) for i in range(n)]
|
||||
for i in range(n):
|
||||
p = A[i][i]
|
||||
for j in range(i + 1, n):
|
||||
m = A[j][i] / p; A[j] = [u - m * w for u, w in zip(A[j], A[i])]; b[j] -= m * b[i]
|
||||
c = [0] * n
|
||||
for i in reversed(range(n)): c[i] = (b[i] - sum(A[i][j] * c[j] for j in range(i + 1, n))) / A[i][i]
|
||||
res = [v - sum(ci * a for ci, a in zip(c, row)) for row, v in zip(X, y)]
|
||||
return c, res
|
||||
def r2(y, res): m = st.mean(y); return 1 - sum(e * e for e in res) / sum((v - m) ** 2 for v in y)
|
||||
|
||||
for nom, sel in [("mois", R), ("après 09.10 12h", [r for r in R if r["t"] >= "2026-10-09T12"])]:
|
||||
T = [f(r, "A0_24h") for r in sel]; d = [day(r) for r in sel]; ti = [f(r, "tilt") for r in sel]; cx = [f(r, "cx") for r in sel]
|
||||
for lab, y in [("tilt", ti), ("cx", cx)]:
|
||||
c1, e1 = ols([[1, t] for t in T], y); c2, e2 = ols([[1, x] for x in d], y); c3, e3 = ols([[1, t, x] for t, x in zip(T, d)], y)
|
||||
print(f"{nom} {lab}: R2 temp={r2(y,e1):.2f} (pente {c1[1]:.4g}/°C), R2 temps={r2(y,e2):.2f}, R2 temp+temps={r2(y,e3):.2f} (pente temp {c3[1]:.4g}, pente temps {c3[2]:.4g}/j)")
|
||||
c, e = ols([[1, t] for t in [f(r, "tilt") for r in sel]], cx); print(f"{nom} cx~tilt R2={r2(cx,e):.2f} pente {c[1]:.4g}")
|
||||
# résidu du tilt après la température, sur le mois, figure
|
||||
T = [f(r, "A0_24h") for r in R]; ti = [f(r, "tilt") for r in R]; x = [datetime.fromisoformat(r["t"]) for r in R]
|
||||
c, e = ols([[1, t] for t in T], ti)
|
||||
cx = [f(r, "cx") for r in R]
|
||||
sel = [i for i, r in enumerate(R) if r["t"] >= "2026-10-09T12"]
|
||||
cc, ee = ols([[1, T[i]] for i in sel], [cx[i] for i in sel])
|
||||
fig, ax = plt.subplots(3, 1, figsize=(14, 9), sharex=True)
|
||||
ax[0].plot(x, e, ".-"); ax[0].set_ylabel("tilt − f(temp. 24 h)"); ax[0].axhline(0, color="k", lw=.5)
|
||||
ax[1].plot([x[i] for i in sel], ee, ".-"); ax[1].set_ylabel("cx − f(temp. 24 h) après 09.10"); ax[1].axhline(0, color="k", lw=.5)
|
||||
ax[2].plot(x, [f(r, "A0") for r in R], "-", lw=.6, label="A0 brut"); ax[2].plot(x, T, "r-", label="A0 24 h"); ax[2].plot(x, [f(r, "thermal") for r in R], "-", lw=.6, label="thermal"); ax[2].legend()
|
||||
for a in ax: a.grid(alpha=.3)
|
||||
fig.tight_layout(); fig.savefig(f"{OUT}/residus_temperature.png", dpi=80); print(f"{OUT}/residus_temperature.png")
|
||||
by = {}
|
||||
for r, ei in zip(R, e): by.setdefault(r["t"][:10], []).append(ei)
|
||||
print("résidu tilt par jour:", " ".join(f"{k[5:]}:{st.mean(v):+.4f}" for k, v in by.items()))
|
||||
@@ -0,0 +1,64 @@
|
||||
"""Table par instant : médiane des cibles (corr - niveau propre), pose caméra, températures ; figure."""
|
||||
import csv, glob, statistics as st, sys
|
||||
from datetime import datetime
|
||||
import matplotlib; matplotlib.use("Agg")
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
D = "data/NEBRASKA"; OUT = "labeling/auto/etiqueteur/NEBRASKA_2026-10-01"
|
||||
T0, T1 = "2026-10-03", "2026-11-01T00:01"
|
||||
def t(s): return s[:16].replace(" ", "T")
|
||||
|
||||
rows = {} # instant -> capteur -> dict
|
||||
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
|
||||
rows.setdefault(k, {})[r["sensor_name"]] = r
|
||||
cam = {}
|
||||
for f in sorted(glob.glob(f"{D}/camera/*.csv")):
|
||||
for r in csv.DictReader(open(f)):
|
||||
cam[t(r["time_utc"])] = r
|
||||
temp = {}
|
||||
for s in ["A0", "CPU", "GPU", "PLL", "thermal"]:
|
||||
for f in glob.glob(f"{D}/metrics/NEBRASKA_sensor_{s}_deg_c_*.csv"):
|
||||
for r in csv.DictReader(open(f)):
|
||||
if r["metric"]: temp.setdefault(t(r["time_utc"]), {})[s] = float(r["metric"])
|
||||
|
||||
inst = sorted(rows)
|
||||
cibles = sorted({c for k in inst for c, r in rows[k].items() if r["pattern_type"] == "target"})
|
||||
def val(r, c):
|
||||
try: return float(r[c]) if float(r["error_value"]) <= float(r["error_threshold"]) and r[c] != "" else None
|
||||
except ValueError: return None
|
||||
niv = {(c, col): st.median([v for k in inst if c in rows[k] for v in [val(rows[k][c], col)] if v is not None])
|
||||
for c in cibles for col in ("corr_x", "corr_y")}
|
||||
# température : moyenne glissante 24 h centrée sur l'instant (heures disponibles)
|
||||
def tmoy(k, s="A0", w=12):
|
||||
h = datetime.fromisoformat(k)
|
||||
vals = [v[s] for kk, v in temp.items() if s in v and abs((datetime.fromisoformat(kk) - h).total_seconds()) <= w * 3600]
|
||||
return st.mean(vals) if vals else None
|
||||
out = []
|
||||
for k in inst:
|
||||
mx = st.median([val(rows[k][c], "corr_x") - niv[(c, "corr_x")] for c in cibles if c in rows[k] and val(rows[k][c], "corr_x") is not None])
|
||||
my = st.median([val(rows[k][c], "corr_y") - niv[(c, "corr_y")] for c in cibles if c in rows[k] and val(rows[k][c], "corr_y") is not None])
|
||||
cm = cam.get(k, {})
|
||||
out.append(dict(t=k, cx=mx, cy=my, pan=float(cm.get("median_pan") or "nan"), tilt=float(cm.get("median_tilt") or "nan"),
|
||||
rot=float(cm.get("median_rotation") or "nan"), scale=float(cm.get("median_scale") or "nan"),
|
||||
tA0=temp.get(k, {}).get("A0"), tA0_24=tmoy(k), tTh=temp.get(k, {}).get("thermal")))
|
||||
with open(f"{OUT}/table.tsv", "w") as fo:
|
||||
fo.write("t\tcx\tcy\tpan\ttilt\trot\tscale\tA0\tA0_24h\tthermal\n")
|
||||
for o in out:
|
||||
fo.write("\t".join(str(round(o[c], 5)) if isinstance(o[c], float) else str(o[c]) for c in ["t","cx","cy","pan","tilt","rot","scale","tA0","tA0_24","tTh"]) + "\n")
|
||||
def corr(a, b):
|
||||
p = [(x, y) for x, y in zip(a, b) if x is not None and y is not None and x == x and y == y]
|
||||
return st.correlation([x for x, _ in p], [y for _, y in p]) if len(p) > 3 else None
|
||||
for nom, sel in [("tout", out), ("avant 09.10 12h", [o for o in out if o["t"] < "2026-10-09T12"]), ("après", [o for o in out if o["t"] >= "2026-10-09T12"])]:
|
||||
print(nom, {f"{a}~{b}": round(corr([o[a] for o in sel], [o[b] for o in sel]) or 0, 2)
|
||||
for a in ("cx", "cy") for b in ("tilt", "pan", "rot", "scale", "tA0_24")}, "tilt~A0_24", round(corr([o["tilt"] for o in sel], [o["tA0_24"] for o in sel]), 2))
|
||||
x = [datetime.fromisoformat(o["t"]) for o in out]
|
||||
fig, ax = plt.subplots(6, 1, figsize=(14, 16), sharex=True)
|
||||
for a, (c, lab) in zip(ax, [("cx", "médiane cibles corr_x"), ("cy", "médiane cibles corr_y"), ("tilt", "tilt"), ("pan", "pan"), ("rot", "rotation"), ("scale", "scale")]):
|
||||
a.plot(x, [o[c] for o in out], ".-"); a.set_ylabel(lab); a.grid(alpha=.3)
|
||||
a2 = ax[2].twinx(); a2.plot(x, [o["tA0_24"] for o in out], "r-"); a2.set_ylabel("A0 moy 24h (rouge)", color="r"); a2.invert_yaxis()
|
||||
a3 = ax[0].twinx(); a3.plot(x, [o["tA0_24"] for o in out], "r-"); a3.invert_yaxis(); a3.set_ylabel("A0 24h inversée", color="r")
|
||||
for a in ax: a.axvline(datetime.fromisoformat("2026-10-09T12:00"), color="k", ls=":")
|
||||
fig.tight_layout(); fig.savefig(f"{OUT}/cibles_pose_temperature.png", dpi=80); print(f"{OUT}/cibles_pose_temperature.png")
|
||||
Reference in new issue
Block a user