35 lines
2.0 KiB
Python
35 lines
2.0 KiB
Python
"""cycle.py START END: per sensor, extreme of the 1-h rolling median of corr_x / corr_y minus the level of the 2 h before START (x1000), with time; pose axes too."""
|
|
import sys, os, statistics; sys.path.insert(0, os.path.dirname(__file__)); import common
|
|
from datetime import timedelta
|
|
d = common.get(); M = d["meas"]; P = d["pose"]; TT = d["temp"]
|
|
t0, t1 = common.T(sys.argv[1]), common.T(sys.argv[2])
|
|
BAD = {t for t, m in M.items() if any(m[r]["rej"] for r in ("CTR02", "CTR03", "CTR04") if r in m)} if os.environ.get("NOREF") else set()
|
|
for t in BAD: M.pop(t, None); P.pop(t, None)
|
|
times = sorted(t for t in M if t0 <= t <= t1)
|
|
def series(get):
|
|
ref = [v for t in M if t0 - timedelta(hours=2) <= t <= t0 for v in [get(t)] if v is not None]
|
|
if len(ref) < 3: return None
|
|
r = statistics.median(ref); out = []
|
|
for t in times:
|
|
w = [v for k in range(-2, 3) for tt in [t + timedelta(minutes=15 * k)] for v in [get(tt)] if v is not None]
|
|
if len(w) >= 3: out.append((t, statistics.median(w) - r))
|
|
return out
|
|
def ext(s):
|
|
if not s: return "-"
|
|
mx = max(s, key=lambda x: x[1]); mn = min(s, key=lambda x: x[1])
|
|
return "max %+6.0f @%s min %+6.0f @%s" % (mx[1]*1e3, mx[0].strftime("%d %H:%M"), mn[1]*1e3, mn[0].strftime("%d %H:%M"))
|
|
tv = [(t, v) for t, v in TT.items() if t0 - timedelta(hours=1) <= t <= t1]
|
|
print("temperature: start %.1f, max %.1f at %s, end %.1f" % (tv[0][1], max(v for _, v in tv), max(tv, key=lambda x: x[1])[0].strftime("%d %H:%M"), tv[-1][1]))
|
|
for a in ("pan", "tilt", "rotation", "scale"):
|
|
k = 1e2 if a == "scale" else 1
|
|
print("%-8s" % a, ext(series(lambda t, a=a: (P[t][a] * k) if t in P and P[t][a] is not None else None)), "(scale x100)" if a == "scale" else "")
|
|
sens = sorted({s for t in times for s in M[t]})
|
|
for c in ("corr_x", "corr_y"):
|
|
print("--", c)
|
|
rows = []
|
|
for s in sens:
|
|
se = series(lambda t, s=s: M[t][s][c] if t in M and s in M[t] else None)
|
|
if se: rows.append((max(abs(x[1]) for x in se), s, ext(se)))
|
|
for a, s, e in sorted(rows, reverse=True):
|
|
print(" %-6s %s" % (s, e))
|