14 lines
811 B
Python
14 lines
811 B
Python
"""Summarise the hourly weather of a station over a range: precipitation, temperature, humidity, wind, sun, snow."""
|
|
import csv, glob, sys
|
|
folder, start, end = sys.argv[1:4]
|
|
rows = []
|
|
for f in sorted(glob.glob(f"{folder}/weather/*.csv")):
|
|
for r in csv.DictReader(open(f)):
|
|
if start <= r["time_utc"] <= end:
|
|
rows.append(r)
|
|
print("station:", rows[0]["station_name"], "distance_km:", rows[0]["distance_km"], "height_m:", rows[0]["height_m"])
|
|
print("time prec T hum wind gust sun rad snow")
|
|
for r in rows:
|
|
print(r["time_utc"], r["precipitation_mm"].rjust(4), r["temperature_c"].rjust(5), r["humidity_pct"].rjust(5),
|
|
r["wind_speed_kmh"].rjust(5), r["wind_gust_kmh"].rjust(5), r["sunshine_min"].rjust(3), r["global_radiation_wm2"].rjust(4), r["snow_depth_cm"])
|