Clean the journal curves, unfold its timeline and sort it in batches (D-056)

Plan points 18 to 26, 30, 39, 40 and the point 37 housekeeping:
- greyed zones per target, vertical scale without the zones to ignore, Fit all,
  mm by default with a px switch, Support view, Expand (one row per category);
- cleaned curves: cut in the zones to ignore, raw data kept there in thin grey;
- target02 to target05 count as targets; smoothing questions answered;
- categories.py sorts in slices with 3 days of history by default;
- the pumping script points to ~/monitoring-dashboard and skips diff images;
- CLAUDE.md back under 200 lines; a case page is named after its case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
maximeandClaude Opus 5.5 committed 2026-10-24 14:31:42 +02:00
1 parent 86547f089b
commit 955566d86f
14 files changed
+303 -98

No files matched your search

@@ -129,6 +129,8 @@
.jentry:hover { background: #e8f0fb; }
.jentry .when { color: var(--muted); font-size: 12px; }
.jentry b { font-size: 14px; }
.jentry details { margin-top: 4px; }
.jentry summary { cursor: pointer; color: var(--muted); font-size: 12px; }
.jentry button { margin-left: 6px; font-size: 12px; cursor: pointer; }
/* Timelapse d'un événement (bouton ▶ Images) : fenêtre par-dessus la page, bord rouge pendant l'événement. */
#j-video { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: rgba(0, 0, 0, .6); }
@@ -263,8 +265,15 @@
</div>
</div>
<div class="pane" id="journal">
<div class="toolbar">Unit <button type="button" data-unit="mm">mm</button><button type="button" data-unit="px">px</button>
&nbsp; <button type="button" id="j-fit">Fit all</button>
&nbsp; <label><input type="checkbox" id="j-expand"> Expand</label>
&nbsp; <label><input type="checkbox" id="j-support"> Support view</label>
<span class="meta">mm: hourly averages, what the platform shows · px: every measurement, short peaks included ·
the vertical scale leaves out the greyed zones and the hidden targets</span></div>
<div id="j-curves"></div>
<p class="hint">Grey zones: do not trust the data there (they are kept, not removed). Hover a bar for details, ▶ Images to see the camera; zoom the curves
<p class="hint">Cleaned curves: the periods to ignore are removed, nothing else changed; the raw data stays there in thin grey,
on a grey zone. Hover a bar for details, ▶ Images to see the camera; zoom the curves
with the wheel or by dragging, double-click for the whole period.</p>
<div id="j-list"></div>
<div id="j-video" hidden><div class="box"><canvas></canvas><div class="bar"><button type="button" data-v="-1">◀</button>
@@ -944,36 +953,85 @@ const jWhen = t => `${MON[+t.slice(5, 7) - 1]} ${+t.slice(8, 10)}, ${t.slice(11,
const plotT = ms => new Date(ms).toISOString().slice(0, 19).replace("T", " "); // instant en ms -> date Plotly (UTC)
const jEnd = e => Math.max(Date.parse(e.end), Date.parse(e.start) + 3600e3); // dessin : 1 h au moins, sinon invisible
function drawJournal() {
const targets = S.filter(s => s.kind === "target" || s.kind === "ref");
const traces = targets.flatMap((s, n) => [["corr_x", "Horizontal"], ["corr_y", "Vertical"]].map(([c, label], r) => ({
type: "scatter", mode: "lines", x: D.times, y: s.values[c], yaxis: `y${r ? 2 : ""}`, name: s.name, showlegend: false,
line: { color: PALETTE[n % PALETTE.length], width: 1 },
hovertemplate: `${s.name} · %{x|%d %b %H:%M} UTC<br>${label} %{y:.2f} px<extra></extra>` })));
// unité des courbes (point 20) : mm par défaut, les moyennes horaires que la plateforme montre au client (export
// horaire) ; px, chaque mesure de l'export « advanced » (corr_x, corr_y), pics d'une mesure compris ; #unit=px : captures
// vue support (point 23) : une ligne par détecteur sous « What happened » et le repli Details de chaque carte, avec les
// épisodes d'origine ; la vue client reste celle du point 8 ; #support pour les captures
let J_SUPPORT = ASKED.has("support");
// frise dépliée (point 40) : une ligne par catégorie présente, dans l'ordre de J_ORDER (« Shift to check » en haut) ;
// repliée, la ligne unique du point 8 ; #expand pour les captures
let J_EXPAND = ASKED.has("expand");
const J_DET = { visibilite: ["Visibility", "#1f77b4"], sauts: ["Jumps", "#d62728"], turbulence: ["Turbulence", "#ff7f0e"],
thermique: ["Thermal", "#2ca02c"], trous: ["Missing data", "#7f7f7f"] };
let J_UNIT = ASKED.get("unit") === "px" || !Object.keys(D.hourly.sensors).length ? "px" : "mm"; // px sans export horaire
const J_PAL = PALETTE.filter(c => c !== "#7f7f7f"); // sans le gris, réservé à la brute à ignorer (point 25)
const jColor = name => J_PAL[Math.max(0, S.findIndex(s => s.name === name)) % J_PAL.length]; // même couleur en mm et en px
function jSeries() { // [{name, times, h, v}] : les courbes dans l'unité choisie
if (J_UNIT === "px") return S.filter(s => s.kind === "target" || s.kind === "ref")
.map(s => ({ name: s.name, times: D.times, h: s.values.corr_x, v: s.values.corr_y }));
return Object.entries(D.hourly.sensors).map(([name, mm]) => ({ name, times: D.hourly.times, h: mm.h, v: mm.v }));
}
function drawJournal(range) {
const series = jSeries(), AXES = [["h", "Horizontal"], ["v", "Vertical"]];
// l'échelle verticale laisse de côté les points des zones grisées et des cibles masquées (point 19) : un pic qu'on
// doit ignorer n'écrase plus les autres courbes ; ils restent dessinés, hors cadre si besoin
const step = J_UNIT === "mm" ? 3599e3 : 0; // en mm, une moyenne horaire couvre toute son heure (point 25)
const inside = (e, t) => { const T = Date.parse(t); return T <= Date.parse(e.end) && T + step >= Date.parse(e.start); };
const scene = J.filter(e => e.ignore && e.category !== "cible_masquee");
const skip = s => { const h = J.filter(e => e.category === "cible_masquee" && e.sensors.includes(s.name));
return s.times.map(t => scene.some(e => inside(e, t)) || h.some(e => inside(e, t))); };
// courbe nettoyée (point 25, option A) : la brute sans les points à ignorer, coupée là, rien d'interpolé ; la brute y
// reste en gris fin, reliée aux points gardés de part et d'autre (sinon un point seul, un passage, ne se verrait pas) ;
// une cible masquée n'est coupée que sur sa courbe, pas sur tout le fond (point 18)
const traces = series.flatMap(s => { const yskip = skip(s), near = yskip.map((v, k) => v || yskip[k - 1] || yskip[k + 1]);
return AXES.flatMap(([c, label], r) => [{
type: "scatter", mode: "lines", x: s.times, y: s[c].map((v, k) => yskip[k] ? null : v), yaxis: `y${r ? 2 : ""}`,
name: s.name, showlegend: false, line: { color: jColor(s.name), width: 1 }, meta: { yskip },
hovertemplate: `${s.name} · %{x|%d %b %H:%M} UTC<br>${label} %{y:.2f} ${J_UNIT}<extra></extra>` }, {
type: "scatter", mode: "lines", x: s.times, y: s[c].map((v, k) => near[k] ? v : null), yaxis: `y${r ? 2 : ""}`,
name: s.name, showlegend: false, line: { color: "#b0b0b0", width: 1 }, meta: { yskip: s.times.map(() => true) },
hovertemplate: `${s.name} (raw, to ignore) · %{x|%d %b %H:%M} UTC<br>${label} %{y:.2f} ${J_UNIT}<extra></extra>` }]); });
// frise : une barre par événement, de son début à sa fin, dans l'ordre de J_ORDER ; une barre perd son étiquette quand
// une barre dessinée par-dessus couvre son milieu (sinon les textes se mêlent ; le survol dit tout)
const bars = [...J].sort((u, v) => J_ORDER.indexOf(u.category) - J_ORDER.indexOf(v.category));
const mid = e => (Date.parse(e.start) + jEnd(e)) / 2;
const covered = e => bars.slice(bars.indexOf(e) + 1).some(o => Date.parse(o.start) <= mid(e) && jEnd(o) >= mid(e));
const covered = e => !J_EXPAND && bars.slice(bars.indexOf(e) + 1).some(o => Date.parse(o.start) <= mid(e) && jEnd(o) >= mid(e));
traces.push({ type: "bar", orientation: "h", yaxis: "y3", name: "events", showlegend: false,
y: bars.map(() => J_ROW), base: bars.map(e => e.start), x: bars.map(e => jEnd(e) - Date.parse(e.start)),
y: bars.map(e => J_EXPAND ? e.label : J_ROW), base: bars.map(e => e.start), x: bars.map(e => jEnd(e) - Date.parse(e.start)),
marker: { color: bars.map(e => J_FAM[jFam(e)]), line: { color: "#fff", width: 1 } },
width: bars.map(e => e.category === "derive_lente" ? 0.2 : 0.75), // la dérive, longue, en trait fin sous les autres
width: bars.map(e => e.category === "derive_lente" && !J_EXPAND ? 0.2 : 0.75), // repliée, la dérive, longue, en trait fin sous les autres
text: bars.map(e => covered(e) ? "" : e.label), textposition: "inside", insidetextanchor: "middle",
insidetextfont: { color: bars.map(e => jFam(e) === "gap" ? "#333" : "#fff") }, customdata: bars.map(e => J.indexOf(e)),
hovertext: bars.map(e => `<b>${e.label}</b><br>${e.text}<br>Sensors: ${e.sensors.length ? e.sensors.join(", ") : "all"}`),
hovertemplate: "%{hovertext}<extra></extra>" });
const C = 220, G = 24, F = 40, A = 2 * C + 2 * G + F; // hauteurs en px, A : zone tracée
const grey = J.filter(e => e.ignore || jFam(e) === "reduced").flatMap(e => ["y domain", "y2 domain"].map(yref => ({ type: "rect",
const eps = J_SUPPORT ? J.flatMap(e => e.episodes) : []; // vue support : les épisodes bruts, une ligne par détecteur
const kinds = [...new Set([...Object.keys(J_DET), ...eps.map(p => p.kind)])].filter(k => eps.some(p => p.kind === k));
const row = k => (J_DET[k] || [k])[0];
for (const k of kinds) {
const ps = eps.filter(p => p.kind === k);
traces.push({ type: "bar", orientation: "h", yaxis: "y3", name: k, showlegend: false, y: ps.map(() => row(k)),
base: ps.map(p => p.start), x: ps.map(p => jEnd(p) - Date.parse(p.start)), marker: { color: (J_DET[k] || [, "#999"])[1] },
text: ps.map(p => p.label), textposition: "inside", insidetextanchor: "middle", insidetextfont: { color: "#fff" },
hovertext: ps.map(p => `<b>${p.label}</b> (${k})${p.text ? "<br>" + p.text : ""}<br>Sensors: ${
p.sensors.length ? p.sensors.join(", ") : "all"}`), hovertemplate: "%{hovertext}<extra></extra>" });
}
const cats = J_EXPAND ? [...new Set(bars.map(e => e.label))].reverse() : [J_ROW];
const rows = [...cats, ...kinds.map(row)];
const C = 220, G = 24, F = 10 + 30 * rows.length, A = 2 * C + 2 * G + F; // hauteurs en px, A : zone tracée
const grey = J.filter(e => (e.ignore || jFam(e) === "reduced") && e.category !== "cible_masquee").flatMap(e => ["y domain", "y2 domain"].map(yref => ({ type: "rect",
xref: "x", yref, x0: e.start, x1: plotT(jEnd(e)), y0: 0, y1: 1, fillcolor: "#888", opacity: e.ignore ? 0.25 : 0.1,
line: { width: 0 }, layer: "below" }))); // grisé ; en léger retrait pour une visibilité réduite
const end = Date.parse(D.times[D.times.length - 1]);
document.querySelectorAll("#journal [data-unit]").forEach(b => b.classList.toggle("active", b.dataset.unit === J_UNIT));
Plotly.purge("j-curves"); // redessin au changement d'unité : sans les écouteurs du dessin d'avant
Plotly.newPlot("j-curves", traces, {
height: A + 70, margin: { l: 110, r: 10, t: 20, b: 50 }, barmode: "overlay", bargap: 0.25, uniformtext: { mode: "hide", minsize: 10 },
xaxis: { type: "date", anchor: "y3", range: [ASKED.get("from") || plotT(end - 3 * 864e5), plotT(end)] }, // départ : les 3 derniers jours (#from=AAAA-MM-JJ : captures)
yaxis: { domain: [1 - C / A, 1], fixedrange: true, title: { text: "Horizontal (px)" } },
yaxis2: { domain: [1 - (2 * C + G) / A, 1 - (C + G) / A], fixedrange: true, title: { text: "Vertical (px)" } },
yaxis3: { domain: [0, F / A], fixedrange: true, type: "category", showgrid: false },
xaxis: { type: "date", anchor: "y3", range: range || [ASKED.get("from") || plotT(end - 3 * 864e5), plotT(end)] }, // départ : les 3 derniers jours (#from=AAAA-MM-JJ : captures)
yaxis: { domain: [1 - C / A, 1], fixedrange: true, title: { text: `Horizontal (${J_UNIT})` } },
yaxis2: { domain: [1 - (2 * C + G) / A, 1 - (C + G) / A], fixedrange: true, title: { text: `Vertical (${J_UNIT})` } },
yaxis3: { domain: [0, F / A], fixedrange: true, type: "category", categoryorder: "array", categoryarray: rows.slice().reverse(),
showgrid: false }, // « What happened » (ou une ligne par catégorie) en haut, les détecteurs dessous (vue support)
shapes: grey,
}, CONFIG).then(() => {
autoscale("j-curves"); // les barres de la frise (ordonnées en texte) n'entrent pas dans le recalage
@@ -992,15 +1050,36 @@ function listJournal([a, b]) { // les événements de la plage visible, dans l'
document.getElementById("j-list").innerHTML = eps.length ? eps.map(e => `<div class="jentry" data-n="${J.indexOf(e)}"
style="border-left-color:${J_FAM[jFam(e)]}"><div class="when">${jWhen(e.start)}${e.end === e.start ? "" : ` – ${
e.end.slice(0, 10) === e.start.slice(0, 10) ? e.end.slice(11, 16) : jWhen(e.end)}`} UTC</div><b>${e.label}</b> · ${
e.text}${e.process === "aucun" ? ""
e.text}${J_SUPPORT && e.episodes.length ? `<details><summary>Details</summary>${e.episodes.map(p => `<div class="meta">${
p.kind} · ${p.label} · ${jWhen(p.start)}${p.end === p.start ? "" : ` – ${jWhen(p.end)}`} UTC${
p.sensors.length ? ` · ${p.sensors.join(", ")}` : ""}</div>`).join("")}</details>` : ""}${e.process === "aucun" ? ""
: jFrames(e).length ? '<button type="button">▶ Images</button>'
: '<button type="button" disabled>▶ Images</button> <span class="meta">No camera image for this period.</span>'}</div>`).join("")
: '<p class="empty">Nothing to report on this period.</p>';
}
document.querySelectorAll("#journal [data-unit]").forEach(b => b.addEventListener("click", () => { // même plage de temps
J_UNIT = b.dataset.unit;
drawJournal(document.getElementById("j-curves").layout.xaxis.range.slice());
}));
const jExpand = document.getElementById("j-expand");
jExpand.checked = J_EXPAND;
jExpand.addEventListener("change", () => { // même plage de temps
J_EXPAND = jExpand.checked;
drawJournal(document.getElementById("j-curves").layout.xaxis.range.slice());
});
const jSupport = document.getElementById("j-support");
jSupport.checked = J_SUPPORT;
jSupport.addEventListener("change", () => { // même plage de temps
J_SUPPORT = jSupport.checked;
drawJournal(document.getElementById("j-curves").layout.xaxis.range.slice());
});
document.getElementById("j-fit").addEventListener("click", () =>
Plotly.relayout("j-curves", { "yaxis.autorange": true, "yaxis2.autorange": true })); // tous les points, pics compris
document.getElementById("j-list").addEventListener("click", ev => {
const el = ev.target.closest("[data-n]");
if (!el) return;
if (ev.target.closest("button")) return openTimelapse(J[+el.dataset.n]);
if (ev.target.closest("details")) return; // le repli Details s'ouvre sans zoomer
const e = J[+el.dataset.n], a = Date.parse(e.start), b = Date.parse(e.end), m = Math.max((b - a) / 2, 2 * 3600e3); // marge
Plotly.relayout("j-curves", { "xaxis.range": [plotT(a - m), plotT(b + m)] });
});