You've already forked donnees_meteo
Ajout de visualisations classiques
This commit is contained in:
46
scripts/plot_diurnal_cycle.py
Normal file
46
scripts/plot_diurnal_cycle.py
Normal file
@@ -0,0 +1,46 @@
|
||||
# scripts/plot_diurnal_cycle.py
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from meteo.dataset import load_raw_csv
|
||||
from meteo.variables import VARIABLES_BY_KEY
|
||||
from meteo.analysis import compute_diurnal_cycle_statistics
|
||||
from meteo.plots import plot_diurnal_cycle
|
||||
|
||||
|
||||
CSV_PATH = Path("data/weather_minutely.csv")
|
||||
OUTPUT_PATH = Path("figures/diurnal_cycle/diurnal_cycle.png")
|
||||
|
||||
VARIABLE_KEYS = ["temperature", "humidity", "pressure", "wind_speed"]
|
||||
|
||||
|
||||
def main() -> None:
|
||||
if not CSV_PATH.exists():
|
||||
print(f"⚠ Fichier introuvable : {CSV_PATH}")
|
||||
return
|
||||
|
||||
df = load_raw_csv(CSV_PATH)
|
||||
print(f"Dataset minuté chargé : {CSV_PATH}")
|
||||
print(f" Lignes : {len(df)}")
|
||||
print(f" Colonnes : {list(df.columns)}")
|
||||
print()
|
||||
|
||||
variables = [VARIABLES_BY_KEY[key] for key in VARIABLE_KEYS]
|
||||
stats = compute_diurnal_cycle_statistics(
|
||||
df=df,
|
||||
variables=variables,
|
||||
quantiles=(0.25, 0.75),
|
||||
)
|
||||
|
||||
output_path = plot_diurnal_cycle(
|
||||
stats=stats,
|
||||
variables=variables,
|
||||
output_path=OUTPUT_PATH,
|
||||
)
|
||||
|
||||
print(f"✔ Cycle diurne sauvegardé : {output_path}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
41
scripts/plot_rain_hyetograph.py
Normal file
41
scripts/plot_rain_hyetograph.py
Normal file
@@ -0,0 +1,41 @@
|
||||
# scripts/plot_rain_hyetograph.py
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from meteo.dataset import load_raw_csv
|
||||
from meteo.analysis import compute_daily_rainfall_totals
|
||||
from meteo.plots import plot_daily_rainfall_hyetograph
|
||||
|
||||
|
||||
CSV_PATH = Path("data/weather_minutely.csv")
|
||||
OUTPUT_PATH = Path("figures/rainfall_hyetograph/daily_rainfall_hyetograph.png")
|
||||
|
||||
|
||||
def main() -> None:
|
||||
if not CSV_PATH.exists():
|
||||
print(f"⚠ Fichier introuvable : {CSV_PATH}")
|
||||
return
|
||||
|
||||
df = load_raw_csv(CSV_PATH)
|
||||
print(f"Dataset minuté chargé : {CSV_PATH}")
|
||||
print(f" Lignes : {len(df)}")
|
||||
print(f" Colonnes : {list(df.columns)}")
|
||||
print()
|
||||
|
||||
daily_totals = compute_daily_rainfall_totals(df=df, rate_column="rain_rate")
|
||||
|
||||
if daily_totals.empty:
|
||||
print("⚠ Aucune donnée de pluie cumule à afficher.")
|
||||
return
|
||||
|
||||
output_path = plot_daily_rainfall_hyetograph(
|
||||
daily_rain=daily_totals,
|
||||
output_path=OUTPUT_PATH,
|
||||
)
|
||||
|
||||
print(f"✔ Hyétographe quotidien exporté : {output_path}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
48
scripts/plot_wind_rose.py
Normal file
48
scripts/plot_wind_rose.py
Normal file
@@ -0,0 +1,48 @@
|
||||
# scripts/plot_wind_rose.py
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from meteo.dataset import load_raw_csv
|
||||
from meteo.analysis import compute_wind_rose_distribution
|
||||
from meteo.plots import plot_wind_rose
|
||||
|
||||
|
||||
CSV_PATH = Path("data/weather_minutely.csv")
|
||||
OUTPUT_PATH = Path("figures/wind_rose/wind_rose.png")
|
||||
|
||||
|
||||
def main() -> None:
|
||||
if not CSV_PATH.exists():
|
||||
print(f"⚠ Fichier introuvable : {CSV_PATH}")
|
||||
return
|
||||
|
||||
df = load_raw_csv(CSV_PATH)
|
||||
print(f"Dataset minuté chargé : {CSV_PATH}")
|
||||
print(f" Lignes : {len(df)}")
|
||||
print(f" Colonnes : {list(df.columns)}")
|
||||
print()
|
||||
|
||||
frequencies, labels, sector_size = compute_wind_rose_distribution(
|
||||
df=df,
|
||||
direction_sector_size=30,
|
||||
speed_bins=(0, 5, 15, 30, 50, float("inf")),
|
||||
)
|
||||
|
||||
if frequencies.empty:
|
||||
print("⚠ Pas assez de données pour construire une rose des vents.")
|
||||
return
|
||||
|
||||
output_path = plot_wind_rose(
|
||||
frequencies=frequencies,
|
||||
speed_bin_labels=labels,
|
||||
output_path=OUTPUT_PATH,
|
||||
sector_size_deg=sector_size,
|
||||
cmap="plasma",
|
||||
)
|
||||
|
||||
print(f"✔ Rose des vents exportée : {output_path}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
55
scripts/plot_wind_rose_rain.py
Normal file
55
scripts/plot_wind_rose_rain.py
Normal file
@@ -0,0 +1,55 @@
|
||||
# scripts/plot_wind_rose_rain.py
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from meteo.dataset import load_raw_csv
|
||||
from meteo.analysis import compute_wind_rose_distribution
|
||||
from meteo.plots import plot_wind_rose
|
||||
|
||||
|
||||
CSV_PATH = Path("data/weather_minutely.csv")
|
||||
OUTPUT_PATH = Path("figures/wind_rose/wind_rose_during_rain.png")
|
||||
RAIN_THRESHOLD = 0.2 # mm/h, pour considérer qu'il pleut réellement
|
||||
|
||||
|
||||
def main() -> None:
|
||||
if not CSV_PATH.exists():
|
||||
print(f"⚠ Fichier introuvable : {CSV_PATH}")
|
||||
return
|
||||
|
||||
df = load_raw_csv(CSV_PATH)
|
||||
print(f"Dataset minuté chargé : {CSV_PATH}")
|
||||
print(f" Lignes : {len(df)}")
|
||||
print(f" Colonnes : {list(df.columns)}")
|
||||
print()
|
||||
|
||||
rainy_df = df[df["rain_rate"].fillna(0.0) >= RAIN_THRESHOLD]
|
||||
print(f"Lignes avec pluie ≥ {RAIN_THRESHOLD} mm/h : {len(rainy_df)}")
|
||||
if rainy_df.empty:
|
||||
print("⚠ Aucun événement pluvieux ne dépasse ce seuil, abandon.")
|
||||
return
|
||||
|
||||
frequencies, labels, sector_size = compute_wind_rose_distribution(
|
||||
df=rainy_df,
|
||||
direction_sector_size=30,
|
||||
speed_bins=(0, 5, 15, 30, 50, float("inf")),
|
||||
)
|
||||
|
||||
if frequencies.empty:
|
||||
print("⚠ Pas assez de données pour construire une rose des vents pendant la pluie.")
|
||||
return
|
||||
|
||||
output_path = plot_wind_rose(
|
||||
frequencies=frequencies,
|
||||
speed_bin_labels=labels,
|
||||
output_path=OUTPUT_PATH,
|
||||
sector_size_deg=sector_size,
|
||||
cmap="plasma",
|
||||
)
|
||||
|
||||
print(f"✔ Rose des vents pendant la pluie exportée : {output_path}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user