Files
aimsight-labeling/auto/analyses/long-labels/NIEDERHORN/scripts/daynight.py
T

22 lines
1.3 KiB
Python
Raw Normal View History

"""Per sensor and column, over a window: accepted measurements by hour of day, median deviation from the night
level (median of 20-03 UTC of the whole window), in own noises; and count of accepted points beyond K noises
from the night level. Usage: daynight.py START END SENSORS [K]"""
import sys, statistics
sys.path.insert(0, "tools/scripts")
import data, common
start, end = data.parse_time(sys.argv[1]), data.parse_time(sys.argv[2])
K = float(sys.argv[4]) if len(sys.argv) > 4 else 5
by = data.load("data/NIEDERHORN")
for s in sys.argv[3].split(","):
ms = [m for m in data.filter_window(by[s], start, end)]
for col in ("corr_x", "corr_y"):
v = [(m["t"], m[col]) for m in ms if m[col] is not None]
if len(v) < 10: continue
noise = common.own_noise([x for _, x in v])
night = [x for t, x in v if t.hour >= 20 or t.hour <= 3]
lvl = statistics.median(night) if night else statistics.median([x for _, x in v])
hours = {}
for t, x in v: hours.setdefault(t.hour, []).append((x - lvl) / noise)
prof = " ".join(f"{h:02d}:{statistics.median(hours[h]):+5.1f}({len(hours[h])})" for h in sorted(hours))
beyond = sum(1 for _, x in v if abs(x - lvl) / noise > K)
print(f"{s:20s} {col} n={len(v)} noise={noise:.4f} beyond{K:g}={beyond}\n {prof}")