Detect every jump and the trends in the Displacements page (D-055)

Jumps: a sudden change within 2 h (8 times the target's usual 2-hour
change) that lasts 24 h (at least 1.4 times its daily swing); every
jump of the range, returns included, so PR17's return on 12/10 now
shows. Trends: Theil-Sen slope and Kendall tau of the daily levels,
jumps set aside, kept when the drift over the period reaches the daily
swing and goes steadily one way. Provisional thresholds; method and
results in vues-deplacements/contexte/detection-d-anomalies.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
maximeandClaude Opus 5.5 committed 2026-10-16 18:22:54 +02:00
1 parent 261f8c9038
commit d07edace60
5 files changed
+152 -58

No files matched your search

@@ -111,10 +111,12 @@
#d-request p { margin: 4px 0; color: var(--text); }
/* Page Displacements (D-055) : un événement par groupe de sauts, ses sauts en tableau, puis les courbes en mm. */
#p-displacements .note { margin: 14px 6px; }
#p-displacements .note { margin: 0 6px 10px; }
#p-displacements .sub { margin: 18px 6px 6px; }
#r-trends { margin: 0 6px 12px; }
#r-events details { margin: 0 6px 12px; color: var(--text); }
#r-events summary { font-size: 15px; cursor: pointer; padding: 4px 0; }
.rtable { border-collapse: collapse; width: 100%; margin-top: 4px; }
.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 tbody tr { cursor: pointer; }
@@ -153,8 +155,12 @@
<main>
<section class="panel" id="p-displacements" hidden>
<div class="panel-title"><h2><!--PLATFORM--><small>Displacements</small></h2></div>
<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>
</section>
<section class="panel" id="p-explore">
@@ -738,26 +744,38 @@ if (ASKED.get("img")) { const k = nearestIndex(Date.parse(ASKED.get("img"))); if
if (IM.length) setCompare(cmp);
else document.querySelector("#view .viewer").innerHTML = '<p class="empty">No image in this folder.</p>';
// Page Displacements (D-055) : les sauts de niveau qui durent (déplacements permanents), calculés par explore.py
// (regime_changes), groupés en événements ; puis toutes les courbes en mm, en gris, celles qui ont sauté en couleur. Un
// clic sur un saut ouvre Explore, onglet Diagnosis, sur cette cible à cette heure. Données inchangées.
const REG = D.regime, RCOL = {};
REG.forEach(e => e.targets.forEach(n => { if (!(n in RCOL)) RCOL[n] = PALETTE[Object.keys(RCOL).length % PALETTE.length]; }));
const signed = v => `${v > 0 ? "+" : v < 0 ? "−" : ""}${Math.abs(v).toFixed(1)} mm`;
document.getElementById("r-note").textContent = `Permanent displacements: a target whose level over the next 24 h differs ` +
`from its level over the previous 24 h by more than ${D.ratio} × its usual daily swing (median of max − min per UTC day). ` +
`Daily and weather cycles come back; these jumps lasted at least 24 h. Jumps within 6 h of each other form one event. ` +
`Hourly export in mm, unchanged.`;
// Page 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 Explore, onglet Diagnosis, sur cette cible à cette heure. Données inchangées.
const REG = D.regime, TRENDS = D.trends, RCOL = {}, RULES = D.rules;
[...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}`;
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 ` +
`and come back; these do not. Jumps within 6 h of each other form one event. Hourly export in mm, unchanged.`;
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>
· ${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>From</th><th>Jump</th><th>Usual daily swing</th>
<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.t}" title="Open in Explore · Diagnosis"><td><i style="background:${RCOL[f.target]}"></i>${f.target}</td>
<td>${f.axis}</td><td>${utc(f.t)}</td><td>${signed(f.jump)}</td><td>${f.swing.toFixed(1)} mm</td><td>${signed(f.left)}</td></tr>`).join("")}
<tr data-target="${f.target}" data-t="${f.t2}" title="Open in Explore · 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>
<td>${signed(f.left)}</td></tr>`).join("")}
</tbody></table></details>`).join("")
: `<p class="empty">No permanent displacement: no target's level jumped by more than ${D.ratio} × its daily swing.</p>`;
document.getElementById("r-events").addEventListener("click", ev => { // un saut : Explore, Diagnosis, cette cible à cette heure
: '<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 Explore · 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>';
document.getElementById("p-displacements").addEventListener("click", ev => { // une ligne : Explore, Diagnosis, cette cible
const tr = ev.target.closest("tr[data-target]");
if (!tr) return;
goPage("explore");
@@ -769,7 +787,7 @@ document.getElementById("r-events").addEventListener("click", ev => { // un sau
drawCurves();
});
function drawRegime() { // toutes les cibles en gris fin, celles qui ont sauté en couleur par-dessus
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];