Build Packages / Build documentation (push) Successful in 46s
Build Packages / Create release (push) Successful in 8s
Build Packages / build:portable:macos-arm64:nocuda (push) Successful in 5m25s
Build Packages / build:rugnux:linux-aarch64:cuda (push) Successful in 9m46s
Build Packages / build:portable:linux-x86_64:nocuda (push) Successful in 13m25s
Build Packages / build:portable:linux-x86_64:cuda (push) Successful in 16m41s
Build Packages / build:portable:windows-x86_64:nocuda (push) Successful in 23m46s
Build Packages / HDF5 consumer tests (DIALS, XDS) (push) Successful in 25m37s
Build Packages / build:jfjoch:rocky8:nocuda (push) Successful in 24m31s
Build Packages / build:portable:windows-x86_64:cuda (push) Successful in 28m9s
Build Packages / build:jfjoch:ubuntu2204:nocuda (push) Successful in 20m47s
Build Packages / build:jfjoch:rocky9:nocuda (push) Successful in 26m21s
Build Packages / build:jfjoch:ubuntu2404:nocuda (push) Successful in 27m36s
Build Packages / Generate python client (push) Successful in 31s
Build Packages / build:jfjoch:rocky8:cuda-sls9 (push) Successful in 29m27s
Build Packages / build:jfjoch:rocky9:cuda-sls9 (push) Successful in 31m46s
Build Packages / build:jfjoch:ubuntu2204:cuda (push) Successful in 25m22s
Build Packages / build:jfjoch:rocky8:cuda (push) Successful in 30m36s
Build Packages / build:jfjoch:rocky9:cuda (push) Successful in 31m49s
Build Packages / build:jfjoch:ubuntu2404:cuda (push) Successful in 23m57s
Build Packages / Unit tests (push) Successful in 1h47m52s
Build Packages / Validation Battery (push) Successful in 44m55s
* Rugnux: Rotation processing recovers most of the speed lost since 1.0.0-rc.180; live processing in jfjoch_broker finishes sooner. * Rugnux: More reliable rotation processing and indexing, including small molecules and supercells. * Rugnux: More robust serial data and model refinement; molecular replacement handles multi-chain models. * jfjoch_broker (experimental): Live serial processing keeps the detector geometry fixed for the whole run. * jfjoch_broker: Pixel sum without an FPGA, a mask bit for inactive pixels, and several stability fixes. * jfjoch_broker: Rotation indexing and quick integration moved to rugnux live mode; their API settings are deprecated and ignored. * jfjoch_broker, Rugnux: Azimuthal integration can use logarithmic (log10) Q bins or a given number of bins, set from the API, the web interface and the Rugnux command line. * jfjoch_viewer: Build and display fixes; the README is rewritten. Reviewed-on: #95 Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch>
221 lines
9.3 KiB
TypeScript
221 lines
9.3 KiB
TypeScript
import {ChangeEvent, memo, useEffect, useState} from 'react';
|
|
|
|
import {FormControlLabel, Checkbox, Stack, Radio, RadioGroup, Typography} from "@mui/material";
|
|
import NumberTextField from "./NumberTextField";
|
|
import {azim_int_settings, q_binning} from "../client";
|
|
import {putConfigAzimIntMutation} from "../client/@tanstack/react-query.gen";
|
|
import _ from "lodash";
|
|
import FormControl from "@mui/material/FormControl";
|
|
import SettingsPanel from "./SettingsPanel";
|
|
import {useUpload} from "./useUpload";
|
|
|
|
// Linear bins are set by their spacing or by their number; log10 bins only by their number.
|
|
type Binning = "linear_spacing" | "linear_bins" | "log10";
|
|
|
|
function binningOf(s: azim_int_settings): Binning {
|
|
if (s.q_binning === q_binning.LOG10)
|
|
return "log10";
|
|
return (s.q_bins !== undefined) ? "linear_bins" : "linear_spacing";
|
|
}
|
|
|
|
type MyProps = {
|
|
s?: azim_int_settings
|
|
};
|
|
|
|
const default_azim_int_settings : azim_int_settings = {
|
|
solid_angle_corr: true,
|
|
polarization_corr: true,
|
|
high_q_recipA: 5,
|
|
low_q_recipA: 0.1,
|
|
q_spacing: 0.1,
|
|
q_binning: q_binning.LINEAR,
|
|
azimuthal_bins: 1,
|
|
force_cpu: false
|
|
}
|
|
|
|
function AzIntSettings({s: serverS}: MyProps) {
|
|
const [s, setS] = useState<azim_int_settings>(default_azim_int_settings);
|
|
const [lastDownloadedS, setLastDownloadedS] = useState<azim_int_settings>(default_azim_int_settings);
|
|
const [downloadCounter, setDownloadCounter] = useState(0);
|
|
const [lowQError, setLowQError] = useState(false);
|
|
const [highQError, setHighQError] = useState(false);
|
|
const [qSpacingError, setQSpacingError] = useState(false);
|
|
const [qBinsError, setQBinsError] = useState(false);
|
|
const [highQ, setHighQ] = useState(5);
|
|
// The spacing and bin count last entered, kept while the other way of binning is selected.
|
|
const [qSpacing, setQSpacing] = useState(0.1);
|
|
const [qBins, setQBins] = useState(500);
|
|
const { submit, pending, snackbar } = useUpload(putConfigAzimIntMutation());
|
|
|
|
useEffect(() => {
|
|
if ((serverS !== undefined) && !_.isEqual(serverS, lastDownloadedS)) {
|
|
setS(serverS);
|
|
setLastDownloadedS(serverS);
|
|
setDownloadCounter(c => c + 1);
|
|
setHighQ(serverS.high_q_recipA ?? highQ);
|
|
setQSpacing(serverS.q_spacing ?? qSpacing);
|
|
setQBins(serverS.q_bins ?? qBins);
|
|
}
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
}, [serverS]);
|
|
|
|
const dirty = !_.isEqual(s, lastDownloadedS);
|
|
const binning = binningOf(s);
|
|
|
|
const selectBinning = (b: Binning) => {
|
|
setS(prev => {
|
|
const rest = _.omit(prev, ["q_spacing", "q_bins"]);
|
|
if (b === "linear_spacing")
|
|
return {...rest, q_binning: q_binning.LINEAR, q_spacing: qSpacing};
|
|
return {...rest, q_binning: (b === "log10") ? q_binning.LOG10 : q_binning.LINEAR, q_bins: qBins};
|
|
});
|
|
};
|
|
|
|
return (
|
|
<SettingsPanel title="Azimuthal integration" dirty={dirty}
|
|
onUpload={() => submit(s)}
|
|
uploadDisabled={pending || ((s.high_q_recipA !== undefined) && (s.high_q_recipA <= s.low_q_recipA))
|
|
|| highQError || lowQError
|
|
|| (binning === "linear_spacing" ? qSpacingError : qBinsError)}
|
|
snackbar={snackbar}>
|
|
<Stack spacing={2} direction="row">
|
|
{(binning === "linear_spacing") ?
|
|
<NumberTextField
|
|
default={1.0}
|
|
start_val={s.q_spacing}
|
|
label={"Q spacing"}
|
|
min={1e-5}
|
|
units={"A-1"}
|
|
float={true}
|
|
decimals={5}
|
|
counter={downloadCounter}
|
|
callback={(val: number, err: boolean) => {
|
|
setQSpacing(val);
|
|
setS(prev => ({...prev, q_spacing: val}));
|
|
setQSpacingError(err);
|
|
}}
|
|
fullWidth/>
|
|
:
|
|
<NumberTextField
|
|
default={500}
|
|
start_val={s.q_bins}
|
|
label={"Q bins"}
|
|
min={1}
|
|
max={65534}
|
|
counter={downloadCounter}
|
|
callback={(val: number, err: boolean) => {
|
|
setQBins(val);
|
|
setS(prev => ({...prev, q_bins: val}));
|
|
setQBinsError(err);
|
|
}}
|
|
fullWidth/>
|
|
}
|
|
|
|
<NumberTextField
|
|
default={0.1}
|
|
start_val={s.low_q_recipA}
|
|
label={"Low Q"}
|
|
min={1e-5}
|
|
max={10.0}
|
|
units={"A-1"}
|
|
float={true}
|
|
decimals={5}
|
|
counter={downloadCounter}
|
|
callback={(val: number, err: boolean) => {
|
|
setS(prev => ({...prev, low_q_recipA: val}));
|
|
setLowQError(err);
|
|
}}
|
|
fullWidth/>
|
|
|
|
<NumberTextField
|
|
default={5}
|
|
start_val={s.high_q_recipA ?? highQ}
|
|
label={"High Q"}
|
|
min={1e-5}
|
|
max={10.0}
|
|
units={"A-1"}
|
|
float={true}
|
|
decimals={5}
|
|
counter={downloadCounter}
|
|
disabled={s.high_q_recipA === undefined}
|
|
callback={(val: number, err: boolean) => {
|
|
setHighQ(val);
|
|
setS(prev => ({...prev, high_q_recipA: val}));
|
|
setHighQError(err);
|
|
}}
|
|
fullWidth/>
|
|
</Stack>
|
|
<FormControl>
|
|
<FormControlLabel control={
|
|
<Checkbox
|
|
checked={s.high_q_recipA === undefined}
|
|
onChange={
|
|
(event: ChangeEvent<HTMLInputElement>) => {
|
|
// No high Q means integrating out to the highest Q the detector reaches.
|
|
setS(prev => event.target.checked ? _.omit(prev, "high_q_recipA")
|
|
: {...prev, high_q_recipA: highQ});
|
|
}}
|
|
/>} label="High Q to detector edge"/>
|
|
<FormControlLabel control={
|
|
<Checkbox
|
|
checked={s.solid_angle_corr}
|
|
onChange={
|
|
(event: ChangeEvent<HTMLInputElement>) => {
|
|
setS(prev => ({...prev, solid_angle_corr: event.target.checked}));
|
|
}}
|
|
/>} label="Solid angle correction"/>
|
|
<FormControlLabel control={
|
|
<Checkbox
|
|
checked={s.polarization_corr}
|
|
onChange={
|
|
(event: ChangeEvent<HTMLInputElement>) => {
|
|
setS(prev => ({...prev, polarization_corr: event.target.checked}));
|
|
}}
|
|
/>} label="Polarization correction"/>
|
|
<FormControlLabel control={
|
|
<Checkbox
|
|
checked={s.force_cpu ?? false}
|
|
onChange={
|
|
(event: ChangeEvent<HTMLInputElement>) => {
|
|
setS(prev => ({...prev, force_cpu: event.target.checked}));
|
|
}}
|
|
/>} label="Force CPU calculation in FPGA workflow"/>
|
|
</FormControl>
|
|
<Typography>Q binning</Typography>
|
|
<FormControl component="fieldset">
|
|
<RadioGroup
|
|
row
|
|
value={binning}
|
|
onChange={(event: ChangeEvent<HTMLInputElement>) => selectBinning(event.target.value as Binning)}
|
|
>
|
|
<FormControlLabel value="linear_spacing" control={<Radio/>} label="Linear, by spacing"/>
|
|
<FormControlLabel value="linear_bins" control={<Radio/>} label="Linear, by number of bins"/>
|
|
<FormControlLabel value="log10" control={<Radio/>} label="Logarithmic (log10 Q)"/>
|
|
</RadioGroup>
|
|
</FormControl>
|
|
<Typography>Azimuthal bins</Typography>
|
|
<FormControl component="fieldset">
|
|
<RadioGroup
|
|
row
|
|
value={s.azimuthal_bins}
|
|
onChange={(event: ChangeEvent<HTMLInputElement>) => {
|
|
setS(prev => ({...prev, azimuthal_bins: Number(event.target.value)}));
|
|
}}
|
|
>
|
|
{[1, 2, 4, 8, 16, 32, 64, 128].map((value) => (
|
|
<FormControlLabel
|
|
key={value}
|
|
value={value}
|
|
control={<Radio/>}
|
|
label={value.toString()}
|
|
/>
|
|
))}
|
|
</RadioGroup>
|
|
</FormControl>
|
|
|
|
</SettingsPanel>
|
|
);
|
|
}
|
|
|
|
export default memo(AzIntSettings);
|