26 lines
1.1 KiB
Python
26 lines
1.1 KiB
Python
"""Pose and temperature per instant, with the deviation of each axis from the median of the previous 12:00-20:00 measurements, in noises."""
|
|
import sys, statistics as st
|
|
rows = []
|
|
for line in open(sys.argv[1]):
|
|
p = line.rstrip('\n').split('\t')
|
|
if p[0].startswith('2026-'): rows.append(p)
|
|
# columns: time temp A0 CPU GPU PLL thermal BusVoltage tgt_corr_x(8) tgt_corr_y(9) pan tilt rot scale
|
|
cols = {'temp': 1, 'cx': 8, 'cy': 9, 'pan': 10, 'tilt': 11, 'rot': 12, 'scale': 13}
|
|
def f(s):
|
|
try: return float(s)
|
|
except ValueError: return None
|
|
lim = sys.argv[2] # noise computed before this instant
|
|
noise = {}
|
|
for k, i in cols.items():
|
|
s = [f(r[i]) for r in rows if r[0] < lim]
|
|
noise[k] = st.median(abs(b - a) for a, b in zip(s, s[1:]))
|
|
print('noise', {k: f"{v:.3g}" for k, v in noise.items()})
|
|
for j, r in enumerate(rows):
|
|
prev = [q for q in rows[max(0, j-6):j] if q[0][11:13] in ('12', '16', '20')]
|
|
if not prev: continue
|
|
out = []
|
|
for k, i in cols.items():
|
|
ref = st.median(f(q[i]) for q in prev)
|
|
out.append(f"{k} {(f(r[i]) - ref) / noise[k]:+5.1f}")
|
|
print(r[0][:16], r[1], ' '.join(out))
|