-
Notifications
You must be signed in to change notification settings - Fork 0
Adds a new page for Jungfrau rotations #88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
3579261
Add starting page and route for JF rotations
noemifrisina 7ce2b13
Add link to navbar
noemifrisina 59346f0
Add jungfrau do darks
noemifrisina 208ba8e
Without file path it works... sigh
noemifrisina a1d1cc2
New changes
noemifrisina a836780
Merge branch 'main' into 59_jf-rotation
noemifrisina 7e1afc4
Update
noemifrisina ad61895
Merge branch 'main' into 59_jf-rotation
noemifrisina dc6d505
Merge branch 'main' into 59_jf-rotation
noemifrisina 7dfa14a
Hopefully fix lint
noemifrisina c4a7a6b
Wrap everything in the fallback just in case
noemifrisina e7bf064
And maybe save everything
noemifrisina cfaa9dc
Start using context and filling in params
noemifrisina 2361432
Finish filling everything in
noemifrisina 601fe68
Run prettier on changes
noemifrisina fda3f13
Fix the contrast text in light mode
noemifrisina e886bfa
Merge branch 'main' into 59_jf-rotation
noemifrisina ea842ed
Merge branch 'main' into 59_jf-rotation
noemifrisina c7af193
Update darks collection
noemifrisina dbff12c
Update JF context
noemifrisina 565310c
Add a visit provider and update the JF rotation parameters
noemifrisina ac18c1f
Save everything
noemifrisina 4cb6289
Increase spacing a bit
noemifrisina 94784b8
Add warning to tooltip
noemifrisina File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,150 @@ | ||
| import { | ||
| Box, | ||
| Card, | ||
| CardContent, | ||
| FormControl, | ||
| InputLabel, | ||
| MenuItem, | ||
| Select, | ||
| Stack, | ||
| Tooltip, | ||
| Typography, | ||
| useTheme, | ||
| } from "@mui/material"; | ||
| import React from "react"; | ||
| import { ParameterInput } from "../ParameterInputs"; | ||
| import { RunPlanButton } from "../../blueapi/BlueapiComponents"; | ||
| import { GainModes } from "./constants"; | ||
|
|
||
| export function CollectDarksPanel() { | ||
| const theme = useTheme(); | ||
| const [filename, setFilename] = React.useState<string>("darks"); | ||
| const [expTime, setExpTime] = React.useState<number>(0.001); | ||
| const [pedestalFrames, setPedestalFrames] = React.useState<number>(20); | ||
| const [pedestalLoops, setPedestalLoops] = React.useState<number>(200); | ||
| const [totTriggers, setTotTriggers] = React.useState<number>(1000); | ||
| const [gainMode, setGainMode] = React.useState<string>(GainModes[0]); | ||
|
|
||
| return ( | ||
| <Box sx={{ flexGrow: 1, marginLeft: 15, marginRight: 5 }}> | ||
| <Card variant="outlined" sx={{ minWidth: 300, minHeight: 600 }}> | ||
| <CardContent> | ||
| <Typography | ||
| variant="h2" | ||
| sx={{ | ||
| color: theme.palette.primary.contrastText, | ||
| fontSize: 24, | ||
| fontWeight: "fontWeightBold", | ||
| }} | ||
| > | ||
| Collect Darks | ||
| </Typography> | ||
| <Stack spacing={4} margin={4} alignItems={"center"}> | ||
| <Stack direction={"row"} spacing={2}> | ||
| <ParameterInput | ||
| value={filename} | ||
| onSet={setFilename} | ||
| label="Filename" | ||
| tooltip="Set filename for darks collection." | ||
| /> | ||
| <ParameterInput | ||
| value={expTime} | ||
| onSet={setExpTime} | ||
| label="Exposure time (s)" | ||
| tooltip="Set exposure time for darks collection." | ||
| /> | ||
| </Stack> | ||
| <Typography | ||
| variant="body1" | ||
| sx={{ | ||
| color: theme.palette.primary.contrastText, | ||
| fontSize: 20, | ||
| fontWeight: "fontWeightBold", | ||
| }} | ||
| > | ||
| Pedestal | ||
| </Typography> | ||
| <Stack direction={"row"} spacing={2}> | ||
| <ParameterInput | ||
| value={pedestalFrames} | ||
| onSet={setPedestalFrames} | ||
| label="Pedestal frames" | ||
| tooltip="Number of pedestal frames to collect." | ||
| /> | ||
| <ParameterInput | ||
| value={pedestalLoops} | ||
| onSet={setPedestalLoops} | ||
| label="Pedestal loops" | ||
| tooltip="Number of pedestal loops." | ||
| /> | ||
| </Stack> | ||
| <RunPlanButton | ||
| btnLabel="Pedestal darks" | ||
| planName="do_pedestal_darks" | ||
| planParams={{ | ||
| exp_time_s: expTime, | ||
| pedestal_frame: pedestalFrames, | ||
| pedestal_loops: pedestalLoops, | ||
| filename: filename, | ||
| }} | ||
| title="Collect pedestal darks" | ||
| btnSize="large" | ||
| /> | ||
| <Typography | ||
| variant="body1" | ||
| sx={{ | ||
| color: theme.palette.primary.contrastText, | ||
| fontSize: 20, | ||
| fontWeight: "fontWeightBold", | ||
| }} | ||
| > | ||
| Standard | ||
| </Typography> | ||
| <Stack direction={"row"} spacing={2}> | ||
| <ParameterInput | ||
| value={totTriggers} | ||
| onSet={setTotTriggers} | ||
| label="Total Triggers" | ||
| tooltip="Total triggers for the dark scan." | ||
| /> | ||
| <Tooltip | ||
| title="Select gain mode before starting the darks acquisition. | ||
| WARNING. FixGO may damage the detector - use with caution." | ||
| placement="right" | ||
| > | ||
| <FormControl size="small" style={{ width: 180 }}> | ||
| <InputLabel id="gain-label">Gain Mode</InputLabel> | ||
| <Select | ||
| labelId="gain-label" | ||
| id="gain" | ||
| value={gainMode} | ||
| label="Gain Mode" | ||
| onChange={(e) => setGainMode(e.target.value)} | ||
| > | ||
| {GainModes.map((choice) => ( | ||
| <MenuItem key={choice} value={choice}> | ||
| {choice} | ||
| </MenuItem> | ||
| ))} | ||
| </Select> | ||
| </FormControl> | ||
| </Tooltip> | ||
| </Stack> | ||
| <RunPlanButton | ||
| btnLabel="Standard darks" | ||
| planName="do_non_pedestal_darks" | ||
| planParams={{ | ||
| gain_mode: gainMode, | ||
| exp_time_s: expTime, | ||
| total_triggers: totTriggers, | ||
| filename: filename, | ||
| }} | ||
| title="Collect non pedestal darks" | ||
| btnSize="large" | ||
| /> | ||
| </Stack> | ||
| </CardContent> | ||
| </Card> | ||
| </Box> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| import { | ||
| Box, | ||
| Grid2 as Grid, | ||
| Stack, | ||
| TextField, | ||
| Typography, | ||
| useTheme, | ||
| } from "@mui/material"; | ||
| import { AbortButton, RunPlanButton } from "blueapi/BlueapiComponents"; | ||
| import { ParameterInput } from "components/ParameterInputs"; | ||
| import { JungfrauRotationContext } from "context/jungfrau/JungfrauRotationContext"; | ||
| import { VisitContext } from "context/VisitContext"; | ||
| import React from "react"; | ||
| import { useContext } from "react"; | ||
|
|
||
| function fullStorageDirectory(visit: string): string { | ||
| const date = new Date(); | ||
| const year = date.getFullYear(); | ||
| return `/dls/i24/data/${year}/${visit}/jungfrau/`; | ||
| } | ||
|
|
||
| function RunButtons(): JSX.Element { | ||
| const { | ||
| expTime, | ||
| detDist, | ||
| fileName, | ||
| omegaStart, | ||
| omegaIncrement, | ||
| transFract, | ||
| sampleId, | ||
| } = useContext(JungfrauRotationContext); | ||
| console.log(transFract); | ||
| return ( | ||
| <React.Fragment> | ||
| <Stack direction={"row"} spacing={4} justifyContent={"center"}> | ||
| <RunPlanButton | ||
| btnLabel="Run rotation scan" | ||
| planName="gui_run_jf_rotation_scan" | ||
| planParams={{ | ||
| exposure_time_s: expTime, | ||
| omega_start_deg: omegaStart, | ||
| omega_increment_deg: omegaIncrement, | ||
| detector_distance_mm: detDist, | ||
| filename: fileName, | ||
| transmissions: transFract, | ||
| sample_id: sampleId, | ||
| }} | ||
| title="Run the jungfrau rotation scan plan" | ||
| btnSize="large" | ||
| /> | ||
| <AbortButton /> | ||
| </Stack> | ||
| </React.Fragment> | ||
| ); | ||
| } | ||
|
|
||
| export function CollectionSetupJf() { | ||
| const theme = useTheme(); | ||
| const context = useContext(JungfrauRotationContext); | ||
| const { visit } = useContext(VisitContext); | ||
| const storageDirectory = fullStorageDirectory(visit); | ||
| return ( | ||
| <Box sx={{ flexGrow: 1 }}> | ||
| <Stack direction={"column"} alignItems={"center"} spacing={5}> | ||
| <Typography | ||
| variant="h2" | ||
| sx={{ | ||
| color: theme.palette.primary.contrastText, | ||
| fontSize: 24, | ||
| fontWeight: "fontWeightBold", | ||
| }} | ||
| > | ||
| Collection Parameters | ||
| </Typography> | ||
| <TextField | ||
| size="small" | ||
| label="Storage Directory" | ||
| value={storageDirectory} | ||
| style={{ width: 570 }} | ||
| slotProps={{ | ||
| input: { readOnly: true }, | ||
| }} | ||
| /> | ||
| <Grid container spacing={2} marginTop={3} justifyContent={"center"}> | ||
| <ParameterInput | ||
| value={context.fileName} | ||
| onSet={context.setFileName} | ||
| label="File Name" | ||
| tooltip="Name to use to save the data" | ||
| /> | ||
| <ParameterInput | ||
| value={context.expTime} | ||
| onSet={context.setExpTime} | ||
| label="Exposure Time (s)" | ||
| tooltip="Exposure time for each window, in seconds" | ||
| /> | ||
| <ParameterInput | ||
| value={context.detDist} | ||
| onSet={context.setDetDist} | ||
| label="Detector Distance (mm)" | ||
| tooltip="Sample detector distance, in millimeters" | ||
| /> | ||
| </Grid> | ||
| <Grid container spacing={2} marginTop={3} justifyContent={"center"}> | ||
| <ParameterInput | ||
| value={context.omegaStart} | ||
| onSet={context.setOmegaStart} | ||
| label="Omega start (deg)" | ||
| tooltip="Rotation start value, in deg" | ||
| /> | ||
| <ParameterInput | ||
| value={context.omegaIncrement} | ||
| onSet={context.setOmegaIncrement} | ||
| label="Omega increment (deg)" | ||
| tooltip="Rotation increment step, in deg" | ||
| /> | ||
| <ParameterInput | ||
| value={context.sampleId} | ||
| onSet={context.setSampleId} | ||
| label="Sample ID" | ||
| tooltip="Sample id" | ||
| /> | ||
| </Grid> | ||
| <Grid container spacing={2} marginTop={3} justifyContent={"center"}> | ||
| <ParameterInput | ||
| value={context.transFract} | ||
| onSet={context.setTransFract} | ||
| label="Transmission (fraction)" | ||
| tooltip="Request transmission value(s) for collection, expressed as a fraction. If running a single rotation, just input one value, if running multiples please pass a list." | ||
| /> | ||
| </Grid> | ||
| <RunButtons /> | ||
| </Stack> | ||
| </Box> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| export type GainModeType = | ||
| | "Dynamic" | ||
| | "ForceSwitchG1" | ||
| | "ForceSwitchG2" | ||
| | "FixG1" | ||
| | "FixG2" | ||
| | "FixG0"; | ||
|
|
||
| export const GainModes = [ | ||
| "Dynamic", | ||
| "ForceSwitchG1", | ||
| "ForceSwitchG2", | ||
| "FixG1", | ||
| "FixG2", | ||
| "FixG0", | ||
| ]; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import React, { createContext } from "react"; | ||
|
|
||
| export type VisitContextType = { | ||
| visit: string; | ||
| setVisit: React.Dispatch<React.SetStateAction<string>>; | ||
| }; | ||
|
|
||
| export const VisitContext = createContext<VisitContextType>( | ||
| null as unknown as VisitContextType, | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { ReactNode, useState } from "react"; | ||
| import { VisitContext } from "./VisitContext"; | ||
|
|
||
| const defaultVisit = "cm44177-1"; // Until we can grab it after authentication | ||
|
|
||
| export const VisitProvider = ({ children }: { children: ReactNode }) => { | ||
| const [visit, setVisit] = useState<string>(defaultVisit); | ||
|
|
||
| return ( | ||
| <VisitContext.Provider value={{ visit, setVisit }}> | ||
| {children} | ||
| </VisitContext.Provider> | ||
| ); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { createContext } from "react"; | ||
|
|
||
| export type JungfrauRotationContextType = { | ||
| fileName: string; | ||
| expTime: number; | ||
| detDist: number; | ||
| transFract: number[]; | ||
| omegaStart: number; | ||
| omegaIncrement: number; | ||
| sampleId: number; | ||
| setFileName: React.Dispatch<React.SetStateAction<string>>; | ||
| setExpTime: React.Dispatch<React.SetStateAction<number>>; | ||
| setDetDist: React.Dispatch<React.SetStateAction<number>>; | ||
| setTransFract: React.Dispatch<React.SetStateAction<number[]>>; | ||
| setOmegaStart: React.Dispatch<React.SetStateAction<number>>; | ||
| setOmegaIncrement: React.Dispatch<React.SetStateAction<number>>; | ||
| setSampleId: React.Dispatch<React.SetStateAction<number>>; | ||
| }; | ||
|
|
||
| export const JungfrauRotationContext = | ||
| createContext<JungfrauRotationContextType>( | ||
| null as unknown as JungfrauRotationContextType, | ||
| ); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the ophyd-async Enum I put a comment before the FIX_G0:
# Use with caution - this may damage the detector. (I got this from an operations guide for the Jungfrau which is now deprecated).Could put a similar message on the screen around this option
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will add to the tooltip