-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
470 Full experiment plan to replace execute request (#538)
* Implementation of grand unified experiment plan * Add load_centre_collect to the experiment registry * Additional system test for full experiment plan * Make ruff happpy * Changes following PR review comments * Make pyright happy
Showing
22 changed files
with
1,388 additions
and
558 deletions.
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
46 changes: 46 additions & 0 deletions
46
src/mx_bluesky/hyperion/experiment_plans/load_centre_collect_full_plan.py
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import dataclasses | ||
|
||
from blueapi.core import BlueskyContext | ||
from dodal.devices.oav.oav_parameters import OAVParameters | ||
|
||
from mx_bluesky.hyperion.experiment_plans.robot_load_then_centre_plan import ( | ||
RobotLoadThenCentreComposite, | ||
robot_load_then_centre, | ||
) | ||
from mx_bluesky.hyperion.experiment_plans.rotation_scan_plan import ( | ||
RotationScanComposite, | ||
multi_rotation_scan, | ||
) | ||
from mx_bluesky.hyperion.parameters.load_centre_collect import LoadCentreCollect | ||
from mx_bluesky.hyperion.utils.context import device_composite_from_context | ||
|
||
|
||
@dataclasses.dataclass | ||
class LoadCentreCollectComposite(RobotLoadThenCentreComposite, RotationScanComposite): | ||
"""Composite that provides access to the required devices.""" | ||
|
||
pass | ||
|
||
|
||
def create_devices(context: BlueskyContext) -> LoadCentreCollectComposite: | ||
"""Create the necessary devices for the plan.""" | ||
return device_composite_from_context(context, LoadCentreCollectComposite) | ||
|
||
|
||
def load_centre_collect_full_plan( | ||
composite: LoadCentreCollectComposite, | ||
params: LoadCentreCollect, | ||
oav_params: OAVParameters | None = None, | ||
): | ||
"""Attempt a complete data collection experiment, consisting of the following: | ||
* Load the sample if necessary | ||
* Move to the specified goniometer start angles | ||
* Perform optical centring, then X-ray centring | ||
* If X-ray centring finds a diffracting centre then move to that centre and | ||
* do a collection with the specified parameters. | ||
""" | ||
if not oav_params: | ||
oav_params = OAVParameters(context="xrayCentring") | ||
yield from robot_load_then_centre(composite, params.robot_load_then_centre) | ||
|
||
yield from multi_rotation_scan(composite, params.multi_rotation_scan, oav_params) |
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from typing import TypeVar | ||
|
||
from pydantic import BaseModel, model_validator | ||
|
||
from mx_bluesky.hyperion.parameters.components import ( | ||
HyperionParameters, | ||
WithSample, | ||
WithVisit, | ||
) | ||
from mx_bluesky.hyperion.parameters.gridscan import ( | ||
RobotLoadThenCentre, | ||
) | ||
from mx_bluesky.hyperion.parameters.rotation import MultiRotationScan | ||
|
||
T = TypeVar("T", bound=BaseModel) | ||
|
||
|
||
def construct_from_values(parent_context: dict, key: str, t: type[T]) -> T: | ||
values = dict(parent_context) | ||
values |= values[key] | ||
return t(**values) | ||
|
||
|
||
class LoadCentreCollect(HyperionParameters, WithVisit, WithSample): | ||
"""Experiment parameters to perform the combined robot load, | ||
pin-tip centre and rotation scan operations.""" | ||
|
||
robot_load_then_centre: RobotLoadThenCentre | ||
multi_rotation_scan: MultiRotationScan | ||
|
||
@model_validator(mode="before") | ||
@classmethod | ||
def validate_model(cls, values): | ||
allowed_keys = ( | ||
LoadCentreCollect.model_fields.keys() | ||
| RobotLoadThenCentre.model_fields.keys() | ||
| MultiRotationScan.model_fields.keys() | ||
) | ||
disallowed_keys = values.keys() - allowed_keys | ||
assert ( | ||
disallowed_keys == set() | ||
), f"Unexpected fields found in LoadCentreCollect {disallowed_keys}" | ||
|
||
values["robot_load_then_centre"] = construct_from_values( | ||
values, "robot_load_then_centre", RobotLoadThenCentre | ||
) | ||
values["multi_rotation_scan"] = construct_from_values( | ||
values, "multi_rotation_scan", MultiRotationScan | ||
) | ||
return values |
Oops, something went wrong.