# scripts/plot_hexbin_explorations.py
from __future__ import annotations

from pathlib import Path
import sys

PROJECT_ROOT = Path(__file__).resolve().parents[3]
if str(PROJECT_ROOT) not in sys.path:
    sys.path.insert(0, str(PROJECT_ROOT))

from meteo.dataset import load_raw_csv
from meteo.plots import generate_hexbin_scenarios
from meteo.correlation_presets import DEFAULT_HEXBIN_SCENARIOS


CSV_PATH = Path("data/weather_minutely.csv")
DOC_DIR = Path(__file__).resolve().parent.parent
OUTPUT_DIR = DOC_DIR / "figures" / "hexbin_explorations"


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()

    results = generate_hexbin_scenarios(
        df=df,
        scenarios=DEFAULT_HEXBIN_SCENARIOS,
        base_output_dir=OUTPUT_DIR,
        cmap="magma",
    )

    for result in results:
        scenario = result.scenario
        print(f"→ Hexbin {result.var_y.key} vs {result.var_x.key} (couleur = {result.var_color.key})")
        print(f"   {scenario.description}")
        print(f"   Points valides : {result.point_count}")
        print(f"   ✔ Graphique enregistré : {result.output_path}")
        print()

    print("✔ Tous les graphiques hexbin ont été générés.")


if __name__ == "__main__":
    main()
