Files
T

20 lines
852 B
Python

# Lists the holes of a station with exactly N missing steps (rounded) and the labels touching each hole (id, family).
# Usage: python3 holes.py <station folder> <labels.jsonl> <N>
import json
import sys
from pathlib import Path
sys.path[:0] = [str(Path.home() / "aimsight-tools" / "scripts"), str(Path.home() / "aimsight-detectors" / "scripts")]
from data import iso, load # noqa: E402
from episodes import cadence # noqa: E402
ms = load(sys.argv[1])
labels = [json.loads(x) for x in open(sys.argv[2]) if x.strip()]
n = int(sys.argv[3])
step = cadence(ms)
ts = sorted({m["t"].replace(second=0, microsecond=0) for v in ms.values() for m in v})
for a, b in zip(ts, ts[1:]):
if round((b - a) / step) - 1 == n:
hit = [(x["id"], x["family"]) for x in labels if x["start"] <= iso(b) and x["end"] >= iso(a)]
print(iso(a), iso(b), hit)