15 lines
973 B
Python
15 lines
973 B
Python
"""nights.py col h0 h1: median of col per sensor over [h0,h1) each day, minus the sensor's median of these medians (x1000)"""
|
|
import sys, os, statistics; sys.path.insert(0, os.path.dirname(__file__)); import common
|
|
from datetime import timedelta
|
|
d = common.get(); M = d["meas"]; col = sys.argv[1]; h0, h1 = float(sys.argv[2]), float(sys.argv[3])
|
|
days = [common.T("2026-09-30T00:00Z") + timedelta(days=i) for i in range(14)]
|
|
sens = sorted({s for m in M.values() for s in m})
|
|
print("sensor " + " ".join(dd.strftime("%d/%m ") for dd in days))
|
|
for s in sens:
|
|
meds = []
|
|
for dd in days:
|
|
v = [m[s][col] for t, m in M.items() if dd + timedelta(hours=h0) <= t < dd + timedelta(hours=h1) and s in m and m[s][col] is not None]
|
|
meds.append(statistics.median(v) if len(v) > 3 else None)
|
|
ref = statistics.median([x for x in meds if x is not None])
|
|
print("%-6s " % s + " ".join(("%5.0f " % ((x - ref) * 1e3)) if x is not None else " - " for x in meds))
|