Show each jump and trend on the curves when hovering its row (D-055)

The Displacements tab now puts the list on the left and the curves on
the right, kept on screen while the list scrolls. Hovering a row keeps
only its target in color and draws it on the curves, with fixed scales:
a jump gets its 2 hours highlighted, the 24 h levels before and after
and an arrow with the jump in mm; a trend gets its period, the
Theil-Sen line, the daily levels, its start and end and the drift as
an arrow. #focus=j0-0, t0 or e0 opens with a row hovered, for captures.

Documented in the detection note: on NORDEND, PR17 and PR06 clear the
thresholds by a wide margin, the next curves fall short (PR03 nearest).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
maximeandClaude Opus 5.5 committed 2026-10-19 09:30:17 +02:00
1 parent 294e024e5a
commit 8d9b927600
5 files changed
+179 -41

No files matched your search

+121 -30
View File
@@ -108,18 +108,24 @@
#d-request textarea { width: 100%; font: 13px/1.4 monospace; padding: 6px 8px; border: 1px solid var(--line); }
#d-request p { margin: 4px 0; color: var(--text); }
/* Onglet Displacements (D-055) : sauts groupés en événements, tendances, puis les courbes en mm. */
#displacements .note { margin: 0 0 10px; }
/* Onglet Displacements (D-055) : à gauche les sauts groupés en événements et les tendances, à droite les courbes en mm,
qui restent à l'écran quand la liste défile ; le survol d'une ligne montre où elle a lieu sur les courbes. */
.rgrid { display: grid; grid-template-columns: minmax(460px, 40%) minmax(0, 1fr); gap: 20px; align-items: start; }
#r-curves { position: sticky; top: 6px; }
#displacements .how { margin: 0 0 8px; color: var(--muted); }
#displacements .how summary { cursor: pointer; font-size: 12px; }
#displacements .hint { color: var(--muted); font-size: 12px; }
#displacements .note { margin: 4px 0 0; }
#displacements .sub { margin: 18px 0 6px; }
#displacements .sub:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
#r-trends { margin: 0 0 12px; }
#r-events details { margin: 0 0 12px; color: var(--text); }
#r-events summary { font-size: 15px; cursor: pointer; padding: 4px 0; }
.rtable { border-collapse: collapse; width: 100%; margin-top: 4px; color: var(--text); }
.rtable th, .rtable td { padding: 5px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.rtable th { color: var(--muted); font-weight: normal; }
.rtable th, .rtable td { padding: 5px 6px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.rtable th { color: var(--muted); font-weight: normal; white-space: normal; vertical-align: bottom; }
.rtable tbody tr { cursor: pointer; }
.rtable tbody tr:hover { background: #f2f5f8; }
.rtable tbody tr:hover, .rtable tbody tr.on, #r-events summary.on { background: #e8f0fb; }
.rtable i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
</style>
</head>
@@ -225,13 +231,18 @@
</div>
</div>
<div class="pane" id="displacements">
<h3 class="sub">Jumps</h3>
<p class="note" id="r-note"></p>
<div id="r-events"></div>
<h3 class="sub">Trends</h3>
<p class="note" id="r-trend-note"></p>
<div id="r-trends"></div>
<div id="r-curves"></div>
<div class="rgrid">
<div class="rlist">
<h3 class="sub">Jumps</h3>
<details class="how"><summary>How they are found</summary><p class="note" id="r-note"></p></details>
<div id="r-events"></div>
<h3 class="sub">Trends</h3>
<details class="how"><summary>How they are found</summary><p class="note" id="r-trend-note"></p></details>
<div id="r-trends"></div>
<p class="hint">Hover a row: the curves show where and how much. Click it: open it in Diagnosis.</p>
</div>
<div id="r-curves"></div>
</div>
</div>
</section>
</main>
@@ -742,13 +753,15 @@ if (IM.length) setCompare(cmp);
else document.querySelector("#view .viewer").innerHTML = '<p class="empty">No image in this folder.</p>';
// Onglet Displacements (D-055) : sauts brutaux qui durent et tendances, calculés par explore.py (regime_changes) ; les sauts
// groupés en événements, dans l'ordre du temps ; puis toutes les courbes en mm, en gris, celles qui ont sauté ou dérivé
// en couleur. Un clic sur une ligne ouvre l'onglet Diagnosis sur cette cible à cette heure. Données inchangées.
const REG = D.regime, TRENDS = D.trends, RCOL = {}, RULES = D.rules;
// groupés en événements, dans l'ordre du temps ; à côté, toutes les courbes en mm, en gris, celles qui ont sauté ou dérivé
// en couleur. Le survol d'une ligne la montre sur les courbes (focusOn) ; un clic ouvre l'onglet Diagnosis sur cette cible
// à cette heure. Données inchangées.
const REG = D.regime, TRENDS = D.trends, RCOL = {}, RULES = D.rules, GREY = "#d3d8de", INK = "#222";
[...REG.flatMap(e => e.targets), ...TRENDS.map(f => f.target)]
.forEach(n => { if (!(n in RCOL)) RCOL[n] = PALETTE[Object.keys(RCOL).length % PALETTE.length]; });
const signed = (v, d = 1) => `${v > 0 ? "+" : v < 0 ? "−" : ""}${Math.abs(v).toFixed(d)} mm`;
const dot = n => `<i style="background:${RCOL[n]}"></i>${n}`;
const dm = t => `${+t.slice(8, 10)}/${+t.slice(5, 7)}`;
document.getElementById("r-note").textContent = `A sudden change that stays: within 2 h, the target moves at least ` +
`${RULES.abrupt} × as much as it usually does in 2 h, and its level over the next 24 h differs from the previous 24 h ` +
`by at least ${RULES.size} × its usual daily swing (median of max − min per UTC day). Daily and weather cycles are slow ` +
@@ -756,19 +769,20 @@ document.getElementById("r-note").textContent = `A sudden change that stays: wit
document.getElementById("r-trend-note").textContent = `A slow, steady drift: the daily level (median of each UTC day, ` +
`jumps above set aside) keeps moving the same way, and drifts over the period by at least ${RULES.trend_size} × the ` +
`usual daily swing. Needs ${RULES.trend_days} full days or more.`;
document.getElementById("r-events").innerHTML = REG.length ? REG.map(e => `
<details${e.jumps.length <= 4 ? " open" : ""}><summary><b>${e.start === e.end ? utc(e.start) : `${utc(e.start)} → ${utc(e.end)}`}</b>
document.getElementById("r-events").innerHTML = REG.length ? REG.map((e, n) => `
<details${e.jumps.length <= 4 ? " open" : ""}><summary data-k="e${n}"><b>${short(e.start)} → ${e.end.slice(0, 10) ===
e.start.slice(0, 10) ? e.end.slice(11, 16) : short(e.end)} UTC</b>
· ${e.targets.length === 1 ? `${e.targets[0]} alone` : `${e.targets.length} targets together`}</summary>
<table class="rtable"><thead><tr><th>Target</th><th>Axis</th><th>When</th><th>Jump</th><th>Usual daily swing</th>
<th>Left at end of data</th></tr></thead><tbody>${e.jumps.map(f => `
<tr data-target="${f.target}" data-t="${f.t2}" title="Open in Diagnosis"><td>${dot(f.target)}</td>
<td>${f.axis}</td><td>${utc(f.t)} → ${f.t2.slice(11, 16)}</td><td>${signed(f.jump)}</td><td>${f.swing.toFixed(1)} mm</td>
<table class="rtable"><thead><tr><th>Target</th><th>Axis</th><th>When (UTC)</th><th>Jump</th><th>Daily swing</th>
<th>Left at end</th></tr></thead><tbody>${e.jumps.map((f, m) => `
<tr data-k="j${n}-${m}" data-target="${f.target}" data-t="${f.t2}" title="Click: open in Diagnosis"><td>${dot(f.target)}</td>
<td>${f.axis}</td><td>${short(f.t)} → ${f.t2.slice(11, 16)}</td><td>${signed(f.jump)}</td><td>${f.swing.toFixed(1)} mm</td>
<td>${signed(f.left)}</td></tr>`).join("")}
</tbody></table></details>`).join("")
: '<p class="empty">No jump: no target changed suddenly and stayed there.</p>';
document.getElementById("r-trends").innerHTML = TRENDS.length ? `<table class="rtable"><thead><tr><th>Target</th><th>Axis</th>
<th>Drift over the period</th><th>Per day</th><th>Usual daily swing</th><th>Days</th><th>Jumps set aside</th></tr></thead>
<tbody>${TRENDS.map(f => `<tr data-target="${f.target}" data-t="${f.t}" title="Open in Diagnosis">
<th>Drift</th><th>Per day</th><th>Daily swing</th><th>Days</th><th>Jumps set aside</th></tr></thead>
<tbody>${TRENDS.map((f, n) => `<tr data-k="t${n}" data-target="${f.target}" data-t="${f.t}" title="Click: open in Diagnosis">
<td>${dot(f.target)}</td><td>${f.axis}</td><td>${signed(f.drift)}</td><td>${signed(f.slope, 2)}</td>
<td>${f.swing.toFixed(1)} mm</td><td>${f.days + 1}</td><td>${f.jumps || ""}</td></tr>`).join("")}</tbody></table>`
: '<p class="empty">No trend: no daily level drifted steadily by more than its daily swing.</p>';
@@ -783,26 +797,103 @@ document.getElementById("displacements").addEventListener("click", ev => { // u
drawCurves();
});
// Ce que montre le survol, par ligne (data-k) : la ou les cibles gardées en couleur, les autres en gris ; des formes et des
// annotations sur les courbes. Saut : ses 2 h surlignées, les niveaux des 24 h d'avant et d'après (médianes, ceux de la
// détection) en pointillés, une flèche de l'un à l'autre. Tendance : sa période, la droite de Theil-Sen en tirets, les
// niveaux journaliers en points, le début et la fin marqués, la dérive en flèche depuis le niveau de départ. Les échelles
// ne bougent pas au survol : on sait toujours ce qu'on regarde (utilisateur, 2026-10-19).
const AX = { horizontal: "y", vertical: "y2" };
const seg = (x0, x1, y0, y1, yref, line) => ({ type: "line", xref: "x", yref, x0, x1, y0, y1, line });
const zone = (x0, x1, fillcolor, opacity) => ({ type: "rect", xref: "x", yref: "paper", x0, x1, y0: 0, y1: 1, fillcolor, opacity,
line: { width: 0 }, layer: "below" });
const label = (x, y, yref, text, more) => ({ x, y, xref: "x", yref, text, showarrow: false, bgcolor: "rgba(255,255,255,.85)", borderpad: 3,
font: { size: 12, color: INK }, ...more });
const arrow = (x, from, to, yref) => ({ x, y: to, ax: x, ay: from, xref: "x", yref, axref: "x", ayref: yref, text: "",
showarrow: true, arrowhead: 2, arrowsize: 1.2, arrowwidth: 2, arrowcolor: INK });
const ITEMS = {};
REG.forEach((e, n) => {
ITEMS[`e${n}`] = { targets: e.targets, shapes: [zone(e.start, e.end, "#d03b3b", .15)] };
e.jumps.forEach((f, m) => {
const ya = AX[f.axis], up = f.jump > 0, small = { size: 11, color: INK };
ITEMS[`j${n}-${m}`] = { targets: [f.target],
shapes: [zone(f.t, f.t2, RCOL[f.target], .25),
seg(f.w0, f.t, f.before, f.before, ya, { color: INK, width: 2, dash: "dot" }),
seg(f.t2, f.w1, f.after, f.after, ya, { color: INK, width: 2, dash: "dot" })],
annotations: [arrow(f.t2, f.before, f.after, ya),
label(f.t2, (f.before + f.after) / 2, ya, `<b>${signed(f.jump)}</b> in 2 h<br>${f.target} ${f.axis}`,
{ xanchor: "left", xshift: 10, align: "left", bordercolor: RCOL[f.target] }),
label(f.w0, f.before, ya, "level, 24 h before", { xanchor: "left", yanchor: up ? "top" : "bottom", font: small }),
label(f.w1, f.after, ya, "level, 24 h after", { xanchor: "right", yanchor: up ? "bottom" : "top", font: small })] };
});
});
TRENDS.forEach((f, n) => {
const ya = AX[f.axis], L = f.line, [t0, y0] = L[0], [t1, y1] = L[L.length - 1], from = y1 - f.drift, up = f.drift > 0;
ITEMS[`t${n}`] = { targets: [f.target], yaxis: ya,
levels: f.levels, ends: [L[0], L[L.length - 1]],
shapes: [zone(t0, t1, RCOL[f.target], .07),
...L.slice(1).map((p, k) => seg(L[k][0], p[0], L[k][1], p[1], ya, { color: INK, width: 2.5, dash: "dash" })),
seg(t0, t1, from, from, ya, { color: INK, width: 1, dash: "dot" })],
annotations: [arrow(t1, from, y1, ya),
label(t1, (from + y1) / 2, ya, `<b>${signed(f.drift)}</b> from ${dm(t0)} to ${dm(t1)}<br>${signed(f.slope, 2)} per day`,
{ xanchor: "right", xshift: -10, align: "right", bordercolor: RCOL[f.target] }),
label(t0, y0, ya, `<b>start</b> ${dm(t0)} · ${y0.toFixed(1)} mm`, { xanchor: "left", yanchor: up ? "top" : "bottom",
yshift: up ? -8 : 8 }),
label(t1, y1, ya, `<b>end</b> ${dm(t1)} · ${y1.toFixed(1)} mm`, { xanchor: "right", yanchor: up ? "bottom" : "top",
yshift: up ? 8 : -8 })] };
});
const RNOTE = { text: "grey: the other targets · hourly export, in mm, hour start in UTC", xref: "paper", yref: "paper",
x: 1, y: 1.07, xanchor: "right", showarrow: false, font: { size: 11, color: "#73879c" } };
let FOCUS = null, OV = 0; // ligne survolée ; OV : index des deux traces du survol (niveaux journaliers, début et fin)
function focusOn(k) {
const gd = document.getElementById("r-curves");
if (k === FOCUS || !gd.data) return;
FOCUS = k;
document.querySelectorAll("#displacements [data-k]").forEach(e => e.classList.toggle("on", e.dataset.k === k));
const it = ITEMS[k], curves = gd.data.slice(0, OV), lit = n => it.targets.includes(n);
Plotly.restyle(gd, {
"line.color": curves.map(t => !it ? RCOL[t.name] || GREY : lit(t.name) ? RCOL[t.name] || INK : GREY),
"line.width": curves.map(t => !it ? (RCOL[t.name] ? 2 : 1) : lit(t.name) ? 2.5 : 1),
}, curves.map((_, i) => i));
const ov = it && it.levels ? [it.levels, it.ends] : [[], []];
Plotly.restyle(gd, { x: ov.map(p => p.map(q => q[0])), y: ov.map(p => p.map(q => q[1])), yaxis: it && it.yaxis || "y",
"marker.color": [it ? RCOL[it.targets[0]] : INK, INK] }, [OV, OV + 1]);
const upd = { shapes: it ? it.shapes : [], annotations: [RNOTE, ...(it && it.annotations || [])] };
Plotly.relayout(gd, upd);
}
document.querySelector("#displacements .rlist").addEventListener("mouseover", ev => { // hors d'une ligne : plus de survol
const el = ev.target.closest("[data-k]");
focusOn(el ? el.dataset.k : null);
});
function drawRegime() { // toutes les cibles en gris fin, celles qui ont sauté ou dérivé en couleur par-dessus
const grey = [], lit = [];
for (const [name, mm] of Object.entries(D.hourly.sensors)) [["h", "horizontal"], ["v", "vertical"]].forEach(([k, label], r) => {
const c = RCOL[name];
(c ? lit : grey).push({ type: "scatter", mode: "lines", x: D.hourly.times, y: mm[k], name, legendgroup: name,
showlegend: !!c && !r, yaxis: `y${r ? 2 : ""}`, line: { color: c || "#d3d8de", width: c ? 2 : 1 },
showlegend: !!c && !r && Object.keys(RCOL).length <= 8, yaxis: `y${r ? 2 : ""}`, line: { color: c || GREY, width: c ? 2 : 1 }, // légende au-delà de 8 : couvre les courbes
hovertemplate: `${name} · %{x|%d %b %H:%M} UTC (hour start)<br>${label} %{y:.2f} mm<extra></extra>` });
});
if (!grey.length && !lit.length) {
document.getElementById("r-curves").innerHTML = '<p class="empty">No hourly export: no displacement in mm.</p>';
return;
}
Plotly.newPlot("r-curves", [...grey, ...lit], {
height: 600, margin: { l: 70, r: 10, t: 40, b: 40 }, legend: { orientation: "h", x: 0, y: 1.07 },
xaxis: { type: "date", anchor: "y2" },
OV = grey.length + lit.length;
const over = (name, marker) => ({ type: "scatter", mode: "markers", x: [], y: [], name, showlegend: false, marker,
hovertemplate: `${name} · %{x|%d %b} · %{y:.2f} mm<extra></extra>` });
Plotly.newPlot("r-curves", [...grey, ...lit, over("daily level (median of the UTC day)", { size: 8, line: { color: "#fff", width: 1.5 } }),
over("trend line", { size: 12 })], {
height: Math.max(420, Math.min(640, innerHeight - 30)), margin: { l: 60, r: 10, t: 40, b: 40 },
legend: { orientation: "h", x: 0, y: 1.07 }, xaxis: { type: "date", anchor: "y2" },
yaxis: { domain: [0.53, 1], fixedrange: true, title: { text: "horizontal (mm)" } },
yaxis2: { domain: [0, 0.47], fixedrange: true, title: { text: "vertical (mm)" } },
annotations: [{ text: "grey: the other targets · hourly export, in mm, hour start in UTC", xref: "paper", yref: "paper",
x: 1, y: 1.07, xanchor: "right", showarrow: false, font: { size: 11, color: "#73879c" } }],
}, CONFIG).then(() => autoscale("r-curves"));
annotations: [RNOTE],
}, CONFIG).then(() => {
autoscale("r-curves");
Plotly.relayout("r-curves", { "xaxis.range": document.getElementById("r-curves").layout.xaxis.range.slice() }); // ordonnées
// fixées sur les données : les formes du survol ne les élargissent plus
if (ITEMS[ASKED.get("focus")]) focusOn(ASKED.get("focus")); // ligne survolée au départ (#focus=j0-0, t0…) : pour les captures
});
}
drawRegime();