You've already forked donnees_meteo
Exportation des CSV pour chaque graphique
This commit is contained in:
@@ -10,7 +10,7 @@ import matplotlib.pyplot as plt
|
||||
|
||||
from meteo.dataset import load_raw_csv
|
||||
from meteo.analysis import compute_daily_rainfall_totals
|
||||
from meteo.plots import plot_calendar_heatmap, plot_weekday_profiles
|
||||
from meteo.plots import export_plot_dataset, plot_calendar_heatmap, plot_weekday_profiles
|
||||
from meteo.variables import VARIABLES_BY_KEY
|
||||
|
||||
|
||||
@@ -56,6 +56,9 @@ def plot_combined_calendar(
|
||||
if not matrices:
|
||||
return
|
||||
|
||||
combined_dataset = pd.concat(matrices, axis=1)
|
||||
export_plot_dataset(combined_dataset, output_path)
|
||||
|
||||
n = len(matrices)
|
||||
fig, axes = plt.subplots(n, 1, figsize=(14, 4 * n), sharex=True)
|
||||
if n == 1:
|
||||
|
||||
@@ -8,6 +8,7 @@ import matplotlib.pyplot as plt
|
||||
import pandas as pd
|
||||
|
||||
from meteo.dataset import load_raw_csv
|
||||
from meteo.plots import export_plot_dataset
|
||||
|
||||
|
||||
CSV_PATH = Path("data/weather_minutely.csv")
|
||||
@@ -38,8 +39,13 @@ def main() -> None:
|
||||
print("⚠ Aucun point dans l'intervalle choisi.")
|
||||
return
|
||||
|
||||
# Moyenne horaire pour lisser un peu la courbe
|
||||
df_hourly = df_slice.resample("1H").mean()
|
||||
# Moyenne horaire pour lisser un peu la courbe (colonnes numériques uniquement)
|
||||
numeric_slice = df_slice.select_dtypes(include="number")
|
||||
if numeric_slice.empty:
|
||||
print("⚠ Aucune colonne numérique disponible pour l'agrégation.")
|
||||
return
|
||||
|
||||
df_hourly = numeric_slice.resample("1h").mean()
|
||||
|
||||
print(f"Intervalle tracé : {df_hourly.index[0]} → {df_hourly.index[-1]}")
|
||||
print(f"Nombre de points (moyenne horaire) : {len(df_hourly)}")
|
||||
@@ -47,6 +53,10 @@ def main() -> None:
|
||||
OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
|
||||
output_path = OUTPUT_DIR / "temperature_last_7_days.png"
|
||||
|
||||
dataset_path = export_plot_dataset(df_hourly, output_path)
|
||||
if dataset_path is not None:
|
||||
print(f"✔ Données exportées : {dataset_path}")
|
||||
|
||||
plt.figure()
|
||||
plt.plot(df_hourly.index, df_hourly["temperature"])
|
||||
plt.xlabel("Temps (UTC)")
|
||||
|
||||
115
scripts/run_all_plots.py
Normal file
115
scripts/run_all_plots.py
Normal file
@@ -0,0 +1,115 @@
|
||||
# scripts/run_all_plots.py
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import subprocess
|
||||
import sys
|
||||
from typing import Iterable
|
||||
|
||||
|
||||
PLOT_MODULES: tuple[str, ...] = (
|
||||
"scripts.plot_temperature",
|
||||
"scripts.plot_calendar_overview",
|
||||
"scripts.plot_all_pairwise_scatter",
|
||||
"scripts.plot_correlation_heatmap",
|
||||
"scripts.plot_diurnal_cycle",
|
||||
"scripts.plot_hexbin_explorations",
|
||||
"scripts.plot_illuminance_focus",
|
||||
"scripts.plot_lagged_correlations",
|
||||
"scripts.plot_monthly_patterns",
|
||||
"scripts.plot_rain_event_composites",
|
||||
"scripts.plot_rain_hyetograph",
|
||||
"scripts.plot_rolling_correlation_heatmap",
|
||||
"scripts.plot_seasonal_overview",
|
||||
"scripts.plot_sun_elevation_relationships",
|
||||
"scripts.plot_wind_conditionals",
|
||||
"scripts.plot_wind_rose",
|
||||
"scripts.plot_wind_rose_rain",
|
||||
)
|
||||
|
||||
|
||||
def _normalize_module(name: str) -> str:
|
||||
name = name.strip()
|
||||
if not name:
|
||||
raise ValueError("Nom de module vide.")
|
||||
return name if name.startswith("scripts.") else f"scripts.{name}"
|
||||
|
||||
|
||||
def iter_modules(selected: Iterable[str] | None) -> list[str]:
|
||||
if not selected:
|
||||
return list(PLOT_MODULES)
|
||||
|
||||
normalized = [_normalize_module(name) for name in selected]
|
||||
modules: list[str] = []
|
||||
missing: list[str] = []
|
||||
for module in normalized:
|
||||
if module in PLOT_MODULES:
|
||||
modules.append(module)
|
||||
else:
|
||||
missing.append(module)
|
||||
|
||||
if missing:
|
||||
available = "\n - ".join(("",) + PLOT_MODULES)
|
||||
missing_list = "\n - ".join(("",) + tuple(missing))
|
||||
raise SystemExit(
|
||||
"\n".join(
|
||||
[
|
||||
"Les modules suivants ne sont pas reconnus :",
|
||||
missing_list,
|
||||
"",
|
||||
"Modules disponibles :",
|
||||
available,
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
return modules
|
||||
|
||||
|
||||
def run_module(module: str) -> bool:
|
||||
cmd = [sys.executable, "-m", module]
|
||||
print(f"\n=== {module} ===")
|
||||
try:
|
||||
result = subprocess.run(cmd, check=False)
|
||||
except FileNotFoundError as exc: # pragma: no cover
|
||||
print(f"⚠ Impossible de lancer {module} : {exc}")
|
||||
return False
|
||||
|
||||
if result.returncode == 0:
|
||||
print(f"✔ {module} terminé avec succès.")
|
||||
return True
|
||||
|
||||
print(f"✘ {module} a échoué (code {result.returncode}).")
|
||||
return False
|
||||
|
||||
|
||||
def main(argv: list[str] | None = None) -> int:
|
||||
parser = argparse.ArgumentParser(description="Lance tous les scripts de tracé météorologiques.")
|
||||
parser.add_argument(
|
||||
"--only",
|
||||
nargs="*",
|
||||
help="Limiter l'exécution à certains modules (ex: plot_temperature).",
|
||||
)
|
||||
args = parser.parse_args(argv)
|
||||
|
||||
modules = iter_modules(args.only)
|
||||
print(f"Exécution de {len(modules)} script(s) de tracé…")
|
||||
|
||||
success_count = 0
|
||||
for module in modules:
|
||||
if run_module(module):
|
||||
success_count += 1
|
||||
|
||||
print()
|
||||
print(f"Scripts réussis : {success_count}/{len(modules)}")
|
||||
failed = len(modules) - success_count
|
||||
if failed:
|
||||
print(f"⚠ {failed} script(s) ont échoué. Consultez les messages ci-dessus.")
|
||||
return 1
|
||||
|
||||
print("✔ Tous les scripts ont été exécutés avec succès.")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__": # pragma: no cover
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user