Deliver Storage and Cellular in the mockups, with site figures and guides

The mockups now walk a list of domains (D-039): the support Home loads
every station in data/ and notifies each station x domain that is Orange
or Red; the client view becomes maquettes/user/summary.py, one System
Summary page per station with one block per measured domain. Storage
shows a free-space scale and the estimated full date; Cellular shows the
day's sends in words and a four-class signal scale.

HEADLINE moves into each day_color.py, with a Green sentence for the
client view. src/storage/final.py and src/cellular/final.py write the
site figures in English; the comparison pages reuse their panels. Each
domain gets a short two-layer guide in docs/<domaine>/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:05:26 +02:00
1 parent 28d441889f
commit f0990c16e6
22 files changed
+682 -246

No files matched your search

+7 -49
View File
@@ -11,60 +11,18 @@ from common.page import AUTOSCALE_Y_JS, ROOT, open_html # noqa: E402 (bascule
from common.stations import gaps, load_stations # noqa: E402
from plotly.subplots import make_subplots # noqa: E402
from cellular import link_state as ls, signal_state as ss # noqa: E402
from energy.final import noon # noqa: E402 (points journaliers à midi UTC, D-019)
from cellular.final import TITLES, analysis_panels # noqa: E402 (panneaux partagés avec la figure du site)
# Couleurs validées par le skill dataviz (toutes paires, fond blanc ; vert/rouge refusé : deutéranopie).
# Le jaune contraste peu avec le fond : chaque état a aussi son symbole, sa légende et son survol.
GRAY = ("#8c8c8c", "circle-open")
LINK_STYLE = {"UP": ("#008300", "circle"), "MISSING": ("#eda100", "diamond"), "DOWN": ("#4a3aa7", "x"), None: GRAY}
CLASS_STYLE = {"EXCELLENT": ("#008300", "circle"), "GOOD": ("#2a78d6", "square"),
"MID_CELL": ("#eda100", "diamond"), "CELL_EDGE": ("#4a3aa7", "x"), None: GRAY}
METRICS = ["rsrp_dBm", "rsrq_dB", "rssi_dbm", "ber_percent"] # liste explicite : jamais SIM_CCID ni ip
def hover(p):
return f"{p['t']:%Y-%m-%d}<br>" + "<br>".join(f"{k}={v}" for k, v in p["facts"].items())
def state_markers(fig, pts, y_key, state_key, styles, row, group):
"""Un marqueur par jour à midi, une trace par état (légende et symbole propres)."""
for state, (color, symbol) in styles.items():
sel = [p for p in pts if p["facts"].get(state_key) == state and p["facts"].get(y_key) is not None]
if sel:
fig.add_scatter(x=[noon(p["t"].date()) for p in sel], y=[p["facts"][y_key] for p in sel],
name=f"{state or 'inconnu'}", mode="markers", text=[hover(p) for p in sel],
hovertemplate="%{text}<extra></extra>",
marker=dict(color=color, symbol=symbol, size=9, line=dict(color="white", width=1)),
row=row, col=1, **group)
def floors_panel(fig, result, row, y_key, class_key, floors, unit):
"""Panneau DAILY_SIGNAL_STATE pour une mesure : médiane du jour, planchers de la grille, classe en marqueurs."""
group = dict(legendgroup=f"{result['analysis']} {unit}", legendgrouptitle_text=f"{result['analysis']} ({unit})")
pts = result["points"]
x = [noon(p["t"].date()) for p in pts]
fig.add_scatter(x=x, y=[p["facts"].get(y_key) for p in pts], name="médiane du jour", mode="lines",
line=dict(color="#52514e", width=1.5), hoverinfo="skip", row=row, col=1, **group)
# Planchers tracés comme des courbes (un point par jour) : AUTOSCALE_Y_JS les garde visibles au zoom (D-013).
for f, c in zip(floors, ss.CLASSES):
fig.add_scatter(x=x, y=[f] * len(x), name=f"plancher {c} {f} {unit}", mode="lines", hoverinfo="skip",
line=dict(color=CLASS_STYLE[c][0], dash="dash", width=1), row=row, col=1, **group)
state_markers(fig, pts, y_key, class_key, CLASS_STYLE, row, group)
fig.update_yaxes(title_text=f"médiane du jour [{unit}]", row=row, col=1)
def figure(station, series, link, signal):
titles = [f"Analyse {ls.RULE['id']}", f"Analyse {ss.RULE['id']} : RSRP", f"Analyse {ss.RULE['id']} : RSRQ"]
fig = make_subplots(rows=len(titles) + len(METRICS) + 1, cols=1, shared_xaxes=True, vertical_spacing=0.03,
subplot_titles=titles + METRICS + ["envois reçus par heure (last_sync, sinon link)"])
group = dict(legendgroup=ls.RULE["id"], legendgrouptitle_text=f"Analyse {ls.RULE['id']}")
state_markers(fig, link["points"], "received_percent", "state", LINK_STYLE, 1, group)
fig.update_yaxes(title_text="envois reçus [%]", row=1, col=1)
floors_panel(fig, signal, 2, "rsrp_median_dbm", "rsrp_class", ss.RSRP_FLOORS_DBM, "dBm")
floors_panel(fig, signal, 3, "rsrq_median_db", "rsrq_class", ss.RSRQ_FLOORS_DB, "dB")
def figure(station, series):
fig = make_subplots(rows=len(TITLES) + len(METRICS) + 1, cols=1, shared_xaxes=True, vertical_spacing=0.03,
subplot_titles=TITLES + METRICS + ["envois reçus par heure (last_sync, sinon link)"])
analysis_panels(fig, series)
mesures = dict(legendgroup="mesures", legendgrouptitle_text="Mesures")
row = len(titles)
row = len(TITLES)
for row, m in enumerate(METRICS, start=row + 1):
s = series.get(m, {})
fig.add_scatter(x=sorted(s), y=[s[t] for t in sorted(s)], name=m, line=dict(width=1), row=row, col=1,
@@ -90,7 +48,7 @@ def main(paths):
print(f"{station} : ignorée, pas de mesures du modem (rsrp_dBm, et link ou last_sync)")
continue
path = ROOT / "out" / f"{station}_cellular.html"
figure(station, series, ls.run(series), ss.run(series)).write_html(
figure(station, series).write_html(
path, include_plotlyjs="cdn", post_script=AUTOSCALE_Y_JS, config={"scrollZoom": True})
print(path)
written.append(path)
+4 -3
View File
@@ -15,9 +15,10 @@ MATRIX = {
"DOWN": {**dict.fromkeys(KNOWN, "ORANGE"), None: "RED"},
}
# Une phrase par couleur notifiée, en anglais (D-023) ; Green ne notifie rien (D-025).
HEADLINE = {"RED": "The station stopped sending data for a large part of the day.",
"ORANGE": "The station's 4G connection showed interruptions."}
# Une phrase par couleur, en anglais (D-023) ; Green ne notifie rien (D-025), sa phrase ne sert qu'à la vue client.
HEADLINE = {"GREEN": "The station sent all its data over 4G.",
"ORANGE": "The station's 4G connection showed interruptions.",
"RED": "The station stopped sending data for a large part of the day."}
RULE = {
"id": "DAY_COLOR",
+103
View File
@@ -0,0 +1,103 @@
"""Analyses de la couleur du jour Cellular (D-037) : DAILY_LINK_STATE et DAILY_SIGNAL_STATE, en une figure pour le site (D-021).
Usage : python3 src/cellular/final.py [CSV ou dossiers...] (défaut : data/WEISSHORN/ et data/NORDEND/)
Écrit out/<STATION>_cellular_daily.html (page de démo) et .json (figure Plotly pour le site, Plotly.newPlot), puis les ouvre.
Documentation : docs/cellular/analyses/daily_link_state.md et daily_signal_state.md ; guide docs/cellular/guide/
"""
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1])) # src/ : paquets common, energy et cellular
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 cellular import link_state as ls, signal_state as ss # noqa: E402
from energy.final import noon # noqa: E402 (points journaliers à midi UTC, D-019)
# Couleurs validées par le skill dataviz (toutes paires, fond blanc ; vert/rouge refusé : deutéranopie).
# Le jaune contraste peu avec le fond : chaque état a aussi son symbole, sa légende et son survol.
GRAY = ("#8c8c8c", "circle-open")
LINK_STYLE = {"UP": ("#008300", "circle"), "MISSING": ("#eda100", "diamond"), "DOWN": ("#4a3aa7", "x"), None: GRAY}
CLASS_STYLE = {"EXCELLENT": ("#008300", "circle"), "GOOD": ("#2a78d6", "square"),
"MID_CELL": ("#eda100", "diamond"), "CELL_EDGE": ("#4a3aa7", "x"), None: GRAY}
def hover(p):
return f"{p['t']:%Y-%m-%d}<br>" + "<br>".join(f"{k}={v}" for k, v in p["facts"].items())
def state_markers(fig, pts, y_key, state_key, styles, row, group):
"""Un marqueur par jour à midi, une trace par état (légende et symbole propres)."""
for state, (color, symbol) in styles.items():
sel = [p for p in pts if p["facts"].get(state_key) == state and p["facts"].get(y_key) is not None]
if sel:
fig.add_scatter(x=[noon(p["t"].date()) for p in sel], y=[p["facts"][y_key] for p in sel],
name=f"{state or 'unknown'}", mode="markers", text=[hover(p) for p in sel],
hovertemplate="%{text}<extra></extra>",
marker=dict(color=color, symbol=symbol, size=9, line=dict(color="white", width=1)),
row=row, col=1, **group)
def link_panel(fig, result, row):
"""Panneau DAILY_LINK_STATE : part des envois reçus par jour, état en marqueurs (fiche daily_link_state)."""
group = dict(legendgroup=result["analysis"], legendgrouptitle_text=f"Analysis {result['analysis']}")
state_markers(fig, result["points"], "received_percent", "state", LINK_STYLE, row, group)
fig.update_yaxes(title_text="sends received [%]", row=row, col=1)
def floors_panel(fig, result, row, y_key, class_key, floors, unit):
"""Panneau DAILY_SIGNAL_STATE pour une mesure : médiane du jour, planchers de la grille, classe en marqueurs."""
group = dict(legendgroup=f"{result['analysis']} {unit}", legendgrouptitle_text=f"{result['analysis']} ({unit})")
pts = result["points"]
x = [noon(p["t"].date()) for p in pts]
fig.add_scatter(x=x, y=[p["facts"].get(y_key) for p in pts], name="daily median", mode="lines",
line=dict(color="#52514e", width=1.5), hoverinfo="skip", row=row, col=1, **group)
# Planchers tracés comme des courbes (un point par jour) : AUTOSCALE_Y_JS les garde visibles au zoom (D-013).
for f, c in zip(floors, ss.CLASSES):
fig.add_scatter(x=x, y=[f] * len(x), name=f"{c} floor {f} {unit}", mode="lines", hoverinfo="skip",
line=dict(color=CLASS_STYLE[c][0], dash="dash", width=1), row=row, col=1, **group)
state_markers(fig, pts, y_key, class_key, CLASS_STYLE, row, group)
fig.update_yaxes(title_text=f"daily median [{unit}]", row=row, col=1)
TITLES = [f"Analysis {ls.RULE['id']}", f"Analysis {ss.RULE['id']}: RSRP", f"Analysis {ss.RULE['id']}: RSRQ"]
def analysis_panels(fig, series):
"""Les trois panneaux des analyses, rangées 1 à 3 : partagés par la figure du site et la page de comparaison."""
link_panel(fig, ls.run(series), 1)
signal = ss.run(series)
floors_panel(fig, signal, 2, "rsrp_median_dbm", "rsrp_class", ss.RSRP_FLOORS_DBM, "dBm")
floors_panel(fig, signal, 3, "rsrq_median_db", "rsrq_class", ss.RSRQ_FLOORS_DB, "dB")
def daily_figure(station, series):
"""Graphique pour le site de monitoring : DAILY_LINK_STATE en haut, DAILY_SIGNAL_STATE (RSRP, RSRQ) dessous."""
fig = make_subplots(rows=3, cols=1, shared_xaxes=True, vertical_spacing=0.08, subplot_titles=TITLES)
analysis_panels(fig, series)
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}: data sent and 4G signal", height=900, legend=dict(groupclick="toggleitem"))
return fig
def main(paths):
"""Pour chaque station qui a les mesures du modem : out/<STATION>_cellular_daily.html et .json. -> chemins écrits."""
(ROOT / "out").mkdir(exist_ok=True)
written = []
for station, series in sorted(load_stations(paths).items()):
if "rsrp_dBm" not in series or not {"link", "last_sync"} & series.keys():
print(f"{station} : ignorée, pas de mesures du modem (rsrp_dBm, et link ou last_sync)")
continue
path = ROOT / "out" / f"{station}_cellular_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" / s) for s in ("WEISSHORN", "NORDEND")]):
open_html(p)