49 lines
1.2 KiB
Python
49 lines
1.2 KiB
Python
# 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()
|