mx-bluesky 1.2.0__py3-none-any.whl → 1.4.1a0__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 +49 -11
- mx_bluesky/beamlines/i24/serial/__init__.py +3 -0
- mx_bluesky/beamlines/i24/serial/dcid.py +19 -21
- mx_bluesky/beamlines/i24/serial/extruder/i24ssx_Extruder_Collect_py3v2.py +69 -91
- mx_bluesky/beamlines/i24/serial/fixed_target/FT-gui-edm/DiamondChipI24-py3v1.edl +2 -5
- mx_bluesky/beamlines/i24/serial/fixed_target/ft_utils.py +0 -1
- mx_bluesky/beamlines/i24/serial/fixed_target/i24ssx_Chip_Collect_py3v1.py +111 -143
- mx_bluesky/beamlines/i24/serial/fixed_target/i24ssx_Chip_Manager_py3v1.py +141 -222
- mx_bluesky/beamlines/i24/serial/fixed_target/i24ssx_Chip_StartUp_py3v1.py +7 -216
- mx_bluesky/beamlines/i24/serial/fixed_target/i24ssx_moveonclick.py +18 -17
- mx_bluesky/beamlines/i24/serial/log.py +58 -49
- mx_bluesky/beamlines/i24/serial/parameters/constants.py +0 -1
- 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 +30 -5
- 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 +79 -81
- mx_bluesky/beamlines/i24/serial/setup_beamline/setup_detector.py +9 -20
- mx_bluesky/beamlines/i24/serial/setup_beamline/setup_zebra_plans.py +26 -28
- mx_bluesky/beamlines/i24/serial/write_nexus.py +11 -11
- mx_bluesky/common/__init__.py +0 -0
- mx_bluesky/common/device_setup_plans/read_hardware_for_setup.py +14 -0
- mx_bluesky/common/external_interaction/config_server.py +46 -0
- mx_bluesky/common/parameters/components.py +258 -0
- mx_bluesky/common/parameters/constants.py +138 -0
- mx_bluesky/common/parameters/gridscan.py +94 -0
- mx_bluesky/common/parameters/robot_load.py +16 -0
- mx_bluesky/common/plans/__init__.py +1 -0
- mx_bluesky/common/plans/do_fgs.py +121 -0
- mx_bluesky/common/utils/log.py +118 -0
- mx_bluesky/{hyperion → common/utils}/tracing.py +2 -2
- mx_bluesky/hyperion/__main__.py +13 -10
- 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 +5 -6
- mx_bluesky/hyperion/device_setup_plans/setup_zebra.py +49 -18
- mx_bluesky/hyperion/device_setup_plans/smargon.py +6 -6
- mx_bluesky/hyperion/device_setup_plans/utils.py +2 -2
- mx_bluesky/hyperion/device_setup_plans/xbpm_feedback.py +4 -4
- mx_bluesky/hyperion/experiment_plans/__init__.py +4 -0
- mx_bluesky/hyperion/experiment_plans/change_aperture_then_move_plan.py +83 -0
- mx_bluesky/hyperion/experiment_plans/common/xrc_result.py +47 -0
- mx_bluesky/hyperion/experiment_plans/experiment_registry.py +9 -9
- mx_bluesky/hyperion/experiment_plans/flyscan_xray_centre_plan.py +145 -161
- mx_bluesky/hyperion/experiment_plans/grid_detect_then_xray_centre_plan.py +56 -22
- mx_bluesky/hyperion/experiment_plans/load_centre_collect_full_plan.py +52 -10
- mx_bluesky/hyperion/experiment_plans/oav_grid_detection_plan.py +21 -20
- mx_bluesky/hyperion/experiment_plans/oav_snapshot_plan.py +11 -14
- mx_bluesky/hyperion/experiment_plans/optimise_attenuation_plan.py +2 -2
- mx_bluesky/hyperion/experiment_plans/pin_centre_then_xray_centre_plan.py +40 -21
- mx_bluesky/hyperion/experiment_plans/pin_tip_centring_plan.py +19 -19
- mx_bluesky/hyperion/experiment_plans/robot_load_and_change_energy.py +21 -21
- mx_bluesky/hyperion/experiment_plans/robot_load_then_centre_plan.py +51 -13
- mx_bluesky/hyperion/experiment_plans/rotation_scan_plan.py +24 -7
- mx_bluesky/hyperion/experiment_plans/set_energy_plan.py +5 -6
- mx_bluesky/hyperion/external_interaction/callbacks/__main__.py +1 -2
- mx_bluesky/hyperion/external_interaction/callbacks/common/abstract_event.py +66 -0
- mx_bluesky/hyperion/external_interaction/callbacks/common/ispyb_mapping.py +1 -1
- mx_bluesky/hyperion/external_interaction/callbacks/grid_detection_callback.py +30 -25
- mx_bluesky/hyperion/external_interaction/callbacks/ispyb_callback_base.py +29 -12
- mx_bluesky/hyperion/external_interaction/callbacks/log_uid_tag_callback.py +1 -1
- mx_bluesky/hyperion/external_interaction/callbacks/robot_load/ispyb_callback.py +1 -1
- mx_bluesky/hyperion/external_interaction/callbacks/rotation/ispyb_callback.py +7 -4
- mx_bluesky/hyperion/external_interaction/callbacks/rotation/nexus_callback.py +5 -3
- mx_bluesky/hyperion/external_interaction/callbacks/xray_centre/ispyb_callback.py +28 -20
- mx_bluesky/hyperion/external_interaction/callbacks/xray_centre/nexus_callback.py +5 -4
- mx_bluesky/hyperion/external_interaction/config_server.py +11 -28
- mx_bluesky/hyperion/external_interaction/ispyb/exp_eye_store.py +1 -1
- mx_bluesky/hyperion/external_interaction/ispyb/ispyb_store.py +1 -1
- 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 +4 -251
- mx_bluesky/hyperion/parameters/constants.py +22 -119
- mx_bluesky/hyperion/parameters/gridscan.py +35 -74
- mx_bluesky/hyperion/parameters/load_centre_collect.py +16 -11
- mx_bluesky/hyperion/parameters/rotation.py +23 -10
- mx_bluesky/hyperion/utils/utils.py +17 -0
- mx_bluesky/hyperion/utils/validation.py +5 -6
- {mx_bluesky-1.2.0.dist-info → mx_bluesky-1.4.1a0.dist-info}/METADATA +36 -33
- {mx_bluesky-1.2.0.dist-info → mx_bluesky-1.4.1a0.dist-info}/RECORD +91 -81
- {mx_bluesky-1.2.0.dist-info → mx_bluesky-1.4.1a0.dist-info}/WHEEL +1 -1
- mx_bluesky/beamlines/i24/serial/fixed_target/i24ssx_Chip_Mapping_py3v1.py +0 -161
- mx_bluesky/example.py +0 -19
- mx_bluesky/hyperion/parameters/robot_load.py +0 -16
- {mx_bluesky-1.2.0.dist-info → mx_bluesky-1.4.1a0.dist-info}/LICENSE +0 -0
- {mx_bluesky-1.2.0.dist-info → mx_bluesky-1.4.1a0.dist-info}/entry_points.txt +0 -0
- {mx_bluesky-1.2.0.dist-info → mx_bluesky-1.4.1a0.dist-info}/top_level.txt +0 -0
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
Fixed target data collection
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
import logging
|
|
6
5
|
import shutil
|
|
7
|
-
import time
|
|
8
6
|
from datetime import datetime
|
|
9
7
|
from pathlib import Path
|
|
10
8
|
from time import sleep
|
|
@@ -12,7 +10,7 @@ from time import sleep
|
|
|
12
10
|
import bluesky.plan_stubs as bps
|
|
13
11
|
import bluesky.preprocessors as bpp
|
|
14
12
|
import numpy as np
|
|
15
|
-
from
|
|
13
|
+
from bluesky.utils import MsgGenerator
|
|
16
14
|
from dodal.common import inject
|
|
17
15
|
from dodal.devices.hutch_shutter import HutchShutter, ShutterDemand
|
|
18
16
|
from dodal.devices.i24.aperture import Aperture
|
|
@@ -23,7 +21,6 @@ from dodal.devices.i24.i24_detector_motion import DetectorMotion
|
|
|
23
21
|
from dodal.devices.i24.pmac import PMAC
|
|
24
22
|
from dodal.devices.zebra import Zebra
|
|
25
23
|
|
|
26
|
-
from mx_bluesky.beamlines.i24.serial import log
|
|
27
24
|
from mx_bluesky.beamlines.i24.serial.dcid import DCID
|
|
28
25
|
from mx_bluesky.beamlines.i24.serial.fixed_target.ft_utils import (
|
|
29
26
|
ChipType,
|
|
@@ -33,6 +30,7 @@ from mx_bluesky.beamlines.i24.serial.fixed_target.ft_utils import (
|
|
|
33
30
|
from mx_bluesky.beamlines.i24.serial.fixed_target.i24ssx_Chip_Manager_py3v1 import (
|
|
34
31
|
write_parameter_file,
|
|
35
32
|
)
|
|
33
|
+
from mx_bluesky.beamlines.i24.serial.log import SSX_LOGGER, log_on_entry
|
|
36
34
|
from mx_bluesky.beamlines.i24.serial.parameters import (
|
|
37
35
|
ChipDescription,
|
|
38
36
|
FixedTargetParameters,
|
|
@@ -56,15 +54,9 @@ from mx_bluesky.beamlines.i24.serial.setup_beamline.setup_zebra_plans import (
|
|
|
56
54
|
)
|
|
57
55
|
from mx_bluesky.beamlines.i24.serial.write_nexus import call_nexgen
|
|
58
56
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
def setup_logging():
|
|
65
|
-
# Log should now change name daily
|
|
66
|
-
logfile = time.strftime("i24fixedtarget_%d%B%y.log").lower()
|
|
67
|
-
log.config(logfile)
|
|
57
|
+
# Move this in common place as part of
|
|
58
|
+
# https://github.com/DiamondLightSource/mx-bluesky/pull/603
|
|
59
|
+
PMAC_MOVE_TIME = 0.008 # Move time between positions on chip ~ 7-8 ms
|
|
68
60
|
|
|
69
61
|
|
|
70
62
|
def calculate_collection_timeout(parameters: FixedTargetParameters) -> float:
|
|
@@ -85,7 +77,7 @@ def calculate_collection_timeout(parameters: FixedTargetParameters) -> float:
|
|
|
85
77
|
Returns:
|
|
86
78
|
The estimated collection time, in s.
|
|
87
79
|
"""
|
|
88
|
-
buffer =
|
|
80
|
+
buffer = PMAC_MOVE_TIME * parameters.total_num_images + 600
|
|
89
81
|
pump_setting = parameters.pump_repeat
|
|
90
82
|
collection_time = parameters.total_num_images * parameters.exposure_time_s
|
|
91
83
|
if pump_setting in [
|
|
@@ -105,7 +97,7 @@ def calculate_collection_timeout(parameters: FixedTargetParameters) -> float:
|
|
|
105
97
|
)
|
|
106
98
|
if pump_setting == PumpProbeSetting.Medium1:
|
|
107
99
|
# Long delay between pump and probe, with fast shutter opening and closing.
|
|
108
|
-
timeout = timeout + SHUTTER_OPEN_TIME
|
|
100
|
+
timeout = timeout + SHUTTER_OPEN_TIME * parameters.total_num_images
|
|
109
101
|
return timeout
|
|
110
102
|
|
|
111
103
|
|
|
@@ -131,7 +123,7 @@ def write_userlog(
|
|
|
131
123
|
# Write a record of what was collected to the processing directory
|
|
132
124
|
userlog_path = Path(parameters.visit) / f"processing/{parameters.directory}"
|
|
133
125
|
userlog_fid = f"{filename}_parameters.txt"
|
|
134
|
-
|
|
126
|
+
SSX_LOGGER.debug(f"Write a user log in {userlog_path}")
|
|
135
127
|
|
|
136
128
|
userlog_path.mkdir(parents=True, exist_ok=True)
|
|
137
129
|
|
|
@@ -154,7 +146,7 @@ def write_userlog(
|
|
|
154
146
|
f.write(text)
|
|
155
147
|
|
|
156
148
|
|
|
157
|
-
@
|
|
149
|
+
@log_on_entry
|
|
158
150
|
def get_chip_prog_values(
|
|
159
151
|
parameters: FixedTargetParameters,
|
|
160
152
|
):
|
|
@@ -179,7 +171,7 @@ def get_chip_prog_values(
|
|
|
179
171
|
else:
|
|
180
172
|
raise ValueError(f"Unknown pump_repeat, pump_repeat = {parameters.pump_repeat}")
|
|
181
173
|
|
|
182
|
-
|
|
174
|
+
SSX_LOGGER.info(
|
|
183
175
|
f"Pump repeat is {str(parameters.pump_repeat)}, PVAR set to {pump_repeat_pvar}"
|
|
184
176
|
)
|
|
185
177
|
|
|
@@ -188,7 +180,7 @@ def get_chip_prog_values(
|
|
|
188
180
|
else:
|
|
189
181
|
pump_in_probe = 0
|
|
190
182
|
|
|
191
|
-
|
|
183
|
+
SSX_LOGGER.info(f"pump_in_probe set to {pump_in_probe}")
|
|
192
184
|
|
|
193
185
|
chip_dict: dict[str, list] = {
|
|
194
186
|
"X_NUM_STEPS": [11, parameters.chip.x_num_steps],
|
|
@@ -226,7 +218,7 @@ def get_chip_prog_values(
|
|
|
226
218
|
return chip_dict
|
|
227
219
|
|
|
228
220
|
|
|
229
|
-
@
|
|
221
|
+
@log_on_entry
|
|
230
222
|
def load_motion_program_data(
|
|
231
223
|
pmac: PMAC,
|
|
232
224
|
motion_program_dict: dict[str, list],
|
|
@@ -234,26 +226,24 @@ def load_motion_program_data(
|
|
|
234
226
|
pump_repeat: int,
|
|
235
227
|
checker_pattern: bool,
|
|
236
228
|
):
|
|
237
|
-
|
|
238
|
-
|
|
229
|
+
SSX_LOGGER.info("Loading motion program data for chip.")
|
|
230
|
+
SSX_LOGGER.info(f"Pump_repeat is {PumpProbeSetting(pump_repeat)}")
|
|
239
231
|
if pump_repeat == PumpProbeSetting.NoPP:
|
|
240
232
|
if map_type == MappingType.NoMap:
|
|
241
233
|
prefix = 11
|
|
242
|
-
|
|
234
|
+
SSX_LOGGER.info(f"Map type is None, setting program prefix to {prefix}")
|
|
243
235
|
elif map_type == MappingType.Lite:
|
|
244
236
|
prefix = 12
|
|
245
|
-
elif map_type == MappingType.Full:
|
|
246
|
-
prefix = 13
|
|
247
237
|
else:
|
|
248
|
-
|
|
238
|
+
SSX_LOGGER.warning(f"Unknown Map Type, map_type = {map_type}")
|
|
249
239
|
return
|
|
250
240
|
elif pump_repeat in [pp.value for pp in PumpProbeSetting if pp != 0]:
|
|
251
241
|
# Pump setting chosen
|
|
252
242
|
prefix = 14
|
|
253
|
-
|
|
243
|
+
SSX_LOGGER.info(f"Setting program prefix to {prefix}")
|
|
254
244
|
yield from bps.abs_set(pmac.pmac_string, "P1439=0", wait=True)
|
|
255
245
|
if checker_pattern:
|
|
256
|
-
|
|
246
|
+
SSX_LOGGER.info("Checker pattern setting enabled.")
|
|
257
247
|
yield from bps.abs_set(pmac.pmac_string, "P1439=1", wait=True)
|
|
258
248
|
if pump_repeat == PumpProbeSetting.Medium1:
|
|
259
249
|
# Medium1 has time delays (Fast shutter opening time in ms)
|
|
@@ -261,23 +251,23 @@ def load_motion_program_data(
|
|
|
261
251
|
else:
|
|
262
252
|
yield from bps.abs_set(pmac.pmac_string, "P1441=0", wait=True)
|
|
263
253
|
else:
|
|
264
|
-
|
|
254
|
+
SSX_LOGGER.warning(f"Unknown Pump repeat, pump_repeat = {pump_repeat}")
|
|
265
255
|
return
|
|
266
256
|
|
|
267
|
-
|
|
257
|
+
SSX_LOGGER.info("Set PMAC_STRING pv.")
|
|
268
258
|
for key in sorted(motion_program_dict.keys()):
|
|
269
259
|
v = motion_program_dict[key]
|
|
270
260
|
pvar_base = prefix * 100
|
|
271
261
|
pvar = pvar_base + v[0]
|
|
272
262
|
value = str(v[1])
|
|
273
263
|
s = f"P{pvar}={value}"
|
|
274
|
-
|
|
264
|
+
SSX_LOGGER.info(f"{key} \t {s}")
|
|
275
265
|
yield from bps.abs_set(pmac.pmac_string, s, wait=True)
|
|
276
266
|
yield from bps.sleep(0.02)
|
|
277
267
|
yield from bps.sleep(0.2)
|
|
278
268
|
|
|
279
269
|
|
|
280
|
-
@
|
|
270
|
+
@log_on_entry
|
|
281
271
|
def get_prog_num(
|
|
282
272
|
chip_type: ChipType, map_type: MappingType, pump_repeat: PumpProbeSetting
|
|
283
273
|
) -> int:
|
|
@@ -290,60 +280,52 @@ def get_prog_num(
|
|
|
290
280
|
- Oxford chips with full mapping should return 13. Currently disabled, will \
|
|
291
281
|
raise an error.
|
|
292
282
|
"""
|
|
293
|
-
|
|
294
|
-
|
|
283
|
+
SSX_LOGGER.info("Get Program Number for the motion program.")
|
|
284
|
+
SSX_LOGGER.info(f"Pump_repeat: {str(pump_repeat)} \t Chip Type: {str(chip_type)}")
|
|
295
285
|
if pump_repeat != PumpProbeSetting.NoPP:
|
|
296
|
-
|
|
297
|
-
|
|
286
|
+
SSX_LOGGER.info("Assuming Map type = Mapping Lite.")
|
|
287
|
+
SSX_LOGGER.info("Program number: 14")
|
|
298
288
|
return 14
|
|
299
289
|
|
|
300
290
|
if chip_type not in [ChipType.Oxford, ChipType.OxfordInner]:
|
|
301
|
-
|
|
291
|
+
SSX_LOGGER.info("Program number: 11")
|
|
302
292
|
return 11
|
|
303
293
|
|
|
304
294
|
if map_type == MappingType.NoMap:
|
|
305
|
-
|
|
306
|
-
|
|
295
|
+
SSX_LOGGER.info(f"Map type: {str(map_type)}")
|
|
296
|
+
SSX_LOGGER.info("Program number: 11")
|
|
307
297
|
return 11
|
|
308
298
|
if map_type == MappingType.Lite:
|
|
309
|
-
|
|
310
|
-
|
|
299
|
+
SSX_LOGGER.info(f"Map type: {str(map_type)}")
|
|
300
|
+
SSX_LOGGER.info("Program number: 12")
|
|
311
301
|
return 12
|
|
312
|
-
if map_type == MappingType.Full:
|
|
313
|
-
# TODO See https://github.com/DiamondLightSource/mx-bluesky/issues/515
|
|
314
|
-
logger.info(f"Map type: {str(map_type)}")
|
|
315
|
-
logger.info("Program number: 13")
|
|
316
|
-
# TODO once reinstated return 13
|
|
317
|
-
msg = "Full mapping is broken and currently disabled."
|
|
318
|
-
logger.error(msg)
|
|
319
|
-
raise ValueError(msg)
|
|
320
302
|
|
|
321
303
|
|
|
322
|
-
@
|
|
304
|
+
@log_on_entry
|
|
323
305
|
def datasetsizei24(
|
|
324
306
|
n_exposures: int,
|
|
325
307
|
chip_params: ChipDescription,
|
|
326
308
|
map_type: MappingType,
|
|
327
309
|
) -> int:
|
|
328
310
|
# Calculates how many images will be collected based on map type and N repeats
|
|
329
|
-
|
|
311
|
+
SSX_LOGGER.info("Calculate total number of images expected in data collection.")
|
|
330
312
|
|
|
331
313
|
if map_type == MappingType.NoMap:
|
|
332
314
|
if chip_params.chip_type == ChipType.Custom:
|
|
333
315
|
total_numb_imgs = chip_params.x_num_steps * chip_params.y_num_steps
|
|
334
|
-
|
|
316
|
+
SSX_LOGGER.info(
|
|
335
317
|
f"Map type: None \tCustom chip \tNumber of images {total_numb_imgs}"
|
|
336
318
|
)
|
|
337
319
|
else:
|
|
338
320
|
chip_format = chip_params.chip_format[:4]
|
|
339
321
|
total_numb_imgs = int(np.prod(chip_format))
|
|
340
|
-
|
|
322
|
+
SSX_LOGGER.info(
|
|
341
323
|
f"""Map type: None \tOxford chip {chip_params.chip_type} \t \
|
|
342
324
|
Number of images {total_numb_imgs}"""
|
|
343
325
|
)
|
|
344
326
|
|
|
345
327
|
elif map_type == MappingType.Lite:
|
|
346
|
-
|
|
328
|
+
SSX_LOGGER.info(f"Using Mapping Lite on chip type {chip_params.chip_type}")
|
|
347
329
|
chip_format = chip_params.chip_format[2:4]
|
|
348
330
|
block_count = 0
|
|
349
331
|
with open(LITEMAP_PATH / "currentchip.map") as f:
|
|
@@ -352,29 +334,21 @@ def datasetsizei24(
|
|
|
352
334
|
if entry[2] == "1":
|
|
353
335
|
block_count += 1
|
|
354
336
|
|
|
355
|
-
|
|
356
|
-
|
|
337
|
+
SSX_LOGGER.info(f"Block count={block_count}")
|
|
338
|
+
SSX_LOGGER.info(f"Chip format={chip_format}")
|
|
357
339
|
|
|
358
|
-
|
|
340
|
+
SSX_LOGGER.info(f"Number of exposures={n_exposures}")
|
|
359
341
|
|
|
360
342
|
total_numb_imgs = int(np.prod(chip_format) * block_count * n_exposures)
|
|
361
|
-
|
|
343
|
+
SSX_LOGGER.info(f"Calculated number of images: {total_numb_imgs}")
|
|
362
344
|
|
|
363
|
-
|
|
364
|
-
logger.error("Not Set Up For Full Mapping")
|
|
365
|
-
raise ValueError("The beamline is currently not set for Full Mapping.")
|
|
366
|
-
|
|
367
|
-
else:
|
|
368
|
-
logger.warning(f"Unknown Map Type, map_type = {str(map_type)}")
|
|
369
|
-
raise ValueError("Unknown map type")
|
|
370
|
-
|
|
371
|
-
logger.info("Set PV to calculated number of images.")
|
|
345
|
+
SSX_LOGGER.info("Set PV to calculated number of images.")
|
|
372
346
|
caput(pv.me14e_gp10, int(total_numb_imgs))
|
|
373
347
|
|
|
374
348
|
return int(total_numb_imgs)
|
|
375
349
|
|
|
376
350
|
|
|
377
|
-
@
|
|
351
|
+
@log_on_entry
|
|
378
352
|
def start_i24(
|
|
379
353
|
zebra: Zebra,
|
|
380
354
|
aperture: Aperture,
|
|
@@ -390,11 +364,11 @@ def start_i24(
|
|
|
390
364
|
Returns the start_time.
|
|
391
365
|
"""
|
|
392
366
|
|
|
393
|
-
|
|
367
|
+
SSX_LOGGER.info("Start I24 data collection.")
|
|
394
368
|
start_time = datetime.now()
|
|
395
|
-
|
|
369
|
+
SSX_LOGGER.info(f"Collection start time {start_time.ctime()}")
|
|
396
370
|
|
|
397
|
-
|
|
371
|
+
SSX_LOGGER.debug("Set up beamline")
|
|
398
372
|
yield from sup.setup_beamline_for_collection_plan(
|
|
399
373
|
aperture, backlight, beamstop, wait=True
|
|
400
374
|
)
|
|
@@ -403,27 +377,27 @@ def start_i24(
|
|
|
403
377
|
detector_stage, parameters.detector_distance_mm
|
|
404
378
|
)
|
|
405
379
|
|
|
406
|
-
|
|
380
|
+
SSX_LOGGER.debug("Set up beamline DONE")
|
|
407
381
|
|
|
408
382
|
filepath = parameters.collection_directory.as_posix()
|
|
409
383
|
filename = parameters.filename
|
|
410
384
|
|
|
411
|
-
|
|
385
|
+
SSX_LOGGER.debug("Acquire Region")
|
|
412
386
|
|
|
413
387
|
num_gates = parameters.total_num_images // parameters.num_exposures
|
|
414
388
|
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
389
|
+
SSX_LOGGER.info(f"Total number of images: {parameters.total_num_images}")
|
|
390
|
+
SSX_LOGGER.info(f"Number of exposures: {parameters.num_exposures}")
|
|
391
|
+
SSX_LOGGER.info(f"Number of gates (=Total images/N exposures): {num_gates:.4f}")
|
|
418
392
|
|
|
419
393
|
if parameters.detector_name == "pilatus":
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
394
|
+
SSX_LOGGER.info("Using Pilatus detector")
|
|
395
|
+
SSX_LOGGER.info(f"Fastchip Pilatus setup: filepath {filepath}")
|
|
396
|
+
SSX_LOGGER.info(f"Fastchip Pilatus setup: filename {filename}")
|
|
397
|
+
SSX_LOGGER.info(
|
|
424
398
|
f"Fastchip Pilatus setup: number of images {parameters.total_num_images}"
|
|
425
399
|
)
|
|
426
|
-
|
|
400
|
+
SSX_LOGGER.info(
|
|
427
401
|
f"Fastchip Pilatus setup: exposure time {parameters.exposure_time_s}"
|
|
428
402
|
)
|
|
429
403
|
|
|
@@ -438,7 +412,7 @@ def start_i24(
|
|
|
438
412
|
)
|
|
439
413
|
|
|
440
414
|
# DCID process depends on detector PVs being set up already
|
|
441
|
-
|
|
415
|
+
SSX_LOGGER.debug("Start DCID process")
|
|
442
416
|
dcid.generate_dcid(
|
|
443
417
|
visit=parameters.visit.name,
|
|
444
418
|
image_dir=filepath,
|
|
@@ -451,8 +425,12 @@ def start_i24(
|
|
|
451
425
|
pump_status=parameters.pump_repeat.value,
|
|
452
426
|
)
|
|
453
427
|
|
|
454
|
-
|
|
455
|
-
shutter_time_offset =
|
|
428
|
+
SSX_LOGGER.debug("Arm Pilatus. Arm Zebra.")
|
|
429
|
+
shutter_time_offset = (
|
|
430
|
+
SHUTTER_OPEN_TIME
|
|
431
|
+
if parameters.pump_repeat is PumpProbeSetting.Medium1
|
|
432
|
+
else 0.0
|
|
433
|
+
)
|
|
456
434
|
yield from setup_zebra_for_fastchip_plan(
|
|
457
435
|
zebra,
|
|
458
436
|
parameters.detector_name,
|
|
@@ -472,33 +450,17 @@ def start_i24(
|
|
|
472
450
|
sleep(1.5)
|
|
473
451
|
|
|
474
452
|
elif parameters.detector_name == "eiger":
|
|
475
|
-
|
|
453
|
+
SSX_LOGGER.info("Using Eiger detector")
|
|
476
454
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
Running a Single image pilatus data collection to create directory."""
|
|
480
|
-
)
|
|
481
|
-
num_imgs = 1
|
|
482
|
-
sup.pilatus(
|
|
483
|
-
"quickshot-internaltrig",
|
|
484
|
-
[filepath, filename, num_imgs, parameters.exposure_time_s],
|
|
485
|
-
)
|
|
486
|
-
logger.debug("Sleep 2s waiting for pilatus to arm")
|
|
487
|
-
sleep(2)
|
|
488
|
-
sleep(0.5)
|
|
489
|
-
caput(pv.pilat_acquire, "0") # Disarm pilatus
|
|
490
|
-
sleep(0.5)
|
|
491
|
-
caput(pv.pilat_acquire, "1") # Arm pilatus
|
|
492
|
-
logger.debug("Pilatus data collection DONE")
|
|
493
|
-
sup.pilatus("return to normal", None)
|
|
494
|
-
logger.info("Pilatus back to normal. Single image pilatus data collection DONE")
|
|
455
|
+
SSX_LOGGER.debug(f"Creating the directory for the collection in {filepath}.")
|
|
456
|
+
Path(filepath).mkdir(parents=True, exist_ok=True)
|
|
495
457
|
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
458
|
+
SSX_LOGGER.info(f"Triggered Eiger setup: filepath {filepath}")
|
|
459
|
+
SSX_LOGGER.info(f"Triggered Eiger setup: filename {filename}")
|
|
460
|
+
SSX_LOGGER.info(
|
|
499
461
|
f"Triggered Eiger setup: number of images {parameters.total_num_images}"
|
|
500
462
|
)
|
|
501
|
-
|
|
463
|
+
SSX_LOGGER.info(
|
|
502
464
|
f"Triggered Eiger setup: exposure time {parameters.exposure_time_s}"
|
|
503
465
|
)
|
|
504
466
|
|
|
@@ -513,7 +475,7 @@ def start_i24(
|
|
|
513
475
|
)
|
|
514
476
|
|
|
515
477
|
# DCID process depends on detector PVs being set up already
|
|
516
|
-
|
|
478
|
+
SSX_LOGGER.debug("Start DCID process")
|
|
517
479
|
dcid.generate_dcid(
|
|
518
480
|
visit=parameters.visit.name,
|
|
519
481
|
image_dir=filepath,
|
|
@@ -526,8 +488,12 @@ def start_i24(
|
|
|
526
488
|
pump_status=parameters.pump_repeat.value,
|
|
527
489
|
)
|
|
528
490
|
|
|
529
|
-
|
|
530
|
-
shutter_time_offset =
|
|
491
|
+
SSX_LOGGER.debug("Arm Zebra.")
|
|
492
|
+
shutter_time_offset = (
|
|
493
|
+
SHUTTER_OPEN_TIME
|
|
494
|
+
if parameters.pump_repeat is PumpProbeSetting.Medium1
|
|
495
|
+
else 0.0
|
|
496
|
+
)
|
|
531
497
|
yield from setup_zebra_for_fastchip_plan(
|
|
532
498
|
zebra,
|
|
533
499
|
parameters.detector_name,
|
|
@@ -547,7 +513,7 @@ def start_i24(
|
|
|
547
513
|
|
|
548
514
|
else:
|
|
549
515
|
msg = f"Unknown Detector Type, det_type = {parameters.detector_name}"
|
|
550
|
-
|
|
516
|
+
SSX_LOGGER.error(msg)
|
|
551
517
|
raise ValueError(msg)
|
|
552
518
|
|
|
553
519
|
# Open the hutch shutter
|
|
@@ -556,7 +522,7 @@ def start_i24(
|
|
|
556
522
|
return start_time
|
|
557
523
|
|
|
558
524
|
|
|
559
|
-
@
|
|
525
|
+
@log_on_entry
|
|
560
526
|
def finish_i24(
|
|
561
527
|
zebra: Zebra,
|
|
562
528
|
pmac: PMAC,
|
|
@@ -564,20 +530,22 @@ def finish_i24(
|
|
|
564
530
|
dcm: DCM,
|
|
565
531
|
parameters: FixedTargetParameters,
|
|
566
532
|
):
|
|
567
|
-
|
|
533
|
+
SSX_LOGGER.info(
|
|
534
|
+
f"Finish I24 data collection with {parameters.detector_name} detector."
|
|
535
|
+
)
|
|
568
536
|
|
|
569
537
|
complete_filename: str
|
|
570
538
|
transmission = float(caget(pv.pilat_filtertrasm))
|
|
571
539
|
wavelength = yield from bps.rd(dcm.wavelength_in_a)
|
|
572
540
|
|
|
573
541
|
if parameters.detector_name == "pilatus":
|
|
574
|
-
|
|
542
|
+
SSX_LOGGER.debug("Finish I24 Pilatus")
|
|
575
543
|
complete_filename = f"{parameters.filename}_{caget(pv.pilat_filenum)}"
|
|
576
544
|
yield from reset_zebra_when_collection_done_plan(zebra)
|
|
577
545
|
sup.pilatus("return-to-normal", None)
|
|
578
546
|
sleep(0.2)
|
|
579
547
|
elif parameters.detector_name == "eiger":
|
|
580
|
-
|
|
548
|
+
SSX_LOGGER.debug("Finish I24 Eiger")
|
|
581
549
|
yield from reset_zebra_when_collection_done_plan(zebra)
|
|
582
550
|
sup.eiger("return-to-normal", None)
|
|
583
551
|
complete_filename = cagetstring(pv.eiger_ODfilenameRBV) # type: ignore
|
|
@@ -585,9 +553,9 @@ def finish_i24(
|
|
|
585
553
|
raise ValueError(f"{parameters.detector_name=} unrecognised")
|
|
586
554
|
|
|
587
555
|
# Detector independent moves
|
|
588
|
-
|
|
556
|
+
SSX_LOGGER.info("Move chip back to home position by setting PMAC_STRING pv.")
|
|
589
557
|
yield from bps.trigger(pmac.to_xyz_zero)
|
|
590
|
-
|
|
558
|
+
SSX_LOGGER.info("Closing shutter")
|
|
591
559
|
yield from bps.abs_set(shutter, ShutterDemand.CLOSE, wait=True)
|
|
592
560
|
|
|
593
561
|
# Write a record of what was collected to the processing directory
|
|
@@ -599,14 +567,14 @@ def run_aborted_plan(pmac: PMAC, dcid: DCID):
|
|
|
599
567
|
either by pressing the Abort button or because of a timeout, and to reset the \
|
|
600
568
|
P variable.
|
|
601
569
|
"""
|
|
602
|
-
|
|
570
|
+
SSX_LOGGER.warning("Data Collection Aborted")
|
|
603
571
|
yield from bps.trigger(pmac.abort_program, wait=True)
|
|
604
572
|
|
|
605
573
|
end_time = datetime.now()
|
|
606
574
|
dcid.collection_complete(end_time, aborted=True)
|
|
607
575
|
|
|
608
576
|
|
|
609
|
-
@
|
|
577
|
+
@log_on_entry
|
|
610
578
|
def main_fixed_target_plan(
|
|
611
579
|
zebra: Zebra,
|
|
612
580
|
pmac: PMAC,
|
|
@@ -619,17 +587,17 @@ def main_fixed_target_plan(
|
|
|
619
587
|
parameters: FixedTargetParameters,
|
|
620
588
|
dcid: DCID,
|
|
621
589
|
) -> MsgGenerator:
|
|
622
|
-
|
|
590
|
+
SSX_LOGGER.info("Running a chip collection on I24")
|
|
623
591
|
|
|
624
|
-
|
|
592
|
+
SSX_LOGGER.info("Getting Program Dictionary")
|
|
625
593
|
|
|
626
594
|
# If alignment type is Oxford inner it is still an Oxford type chip
|
|
627
595
|
if parameters.chip.chip_type == ChipType.OxfordInner:
|
|
628
|
-
|
|
596
|
+
SSX_LOGGER.debug("Change chip type Oxford Inner to Oxford.")
|
|
629
597
|
parameters.chip.chip_type = ChipType.Oxford
|
|
630
598
|
|
|
631
599
|
chip_prog_dict = get_chip_prog_values(parameters)
|
|
632
|
-
|
|
600
|
+
SSX_LOGGER.info("Loading Motion Program Data")
|
|
633
601
|
yield from load_motion_program_data(
|
|
634
602
|
pmac,
|
|
635
603
|
chip_prog_dict,
|
|
@@ -646,21 +614,21 @@ def main_fixed_target_plan(
|
|
|
646
614
|
zebra, aperture, backlight, beamstop, detector_stage, shutter, parameters, dcid
|
|
647
615
|
)
|
|
648
616
|
|
|
649
|
-
|
|
617
|
+
SSX_LOGGER.info("Moving to Start")
|
|
650
618
|
yield from bps.trigger(pmac.to_xyz_zero)
|
|
651
619
|
sleep(2.0)
|
|
652
620
|
|
|
653
621
|
# Now ready for data collection. Open fast shutter (zebra gate)
|
|
654
|
-
|
|
622
|
+
SSX_LOGGER.info("Opening fast shutter.")
|
|
655
623
|
yield from open_fast_shutter(zebra)
|
|
656
624
|
|
|
657
625
|
# Kick off the StartOfCollect script
|
|
658
|
-
|
|
626
|
+
SSX_LOGGER.debug("Notify DCID of the start of the collection.")
|
|
659
627
|
dcid.notify_start()
|
|
660
628
|
|
|
661
629
|
wavelength = yield from bps.rd(dcm.wavelength_in_a)
|
|
662
630
|
if parameters.detector_name == "eiger":
|
|
663
|
-
|
|
631
|
+
SSX_LOGGER.debug("Start nexus writing service.")
|
|
664
632
|
call_nexgen(
|
|
665
633
|
chip_prog_dict,
|
|
666
634
|
start_time,
|
|
@@ -678,7 +646,7 @@ def kickoff_and_complete_collection(pmac: PMAC, parameters: FixedTargetParameter
|
|
|
678
646
|
yield from bps.abs_set(pmac.program_number, prog_num, group="setup_pmac")
|
|
679
647
|
# Calculate approx collection time
|
|
680
648
|
total_collection_time = calculate_collection_timeout(parameters)
|
|
681
|
-
|
|
649
|
+
SSX_LOGGER.info(f"Estimated collection time: {total_collection_time}s.")
|
|
682
650
|
yield from bps.abs_set(
|
|
683
651
|
pmac.collection_time, total_collection_time, group="setup_pmac"
|
|
684
652
|
)
|
|
@@ -686,20 +654,20 @@ def kickoff_and_complete_collection(pmac: PMAC, parameters: FixedTargetParameter
|
|
|
686
654
|
|
|
687
655
|
@bpp.run_decorator(md={"subplan_name": "run_ft_collection"})
|
|
688
656
|
def run_collection():
|
|
689
|
-
|
|
657
|
+
SSX_LOGGER.info(f"Kick off PMAC with program number {prog_num}.")
|
|
690
658
|
yield from bps.kickoff(pmac.run_program, wait=True)
|
|
691
659
|
yield from bps.complete(pmac.run_program, wait=True)
|
|
692
|
-
|
|
660
|
+
SSX_LOGGER.info("Collection completed without errors.")
|
|
693
661
|
|
|
694
662
|
yield from run_collection()
|
|
695
663
|
|
|
696
664
|
|
|
697
|
-
@
|
|
665
|
+
@log_on_entry
|
|
698
666
|
def collection_complete_plan(
|
|
699
667
|
dcid: DCID, collection_directory: Path, map_type: MappingType
|
|
700
668
|
) -> MsgGenerator:
|
|
701
669
|
end_time = datetime.now()
|
|
702
|
-
|
|
670
|
+
SSX_LOGGER.debug(f"Collection end time {end_time}")
|
|
703
671
|
dcid.collection_complete(end_time, aborted=False)
|
|
704
672
|
|
|
705
673
|
# Copy parameter file and eventual chip map to collection directory
|
|
@@ -707,7 +675,7 @@ def collection_complete_plan(
|
|
|
707
675
|
yield from bps.null()
|
|
708
676
|
|
|
709
677
|
|
|
710
|
-
@
|
|
678
|
+
@log_on_entry
|
|
711
679
|
def tidy_up_after_collection_plan(
|
|
712
680
|
zebra: Zebra,
|
|
713
681
|
pmac: PMAC,
|
|
@@ -719,27 +687,29 @@ def tidy_up_after_collection_plan(
|
|
|
719
687
|
"""A plan to be run to tidy things up at the end af a fixed target collection, \
|
|
720
688
|
both successful or aborted.
|
|
721
689
|
"""
|
|
722
|
-
|
|
690
|
+
SSX_LOGGER.info("Closing fast shutter")
|
|
723
691
|
yield from close_fast_shutter(zebra)
|
|
724
692
|
sleep(2.0)
|
|
725
693
|
|
|
726
694
|
# This probably should go in main then
|
|
727
695
|
if parameters.detector_name == "pilatus":
|
|
728
|
-
|
|
696
|
+
SSX_LOGGER.debug("Pilatus Acquire STOP")
|
|
729
697
|
caput(pv.pilat_acquire, 0)
|
|
730
698
|
elif parameters.detector_name == "eiger":
|
|
731
|
-
|
|
699
|
+
SSX_LOGGER.debug("Eiger Acquire STOP")
|
|
732
700
|
caput(pv.eiger_acquire, 0)
|
|
733
701
|
caput(pv.eiger_ODcapture, "Done")
|
|
734
702
|
sleep(0.5)
|
|
735
703
|
|
|
736
704
|
yield from finish_i24(zebra, pmac, shutter, dcm, parameters)
|
|
737
705
|
|
|
738
|
-
|
|
706
|
+
SSX_LOGGER.debug("Notify DCID of end of collection.")
|
|
739
707
|
dcid.notify_end()
|
|
740
708
|
|
|
741
|
-
|
|
742
|
-
|
|
709
|
+
SSX_LOGGER.debug("Quick summary of settings")
|
|
710
|
+
SSX_LOGGER.debug(
|
|
711
|
+
f"Chip name = {parameters.filename} sub_dir = {parameters.directory}"
|
|
712
|
+
)
|
|
743
713
|
|
|
744
714
|
|
|
745
715
|
def run_fixed_target_plan(
|
|
@@ -752,12 +722,10 @@ def run_fixed_target_plan(
|
|
|
752
722
|
shutter: HutchShutter = inject("shutter"),
|
|
753
723
|
dcm: DCM = inject("dcm"),
|
|
754
724
|
) -> MsgGenerator:
|
|
755
|
-
setup_logging()
|
|
756
|
-
|
|
757
725
|
# in the first instance, write params here
|
|
758
726
|
yield from write_parameter_file(detector_stage)
|
|
759
727
|
|
|
760
|
-
|
|
728
|
+
SSX_LOGGER.info("Getting parameters from file.")
|
|
761
729
|
parameters = FixedTargetParameters.from_file(PARAM_FILE_PATH_FT / PARAM_FILE_NAME)
|
|
762
730
|
|
|
763
731
|
log_msg = f"""
|
|
@@ -776,7 +744,7 @@ def run_fixed_target_plan(
|
|
|
776
744
|
pumpdelay = {parameters.laser_delay_s}
|
|
777
745
|
prepumpexptime = {parameters.pre_pump_exposure_s}
|
|
778
746
|
"""
|
|
779
|
-
|
|
747
|
+
SSX_LOGGER.info(log_msg)
|
|
780
748
|
|
|
781
749
|
# DCID instance - do not create yet
|
|
782
750
|
dcid = DCID(
|