"""L'analyse Temperature, pour la vérifier (D-016) : le panneau DAILY_GPU_TEMPERATURE_LIMIT, puis la série du GPU. Usage : python3 src/temperature/all_analyses.py [CSV ou dossiers...] (défaut : data/WEISSHORN/ et data/NORDEND/) Écrit out/_temperature.html et l'ouvre. Documentation : docs/temperature/analyses/daily_gpu_temperature_limit.md """ import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parents[1])) # src/ : paquets common, energy et temperature from common.page import AUTOSCALE_Y_JS, ROOT, open_html # noqa: E402 (bascule seule sur .venv si plotly manque) from common.stations import gaps, load_stations # noqa: E402 from plotly.subplots import make_subplots # noqa: E402 from temperature import gpu_temperature_limit as gl # noqa: E402 from temperature.final import METRIC, TITLES, analysis_panels # noqa: E402 (panneau partagé avec la figure du site) def figure(station, series): fig = make_subplots(rows=2, cols=1, shared_xaxes=True, vertical_spacing=0.08, subplot_titles=TITLES + [METRIC]) analysis_panels(fig, series) s = series[METRIC] fig.add_scatter(x=sorted(s), y=[s[t] for t in sorted(s)], name=METRIC, line=dict(width=1), row=2, col=1, legendgroup="mesures", legendgrouptitle_text="Mesures") for a, b in gaps(s): fig.add_vrect(x0=a, x1=b, fillcolor="gray", opacity=0.3, line_width=0, row=2, col=1) fig.update_yaxes(title_text="°C", row=2, col=1) fig.update_xaxes(showticklabels=True) # dates sous chaque graphique, pas seulement le dernier fig.update_yaxes(fixedrange=True) # zoom horizontal seulement : l'ordonnée est recalée par AUTOSCALE_Y_JS fig.update_layout(title=f"{station} : analysis {gl.RULE['id']}", height=700, legend=dict(groupclick="toggleitem")) return fig def main(paths): """Pour chaque station qui a la température du GPU : out/_temperature.html. -> chemins écrits.""" (ROOT / "out").mkdir(exist_ok=True) written = [] for station, series in sorted(load_stations(paths).items()): if METRIC not in series: print(f"{station} : ignorée, pas de {METRIC}") continue path = ROOT / "out" / f"{station}_temperature.html" figure(station, series).write_html( path, include_plotlyjs="cdn", post_script=AUTOSCALE_Y_JS, config={"scrollZoom": True}) print(path) written.append(path) return written if __name__ == "__main__": for p in main(sys.argv[1:] or [str(ROOT / "data" / d) for d in ("WEISSHORN", "NORDEND")]): open_html(p)