49 lines
2.7 KiB
Python
49 lines
2.7 KiB
Python
"""Une ligne par étiquette Thermal displacement : pose brute (tilt, pan, rotation, scale) et température du
|
|||
|
|
boîtier de 03:00 à 19:00, l'étiquette grisée, le repos en pointillé (nuit 00-03 ou après-midi 13:30-fin) ;
|
||
|
|
puis corr_x et corr_y de chaque cible (mesures acceptées), moins son repos, décalées de 0,3 l'une de l'autre.
|
||
|
|
Usage : plot_jours.py ID1,ID2,... SORTIE.png"""
|
||
|
|
import sys, statistics as st
|
||
|
|
from datetime import datetime, timedelta
|
||
|
|
sys.path.insert(0, sys.path[0])
|
||
|
|
import matplotlib; matplotlib.use('Agg')
|
||
|
|
import matplotlib.pyplot as plt, matplotlib.dates as md
|
||
|
|
from donnees import mesures, pose, temperature, etiquettes
|
||
|
|
|
||
|
|
ids = sys.argv[1].split(',')
|
||
|
|
CIB = ('PA2_2', 'PA3_2', 'PA_9', 'PB1_2', 'PB2_2', 'PB4', 'PB_5')
|
||
|
|
M, P, T = mesures(), pose(), temperature()
|
||
|
|
E = dict(etiquettes())
|
||
|
|
fig, ax = plt.subplots(len(ids), 7, figsize=(30, 2.6 * len(ids)), squeeze=False)
|
||
|
|
for row, eid in enumerate(ids):
|
||
|
|
e = E[eid]
|
||
|
|
a, b = datetime.fromisoformat(e['debut'][:16]), datetime.fromisoformat(e['fin'][:16])
|
||
|
|
j = a.replace(hour=0, minute=0)
|
||
|
|
w0, w1 = j + timedelta(hours=3), j + timedelta(hours=19)
|
||
|
|
nuit = [t for t in P if j <= t < j + timedelta(hours=3)]
|
||
|
|
rep = nuit if len(nuit) >= 6 else [t for t in P if j + timedelta(hours=13, minutes=30) <= t <= w1]
|
||
|
|
ts = sorted(t for t in P if w0 <= t <= w1)
|
||
|
|
for k, nom in enumerate(('pan', 'tilt', 'rotation', 'scale')):
|
||
|
|
g = ax[row][k]
|
||
|
|
g.plot(ts, [P[t][k] for t in ts], '.-', ms=3, lw=.6)
|
||
|
|
if rep:
|
||
|
|
g.axhline(st.median(P[t][k] for t in rep), ls=':', c='k')
|
||
|
|
g.axvspan(a, b, color='0.85')
|
||
|
|
g.set_title(f'{eid} {a:%d/%m} {nom}', fontsize=8)
|
||
|
|
g = ax[row][4]
|
||
|
|
th = sorted(t for t in T if w0 <= t <= w1)
|
||
|
|
g.plot(th, [T[t] for t in th], 'r.-'); g.axvspan(a, b, color='0.85'); g.set_title('temp. boîtier', fontsize=8)
|
||
|
|
for k, col in enumerate(('corr_x', 'corr_y')):
|
||
|
|
g = ax[row][5 + k]
|
||
|
|
for n, c in enumerate(CIB):
|
||
|
|
def v(t):
|
||
|
|
r = M.get((t, c))
|
||
|
|
return float(r[col]) if r and r[col] and float(r['error_value']) <= float(r['error_threshold']) else None
|
||
|
|
tt = sorted(t for (t, s) in M if s == c and w0 <= t <= w1 and v(t) is not None)
|
||
|
|
rr = [v(t) for t in (rep if rep else tt) if v(t) is not None]
|
||
|
|
m = st.median(rr) if rr else 0
|
||
|
|
g.plot(tt, [v(t) - m + .3 * n for t in tt], '.-', ms=2, lw=.5, label=c)
|
||
|
|
g.axhline(.3 * n, c='0.6', lw=.4)
|
||
|
|
g.set_ylim(-.3, .3 * len(CIB)); g.axvspan(a, b, color='0.9'); g.set_title(col + ' (bas : PA2_2 ... haut : PB_5)', fontsize=8)
|
||
|
|
for g in ax[row]:
|
||
|
|
g.set_xlim(w0, w1); g.xaxis.set_major_formatter(md.DateFormatter('%H')); g.tick_params(labelsize=6)
|
||
|
|
fig.tight_layout(); fig.savefig(sys.argv[2], dpi=55); print(sys.argv[2])
|