Files

29 lines
1.5 KiB
Python
Raw Normal View History

"""Print the camera-slide instants of thermal_displacement.slides per day, and the runs they make with several merge gaps.
Usage: python3 slides.py <detectors folder> <station folder> <from YYYY-MM-DD> <to YYYY-MM-DD>
"""
import sys
from datetime import datetime, timedelta, timezone
from pathlib import Path
det = Path(sys.argv[1]).resolve()
sys.path[:0] = [str(det / "scripts"), str(det.parents[0] / "aimsight-tools" / "scripts")]
import thermal_displacement as td # noqa: E402
from episodes import runs # noqa: E402
from data import load, is_reference # noqa: E402
day = lambda d: datetime.strptime(d, "%Y-%m-%d").replace(tzinfo=timezone.utc) # noqa: E731
a, b = day(sys.argv[3]) - timedelta(days=3), day(sys.argv[4])
ms = {s: k for s, v in load(sys.argv[2]).items() if (k := [m for m in v if a <= m["t"] < b])}
print("wave corr:", bool(td._wave(ms, ("corr_x", "corr_y"), "Thermal", False)),
"wave raw:", bool(td._wave(ms, ("x", "y"), "Camera thermal", True)))
targets = [v for v in ms.values() if not is_reference(v)]
both = sorted(set().union(*(td._common([td._signs(v, c) for v in ms.values()]) & td._common(
[td._signs(v, "corr_" + c) for v in targets]) for c in ("x", "y"))))
per = {}
for t in both:
per.setdefault(t.date(), []).append(t.strftime("%H:%M"))
for d, ts in sorted(per.items()):
print(d, len(ts), ts[0], "->", ts[-1])
for h in (1, 2, 3, 6, 12, 24):
rs = runs(both, timedelta(hours=h))
print(f"gap {h} h: {len(rs)} runs:", ", ".join(f"{r[0]:%m-%d %H:%M}→{r[-1]:%m-%d %H:%M}" for r in rs if len(rs) < 40))