mx-bluesky 1.4.7__py3-none-any.whl → 1.4.8__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/redis_to_murko_forwarder.py +4 -4
- mx_bluesky/beamlines/i04/thawing_plan.py +8 -2
- mx_bluesky/beamlines/i23/__init__.py +3 -0
- mx_bluesky/beamlines/i23/serial.py +71 -0
- mx_bluesky/beamlines/i24/serial/__init__.py +2 -0
- mx_bluesky/beamlines/i24/serial/extruder/i24ssx_Extruder_Collect_py3v2.py +7 -2
- mx_bluesky/beamlines/i24/serial/fixed_target/FT-gui-edm/pumpprobe-py3v1.edl +3 -3
- mx_bluesky/beamlines/i24/serial/fixed_target/i24ssx_Chip_Collect_py3v1.py +6 -56
- mx_bluesky/beamlines/i24/serial/log.py +9 -10
- mx_bluesky/beamlines/i24/serial/parameters/utils.py +36 -7
- mx_bluesky/beamlines/i24/serial/setup_beamline/pv.py +0 -1
- mx_bluesky/beamlines/i24/serial/setup_beamline/pv_abstract.py +4 -4
- mx_bluesky/beamlines/i24/serial/setup_beamline/setup_beamline.py +4 -4
- mx_bluesky/beamlines/i24/serial/setup_beamline/setup_detector.py +2 -1
- mx_bluesky/beamlines/i24/serial/web_gui_plans/general_plans.py +71 -11
- mx_bluesky/beamlines/i24/serial/write_nexus.py +3 -3
- mx_bluesky/{hyperion → common}/device_setup_plans/check_beamstop.py +1 -1
- mx_bluesky/{hyperion → common}/device_setup_plans/manipulate_sample.py +1 -1
- mx_bluesky/{hyperion → common}/device_setup_plans/setup_oav.py +12 -6
- mx_bluesky/{hyperion → common}/experiment_plans/change_aperture_then_move_plan.py +4 -5
- mx_bluesky/{hyperion → common}/experiment_plans/oav_grid_detection_plan.py +6 -6
- mx_bluesky/common/external_interaction/callbacks/common/ispyb_callback_base.py +6 -5
- mx_bluesky/common/external_interaction/callbacks/xray_centre/ispyb_callback.py +16 -47
- mx_bluesky/common/external_interaction/ispyb/ispyb_store.py +4 -1
- mx_bluesky/common/external_interaction/ispyb/ispyb_utils.py +4 -4
- mx_bluesky/common/parameters/components.py +22 -2
- mx_bluesky/common/parameters/constants.py +4 -16
- mx_bluesky/common/parameters/gridscan.py +36 -32
- mx_bluesky/common/plans/common_flyscan_xray_centre_plan.py +316 -0
- mx_bluesky/common/plans/inner_plans/__init__ .py +0 -0
- mx_bluesky/common/plans/read_hardware.py +3 -3
- mx_bluesky/common/utils/log.py +15 -12
- mx_bluesky/hyperion/__main__.py +2 -15
- mx_bluesky/hyperion/device_setup_plans/dcm_pitch_roll_mirror_adjuster.py +4 -4
- mx_bluesky/hyperion/device_setup_plans/setup_zebra.py +0 -33
- mx_bluesky/hyperion/device_setup_plans/utils.py +4 -4
- mx_bluesky/hyperion/experiment_plans/__init__.py +0 -6
- mx_bluesky/hyperion/experiment_plans/experiment_registry.py +0 -9
- mx_bluesky/hyperion/experiment_plans/grid_detect_then_xray_centre_plan.py +71 -88
- mx_bluesky/hyperion/experiment_plans/hyperion_flyscan_xray_centre_plan.py +183 -0
- mx_bluesky/hyperion/experiment_plans/load_centre_collect_full_plan.py +12 -7
- mx_bluesky/hyperion/experiment_plans/oav_snapshot_plan.py +28 -7
- mx_bluesky/hyperion/experiment_plans/pin_centre_then_xray_centre_plan.py +4 -4
- mx_bluesky/hyperion/experiment_plans/pin_tip_centring_plan.py +1 -1
- mx_bluesky/hyperion/experiment_plans/robot_load_and_change_energy.py +11 -3
- mx_bluesky/hyperion/experiment_plans/robot_load_then_centre_plan.py +9 -8
- mx_bluesky/hyperion/experiment_plans/rotation_scan_plan.py +18 -56
- mx_bluesky/hyperion/experiment_plans/set_energy_plan.py +2 -2
- mx_bluesky/hyperion/external_interaction/agamemnon.py +62 -70
- mx_bluesky/hyperion/external_interaction/callbacks/__main__.py +8 -6
- mx_bluesky/hyperion/external_interaction/callbacks/snapshot_callback.py +183 -31
- mx_bluesky/hyperion/parameters/cli.py +2 -10
- mx_bluesky/hyperion/parameters/constants.py +0 -5
- mx_bluesky/hyperion/parameters/device_composites.py +40 -5
- mx_bluesky/hyperion/parameters/gridscan.py +9 -58
- mx_bluesky/hyperion/parameters/rotation.py +0 -4
- mx_bluesky/hyperion/utils/context.py +2 -5
- mx_bluesky/hyperion/utils/validation.py +13 -10
- {mx_bluesky-1.4.7.dist-info → mx_bluesky-1.4.8.dist-info}/METADATA +5 -4
- {mx_bluesky-1.4.7.dist-info → mx_bluesky-1.4.8.dist-info}/RECORD +69 -65
- {mx_bluesky-1.4.7.dist-info → mx_bluesky-1.4.8.dist-info}/WHEEL +1 -1
- mx_bluesky/hyperion/experiment_plans/flyscan_xray_centre_plan.py +0 -467
- /mx_bluesky/beamlines/i24/serial/fixed_target/FT-gui-edm/{short1-laser.png → s1l.png} +0 -0
- /mx_bluesky/beamlines/i24/serial/fixed_target/FT-gui-edm/{short2-laser.png → s2l.png} +0 -0
- /mx_bluesky/{hyperion → common}/device_setup_plans/position_detector.py +0 -0
- /mx_bluesky/common/plans/{do_fgs.py → inner_plans/do_fgs.py} +0 -0
- {mx_bluesky-1.4.7.dist-info → mx_bluesky-1.4.8.dist-info}/entry_points.txt +0 -0
- {mx_bluesky-1.4.7.dist-info → mx_bluesky-1.4.8.dist-info}/licenses/LICENSE +0 -0
- {mx_bluesky-1.4.7.dist-info → mx_bluesky-1.4.8.dist-info}/top_level.txt +0 -0
|
@@ -10,13 +10,14 @@ from bluesky.utils import MsgGenerator
|
|
|
10
10
|
from dodal.devices.aperturescatterguard import ApertureScatterguard
|
|
11
11
|
from dodal.devices.attenuator.attenuator import BinaryFilterAttenuator
|
|
12
12
|
from dodal.devices.backlight import Backlight
|
|
13
|
-
from dodal.devices.dcm import DCM
|
|
14
13
|
from dodal.devices.detector.detector_motion import DetectorMotion
|
|
15
14
|
from dodal.devices.eiger import EigerDetector
|
|
16
15
|
from dodal.devices.fast_grid_scan import PandAFastGridScan, ZebraFastGridScan
|
|
17
16
|
from dodal.devices.flux import Flux
|
|
18
17
|
from dodal.devices.focusing_mirror import FocusingMirrorWithStripes, MirrorVoltages
|
|
19
|
-
from dodal.devices.i03
|
|
18
|
+
from dodal.devices.i03 import Beamstop
|
|
19
|
+
from dodal.devices.i03.dcm import DCM
|
|
20
|
+
from dodal.devices.i03.undulator_dcm import UndulatorDCM
|
|
20
21
|
from dodal.devices.motors import XYZPositioner
|
|
21
22
|
from dodal.devices.oav.oav_detector import OAV
|
|
22
23
|
from dodal.devices.oav.pin_image_recognition import PinTipDetection
|
|
@@ -26,7 +27,6 @@ from dodal.devices.smargon import Smargon
|
|
|
26
27
|
from dodal.devices.synchrotron import Synchrotron
|
|
27
28
|
from dodal.devices.thawer import Thawer
|
|
28
29
|
from dodal.devices.undulator import Undulator
|
|
29
|
-
from dodal.devices.undulator_dcm import UndulatorDCM
|
|
30
30
|
from dodal.devices.webcam import Webcam
|
|
31
31
|
from dodal.devices.xbpm_feedback import XBPMFeedback
|
|
32
32
|
from dodal.devices.zebra.zebra import Zebra
|
|
@@ -112,6 +112,7 @@ def _flyscan_plan_from_robot_load_params(
|
|
|
112
112
|
yield from pin_centre_then_flyscan_plan(
|
|
113
113
|
cast(GridDetectThenXRayCentreComposite, composite),
|
|
114
114
|
params.pin_centre_then_xray_centre_params,
|
|
115
|
+
oav_config_file,
|
|
115
116
|
)
|
|
116
117
|
|
|
117
118
|
|
|
@@ -131,6 +132,7 @@ def _robot_load_then_flyscan_plan(
|
|
|
131
132
|
def robot_load_then_xray_centre(
|
|
132
133
|
composite: RobotLoadThenCentreComposite,
|
|
133
134
|
parameters: RobotLoadThenCentre,
|
|
135
|
+
oav_config_file: str = OavConstants.OAV_CONFIG_JSON,
|
|
134
136
|
) -> MsgGenerator:
|
|
135
137
|
"""Perform pin-tip detection followed by a flyscan to determine centres of interest.
|
|
136
138
|
Performs a robot load if necessary."""
|
|
@@ -154,10 +156,7 @@ def robot_load_then_xray_centre(
|
|
|
154
156
|
|
|
155
157
|
if doing_sample_load:
|
|
156
158
|
LOGGER.info("Pin not loaded, loading and centring")
|
|
157
|
-
plan = _robot_load_then_flyscan_plan(
|
|
158
|
-
composite,
|
|
159
|
-
parameters,
|
|
160
|
-
)
|
|
159
|
+
plan = _robot_load_then_flyscan_plan(composite, parameters, oav_config_file)
|
|
161
160
|
else:
|
|
162
161
|
# Robot load normally sets the energy so we should do this explicitly if no load is
|
|
163
162
|
# being done
|
|
@@ -168,7 +167,9 @@ def robot_load_then_xray_centre(
|
|
|
168
167
|
)
|
|
169
168
|
|
|
170
169
|
if doing_chi_change:
|
|
171
|
-
plan = _flyscan_plan_from_robot_load_params(
|
|
170
|
+
plan = _flyscan_plan_from_robot_load_params(
|
|
171
|
+
composite, parameters, oav_config_file
|
|
172
|
+
)
|
|
172
173
|
LOGGER.info("Pin already loaded but chi changed so centring")
|
|
173
174
|
else:
|
|
174
175
|
LOGGER.info("Pin already loaded and chi not changed so doing nothing")
|
|
@@ -10,11 +10,11 @@ from bluesky.utils import MsgGenerator
|
|
|
10
10
|
from dodal.devices.aperturescatterguard import ApertureScatterguard
|
|
11
11
|
from dodal.devices.attenuator.attenuator import BinaryFilterAttenuator
|
|
12
12
|
from dodal.devices.backlight import Backlight
|
|
13
|
-
from dodal.devices.dcm import DCM
|
|
14
13
|
from dodal.devices.detector.detector_motion import DetectorMotion
|
|
15
14
|
from dodal.devices.eiger import EigerDetector
|
|
16
15
|
from dodal.devices.flux import Flux
|
|
17
|
-
from dodal.devices.i03
|
|
16
|
+
from dodal.devices.i03 import Beamstop
|
|
17
|
+
from dodal.devices.i03.dcm import DCM
|
|
18
18
|
from dodal.devices.oav.oav_detector import OAV
|
|
19
19
|
from dodal.devices.oav.oav_parameters import OAVParameters
|
|
20
20
|
from dodal.devices.robot import BartRobot
|
|
@@ -30,6 +30,12 @@ from dodal.plans.preprocessors.verify_undulator_gap import (
|
|
|
30
30
|
verify_undulator_gap_before_run_decorator,
|
|
31
31
|
)
|
|
32
32
|
|
|
33
|
+
from mx_bluesky.common.device_setup_plans.manipulate_sample import (
|
|
34
|
+
cleanup_sample_environment,
|
|
35
|
+
move_phi_chi_omega,
|
|
36
|
+
move_x_y_z,
|
|
37
|
+
setup_sample_environment,
|
|
38
|
+
)
|
|
33
39
|
from mx_bluesky.common.parameters.components import WithSnapshot
|
|
34
40
|
from mx_bluesky.common.plans.read_hardware import (
|
|
35
41
|
read_hardware_for_zocalo,
|
|
@@ -41,12 +47,6 @@ from mx_bluesky.common.preprocessors.preprocessors import (
|
|
|
41
47
|
)
|
|
42
48
|
from mx_bluesky.common.utils.context import device_composite_from_context
|
|
43
49
|
from mx_bluesky.common.utils.log import LOGGER
|
|
44
|
-
from mx_bluesky.hyperion.device_setup_plans.manipulate_sample import (
|
|
45
|
-
cleanup_sample_environment,
|
|
46
|
-
move_phi_chi_omega,
|
|
47
|
-
move_x_y_z,
|
|
48
|
-
setup_sample_environment,
|
|
49
|
-
)
|
|
50
50
|
from mx_bluesky.hyperion.device_setup_plans.setup_zebra import (
|
|
51
51
|
arm_zebra,
|
|
52
52
|
setup_zebra_for_rotation,
|
|
@@ -356,68 +356,30 @@ def _move_and_rotation(
|
|
|
356
356
|
group=CONST.WAIT.ROTATION_READY_FOR_DC,
|
|
357
357
|
)
|
|
358
358
|
yield from oav_snapshot_plan(composite, params, oav_params)
|
|
359
|
-
yield from rotation_scan_plan(
|
|
360
|
-
composite,
|
|
361
|
-
params,
|
|
362
|
-
motion_values,
|
|
363
|
-
)
|
|
359
|
+
yield from rotation_scan_plan(composite, params, motion_values)
|
|
364
360
|
|
|
365
361
|
|
|
366
|
-
def
|
|
362
|
+
def multi_rotation_scan(
|
|
367
363
|
composite: RotationScanComposite,
|
|
368
|
-
parameters:
|
|
364
|
+
parameters: MultiRotationScan,
|
|
369
365
|
oav_params: OAVParameters | None = None,
|
|
370
366
|
) -> MsgGenerator:
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
if not oav_params:
|
|
374
|
-
oav_params = OAVParameters(context="xrayCentring")
|
|
375
|
-
|
|
376
|
-
@transmission_and_xbpm_feedback_for_collection_decorator(
|
|
377
|
-
composite,
|
|
378
|
-
parameters.transmission_frac,
|
|
379
|
-
)
|
|
380
|
-
@verify_undulator_gap_before_run_decorator(composite)
|
|
381
|
-
@bpp.set_run_key_decorator("rotation_scan")
|
|
382
|
-
@bpp.run_decorator( # attach experiment metadata to the start document
|
|
367
|
+
@bpp.set_run_key_decorator(CONST.PLAN.ROTATION_MULTI_OUTER)
|
|
368
|
+
@bpp.run_decorator(
|
|
383
369
|
md={
|
|
384
|
-
"
|
|
385
|
-
"mx_bluesky_parameters": parameters.model_dump_json(),
|
|
370
|
+
"activate_callbacks": ["BeamDrawingCallback"],
|
|
386
371
|
"with_snapshot": parameters.model_dump_json(
|
|
387
372
|
include=WithSnapshot.model_fields.keys() # type: ignore
|
|
388
373
|
),
|
|
389
|
-
"activate_callbacks": [
|
|
390
|
-
"BeamDrawingCallback",
|
|
391
|
-
"RotationISPyBCallback",
|
|
392
|
-
"RotationNexusFileCallback",
|
|
393
|
-
],
|
|
394
374
|
}
|
|
395
375
|
)
|
|
396
|
-
def
|
|
397
|
-
|
|
398
|
-
):
|
|
399
|
-
eiger: EigerDetector = composite.eiger
|
|
400
|
-
eiger.set_detector_parameters(params.detector_params)
|
|
401
|
-
|
|
402
|
-
@bpp.finalize_decorator(lambda: _cleanup_plan(composite))
|
|
403
|
-
def rotation_with_cleanup_and_stage(params: RotationScan):
|
|
404
|
-
yield from _move_and_rotation(composite, params, oav_params)
|
|
405
|
-
|
|
406
|
-
LOGGER.info("setting up and staging eiger...")
|
|
407
|
-
yield from start_preparing_data_collection_then_do_plan(
|
|
408
|
-
composite.beamstop,
|
|
409
|
-
eiger,
|
|
410
|
-
composite.detector_motion,
|
|
411
|
-
params.detector_distance_mm,
|
|
412
|
-
rotation_with_cleanup_and_stage(params),
|
|
413
|
-
group=CONST.WAIT.ROTATION_READY_FOR_DC,
|
|
414
|
-
)
|
|
415
|
-
yield from bps.unstage(eiger)
|
|
376
|
+
def _wrapped_multi_rotation_scan():
|
|
377
|
+
yield from multi_rotation_scan_internal(composite, parameters, oav_params)
|
|
416
378
|
|
|
417
|
-
yield from
|
|
379
|
+
yield from _wrapped_multi_rotation_scan()
|
|
418
380
|
|
|
419
381
|
|
|
420
|
-
def
|
|
382
|
+
def multi_rotation_scan_internal(
|
|
421
383
|
composite: RotationScanComposite,
|
|
422
384
|
parameters: MultiRotationScan,
|
|
423
385
|
oav_params: OAVParameters | None = None,
|
|
@@ -9,10 +9,10 @@ import bluesky.preprocessors as bpp
|
|
|
9
9
|
import pydantic
|
|
10
10
|
from bluesky import plan_stubs as bps
|
|
11
11
|
from dodal.devices.attenuator.attenuator import BinaryFilterAttenuator
|
|
12
|
-
from dodal.devices.dcm import DCM
|
|
13
12
|
from dodal.devices.focusing_mirror import FocusingMirrorWithStripes, MirrorVoltages
|
|
13
|
+
from dodal.devices.i03.dcm import DCM
|
|
14
|
+
from dodal.devices.i03.undulator_dcm import UndulatorDCM
|
|
14
15
|
from dodal.devices.undulator import Undulator
|
|
15
|
-
from dodal.devices.undulator_dcm import UndulatorDCM
|
|
16
16
|
from dodal.devices.xbpm_feedback import XBPMFeedback
|
|
17
17
|
|
|
18
18
|
from mx_bluesky.common.parameters.constants import PlanNameConstants
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import dataclasses
|
|
2
2
|
import json
|
|
3
3
|
import re
|
|
4
|
+
import traceback
|
|
4
5
|
from os import path
|
|
5
6
|
from typing import Any, TypeVar
|
|
6
7
|
|
|
@@ -12,11 +13,6 @@ from pydantic_extra_types.semantic_version import SemanticVersion
|
|
|
12
13
|
|
|
13
14
|
from mx_bluesky.common.parameters.components import (
|
|
14
15
|
PARAMETER_VERSION,
|
|
15
|
-
MxBlueskyParameters,
|
|
16
|
-
TopNByMaxCountSelection,
|
|
17
|
-
WithCentreSelection,
|
|
18
|
-
WithOptionalEnergyChange,
|
|
19
|
-
WithSample,
|
|
20
16
|
WithVisit,
|
|
21
17
|
)
|
|
22
18
|
from mx_bluesky.common.parameters.constants import (
|
|
@@ -24,9 +20,7 @@ from mx_bluesky.common.parameters.constants import (
|
|
|
24
20
|
)
|
|
25
21
|
from mx_bluesky.common.utils.log import LOGGER
|
|
26
22
|
from mx_bluesky.common.utils.utils import convert_angstrom_to_eV
|
|
27
|
-
from mx_bluesky.hyperion.parameters.components import WithHyperionUDCFeatures
|
|
28
23
|
from mx_bluesky.hyperion.parameters.load_centre_collect import LoadCentreCollect
|
|
29
|
-
from mx_bluesky.hyperion.parameters.robot_load import RobotLoadThenCentre
|
|
30
24
|
|
|
31
25
|
T = TypeVar("T", bound=WithVisit)
|
|
32
26
|
AGAMEMNON_URL = "http://agamemnon.diamond.ac.uk/"
|
|
@@ -36,19 +30,6 @@ MULTIPIN_REGEX = rf"^{MULTIPIN_PREFIX}_(\d+)x(\d+(?:\.\d+)?)\+(\d+(?:\.\d+)?)$"
|
|
|
36
30
|
MX_GENERAL_ROOT_REGEX = r"^/dls/(?P<beamline>[^/]+)/data/[^/]*/(?P<visit>[^/]+)(?:/|$)"
|
|
37
31
|
|
|
38
32
|
|
|
39
|
-
class AgamemnonLoadCentreCollect(
|
|
40
|
-
MxBlueskyParameters,
|
|
41
|
-
WithVisit,
|
|
42
|
-
WithSample,
|
|
43
|
-
WithCentreSelection,
|
|
44
|
-
WithHyperionUDCFeatures,
|
|
45
|
-
WithOptionalEnergyChange,
|
|
46
|
-
):
|
|
47
|
-
"""Experiment parameters to compare against GDA populated LoadCentreCollect."""
|
|
48
|
-
|
|
49
|
-
robot_load_then_centre: RobotLoadThenCentre
|
|
50
|
-
|
|
51
|
-
|
|
52
33
|
@dataclasses.dataclass
|
|
53
34
|
class PinType:
|
|
54
35
|
expected_number_of_crystals: int
|
|
@@ -131,15 +112,6 @@ def get_withvisit_parameters_from_agamemnon(parameters: dict) -> tuple:
|
|
|
131
112
|
)
|
|
132
113
|
|
|
133
114
|
|
|
134
|
-
def get_withsample_parameters_from_agamemnon(parameters: dict) -> dict[str, Any]:
|
|
135
|
-
assert parameters.get("sample"), "instruction does not have a sample"
|
|
136
|
-
return {
|
|
137
|
-
"sample_id": parameters["sample"]["id"],
|
|
138
|
-
"sample_puck": parameters["sample"]["container"],
|
|
139
|
-
"sample_pin": parameters["sample"]["position"],
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
|
|
143
115
|
def get_withenergy_parameters_from_agamemnon(parameters: dict) -> dict[str, Any]:
|
|
144
116
|
try:
|
|
145
117
|
first_collection: dict = parameters["collection"][0]
|
|
@@ -155,57 +127,75 @@ def get_param_version() -> SemanticVersion:
|
|
|
155
127
|
return SemanticVersion.validate_from_str(str(PARAMETER_VERSION))
|
|
156
128
|
|
|
157
129
|
|
|
158
|
-
def create_robot_load_then_centre_params_from_agamemnon(
|
|
159
|
-
parameters: dict,
|
|
160
|
-
) -> RobotLoadThenCentre:
|
|
161
|
-
visit, detector_distance = get_withvisit_parameters_from_agamemnon(parameters)
|
|
162
|
-
with_sample_params = get_withsample_parameters_from_agamemnon(parameters)
|
|
163
|
-
with_energy_params = get_withenergy_parameters_from_agamemnon(parameters)
|
|
164
|
-
visit_directory, file_name = path.split(parameters["prefix"])
|
|
165
|
-
return RobotLoadThenCentre(
|
|
166
|
-
parameter_model_version=get_param_version(),
|
|
167
|
-
storage_directory=visit_directory + "/xraycentring",
|
|
168
|
-
visit=visit,
|
|
169
|
-
detector_distance_mm=detector_distance,
|
|
170
|
-
snapshot_directory=visit_directory + "/snapshots",
|
|
171
|
-
file_name=file_name,
|
|
172
|
-
**with_energy_params,
|
|
173
|
-
**with_sample_params,
|
|
174
|
-
)
|
|
175
|
-
|
|
176
|
-
|
|
177
130
|
def populate_parameters_from_agamemnon(agamemnon_params):
|
|
178
131
|
visit, detector_distance = get_withvisit_parameters_from_agamemnon(agamemnon_params)
|
|
179
|
-
with_sample_params = get_withsample_parameters_from_agamemnon(agamemnon_params)
|
|
180
132
|
with_energy_params = get_withenergy_parameters_from_agamemnon(agamemnon_params)
|
|
181
133
|
pin_type = get_pin_type_from_agamemnon_parameters(agamemnon_params)
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
134
|
+
first_collection = agamemnon_params["collection"][0]
|
|
135
|
+
visit_directory, file_name = path.split(agamemnon_params["prefix"])
|
|
136
|
+
return LoadCentreCollect.model_validate(
|
|
137
|
+
{
|
|
138
|
+
"parameter_model_version": get_param_version(),
|
|
139
|
+
"visit": visit,
|
|
140
|
+
"detector_distance_mm": detector_distance,
|
|
141
|
+
"sample_id": agamemnon_params["sample"]["id"],
|
|
142
|
+
"sample_puck": agamemnon_params["sample"]["container"],
|
|
143
|
+
"sample_pin": agamemnon_params["sample"]["position"],
|
|
144
|
+
"select_centres": {
|
|
145
|
+
"name": "TopNByMaxCount",
|
|
146
|
+
"n": pin_type.expected_number_of_crystals,
|
|
147
|
+
},
|
|
148
|
+
"robot_load_then_centre": {
|
|
149
|
+
"storage_directory": str(visit_directory) + "/xraycentring",
|
|
150
|
+
"file_name": file_name,
|
|
151
|
+
"tip_offset_um": pin_type.full_width / 2,
|
|
152
|
+
"grid_width_um": pin_type.full_width,
|
|
153
|
+
"omega_start_deg": 0.0,
|
|
154
|
+
"chi_start_deg": first_collection["chi"],
|
|
155
|
+
"transmission_frac": 1.0,
|
|
156
|
+
"features": {"use_gpu_results": True},
|
|
157
|
+
**with_energy_params,
|
|
158
|
+
},
|
|
159
|
+
"multi_rotation_scan": {
|
|
160
|
+
"comment": first_collection["comment"],
|
|
161
|
+
"storage_directory": str(visit_directory),
|
|
162
|
+
"exposure_time_s": first_collection["exposure_time"],
|
|
163
|
+
"file_name": file_name,
|
|
164
|
+
"transmission_frac": first_collection["transmission"],
|
|
165
|
+
"rotation_increment_deg": first_collection["omega_increment"],
|
|
166
|
+
"ispyb_experiment_type": first_collection["experiment_type"],
|
|
167
|
+
"snapshot_omegas_deg": [0.0, 90.0, 180.0, 270.0],
|
|
168
|
+
"rotation_scans": [
|
|
169
|
+
{
|
|
170
|
+
"scan_width_deg": (
|
|
171
|
+
first_collection["number_of_images"]
|
|
172
|
+
* first_collection["omega_increment"]
|
|
173
|
+
),
|
|
174
|
+
"omega_start_deg": first_collection["omega_start"],
|
|
175
|
+
"phi_start_deg": first_collection["phi_start"],
|
|
176
|
+
"chi_start_deg": first_collection["chi"],
|
|
177
|
+
"rotation_direction": "Positive",
|
|
178
|
+
}
|
|
179
|
+
],
|
|
180
|
+
**with_energy_params,
|
|
181
|
+
},
|
|
182
|
+
}
|
|
195
183
|
)
|
|
196
184
|
|
|
197
185
|
|
|
198
|
-
def create_parameters_from_agamemnon() ->
|
|
186
|
+
def create_parameters_from_agamemnon() -> LoadCentreCollect | None:
|
|
199
187
|
beamline_name = get_beamline_name("i03")
|
|
200
188
|
agamemnon_params = get_next_instruction(beamline_name)
|
|
201
|
-
|
|
202
|
-
|
|
189
|
+
return (
|
|
190
|
+
populate_parameters_from_agamemnon(agamemnon_params)
|
|
191
|
+
if agamemnon_params
|
|
192
|
+
else None
|
|
193
|
+
)
|
|
203
194
|
|
|
204
195
|
|
|
205
196
|
def compare_params(load_centre_collect_params):
|
|
206
197
|
try:
|
|
207
198
|
parameters = create_parameters_from_agamemnon()
|
|
208
|
-
|
|
209
199
|
# Log differences against GDA populated parameters
|
|
210
200
|
differences = DeepDiff(
|
|
211
201
|
parameters, load_centre_collect_params, math_epsilon=1e-5
|
|
@@ -214,10 +204,12 @@ def compare_params(load_centre_collect_params):
|
|
|
214
204
|
LOGGER.info(
|
|
215
205
|
f"Different parameters found when directly reading from Hyperion: {differences}"
|
|
216
206
|
)
|
|
217
|
-
except (ValueError, KeyError)
|
|
218
|
-
LOGGER.warning(f"Failed to compare parameters: {
|
|
219
|
-
except Exception
|
|
220
|
-
LOGGER.warning(
|
|
207
|
+
except (ValueError, KeyError):
|
|
208
|
+
LOGGER.warning(f"Failed to compare parameters: {traceback.format_exc()}")
|
|
209
|
+
except Exception:
|
|
210
|
+
LOGGER.warning(
|
|
211
|
+
f"Unexpected error occurred. Failed to compare parameters: {traceback.format_exc()}"
|
|
212
|
+
)
|
|
221
213
|
|
|
222
214
|
|
|
223
215
|
def update_params_from_agamemnon(parameters: T) -> T:
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
from collections.abc import Callable, Sequence
|
|
3
3
|
from threading import Thread
|
|
4
|
+
from time import sleep # noqa
|
|
4
5
|
|
|
5
|
-
import bluesky.plan_stubs as bps
|
|
6
6
|
from bluesky.callbacks import CallbackBase
|
|
7
7
|
from bluesky.callbacks.zmq import Proxy, RemoteDispatcher
|
|
8
8
|
from dodal.log import LOGGER as dodal_logger
|
|
@@ -26,7 +26,7 @@ from mx_bluesky.common.external_interaction.callbacks.xray_centre.nexus_callback
|
|
|
26
26
|
from mx_bluesky.common.utils.log import (
|
|
27
27
|
ISPYB_ZOCALO_CALLBACK_LOGGER,
|
|
28
28
|
NEXUS_LOGGER,
|
|
29
|
-
|
|
29
|
+
_get_logging_dirs,
|
|
30
30
|
tag_filter,
|
|
31
31
|
)
|
|
32
32
|
from mx_bluesky.hyperion.external_interaction.callbacks.robot_load.ispyb_callback import (
|
|
@@ -93,14 +93,16 @@ def setup_logging(dev_mode: bool):
|
|
|
93
93
|
(ISPYB_ZOCALO_CALLBACK_LOGGER, "hyperion_ispyb_callback.log"),
|
|
94
94
|
(NEXUS_LOGGER, "hyperion_nexus_callback.log"),
|
|
95
95
|
]:
|
|
96
|
+
logging_path, debug_logging_path = _get_logging_dirs()
|
|
96
97
|
if logger.handlers == []:
|
|
97
98
|
handlers = set_up_all_logging_handlers(
|
|
98
99
|
logger,
|
|
99
|
-
|
|
100
|
+
logging_path,
|
|
100
101
|
filename,
|
|
101
102
|
dev_mode,
|
|
102
|
-
|
|
103
|
-
|
|
103
|
+
ERROR_LOG_BUFFER_LINES,
|
|
104
|
+
CONST.GRAYLOG_PORT,
|
|
105
|
+
debug_logging_path,
|
|
104
106
|
)
|
|
105
107
|
handlers["graylog_handler"].addFilter(tag_filter)
|
|
106
108
|
log_info(f"Loggers initialised with dev_mode={dev_mode}")
|
|
@@ -140,7 +142,7 @@ def wait_for_threads_forever(threads: Sequence[Thread]):
|
|
|
140
142
|
try:
|
|
141
143
|
log_debug("Trying to wait forever on callback and dispatcher threads")
|
|
142
144
|
while all(alive):
|
|
143
|
-
|
|
145
|
+
sleep(LIVENESS_POLL_SECONDS)
|
|
144
146
|
alive = [t.is_alive() for t in threads]
|
|
145
147
|
except KeyboardInterrupt:
|
|
146
148
|
log_info("Main thread received interrupt - exiting.")
|