29 lines
1.6 KiB
Python
29 lines
1.6 KiB
Python
"""Hourly median of corr_x_mm, corr_y_mm per target (minus its median over the window) against the housing temperature
|
|
and the pose scale. usage: slowfig.py FOLDER START END OUT.png [SENSORS]"""
|
|
import sys, statistics as st
|
|
from collections import defaultdict
|
|
sys.path.insert(0, "tools/scripts")
|
|
import data
|
|
import matplotlib; matplotlib.use("Agg"); import matplotlib.pyplot as plt
|
|
folder, start, end, out = sys.argv[1:5]
|
|
S, E = data.parse_time(start), data.parse_time(end)
|
|
D = data.load(folder)
|
|
sens = sys.argv[5].split(",") if len(sys.argv) > 5 else [s for s in D if not data.is_reference(D[s])]
|
|
fig, ax = plt.subplots(4, 1, figsize=(14, 12), sharex=True)
|
|
for s in sens:
|
|
for k, col in enumerate(("corr_x_mm", "corr_y_mm")):
|
|
h = defaultdict(list)
|
|
for m in D[s]:
|
|
if S <= m["t"] <= E and m[col] is not None:
|
|
h[m["t"].replace(minute=0, second=0, microsecond=0)].append(m[col])
|
|
ts = sorted(h); v = [st.median(h[t]) for t in ts]; md = st.median(v)
|
|
ax[k].plot(ts, [x - md for x in v], label=s, lw=1)
|
|
for k, c in enumerate(("corr_x_mm hourly median - level", "corr_y_mm hourly median - level")):
|
|
ax[k].set_ylabel(c); ax[k].grid(alpha=.3)
|
|
ax[0].legend(ncol=6, fontsize=7)
|
|
T = [(t, v) for t, v in data.load_temperature(folder) if S <= t <= E]
|
|
ax[2].plot([t for t, _ in T], [v for _, v in T], "k"); ax[2].set_ylabel("housing temperature"); ax[2].grid(alpha=.3)
|
|
C = [p for p in data.load_camera(folder) if S <= p["t"] <= E]
|
|
ax[3].plot([p["t"] for p in C], [p.get("scale") for p in C], lw=.6); ax[3].set_ylabel("cam scale"); ax[3].grid(alpha=.3)
|
|
fig.tight_layout(); fig.savefig(out, dpi=80); print(out)
|