26 lines
1.6 KiB
Python
26 lines
1.6 KiB
Python
"""Per-instant table over a window: pose and, per sensor, a column minus its median over the window (x100), r = rejected.
|
|
usage: dump.py START END COLUMN [SENSORS] ; COLUMN corr_x|corr_y|error_value|x|y (error_value: raw x100)"""
|
|
import sys, statistics
|
|
sys.path.insert(0, 'tools/scripts')
|
|
import data
|
|
st, en, col = data.parse_time(sys.argv[1]), data.parse_time(sys.argv[2]), sys.argv[3]
|
|
S = data.load('data/JUNGFRAU')
|
|
names = sys.argv[4].split(',') if len(sys.argv) > 4 else [s for s in S if s != 'PM_G']
|
|
cam = {p['t'].replace(second=0, microsecond=0): p for p in data.load_camera('data/JUNGFRAU')}
|
|
rows = {}
|
|
for s in names:
|
|
ms = data.filter_window(S[s], st, en)
|
|
vals = [m[col] for m in ms if m[col] is not None]
|
|
med = 0 if col == 'error_value' else statistics.median(vals)
|
|
for m in ms:
|
|
t = m['t'].replace(second=0, microsecond=0)
|
|
v = m[col]
|
|
rows.setdefault(t, {})[s] = ('r' if data.rejected(m) and col != 'error_value' else ('%+.0f' % ((v - med) * 100) if v is not None else '.')) + ('*' if data.rejected(m) and col == 'error_value' else '')
|
|
camt = [p for t, p in cam.items() if st <= t <= en]
|
|
mp = {c: statistics.median([p[c] for p in camt]) for c in ('pan', 'tilt', 'rotation', 'scale')}
|
|
print('time pan tilt rot scale(x1e-3deg / 1e-6) | ' + ' '.join('%6s' % s[:6] for s in names))
|
|
for t in sorted(rows):
|
|
p = cam.get(t)
|
|
ps = ' '.join('%+4.0f' % ((p[c] - mp[c]) * (1e3 if c != 'scale' else 1e6)) for c in ('pan', 'tilt', 'rotation', 'scale')) if p else ' ' * 19
|
|
print(t.strftime('%m-%d %H:%M'), ps, '|', ' '.join('%6s' % rows[t].get(s, '-') for s in names))
|