Files
aimsight-optimizer/sessions/NORDEND_2026-08-23T0515_2026-09-04T0615_20261118T1542Z/tools/dayshare.py
T

20 lines
877 B
Python

# Per UTC day, the share of rejected measurements (error_value > error_threshold) of given sensors. Args: <station folder> <from> <to> <sensor,...>
import sys
from pathlib import Path
sys.path[:0] = [str(Path.home() / "aimsight-tools" / "scripts")]
from data import load
folder, a, b, sensors = sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4].split(",")
ms = load(folder)
for s in sensors:
days = {}
for m in ms.get(s, []):
d = m["t"].date().isoformat()
if not (a <= d < b):
continue
r = m["error_value"] is not None and m["error_threshold"] is not None and m["error_value"] > m["error_threshold"]
c = days.setdefault(d, [0, 0, 0])
c[0] += r; c[1] += 1; c[2] += m["error_value"] is None
print(s)
for d, (r, n, none) in sorted(days.items()):
print(f" {d} {r:3}/{n:3} {100*r/n:5.1f}% none={none}")