Points: the plots rx, ry, error value (its threshold dashed) and image quality, stacked; the points from rx, ry, rejected measurements included

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
maximeandClaude Opus 5.5 committed 2026-11-20 08:41:06 +01:00
1 parent 810e349b42
commit 7ef808eee3
2 files changed
+49 -20

No files matched your search

+30 -12
View File
@@ -4,7 +4,8 @@ import { call, Selector } from "../common.jsx";
// Points: the point labels (labeling/points/, labeling/scripts/points.py), one boolean per measurement of a range, valid or
// not, set by hand: the ground truth of the benchmarks. Mainly on the runs of the emulator: the page starts on that source. A dataset per station and range, created with every point valid;
// one target at a time, corr_x above corr_y; a click on a point switches it, a box sets every point inside it (mode).
// one target at a time, its rx, ry, error value and image quality stacked on the same time; a click on a point of any plot
// switches it, a box sets every point inside it (mode).
// Each change is saved at once.
const VALID = "#2f9e44", INVALID = "#e03131";
const FONT = "Roboto, sans-serif";
@@ -75,7 +76,14 @@ export default function Points({ selection, choose }) {
);
}
// corr_x above corr_y (px, the curves labelled), sharing the time; the points green valid, red invalid
// The plots, top to bottom, those the sensor has (validity.COLUMNS): [column, title, unit of the tooltip]; the threshold
// of the error drawn dashed on its plot
const PANELS = [["relative_x", "rx [px]", " px"], ["relative_y", "ry [px]", " px"], ["error_value", "Error value", ""],
["peak", "Peak", ""], ["flux", "Flux", ""], ["sharpness", "Sharpness", ""], ["fwhm", "FWHM [px]", " px"],
["dominance", "Dominance", ""], ["snr", "SNR", ""]];
const ROW = 170, GAP = 0.012; // px per plot; space between plots (fraction of the height)
// the points green valid, red invalid, the same point at the same index on every plot
function Plot({ o, sensor, set, mode }) {
const g = useRef(), [Plotly, setPlotly] = useState(null), dark = useComputedColorScheme("light") === "dark";
const latest = useRef();
@@ -84,21 +92,31 @@ function Plot({ o, sensor, set, mode }) {
useEffect(() => {
if (!Plotly) return;
const color = o.valid.map(v => (v ? VALID : INVALID)), text = dark ? "#c9c9c9" : "#495057", grid = dark ? "#2e2e2e" : "#eef0f2";
const trace = (y, yaxis) => ({ type: "scattergl", mode: "lines+markers", x: o.t, y, yaxis, hovertemplate: "%{x}<br>%{y:.4f} px<extra></extra>",
line: { width: 1, color: dark ? "#555" : "#ccc" }, marker: { size: 6, color }, unselected: { marker: { opacity: 1 } } });
const axis = { gridcolor: grid, zeroline: false };
Plotly.react(g.current, [trace(o.x, "y"), trace(o.y, "y2")], {
height: 560, margin: { l: 60, r: 20, t: 10, b: 30 }, showlegend: false, dragmode: "select", selectdirection: "any",
const panels = PANELS.filter(([c]) => o.columns[c]), n = panels.length, h = (1 - GAP * (n - 1)) / n;
const axis = { gridcolor: grid, zeroline: false }, layout = {}, traces = [];
panels.forEach(([c, title, unit], k) => {
const y = k ? `y${k + 1}` : "y", top = 1 - k * (h + GAP);
layout[k ? `yaxis${k + 1}` : "yaxis"] = { ...axis, domain: [Math.max(0, top - h), top], title: { text: title, font: { size: 11 } } };
traces.push({ type: "scattergl", mode: "lines+markers", x: o.t, y: o.columns[c], yaxis: y, meta: "point",
hovertemplate: `%{x}<br>${title}: %{y:.4f}${unit}<extra></extra>`, line: { width: 1, color: dark ? "#555" : "#ccc" },
marker: { size: 5, color }, unselected: { marker: { opacity: 1 } } });
if (c === "error_value" && o.columns.error_threshold)
traces.push({ type: "scattergl", mode: "lines", x: o.t, y: o.columns.error_threshold, yaxis: y, meta: "threshold", hoverinfo: "skip",
line: { width: 1, dash: "dash", color: INVALID } });
});
Plotly.react(g.current, traces, {
...layout, height: ROW * n + 40, margin: { l: 70, r: 20, t: 10, b: 30 }, showlegend: false, dragmode: "select", selectdirection: "any",
uirevision: sensor, paper_bgcolor: "rgba(0,0,0,0)", plot_bgcolor: "rgba(0,0,0,0)", font: { family: FONT, size: 11, color: text },
grid: { rows: 2, columns: 1, shared_xaxes: true }, xaxis: { ...axis, anchor: "y2" },
yaxis: { ...axis, domain: [0.53, 1], title: { text: "corr_x [px]" } }, yaxis2: { ...axis, domain: [0, 0.47], title: { text: "corr_y [px]" } },
xaxis: { ...axis, anchor: n > 1 ? `y${n}` : "y" },
}, { responsive: true, displaylogo: false, doubleClick: "reset", modeBarButtonsToRemove: ["lasso2d", "autoScale2d", "toggleSpikelines"] });
if (!g.current._bound) { // once per plot: the handlers read the latest state
g.current._bound = true;
g.current.on("plotly_click", ev => { const i = ev.points[0].pointIndex; latest.current.set([i], !latest.current.o.valid[i]); });
const ofPoints = ps => ps.filter(p => p.data.meta === "point").map(p => p.pointIndex);
g.current.on("plotly_click", ev => { const [i] = ofPoints(ev.points); if (i !== undefined) latest.current.set([i], !latest.current.o.valid[i]); });
g.current.on("plotly_selected", ev => {
if (!ev?.points?.length) return;
latest.current.set([...new Set(ev.points.map(p => p.pointIndex))], latest.current.mode === "valid");
const is = [...new Set(ofPoints(ev?.points || []))];
if (!is.length) return;
latest.current.set(is, latest.current.mode === "valid");
Plotly.relayout(g.current, { selections: [] });
});
}