20 lines
1.4 KiB
Python
20 lines
1.4 KiB
Python
# Lists the instants thermal_displacement.slides keeps (raw and corrected moving together), with how many sensors move on each side, over a window (3 days of history). Args: <detectors dir> <station folder> <from> <to>
|
|
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"), str(Path.cwd() / "tools" / "scripts")]
|
|
import thermal_displacement as T
|
|
from data import load, is_reference, iso
|
|
day = lambda d: datetime.strptime(d, "%Y-%m-%d").replace(tzinfo=timezone.utc)
|
|
start, end = day(sys.argv[3]), day(sys.argv[4])
|
|
ms = load(sys.argv[2])
|
|
m = {s: k for s, v in ms.items() if (k := [x for x in v if start - timedelta(days=3) <= x["t"] < end])}
|
|
targets = [v for v in m.values() if not is_reference(v)]
|
|
raw = {c: T._common([T._signs(v, c) for v in m.values()]) for c in ("x", "y")}
|
|
corr = {c: T._common([T._signs(v, c) for v in targets]) for c in ("corr_x", "corr_y")}
|
|
r, c = raw["x"] | raw["y"], corr["corr_x"] | corr["corr_y"]
|
|
print("wave corr:", bool(T._wave(m, ("corr_x", "corr_y"), "Thermal", False)), "wave raw:", bool(T._wave(m, ("x", "y"), "Camera thermal", True)))
|
|
for t in sorted(r & c):
|
|
print(iso(t), "raw:", "x" if t in raw["x"] else "-", "y" if t in raw["y"] else "-", "corr:", "x" if t in corr["corr_x"] else "-", "y" if t in corr["corr_y"] else "-")
|