19 lines
930 B
Python
19 lines
930 B
Python
# Médiane horaire d'une colonne pour quelques capteurs, sur plusieurs jours (STATION COL CAPTEUR[,CAPTEUR] J0 J1 [H0 H1]) : le même motif revient-il chaque jour ?
|
|
import statistics, sys
|
|
from datetime import datetime, timezone
|
|
import os
|
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) # outils.py, à côté
|
|
from outils import station
|
|
nom, col, caps, j0, j1 = sys.argv[1:6]
|
|
h0, h1 = (int(x) for x in sys.argv[6:8]) if len(sys.argv) > 7 else (0, 24)
|
|
m, _ = station(nom)
|
|
for s in caps.split(","):
|
|
par = {}
|
|
for x in m[s]:
|
|
j = x["t"].strftime("%m-%d")
|
|
if j0 <= j <= j1 and h0 <= x["t"].hour < h1 and x[col] is not None:
|
|
par.setdefault(j, {}).setdefault(x["t"].hour, []).append(x[col])
|
|
print(s, col, "heures", h0, "à", h1 - 1)
|
|
for j in sorted(par):
|
|
print(" ", j, " ".join(f"{statistics.median(par[j][h]):+.3f}" if h in par[j] else " - " for h in range(h0, h1)))
|