From cedca209a7ae23298f786d3b72416e94f798c2c7 Mon Sep 17 00:00:00 2001 From: tizayi Date: Thu, 9 May 2024 11:56:06 +0100 Subject: [PATCH] fix wavelength unit initialisation --- src/dialogs/beamlineDialog.tsx | 4 ++-- src/dialogs/detectorDialog.tsx | 2 +- src/presets/beamlines.json | 2 +- src/presets/detectors.json | 21 ++++++++++++++++----- src/presets/presetConfigs.json | 17 ----------------- src/presets/presetManager.ts | 5 +++-- 6 files changed, 23 insertions(+), 28 deletions(-) diff --git a/src/dialogs/beamlineDialog.tsx b/src/dialogs/beamlineDialog.tsx index d4d634b..b01717f 100644 --- a/src/dialogs/beamlineDialog.tsx +++ b/src/dialogs/beamlineDialog.tsx @@ -34,7 +34,7 @@ export default function PresetDialog(props: { handleOpen: () => void; }): JSX.Element { const beamlineConfigStore = useBeamlineConfigStore(); - const { register, handleSubmit } = useForm(); + const { register, reset, handleSubmit } = useForm(); const onSubmit: SubmitHandler = (data: BeamlineForm) => { beamlineConfigStore.addNewBeamline( data.name, createInternalBeamline(data.beamline)); @@ -50,7 +50,7 @@ export default function PresetDialog(props: { keepMounted onClose={props.handleClose} > -
+ Beamlines diff --git a/src/dialogs/detectorDialog.tsx b/src/dialogs/detectorDialog.tsx index 5274839..71a24b1 100644 --- a/src/dialogs/detectorDialog.tsx +++ b/src/dialogs/detectorDialog.tsx @@ -46,7 +46,7 @@ export default function DetectorDialog(props: { onClose={props.handleClose} maxWidth={"md"} > - + Detectors diff --git a/src/presets/beamlines.json b/src/presets/beamlines.json index 2934cde..d912d33 100644 --- a/src/presets/beamlines.json +++ b/src/presets/beamlines.json @@ -1,7 +1,7 @@ { "I22": { "beamstopDiameter": 4, - "cameratubeDiameter": 300, + "cameratubeDiameter": 310, "minWavelength": 0.062, "maxWavelength": 0.335, "minCameraLength": 1.9, diff --git a/src/presets/detectors.json b/src/presets/detectors.json index 1ff792f..503de39 100644 --- a/src/presets/detectors.json +++ b/src/presets/detectors.json @@ -9,14 +9,25 @@ "height": 0.172 } }, - "test": { + "Pilatus6M": { "resolution": { - "width": 1000, - "height": 1000 + "width": 2527, + "height": 2463 }, "pixelSize": { - "width": 0.2, - "height": 0.2 + "width": 0.172, + "height": 0.172 + } + }, + "Eiger 16M": { + "resolution": { + "width": 4150, + "height": 4371 + }, + "pixelSize": { + "width": 7.50e-2, + "height": 7.50e-2 } } + } diff --git a/src/presets/presetConfigs.json b/src/presets/presetConfigs.json index 17ff7df..d4ae4f3 100644 --- a/src/presets/presetConfigs.json +++ b/src/presets/presetConfigs.json @@ -32,22 +32,5 @@ "y": 840 } } - }, - "test":{ - "detector": "test", - "beamline": "test", - "beamstop": { - "centre": { - "x": 500, - "y": 500 - }, - "clearance": 5 - }, - "cameraTube": { - "centre": { - "x": 500, - "y": 500 - } - } } } diff --git a/src/presets/presetManager.ts b/src/presets/presetManager.ts index ea1fa79..ee38780 100644 --- a/src/presets/presetManager.ts +++ b/src/presets/presetManager.ts @@ -44,8 +44,9 @@ export function createInternalBeamline(beamlineData: IOBeamline): AppBeamline { return { cameratubeDiameter: beamlineData.cameratubeDiameter, beamstopDiameter: beamlineData.beamstopDiameter, - minWavelength: unit(beamlineData.minWavelength, "nm"), - maxWavelength: unit(beamlineData.maxWavelength, "nm"), + // Solution to units not being properly initialised + minWavelength: unit(beamlineData.minWavelength, "nm").to("nm"), + maxWavelength: unit(beamlineData.maxWavelength, "nm").to("nm"), minCameraLength: unit(beamlineData.minCameraLength, "m"), maxCameraLength: unit(beamlineData.maxCameraLength, "m"), cameraLengthStep: unit(beamlineData.cameraLengthStep, "m"),