55 lines
2.3 KiB
Python
55 lines
2.3 KiB
Python
"""Per day: the hourly median of each target's corr_x, corr_y minus its preceding night level (20-03 UTC), in own
|
|||
|
|
noises (noise of the window at the native step), next to the hourly camera tilt (minus its night level, mdeg) and
|
||
|
|
the housing temperature. What the corrected curves keep of the slow morning wave, without the point-to-point agitation.
|
||
|
|
Usage: python3 thermal_check.py"""
|
||
|
|
import statistics
|
||
|
|
import sys
|
||
|
|
from datetime import timedelta
|
||
|
|
|
||
|
|
sys.path.insert(0, "tools/scripts")
|
||
|
|
import data # noqa: E402
|
||
|
|
import common # noqa: E402
|
||
|
|
|
||
|
|
F = "data/WILDSTRUBEL"
|
||
|
|
W0, W1 = data.parse_time("2026-08-31T20:00Z"), data.parse_time("2026-09-09T21:45Z")
|
||
|
|
by = data.load(F)
|
||
|
|
tg = [s for s, ms in by.items() if not data.is_reference(ms)]
|
||
|
|
cam = [p for p in data.load_camera(F) if W0 <= p["t"] <= W1]
|
||
|
|
temp = dict((t, v) for t, v in data.load_temperature(F) if W0 <= t <= W1)
|
||
|
|
noise = {}
|
||
|
|
ser = {}
|
||
|
|
for s in tg:
|
||
|
|
for c in ("corr_x", "corr_y"):
|
||
|
|
pts = [(m["t"], m[c]) for m in by[s] if W0 <= m["t"] <= W1 and m[c] is not None]
|
||
|
|
ser[(s, c)] = pts
|
||
|
|
noise[(s, c)] = common.own_noise([v for t, v in pts])
|
||
|
|
|
||
|
|
|
||
|
|
def med(pts, a, b):
|
||
|
|
v = [x for t, x in pts if a <= t < b]
|
||
|
|
return statistics.median(v) if v else None
|
||
|
|
|
||
|
|
|
||
|
|
day = data.parse_time("2026-09-01T00:00Z")
|
||
|
|
while day <= data.parse_time("2026-09-09T00:00Z"):
|
||
|
|
na, nb = day - timedelta(hours=4), day + timedelta(hours=3)
|
||
|
|
tilt = [(p["t"], p["tilt"]) for p in cam if p["tilt"] is not None]
|
||
|
|
tn = med(tilt, na, nb)
|
||
|
|
print(f"\n=== {day:%d/%m} columns: hour, tilt-night (mdeg), temp, then per target cx/cy in noises")
|
||
|
|
print("hh tilt temp " + " ".join(f"{s:>11}" for s in tg))
|
||
|
|
for h in range(3, 17):
|
||
|
|
a = day + timedelta(hours=h)
|
||
|
|
b = a + timedelta(hours=1)
|
||
|
|
tm = med(tilt, a, b)
|
||
|
|
te = temp.get(a)
|
||
|
|
cells = []
|
||
|
|
for s in tg:
|
||
|
|
out = []
|
||
|
|
for c in ("corr_x", "corr_y"):
|
||
|
|
lv = med(ser[(s, c)], na, nb)
|
||
|
|
m = med(ser[(s, c)], a, b)
|
||
|
|
out.append(" ." if lv is None or m is None else f"{(m - lv) / noise[(s, c)]:+4.0f}")
|
||
|
|
cells.append("/".join(out))
|
||
|
|
print(f"{h:02d} {1000 * (tm - tn) if tm is not None else float('nan'):+6.1f} {te if te else float('nan'):5.1f} "
|
||
|
|
+ " ".join(f"{c:>11}" for c in cells))
|
||
|
|
day += timedelta(days=1)
|