45 lines
2.7 KiB
Python
45 lines
2.7 KiB
Python
"""Per-day figure: corr_x, corr_y of targets (accepted), error_value of all, pose, temperature; existing labels shaded."""
|
|
import sys, json, os
|
|
from datetime import datetime, timedelta, timezone
|
|
sys.path.insert(0, 'tools/scripts')
|
|
import data
|
|
import matplotlib; matplotlib.use('Agg')
|
|
import matplotlib.pyplot as plt
|
|
F = 'data/FLORIDA'; D = sys.argv[1]; out = sys.argv[2]
|
|
labels = [json.loads(l) for l in open(sys.argv[3])]
|
|
M = data.load(F); cam = data.load_camera(F); tem = data.load_temperature(F)
|
|
t0 = data.parse_time(sys.argv[4]); t1 = data.parse_time(sys.argv[5])
|
|
tg = ['Sellette 4', 'Sellette 5', 'Sellette 6', 'Massif 2', 'Pont Ernen', 'Sellette 3']
|
|
col = dict(zip(tg + ['p1_r', 'r1_r'], ['C0','C1','C2','C3','C4','C5','k','C6']))
|
|
fig, ax = plt.subplots(6, 1, figsize=(14, 16), sharex=True)
|
|
for s in tg:
|
|
ms = [m for m in M[s] if t0 <= m['t'] <= t1]
|
|
for i, c in enumerate(['corr_x', 'corr_y']):
|
|
v = [m[c] for m in ms if m[c] is not None]
|
|
if not v: continue
|
|
med = sorted(v)[len(v)//2]
|
|
ax[i].plot([m['t'] for m in ms], [m[c] - med if m[c] is not None else None for m in ms], '.-', ms=3, lw=.7, color=col[s], label=s)
|
|
for s in tg + ['p1_r', 'r1_r']:
|
|
ms = [m for m in M[s] if t0 <= m['t'] <= t1]
|
|
ax[2].plot([m['t'] for m in ms], [m['error_value'] for m in ms], '.-', ms=2, lw=.6, color=col[s], label=s)
|
|
ax[2].axhline(.7, color='r', ls=':')
|
|
cs = [p for p in cam if t0 <= p['t'] <= t1]
|
|
for c, a in [('pan', 3), ('tilt', 3), ('rotation', 4), ('scale', 4)]:
|
|
v = [p[c] for p in cs]
|
|
if c == 'scale': v = [(x - 1) * 50 if x is not None else None for x in v]
|
|
ax[a].plot([p['t'] for p in cs], v, '.-', ms=2, lw=.6, label=c if c != 'scale' else '(scale-1)*50')
|
|
ts = [(t, v) for t, v in tem if t0 <= t <= t1]
|
|
ax[5].plot([t for t, v in ts], [v for t, v in ts], 'o-')
|
|
for a, n in zip(ax, ['corr_x - median', 'corr_y - median', 'error_value', 'pan, tilt', 'rot, scale', 'housing T']):
|
|
a.set_ylabel(n); a.grid(alpha=.3); a.legend(fontsize=6, ncol=4)
|
|
ax[0].set_ylim(-.4, .4); ax[1].set_ylim(-.3, .3)
|
|
cols = {'Visibility':'yellow','Thermal displacement':'orange','No data':'grey','Displacement':'red','Target issue':'none','Obstruction':'blue'}
|
|
for l in labels:
|
|
a_, b_ = data.parse_time(l['start']), data.parse_time(l['end'])
|
|
if b_ < t0 or a_ > t1 or l['family'] == 'Target issue': continue
|
|
for a in ax: a.axvspan(max(a_, t0), min(b_, t1), color=cols[l['family']], alpha=.2)
|
|
ax[0].text(max(a_, t0), .35, l.get('id', l['family'][:4]), fontsize=7)
|
|
import matplotlib.dates as md
|
|
ax[-1].xaxis.set_major_locator(md.HourLocator(interval=2)); ax[-1].xaxis.set_major_formatter(md.DateFormatter('%d %Hh'))
|
|
fig.tight_layout(); fig.savefig(out, dpi=80); print(out)
|