mx-bluesky 0.3.1__py3-none-any.whl → 1.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mx_bluesky/_version.py +2 -2
- mx_bluesky/beamlines/i04/__init__.py +3 -0
- mx_bluesky/{i04 → beamlines/i04}/thawing_plan.py +5 -4
- mx_bluesky/{i24 → beamlines/i24}/serial/blueapi_config.yaml +1 -1
- mx_bluesky/{i24 → beamlines/i24}/serial/dcid.py +2 -2
- mx_bluesky/{i24 → beamlines/i24}/serial/extruder/EX-gui-edm/DetStage.edl +3 -3
- mx_bluesky/{i24 → beamlines/i24}/serial/extruder/EX-gui-edm/DiamondExtruder-I24-py3v1.edl +7 -7
- mx_bluesky/{i24 → beamlines/i24}/serial/extruder/i24ssx_Extruder_Collect_py3v2.py +12 -9
- mx_bluesky/{i24 → beamlines/i24}/serial/fixed_target/FT-gui-edm/CustomChip_py3v1.edl +3 -3
- mx_bluesky/{i24 → beamlines/i24}/serial/fixed_target/FT-gui-edm/DetStage.edl +3 -3
- mx_bluesky/{i24 → beamlines/i24}/serial/fixed_target/FT-gui-edm/DiamondChipI24-py3v1.edl +245 -200
- mx_bluesky/{i24 → beamlines/i24}/serial/fixed_target/FT-gui-edm/MappingLite-oxford_py3v1.edl +4 -4
- mx_bluesky/{i24 → beamlines/i24}/serial/fixed_target/FT-gui-edm/pumpprobe-py3v1.edl +8 -8
- mx_bluesky/beamlines/i24/serial/fixed_target/__init__.py +0 -0
- mx_bluesky/{i24 → beamlines/i24}/serial/fixed_target/i24ssx_Chip_Collect_py3v1.py +80 -70
- mx_bluesky/{i24 → beamlines/i24}/serial/fixed_target/i24ssx_Chip_Manager_py3v1.py +20 -21
- mx_bluesky/{i24 → beamlines/i24}/serial/fixed_target/i24ssx_Chip_Mapping_py3v1.py +5 -5
- mx_bluesky/{i24 → beamlines/i24}/serial/fixed_target/i24ssx_Chip_StartUp_py3v1.py +7 -4
- mx_bluesky/{i24 → beamlines/i24}/serial/fixed_target/i24ssx_moveonclick.py +59 -39
- mx_bluesky/{i24 → beamlines/i24}/serial/log.py +1 -9
- mx_bluesky/beamlines/i24/serial/parameters/__init__.py +15 -0
- mx_bluesky/{i24 → beamlines/i24}/serial/parameters/constants.py +1 -1
- mx_bluesky/{i24 → beamlines/i24}/serial/parameters/experiment_parameters.py +4 -25
- mx_bluesky/{i24 → beamlines/i24}/serial/parameters/utils.py +5 -3
- mx_bluesky/{i24 → beamlines/i24}/serial/run_serial.py +1 -1
- mx_bluesky/{i24 → beamlines/i24}/serial/setup_beamline/pv_abstract.py +1 -1
- mx_bluesky/{i24 → beamlines/i24}/serial/setup_beamline/setup_beamline.py +2 -2
- mx_bluesky/{i24 → beamlines/i24}/serial/setup_beamline/setup_detector.py +5 -5
- mx_bluesky/{i24 → beamlines/i24}/serial/write_nexus.py +6 -3
- mx_bluesky/hyperion/__init__.py +1 -0
- mx_bluesky/hyperion/__main__.py +374 -0
- mx_bluesky/hyperion/device_setup_plans/__init__.py +0 -0
- mx_bluesky/hyperion/device_setup_plans/dcm_pitch_roll_mirror_adjuster.py +134 -0
- mx_bluesky/hyperion/device_setup_plans/manipulate_sample.py +110 -0
- mx_bluesky/hyperion/device_setup_plans/position_detector.py +16 -0
- mx_bluesky/hyperion/device_setup_plans/read_hardware_for_setup.py +60 -0
- mx_bluesky/hyperion/device_setup_plans/setup_oav.py +87 -0
- mx_bluesky/hyperion/device_setup_plans/setup_panda.py +210 -0
- mx_bluesky/hyperion/device_setup_plans/setup_zebra.py +214 -0
- mx_bluesky/hyperion/device_setup_plans/smargon.py +25 -0
- mx_bluesky/hyperion/device_setup_plans/utils.py +55 -0
- mx_bluesky/hyperion/device_setup_plans/xbpm_feedback.py +93 -0
- mx_bluesky/hyperion/exceptions.py +47 -0
- mx_bluesky/hyperion/experiment_plans/__init__.py +30 -0
- mx_bluesky/hyperion/experiment_plans/experiment_registry.py +93 -0
- mx_bluesky/hyperion/experiment_plans/flyscan_xray_centre_plan.py +537 -0
- mx_bluesky/hyperion/experiment_plans/grid_detect_then_xray_centre_plan.py +209 -0
- mx_bluesky/hyperion/experiment_plans/load_centre_collect_full_plan.py +46 -0
- mx_bluesky/hyperion/experiment_plans/oav_grid_detection_plan.py +173 -0
- mx_bluesky/hyperion/experiment_plans/oav_snapshot_plan.py +81 -0
- mx_bluesky/hyperion/experiment_plans/optimise_attenuation_plan.py +463 -0
- mx_bluesky/hyperion/experiment_plans/pin_centre_then_xray_centre_plan.py +119 -0
- mx_bluesky/hyperion/experiment_plans/pin_tip_centring_plan.py +164 -0
- mx_bluesky/hyperion/experiment_plans/robot_load_and_change_energy.py +237 -0
- mx_bluesky/hyperion/experiment_plans/robot_load_then_centre_plan.py +162 -0
- mx_bluesky/hyperion/experiment_plans/rotation_scan_plan.py +436 -0
- mx_bluesky/hyperion/experiment_plans/set_energy_plan.py +60 -0
- mx_bluesky/hyperion/external_interaction/__init__.py +9 -0
- mx_bluesky/hyperion/external_interaction/callbacks/__init__.py +10 -0
- mx_bluesky/hyperion/external_interaction/callbacks/__main__.py +148 -0
- mx_bluesky/hyperion/external_interaction/callbacks/aperture_change_callback.py +22 -0
- mx_bluesky/hyperion/external_interaction/callbacks/common/__init__.py +0 -0
- mx_bluesky/hyperion/external_interaction/callbacks/common/callback_util.py +64 -0
- mx_bluesky/hyperion/external_interaction/callbacks/common/ispyb_mapping.py +62 -0
- mx_bluesky/hyperion/external_interaction/callbacks/grid_detection_callback.py +88 -0
- mx_bluesky/hyperion/external_interaction/callbacks/ispyb_callback_base.py +203 -0
- mx_bluesky/hyperion/external_interaction/callbacks/log_uid_tag_callback.py +20 -0
- mx_bluesky/hyperion/external_interaction/callbacks/logging_callback.py +29 -0
- mx_bluesky/hyperion/external_interaction/callbacks/plan_reactive_callback.py +101 -0
- mx_bluesky/hyperion/external_interaction/callbacks/robot_load/ispyb_callback.py +86 -0
- mx_bluesky/hyperion/external_interaction/callbacks/rotation/__init__.py +0 -0
- mx_bluesky/hyperion/external_interaction/callbacks/rotation/ispyb_callback.py +174 -0
- mx_bluesky/hyperion/external_interaction/callbacks/rotation/ispyb_mapping.py +17 -0
- mx_bluesky/hyperion/external_interaction/callbacks/rotation/nexus_callback.py +102 -0
- mx_bluesky/hyperion/external_interaction/callbacks/xray_centre/__init__.py +0 -0
- mx_bluesky/hyperion/external_interaction/callbacks/xray_centre/ispyb_callback.py +269 -0
- mx_bluesky/hyperion/external_interaction/callbacks/xray_centre/ispyb_mapping.py +53 -0
- mx_bluesky/hyperion/external_interaction/callbacks/xray_centre/nexus_callback.py +95 -0
- mx_bluesky/hyperion/external_interaction/callbacks/zocalo_callback.py +92 -0
- mx_bluesky/hyperion/external_interaction/config_server.py +35 -0
- mx_bluesky/hyperion/external_interaction/exceptions.py +13 -0
- mx_bluesky/hyperion/external_interaction/ispyb/__init__.py +0 -0
- mx_bluesky/hyperion/external_interaction/ispyb/data_model.py +95 -0
- mx_bluesky/hyperion/external_interaction/ispyb/exp_eye_store.py +125 -0
- mx_bluesky/hyperion/external_interaction/ispyb/ispyb_store.py +276 -0
- mx_bluesky/hyperion/external_interaction/ispyb/ispyb_utils.py +27 -0
- mx_bluesky/hyperion/external_interaction/nexus/__init__.py +0 -0
- mx_bluesky/hyperion/external_interaction/nexus/nexus_utils.py +148 -0
- mx_bluesky/hyperion/external_interaction/nexus/write_nexus.py +114 -0
- mx_bluesky/hyperion/log.py +99 -0
- mx_bluesky/hyperion/parameters/__init__.py +2 -0
- mx_bluesky/hyperion/parameters/cli.py +68 -0
- mx_bluesky/{parameters → hyperion/parameters}/components.py +80 -26
- mx_bluesky/hyperion/parameters/constants.py +158 -0
- mx_bluesky/hyperion/parameters/gridscan.py +221 -0
- mx_bluesky/hyperion/parameters/load_centre_collect.py +50 -0
- mx_bluesky/hyperion/parameters/robot_load.py +16 -0
- mx_bluesky/hyperion/parameters/rotation.py +160 -0
- mx_bluesky/hyperion/resources/panda/panda-gridscan.yaml +964 -0
- mx_bluesky/hyperion/tracing.py +28 -0
- mx_bluesky/hyperion/utils/context.py +84 -0
- mx_bluesky/hyperion/utils/utils.py +25 -0
- mx_bluesky/hyperion/utils/validation.py +196 -0
- mx_bluesky/jupyter_example.ipynb +3 -2
- {mx_bluesky-0.3.1.dist-info → mx_bluesky-1.2.0.dist-info}/METADATA +26 -11
- mx_bluesky-1.2.0.dist-info/RECORD +140 -0
- {mx_bluesky-0.3.1.dist-info → mx_bluesky-1.2.0.dist-info}/WHEEL +1 -1
- mx_bluesky-1.2.0.dist-info/entry_points.txt +8 -0
- mx_bluesky/i04/__init__.py +0 -3
- mx_bluesky/i24/serial/parameters/__init__.py +0 -15
- mx_bluesky/parameters/__init__.py +0 -31
- mx_bluesky-0.3.1.dist-info/RECORD +0 -67
- mx_bluesky-0.3.1.dist-info/entry_points.txt +0 -4
- /mx_bluesky/{i24 → beamlines}/__init__.py +0 -0
- /mx_bluesky/{i04 → beamlines/i04}/callbacks/murko_callback.py +0 -0
- /mx_bluesky/{i24/serial/extruder → beamlines/i24}/__init__.py +0 -0
- /mx_bluesky/{i24 → beamlines/i24}/serial/__init__.py +0 -0
- /mx_bluesky/{i24 → beamlines/i24}/serial/extruder/EX-gui-edm/microdrop_alignment.edl +0 -0
- /mx_bluesky/{i24/serial/fixed_target → beamlines/i24/serial/extruder}/__init__.py +0 -0
- /mx_bluesky/{i24 → beamlines/i24}/serial/fixed_target/FT-gui-edm/ME14E-GeneralPurpose.edl +0 -0
- /mx_bluesky/{i24 → beamlines/i24}/serial/fixed_target/FT-gui-edm/PMAC_Command.edl +0 -0
- /mx_bluesky/{i24 → beamlines/i24}/serial/fixed_target/FT-gui-edm/Shutter_Control.edl +0 -0
- /mx_bluesky/{i24 → beamlines/i24}/serial/fixed_target/FT-gui-edm/microdrop_alignment.edl +0 -0
- /mx_bluesky/{i24 → beamlines/i24}/serial/fixed_target/FT-gui-edm/nudgechip.edl +0 -0
- /mx_bluesky/{i24 → beamlines/i24}/serial/fixed_target/FT-gui-edm/short1-laser.png +0 -0
- /mx_bluesky/{i24 → beamlines/i24}/serial/fixed_target/FT-gui-edm/short2-laser.png +0 -0
- /mx_bluesky/{i24 → beamlines/i24}/serial/fixed_target/ft_utils.py +0 -0
- /mx_bluesky/{i24 → beamlines/i24}/serial/parameters/fixed_target/cs/cs_maker.json +0 -0
- /mx_bluesky/{i24 → beamlines/i24}/serial/parameters/fixed_target/cs/motor_direction.txt +0 -0
- /mx_bluesky/{i24 → beamlines/i24}/serial/parameters/fixed_target/pvar_files/minichip-oxford.pvar +0 -0
- /mx_bluesky/{i24 → beamlines/i24}/serial/parameters/fixed_target/pvar_files/oxford.pvar +0 -0
- /mx_bluesky/{i24 → beamlines/i24}/serial/run_extruder.sh +0 -0
- /mx_bluesky/{i24 → beamlines/i24}/serial/run_fixed_target.sh +0 -0
- /mx_bluesky/{i24 → beamlines/i24}/serial/run_ssx.sh +0 -0
- /mx_bluesky/{i24 → beamlines/i24}/serial/set_visit_directory.sh +0 -0
- /mx_bluesky/{i24 → beamlines/i24}/serial/setup_beamline/__init__.py +0 -0
- /mx_bluesky/{i24 → beamlines/i24}/serial/setup_beamline/ca.py +0 -0
- /mx_bluesky/{i24 → beamlines/i24}/serial/setup_beamline/pv.py +0 -0
- /mx_bluesky/{i24 → beamlines/i24}/serial/setup_beamline/setup_zebra_plans.py +0 -0
- /mx_bluesky/{i24 → beamlines/i24}/serial/start_blueapi.sh +0 -0
- {mx_bluesky-0.3.1.dist-info → mx_bluesky-1.2.0.dist-info}/LICENSE +0 -0
- {mx_bluesky-0.3.1.dist-info → mx_bluesky-1.2.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
from bluesky import plan_stubs as bps
|
|
3
|
+
from dodal.devices.smargon import Smargon
|
|
4
|
+
|
|
5
|
+
from mx_bluesky.hyperion.exceptions import WarningException
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def move_smargon_warn_on_out_of_range(
|
|
9
|
+
smargon: Smargon, position: np.ndarray | list[float] | tuple[float, float, float]
|
|
10
|
+
):
|
|
11
|
+
"""Throws a WarningException if the specified position is out of range for the
|
|
12
|
+
smargon. Otherwise moves to that position."""
|
|
13
|
+
limits = yield from smargon.get_xyz_limits()
|
|
14
|
+
if not limits.position_valid(position):
|
|
15
|
+
raise WarningException(
|
|
16
|
+
"Pin tip centring failed - pin too long/short/bent and out of range"
|
|
17
|
+
)
|
|
18
|
+
yield from bps.mv(
|
|
19
|
+
smargon.x,
|
|
20
|
+
position[0],
|
|
21
|
+
smargon.y,
|
|
22
|
+
position[1],
|
|
23
|
+
smargon.z,
|
|
24
|
+
position[2],
|
|
25
|
+
)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
from collections.abc import Generator
|
|
2
|
+
|
|
3
|
+
from bluesky import plan_stubs as bps
|
|
4
|
+
from bluesky import preprocessors as bpp
|
|
5
|
+
from bluesky.utils import Msg
|
|
6
|
+
from dodal.devices.dcm import DCM
|
|
7
|
+
from dodal.devices.detector import (
|
|
8
|
+
DetectorParams,
|
|
9
|
+
)
|
|
10
|
+
from dodal.devices.detector.detector_motion import DetectorMotion, ShutterState
|
|
11
|
+
from dodal.devices.eiger import EigerDetector
|
|
12
|
+
|
|
13
|
+
from mx_bluesky.hyperion.device_setup_plans.position_detector import (
|
|
14
|
+
set_detector_z_position,
|
|
15
|
+
set_shutter,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def fill_in_energy_if_not_supplied(dcm: DCM, detector_params: DetectorParams):
|
|
20
|
+
if not detector_params.expected_energy_ev:
|
|
21
|
+
actual_energy_ev = 1000 * (yield from bps.rd(dcm.energy_in_kev))
|
|
22
|
+
detector_params.expected_energy_ev = actual_energy_ev
|
|
23
|
+
return detector_params
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def start_preparing_data_collection_then_do_plan(
|
|
27
|
+
eiger: EigerDetector,
|
|
28
|
+
detector_motion: DetectorMotion,
|
|
29
|
+
detector_distance_mm: float | None,
|
|
30
|
+
plan_to_run: Generator[Msg, None, None],
|
|
31
|
+
group="ready_for_data_collection",
|
|
32
|
+
) -> Generator[Msg, None, None]:
|
|
33
|
+
"""Starts preparing for the next data collection and then runs the
|
|
34
|
+
given plan.
|
|
35
|
+
|
|
36
|
+
Preparation consists of:
|
|
37
|
+
* Arming the Eiger
|
|
38
|
+
* Moving the detector to the specified position
|
|
39
|
+
* Opening the detect shutter
|
|
40
|
+
If the plan fails it will disarm the eiger.
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
def wrapped_plan():
|
|
44
|
+
yield from bps.abs_set(eiger.do_arm, 1, group=group)
|
|
45
|
+
if detector_distance_mm:
|
|
46
|
+
yield from set_detector_z_position(
|
|
47
|
+
detector_motion, detector_distance_mm, group
|
|
48
|
+
)
|
|
49
|
+
yield from set_shutter(detector_motion, ShutterState.OPEN, group)
|
|
50
|
+
yield from plan_to_run
|
|
51
|
+
|
|
52
|
+
yield from bpp.contingency_wrapper(
|
|
53
|
+
wrapped_plan(),
|
|
54
|
+
except_plan=lambda e: (yield from bps.stop(eiger)),
|
|
55
|
+
)
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
from bluesky import plan_stubs as bps
|
|
2
|
+
from bluesky.preprocessors import finalize_wrapper
|
|
3
|
+
from bluesky.utils import make_decorator
|
|
4
|
+
from dodal.devices.attenuator import Attenuator
|
|
5
|
+
from dodal.devices.xbpm_feedback import Pause, XBPMFeedback
|
|
6
|
+
|
|
7
|
+
from mx_bluesky.hyperion.log import LOGGER
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def _check_and_pause_feedback(
|
|
11
|
+
xbpm_feedback: XBPMFeedback,
|
|
12
|
+
attenuator: Attenuator,
|
|
13
|
+
desired_transmission_fraction: float,
|
|
14
|
+
):
|
|
15
|
+
"""Checks that the xbpm is in position before then turning it off and setting a new
|
|
16
|
+
transmission.
|
|
17
|
+
|
|
18
|
+
Args:
|
|
19
|
+
xbpm_feedback (XBPMFeedback): The XBPM device that is responsible for keeping
|
|
20
|
+
the beam in position
|
|
21
|
+
attenuator (Attenuator): The attenuator used to set transmission
|
|
22
|
+
desired_transmission_fraction (float): The desired transmission to set after
|
|
23
|
+
turning XBPM feedback off.
|
|
24
|
+
|
|
25
|
+
"""
|
|
26
|
+
yield from bps.mv(attenuator, 1.0)
|
|
27
|
+
LOGGER.info("Waiting for XBPM feedback to be stable")
|
|
28
|
+
yield from bps.trigger(xbpm_feedback, wait=True)
|
|
29
|
+
LOGGER.info(
|
|
30
|
+
f"XPBM feedback in position, pausing and setting transmission to {desired_transmission_fraction}"
|
|
31
|
+
)
|
|
32
|
+
yield from bps.mv(xbpm_feedback.pause_feedback, Pause.PAUSE)
|
|
33
|
+
yield from bps.mv(attenuator, desired_transmission_fraction)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _unpause_xbpm_feedback_and_set_transmission_to_1(
|
|
37
|
+
xbpm_feedback: XBPMFeedback, attenuator: Attenuator
|
|
38
|
+
):
|
|
39
|
+
"""Turns the XBPM feedback back on and sets transmission to 1 so that it keeps the
|
|
40
|
+
beam aligned whilst not collecting.
|
|
41
|
+
|
|
42
|
+
Args:
|
|
43
|
+
xbpm_feedback (XBPMFeedback): The XBPM device that is responsible for keeping
|
|
44
|
+
the beam in position
|
|
45
|
+
attenuator (Attenuator): The attenuator used to set transmission
|
|
46
|
+
"""
|
|
47
|
+
yield from bps.mv(xbpm_feedback.pause_feedback, Pause.RUN, attenuator, 1.0)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def transmission_and_xbpm_feedback_for_collection_wrapper(
|
|
51
|
+
plan,
|
|
52
|
+
xbpm_feedback: XBPMFeedback,
|
|
53
|
+
attenuator: Attenuator,
|
|
54
|
+
desired_transmission_fraction: float,
|
|
55
|
+
):
|
|
56
|
+
"""Sets the transmission for the data collection, ensuring the xbpm feedback is valid
|
|
57
|
+
this wrapper should be run around every data collection or movement that may disrupt
|
|
58
|
+
the XBPM feedback.
|
|
59
|
+
|
|
60
|
+
XBPM feedback isn't reliable during collections due to:
|
|
61
|
+
* Objects (e.g. attenuator) crossing the beam can cause large (incorrect) feedback movements
|
|
62
|
+
* Lower transmissions/higher energies are less reliable for the xbpm
|
|
63
|
+
|
|
64
|
+
So we need to keep the transmission at 100% and the feedback on when not collecting
|
|
65
|
+
and then turn it off and set the correct transmission for collection. The feedback
|
|
66
|
+
mostly accounts for slow thermal drift so it is safe to assume that the beam is
|
|
67
|
+
stable during a collection.
|
|
68
|
+
|
|
69
|
+
Args:
|
|
70
|
+
plan: The plan performing the data collection
|
|
71
|
+
xbpm_feedback (XBPMFeedback): The XBPM device that is responsible for keeping
|
|
72
|
+
the beam in position
|
|
73
|
+
attenuator (Attenuator): The attenuator used to set transmission
|
|
74
|
+
desired_transmission_fraction (float): The desired transmission for the collection
|
|
75
|
+
"""
|
|
76
|
+
|
|
77
|
+
def _inner_plan():
|
|
78
|
+
yield from _check_and_pause_feedback(
|
|
79
|
+
xbpm_feedback, attenuator, desired_transmission_fraction
|
|
80
|
+
)
|
|
81
|
+
return (yield from plan)
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
yield from finalize_wrapper(
|
|
85
|
+
_inner_plan(),
|
|
86
|
+
_unpause_xbpm_feedback_and_set_transmission_to_1(xbpm_feedback, attenuator),
|
|
87
|
+
)
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
transmission_and_xbpm_feedback_for_collection_decorator = make_decorator(
|
|
92
|
+
transmission_and_xbpm_feedback_for_collection_wrapper
|
|
93
|
+
)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
from collections.abc import Callable, Generator
|
|
2
|
+
from typing import TypeVar
|
|
3
|
+
|
|
4
|
+
from bluesky.plan_stubs import null
|
|
5
|
+
from bluesky.preprocessors import contingency_wrapper
|
|
6
|
+
from bluesky.utils import Msg
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class WarningException(Exception):
|
|
10
|
+
"""An exception used when we want to warn GDA of a
|
|
11
|
+
problem but continue with UDC anyway"""
|
|
12
|
+
|
|
13
|
+
pass
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
T = TypeVar("T")
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def catch_exception_and_warn(
|
|
20
|
+
exception_to_catch: type[Exception],
|
|
21
|
+
func: Callable[..., Generator[Msg, None, T]],
|
|
22
|
+
*args,
|
|
23
|
+
**kwargs,
|
|
24
|
+
) -> Generator[Msg, None, T]:
|
|
25
|
+
"""A plan wrapper to catch a specific exception and instead raise a WarningException,
|
|
26
|
+
so that UDC is not halted
|
|
27
|
+
|
|
28
|
+
Example usage:
|
|
29
|
+
|
|
30
|
+
'def plan_which_can_raise_exception_a(*args, **kwargs):
|
|
31
|
+
...
|
|
32
|
+
yield from catch_exception_and_warn(ExceptionA, plan_which_can_raise_exception_a, **args, **kwargs)'
|
|
33
|
+
|
|
34
|
+
This will catch ExceptionA raised by the plan and instead raise a WarningException
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
def warn_if_exception_matches(exception: Exception):
|
|
38
|
+
if isinstance(exception, exception_to_catch):
|
|
39
|
+
raise WarningException(str(exception))
|
|
40
|
+
yield from null()
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
yield from contingency_wrapper(
|
|
44
|
+
func(*args, **kwargs),
|
|
45
|
+
except_plan=warn_if_exception_matches,
|
|
46
|
+
)
|
|
47
|
+
)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""This module contains the experimental plans which hyperion can run.
|
|
2
|
+
|
|
3
|
+
The __all__ list in here are the plans that are externally available from outside Hyperion.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from mx_bluesky.hyperion.experiment_plans.flyscan_xray_centre_plan import (
|
|
7
|
+
flyscan_xray_centre,
|
|
8
|
+
)
|
|
9
|
+
from mx_bluesky.hyperion.experiment_plans.grid_detect_then_xray_centre_plan import (
|
|
10
|
+
grid_detect_then_xray_centre,
|
|
11
|
+
)
|
|
12
|
+
from mx_bluesky.hyperion.experiment_plans.pin_centre_then_xray_centre_plan import (
|
|
13
|
+
pin_tip_centre_then_xray_centre,
|
|
14
|
+
)
|
|
15
|
+
from mx_bluesky.hyperion.experiment_plans.robot_load_then_centre_plan import (
|
|
16
|
+
robot_load_then_centre,
|
|
17
|
+
)
|
|
18
|
+
from mx_bluesky.hyperion.experiment_plans.rotation_scan_plan import (
|
|
19
|
+
multi_rotation_scan,
|
|
20
|
+
rotation_scan,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
__all__ = [
|
|
24
|
+
"flyscan_xray_centre",
|
|
25
|
+
"grid_detect_then_xray_centre",
|
|
26
|
+
"rotation_scan",
|
|
27
|
+
"pin_tip_centre_then_xray_centre",
|
|
28
|
+
"multi_rotation_scan",
|
|
29
|
+
"robot_load_then_centre",
|
|
30
|
+
]
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections.abc import Callable
|
|
4
|
+
from typing import TypedDict
|
|
5
|
+
|
|
6
|
+
import mx_bluesky.hyperion.experiment_plans.flyscan_xray_centre_plan as flyscan_xray_centre_plan
|
|
7
|
+
import mx_bluesky.hyperion.experiment_plans.rotation_scan_plan as rotation_scan_plan
|
|
8
|
+
from mx_bluesky.hyperion.experiment_plans import (
|
|
9
|
+
grid_detect_then_xray_centre_plan,
|
|
10
|
+
load_centre_collect_full_plan,
|
|
11
|
+
pin_centre_then_xray_centre_plan,
|
|
12
|
+
robot_load_then_centre_plan,
|
|
13
|
+
)
|
|
14
|
+
from mx_bluesky.hyperion.external_interaction.callbacks.common.callback_util import (
|
|
15
|
+
CallbacksFactory,
|
|
16
|
+
create_gridscan_callbacks,
|
|
17
|
+
create_load_centre_collect_callbacks,
|
|
18
|
+
create_robot_load_and_centre_callbacks,
|
|
19
|
+
create_rotation_callbacks,
|
|
20
|
+
)
|
|
21
|
+
from mx_bluesky.hyperion.parameters.gridscan import (
|
|
22
|
+
GridScanWithEdgeDetect,
|
|
23
|
+
PinTipCentreThenXrayCentre,
|
|
24
|
+
RobotLoadThenCentre,
|
|
25
|
+
ThreeDGridScan,
|
|
26
|
+
)
|
|
27
|
+
from mx_bluesky.hyperion.parameters.load_centre_collect import LoadCentreCollect
|
|
28
|
+
from mx_bluesky.hyperion.parameters.rotation import MultiRotationScan, RotationScan
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def not_implemented():
|
|
32
|
+
raise NotImplementedError
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def do_nothing():
|
|
36
|
+
pass
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class ExperimentRegistryEntry(TypedDict):
|
|
40
|
+
setup: Callable
|
|
41
|
+
param_type: type[
|
|
42
|
+
ThreeDGridScan
|
|
43
|
+
| GridScanWithEdgeDetect
|
|
44
|
+
| RotationScan
|
|
45
|
+
| MultiRotationScan
|
|
46
|
+
| PinTipCentreThenXrayCentre
|
|
47
|
+
| RobotLoadThenCentre
|
|
48
|
+
| LoadCentreCollect
|
|
49
|
+
]
|
|
50
|
+
callbacks_factory: CallbacksFactory
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
PLAN_REGISTRY: dict[str, ExperimentRegistryEntry] = {
|
|
54
|
+
"flyscan_xray_centre": {
|
|
55
|
+
"setup": flyscan_xray_centre_plan.create_devices,
|
|
56
|
+
"param_type": ThreeDGridScan,
|
|
57
|
+
"callbacks_factory": create_gridscan_callbacks,
|
|
58
|
+
},
|
|
59
|
+
"grid_detect_then_xray_centre": {
|
|
60
|
+
"setup": grid_detect_then_xray_centre_plan.create_devices,
|
|
61
|
+
"param_type": GridScanWithEdgeDetect,
|
|
62
|
+
"callbacks_factory": create_gridscan_callbacks,
|
|
63
|
+
},
|
|
64
|
+
"rotation_scan": {
|
|
65
|
+
"setup": rotation_scan_plan.create_devices,
|
|
66
|
+
"param_type": RotationScan,
|
|
67
|
+
"callbacks_factory": create_rotation_callbacks,
|
|
68
|
+
},
|
|
69
|
+
"pin_tip_centre_then_xray_centre": {
|
|
70
|
+
"setup": pin_centre_then_xray_centre_plan.create_devices,
|
|
71
|
+
"param_type": PinTipCentreThenXrayCentre,
|
|
72
|
+
"callbacks_factory": create_gridscan_callbacks,
|
|
73
|
+
},
|
|
74
|
+
"robot_load_then_centre": {
|
|
75
|
+
"setup": robot_load_then_centre_plan.create_devices,
|
|
76
|
+
"param_type": RobotLoadThenCentre,
|
|
77
|
+
"callbacks_factory": create_robot_load_and_centre_callbacks,
|
|
78
|
+
},
|
|
79
|
+
"multi_rotation_scan": {
|
|
80
|
+
"setup": rotation_scan_plan.create_devices,
|
|
81
|
+
"param_type": MultiRotationScan,
|
|
82
|
+
"callbacks_factory": create_rotation_callbacks,
|
|
83
|
+
},
|
|
84
|
+
"load_centre_collect_full_plan": {
|
|
85
|
+
"setup": load_centre_collect_full_plan.create_devices,
|
|
86
|
+
"param_type": LoadCentreCollect,
|
|
87
|
+
"callbacks_factory": create_load_centre_collect_callbacks,
|
|
88
|
+
},
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class PlanNotFound(Exception):
|
|
93
|
+
pass
|