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:
1 parent
28d441889f
commit
f0990c16e6
22 files changed
+682
-246
No files matched your search
@@ -10,40 +10,19 @@ 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 cellular.all_analyses import GRAY, hover, state_markers # noqa: E402 (mêmes marqueurs que Cellular)
|
||||
from energy.final import noon # noqa: E402 (points journaliers à midi UTC, D-019)
|
||||
from storage import days_until_full as du, storage_state as ss # noqa: E402
|
||||
from storage.final import TITLES, analysis_panels # noqa: E402 (panneaux partagés avec la figure du site)
|
||||
|
||||
# Couleurs de la page Cellular, validées par le skill dataviz.
|
||||
STATE_STYLE = {"OK": ("#008300", "circle"), "LOW": ("#eda100", "diamond"), "CRITICAL": ("#4a3aa7", "x"), None: GRAY}
|
||||
METRICS = ["data_storage_free_gb", "data_storage_used_gb", "data_storage_total_gb"]
|
||||
|
||||
|
||||
def figure(station, series, state, days):
|
||||
titles = [f"Analyse {ss.RULE['id']}", f"Analyse {du.RULE['id']}"]
|
||||
fig = make_subplots(rows=len(titles) + len(METRICS), cols=1, shared_xaxes=True, vertical_spacing=0.04,
|
||||
subplot_titles=titles + METRICS)
|
||||
group = dict(legendgroup=ss.RULE["id"], legendgrouptitle_text=f"Analyse {ss.RULE['id']}")
|
||||
pts = state["points"]
|
||||
x = [noon(p["t"].date()) for p in pts]
|
||||
fig.add_scatter(x=x, y=[p["value"] for p in pts], name="espace libre du jour", mode="lines",
|
||||
line=dict(color="#52514e", width=1.5), hoverinfo="skip", row=1, 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, s in zip(ss.FREE_PERCENT_FLOORS, ss.STATES):
|
||||
fig.add_scatter(x=x, y=[f] * len(x), name=f"plancher {s} {f} %", mode="lines", hoverinfo="skip",
|
||||
line=dict(color=STATE_STYLE[s][0], dash="dash", width=1), row=1, col=1, **group)
|
||||
state_markers(fig, pts, "free_percent", "state", STATE_STYLE, 1, group)
|
||||
fig.update_yaxes(title_text="libre / utilisable [%]", row=1, col=1)
|
||||
|
||||
pts = [p for p in days["points"] if p["value"] is not None]
|
||||
fig.add_scatter(x=[noon(p["t"].date()) for p in pts], y=[p["value"] for p in pts], name="jours avant saturation",
|
||||
mode="lines+markers", text=[hover(p) for p in pts], hovertemplate="%{text}<extra></extra>",
|
||||
line=dict(color="#2a78d6", width=1.5), legendgroup=du.RULE["id"],
|
||||
legendgrouptitle_text=f"Analyse {du.RULE['id']}", row=2, col=1)
|
||||
fig.update_yaxes(title_text="jours restants", row=2, col=1)
|
||||
def figure(station, series):
|
||||
fig = make_subplots(rows=len(TITLES) + len(METRICS), cols=1, shared_xaxes=True, vertical_spacing=0.04,
|
||||
subplot_titles=TITLES + METRICS)
|
||||
analysis_panels(fig, series)
|
||||
|
||||
mesures = dict(legendgroup="mesures", legendgrouptitle_text="Mesures")
|
||||
for row, m in enumerate(METRICS, start=len(titles) + 1):
|
||||
for row, m in enumerate(METRICS, start=len(TITLES) + 1):
|
||||
s = series[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,
|
||||
**mesures)
|
||||
@@ -66,7 +45,7 @@ def main(paths):
|
||||
print(f"{station} : ignorée, pas de mesures du disque ({', '.join(METRICS)})")
|
||||
continue
|
||||
path = ROOT / "out" / f"{station}_storage.html"
|
||||
figure(station, series, ss.run(series), du.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)
|
||||
|
||||
@@ -17,9 +17,10 @@ MATRIX = {
|
||||
"CRITICAL": {"BEYOND_60_DAYS": "RED", "WITHIN_60_DAYS": "RED", "WITHIN_14_DAYS": "RED", None: "RED"},
|
||||
}
|
||||
|
||||
# Une phrase par couleur notifiée, en anglais (D-023) ; Green ne notifie rien (D-025).
|
||||
HEADLINE = {"RED": "The station is about to run out of storage space.",
|
||||
"ORANGE": "The station's storage space is running low."}
|
||||
# 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 has enough storage space.",
|
||||
"ORANGE": "The station's storage space is running low.",
|
||||
"RED": "The station is about to run out of storage space."}
|
||||
|
||||
RULE = {
|
||||
"id": "DAY_COLOR",
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
"""Analyses de la couleur du jour Storage (D-035) : DAILY_STORAGE_STATE et DAYS_UNTIL_STORAGE_FULL, en une figure pour le site (D-021).
|
||||
|
||||
Usage : python3 src/storage/final.py [CSV ou dossiers...] (défaut : data/WEISSHORN/)
|
||||
Écrit out/<STATION>_storage_daily.html (page de démo) et .json (figure Plotly pour le site, Plotly.newPlot), puis les ouvre.
|
||||
Documentation : docs/storage/analyses/daily_storage_state.md et days_until_storage_full.md ; guide docs/storage/guide/
|
||||
"""
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1])) # src/ : paquets common, energy, cellular et storage
|
||||
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.final import GRAY, hover, state_markers # noqa: E402 (mêmes marqueurs que Cellular)
|
||||
from energy.final import noon # noqa: E402 (points journaliers à midi UTC, D-019)
|
||||
from storage import days_until_full as du, storage_state as ss # noqa: E402
|
||||
|
||||
# Couleurs de la page Cellular, validées par le skill dataviz.
|
||||
STATE_STYLE = {"OK": ("#008300", "circle"), "LOW": ("#eda100", "diamond"), "CRITICAL": ("#4a3aa7", "x"), None: GRAY}
|
||||
TITLES = [f"Analysis {ss.RULE['id']}", f"Analysis {du.RULE['id']}"]
|
||||
|
||||
|
||||
def state_panel(fig, result, row):
|
||||
"""Panneau DAILY_STORAGE_STATE : espace libre en fin de jour, planchers, état en marqueurs (fiche daily_storage_state)."""
|
||||
group = dict(legendgroup=result["analysis"], legendgrouptitle_text=f"Analysis {result['analysis']}")
|
||||
pts = result["points"]
|
||||
x = [noon(p["t"].date()) for p in pts]
|
||||
fig.add_scatter(x=x, y=[p["value"] for p in pts], name="free space (end of day)", 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, s in zip(ss.FREE_PERCENT_FLOORS, ss.STATES):
|
||||
fig.add_scatter(x=x, y=[f] * len(x), name=f"{s} floor {f} %", mode="lines", hoverinfo="skip",
|
||||
line=dict(color=STATE_STYLE[s][0], dash="dash", width=1), row=row, col=1, **group)
|
||||
state_markers(fig, pts, "free_percent", "state", STATE_STYLE, row, group)
|
||||
fig.update_yaxes(title_text="free / usable [%]", row=row, col=1)
|
||||
|
||||
|
||||
def days_panel(fig, result, row):
|
||||
"""Panneau DAYS_UNTIL_STORAGE_FULL : jours avant saturation, au rythme médian sur 7 jours (fiche days_until_storage_full)."""
|
||||
pts = [p for p in result["points"] if p["value"] is not None]
|
||||
fig.add_scatter(x=[noon(p["t"].date()) for p in pts], y=[p["value"] for p in pts], name="days until full",
|
||||
mode="lines+markers", text=[hover(p) for p in pts], hovertemplate="%{text}<extra></extra>",
|
||||
line=dict(color="#2a78d6", width=1.5), legendgroup=result["analysis"],
|
||||
legendgrouptitle_text=f"Analysis {result['analysis']}", row=row, col=1)
|
||||
fig.update_yaxes(title_text="days left", row=row, col=1)
|
||||
|
||||
|
||||
def analysis_panels(fig, series):
|
||||
"""Les deux panneaux des analyses, rangées 1 et 2 : partagés par la figure du site et la page de comparaison."""
|
||||
state_panel(fig, ss.run(series), 1)
|
||||
days_panel(fig, du.run(series), 2)
|
||||
|
||||
|
||||
def daily_figure(station, series):
|
||||
"""Graphique pour le site de monitoring : DAILY_STORAGE_STATE en haut, DAYS_UNTIL_STORAGE_FULL dessous."""
|
||||
fig = make_subplots(rows=2, 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}: storage space", height=700, legend=dict(groupclick="toggleitem"))
|
||||
return fig
|
||||
|
||||
|
||||
def main(paths):
|
||||
"""Pour chaque station qui a les mesures de /data : out/<STATION>_storage_daily.html et .json. -> chemins écrits."""
|
||||
(ROOT / "out").mkdir(exist_ok=True)
|
||||
written = []
|
||||
for station, series in sorted(load_stations(paths).items()):
|
||||
if "data_storage_free_gb" not in series:
|
||||
print(f"{station} : ignorée, pas de mesures de /data (data_storage_*)")
|
||||
continue
|
||||
path = ROOT / "out" / f"{station}_storage_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" / "WEISSHORN")]):
|
||||
open_html(p)
|
||||
Reference in new issue
Block a user