Files
Support-Agent/labeling/auto/revue-croisee/2026-11-04/finition/wildstrubel/outils/thermique.py
T
maximeandClaude Opus 5.5 35b5ed4d74 Auto labels reviewed per station and cross-reviewed; all labeling knowledge in labeling/ (D-130)
- Every station's auto labels reviewed by an analyst (/review-auto-labels), then a
  cross-review per family across all stations (new skill /cross-review-labels),
  a finishing pass, and descriptions rewritten in words (no numeric values).
- The three never-labeled ranges (WILDSTRUBEL 07/09-01/10, NORDEND 16/08-01/10)
  labeled and reviewed: 991 auto labels on 11 stations, labeling/controle.py at 0 errors.
- Labeling knowledge gathered in labeling/: regles-d-etiquetage.md (new), familles.md
  (settled boundaries), connaissances/ (notes moved from docs/, links updated),
  the label map rebuilt from reviewed labels, events and cases; events tied to their
  stations (PS_DES_COUDRES is JUNGFRAU). The labeler and reviewers read only labeling/.
- labels-map reads auto labels and events; decision D-130; living plan points 73-75.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 08:21:57 +01:00

96 lines
5.3 KiB
Python

"""Chaque étiquette Thermal displacement de WILDSTRUBEL face au jour mesuré.
Repos de la pose : nuit 00:00-03:00 du jour s'il y a au moins 6 mesures (septembre), sinon le repos de
l'après-midi du jour, de 13:30 à la dernière mesure (octobre : les nuits ne sont pas mesurées).
Par axe : écart au repos en bruits (bruit = médiane des |écarts| entre deux mesures du repos), au début de
l'étiquette, extrêmes et instants, retour (première mesure après le dernier extrême d'où l'axe reste à moins
de 5 bruits pendant 4 mesures). Température du boîtier (médiane des sensor_*_deg_c, à l'heure).
Positions brutes : médiane des y des capteurs non rejetés, écart au repos (px, y croît vers le bas).
Cibles : r de corr_x, corr_y (mesures acceptées) avec le tilt sur l'étiquette, et écart lissé (médiane
glissante de 5 mesures) au repos, en bruits du repos.
Usage : thermique.py"""
import sys, statistics as st
from datetime import datetime, timedelta
sys.path.insert(0, sys.path[0])
from donnees import mesures, pose, temperature, etiquettes
AX = ('pan', 'tilt', 'rot', 'scale')
CIB = ('PA2_2', 'PA3_2', 'PA_9', 'PB1_2', 'PB2_2', 'PB4', 'PB_5')
M, P, T = mesures(), pose(), temperature()
temps = sorted({t for t, _ in M})
def bruit(s):
return max(st.median([abs(b - a) for a, b in zip(s, s[1:])]), 1e-12)
def r(a, b):
if len(a) < 5:
return float('nan')
ma, mb = st.mean(a), st.mean(b)
num = sum((x - ma) * (y - mb) for x, y in zip(a, b))
den = (sum((x - ma) ** 2 for x in a) * sum((y - mb) ** 2 for y in b)) ** .5
return num / den if den else float('nan')
def ymed(t):
v = [float(M[(t, c)]['y']) for (tt, c) in [(t, c) for c in CIB + ('PA1_2', 'PA_8', 'PB3_2', 'R1', 'R2', 'R3')]
if (tt, c) in M and float(M[(tt, c)]['error_value']) <= float(M[(tt, c)]['error_threshold'])]
return st.median(v) if v else None
def corr(t, c, k):
r_ = M.get((t, c))
return float(r_[k]) if r_ and r_[k] and float(r_['error_value']) <= float(r_['error_threshold']) else None
for eid, e in etiquettes():
if e['categorie'] != 'Thermal displacement':
continue
a, b = datetime.fromisoformat(e['debut'][:16]), datetime.fromisoformat(e['fin'][:16])
j = a.replace(hour=0, minute=0)
nuit = [t for t in sorted(P) if j <= t < j + timedelta(hours=3)]
if len(nuit) >= 6:
rep, nom = nuit, 'nuit 00-03'
else:
fin_j = max(t for t in P if t.date() == a.date())
rep, nom = [t for t in sorted(P) if j + timedelta(hours=13, minutes=30) <= t <= fin_j], f'après-midi 13:30-{fin_j:%H:%M}'
jour = [t for t in sorted(P) if j + timedelta(hours=3) <= t <= j + timedelta(hours=19)]
print(f'\n=== {eid} {a:%d/%m %H:%M} -> {b:%H:%M} repos : {nom} ({len(rep)} mesures) ; mesures du jour {jour[0]:%H:%M}-{jour[-1]:%H:%M}')
for i, ax in enumerate(AX):
s = [P[t][i] for t in rep]
m, n = st.median(s), bruit(s)
dv = [(t, (P[t][i] - m) / n) for t in jour]
tmax = max(dv, key=lambda x: x[1]); tmin = min(dv, key=lambda x: x[1])
hors = [k for k, (t, d) in enumerate(dv) if abs(d) > 5]
prem = f'{dv[hors[0]-1][0]:%H:%M}' if hors and hors[0] > 0 else ('-' if not hors else 'début')
dern = max(k for k in (dv.index(tmax), dv.index(tmin)))
ret = '-'
for k in range(dern, len(dv) - 3):
if all(abs(d) < 5 for _, d in dv[k:k + 4]):
ret = f'{dv[k][0]:%H:%M}'; break
deb = dict(dv).get(a)
print(f' {ax:5} repos {m:+.5f} bruit {n:.2g} | au début {deb if deb is None else round(deb,1)} | max {tmax[1]:+.0f} à {tmax[0]:%H:%M}, min {tmin[1]:+.0f} à {tmin[0]:%H:%M} | 1er > 5 : après {prem} ; retour à moins de 5 dès {ret} ; à la fin {round(dict(dv).get(b, float("nan")),1)}')
th = [(t, T[t]) for t in sorted(T) if j <= t <= j + timedelta(hours=18)]
if th:
tm = max(th, key=lambda x: x[1]); tn = min(th, key=lambda x: x[1])
print(f' temp. boîtier : à {a:%H}h {T.get(a.replace(minute=0))}, min {tn[1]:.1f} à {tn[0]:%H}h, max {tm[1]:.1f} à {tm[0]:%H}h, à {b:%H}h {T.get(b.replace(minute=0))}, 15h {T.get(j+timedelta(hours=15))}, 17h {T.get(j+timedelta(hours=17))}')
yr = [ymed(t) for t in rep if t in set(temps)]
yr = st.median([y for y in yr if y is not None])
yd = [(t, ymed(t) - yr) for t in jour if t in set(temps) and ymed(t) is not None]
print(f' y brut médian : min {min(yd,key=lambda x:x[1])[1]:+.2f} px à {min(yd,key=lambda x:x[1])[0]:%H:%M}, max {max(yd,key=lambda x:x[1])[1]:+.2f} px à {max(yd,key=lambda x:x[1])[0]:%H:%M}')
lab = [t for t in temps if a <= t <= b]
ti = dict((t, P[t][1]) for t in lab if t in P)
for c in CIB:
out = []
for k in ('corr_x', 'corr_y'):
pr = [(ti[t], corr(t, c, k)) for t in lab if t in ti and corr(t, c, k) is not None]
sr = [corr(t, c, k) for t in rep if corr(t, c, k) is not None]
if len(sr) < 4:
out.append(f'{k[-1]}: repos insuffisant'); continue
m, n = st.median(sr), bruit(sr)
v = [y for _, y in pr]
lis = [st.median(v[max(0, q - 2):q + 3]) for q in range(len(v))]
ex = max(lis, key=lambda z: abs(z - m)) if lis else m
out.append(f'{k[-1]}: r_tilt {r([x for x,_ in pr],[y for _,y in pr]):+.2f}, lissé max {(ex-m)/n:+.1f} b ({len(v)} acc./{len(lab)})')
print(f' {c:6} ' + ' | '.join(out))