31 lines
1.3 KiB
Python
31 lines
1.3 KiB
Python
"""Per sensor of a station on a range: noise (median step), MAD, range of corr_x/corr_y, and the K-noise jumps of displacement.py.
|
|
Usage: python3 series.py <station folder> <from YYYY-MM-DD> <to YYYY-MM-DD> [sensor ...] (with sensors: prints their series)
|
|
"""
|
|
import statistics
|
|
import sys
|
|
from datetime import datetime, timezone
|
|
from pathlib import Path
|
|
|
|
ROOT = Path("/home/maxime/aimsight-optimizer")
|
|
sys.path[:0] = [str(ROOT / "detectors" / "scripts"), str(ROOT / "tools" / "scripts")]
|
|
from data import load, is_reference # noqa: E402
|
|
from episodes import noise # noqa: E402
|
|
|
|
folder, a, b = sys.argv[1:4]
|
|
show = sys.argv[4:]
|
|
day = lambda d: datetime.strptime(d, "%Y-%m-%d").replace(tzinfo=timezone.utc) # noqa: E731
|
|
ms_all = load(folder)
|
|
for s, ms in sorted(ms_all.items()):
|
|
ms = [m for m in ms if day(a) <= m["t"] < day(b)]
|
|
for ax in ("corr_x", "corr_y"):
|
|
v = [m[ax] for m in ms if m[ax] is not None]
|
|
if len(v) < 3:
|
|
continue
|
|
med = statistics.median(v)
|
|
mad = statistics.median(abs(x - med) for x in v)
|
|
print(f"{s:12} ref={is_reference(ms)!s:5} {ax} n={len(v)} noise={noise(v):.4f} mad={mad:.4f} "
|
|
f"min={min(v):.3f} max={max(v):.3f}")
|
|
if s in show:
|
|
for m in ms:
|
|
print(" ", m["t"].strftime("%m-%dT%H:%M"), m["corr_x"], m["corr_y"], m["error_value"], m["error_threshold"])
|