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>
75 lines
3.6 KiB
Python
75 lines
3.6 KiB
Python
"""Vue d'une fenêtre : température, pose, error_value, corr_x, corr_y (mesures acceptées), rejets marqués.
|
|
Usage : .venv/bin/python vue.py DEBUT FIN NOM
|
|
"""
|
|
import csv, glob, sys
|
|
from datetime import datetime
|
|
import matplotlib
|
|
matplotlib.use('Agg')
|
|
import matplotlib.pyplot as plt
|
|
import matplotlib.dates as mdates
|
|
|
|
D = 'data/FLORIDA'
|
|
OUT = 'labeling/auto/etiqueteur/FLORIDA_2026-10-01'
|
|
deb, fin, nom = sys.argv[1], sys.argv[2], sys.argv[3]
|
|
P = lambda s: datetime.fromisoformat(s[:16].replace(' ', 'T'))
|
|
d0, d1 = P(deb), P(fin)
|
|
caps = ['p1_r', 'r1_r', 'Sellette 3', 'Pont Ernen', 'Sellette 4', 'Sellette 5', 'Massif 2', 'Sellette 6']
|
|
S = {c: {'t': [], 'e': [], 'cx': [], 'cy': [], 'rej': []} for c in caps}
|
|
for f in sorted(glob.glob(f'{D}/displacement/*.csv')):
|
|
for r in csv.DictReader(open(f)):
|
|
t = P(r['time_utc'])
|
|
if not d0 <= t <= d1:
|
|
continue
|
|
s = S[r['sensor_name']]
|
|
rej = float(r['error_value']) > float(r['error_threshold'])
|
|
s['t'].append(t); s['e'].append(float(r['error_value'])); s['rej'].append(rej)
|
|
ok = not rej and r['corr_x'] != ''
|
|
s['cx'].append(float(r['corr_x']) if ok else float('nan'))
|
|
s['cy'].append(float(r['corr_y']) if ok else float('nan'))
|
|
pose = {'t': [], 'pan': [], 'tilt': [], 'scale': [], 'rot': []}
|
|
for f in sorted(glob.glob(f'{D}/camera/*.csv')):
|
|
for r in csv.DictReader(open(f)):
|
|
t = P(r['time_utc'])
|
|
if d0 <= t <= d1:
|
|
pose['t'].append(t); pose['pan'].append(float(r['median_pan'])); pose['tilt'].append(float(r['median_tilt']))
|
|
pose['scale'].append(float(r['median_scale'])); pose['rot'].append(float(r['median_rotation']))
|
|
temp = {}
|
|
for m in ['sensor_thermal_deg_c', 'BusVoltage']:
|
|
tt, vv = [], []
|
|
for f in sorted(glob.glob(f'{D}/metrics/FLORIDA_{m}_*.csv')):
|
|
for r in csv.DictReader(open(f)):
|
|
t = P(r['time_utc'])
|
|
if d0 <= t <= d1 and r['metric'] not in ('', 'nan'):
|
|
tt.append(t); vv.append(float(r['metric']))
|
|
temp[m] = (tt, vv)
|
|
fig, ax = plt.subplots(8, 1, figsize=(16, 22), sharex=True)
|
|
ax[0].plot(*temp['sensor_thermal_deg_c'], '.-'); ax[0].set_ylabel('T thermal °C')
|
|
a2 = ax[0].twinx(); a2.plot(*temp['BusVoltage'], 'r.', ms=2); a2.set_ylabel('BusVoltage', color='r')
|
|
ax[1].plot(pose['t'], pose['pan'], '.-', ms=2, label='pan'); ax[1].plot(pose['t'], pose['tilt'], '.-', ms=2, label='tilt'); ax[1].legend(); ax[1].set_ylabel('deg')
|
|
ax[2].plot(pose['t'], pose['scale'], '.-', ms=2); ax[2].set_ylabel('scale')
|
|
a3 = ax[2].twinx(); a3.plot(pose['t'], pose['rot'], 'g.', ms=2); a3.set_ylabel('rotation', color='g')
|
|
for c in caps:
|
|
s = S[c]
|
|
l, = ax[3].plot(s['t'], s['e'], '.-', ms=2, lw=0.5, label=c)
|
|
ax[3].axhline(0.7, color='k', ls=':'); ax[3].legend(ncol=8, fontsize=7); ax[3].set_ylabel('error_value')
|
|
for i, k in [(4, 'cx'), (5, 'cy')]:
|
|
for c in caps[2:]:
|
|
ax[i].plot(S[c]['t'], S[c][k], '.-', ms=2, lw=0.5, label=c)
|
|
ax[i].legend(ncol=6, fontsize=7); ax[i].set_ylabel('corr_' + k[1])
|
|
# rejets : une ligne par capteur
|
|
for j, c in enumerate(caps):
|
|
s = S[c]
|
|
ax[6].plot([t for t, r in zip(s['t'], s['rej']) if r], [j] * sum(s['rej']), '|', ms=8)
|
|
ax[6].set_yticks(range(len(caps))); ax[6].set_yticklabels(caps); ax[6].set_ylabel('rejetées')
|
|
pt = set(pose['t'])
|
|
ax[7].plot([t for t in S['p1_r']['t'] if t not in pt], [1] * len([t for t in S['p1_r']['t'] if t not in pt]), 'k|', ms=10)
|
|
ax[7].set_ylabel('sans pose')
|
|
for a in ax:
|
|
a.grid(alpha=.3)
|
|
ax[-1].xaxis.set_major_formatter(mdates.DateFormatter('%d/%m %H:%M'))
|
|
fig.autofmt_xdate()
|
|
fig.tight_layout()
|
|
p = f'{OUT}/vue_{nom}.png'
|
|
fig.savefig(p, dpi=70)
|
|
print(p)
|