"""Bornes du cycle thermique de chaque jour (UTC) : heures où la pose (pan) s'écarte de son niveau de la nuit, et où la médiane des cibles de |corr_x - niveau de nuit| dépasse un seuil. Nuit = 02:00-10:00 UTC (nuit locale). usage: thermique.py""" import csv, glob, sys, statistics as st sys.path.insert(0, 'labeling/auto/etiqueteur/NIEDERHORN_2026-10-01/outils') from table import charge pan = {} for f in glob.glob('data/NIEDERHORN/camera/NIEDERHORN_camera_2026*.csv'): with open(f) as fh: for r in csv.DictReader(fh): t = r['time_utc'][:13].replace(' ', 'T') + ':00Z' pan[t] = (float(r['median_pan']), float(r['median_tilt'])) rows = charge('2026-09-30T00:00Z', '2026-11-01T23:00Z') cx = {} for r in rows: if r['pattern_type'] != 'global_ref' and r['corr_x'] != '': cx.setdefault(r['sensor_name'], {})[r['t']] = float(r['corr_x']) TH_PAN, TH_C = 0.006, 0.08 for d in range(1, 32): j = f'2026-10-{d:02d}' nuit = [pan[t][0] for t in pan if t.startswith(j) and '02' <= t[11:13] <= '10'] if not nuit: print(j, 'pas de nuit'); continue n0 = st.median(nuit) hp = [t[11:13] for t in sorted(pan) if t.startswith(j) and abs(pan[t][0] - n0) > TH_PAN] hc = [] for h in range(24): t = f'{j}T{h:02d}:00Z' devs = [] for c, s in cx.items(): nn = [s[u] for u in s if u.startswith(j) and '02' <= u[11:13] <= '10'] if len(nn) >= 3 and t in s: devs.append(abs(s[t] - st.median(nn))) if len(devs) >= 8 and st.median(devs) > TH_C: hc.append(f'{h:02d}') print(j, 'pan>', ','.join(hp), '| corr>', ','.join(hc))