Add the day color matrix, the energy diagnostic manual and the site figure

D-020: the delivered energy diagnostic keeps analyses 03 and 04 only,
combined by the state x trend matrix of cas-d-usage-03-04.drawio into
one color per day (green / orange / red, grey when unknown), coded in
src/day_color.py (standard library). docs/guide/diagnostic-energetique.md
explains it: part 1 for the client, part 2 for support.

D-021: energy_plot.daily_figure builds the figure for the monitoring
site (panel 03 above panel 04, shared time axis), written by
analyse_01.py as out/<STATION>_daily.html and .json. battery_state no
longer imports energy_check, so analyses 03 and 04 ship on their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
maximeandClaude Opus 5.5 committed 2026-10-12 16:23:21 +02:00
1 parent 129d4ff59b
commit fc74fec10f
9 files changed
+467 -8

No files matched your search

+21 -1
View File
@@ -120,7 +120,7 @@ def daily_trend_panel(fig, result, row):
sel = [p for p in pts if p["facts"]["trend"] == trend and p["value"] is not None]
if not sel:
continue
hover = [f"{p['t']:%Y-%m-%d} : {label} (décidé par {p['facts']['decided_by']})<br>"
hover = [f"{p['t']:%Y-%m-%d}: {label} (décidé par {p['facts']['decided_by']})<br>"
f"{p['facts']['state_prev']} → {p['facts']['state']}<br>"
+ "<br>".join(f"{k}={v}" for k, v in p["facts"].items() if k.startswith("delta")) for p in sel]
fig.add_bar(x=[noon(p["t"].date()) for p in sel], y=[p["value"] for p in sel], name=label,
@@ -129,6 +129,19 @@ def daily_trend_panel(fig, result, row):
fig.update_yaxes(title_text="Δ fin de nuit [V]", row=row, col=1)
def daily_figure(station, series):
"""Graphique pour le site de monitoring (D-021) : analyse 03 en haut, analyse 04 dessous, même axe du temps."""
fig = make_subplots(rows=2, cols=1, shared_xaxes=True, vertical_spacing=0.08,
subplot_titles=[f"Analyse {bs.RULE['id']}", f"Analyse {bt.RULE['id']}"])
daily_state_panel(fig, bs.run(series), 1)
daily_trend_panel(fig, bt.run(series), 2)
fig.update_xaxes(showticklabels=True)
fig.update_yaxes(fixedrange=True) # zoom horizontal seulement : l'ordonnée est recalée par AUTOSCALE_Y_JS
fig.update_layout(title=f"{station} : état et tendance de la batterie", height=700, barmode="overlay",
legend=dict(groupclick="toggleitem"))
return fig
def gaps(v):
"""Plages de créneaux sans BusVoltage : [(premier créneau vide, première valeur suivante)]."""
out, start = [], None
@@ -209,6 +222,13 @@ def main(argv=None):
path, include_plotlyjs="cdn", post_script=AUTOSCALE_Y_JS, config={"scrollZoom": True})
print(path)
paths.append(path)
# Analyses 03 et 04 : page de démo, et figure Plotly en JSON pour le site (Plotly.newPlot).
path = os.path.join(a.out, f"{station}_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.removesuffix(".html") + ".json")
print(path)
paths.append(path)
return paths