mx-bluesky 1.4.1a0__py3-none-any.whl → 1.4.2__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 +178 -0
- mx_bluesky/beamlines/i24/serial/__init__.py +0 -6
- mx_bluesky/beamlines/i24/serial/dcid.py +125 -151
- mx_bluesky/beamlines/i24/serial/extruder/EX-gui-edm/DiamondExtruder-I24-py3v1.edl +1 -1
- mx_bluesky/beamlines/i24/serial/extruder/i24ssx_Extruder_Collect_py3v2.py +66 -36
- mx_bluesky/beamlines/i24/serial/fixed_target/FT-gui-edm/DiamondChipI24-py3v1.edl +1 -1
- mx_bluesky/beamlines/i24/serial/fixed_target/FT-gui-edm/MappingLite-oxford_py3v1.edl +2 -46
- mx_bluesky/beamlines/i24/serial/fixed_target/i24ssx_Chip_Collect_py3v1.py +74 -120
- mx_bluesky/beamlines/i24/serial/fixed_target/i24ssx_Chip_Manager_py3v1.py +58 -66
- mx_bluesky/beamlines/i24/serial/fixed_target/i24ssx_Chip_StartUp_py3v1.py +1 -19
- mx_bluesky/beamlines/i24/serial/parameters/__init__.py +9 -1
- mx_bluesky/beamlines/i24/serial/parameters/constants.py +6 -0
- mx_bluesky/beamlines/i24/serial/parameters/experiment_parameters.py +75 -16
- mx_bluesky/beamlines/i24/serial/parameters/utils.py +19 -0
- mx_bluesky/beamlines/i24/serial/setup_beamline/pv.py +2 -0
- mx_bluesky/beamlines/i24/serial/setup_beamline/setup_beamline.py +32 -8
- mx_bluesky/beamlines/i24/serial/write_nexus.py +66 -67
- mx_bluesky/common/parameters/components.py +3 -3
- mx_bluesky/common/parameters/constants.py +5 -0
- mx_bluesky/hyperion/device_setup_plans/dcm_pitch_roll_mirror_adjuster.py +21 -31
- mx_bluesky/hyperion/device_setup_plans/manipulate_sample.py +6 -6
- mx_bluesky/hyperion/device_setup_plans/smargon.py +3 -3
- mx_bluesky/hyperion/exceptions.py +13 -1
- mx_bluesky/hyperion/experiment_plans/flyscan_xray_centre_plan.py +16 -10
- mx_bluesky/hyperion/experiment_plans/grid_detect_then_xray_centre_plan.py +0 -8
- mx_bluesky/hyperion/experiment_plans/load_centre_collect_full_plan.py +58 -34
- mx_bluesky/hyperion/experiment_plans/oav_snapshot_plan.py +8 -2
- mx_bluesky/hyperion/experiment_plans/pin_tip_centring_plan.py +3 -3
- mx_bluesky/hyperion/experiment_plans/robot_load_and_change_energy.py +30 -26
- mx_bluesky/hyperion/experiment_plans/robot_load_then_centre_plan.py +26 -7
- mx_bluesky/hyperion/experiment_plans/rotation_scan_plan.py +0 -7
- mx_bluesky/hyperion/experiment_plans/set_energy_plan.py +8 -7
- mx_bluesky/hyperion/external_interaction/callbacks/__init__.py +0 -4
- mx_bluesky/hyperion/external_interaction/callbacks/__main__.py +4 -0
- mx_bluesky/hyperion/external_interaction/callbacks/common/callback_util.py +5 -0
- mx_bluesky/hyperion/external_interaction/callbacks/robot_load/ispyb_callback.py +18 -10
- mx_bluesky/hyperion/external_interaction/callbacks/sample_handling/__init__.py +0 -0
- mx_bluesky/hyperion/external_interaction/callbacks/sample_handling/sample_handling_callback.py +84 -0
- mx_bluesky/hyperion/external_interaction/callbacks/xray_centre/ispyb_callback.py +10 -7
- mx_bluesky/hyperion/external_interaction/exceptions.py +0 -9
- mx_bluesky/hyperion/external_interaction/ispyb/exp_eye_store.py +65 -15
- mx_bluesky/hyperion/utils/validation.py +1 -1
- {mx_bluesky-1.4.1a0.dist-info → mx_bluesky-1.4.2.dist-info}/METADATA +2 -2
- {mx_bluesky-1.4.1a0.dist-info → mx_bluesky-1.4.2.dist-info}/RECORD +49 -46
- {mx_bluesky-1.4.1a0.dist-info → mx_bluesky-1.4.2.dist-info}/LICENSE +0 -0
- {mx_bluesky-1.4.1a0.dist-info → mx_bluesky-1.4.2.dist-info}/WHEEL +0 -0
- {mx_bluesky-1.4.1a0.dist-info → mx_bluesky-1.4.2.dist-info}/entry_points.txt +0 -0
- {mx_bluesky-1.4.1a0.dist-info → mx_bluesky-1.4.2.dist-info}/top_level.txt +0 -0
|
@@ -4,9 +4,7 @@ This version in python3 new Feb2021 by RLO
|
|
|
4
4
|
- March 21 added logging and Eiger functionality
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
|
-
import json
|
|
8
7
|
import re
|
|
9
|
-
import shutil
|
|
10
8
|
import sys
|
|
11
9
|
import time
|
|
12
10
|
from datetime import datetime
|
|
@@ -18,25 +16,28 @@ import bluesky.plan_stubs as bps
|
|
|
18
16
|
import bluesky.preprocessors as bpp
|
|
19
17
|
from bluesky.utils import MsgGenerator
|
|
20
18
|
from dodal.common import inject
|
|
19
|
+
from dodal.devices.attenuator import ReadOnlyAttenuator
|
|
21
20
|
from dodal.devices.hutch_shutter import HutchShutter, ShutterDemand
|
|
22
21
|
from dodal.devices.i24.aperture import Aperture
|
|
22
|
+
from dodal.devices.i24.beam_center import DetectorBeamCenter
|
|
23
23
|
from dodal.devices.i24.beamstop import Beamstop
|
|
24
24
|
from dodal.devices.i24.dcm import DCM
|
|
25
25
|
from dodal.devices.i24.dual_backlight import DualBacklight
|
|
26
|
+
from dodal.devices.i24.focus_mirrors import FocusMirrorsMode
|
|
26
27
|
from dodal.devices.i24.i24_detector_motion import DetectorMotion
|
|
27
28
|
from dodal.devices.zebra import DISCONNECT, SOFT_IN3, Zebra
|
|
28
29
|
|
|
29
|
-
from mx_bluesky.beamlines.i24.serial.dcid import
|
|
30
|
+
from mx_bluesky.beamlines.i24.serial.dcid import (
|
|
31
|
+
DCID,
|
|
32
|
+
get_pilatus_filename_template_from_device,
|
|
33
|
+
read_beam_info_from_hardware,
|
|
34
|
+
)
|
|
30
35
|
from mx_bluesky.beamlines.i24.serial.log import (
|
|
31
36
|
SSX_LOGGER,
|
|
32
37
|
_read_visit_directory_from_file,
|
|
33
38
|
log_on_entry,
|
|
34
39
|
)
|
|
35
|
-
from mx_bluesky.beamlines.i24.serial.parameters import ExtruderParameters
|
|
36
|
-
from mx_bluesky.beamlines.i24.serial.parameters.constants import (
|
|
37
|
-
PARAM_FILE_NAME,
|
|
38
|
-
PARAM_FILE_PATH,
|
|
39
|
-
)
|
|
40
|
+
from mx_bluesky.beamlines.i24.serial.parameters import ExtruderParameters
|
|
40
41
|
from mx_bluesky.beamlines.i24.serial.setup_beamline import Pilatus, caget, caput, pv
|
|
41
42
|
from mx_bluesky.beamlines.i24.serial.setup_beamline import setup_beamline as sup
|
|
42
43
|
from mx_bluesky.beamlines.i24.serial.setup_beamline.setup_detector import (
|
|
@@ -134,10 +135,20 @@ def enter_hutch(
|
|
|
134
135
|
|
|
135
136
|
|
|
136
137
|
@log_on_entry
|
|
137
|
-
def
|
|
138
|
-
"""
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
def read_parameters(detector_stage: DetectorMotion, attenuator: ReadOnlyAttenuator):
|
|
139
|
+
""" Read the parameters from user input and create the parameter model for an \
|
|
140
|
+
extruder collection.
|
|
141
|
+
|
|
142
|
+
Args:
|
|
143
|
+
detector_stage (DetectorMotion): The detector stage device.
|
|
144
|
+
attenuator (ReadOnlyAttenuator): A read-only attenuator device to get the \
|
|
145
|
+
transmission value.
|
|
146
|
+
|
|
147
|
+
Returns:
|
|
148
|
+
ExtruderParameters: Parameter model for extruder collections
|
|
149
|
+
|
|
150
|
+
"""
|
|
151
|
+
SSX_LOGGER.info("Creating parameter model from input.")
|
|
141
152
|
|
|
142
153
|
det_type = yield from get_detector_type(detector_stage)
|
|
143
154
|
SSX_LOGGER.warning(f"DETECTOR TYPE: {det_type}")
|
|
@@ -154,9 +165,11 @@ def write_parameter_file(detector_stage: DetectorMotion):
|
|
|
154
165
|
f"Requested filename ends in a number. Appended dash: {filename}"
|
|
155
166
|
)
|
|
156
167
|
|
|
168
|
+
transmission = yield from bps.rd(attenuator.actual_transmission)
|
|
169
|
+
|
|
157
170
|
pump_status = bool(int(caget(pv.ioc12_gp6)))
|
|
158
|
-
pump_exp = float(caget(pv.ioc12_gp9)) if pump_status else
|
|
159
|
-
pump_delay = float(caget(pv.ioc12_gp10)) if pump_status else
|
|
171
|
+
pump_exp = float(caget(pv.ioc12_gp9)) if pump_status else 0.0
|
|
172
|
+
pump_delay = float(caget(pv.ioc12_gp10)) if pump_status else 0.0
|
|
160
173
|
|
|
161
174
|
params_dict = {
|
|
162
175
|
"visit": _read_visit_directory_from_file().as_posix(), # noqa
|
|
@@ -165,17 +178,17 @@ def write_parameter_file(detector_stage: DetectorMotion):
|
|
|
165
178
|
"exposure_time_s": float(caget(pv.ioc12_gp5)),
|
|
166
179
|
"detector_distance_mm": float(caget(pv.ioc12_gp7)),
|
|
167
180
|
"detector_name": str(det_type),
|
|
181
|
+
"transmission": transmission,
|
|
168
182
|
"num_images": int(caget(pv.ioc12_gp4)),
|
|
169
183
|
"pump_status": pump_status,
|
|
170
184
|
"laser_dwell_s": pump_exp,
|
|
171
185
|
"laser_delay_s": pump_delay,
|
|
172
186
|
}
|
|
173
|
-
with open(param_file, "w") as f:
|
|
174
|
-
json.dump(params_dict, f, indent=4)
|
|
175
187
|
|
|
176
188
|
SSX_LOGGER.info("Parameters \n")
|
|
177
189
|
SSX_LOGGER.info(pformat(params_dict))
|
|
178
190
|
yield from bps.null()
|
|
191
|
+
return ExtruderParameters(**params_dict)
|
|
179
192
|
|
|
180
193
|
|
|
181
194
|
@log_on_entry
|
|
@@ -187,10 +200,16 @@ def main_extruder_plan(
|
|
|
187
200
|
detector_stage: DetectorMotion,
|
|
188
201
|
shutter: HutchShutter,
|
|
189
202
|
dcm: DCM,
|
|
203
|
+
mirrors: FocusMirrorsMode,
|
|
204
|
+
beam_center_device: DetectorBeamCenter,
|
|
190
205
|
parameters: ExtruderParameters,
|
|
191
206
|
dcid: DCID,
|
|
192
207
|
start_time: datetime,
|
|
193
208
|
) -> MsgGenerator:
|
|
209
|
+
yield from sup.set_detector_beam_center_plan(
|
|
210
|
+
beam_center_device, parameters.detector_name
|
|
211
|
+
)
|
|
212
|
+
|
|
194
213
|
# Setting up the beamline
|
|
195
214
|
SSX_LOGGER.info("Open hutch shutter")
|
|
196
215
|
yield from bps.abs_set(shutter, ShutterDemand.OPEN, wait=True)
|
|
@@ -316,16 +335,22 @@ def main_extruder_plan(
|
|
|
316
335
|
SSX_LOGGER.error(err)
|
|
317
336
|
raise UnknownDetectorType(err)
|
|
318
337
|
|
|
338
|
+
beam_settings = yield from read_beam_info_from_hardware(
|
|
339
|
+
dcm, mirrors, beam_center_device, parameters.detector_name
|
|
340
|
+
)
|
|
341
|
+
|
|
319
342
|
# Do DCID creation BEFORE arming the detector
|
|
343
|
+
if parameters.detector_name == "eiger":
|
|
344
|
+
filetemplate = f"{parameters.filename}.nxs"
|
|
345
|
+
else:
|
|
346
|
+
filetemplate = yield from get_pilatus_filename_template_from_device()
|
|
320
347
|
dcid.generate_dcid(
|
|
321
|
-
|
|
348
|
+
beam_settings=beam_settings,
|
|
322
349
|
image_dir=parameters.collection_directory.as_posix(),
|
|
323
|
-
|
|
350
|
+
file_template=filetemplate,
|
|
324
351
|
num_images=parameters.num_images,
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
pump_delay=parameters.laser_delay_s or 0,
|
|
328
|
-
pump_status=int(parameters.pump_status),
|
|
352
|
+
start_time=start_time,
|
|
353
|
+
pump_probe=parameters.pump_status,
|
|
329
354
|
)
|
|
330
355
|
|
|
331
356
|
# Collect
|
|
@@ -341,9 +366,16 @@ def main_extruder_plan(
|
|
|
341
366
|
dcid.notify_start()
|
|
342
367
|
|
|
343
368
|
if parameters.detector_name == "eiger":
|
|
344
|
-
wavelength = yield from bps.rd(dcm.wavelength_in_a)
|
|
345
369
|
SSX_LOGGER.debug("Call nexgen server for nexus writing.")
|
|
346
|
-
|
|
370
|
+
beam_x = yield from bps.rd(beam_center_device.beam_x)
|
|
371
|
+
beam_y = yield from bps.rd(beam_center_device.beam_y)
|
|
372
|
+
call_nexgen(
|
|
373
|
+
None,
|
|
374
|
+
parameters,
|
|
375
|
+
beam_settings.wavelength_in_a,
|
|
376
|
+
(beam_x, beam_y),
|
|
377
|
+
start_time,
|
|
378
|
+
)
|
|
347
379
|
|
|
348
380
|
timeout_time = time.time() + parameters.num_images * parameters.exposure_time_s + 10
|
|
349
381
|
|
|
@@ -436,11 +468,6 @@ def collection_complete_plan(
|
|
|
436
468
|
dcid.collection_complete(end_time, aborted=False)
|
|
437
469
|
SSX_LOGGER.info(f"End Time = {end_time.ctime()}")
|
|
438
470
|
|
|
439
|
-
# Copy parameter file
|
|
440
|
-
shutil.copy2(
|
|
441
|
-
PARAM_FILE_PATH / PARAM_FILE_NAME,
|
|
442
|
-
collection_directory / PARAM_FILE_NAME,
|
|
443
|
-
)
|
|
444
471
|
yield from bps.null()
|
|
445
472
|
|
|
446
473
|
|
|
@@ -452,19 +479,20 @@ def run_extruder_plan(
|
|
|
452
479
|
detector_stage: DetectorMotion = inject("detector_motion"),
|
|
453
480
|
shutter: HutchShutter = inject("shutter"),
|
|
454
481
|
dcm: DCM = inject("dcm"),
|
|
482
|
+
mirrors: FocusMirrorsMode = inject("focus_mirrors"),
|
|
483
|
+
attenuator: ReadOnlyAttenuator = inject("attenuator"),
|
|
455
484
|
) -> MsgGenerator:
|
|
456
485
|
start_time = datetime.now()
|
|
457
486
|
SSX_LOGGER.info(f"Collection start time: {start_time.ctime()}")
|
|
458
487
|
|
|
459
|
-
yield from
|
|
460
|
-
|
|
488
|
+
parameters: ExtruderParameters = yield from read_parameters(
|
|
489
|
+
detector_stage, attenuator
|
|
490
|
+
)
|
|
491
|
+
|
|
492
|
+
beam_center_device = sup.get_beam_center_device(parameters.detector_name)
|
|
461
493
|
|
|
462
494
|
# DCID - not generated yet
|
|
463
|
-
dcid = DCID(
|
|
464
|
-
emit_errors=False,
|
|
465
|
-
ssx_type=SSXType.EXTRUDER,
|
|
466
|
-
detector=parameters.detector_name,
|
|
467
|
-
)
|
|
495
|
+
dcid = DCID(emit_errors=False, expt_params=parameters)
|
|
468
496
|
|
|
469
497
|
yield from bpp.contingency_wrapper(
|
|
470
498
|
main_extruder_plan(
|
|
@@ -475,6 +503,8 @@ def run_extruder_plan(
|
|
|
475
503
|
detector_stage=detector_stage,
|
|
476
504
|
shutter=shutter,
|
|
477
505
|
dcm=dcm,
|
|
506
|
+
mirrors=mirrors,
|
|
507
|
+
beam_center_device=beam_center_device,
|
|
478
508
|
parameters=parameters,
|
|
479
509
|
dcid=dcid,
|
|
480
510
|
start_time=start_time,
|
|
@@ -323,7 +323,7 @@ font "helvetica-bold-r-24.0"
|
|
|
323
323
|
buttonLabel "Start"
|
|
324
324
|
numCmds 1
|
|
325
325
|
command {
|
|
326
|
-
0 "blueapi -c CONFIG_LOCATION controller run run_fixed_target_plan '\{\"zebra\":\"zebra\",\"pmac\":\"pmac\",\"aperture\":\"aperture\",\"backlight\":\"backlight\",\"beamstop\":\"beamstop\",\"detector_stage\":\"detector_motion\",\"shutter\":\"shutter\",\"dcm\":\"dcm\"\}'"
|
|
326
|
+
0 "blueapi -c CONFIG_LOCATION controller run run_fixed_target_plan '\{\"zebra\":\"zebra\",\"pmac\":\"pmac\",\"aperture\":\"aperture\",\"backlight\":\"backlight\",\"beamstop\":\"beamstop\",\"detector_stage\":\"detector_motion\",\"shutter\":\"shutter\",\"dcm\":\"dcm\",\"mirrors\":\"focus_mirrors\",\"attenuator\":\"attenuator\"\}'"
|
|
327
327
|
}
|
|
328
328
|
endObjectProperties
|
|
329
329
|
|
|
@@ -3,8 +3,8 @@ beginScreenProperties
|
|
|
3
3
|
major 4
|
|
4
4
|
minor 0
|
|
5
5
|
release 1
|
|
6
|
-
x
|
|
7
|
-
y
|
|
6
|
+
x 308
|
|
7
|
+
y 339
|
|
8
8
|
w 650
|
|
9
9
|
h 400
|
|
10
10
|
font "arial-medium-r-18.0"
|
|
@@ -179,50 +179,6 @@ font "arial-medium-r-18.0"
|
|
|
179
179
|
colorPv "ME14E-MO-IOC-01:GP67"
|
|
180
180
|
endObjectProperties
|
|
181
181
|
|
|
182
|
-
# (Shell Command)
|
|
183
|
-
object shellCmdClass
|
|
184
|
-
beginObjectProperties
|
|
185
|
-
major 4
|
|
186
|
-
minor 3
|
|
187
|
-
release 0
|
|
188
|
-
x 40
|
|
189
|
-
y 290
|
|
190
|
-
w 194
|
|
191
|
-
h 40
|
|
192
|
-
fgColor index 0
|
|
193
|
-
bgColor index 23
|
|
194
|
-
topShadowColor index 1
|
|
195
|
-
botShadowColor index 11
|
|
196
|
-
font "arial-medium-r-18.0"
|
|
197
|
-
buttonLabel "Save Screen Map"
|
|
198
|
-
numCmds 1
|
|
199
|
-
command {
|
|
200
|
-
0 "blueapi -c CONFIG_LOCATION controller run save_screen_map"
|
|
201
|
-
}
|
|
202
|
-
endObjectProperties
|
|
203
|
-
|
|
204
|
-
# (Shell Command)
|
|
205
|
-
object shellCmdClass
|
|
206
|
-
beginObjectProperties
|
|
207
|
-
major 4
|
|
208
|
-
minor 3
|
|
209
|
-
release 0
|
|
210
|
-
x 12
|
|
211
|
-
y 337
|
|
212
|
-
w 244
|
|
213
|
-
h 53
|
|
214
|
-
fgColor index 13
|
|
215
|
-
bgColor index 49
|
|
216
|
-
topShadowColor index 1
|
|
217
|
-
botShadowColor index 11
|
|
218
|
-
font "arial-medium-r-18.0"
|
|
219
|
-
buttonLabel "Upload Parameters"
|
|
220
|
-
numCmds 1
|
|
221
|
-
command {
|
|
222
|
-
0 "blueapi -c CONFIG_LOCATION controller run upload_parameters '\{\"pmac\":\"pmac\"\}'"
|
|
223
|
-
}
|
|
224
|
-
endObjectProperties
|
|
225
|
-
|
|
226
182
|
# (Message Button)
|
|
227
183
|
object activeMessageButtonClass
|
|
228
184
|
beginObjectProperties
|
|
@@ -2,45 +2,42 @@
|
|
|
2
2
|
Fixed target data collection
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
import shutil
|
|
6
5
|
from datetime import datetime
|
|
7
6
|
from pathlib import Path
|
|
8
7
|
from time import sleep
|
|
9
8
|
|
|
10
9
|
import bluesky.plan_stubs as bps
|
|
11
10
|
import bluesky.preprocessors as bpp
|
|
12
|
-
import numpy as np
|
|
13
11
|
from bluesky.utils import MsgGenerator
|
|
14
12
|
from dodal.common import inject
|
|
13
|
+
from dodal.devices.attenuator import ReadOnlyAttenuator
|
|
15
14
|
from dodal.devices.hutch_shutter import HutchShutter, ShutterDemand
|
|
16
15
|
from dodal.devices.i24.aperture import Aperture
|
|
16
|
+
from dodal.devices.i24.beam_center import DetectorBeamCenter
|
|
17
17
|
from dodal.devices.i24.beamstop import Beamstop
|
|
18
18
|
from dodal.devices.i24.dcm import DCM
|
|
19
19
|
from dodal.devices.i24.dual_backlight import DualBacklight
|
|
20
|
+
from dodal.devices.i24.focus_mirrors import FocusMirrorsMode
|
|
20
21
|
from dodal.devices.i24.i24_detector_motion import DetectorMotion
|
|
21
22
|
from dodal.devices.i24.pmac import PMAC
|
|
22
23
|
from dodal.devices.zebra import Zebra
|
|
23
24
|
|
|
24
|
-
from mx_bluesky.beamlines.i24.serial.dcid import
|
|
25
|
+
from mx_bluesky.beamlines.i24.serial.dcid import (
|
|
26
|
+
DCID,
|
|
27
|
+
get_pilatus_filename_template_from_device,
|
|
28
|
+
read_beam_info_from_hardware,
|
|
29
|
+
)
|
|
25
30
|
from mx_bluesky.beamlines.i24.serial.fixed_target.ft_utils import (
|
|
26
31
|
ChipType,
|
|
27
32
|
MappingType,
|
|
28
33
|
PumpProbeSetting,
|
|
29
34
|
)
|
|
30
35
|
from mx_bluesky.beamlines.i24.serial.fixed_target.i24ssx_Chip_Manager_py3v1 import (
|
|
31
|
-
|
|
36
|
+
read_parameters,
|
|
37
|
+
upload_chip_map_to_geobrick,
|
|
32
38
|
)
|
|
33
39
|
from mx_bluesky.beamlines.i24.serial.log import SSX_LOGGER, log_on_entry
|
|
34
|
-
from mx_bluesky.beamlines.i24.serial.parameters import
|
|
35
|
-
ChipDescription,
|
|
36
|
-
FixedTargetParameters,
|
|
37
|
-
SSXType,
|
|
38
|
-
)
|
|
39
|
-
from mx_bluesky.beamlines.i24.serial.parameters.constants import (
|
|
40
|
-
LITEMAP_PATH,
|
|
41
|
-
PARAM_FILE_NAME,
|
|
42
|
-
PARAM_FILE_PATH_FT,
|
|
43
|
-
)
|
|
40
|
+
from mx_bluesky.beamlines.i24.serial.parameters import FixedTargetParameters
|
|
44
41
|
from mx_bluesky.beamlines.i24.serial.setup_beamline import caget, cagetstring, caput, pv
|
|
45
42
|
from mx_bluesky.beamlines.i24.serial.setup_beamline import setup_beamline as sup
|
|
46
43
|
from mx_bluesky.beamlines.i24.serial.setup_beamline.setup_zebra_plans import (
|
|
@@ -101,19 +98,6 @@ def calculate_collection_timeout(parameters: FixedTargetParameters) -> float:
|
|
|
101
98
|
return timeout
|
|
102
99
|
|
|
103
100
|
|
|
104
|
-
def copy_files_to_data_location(
|
|
105
|
-
dest_dir: Path | str,
|
|
106
|
-
param_path: Path = PARAM_FILE_PATH_FT,
|
|
107
|
-
map_file: Path = LITEMAP_PATH,
|
|
108
|
-
map_type: MappingType = MappingType.Lite,
|
|
109
|
-
):
|
|
110
|
-
if not isinstance(dest_dir, Path):
|
|
111
|
-
dest_dir = Path(dest_dir)
|
|
112
|
-
shutil.copy2(param_path / "parameters.txt", dest_dir / "parameters.txt")
|
|
113
|
-
if map_type == MappingType.Lite:
|
|
114
|
-
shutil.copy2(map_file / "currentchip.map", dest_dir / "currentchip.map")
|
|
115
|
-
|
|
116
|
-
|
|
117
101
|
def write_userlog(
|
|
118
102
|
parameters: FixedTargetParameters,
|
|
119
103
|
filename: str,
|
|
@@ -302,50 +286,18 @@ def get_prog_num(
|
|
|
302
286
|
|
|
303
287
|
|
|
304
288
|
@log_on_entry
|
|
305
|
-
def
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
) -> int:
|
|
310
|
-
# Calculates how many images will be collected based on map type and N repeats
|
|
311
|
-
SSX_LOGGER.info("Calculate total number of images expected in data collection.")
|
|
312
|
-
|
|
313
|
-
if map_type == MappingType.NoMap:
|
|
314
|
-
if chip_params.chip_type == ChipType.Custom:
|
|
315
|
-
total_numb_imgs = chip_params.x_num_steps * chip_params.y_num_steps
|
|
316
|
-
SSX_LOGGER.info(
|
|
317
|
-
f"Map type: None \tCustom chip \tNumber of images {total_numb_imgs}"
|
|
318
|
-
)
|
|
319
|
-
else:
|
|
320
|
-
chip_format = chip_params.chip_format[:4]
|
|
321
|
-
total_numb_imgs = int(np.prod(chip_format))
|
|
322
|
-
SSX_LOGGER.info(
|
|
323
|
-
f"""Map type: None \tOxford chip {chip_params.chip_type} \t \
|
|
324
|
-
Number of images {total_numb_imgs}"""
|
|
325
|
-
)
|
|
326
|
-
|
|
327
|
-
elif map_type == MappingType.Lite:
|
|
328
|
-
SSX_LOGGER.info(f"Using Mapping Lite on chip type {chip_params.chip_type}")
|
|
329
|
-
chip_format = chip_params.chip_format[2:4]
|
|
330
|
-
block_count = 0
|
|
331
|
-
with open(LITEMAP_PATH / "currentchip.map") as f:
|
|
332
|
-
for line in f.readlines():
|
|
333
|
-
entry = line.split()
|
|
334
|
-
if entry[2] == "1":
|
|
335
|
-
block_count += 1
|
|
336
|
-
|
|
337
|
-
SSX_LOGGER.info(f"Block count={block_count}")
|
|
338
|
-
SSX_LOGGER.info(f"Chip format={chip_format}")
|
|
339
|
-
|
|
340
|
-
SSX_LOGGER.info(f"Number of exposures={n_exposures}")
|
|
341
|
-
|
|
342
|
-
total_numb_imgs = int(np.prod(chip_format) * block_count * n_exposures)
|
|
343
|
-
SSX_LOGGER.info(f"Calculated number of images: {total_numb_imgs}")
|
|
289
|
+
def set_datasize(
|
|
290
|
+
parameters: FixedTargetParameters,
|
|
291
|
+
):
|
|
292
|
+
SSX_LOGGER.info("Setting PV to calculated total number of images")
|
|
344
293
|
|
|
345
|
-
SSX_LOGGER.
|
|
346
|
-
|
|
294
|
+
SSX_LOGGER.debug(f"Map type: {parameters.map_type}")
|
|
295
|
+
SSX_LOGGER.debug(f"Chip type: {parameters.chip.chip_type}")
|
|
296
|
+
if parameters.map_type == MappingType.Lite:
|
|
297
|
+
SSX_LOGGER.debug(f"Num exposures: {parameters.num_exposures}")
|
|
298
|
+
SSX_LOGGER.debug(f"Block count: {len(parameters.chip_map)}")
|
|
347
299
|
|
|
348
|
-
|
|
300
|
+
caput(pv.me14e_gp10, parameters.total_num_images)
|
|
349
301
|
|
|
350
302
|
|
|
351
303
|
@log_on_entry
|
|
@@ -357,6 +309,9 @@ def start_i24(
|
|
|
357
309
|
detector_stage: DetectorMotion,
|
|
358
310
|
shutter: HutchShutter,
|
|
359
311
|
parameters: FixedTargetParameters,
|
|
312
|
+
dcm: DCM,
|
|
313
|
+
mirrors: FocusMirrorsMode,
|
|
314
|
+
beam_center_device: DetectorBeamCenter,
|
|
360
315
|
dcid: DCID,
|
|
361
316
|
):
|
|
362
317
|
"""Set up for I24 fixed target data collection, trigger the detector and open \
|
|
@@ -364,6 +319,9 @@ def start_i24(
|
|
|
364
319
|
Returns the start_time.
|
|
365
320
|
"""
|
|
366
321
|
|
|
322
|
+
beam_settings = yield from read_beam_info_from_hardware(
|
|
323
|
+
dcm, mirrors, beam_center_device, parameters.detector_name
|
|
324
|
+
)
|
|
367
325
|
SSX_LOGGER.info("Start I24 data collection.")
|
|
368
326
|
start_time = datetime.now()
|
|
369
327
|
SSX_LOGGER.info(f"Collection start time {start_time.ctime()}")
|
|
@@ -413,16 +371,15 @@ def start_i24(
|
|
|
413
371
|
|
|
414
372
|
# DCID process depends on detector PVs being set up already
|
|
415
373
|
SSX_LOGGER.debug("Start DCID process")
|
|
374
|
+
filetemplate = yield from get_pilatus_filename_template_from_device()
|
|
416
375
|
dcid.generate_dcid(
|
|
417
|
-
|
|
376
|
+
beam_settings=beam_settings,
|
|
418
377
|
image_dir=filepath,
|
|
419
|
-
|
|
378
|
+
file_template=filetemplate,
|
|
420
379
|
num_images=parameters.total_num_images,
|
|
421
|
-
exposure_time=parameters.exposure_time_s,
|
|
422
380
|
shots_per_position=parameters.num_exposures,
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
pump_status=parameters.pump_repeat.value,
|
|
381
|
+
start_time=start_time,
|
|
382
|
+
pump_probe=bool(parameters.pump_repeat),
|
|
426
383
|
)
|
|
427
384
|
|
|
428
385
|
SSX_LOGGER.debug("Arm Pilatus. Arm Zebra.")
|
|
@@ -476,16 +433,15 @@ def start_i24(
|
|
|
476
433
|
|
|
477
434
|
# DCID process depends on detector PVs being set up already
|
|
478
435
|
SSX_LOGGER.debug("Start DCID process")
|
|
436
|
+
filetemplate = f"{parameters.filename}.nxs"
|
|
479
437
|
dcid.generate_dcid(
|
|
480
|
-
|
|
438
|
+
beam_settings=beam_settings,
|
|
481
439
|
image_dir=filepath,
|
|
482
|
-
|
|
440
|
+
file_template=filetemplate,
|
|
483
441
|
num_images=parameters.total_num_images,
|
|
484
|
-
exposure_time=parameters.exposure_time_s,
|
|
485
442
|
shots_per_position=parameters.num_exposures,
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
pump_status=parameters.pump_repeat.value,
|
|
443
|
+
start_time=start_time,
|
|
444
|
+
pump_probe=bool(parameters.pump_repeat),
|
|
489
445
|
)
|
|
490
446
|
|
|
491
447
|
SSX_LOGGER.debug("Arm Zebra.")
|
|
@@ -584,11 +540,17 @@ def main_fixed_target_plan(
|
|
|
584
540
|
detector_stage: DetectorMotion,
|
|
585
541
|
shutter: HutchShutter,
|
|
586
542
|
dcm: DCM,
|
|
543
|
+
mirrors: FocusMirrorsMode,
|
|
544
|
+
beam_center_device: DetectorBeamCenter,
|
|
587
545
|
parameters: FixedTargetParameters,
|
|
588
546
|
dcid: DCID,
|
|
589
547
|
) -> MsgGenerator:
|
|
590
548
|
SSX_LOGGER.info("Running a chip collection on I24")
|
|
591
549
|
|
|
550
|
+
yield from sup.set_detector_beam_center_plan(
|
|
551
|
+
beam_center_device, parameters.detector_name
|
|
552
|
+
)
|
|
553
|
+
|
|
592
554
|
SSX_LOGGER.info("Getting Program Dictionary")
|
|
593
555
|
|
|
594
556
|
# If alignment type is Oxford inner it is still an Oxford type chip
|
|
@@ -606,12 +568,20 @@ def main_fixed_target_plan(
|
|
|
606
568
|
parameters.checker_pattern,
|
|
607
569
|
)
|
|
608
570
|
|
|
609
|
-
parameters
|
|
610
|
-
parameters.num_exposures, parameters.chip, parameters.map_type
|
|
611
|
-
)
|
|
571
|
+
set_datasize(parameters)
|
|
612
572
|
|
|
613
573
|
start_time = yield from start_i24(
|
|
614
|
-
zebra,
|
|
574
|
+
zebra,
|
|
575
|
+
aperture,
|
|
576
|
+
backlight,
|
|
577
|
+
beamstop,
|
|
578
|
+
detector_stage,
|
|
579
|
+
shutter,
|
|
580
|
+
parameters,
|
|
581
|
+
dcm,
|
|
582
|
+
mirrors,
|
|
583
|
+
beam_center_device,
|
|
584
|
+
dcid,
|
|
615
585
|
)
|
|
616
586
|
|
|
617
587
|
SSX_LOGGER.info("Moving to Start")
|
|
@@ -626,14 +596,13 @@ def main_fixed_target_plan(
|
|
|
626
596
|
SSX_LOGGER.debug("Notify DCID of the start of the collection.")
|
|
627
597
|
dcid.notify_start()
|
|
628
598
|
|
|
629
|
-
wavelength = yield from bps.rd(dcm.wavelength_in_a)
|
|
630
599
|
if parameters.detector_name == "eiger":
|
|
600
|
+
wavelength = yield from bps.rd(dcm.wavelength_in_a)
|
|
601
|
+
beam_x = yield from bps.rd(beam_center_device.beam_x)
|
|
602
|
+
beam_y = yield from bps.rd(beam_center_device.beam_y)
|
|
631
603
|
SSX_LOGGER.debug("Start nexus writing service.")
|
|
632
604
|
call_nexgen(
|
|
633
|
-
chip_prog_dict,
|
|
634
|
-
start_time,
|
|
635
|
-
parameters,
|
|
636
|
-
wavelength,
|
|
605
|
+
chip_prog_dict, parameters, wavelength, (beam_x, beam_y), start_time
|
|
637
606
|
)
|
|
638
607
|
|
|
639
608
|
yield from kickoff_and_complete_collection(pmac, parameters)
|
|
@@ -670,8 +639,7 @@ def collection_complete_plan(
|
|
|
670
639
|
SSX_LOGGER.debug(f"Collection end time {end_time}")
|
|
671
640
|
dcid.collection_complete(end_time, aborted=False)
|
|
672
641
|
|
|
673
|
-
#
|
|
674
|
-
copy_files_to_data_location(collection_directory, map_type=map_type)
|
|
642
|
+
# NOTE no files to copy anymore but shoud write userlog here
|
|
675
643
|
yield from bps.null()
|
|
676
644
|
|
|
677
645
|
|
|
@@ -721,37 +689,21 @@ def run_fixed_target_plan(
|
|
|
721
689
|
detector_stage: DetectorMotion = inject("detector_motion"),
|
|
722
690
|
shutter: HutchShutter = inject("shutter"),
|
|
723
691
|
dcm: DCM = inject("dcm"),
|
|
692
|
+
mirrors: FocusMirrorsMode = inject("focus_mirrors"),
|
|
693
|
+
attenuator: ReadOnlyAttenuator = inject("attenuator"),
|
|
724
694
|
) -> MsgGenerator:
|
|
725
|
-
#
|
|
726
|
-
yield from
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
visit = {parameters.visit}
|
|
735
|
-
sub_dir = {parameters.directory}
|
|
736
|
-
n_exposures = {parameters.num_exposures}
|
|
737
|
-
chip_type = {str(parameters.chip.chip_type)}
|
|
738
|
-
map_type = {str(parameters.map_type)}
|
|
739
|
-
dcdetdist = {parameters.detector_distance_mm}
|
|
740
|
-
exptime = {parameters.exposure_time_s}
|
|
741
|
-
det_type = {parameters.detector_name}
|
|
742
|
-
pump_repeat = {str(parameters.pump_repeat)}
|
|
743
|
-
pumpexptime = {parameters.laser_dwell_s}
|
|
744
|
-
pumpdelay = {parameters.laser_delay_s}
|
|
745
|
-
prepumpexptime = {parameters.pre_pump_exposure_s}
|
|
746
|
-
"""
|
|
747
|
-
SSX_LOGGER.info(log_msg)
|
|
695
|
+
# Read the parameters
|
|
696
|
+
parameters: FixedTargetParameters = yield from read_parameters(
|
|
697
|
+
detector_stage, attenuator
|
|
698
|
+
)
|
|
699
|
+
|
|
700
|
+
if parameters.chip_map:
|
|
701
|
+
upload_chip_map_to_geobrick(pmac, parameters.chip_map)
|
|
702
|
+
|
|
703
|
+
beam_center_device = sup.get_beam_center_device(parameters.detector_name)
|
|
748
704
|
|
|
749
705
|
# DCID instance - do not create yet
|
|
750
|
-
dcid = DCID(
|
|
751
|
-
emit_errors=False,
|
|
752
|
-
ssx_type=SSXType.FIXED,
|
|
753
|
-
detector=parameters.detector_name,
|
|
754
|
-
)
|
|
706
|
+
dcid = DCID(emit_errors=False, expt_params=parameters)
|
|
755
707
|
|
|
756
708
|
yield from bpp.contingency_wrapper(
|
|
757
709
|
main_fixed_target_plan(
|
|
@@ -763,6 +715,8 @@ def run_fixed_target_plan(
|
|
|
763
715
|
detector_stage,
|
|
764
716
|
shutter,
|
|
765
717
|
dcm,
|
|
718
|
+
mirrors,
|
|
719
|
+
beam_center_device,
|
|
766
720
|
parameters,
|
|
767
721
|
dcid,
|
|
768
722
|
),
|