diff --git a/frontend/src/components/RugnuxCollectionPlots.tsx b/frontend/src/components/RugnuxCollectionPlots.tsx
new file mode 100644
index 000000000..7cdf6882e
--- /dev/null
+++ b/frontend/src/components/RugnuxCollectionPlots.tsx
@@ -0,0 +1,97 @@
+import {Box, Typography, useTheme} from "@mui/material";
+import {useQuery} from "@tanstack/react-query";
+import {plot_type, rugnux_live_status} from "../client";
+import {getPreviewPlotOptions} from "../client/@tanstack/react-query.gen";
+import Plot from "./Plot";
+import {livePalette} from "../livePalette";
+
+// The collection image by image, in two small panels on one image axis: the spots found and the background
+// of every image as the broker's spot finder saw them (the receiver's plots), and what the merge made of the
+// frames - rotation: the per-image scale factor of the merge with the stretches it downgraded (amber) or
+// rejected (red) as bands over both panels, each with the reason it saw; serial: the indexing rate. The
+// second panel is empty until there is a merge.
+
+const PLOT_MARGIN = {t: 6, b: 22, l: 42, r: 42};
+
+// Points of one receiver plot, polled while the run is on; coarser bins on a long serial collection
+function useCollectionPlot(type: plot_type, s: rugnux_live_status) {
+ const binning = Math.max(1, Math.ceil(s.images_expected / 3000));
+ const {data} = useQuery({
+ ...getPreviewPlotOptions({query: {type, binning}}),
+ refetchInterval: s.state === "Running" ? 2000 : false,
+ });
+ const p = data?.plot?.[0];
+ return p && p.x.length > 0 ? {x: p.x, y: p.y} : undefined;
+}
+
+function Empty({text}: { text: string }) {
+ return {text};
+}
+
+function RugnuxCollectionPlots({s, height}: { s: rugnux_live_status, height: number }) {
+ const theme = useTheme();
+ const pal = livePalette(theme.palette.mode);
+ // type that grows with the strip, so a 4k screen does not get 11 px labels
+ const size = Math.round(Math.min(16, Math.max(10, height / 15)));
+ const font = {color: theme.palette.text.secondary, size};
+ const axis = {gridcolor: pal.grid, zerolinecolor: pal.grid, tickfont: {size: size - 1}};
+ const title = (text: string, color: string) => ({text, standoff: 4, font: {size: size - 1, color}});
+ const spots = useCollectionPlot(plot_type.SPOT_COUNT, s);
+ const bkg = useCollectionPlot(plot_type.BKG_ESTIMATE, s);
+ const indexing = useCollectionPlot(plot_type.INDEXING_RATE, s);
+ const scales = s.frame_scales;
+ const images = Math.max(s.images_expected, s.images_received, 1);
+
+ const common = {paper_bgcolor: "rgba(0,0,0,0)", plot_bgcolor: "rgba(0,0,0,0)", font, height, margin: PLOT_MARGIN,
+ showlegend: false, xaxis: {...axis, range: [0, images - 1], title: {text: "image", standoff: 2, font: {size: size - 1}}}};
+ const config = {responsive: true, displayModeBar: false};
+ const panelSx = {display: "flex", minWidth: 0, bgcolor: pal.panel, borderRadius: 1, height};
+
+ // amber and red bands where the merge downgraded or rejected the frames, their reason written over them
+ const bands = (s.frame_ranges ?? []).map(r => ({
+ type: "rect" as const, xref: "x" as const, yref: "paper" as const, x0: r.first_image - 0.5, x1: r.last_image + 0.5, y0: 0, y1: 1,
+ fillcolor: r.disposition === "rejected" ? pal.bands.rejected : pal.bands.downgraded, line: {width: 0}, layer: "below" as const,
+ }));
+ const bandLabels = (s.frame_ranges ?? []).map(r => ({
+ x: (r.first_image + r.last_image) / 2, y: 1, xref: "x" as const, yref: "paper" as const, yanchor: "top" as const,
+ text: r.reason || r.disposition, showarrow: false, font: {size: size - 2, color: r.disposition === "rejected" ? pal.serious : pal.attention},
+ }));
+
+ return (
+
+
+ {spots || bkg
+ ?
+ : }
+
+
+ {s.stills
+ ? (indexing
+ ?
+ : )
+ : (scales && scales.length > 0
+ ? i), y: scales.map(g => g > 0 ? g : null), type: "scatter", mode: "lines",
+ name: "scale", line: {color: pal.traces[2], width: 1.2}, connectgaps: false}]}
+ layout={{...common, uirevision: "scales", shapes: bands, annotations: bandLabels,
+ yaxis: {...axis, rangemode: "tozero", title: title("scale", pal.traces[2])}}}/>
+ : )}
+
+
+ );
+}
+
+export default RugnuxCollectionPlots;
diff --git a/frontend/src/components/RugnuxHero.tsx b/frontend/src/components/RugnuxHero.tsx
index bbd486e67..6c3d74a3e 100644
--- a/frontend/src/components/RugnuxHero.tsx
+++ b/frontend/src/components/RugnuxHero.tsx
@@ -1,5 +1,4 @@
import {Box, Tooltip, Typography} from "@mui/material";
-import {green, red} from "@mui/material/colors";
import {keyframes} from "@mui/system";
import {rugnux_live_status} from "../client";
@@ -35,19 +34,19 @@ export function SpaceGroup({hm}: { hm: string }) {
type Tone = "plain" | "pending" | "good" | "bad";
-const VALUE_COLOUR: Record = {plain: "text.primary", pending: "text.disabled", good: green[300], bad: red[300]};
+const VALUE_COLOUR: Record = {plain: "text.primary", pending: "text.disabled", good: "success.main", bad: "error.main"};
function Tile({value, caption, tip, tone}: { value: React.ReactNode, caption: string, tip: React.ReactNode, tone: Tone }) {
return (
-
-
+
+
{caption}
diff --git a/frontend/src/components/RugnuxImage.tsx b/frontend/src/components/RugnuxImage.tsx
new file mode 100644
index 000000000..76e88303b
--- /dev/null
+++ b/frontend/src/components/RugnuxImage.tsx
@@ -0,0 +1,92 @@
+import {useEffect, useRef, useState} from "react";
+import {Box, Tooltip, Typography, useTheme} from "@mui/material";
+import {TransformComponent, TransformWrapper} from "react-zoom-pan-pinch";
+import {color_scale} from "../client";
+import {authHeaders, noteResponse} from "../auth";
+
+// The diffraction image the broker is on, as a square window of the live page: the last image of the buffer
+// (or the last indexed one), with its spots, the beam centre and the resolution estimate drawn by the broker
+// (`/image_buffer/image.jpeg`), fetched every two seconds while images come in. Wheel to zoom, drag to pan,
+// nothing else on screen but three pills: which image, spots on or off, predictions on or off. White with
+// indigo by day, black with white by night.
+
+type Props = { measuring: boolean };
+
+const POLL_MS = 2000;
+
+function Pill({on, label, tip, onClick}: { on: boolean, label: string, tip: string, onClick: () => void }) {
+ return (
+
+
+ {label}
+
+
+ );
+}
+
+function RugnuxImage({measuring}: Props) {
+ const dark = useTheme().palette.mode === "dark";
+ const [indexed, setIndexed] = useState(false);
+ const [spots, setSpots] = useState(true);
+ const [predictions, setPredictions] = useState(false);
+ const [url, setUrl] = useState();
+ const [missing, setMissing] = useState(false);
+ const urlRef = useRef(undefined);
+
+ const query = `id=${indexed ? -2 : -1}&show_spots=${spots}&show_predictions=${predictions}&show_beam_center=true`
+ + `&show_res_est=true&jpeg_quality=85&color=${dark ? color_scale.WB : color_scale.INDIGO}`;
+
+ // One fetch per change of the query, then every POLL_MS while measuring; the object URL of the image on
+ // screen is released as the next one replaces it, and on unmount.
+ useEffect(() => {
+ let alive = true;
+ const fetchImage = () => fetch(`/image_buffer/image.jpeg?${query}`, {headers: authHeaders()})
+ .then(r => { noteResponse(r); if (!r.ok) throw new Error(r.statusText); return r.blob(); })
+ .then(blob => {
+ if (!alive)
+ return;
+ const next = URL.createObjectURL(blob);
+ if (urlRef.current)
+ URL.revokeObjectURL(urlRef.current);
+ urlRef.current = next;
+ setUrl(next);
+ setMissing(false);
+ })
+ .catch(() => { if (alive) setMissing(true); });
+ fetchImage();
+ const timer = measuring ? setInterval(fetchImage, POLL_MS) : undefined;
+ return () => {
+ alive = false;
+ if (timer)
+ clearInterval(timer);
+ };
+ }, [query, measuring]);
+ useEffect(() => () => { if (urlRef.current) URL.revokeObjectURL(urlRef.current); }, []);
+
+ return (
+
+ {url && !missing
+ ?
+
+
+
+
+ : no image}
+
+ setIndexed(i => !i)}
+ tip={indexed ? "The last image that indexed; click for the last image" : "The last image; click for the last that indexed"}/>
+ setSpots(s => !s)} tip="The spots found on the image"/>
+ setPredictions(p => !p)} tip="Where the lattice predicts reflections"/>
+
+
+ );
+}
+
+export default RugnuxImage;
diff --git a/frontend/src/components/RugnuxPage.tsx b/frontend/src/components/RugnuxPage.tsx
index 463fa019f..355deba74 100644
--- a/frontend/src/components/RugnuxPage.tsx
+++ b/frontend/src/components/RugnuxPage.tsx
@@ -1,10 +1,10 @@
-import {Alert, Box, Button, Collapse, Paper, Stack, ThemeProvider, Typography, createTheme} from "@mui/material";
-import {green, indigo, lime, orange, red, grey} from "@mui/material/colors";
+import {Alert, Box, Button, Collapse, Paper, Stack, Typography, useTheme} from "@mui/material";
import {keyframes} from "@mui/system";
import {useQuery} from "@tanstack/react-query";
import {getConfigRugnuxOptions, getRugnuxStatusOptions} from "../client/@tanstack/react-query.gen";
import {rugnux_live_status} from "../client";
import {useTokenRequired} from "../auth";
+import {LivePalette, livePalette} from "../livePalette";
import EmptyState from "./EmptyState";
import RugnuxTriage from "./RugnuxTriage";
import RugnuxTimeline from "./RugnuxTimeline";
@@ -13,35 +13,26 @@ import RugnuxHero from "./RugnuxHero";
import RugnuxStills from "./RugnuxStills";
import RugnuxShellPlots from "./RugnuxShellPlots";
import RugnuxProgress from "./RugnuxProgress";
+import RugnuxImage from "./RugnuxImage";
+import RugnuxCollectionPlots from "./RugnuxCollectionPlots";
import {lastImageTime, ModelScores, StepTable, VerdictAlert} from "./RugnuxParts";
import BoltIcon from "@mui/icons-material/Bolt";
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
import {lazy, Suspense, useEffect, useRef, useState} from "react";
-// The live page as one control-room screen: a dark stage the height of the window, edged in the colour of the
-// run's phase. Across the top, the phase, the two progress bars (the detector's and rugnux's) and the clock the
-// run is judged by. Below, three columns: the hero numbers of the merge as a rail at the left, the placed model
-// in Mol* filling the centre (the run's steps until there is one), and at the right the triage list over the
-// merging statistics by shell. Everything else - the timeline, step notes, summary rows, warnings, the serial
-// pre-pass geometry - sits under a "Details" fold below the stage, and the settings under that, on the page's
-// ordinary light background.
+// The live page as one control-room screen, in the app's own light or dark: a stage the height of the window,
+// edged in the colour of the run's phase, that shows everything at once - images, structure, statistics.
+// Across the top, the phase, the two progress bars (the detector's and rugnux's) and the clock the run is
+// judged by. Below, left to right: the hero numbers of the merge as a rail, the diffraction image the broker
+// is on, the placed model in Mol* (the run's step until there is one), and the triage badges over the merging
+// statistics by shell. Under the image and the model, the collection image by image: spots and background,
+// and the per-image scale with the frames the merge left out. Everything else - the timeline, step notes,
+// summary rows, warnings, the serial pre-pass geometry - sits under a "Details" fold below the stage, and the
+// settings under that.
// Mol* is large: loaded only when there is a model to show.
const RugnuxStructureViewer = lazy(() => import("./RugnuxStructureViewer"));
-// The dark room: the app's indigo/lime, on a navy stage the viewer's black blends into.
-const liveTheme = createTheme({
- palette: {
- mode: "dark",
- primary: {main: indigo[300]},
- secondary: {main: lime[500]},
- background: {default: "#0b0f1d", paper: "#151c33"},
- text: {primary: "#e9edf7", secondary: "#9aa5c4", disabled: "#596483"},
- divider: "rgba(154,165,196,.2)",
- },
- shape: {borderRadius: 8},
-});
-
const pulse = keyframes`
0%, 100% { opacity: 1; }
50% { opacity: .45; }
@@ -51,30 +42,30 @@ const LABEL_SX = {fontSize: "0.7rem", fontWeight: 700, letterSpacing: ".1em", te
color: "text.secondary", whiteSpace: "nowrap" as const, overflow: "hidden", textOverflow: "ellipsis"};
// What the run is doing, in one word, with the colour the rest of the screen takes from it.
-function phase(s: rugnux_live_status): { label: string, colour: string } {
+function phase(s: rugnux_live_status, pal: LivePalette): { label: string, colour: string } {
if (s.state === "Running")
return lastImageTime(s) === undefined
- ? {label: "Collecting", colour: lime[500]} : {label: "Processing", colour: indigo[300]};
+ ? {label: "Collecting", colour: pal.collecting} : {label: "Processing", colour: pal.processing};
if (s.state === "Done")
- return s.verdict === "OK" ? {label: "Done", colour: green[400]}
- : s.verdict === "WARNINGS" ? {label: "Done · warnings", colour: orange[400]}
- : {label: `Done · ${s.verdict.toLowerCase()}`, colour: red[400]};
+ return s.verdict === "OK" ? {label: "Done", colour: pal.ok}
+ : s.verdict === "WARNINGS" ? {label: "Done · warnings", colour: pal.attention}
+ : {label: `Done · ${s.verdict.toLowerCase()}`, colour: pal.serious};
if (s.state === "Failed")
- return {label: "Failed", colour: red[400]};
- return {label: s.state, colour: grey[500]};
+ return {label: "Failed", colour: pal.serious};
+ return {label: s.state, colour: "text.disabled"};
}
// Phase, the progress block and the clock: the number the run is judged by - seconds since the first image
// while it runs, from the last image to all results written once it is over.
-function Header({s, deadline_s}: { s: rugnux_live_status, deadline_s: number }) {
- const p = phase(s);
+function Header({s, deadline_s, pal}: { s: rugnux_live_status, deadline_s: number, pal: LivePalette }) {
+ const p = phase(s, pal);
const running = s.state === "Running";
const lastImage = lastImageTime(s);
const latency = s.last_image_to_written_s;
const clock = latency !== undefined
? {caption: "last image → written", value: latency, colour: p.colour}
: lastImage !== undefined
- ? {caption: "since last image", value: s.elapsed_s - lastImage, colour: indigo[200]}
+ ? {caption: "since last image", value: s.elapsed_s - lastImage, colour: pal.processing}
: {caption: "since first image", value: s.elapsed_s, colour: "text.primary"};
const deadline = running && lastImage !== undefined && deadline_s > 0 ? lastImage + deadline_s - s.elapsed_s : undefined;
@@ -97,7 +88,7 @@ function Header({s, deadline_s}: { s: rugnux_live_status, deadline_s: number })
{clock.value.toFixed(1)}s
-
+
{deadline !== undefined ? `deadline in ${Math.max(0, deadline).toFixed(0)} s` : ""}
@@ -111,7 +102,7 @@ function Later({text}: { text: string }) {
// The step rugnux is on, large with its progress, filling the centre until there is a model to show; the
// steps behind it are on the strip under the bars.
-function RunConsole({s}: { s: rugnux_live_status }) {
+function RunConsole({s, pal}: { s: rugnux_live_status, pal: LivePalette }) {
const running = s.state === "Running";
const current = running && s.steps.length > 0 && s.steps[s.steps.length - 1].duration_s === undefined
? s.steps[s.steps.length - 1] : undefined;
@@ -119,10 +110,10 @@ function RunConsole({s}: { s: rugnux_live_status }) {
return ;
return (
- now
+ now
- {current.title}{s.step_progress !== undefined && {(100 * s.step_progress).toFixed(0)} %}
+ {current.title}{s.step_progress !== undefined && {(100 * s.step_progress).toFixed(0)} %}
);
@@ -138,7 +129,7 @@ function Division({label, children, sx}: { label?: React.ReactNode, children: Re
);
}
-function Centre({s}: { s: rugnux_live_status }) {
+function Centre({s, pal}: { s: rugnux_live_status, pal: LivePalette }) {
const m = s.model;
// The model shows once a rotation run is over; serial data place it on each provisional merge, and the viewer
// reloads when the model step has a new result, not every time the status is polled.
@@ -157,10 +148,10 @@ function Centre({s}: { s: rugnux_live_status }) {
);
}
- return ;
+ return ;
}
-// Height of an element in px, kept up to date as the page resizes: the shell plots need theirs in pixels.
+// Height of an element in px, kept up to date as the page resizes: the plots need theirs in pixels.
function useHeight() {
const ref = useRef(null);
const [height, setHeight] = useState(0);
@@ -174,42 +165,58 @@ function useHeight() {
return [ref, height] as const;
}
-function Dashboard({s, deadline_s, modelLoaded}: { s: rugnux_live_status, deadline_s: number, modelLoaded: boolean }) {
+// The height of the collection strip and the side of the image window, from the window's height so the
+// stage holds everything without scrolling: the image takes what the header and the strip leave.
+const STRIP = "clamp(150px, 11vh, 260px)";
+const IMAGE = "clamp(240px, min(calc(88vh - 430px), 30vw), 1500px)";
+const RAIL = "clamp(200px, 12vw, 420px)";
+
+function Dashboard({s, deadline_s, modelLoaded, measuring, pal}:
+ { s: rugnux_live_status, deadline_s: number, modelLoaded: boolean, measuring: boolean, pal: LivePalette }) {
const [plotsRef, plotsHeight] = useHeight();
+ const [stripRef, stripHeight] = useHeight();
const later = s.stills ? "after the first merge" : "after the run";
- const hairline = {borderLeft: {lg: "1px solid"}, borderColor: {lg: "divider"}, pl: {lg: 2.5}};
+ const hairline = {borderLeft: {xl: "1px solid"}, borderColor: {xl: "divider"}, pl: {xl: 2.5}};
return (
-
+
-
+ gridTemplateColumns: {xs: "1fr", md: `${RAIL} minmax(0, 1fr)`, xl: `${RAIL} ${IMAGE} minmax(0, 1fr) minmax(360px, 27%)`},
+ gridTemplateRows: {xs: "auto", xl: `minmax(0, 1fr) ${STRIP}`}}}>
+
-
-
+
+
+
+
+
-
+
*": {flexShrink: 0}}}>
{s.triage && s.triage.length > 0 ? : }
By resolution{s.stills && s.shells_merge && ` · ${s.shells_merge}`}>}>
-
+
{s.shells && s.shells.length > 0
?
-
+
: }
+
+
+
+
+
);
}
-// What the stage leaves out, on the light page: the timeline, the steps with their notes, the summary rows
+// What the stage leaves out, below it: the timeline, the steps with their notes, the summary rows
// and warnings, the model's scores, and the serial pre-pass geometry.
function Details({s, deadline_s}: { s: rugnux_live_status, deadline_s: number }) {
const [open, setOpen] = useState(false);
@@ -254,6 +261,7 @@ function RugnuxPage({measuring}: { measuring: boolean }) {
enabled,
});
const tokenRequired = useTokenRequired();
+ const pal = livePalette(useTheme().palette.mode);
let empty;
if (settings !== undefined && !enabled)
@@ -264,20 +272,18 @@ function RugnuxPage({measuring}: { measuring: boolean }) {
empty = "No rugnux run yet - start a collection with live processing enabled";
// The stage is the height of the window less the app's bars, so the essentials never scroll on a desktop
- // screen; below the lg breakpoint it flows.
+ // screen; below the xl breakpoint it flows.
return (
-
-
- {empty || !s
- ?
- } text={empty ?? ""}/>
-
- : }
-
-
+
+ {empty || !s
+ ?
+ } text={empty ?? ""}/>
+
+ : }
+
{s && !empty && }
diff --git a/frontend/src/components/RugnuxParts.tsx b/frontend/src/components/RugnuxParts.tsx
index 7dfce46b0..e84c33716 100644
--- a/frontend/src/components/RugnuxParts.tsx
+++ b/frontend/src/components/RugnuxParts.tsx
@@ -1,6 +1,6 @@
import {Alert, AlertTitle, Box, Chip, Paper, Table, TableBody, TableCell, TableContainer, TableRow, Typography} from "@mui/material";
import {indigo, lime, deepOrange, grey} from "@mui/material/colors";
-import {SxProps, Theme} from "@mui/material/styles";
+import {alpha, SxProps, Theme} from "@mui/material/styles";
import {rugnux_live_model, rugnux_live_status, rugnux_live_step} from "../client";
// Pieces of the rugnux live status shared by the dashboard card and the Rugnux page.
@@ -119,10 +119,11 @@ export function StepTable({steps}: { steps: rugnux_live_step[] }) {
function ScoreTile({label, value, sub, accent}: { label: string, value: string, sub?: string, accent?: boolean }) {
return (
+ bgcolor: t => accent ? alpha(t.palette.primary.main, 0.08) : "action.hover",
+ borderColor: t => accent ? alpha(t.palette.primary.main, 0.2) : "divider"}}>
{label}
-
{value}
{sub && {sub}}
diff --git a/frontend/src/components/RugnuxProgress.tsx b/frontend/src/components/RugnuxProgress.tsx
index 2daddc425..92a64e1f8 100644
--- a/frontend/src/components/RugnuxProgress.tsx
+++ b/frontend/src/components/RugnuxProgress.tsx
@@ -1,9 +1,9 @@
import {useEffect, useRef, useState} from "react";
-import {Box, Tooltip, Typography} from "@mui/material";
+import {Box, Tooltip, Typography, useTheme} from "@mui/material";
import {keyframes} from "@mui/system";
-import {deepOrange, grey, indigo, lime} from "@mui/material/colors";
import {rugnux_live_status, rugnux_live_step} from "../client";
import {lastImageTime} from "./RugnuxParts";
+import {inkOn, LivePalette, livePalette} from "../livePalette";
// The detector's and rugnux's progress one under the other on one time axis (seconds since the first image):
// the detector's bar fills as images arrive, up to the collection's expected end; rugnux's bar is its steps,
@@ -38,28 +38,18 @@ const TAGS: [RegExp, string][] = [
];
const tagOf = (title: string) => TAGS.find(([re]) => re.test(title))?.[1] ?? title.split(/[\s,]/)[0].slice(0, 6);
-// One colour per kind of step - Okabe-Ito, which keeps its kinds apart for colour-blind readers too, with
-// its blue lightened for the dark stage; a kind not in the table takes the next free one.
-const KIND_COLOURS: Record = {
- Pre: "#56B4E9", Spots: "#E69F00", Idx: "#F0E442", Int: "#3C8DD6", GPU: "#3C8DD6", Scale: "#009E73",
- Merge: "#009E73", MR: "#CC79A7", Ref: "#D55E00", Out: "#9E9E9E",
-};
-const SPARE_COLOURS = ["#8DD3C7", "#BEBADA", "#FB8072", "#FDB462", "#B3DE69"];
-function kindColours(steps: rugnux_live_step[]) {
- const colours: Record = {...KIND_COLOURS};
+// One colour per kind of step (livePalette: Okabe-Ito, which keeps its kinds apart for colour-blind readers
+// too); a kind not in the table takes the next free one.
+function kindColours(steps: rugnux_live_step[], pal: LivePalette) {
+ const colours: Record = {...pal.kinds};
let spare = 0;
for (const st of steps) {
const tag = tagOf(st.title);
if (!(tag in colours))
- colours[tag] = SPARE_COLOURS[spare++ % SPARE_COLOURS.length];
+ colours[tag] = pal.spare[spare++ % pal.spare.length];
}
return colours;
}
-// dark text on the light colours
-const inkOn = (hex: string) => {
- const [r, g, b] = [1, 3, 5].map(i => parseInt(hex.slice(i, i + 2), 16));
- return 0.299 * r + 0.587 * g + 0.114 * b > 150 ? "rgba(0,0,0,.85)" : "#fff";
-};
const BAR = 20;
const GAP = 6;
@@ -92,6 +82,7 @@ function useWidth() {
const seconds = (t: number) => `${t.toFixed(1)} s`;
function RugnuxProgress({s, deadline_s}: { s: rugnux_live_status, deadline_s: number }) {
+ const pal = livePalette(useTheme().palette.mode);
const running = s.state === "Running";
const lastImage = lastImageTime(s);
const collecting = running && lastImage === undefined;
@@ -117,7 +108,7 @@ function RugnuxProgress({s, deadline_s}: { s: rugnux_live_status, deadline_s: nu
: s.cut ? `cut (${s.cut})` : `${s.steps.length} steps · ${seconds(s.elapsed_s)}`;
const stepEnd = (i: number) => s.steps[i].duration_s === undefined ? s.elapsed_s : s.steps[i].started_s + s.steps[i].duration_s!;
- const colours = kindColours(s.steps);
+ const colours = kindColours(s.steps, pal);
const tags = s.steps.map(st => tagOf(st.title));
// consecutive steps of one kind (the passes) as one chip, with their time together
const kinds: { tag: string, titles: string[], seconds: number, open: boolean }[] = [];
@@ -137,20 +128,20 @@ function RugnuxProgress({s, deadline_s}: { s: rugnux_live_status, deadline_s: nu
{/* captions */}
- Detector
- Rugnux
+ Detector
+ Rugnux
{/* the two bars on one axis, the axis under them */}
-
-
+
{collecting && expectedEnd > collectionEnd &&
}
+ top: 0, bottom: 0, border: `1px dashed ${pal.collecting}`, borderLeft: "none", borderRadius: "0 4px 4px 0"}}/>}
-
+
{s.steps.map((st, i) => {
const open = st.duration_s === undefined;
const width = Math.max(pct(stepEnd(i)) - pct(st.started_s), 0.3);
@@ -185,12 +176,12 @@ function RugnuxProgress({s, deadline_s}: { s: rugnux_live_status, deadline_s: nu
{lastImage !== undefined &&
+ borderLeft: "2px solid", borderColor: "text.secondary"}}/>
}
{deadline !== undefined &&
+ borderLeft: `2px dashed ${pal.attention}`}}/>
}
@@ -210,7 +201,7 @@ function RugnuxProgress({s, deadline_s}: { s: rugnux_live_status, deadline_s: nu
{kinds.map((k, i) => (
diff --git a/frontend/src/components/RugnuxShellPlots.tsx b/frontend/src/components/RugnuxShellPlots.tsx
index 75193134e..0d33f0468 100644
--- a/frontend/src/components/RugnuxShellPlots.tsx
+++ b/frontend/src/components/RugnuxShellPlots.tsx
@@ -1,6 +1,7 @@
import {Box, Typography, useTheme} from "@mui/material";
import {rugnux_live_shell} from "../client";
import Plot from "./Plot";
+import {livePalette} from "../livePalette";
// Merging statistics by resolution shell, the shell table of rugnux's _report.txt. Each shell is drawn at
// 1/d^2 of its d_min (the label of its row in the report), with the axis labelled in d. A quantity the run
@@ -28,8 +29,8 @@ const PANELS: { title: string, percent: boolean, legendLeft?: boolean, series: S
// same on the light dashboard card and on the dark live page.
function RugnuxShellPlots({shells, merge, height = 300}: { shells: rugnux_live_shell[], merge?: string, height?: number }) {
const theme = useTheme();
- const dark = theme.palette.mode === "dark";
- const grid = dark ? "rgba(255,255,255,.12)" : "#eee";
+ const pal = livePalette(theme.palette.mode);
+ const grid = pal.grid;
// type that grows with the panel, so a 4k screen does not get 11 px labels
const font = Math.round(Math.min(17, Math.max(11, height / 24)));
const x = shells.map(sh => 1 / (sh.d_min * sh.d_min));
@@ -44,7 +45,7 @@ function RugnuxShellPlots({shells, merge, height = 300}: { shells: rugnux_live_s
{PANELS.map(panel => {
const data = panel.series
.filter(s => shells.some(sh => s.value(sh) !== undefined))
- .map(s => ({
+ .map((s, i) => ({
x: x,
y: shells.map(sh => {
const v = s.value(sh);
@@ -53,6 +54,8 @@ function RugnuxShellPlots({shells, merge, height = 300}: { shells: rugnux_live_s
type: "scatter" as const,
mode: "lines+markers" as const,
name: s.name,
+ line: {color: pal.traces[i % pal.traces.length]},
+ marker: {color: pal.traces[i % pal.traces.length], size: 5},
}));
if (data.length === 0)
return null;
diff --git a/frontend/src/components/RugnuxStills.tsx b/frontend/src/components/RugnuxStills.tsx
index 1e878a76f..e0254135e 100644
--- a/frontend/src/components/RugnuxStills.tsx
+++ b/frontend/src/components/RugnuxStills.tsx
@@ -1,5 +1,5 @@
import {Box, Chip, LinearProgress, Stack, Table, TableBody, TableCell, TableHead, TableRow, Typography} from "@mui/material";
-import {grey, indigo} from "@mui/material/colors";
+import {alpha} from "@mui/material/styles";
import {rugnux_live_stills} from "../client";
// Serial frames analysed on the GPU: the pre-pass on the first images - the beam
@@ -9,12 +9,13 @@ const PREPASS_COLOUR = {Holding: "default", Running: "primary", Done: "success",
function Tile({label, value, sub}: { label: string, value: string, sub?: string }) {
return (
-
+ alpha(t.palette.primary.main, 0.08),
+ borderColor: t => alpha(t.palette.primary.main, 0.2)}}>
{label}
- {value}
+ {value}
{sub && {sub}}
);
@@ -88,7 +89,7 @@ function RugnuxStills({st}: { st: rugnux_live_stills }) {
-
+
Every image is analysed with the pre-pass's beam centre, distance and mask; images arriving
during the pre-pass are held and analysed after it.
diff --git a/frontend/src/components/RugnuxStructureViewer.tsx b/frontend/src/components/RugnuxStructureViewer.tsx
index 48dc7bee6..093381aa4 100644
--- a/frontend/src/components/RugnuxStructureViewer.tsx
+++ b/frontend/src/components/RugnuxStructureViewer.tsx
@@ -162,8 +162,8 @@ function RugnuxStructureViewer({resultKey, anomalous, anomalousSignal, fill}:
toggleLayer('fofc', !show.fofc)} disabled={mapsLoading}
sx={{position: 'absolute', top: 8, right: 8, display: 'inline-flex', alignItems: 'center', gap: 0.75,
px: 1, height: 26, borderRadius: '13px', border: '1px solid', cursor: 'pointer',
- borderColor: show.fofc ? 'primary.main' : 'divider', bgcolor: 'rgba(8,12,26,.8)',
- color: show.fofc ? 'text.primary' : 'text.secondary', fontSize: '0.75rem', fontFamily: 'inherit'}}>
+ borderColor: show.fofc ? 'primary.main' : 'rgba(154,165,196,.3)', bgcolor: 'rgba(8,12,26,.8)',
+ color: show.fofc ? '#e9edf7' : '#9aa5c4', fontSize: '0.75rem', fontFamily: 'inherit'}}>
Fo−Fc
diff --git a/frontend/src/components/RugnuxTimeline.tsx b/frontend/src/components/RugnuxTimeline.tsx
index fb98ea398..5b095e0c4 100644
--- a/frontend/src/components/RugnuxTimeline.tsx
+++ b/frontend/src/components/RugnuxTimeline.tsx
@@ -22,7 +22,7 @@ const runningSx = {
animation: `${stripes} 1s linear infinite`,
};
-const STEP_COLOURS = [indigo[500], indigo[300], indigo[700], lightBlue[700], indigo[400], lightBlue[900]];
+const STEP_COLOURS = [indigo[500], indigo[300], indigo[700], lightBlue[700], indigo[400], lightBlue[800]];
const LABEL_WIDTH = 120;
const LANE_HEIGHT = 64;
@@ -128,7 +128,7 @@ function RugnuxTimeline({s, deadline_s}: { s: rugnux_live_status, deadline_s: nu
markers.push({x: pct(s.probe_s), label: `probe ${s.probe_s.toFixed(1)} s`,
colour: s.probe.startsWith("no lattice") ? orange[800] : lightBlue[800]});
if (lastImage !== undefined)
- markers.push({x: pct(lastImage), dashed: true, colour: grey[800], label: "last image"});
+ markers.push({x: pct(lastImage), dashed: true, colour: grey[500], label: "last image"});
if (deadline !== undefined && s.cut !== 'deadline')
markers.push({x: pct(deadline), dashed: true, colour: deepOrange[700], label: `deadline ${deadline.toFixed(1)} s`});
if (s.cut && s.cut_s !== undefined)
@@ -153,11 +153,11 @@ function RugnuxTimeline({s, deadline_s}: { s: rugnux_live_status, deadline_s: nu
{/* grid lines */}
{ticks.map(t => (
+ height: 2 * LANE_HEIGHT + 12, borderLeft: "1px solid", borderColor: "divider"}}/>
))}
{/* detector lane */}
-
+
@@ -177,7 +177,7 @@ function RugnuxTimeline({s, deadline_s}: { s: rugnux_live_status, deadline_s: nu
{/* rugnux lane */}
-
+
{s.steps.map((step, i) => {
const open = step.duration_s === undefined;
const end = open ? s.elapsed_s : step.started_s + step.duration_s!;
@@ -227,7 +227,7 @@ function RugnuxTimeline({s, deadline_s}: { s: rugnux_live_status, deadline_s: nu
borderBottom: `4px solid ${lime[700]}`, borderLeft: `4px solid ${lime[700]}`,
borderRight: `4px solid ${lime[700]}`, borderRadius: "0 0 8px 8px"}}>
+ fontSize: "1.4rem", color: t => t.palette.mode === "dark" ? lime[300] : lime[900], whiteSpace: "nowrap"}}>
+{latency.toFixed(1)} s → all written
diff --git a/frontend/src/livePalette.ts b/frontend/src/livePalette.ts
new file mode 100644
index 000000000..34fcc036f
--- /dev/null
+++ b/frontend/src/livePalette.ts
@@ -0,0 +1,59 @@
+import {PaletteMode} from "@mui/material";
+import {indigo, lime} from "@mui/material/colors";
+import {SEMANTIC} from "./theme";
+
+// The colours of the Rugnux live page, one set per mode, all drawn from the app's indigo and lime:
+// - the two phases: collecting is lime (the detector's colour everywhere in the app), processing is indigo;
+// - the three verdicts: the theme's success / warning / error (SEMANTIC in theme.ts);
+// - the kinds of step: Okabe-Ito, which stays apart for colour-blind readers; its blue is lightened at night;
+// - the plot traces, in the order a panel uses them: indigo, vermillion, bluish green, pink - again Okabe-Ito
+// apart from the indigo, which is the brand's; and the bands of frames the merge rejected (red) or
+// downgraded (amber), translucent so the traces stay readable through them.
+
+export type LivePalette = {
+ collecting: string; // the detector's colour, as a label or an edge
+ collectingFill: string; // the same as a bar
+ processing: string;
+ ok: string;
+ attention: string;
+ serious: string;
+ // the surfaces of the stage: the panel the image and plots sit in, the progress tracks, the plot grid
+ panel: string;
+ track: string;
+ grid: string;
+ kinds: Record;
+ spare: string[];
+ traces: string[];
+ bands: {rejected: string, downgraded: string};
+};
+
+const KINDS_LIGHT: Record = {
+ Pre: "#56B4E9", Spots: "#E69F00", Idx: "#F0E442", Int: "#0072B2", GPU: "#0072B2", Scale: "#009E73",
+ Merge: "#009E73", MR: "#CC79A7", Ref: "#D55E00", Out: "#8E8E8E",
+};
+const KINDS_DARK: Record = {...KINDS_LIGHT, Int: "#3C8DD6", GPU: "#3C8DD6", Out: "#9E9E9E"};
+
+export function livePalette(mode: PaletteMode): LivePalette {
+ const sem = SEMANTIC[mode];
+ if (mode === "dark")
+ return {
+ collecting: lime[400], collectingFill: lime[700], processing: indigo[300], ...sem,
+ panel: "rgba(255,255,255,.04)", track: "rgba(255,255,255,.08)", grid: "rgba(255,255,255,.1)",
+ kinds: KINDS_DARK, spare: ["#8DD3C7", "#BEBADA", "#FB8072", "#FDB462", "#B3DE69"],
+ traces: [indigo[300], "#FF8A50", "#3EC9A0", "#E4A0CF"],
+ bands: {rejected: "rgba(255,107,107,.22)", downgraded: "rgba(255,179,71,.2)"},
+ };
+ return {
+ collecting: lime[800], collectingFill: lime[500], processing: indigo[500], ...sem,
+ panel: "rgba(63,81,181,.04)", track: "rgba(63,81,181,.1)", grid: "#e6e8f0",
+ kinds: KINDS_LIGHT, spare: ["#66C2A5", "#8DA0CB", "#FC8D62", "#E5C494", "#A6D854"],
+ traces: [indigo[500], "#D55E00", "#009E73", "#CC79A7"],
+ bands: {rejected: "rgba(215,38,61,.16)", downgraded: "rgba(224,138,0,.16)"},
+ };
+}
+
+// dark or light ink on a colour
+export const inkOn = (hex: string) => {
+ const [r, g, b] = [1, 3, 5].map(i => parseInt(hex.slice(i, i + 2), 16));
+ return 0.299 * r + 0.587 * g + 0.114 * b > 150 ? "rgba(0,0,0,.85)" : "#fff";
+};