# Counts, per station, the gaps between instants (minute-truncated, as no_data.py) by multiple of the cadence: (1,1.5], (1.5,2.5], >2.5 steps; and the share of last instants of a day not on the cadence grid. Args: data_dir STATION... import sys from pathlib import Path sys.path[:0] = ["/home/maxime/aimsight-detectors/scripts", "/home/maxime/aimsight-tools/scripts"] from data import load from episodes import cadence for st in sys.argv[2:]: ms = load(str(Path(sys.argv[1]) / st)) ts = sorted({m["t"].replace(second=0, microsecond=0) for v in ms.values() for m in v}) step = cadence(ms) c = [0, 0, 0] for a, b in zip(ts, ts[1:]): r = (b - a) / step if 1 < r <= 1.5: c[0] += 1 elif 1.5 < r <= 2.5: c[1] += 1 elif r > 2.5: c[2] += 1 print(f"{st:<12} step={step} gaps (1,1.5]={c[0]} (1.5,2.5]={c[1]} >2.5={c[2]} instants={len(ts)}")