30 lines
1.3 KiB
Python
30 lines
1.3 KiB
Python
"""Grappes d'instants où une référence, Sellette 4 ou Sellette 5 est rejetée, ou sans pose ; écart max 1 h. Bornes : pas d'avant, pas d'après."""
|
|||
|
|
import csv, glob, sys
|
||
|
|
from collections import defaultdict
|
||
|
|
from datetime import datetime, timedelta
|
||
|
|
D='data/FLORIDA'; P=lambda s: datetime.fromisoformat(s[:16].replace(' ','T'))
|
||
|
|
gap=timedelta(minutes=int(sys.argv[1]) if len(sys.argv)>1 else 60)
|
||
|
|
inst=set(); rej=defaultdict(set)
|
||
|
|
for f in sorted(glob.glob(f'{D}/displacement/*.csv')):
|
||
|
|
for r in csv.DictReader(open(f)):
|
||
|
|
t=P(r['time_utc'])
|
||
|
|
if t.month!=10: continue
|
||
|
|
inst.add(t)
|
||
|
|
if float(r['error_value'])>float(r['error_threshold']): rej[t].add(r['sensor_name'])
|
||
|
|
pose=set()
|
||
|
|
for f in sorted(glob.glob(f'{D}/camera/*.csv')):
|
||
|
|
for r in csv.DictReader(open(f)): pose.add(P(r['time_utc']))
|
||
|
|
T=sorted(inst)
|
||
|
|
flag=[t for t in T if t not in pose or rej[t]&{'p1_r','r1_r','Sellette 4','Sellette 5'}]
|
||
|
|
cl=[]
|
||
|
|
for t in flag:
|
||
|
|
if cl and t-cl[-1][-1]<=gap: cl[-1].append(t)
|
||
|
|
else: cl.append([t])
|
||
|
|
for c in cl:
|
||
|
|
i=T.index(c[0]); j=T.index(c[-1])
|
||
|
|
a=T[i-1] if i else c[0]; b=T[j+1] if j+1<len(T) else c[-1]
|
||
|
|
who=defaultdict(int)
|
||
|
|
for t in c:
|
||
|
|
for s in rej[t]: who[s]+=1
|
||
|
|
np_=sum(1 for t in T[i:j+1] if t not in pose)
|
||
|
|
print(f"{a:%m-%d %H:%M} -> {b:%m-%d %H:%M} ({len(c)} pas marqués, sans pose {np_}) ", dict(who))
|