44 lines
1.5 KiB
Python
44 lines
1.5 KiB
Python
"""Lecture des données de WILDSTRUBEL pour la finition (lancé depuis la racine du dépôt).
|
|||
|
|
mesures() : {(t, capteur): ligne}, pose() : {t: (pan, tilt, rot, scale)}, temperature() : {heure: °C},
|
||
|
|
etiquettes() : [(id, dict)]. Heures en datetime UTC naïf, à la minute."""
|
||
|
|
import csv, glob, json, statistics as st
|
||
|
|
from datetime import datetime
|
||
|
|
|
||
|
|
D = 'data/WILDSTRUBEL'
|
||
|
|
|
||
|
|
|
||
|
|
def _t(s):
|
||
|
|
return datetime.fromisoformat(s[:16])
|
||
|
|
|
||
|
|
|
||
|
|
def mesures(j1='20260829', j2='20261104'):
|
||
|
|
out = {}
|
||
|
|
for f in sorted(glob.glob(f'{D}/displacement/WILDSTRUBEL_advanced_*.csv')):
|
||
|
|
j = f[-12:-4]
|
||
|
|
if not (j1 <= j <= j2):
|
||
|
|
continue
|
||
|
|
for r in csv.DictReader(open(f)):
|
||
|
|
out[(_t(r['time_utc']), r['sensor_name'])] = r
|
||
|
|
return out
|
||
|
|
|
||
|
|
|
||
|
|
def pose():
|
||
|
|
out = {}
|
||
|
|
for f in sorted(glob.glob(f'{D}/camera/*.csv')):
|
||
|
|
for r in csv.DictReader(open(f)):
|
||
|
|
out[_t(r['time_utc'])] = tuple(float(r['median_' + c]) for c in ('pan', 'tilt', 'rotation', 'scale'))
|
||
|
|
return out
|
||
|
|
|
||
|
|
|
||
|
|
def temperature():
|
||
|
|
"""Médiane des composants sensor_*_deg_c par heure : la température du boîtier (comme metriques.py)."""
|
||
|
|
par = {}
|
||
|
|
for f in glob.glob(f'{D}/metrics/WILDSTRUBEL_sensor_*_deg_c_*.csv'):
|
||
|
|
for r in csv.DictReader(open(f)):
|
||
|
|
if r['metric']:
|
||
|
|
par.setdefault(_t(r['time_utc']), []).append(float(r['metric']))
|
||
|
|
return {t: st.median(v) for t, v in par.items()}
|
||
|
|
|
||
|
|
|
||
|
|
def etiquettes():
|
||
|
|
return [(f'WILDSTRUBEL#{i}', json.loads(l)) for i, l in enumerate(open('labeling/auto/WILDSTRUBEL.jsonl'), 1)]
|