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:
maximeandClaude Opus 5.5 committed 2026-10-13 16:11:21 +02:00
1 parent 276c34ea38
commit 27c52bac75
9 files changed
+200 -43

No files matched your search

+5 -25
View File
@@ -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"))