-
Notifications
You must be signed in to change notification settings - Fork 2
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
Correctly pass parameters through all of Hyperion's UDC parameters #746
Merged
olliesilvester
merged 12 commits into
main
from
738_give_other_hyperion_params_features
Jan 17, 2025
Merged
Changes from 6 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
53f0d07
Get Hyperion parameters to correctly pass features to its subsequent …
olliesilvester 8aadf2e
Fixes and tests
olliesilvester e240023
Forgot to commit this file
olliesilvester 8648ef4
Revert accidental changes to experiemnt registry
olliesilvester 5bf4f72
Refactor parameters
olliesilvester b7ac4e7
typing
olliesilvester 1aa242e
small tidy
olliesilvester 2d6ea49
Change bluesky pinning
olliesilvester dbc2371
Update test to assert for detector params
olliesilvester d3a6ea2
Merge branch 'main' into 738_give_other_hyperion_params_features
olliesilvester 2945a54
Merge branch 'main' into 738_give_other_hyperion_params_features
olliesilvester b6716ad
Fix linting
olliesilvester 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 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 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 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 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 |
---|---|---|
@@ -1,11 +1,6 @@ | ||
from __future__ import annotations | ||
|
||
import os | ||
|
||
from dodal.devices.aperturescatterguard import ApertureValue | ||
from dodal.devices.detector import ( | ||
DetectorParams, | ||
) | ||
from dodal.devices.fast_grid_scan import ( | ||
ZebraGridScanParams, | ||
) | ||
|
@@ -23,86 +18,37 @@ | |
XyzStarts, | ||
) | ||
from mx_bluesky.common.parameters.constants import ( | ||
DetectorParamConstants, | ||
GridscanParamConstants, | ||
HardwareConstants, | ||
) | ||
from mx_bluesky.common.parameters.robot_load import RobotLoadAndEnergyChange | ||
|
||
"""Parameter models in this file are abstract. They should be inherited by a top-level model""" | ||
|
||
|
||
class GridCommon( | ||
DiffractionExperimentWithSample, | ||
OptionalGonioAngleStarts, | ||
): | ||
"""Parameters used in every MX diffraction experiment using grids. This model should be used by plans which have no knowledge of the grid specifications - i.e before automatic grid detection has completed""" | ||
|
||
grid_width_um: float = Field(default=GridscanParamConstants.WIDTH_UM) | ||
exposure_time_s: float = Field(default=GridscanParamConstants.EXPOSURE_TIME_S) | ||
use_roi_mode: bool = Field(default=GridscanParamConstants.USE_ROI) | ||
|
||
ispyb_experiment_type: IspybExperimentType = Field( | ||
default=IspybExperimentType.GRIDSCAN_3D | ||
) | ||
selected_aperture: ApertureValue | None = Field(default=ApertureValue.SMALL) | ||
|
||
@property | ||
def detector_params(self): | ||
self.det_dist_to_beam_converter_path = ( | ||
self.det_dist_to_beam_converter_path | ||
or DetectorParamConstants.BEAM_XY_LUT_PATH | ||
) | ||
optional_args = {} | ||
if self.run_number: | ||
optional_args["run_number"] = self.run_number | ||
assert self.detector_distance_mm is not None, ( | ||
"Detector distance must be filled before generating DetectorParams" | ||
) | ||
os.makedirs(self.storage_directory, exist_ok=True) | ||
return DetectorParams( | ||
detector_size_constants=DetectorParamConstants.DETECTOR, | ||
expected_energy_ev=self.demand_energy_ev, | ||
exposure_time=self.exposure_time_s, | ||
directory=self.storage_directory, | ||
prefix=self.file_name, | ||
detector_distance=self.detector_distance_mm, | ||
omega_start=self.omega_start_deg or 0, | ||
omega_increment=0, | ||
num_images_per_trigger=1, | ||
num_triggers=self.num_images, | ||
use_roi_mode=self.use_roi_mode, | ||
det_dist_to_beam_converter_path=self.det_dist_to_beam_converter_path, | ||
trigger_mode=self.trigger_mode, | ||
**optional_args, | ||
) | ||
|
||
|
||
class RobotLoadThenCentre(GridCommon): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Discussed with @rtuck99 - we're so far off any non-hyperion beamlines doing anything other than a grid scan, it's probably good to get rid of some of the common parameters like this one |
||
thawing_time: float = Field(default=HardwareConstants.THAWING_TIME) | ||
tip_offset_um: float = Field(default=HardwareConstants.TIP_OFFSET_UM) | ||
|
||
def robot_load_params(self): | ||
my_params = self.model_dump() | ||
return RobotLoadAndEnergyChange(**my_params) | ||
|
||
def pin_centre_then_xray_centre_params(self): | ||
my_params = self.model_dump() | ||
del my_params["thawing_time"] | ||
return PinTipCentreThenXrayCentre(**my_params) | ||
|
||
|
||
class GridScanWithEdgeDetect(GridCommon): | ||
box_size_um: float = Field(default=GridscanParamConstants.BOX_WIDTH_UM) | ||
|
||
|
||
class PinTipCentreThenXrayCentre(GridCommon): | ||
tip_offset_um: float = 0 | ||
|
||
|
||
class SpecifiedGrid(XyzStarts, WithScan): | ||
"""A specified grid is one which has defined values for the start position, | ||
grid and box sizes, etc., as opposed to parameters for a plan which will create | ||
those parameters at some point (e.g. through optical pin detection).""" | ||
|
||
|
||
class ThreeDGridScan( | ||
class SpecifiedThreeDGridScan( | ||
GridCommon, | ||
SpecifiedGrid, | ||
SplitScan, | ||
|
This file was deleted.
Oops, something went wrong.
This file contains 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 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
Oops, something went wrong.
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.
Because
GridCommon
is now abstract, we need to use an implemented version of this model here. Since the type is bound toGridCommon
, I don't think this will affect generalisability.Similar change done in
nexus_callback.py