Deliver Temperature in the mockups, with its site figure and guide
Temperature joins the mockups' list of domains (D-041): a Red
notification on the support Home, and a one-line block on the client
view ("Hottest (24 h) 43 °C · limit 97.5 °C") for the stations that
measure the GPU. src/temperature/final.py writes the site figure; the
comparison page reuses its panel. Short two-layer guide in
docs/temperature/guide/.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
276c34ea38
commit
27c52bac75
9 files changed
+200
-43
No files matched your search
@@ -10,40 +10,20 @@ sys.path.insert(0, str(Path(__file__).resolve().parents[1])) # src/ : paquets c
|
||||
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 energy.final import noon # noqa: E402 (points journaliers à midi UTC, D-019)
|
||||
from temperature import day_color as dc, gpu_temperature_limit as gl # noqa: E402
|
||||
|
||||
METRIC = "sensor_GPU_deg_c"
|
||||
STYLE = {"GREEN": ("#008300", "circle"), "RED": ("#d03b3b", "x"), None: ("#8c8c8c", "circle-open")} # couleurs d'Energy
|
||||
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):
|
||||
title = f"Analysis {gl.RULE['id']}"
|
||||
fig = make_subplots(rows=2, cols=1, shared_xaxes=True, vertical_spacing=0.08, subplot_titles=[title, METRIC])
|
||||
group = dict(legendgroup=gl.RULE["id"], legendgrouptitle_text=title)
|
||||
pts = dc.run(series)["points"]
|
||||
x = [noon(p["t"].date()) for p in pts]
|
||||
fig.add_scatter(x=x, y=[p["facts"].get("max_deg_c") for p in pts], name="max of the last 24 h", mode="lines",
|
||||
line=dict(color="#52514e", width=1.5), hoverinfo="skip", row=1, col=1, **group)
|
||||
# Limite tracée comme une courbe (un point par jour) : AUTOSCALE_Y_JS la garde visible au zoom (D-013).
|
||||
fig.add_scatter(x=x, y=[gl.GPU_LIMIT_DEG_C] * len(x), name=f"limit {gl.GPU_LIMIT_DEG_C} °C", mode="lines",
|
||||
hoverinfo="skip", line=dict(color=STYLE["RED"][0], dash="dash", width=1), row=1, col=1, **group)
|
||||
for color, (c, symbol) in STYLE.items():
|
||||
sel = [p for p in pts if p["facts"]["color"] == color]
|
||||
if sel:
|
||||
fig.add_scatter(x=[noon(p["t"].date()) for p in sel], y=[p["facts"].get("max_deg_c", 0) for p in sel],
|
||||
name=color or "unknown", mode="markers", hovertemplate="%{text}<extra></extra>",
|
||||
text=[f"{p['t']:%Y-%m-%d}<br>" + "<br>".join(f"{k}={v}" for k, v in p["facts"].items())
|
||||
for p in sel],
|
||||
marker=dict(color=c, symbol=symbol, size=9, line=dict(color="white", width=1)),
|
||||
row=1, col=1, **group)
|
||||
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")
|
||||
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"))
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
"""Analyse de la couleur du jour Temperature (D-040) : DAILY_GPU_TEMPERATURE_LIMIT, en une figure pour le site (D-021).
|
||||
|
||||
Usage : python3 src/temperature/final.py [CSV ou dossiers...] (défaut : data/WEISSHORN/ et data/NORDEND/)
|
||||
Écrit out/<STATION>_temperature_daily.html (page de démo) et .json (figure Plotly pour le site, Plotly.newPlot), puis les ouvre.
|
||||
Documentation : docs/temperature/analyses/daily_gpu_temperature_limit.md ; guide docs/temperature/guide/
|
||||
"""
|
||||
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 load_stations # noqa: E402
|
||||
from plotly.subplots import make_subplots # noqa: E402
|
||||
from energy.final import noon # noqa: E402 (points journaliers à midi UTC, D-019)
|
||||
from temperature import day_color as dc, gpu_temperature_limit as gl # noqa: E402
|
||||
|
||||
METRIC = "sensor_GPU_deg_c"
|
||||
STYLE = {"GREEN": ("#008300", "circle"), "RED": ("#d03b3b", "x"), None: ("#8c8c8c", "circle-open")} # couleurs d'Energy
|
||||
TITLES = [f"Analysis {gl.RULE['id']}"]
|
||||
|
||||
|
||||
def analysis_panels(fig, series):
|
||||
"""Panneau DAILY_GPU_TEMPERATURE_LIMIT, rangée 1 : maximum des 24 h, limite, couleur du jour en marqueurs.
|
||||
Partagé par la figure du site et la page de comparaison (fiche daily_gpu_temperature_limit)."""
|
||||
group = dict(legendgroup=gl.RULE["id"], legendgrouptitle_text=TITLES[0])
|
||||
pts = dc.run(series)["points"]
|
||||
x = [noon(p["t"].date()) for p in pts]
|
||||
fig.add_scatter(x=x, y=[p["facts"].get("max_deg_c") for p in pts], name="max of the last 24 h", mode="lines",
|
||||
line=dict(color="#52514e", width=1.5), hoverinfo="skip", row=1, col=1, **group)
|
||||
# Limite tracée comme une courbe (un point par jour) : AUTOSCALE_Y_JS la garde visible au zoom (D-013).
|
||||
fig.add_scatter(x=x, y=[gl.GPU_LIMIT_DEG_C] * len(x), name=f"limit {gl.GPU_LIMIT_DEG_C} °C", mode="lines",
|
||||
hoverinfo="skip", line=dict(color=STYLE["RED"][0], dash="dash", width=1), row=1, col=1, **group)
|
||||
for color, (c, symbol) in STYLE.items():
|
||||
sel = [p for p in pts if p["facts"]["color"] == color]
|
||||
if sel:
|
||||
fig.add_scatter(x=[noon(p["t"].date()) for p in sel], y=[p["facts"].get("max_deg_c", 0) for p in sel],
|
||||
name=color or "unknown", mode="markers", hovertemplate="%{text}<extra></extra>",
|
||||
text=[f"{p['t']:%Y-%m-%d}<br>" + "<br>".join(f"{k}={v}" for k, v in p["facts"].items())
|
||||
for p in sel],
|
||||
marker=dict(color=c, symbol=symbol, size=9, line=dict(color="white", width=1)),
|
||||
row=1, col=1, **group)
|
||||
fig.update_yaxes(title_text="GPU [°C]", row=1, col=1)
|
||||
|
||||
|
||||
def daily_figure(station, series):
|
||||
"""Graphique pour le site de monitoring : le panneau DAILY_GPU_TEMPERATURE_LIMIT seul."""
|
||||
fig = make_subplots(rows=1, cols=1, subplot_titles=TITLES)
|
||||
analysis_panels(fig, series)
|
||||
fig.update_yaxes(fixedrange=True) # zoom horizontal seulement : l'ordonnée est recalée par AUTOSCALE_Y_JS
|
||||
fig.update_layout(title=f"{station}: GPU temperature", height=420, legend=dict(groupclick="toggleitem"))
|
||||
return fig
|
||||
|
||||
|
||||
def main(paths):
|
||||
"""Pour chaque station qui a la température du GPU : out/<STATION>_temperature_daily.html et .json. -> 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_daily.html"
|
||||
fig = daily_figure(station, series)
|
||||
fig.write_html(path, include_plotlyjs="cdn", post_script=AUTOSCALE_Y_JS, config={"scrollZoom": True})
|
||||
fig.write_json(path.with_suffix(".json"))
|
||||
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)
|
||||
Reference in new issue
Block a user