Files
Support-Agent/labeling/auto/etiqueteur/FLORIDA_2026-10-01/outils/jour_nuit.py
T
maximeandClaude Opus 5.5 6fbd7510b7 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>
2026-11-03 16:33:41 +01:00

51 lines
2.8 KiB
Python

"""Par jour : température min/max (heure), pose et corr : médiane 10-15 h moins médiane 0-4 h UTC ; rejets par capteur ; pas absents.
Usage : python3 jour_nuit.py
"""
import csv, glob, statistics as st
from collections import defaultdict
from datetime import datetime
D = 'data/FLORIDA'
P = lambda s: datetime.fromisoformat(s[:16].replace(' ', 'T'))
J0, J1 = '2026-10-01', '2026-10-31'
temp = defaultdict(list)
for f in sorted(glob.glob(f'{D}/metrics/FLORIDA_sensor_thermal_deg_c_*.csv')):
for r in csv.DictReader(open(f)):
if r['metric'] not in ('', 'nan'):
t = P(r['time_utc']); temp[t.date().isoformat()].append((t.hour, float(r['metric'])))
pose = defaultdict(lambda: defaultdict(list))
for f in sorted(glob.glob(f'{D}/camera/*.csv')):
for r in csv.DictReader(open(f)):
t = P(r['time_utc']); d = t.date().isoformat()
b = 'J' if 10 <= t.hour < 15 else 'N' if t.hour < 4 else None
if b:
for k in ('pan', 'tilt', 'scale'):
pose[d][k + b].append(float(r['median_' + k]))
corr = defaultdict(lambda: defaultdict(list))
rej = defaultdict(lambda: defaultdict(int))
n = defaultdict(set)
for f in sorted(glob.glob(f'{D}/displacement/*.csv')):
for r in csv.DictReader(open(f)):
t = P(r['time_utc']); d = t.date().isoformat(); c = r['sensor_name']
n[d].add(t)
if float(r['error_value']) > float(r['error_threshold']):
rej[d][c] += 1; continue
b = 'J' if 10 <= t.hour < 15 else 'N' if t.hour < 4 else None
if b and r['corr_x']:
corr[d][(c, 'x', b)].append(float(r['corr_x'])); corr[d][(c, 'y', b)].append(float(r['corr_y']))
def dj(dct, k):
a, b = dct.get(k + 'J') if isinstance(k, str) else dct.get(k + ('J',)), dct.get(k + 'N') if isinstance(k, str) else dct.get(k + ('N',))
return st.median(a) - st.median(b) if a and b else float('nan')
caps = ['p1_r', 'r1_r', 'Sellette 4', 'Sellette 5', 'Massif 2', 'Sellette 6']
print('jour Tmin Tmax hmax | dpan dtilt dscale | S4x S4y S5x S5y M2x S6x | pas | rejets ' + ' '.join(c[:6] for c in caps))
for d in sorted(n):
if not J0 <= d <= J1:
continue
T = temp.get(d, [])
tmin = min(v for h, v in T) if T else float('nan'); tmax = max(v for h, v in T) if T else float('nan')
hmax = max(T, key=lambda x: x[1])[0] if T else -1
p = pose[d]
dp = [dj(p, k) for k in ('pan', 'tilt', 'scale')]
cc = [dj(corr[d], (c, a)) for c, a in [('Sellette 4', 'x'), ('Sellette 4', 'y'), ('Sellette 5', 'x'), ('Sellette 5', 'y'), ('Massif 2', 'x'), ('Sellette 6', 'x')]]
print(f'{d} {tmin:5.1f} {tmax:5.1f} {hmax:3d} | {dp[0]:+.4f} {dp[1]:+.4f} {dp[2]*1e4:+6.1f}e-4 | ' + ' '.join(f'{v:+.3f}' for v in cc) + f' | {len(n[d]):3d} | ' + ' '.join(f'{rej[d][c]:6d}' for c in caps))