31 lines
2.0 KiB
Python
31 lines
2.0 KiB
Python
"""Hourly median of Sellette 4/5 corr against housing temperature and pose, whole range, labels shaded."""
|
|
import sys, json, statistics
|
|
sys.path.insert(0, 'tools/scripts')
|
|
import data
|
|
import matplotlib; matplotlib.use('Agg'); import matplotlib.pyplot as plt, matplotlib.dates as md
|
|
F='data/FLORIDA'; out=sys.argv[1]; labels=[json.loads(l) for l in open(sys.argv[2])]
|
|
t0,t1=data.parse_time('2026-10-21T18:00Z'),data.parse_time('2026-11-01T00:00Z')
|
|
M=data.load(F); cam=[p for p in data.load_camera(F) if t0<=p['t']<=t1]; tem=[x for x in data.load_temperature(F) if t0<=x[0]<=t1]
|
|
def hourly(pts):
|
|
by={}
|
|
for t,v in pts: by.setdefault(t.replace(minute=0,second=0,microsecond=0),[]).append(v)
|
|
k=sorted(by); return k,[statistics.median(by[t]) for t in k]
|
|
fig,ax=plt.subplots(5,1,figsize=(18,13),sharex=True)
|
|
for i,(s,c) in enumerate([('Sellette 5','corr_y'),('Sellette 5','corr_x'),('Sellette 4','corr_x'),('Sellette 4','corr_y')]):
|
|
a=ax[0] if c=='corr_y' else ax[1]
|
|
pts=[(m['t'],m[c]) for m in M[s] if t0<=m['t']<=t1 and m[c] is not None]
|
|
k,v=hourly(pts); med=statistics.median(v); a.plot(k,[x-med for x in v],'.-',label=f'{s} {c}')
|
|
for c in ('rotation',):
|
|
k,v=hourly([(p['t'],p[c]) for p in cam if p[c] is not None]); ax[2].plot(k,v,'.-',label=c)
|
|
for c in ('pan','tilt'):
|
|
k,v=hourly([(p['t'],p[c]) for p in cam if p[c] is not None]); ax[3].plot(k,v,'.-',label=c)
|
|
ax[4].plot([t for t,v in tem],[v for t,v in tem],'o-',ms=3)
|
|
cols={'Visibility':'yellow','Thermal displacement':'orange','No data':'grey','Displacement':'red','Obstruction':'blue'}
|
|
for l in labels:
|
|
if l['family'] not in cols: continue
|
|
for a in ax: a.axvspan(data.parse_time(l['start']),data.parse_time(l['end']),color=cols[l['family']],alpha=.25)
|
|
for a in ax: a.grid(alpha=.3); a.legend(fontsize=7)
|
|
ax[0].set_ylim(-.2,.2); ax[1].set_ylim(-.2,.2)
|
|
ax[-1].xaxis.set_major_locator(md.HourLocator(byhour=[0,12])); ax[-1].xaxis.set_major_formatter(md.DateFormatter('%d %Hh'))
|
|
fig.tight_layout(); fig.savefig(out,dpi=70); print(out)
|