mx-bluesky 1.1.0__py3-none-any.whl → 1.4.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/__init__.py +8 -3
- mx_bluesky/__main__.py +12 -7
- mx_bluesky/_version.py +2 -2
- mx_bluesky/beamlines/i04/callbacks/murko_callback.py +14 -4
- mx_bluesky/beamlines/i04/thawing_plan.py +48 -10
- mx_bluesky/beamlines/i24/serial/__init__.py +3 -0
- mx_bluesky/beamlines/i24/serial/extruder/i24ssx_Extruder_Collect_py3v2.py +68 -90
- mx_bluesky/beamlines/i24/serial/fixed_target/FT-gui-edm/DiamondChipI24-py3v1.edl +1 -1
- mx_bluesky/beamlines/i24/serial/fixed_target/i24ssx_Chip_Collect_py3v1.py +104 -126
- mx_bluesky/beamlines/i24/serial/fixed_target/i24ssx_Chip_Manager_py3v1.py +139 -162
- mx_bluesky/beamlines/i24/serial/fixed_target/i24ssx_Chip_Mapping_py3v1.py +25 -36
- mx_bluesky/beamlines/i24/serial/fixed_target/i24ssx_Chip_StartUp_py3v1.py +24 -34
- mx_bluesky/beamlines/i24/serial/fixed_target/i24ssx_moveonclick.py +14 -11
- mx_bluesky/beamlines/i24/serial/log.py +58 -49
- mx_bluesky/beamlines/i24/serial/parameters/fixed_target/cs/cs_maker.json +3 -3
- mx_bluesky/beamlines/i24/serial/run_extruder.sh +30 -5
- mx_bluesky/beamlines/i24/serial/run_fixed_target.sh +31 -7
- mx_bluesky/beamlines/i24/serial/run_serial.py +24 -8
- mx_bluesky/beamlines/i24/serial/setup_beamline/ca.py +0 -2
- mx_bluesky/beamlines/i24/serial/setup_beamline/setup_beamline.py +1 -1
- mx_bluesky/beamlines/i24/serial/setup_beamline/setup_detector.py +8 -18
- mx_bluesky/beamlines/i24/serial/setup_beamline/setup_zebra_plans.py +2 -2
- mx_bluesky/common/__init__.py +0 -0
- mx_bluesky/common/device_setup_plans/read_hardware_for_setup.py +14 -0
- mx_bluesky/common/parameters/components.py +221 -0
- mx_bluesky/common/parameters/constants.py +133 -0
- mx_bluesky/common/plans/__init__.py +1 -0
- mx_bluesky/common/plans/do_fgs.py +121 -0
- mx_bluesky/common/utils/log.py +116 -0
- mx_bluesky/{hyperion → common/utils}/tracing.py +2 -2
- mx_bluesky/hyperion/__main__.py +11 -9
- mx_bluesky/hyperion/device_setup_plans/dcm_pitch_roll_mirror_adjuster.py +31 -26
- mx_bluesky/hyperion/device_setup_plans/read_hardware_for_setup.py +6 -12
- mx_bluesky/hyperion/device_setup_plans/setup_oav.py +6 -12
- mx_bluesky/hyperion/device_setup_plans/setup_panda.py +1 -2
- mx_bluesky/hyperion/device_setup_plans/setup_zebra.py +48 -17
- mx_bluesky/hyperion/device_setup_plans/smargon.py +6 -6
- mx_bluesky/hyperion/device_setup_plans/utils.py +13 -2
- mx_bluesky/hyperion/device_setup_plans/xbpm_feedback.py +4 -4
- mx_bluesky/hyperion/experiment_plans/experiment_registry.py +9 -0
- mx_bluesky/hyperion/experiment_plans/flyscan_xray_centre_plan.py +59 -108
- mx_bluesky/hyperion/experiment_plans/grid_detect_then_xray_centre_plan.py +7 -5
- mx_bluesky/hyperion/experiment_plans/load_centre_collect_full_plan.py +46 -0
- mx_bluesky/hyperion/experiment_plans/oav_grid_detection_plan.py +19 -18
- mx_bluesky/hyperion/experiment_plans/oav_snapshot_plan.py +8 -5
- mx_bluesky/hyperion/experiment_plans/pin_centre_then_xray_centre_plan.py +4 -4
- mx_bluesky/hyperion/experiment_plans/pin_tip_centring_plan.py +17 -17
- mx_bluesky/hyperion/experiment_plans/robot_load_and_change_energy.py +241 -0
- mx_bluesky/hyperion/experiment_plans/robot_load_then_centre_plan.py +24 -181
- mx_bluesky/hyperion/experiment_plans/rotation_scan_plan.py +6 -4
- mx_bluesky/hyperion/experiment_plans/set_energy_plan.py +3 -11
- mx_bluesky/hyperion/external_interaction/callbacks/__main__.py +1 -2
- mx_bluesky/hyperion/external_interaction/callbacks/common/callback_util.py +18 -0
- mx_bluesky/hyperion/external_interaction/callbacks/common/ispyb_mapping.py +1 -9
- mx_bluesky/hyperion/external_interaction/callbacks/grid_detection_callback.py +18 -13
- mx_bluesky/hyperion/external_interaction/callbacks/ispyb_callback_base.py +32 -15
- mx_bluesky/hyperion/external_interaction/callbacks/log_uid_tag_callback.py +1 -1
- mx_bluesky/hyperion/external_interaction/callbacks/robot_load/ispyb_callback.py +3 -5
- mx_bluesky/hyperion/external_interaction/callbacks/rotation/ispyb_callback.py +4 -3
- mx_bluesky/hyperion/external_interaction/callbacks/xray_centre/ispyb_callback.py +23 -18
- mx_bluesky/hyperion/external_interaction/config_server.py +22 -10
- mx_bluesky/hyperion/external_interaction/ispyb/ispyb_store.py +1 -1
- mx_bluesky/hyperion/external_interaction/ispyb/ispyb_utils.py +0 -2
- mx_bluesky/hyperion/external_interaction/nexus/nexus_utils.py +2 -2
- mx_bluesky/hyperion/external_interaction/nexus/write_nexus.py +1 -1
- mx_bluesky/hyperion/log.py +0 -84
- mx_bluesky/hyperion/parameters/components.py +1 -242
- mx_bluesky/hyperion/parameters/constants.py +22 -118
- mx_bluesky/hyperion/parameters/gridscan.py +20 -11
- 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 +9 -5
- mx_bluesky/hyperion/utils/utils.py +17 -0
- mx_bluesky/hyperion/utils/validation.py +5 -6
- {mx_bluesky-1.1.0.dist-info → mx_bluesky-1.4.0.dist-info}/METADATA +4 -2
- {mx_bluesky-1.1.0.dist-info → mx_bluesky-1.4.0.dist-info}/RECORD +80 -70
- {mx_bluesky-1.1.0.dist-info → mx_bluesky-1.4.0.dist-info}/WHEEL +1 -1
- mx_bluesky/example.py +0 -19
- {mx_bluesky-1.1.0.dist-info → mx_bluesky-1.4.0.dist-info}/LICENSE +0 -0
- {mx_bluesky-1.1.0.dist-info → mx_bluesky-1.4.0.dist-info}/entry_points.txt +0 -0
- {mx_bluesky-1.1.0.dist-info → mx_bluesky-1.4.0.dist-info}/top_level.txt +0 -0
mx_bluesky/__init__.py
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
"""Top level API.
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
.. data:: __version__
|
|
4
|
+
:type: str
|
|
5
|
+
|
|
6
|
+
Version number as calculated by https://github.com/pypa/setuptools_scm
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from ._version import __version__
|
|
5
10
|
|
|
6
11
|
__all__ = ["__version__"]
|
mx_bluesky/__main__.py
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
"""Interface for ``python -m mx_bluesky``."""
|
|
2
2
|
|
|
3
|
-
from
|
|
3
|
+
from argparse import ArgumentParser
|
|
4
|
+
from collections.abc import Sequence
|
|
4
5
|
|
|
5
6
|
from . import __version__
|
|
6
7
|
|
|
7
8
|
__all__ = ["main"]
|
|
8
9
|
|
|
9
10
|
|
|
10
|
-
def main(args=None):
|
|
11
|
+
def main(args: Sequence[str] | None = None) -> None:
|
|
12
|
+
"""Argument parser for the CLI."""
|
|
11
13
|
parser = ArgumentParser()
|
|
12
|
-
parser.add_argument(
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
parser.add_argument(
|
|
15
|
+
"-v",
|
|
16
|
+
"--version",
|
|
17
|
+
action="version",
|
|
18
|
+
version=__version__,
|
|
19
|
+
)
|
|
20
|
+
parser.parse_args(args)
|
|
15
21
|
|
|
16
22
|
|
|
17
|
-
# test with: python -m mx_bluesky
|
|
18
23
|
if __name__ == "__main__":
|
|
19
24
|
main()
|
mx_bluesky/_version.py
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import copy
|
|
2
2
|
import json
|
|
3
|
+
from datetime import timedelta
|
|
3
4
|
|
|
4
5
|
from bluesky.callbacks import CallbackBase
|
|
5
6
|
from dodal.log import LOGGER
|
|
6
|
-
from event_model.documents import Event, RunStart
|
|
7
|
+
from event_model.documents import Event, RunStart, RunStop
|
|
7
8
|
from redis import StrictRedis
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
class MurkoCallback(CallbackBase):
|
|
12
|
+
DATA_EXPIRY_DAYS = 7
|
|
13
|
+
|
|
11
14
|
def __init__(self, redis_host: str, redis_password: str, redis_db: int = 0):
|
|
12
15
|
self.redis_client = StrictRedis(
|
|
13
16
|
host=redis_host, password=redis_password, db=redis_db
|
|
@@ -15,15 +18,17 @@ class MurkoCallback(CallbackBase):
|
|
|
15
18
|
self.last_uuid = None
|
|
16
19
|
|
|
17
20
|
def start(self, doc: RunStart) -> RunStart | None:
|
|
21
|
+
self.sample_id = doc.get("sample_id")
|
|
18
22
|
self.murko_metadata = {
|
|
19
23
|
"zoom_percentage": doc.get("zoom_percentage"),
|
|
20
24
|
"microns_per_x_pixel": doc.get("microns_per_x_pixel"),
|
|
21
25
|
"microns_per_y_pixel": doc.get("microns_per_y_pixel"),
|
|
22
26
|
"beam_centre_i": doc.get("beam_centre_i"),
|
|
23
27
|
"beam_centre_j": doc.get("beam_centre_j"),
|
|
24
|
-
"sample_id":
|
|
28
|
+
"sample_id": self.sample_id,
|
|
25
29
|
}
|
|
26
30
|
self.last_uuid = None
|
|
31
|
+
LOGGER.info(f"Starting to stream metadata to murko under {self.sample_id}")
|
|
27
32
|
return doc
|
|
28
33
|
|
|
29
34
|
def event(self, doc: Event) -> Event:
|
|
@@ -40,6 +45,11 @@ class MurkoCallback(CallbackBase):
|
|
|
40
45
|
metadata["uuid"] = uuid
|
|
41
46
|
|
|
42
47
|
# Send metadata to REDIS and trigger murko
|
|
43
|
-
|
|
48
|
+
redis_key = f"murko:{metadata['sample_id']}:metadata"
|
|
49
|
+
self.redis_client.hset(redis_key, uuid, json.dumps(metadata))
|
|
50
|
+
self.redis_client.expire(redis_key, timedelta(days=self.DATA_EXPIRY_DAYS))
|
|
44
51
|
self.redis_client.publish("murko", json.dumps(metadata))
|
|
45
|
-
|
|
52
|
+
|
|
53
|
+
def stop(self, doc: RunStop) -> RunStop | None:
|
|
54
|
+
LOGGER.info(f"Finished streaming {self.sample_id} to murko")
|
|
55
|
+
return doc
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
from collections.abc import Callable
|
|
2
|
+
|
|
1
3
|
import bluesky.plan_stubs as bps
|
|
2
4
|
import bluesky.preprocessors as bpp
|
|
3
5
|
from bluesky.preprocessors import run_decorator, subs_decorator
|
|
@@ -5,7 +7,7 @@ from dls_bluesky_core.core import MsgGenerator
|
|
|
5
7
|
from dodal.beamlines.i04 import MURKO_REDIS_DB, REDIS_HOST, REDIS_PASSWORD
|
|
6
8
|
from dodal.common import inject
|
|
7
9
|
from dodal.devices.oav.oav_detector import OAV
|
|
8
|
-
from dodal.devices.oav.oav_to_redis_forwarder import OAVToRedisForwarder
|
|
10
|
+
from dodal.devices.oav.oav_to_redis_forwarder import OAVToRedisForwarder, Source
|
|
9
11
|
from dodal.devices.robot import BartRobot
|
|
10
12
|
from dodal.devices.smargon import Smargon
|
|
11
13
|
from dodal.devices.thawer import Thawer, ThawerStates
|
|
@@ -22,31 +24,62 @@ def thaw_and_stream_to_redis(
|
|
|
22
24
|
oav: OAV = inject("oav"),
|
|
23
25
|
oav_to_redis_forwarder: OAVToRedisForwarder = inject("oav_to_redis_forwarder"),
|
|
24
26
|
) -> MsgGenerator:
|
|
25
|
-
zoom_percentage = yield from bps.rd(oav.zoom_controller.percentage)
|
|
27
|
+
zoom_percentage = yield from bps.rd(oav.zoom_controller.percentage) # type: ignore # See: https://github.com/bluesky/bluesky/issues/1809
|
|
26
28
|
sample_id = yield from bps.rd(robot.sample_id)
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
yield from bps.
|
|
30
|
+
sample_id = int(sample_id)
|
|
31
|
+
zoom_level_before_thawing = yield from bps.rd(oav.zoom_controller.level) # type: ignore # See: https://github.com/bluesky/bluesky/issues/1809
|
|
32
|
+
|
|
33
|
+
yield from bps.mv(oav.zoom_controller.level, "1.0x") # type: ignore # See: https://github.com/bluesky/bluesky/issues/1809
|
|
34
|
+
|
|
35
|
+
def switch_forwarder_to_ROI() -> MsgGenerator:
|
|
36
|
+
yield from bps.complete(oav_to_redis_forwarder, wait=True)
|
|
37
|
+
yield from bps.mv(
|
|
38
|
+
# See: https://github.com/bluesky/bluesky/issues/1809
|
|
39
|
+
oav_to_redis_forwarder.selected_source, # type: ignore
|
|
40
|
+
Source.ROI.value, # type: ignore
|
|
41
|
+
)
|
|
42
|
+
yield from bps.kickoff(oav_to_redis_forwarder, wait=True)
|
|
43
|
+
|
|
44
|
+
microns_per_pixel_x = yield from bps.rd(oav.microns_per_pixel_x)
|
|
45
|
+
microns_per_pixel_y = yield from bps.rd(oav.microns_per_pixel_y)
|
|
46
|
+
beam_centre_i = yield from bps.rd(oav.beam_centre_i)
|
|
47
|
+
beam_centre_j = yield from bps.rd(oav.beam_centre_j)
|
|
30
48
|
|
|
31
49
|
@subs_decorator(MurkoCallback(REDIS_HOST, REDIS_PASSWORD, MURKO_REDIS_DB))
|
|
32
50
|
@run_decorator(
|
|
33
51
|
md={
|
|
34
|
-
"microns_per_x_pixel":
|
|
35
|
-
"microns_per_y_pixel":
|
|
36
|
-
"beam_centre_i":
|
|
37
|
-
"beam_centre_j":
|
|
52
|
+
"microns_per_x_pixel": microns_per_pixel_x,
|
|
53
|
+
"microns_per_y_pixel": microns_per_pixel_y,
|
|
54
|
+
"beam_centre_i": beam_centre_i,
|
|
55
|
+
"beam_centre_j": beam_centre_j,
|
|
38
56
|
"zoom_percentage": zoom_percentage,
|
|
39
57
|
"sample_id": sample_id,
|
|
40
58
|
}
|
|
41
59
|
)
|
|
42
60
|
def _thaw_and_stream_to_redis():
|
|
61
|
+
yield from bps.mv(
|
|
62
|
+
oav_to_redis_forwarder.sample_id, # type: ignore # See: https://github.com/bluesky/bluesky/issues/1809
|
|
63
|
+
sample_id, # type: ignore # See: https://github.com/bluesky/bluesky/issues/1809
|
|
64
|
+
oav_to_redis_forwarder.selected_source, # type: ignore # See: https://github.com/bluesky/bluesky/issues/1809
|
|
65
|
+
Source.FULL_SCREEN.value, # type: ignore # See: https://github.com/bluesky/bluesky/issues/1809
|
|
66
|
+
)
|
|
67
|
+
|
|
43
68
|
yield from bps.kickoff(oav_to_redis_forwarder, wait=True)
|
|
44
69
|
yield from bps.monitor(smargon.omega.user_readback, name="smargon")
|
|
45
70
|
yield from bps.monitor(oav_to_redis_forwarder.uuid, name="oav")
|
|
46
|
-
yield from thaw(
|
|
71
|
+
yield from thaw(
|
|
72
|
+
time_to_thaw, rotation, thawer, smargon, switch_forwarder_to_ROI
|
|
73
|
+
)
|
|
47
74
|
yield from bps.complete(oav_to_redis_forwarder)
|
|
48
75
|
|
|
49
|
-
|
|
76
|
+
def cleanup():
|
|
77
|
+
yield from bps.mv(oav.zoom_controller.level, zoom_level_before_thawing) # type: ignore # See: https://github.com/bluesky/bluesky/issues/1809
|
|
78
|
+
|
|
79
|
+
yield from bpp.contingency_wrapper(
|
|
80
|
+
_thaw_and_stream_to_redis(),
|
|
81
|
+
final_plan=cleanup,
|
|
82
|
+
)
|
|
50
83
|
|
|
51
84
|
|
|
52
85
|
def thaw(
|
|
@@ -54,6 +87,7 @@ def thaw(
|
|
|
54
87
|
rotation: float = 360,
|
|
55
88
|
thawer: Thawer = inject("thawer"),
|
|
56
89
|
smargon: Smargon = inject("smargon"),
|
|
90
|
+
plan_between_rotations: Callable[[], MsgGenerator] | None = None,
|
|
57
91
|
) -> MsgGenerator:
|
|
58
92
|
"""Rotates the sample and thaws it at the same time.
|
|
59
93
|
|
|
@@ -64,6 +98,8 @@ def thaw(
|
|
|
64
98
|
thawer (Thawer, optional): The thawing device. Defaults to inject("thawer").
|
|
65
99
|
smargon (Smargon, optional): The smargon used to rotate.
|
|
66
100
|
Defaults to inject("smargon")
|
|
101
|
+
plan_between_rotations (MsgGenerator, optional): A plan to run between rotations
|
|
102
|
+
of the smargon. Defaults to no plan.
|
|
67
103
|
"""
|
|
68
104
|
inital_velocity = yield from bps.rd(smargon.omega.velocity)
|
|
69
105
|
new_velocity = abs(rotation / time_to_thaw) * 2.0
|
|
@@ -72,6 +108,8 @@ def thaw(
|
|
|
72
108
|
yield from bps.abs_set(smargon.omega.velocity, new_velocity, wait=True)
|
|
73
109
|
yield from bps.abs_set(thawer.control, ThawerStates.ON, wait=True)
|
|
74
110
|
yield from bps.rel_set(smargon.omega, rotation, wait=True)
|
|
111
|
+
if plan_between_rotations:
|
|
112
|
+
yield from plan_between_rotations()
|
|
75
113
|
yield from bps.rel_set(smargon.omega, -rotation, wait=True)
|
|
76
114
|
|
|
77
115
|
def cleanup():
|
|
@@ -22,6 +22,7 @@ from .fixed_target.i24ssx_Chip_Manager_py3v1 import (
|
|
|
22
22
|
upload_parameters,
|
|
23
23
|
write_parameter_file,
|
|
24
24
|
)
|
|
25
|
+
from .log import clean_up_log_config_at_end, setup_collection_logs
|
|
25
26
|
from .setup_beamline.setup_detector import setup_detector_stage
|
|
26
27
|
|
|
27
28
|
__all__ = [
|
|
@@ -46,4 +47,6 @@ __all__ = [
|
|
|
46
47
|
"save_screen_map",
|
|
47
48
|
"upload_parameters",
|
|
48
49
|
"write_parameter_file",
|
|
50
|
+
"setup_collection_logs",
|
|
51
|
+
"clean_up_log_config_at_end",
|
|
49
52
|
]
|
|
@@ -5,7 +5,6 @@ This version in python3 new Feb2021 by RLO
|
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
7
|
import json
|
|
8
|
-
import logging
|
|
9
8
|
import re
|
|
10
9
|
import shutil
|
|
11
10
|
import sys
|
|
@@ -27,8 +26,12 @@ from dodal.devices.i24.dual_backlight import DualBacklight
|
|
|
27
26
|
from dodal.devices.i24.i24_detector_motion import DetectorMotion
|
|
28
27
|
from dodal.devices.zebra import DISCONNECT, SOFT_IN3, Zebra
|
|
29
28
|
|
|
30
|
-
from mx_bluesky.beamlines.i24.serial import log
|
|
31
29
|
from mx_bluesky.beamlines.i24.serial.dcid import DCID
|
|
30
|
+
from mx_bluesky.beamlines.i24.serial.log import (
|
|
31
|
+
SSX_LOGGER,
|
|
32
|
+
_read_visit_directory_from_file,
|
|
33
|
+
log_on_entry,
|
|
34
|
+
)
|
|
32
35
|
from mx_bluesky.beamlines.i24.serial.parameters import ExtruderParameters, SSXType
|
|
33
36
|
from mx_bluesky.beamlines.i24.serial.parameters.constants import (
|
|
34
37
|
PARAM_FILE_NAME,
|
|
@@ -54,31 +57,22 @@ from mx_bluesky.beamlines.i24.serial.setup_beamline.setup_zebra_plans import (
|
|
|
54
57
|
)
|
|
55
58
|
from mx_bluesky.beamlines.i24.serial.write_nexus import call_nexgen
|
|
56
59
|
|
|
57
|
-
usage = "%(prog)s command [options]"
|
|
58
|
-
logger = logging.getLogger("I24ssx.extruder")
|
|
59
|
-
|
|
60
60
|
SAFE_DET_Z = 1480
|
|
61
61
|
|
|
62
62
|
|
|
63
|
-
def setup_logging():
|
|
64
|
-
logfile = time.strftime("i24extruder_%d%B%y.log").lower()
|
|
65
|
-
log.config(logfile)
|
|
66
|
-
|
|
67
|
-
|
|
68
63
|
def flush_print(text):
|
|
69
64
|
sys.stdout.write(str(text))
|
|
70
65
|
sys.stdout.flush()
|
|
71
66
|
|
|
72
67
|
|
|
73
|
-
@
|
|
68
|
+
@log_on_entry
|
|
74
69
|
def initialise_extruder(
|
|
75
70
|
detector_stage: DetectorMotion = inject("detector_motion"),
|
|
76
71
|
) -> MsgGenerator:
|
|
77
|
-
|
|
78
|
-
logger.info("Initialise Parameters for extruder data collection on I24.")
|
|
72
|
+
SSX_LOGGER.info("Initialise Parameters for extruder data collection on I24.")
|
|
79
73
|
|
|
80
74
|
visit = caget(pv.ioc12_gp1)
|
|
81
|
-
|
|
75
|
+
SSX_LOGGER.info(f"Visit defined {visit}")
|
|
82
76
|
|
|
83
77
|
# Define detector in use
|
|
84
78
|
det_type = yield from get_detector_type(detector_stage)
|
|
@@ -93,11 +87,11 @@ def initialise_extruder(
|
|
|
93
87
|
caput(pv.ioc12_gp10, 0)
|
|
94
88
|
caput(pv.ioc12_gp15, det_type.name)
|
|
95
89
|
caput(pv.pilat_cbftemplate, 0)
|
|
96
|
-
|
|
90
|
+
SSX_LOGGER.info("Initialisation complete.")
|
|
97
91
|
yield from bps.null()
|
|
98
92
|
|
|
99
93
|
|
|
100
|
-
@
|
|
94
|
+
@log_on_entry
|
|
101
95
|
def laser_check(
|
|
102
96
|
mode: str,
|
|
103
97
|
zebra: Zebra = inject("zebra"),
|
|
@@ -116,8 +110,7 @@ def laser_check(
|
|
|
116
110
|
detector in use is the Eiger, the Pilatus cable is repurposed to trigger the light \
|
|
117
111
|
source, and viceversa.
|
|
118
112
|
"""
|
|
119
|
-
|
|
120
|
-
logger.debug(f"Laser check: {mode}")
|
|
113
|
+
SSX_LOGGER.debug(f"Laser check: {mode}")
|
|
121
114
|
|
|
122
115
|
det_type = yield from get_detector_type(detector_stage)
|
|
123
116
|
|
|
@@ -131,24 +124,23 @@ def laser_check(
|
|
|
131
124
|
yield from set_shutter_mode(zebra, "manual")
|
|
132
125
|
|
|
133
126
|
|
|
134
|
-
@
|
|
127
|
+
@log_on_entry
|
|
135
128
|
def enter_hutch(
|
|
136
129
|
detector_stage: DetectorMotion = inject("detector_motion"),
|
|
137
130
|
) -> MsgGenerator:
|
|
138
131
|
"""Move the detector stage before entering hutch."""
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
logger.debug("Detector moved.")
|
|
132
|
+
yield from bps.mv(detector_stage.z, SAFE_DET_Z) # type: ignore # See: https://github.com/bluesky/bluesky/issues/1809
|
|
133
|
+
SSX_LOGGER.debug("Detector moved.")
|
|
142
134
|
|
|
143
135
|
|
|
144
|
-
@
|
|
136
|
+
@log_on_entry
|
|
145
137
|
def write_parameter_file(detector_stage: DetectorMotion):
|
|
146
138
|
"""Writes a json parameter file that can later be parsed by the model."""
|
|
147
139
|
param_file: Path = PARAM_FILE_PATH / PARAM_FILE_NAME
|
|
148
|
-
|
|
140
|
+
SSX_LOGGER.debug(f"Writing Parameter File to: {param_file}\n")
|
|
149
141
|
|
|
150
142
|
det_type = yield from get_detector_type(detector_stage)
|
|
151
|
-
|
|
143
|
+
SSX_LOGGER.warning(f"DETECTOR TYPE: {det_type}")
|
|
152
144
|
filename = caget(pv.ioc12_gp3)
|
|
153
145
|
# If file name ends in a digit this causes processing/pilatus pain.
|
|
154
146
|
# Append an underscore
|
|
@@ -158,16 +150,16 @@ def write_parameter_file(detector_stage: DetectorMotion):
|
|
|
158
150
|
# Note for future reference. Appending underscore causes more hassle and
|
|
159
151
|
# high probability of users accidentally overwriting data. Use a dash
|
|
160
152
|
filename = filename + "-"
|
|
161
|
-
|
|
153
|
+
SSX_LOGGER.info(
|
|
162
154
|
f"Requested filename ends in a number. Appended dash: {filename}"
|
|
163
155
|
)
|
|
164
156
|
|
|
165
|
-
pump_status = bool(caget(pv.ioc12_gp6))
|
|
157
|
+
pump_status = bool(int(caget(pv.ioc12_gp6)))
|
|
166
158
|
pump_exp = float(caget(pv.ioc12_gp9)) if pump_status else None
|
|
167
159
|
pump_delay = float(caget(pv.ioc12_gp10)) if pump_status else None
|
|
168
160
|
|
|
169
161
|
params_dict = {
|
|
170
|
-
"visit":
|
|
162
|
+
"visit": _read_visit_directory_from_file().as_posix(), # noqa
|
|
171
163
|
"directory": caget(pv.ioc12_gp2),
|
|
172
164
|
"filename": filename,
|
|
173
165
|
"exposure_time_s": float(caget(pv.ioc12_gp5)),
|
|
@@ -181,12 +173,12 @@ def write_parameter_file(detector_stage: DetectorMotion):
|
|
|
181
173
|
with open(param_file, "w") as f:
|
|
182
174
|
json.dump(params_dict, f, indent=4)
|
|
183
175
|
|
|
184
|
-
|
|
185
|
-
|
|
176
|
+
SSX_LOGGER.info("Parameters \n")
|
|
177
|
+
SSX_LOGGER.info(pformat(params_dict))
|
|
186
178
|
yield from bps.null()
|
|
187
179
|
|
|
188
180
|
|
|
189
|
-
@
|
|
181
|
+
@log_on_entry
|
|
190
182
|
def main_extruder_plan(
|
|
191
183
|
zebra: Zebra,
|
|
192
184
|
aperture: Aperture,
|
|
@@ -200,7 +192,7 @@ def main_extruder_plan(
|
|
|
200
192
|
start_time: datetime,
|
|
201
193
|
) -> MsgGenerator:
|
|
202
194
|
# Setting up the beamline
|
|
203
|
-
|
|
195
|
+
SSX_LOGGER.info("Open hutch shutter")
|
|
204
196
|
yield from bps.abs_set(shutter, ShutterDemand.OPEN, wait=True)
|
|
205
197
|
|
|
206
198
|
yield from sup.setup_beamline_for_collection_plan(
|
|
@@ -213,25 +205,25 @@ def main_extruder_plan(
|
|
|
213
205
|
|
|
214
206
|
# For pixel detector
|
|
215
207
|
filepath = parameters.collection_directory.as_posix()
|
|
216
|
-
|
|
217
|
-
|
|
208
|
+
SSX_LOGGER.debug(f"Filepath {filepath}")
|
|
209
|
+
SSX_LOGGER.debug(f"Filename {parameters.filename}")
|
|
218
210
|
|
|
219
211
|
if parameters.detector_name == "pilatus":
|
|
220
|
-
|
|
212
|
+
SSX_LOGGER.info("Using pilatus mini cbf")
|
|
221
213
|
caput(pv.pilat_cbftemplate, 0)
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
214
|
+
SSX_LOGGER.info(f"Pilatus quickshot setup: filepath {filepath}")
|
|
215
|
+
SSX_LOGGER.info(f"Pilatus quickshot setup: filepath {parameters.filename}")
|
|
216
|
+
SSX_LOGGER.info(
|
|
225
217
|
f"Pilatus quickshot setup: number of images {parameters.num_images}"
|
|
226
218
|
)
|
|
227
|
-
|
|
219
|
+
SSX_LOGGER.info(
|
|
228
220
|
f"Pilatus quickshot setup: exposure time {parameters.exposure_time_s}"
|
|
229
221
|
)
|
|
230
222
|
|
|
231
223
|
if parameters.pump_status:
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
224
|
+
SSX_LOGGER.info("Pump probe extruder data collection")
|
|
225
|
+
SSX_LOGGER.info(f"Pump exposure time {parameters.laser_dwell_s}")
|
|
226
|
+
SSX_LOGGER.info(f"Pump delay time {parameters.laser_delay_s}")
|
|
235
227
|
sup.pilatus(
|
|
236
228
|
"fastchip",
|
|
237
229
|
[
|
|
@@ -252,7 +244,7 @@ def main_extruder_plan(
|
|
|
252
244
|
wait=True,
|
|
253
245
|
)
|
|
254
246
|
else:
|
|
255
|
-
|
|
247
|
+
SSX_LOGGER.info("Static experiment: no photoexcitation")
|
|
256
248
|
sup.pilatus(
|
|
257
249
|
"quickshot",
|
|
258
250
|
[
|
|
@@ -267,38 +259,25 @@ def main_extruder_plan(
|
|
|
267
259
|
)
|
|
268
260
|
|
|
269
261
|
elif parameters.detector_name == "eiger":
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
Running a Single image pilatus data collection to create directory."""
|
|
275
|
-
) # See https://github.com/DiamondLightSource/mx_bluesky/issues/45
|
|
276
|
-
num_shots = 1
|
|
277
|
-
sup.pilatus(
|
|
278
|
-
"quickshot-internaltrig",
|
|
279
|
-
[filepath, parameters.filename, num_shots, parameters.exposure_time_s],
|
|
280
|
-
)
|
|
281
|
-
logger.debug("Sleep 2s waiting for pilatus to arm")
|
|
282
|
-
sleep(2.5)
|
|
283
|
-
caput(pv.pilat_acquire, "0") # Disarm pilatus
|
|
284
|
-
sleep(0.5)
|
|
285
|
-
caput(pv.pilat_acquire, "1") # Arm pilatus
|
|
286
|
-
logger.debug("Pilatus data collection DONE")
|
|
287
|
-
sup.pilatus("return to normal", None)
|
|
288
|
-
logger.info("Pilatus back to normal. Single image pilatus data collection DONE")
|
|
262
|
+
SSX_LOGGER.info("Using Eiger detector")
|
|
263
|
+
|
|
264
|
+
SSX_LOGGER.debug(f"Creating the directory for the collection in {filepath}.")
|
|
265
|
+
Path(filepath).mkdir(parents=True)
|
|
289
266
|
|
|
290
267
|
caput(pv.eiger_seqID, int(caget(pv.eiger_seqID)) + 1)
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
268
|
+
SSX_LOGGER.info(f"Eiger quickshot setup: filepath {filepath}")
|
|
269
|
+
SSX_LOGGER.info(f"Eiger quickshot setup: filepath {parameters.filename}")
|
|
270
|
+
SSX_LOGGER.info(
|
|
271
|
+
f"Eiger quickshot setup: number of images {parameters.num_images}"
|
|
272
|
+
)
|
|
273
|
+
SSX_LOGGER.info(
|
|
295
274
|
f"Eiger quickshot setup: exposure time {parameters.exposure_time_s}"
|
|
296
275
|
)
|
|
297
276
|
|
|
298
277
|
if parameters.pump_status:
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
278
|
+
SSX_LOGGER.info("Pump probe extruder data collection")
|
|
279
|
+
SSX_LOGGER.debug(f"Pump exposure time {parameters.laser_dwell_s}")
|
|
280
|
+
SSX_LOGGER.debug(f"Pump delay time {parameters.laser_delay_s}")
|
|
302
281
|
sup.eiger(
|
|
303
282
|
"triggered",
|
|
304
283
|
[
|
|
@@ -319,7 +298,7 @@ def main_extruder_plan(
|
|
|
319
298
|
wait=True,
|
|
320
299
|
)
|
|
321
300
|
else:
|
|
322
|
-
|
|
301
|
+
SSX_LOGGER.info("Static experiment: no photoexcitation")
|
|
323
302
|
sup.eiger(
|
|
324
303
|
"quickshot",
|
|
325
304
|
[
|
|
@@ -334,7 +313,7 @@ def main_extruder_plan(
|
|
|
334
313
|
)
|
|
335
314
|
else:
|
|
336
315
|
err = f"Unknown Detector Type, det_type = {parameters.detector_name}"
|
|
337
|
-
|
|
316
|
+
SSX_LOGGER.error(err)
|
|
338
317
|
raise UnknownDetectorType(err)
|
|
339
318
|
|
|
340
319
|
# Do DCID creation BEFORE arming the detector
|
|
@@ -350,20 +329,20 @@ def main_extruder_plan(
|
|
|
350
329
|
)
|
|
351
330
|
|
|
352
331
|
# Collect
|
|
353
|
-
|
|
332
|
+
SSX_LOGGER.info("Fast shutter opening")
|
|
354
333
|
yield from open_fast_shutter(zebra)
|
|
355
334
|
if parameters.detector_name == "pilatus":
|
|
356
|
-
|
|
335
|
+
SSX_LOGGER.info("Pilatus acquire ON")
|
|
357
336
|
caput(pv.pilat_acquire, 1)
|
|
358
337
|
elif parameters.detector_name == "eiger":
|
|
359
|
-
|
|
338
|
+
SSX_LOGGER.info("Triggering Eiger NOW")
|
|
360
339
|
caput(pv.eiger_trigger, 1)
|
|
361
340
|
|
|
362
341
|
dcid.notify_start()
|
|
363
342
|
|
|
364
343
|
if parameters.detector_name == "eiger":
|
|
365
344
|
wavelength = yield from bps.rd(dcm.wavelength_in_a)
|
|
366
|
-
|
|
345
|
+
SSX_LOGGER.debug("Call nexgen server for nexus writing.")
|
|
367
346
|
call_nexgen(None, start_time, parameters, wavelength, "extruder")
|
|
368
347
|
|
|
369
348
|
timeout_time = time.time() + parameters.num_images * parameters.exposure_time_s + 10
|
|
@@ -381,25 +360,25 @@ def main_extruder_plan(
|
|
|
381
360
|
if zebra_arm_status == 0: # not zebra.pc.is_armed():
|
|
382
361
|
# As soon as zebra is disarmed, exit.
|
|
383
362
|
# Epics updates this PV once the collection is done.
|
|
384
|
-
|
|
363
|
+
SSX_LOGGER.info("Zebra disarmed - Collection done.")
|
|
385
364
|
break
|
|
386
365
|
if time.time() >= timeout_time:
|
|
387
|
-
|
|
366
|
+
SSX_LOGGER.warning(
|
|
388
367
|
"""
|
|
389
368
|
Something went wrong and data collection timed out. Aborting.
|
|
390
369
|
"""
|
|
391
370
|
)
|
|
392
371
|
raise TimeoutError("Data collection timed out.")
|
|
393
372
|
|
|
394
|
-
|
|
373
|
+
SSX_LOGGER.info("Collection completed without errors.")
|
|
395
374
|
|
|
396
375
|
|
|
397
|
-
@
|
|
376
|
+
@log_on_entry
|
|
398
377
|
def collection_aborted_plan(
|
|
399
378
|
zebra: Zebra, detector_name: str, dcid: DCID
|
|
400
379
|
) -> MsgGenerator:
|
|
401
380
|
"""A plan to run in case the collection is aborted before the end."""
|
|
402
|
-
|
|
381
|
+
SSX_LOGGER.warning("Data Collection Aborted")
|
|
403
382
|
yield from disarm_zebra(zebra) # If aborted/timed out zebra still armed
|
|
404
383
|
if detector_name == "pilatus":
|
|
405
384
|
caput(pv.pilat_acquire, 0)
|
|
@@ -410,7 +389,7 @@ def collection_aborted_plan(
|
|
|
410
389
|
dcid.collection_complete(end_time, aborted=True)
|
|
411
390
|
|
|
412
391
|
|
|
413
|
-
@
|
|
392
|
+
@log_on_entry
|
|
414
393
|
def tidy_up_at_collection_end_plan(
|
|
415
394
|
zebra: Zebra,
|
|
416
395
|
shutter: HutchShutter,
|
|
@@ -431,23 +410,23 @@ def tidy_up_at_collection_end_plan(
|
|
|
431
410
|
sup.pilatus("return-to-normal", None)
|
|
432
411
|
elif parameters.detector_name == "eiger":
|
|
433
412
|
sup.eiger("return-to-normal", None)
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
413
|
+
SSX_LOGGER.debug(f"{parameters.filename}_{caget(pv.eiger_seqID)}")
|
|
414
|
+
SSX_LOGGER.debug("End of Run")
|
|
415
|
+
SSX_LOGGER.info("Close hutch shutter")
|
|
437
416
|
yield from bps.abs_set(shutter, ShutterDemand.CLOSE, wait=True)
|
|
438
417
|
|
|
439
418
|
dcid.notify_end()
|
|
440
419
|
|
|
441
420
|
|
|
442
|
-
@
|
|
421
|
+
@log_on_entry
|
|
443
422
|
def collection_complete_plan(
|
|
444
423
|
collection_directory: Path, detector_name: str, dcid: DCID
|
|
445
424
|
) -> MsgGenerator:
|
|
446
425
|
if detector_name == "pilatus":
|
|
447
|
-
|
|
426
|
+
SSX_LOGGER.info("Pilatus Acquire STOP")
|
|
448
427
|
caput(pv.pilat_acquire, 0)
|
|
449
428
|
elif detector_name == "eiger":
|
|
450
|
-
|
|
429
|
+
SSX_LOGGER.info("Eiger Acquire STOP")
|
|
451
430
|
caput(pv.eiger_acquire, 0)
|
|
452
431
|
caput(pv.eiger_ODcapture, "Done")
|
|
453
432
|
|
|
@@ -455,7 +434,7 @@ def collection_complete_plan(
|
|
|
455
434
|
|
|
456
435
|
end_time = datetime.now()
|
|
457
436
|
dcid.collection_complete(end_time, aborted=False)
|
|
458
|
-
|
|
437
|
+
SSX_LOGGER.info(f"End Time = {end_time.ctime()}")
|
|
459
438
|
|
|
460
439
|
# Copy parameter file
|
|
461
440
|
shutil.copy2(
|
|
@@ -474,9 +453,8 @@ def run_extruder_plan(
|
|
|
474
453
|
shutter: HutchShutter = inject("shutter"),
|
|
475
454
|
dcm: DCM = inject("dcm"),
|
|
476
455
|
) -> MsgGenerator:
|
|
477
|
-
setup_logging()
|
|
478
456
|
start_time = datetime.now()
|
|
479
|
-
|
|
457
|
+
SSX_LOGGER.info(f"Collection start time: {start_time.ctime()}")
|
|
480
458
|
|
|
481
459
|
yield from write_parameter_file(detector_stage)
|
|
482
460
|
parameters = ExtruderParameters.from_file(PARAM_FILE_PATH / PARAM_FILE_NAME)
|
|
@@ -3862,7 +3862,7 @@ buttonLabel "Stages"
|
|
|
3862
3862
|
numPvs 4
|
|
3863
3863
|
numDsps 1
|
|
3864
3864
|
displayFileName {
|
|
3865
|
-
0 "/dls_sw/work/R3.14.12.
|
|
3865
|
+
0 "/dls_sw/work/R3.14.12.7/ioc/ME14E/BL/data/ME14E-motors.edl"
|
|
3866
3866
|
}
|
|
3867
3867
|
endObjectProperties
|
|
3868
3868
|
|