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.
Files changed (81) hide show
  1. mx_bluesky/__init__.py +8 -3
  2. mx_bluesky/__main__.py +12 -7
  3. mx_bluesky/_version.py +2 -2
  4. mx_bluesky/beamlines/i04/callbacks/murko_callback.py +14 -4
  5. mx_bluesky/beamlines/i04/thawing_plan.py +48 -10
  6. mx_bluesky/beamlines/i24/serial/__init__.py +3 -0
  7. mx_bluesky/beamlines/i24/serial/extruder/i24ssx_Extruder_Collect_py3v2.py +68 -90
  8. mx_bluesky/beamlines/i24/serial/fixed_target/FT-gui-edm/DiamondChipI24-py3v1.edl +1 -1
  9. mx_bluesky/beamlines/i24/serial/fixed_target/i24ssx_Chip_Collect_py3v1.py +104 -126
  10. mx_bluesky/beamlines/i24/serial/fixed_target/i24ssx_Chip_Manager_py3v1.py +139 -162
  11. mx_bluesky/beamlines/i24/serial/fixed_target/i24ssx_Chip_Mapping_py3v1.py +25 -36
  12. mx_bluesky/beamlines/i24/serial/fixed_target/i24ssx_Chip_StartUp_py3v1.py +24 -34
  13. mx_bluesky/beamlines/i24/serial/fixed_target/i24ssx_moveonclick.py +14 -11
  14. mx_bluesky/beamlines/i24/serial/log.py +58 -49
  15. mx_bluesky/beamlines/i24/serial/parameters/fixed_target/cs/cs_maker.json +3 -3
  16. mx_bluesky/beamlines/i24/serial/run_extruder.sh +30 -5
  17. mx_bluesky/beamlines/i24/serial/run_fixed_target.sh +31 -7
  18. mx_bluesky/beamlines/i24/serial/run_serial.py +24 -8
  19. mx_bluesky/beamlines/i24/serial/setup_beamline/ca.py +0 -2
  20. mx_bluesky/beamlines/i24/serial/setup_beamline/setup_beamline.py +1 -1
  21. mx_bluesky/beamlines/i24/serial/setup_beamline/setup_detector.py +8 -18
  22. mx_bluesky/beamlines/i24/serial/setup_beamline/setup_zebra_plans.py +2 -2
  23. mx_bluesky/common/__init__.py +0 -0
  24. mx_bluesky/common/device_setup_plans/read_hardware_for_setup.py +14 -0
  25. mx_bluesky/common/parameters/components.py +221 -0
  26. mx_bluesky/common/parameters/constants.py +133 -0
  27. mx_bluesky/common/plans/__init__.py +1 -0
  28. mx_bluesky/common/plans/do_fgs.py +121 -0
  29. mx_bluesky/common/utils/log.py +116 -0
  30. mx_bluesky/{hyperion → common/utils}/tracing.py +2 -2
  31. mx_bluesky/hyperion/__main__.py +11 -9
  32. mx_bluesky/hyperion/device_setup_plans/dcm_pitch_roll_mirror_adjuster.py +31 -26
  33. mx_bluesky/hyperion/device_setup_plans/read_hardware_for_setup.py +6 -12
  34. mx_bluesky/hyperion/device_setup_plans/setup_oav.py +6 -12
  35. mx_bluesky/hyperion/device_setup_plans/setup_panda.py +1 -2
  36. mx_bluesky/hyperion/device_setup_plans/setup_zebra.py +48 -17
  37. mx_bluesky/hyperion/device_setup_plans/smargon.py +6 -6
  38. mx_bluesky/hyperion/device_setup_plans/utils.py +13 -2
  39. mx_bluesky/hyperion/device_setup_plans/xbpm_feedback.py +4 -4
  40. mx_bluesky/hyperion/experiment_plans/experiment_registry.py +9 -0
  41. mx_bluesky/hyperion/experiment_plans/flyscan_xray_centre_plan.py +59 -108
  42. mx_bluesky/hyperion/experiment_plans/grid_detect_then_xray_centre_plan.py +7 -5
  43. mx_bluesky/hyperion/experiment_plans/load_centre_collect_full_plan.py +46 -0
  44. mx_bluesky/hyperion/experiment_plans/oav_grid_detection_plan.py +19 -18
  45. mx_bluesky/hyperion/experiment_plans/oav_snapshot_plan.py +8 -5
  46. mx_bluesky/hyperion/experiment_plans/pin_centre_then_xray_centre_plan.py +4 -4
  47. mx_bluesky/hyperion/experiment_plans/pin_tip_centring_plan.py +17 -17
  48. mx_bluesky/hyperion/experiment_plans/robot_load_and_change_energy.py +241 -0
  49. mx_bluesky/hyperion/experiment_plans/robot_load_then_centre_plan.py +24 -181
  50. mx_bluesky/hyperion/experiment_plans/rotation_scan_plan.py +6 -4
  51. mx_bluesky/hyperion/experiment_plans/set_energy_plan.py +3 -11
  52. mx_bluesky/hyperion/external_interaction/callbacks/__main__.py +1 -2
  53. mx_bluesky/hyperion/external_interaction/callbacks/common/callback_util.py +18 -0
  54. mx_bluesky/hyperion/external_interaction/callbacks/common/ispyb_mapping.py +1 -9
  55. mx_bluesky/hyperion/external_interaction/callbacks/grid_detection_callback.py +18 -13
  56. mx_bluesky/hyperion/external_interaction/callbacks/ispyb_callback_base.py +32 -15
  57. mx_bluesky/hyperion/external_interaction/callbacks/log_uid_tag_callback.py +1 -1
  58. mx_bluesky/hyperion/external_interaction/callbacks/robot_load/ispyb_callback.py +3 -5
  59. mx_bluesky/hyperion/external_interaction/callbacks/rotation/ispyb_callback.py +4 -3
  60. mx_bluesky/hyperion/external_interaction/callbacks/xray_centre/ispyb_callback.py +23 -18
  61. mx_bluesky/hyperion/external_interaction/config_server.py +22 -10
  62. mx_bluesky/hyperion/external_interaction/ispyb/ispyb_store.py +1 -1
  63. mx_bluesky/hyperion/external_interaction/ispyb/ispyb_utils.py +0 -2
  64. mx_bluesky/hyperion/external_interaction/nexus/nexus_utils.py +2 -2
  65. mx_bluesky/hyperion/external_interaction/nexus/write_nexus.py +1 -1
  66. mx_bluesky/hyperion/log.py +0 -84
  67. mx_bluesky/hyperion/parameters/components.py +1 -242
  68. mx_bluesky/hyperion/parameters/constants.py +22 -118
  69. mx_bluesky/hyperion/parameters/gridscan.py +20 -11
  70. mx_bluesky/hyperion/parameters/load_centre_collect.py +50 -0
  71. mx_bluesky/hyperion/parameters/robot_load.py +16 -0
  72. mx_bluesky/hyperion/parameters/rotation.py +9 -5
  73. mx_bluesky/hyperion/utils/utils.py +17 -0
  74. mx_bluesky/hyperion/utils/validation.py +5 -6
  75. {mx_bluesky-1.1.0.dist-info → mx_bluesky-1.4.0.dist-info}/METADATA +4 -2
  76. {mx_bluesky-1.1.0.dist-info → mx_bluesky-1.4.0.dist-info}/RECORD +80 -70
  77. {mx_bluesky-1.1.0.dist-info → mx_bluesky-1.4.0.dist-info}/WHEEL +1 -1
  78. mx_bluesky/example.py +0 -19
  79. {mx_bluesky-1.1.0.dist-info → mx_bluesky-1.4.0.dist-info}/LICENSE +0 -0
  80. {mx_bluesky-1.1.0.dist-info → mx_bluesky-1.4.0.dist-info}/entry_points.txt +0 -0
  81. {mx_bluesky-1.1.0.dist-info → mx_bluesky-1.4.0.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
@@ -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
- ABORTED = False
60
-
61
- logger = logging.getLogger("I24ssx.fixed_target")
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 = 30
80
+ buffer = PMAC_MOVE_TIME * parameters.total_num_images + 2
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 [
@@ -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
- logger.debug(f"Write a user log in {userlog_path}")
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
- @log.log_on_entry
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
- logger.info(
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
- logger.info(f"pump_in_probe set to {pump_in_probe}")
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
- @log.log_on_entry
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,26 @@ def load_motion_program_data(
234
226
  pump_repeat: int,
235
227
  checker_pattern: bool,
236
228
  ):
237
- logger.info("Loading motion program data for chip.")
238
- logger.info(f"Pump_repeat is {PumpProbeSetting(pump_repeat)}")
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
- logger.info(f"Map type is None, setting program prefix to {prefix}")
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
237
  elif map_type == MappingType.Full:
246
238
  prefix = 13
247
239
  else:
248
- logger.warning(f"Unknown Map Type, map_type = {map_type}")
240
+ SSX_LOGGER.warning(f"Unknown Map Type, map_type = {map_type}")
249
241
  return
250
242
  elif pump_repeat in [pp.value for pp in PumpProbeSetting if pp != 0]:
251
243
  # Pump setting chosen
252
244
  prefix = 14
253
- logger.info(f"Setting program prefix to {prefix}")
245
+ SSX_LOGGER.info(f"Setting program prefix to {prefix}")
254
246
  yield from bps.abs_set(pmac.pmac_string, "P1439=0", wait=True)
255
247
  if checker_pattern:
256
- logger.info("Checker pattern setting enabled.")
248
+ SSX_LOGGER.info("Checker pattern setting enabled.")
257
249
  yield from bps.abs_set(pmac.pmac_string, "P1439=1", wait=True)
258
250
  if pump_repeat == PumpProbeSetting.Medium1:
259
251
  # Medium1 has time delays (Fast shutter opening time in ms)
@@ -261,23 +253,23 @@ def load_motion_program_data(
261
253
  else:
262
254
  yield from bps.abs_set(pmac.pmac_string, "P1441=0", wait=True)
263
255
  else:
264
- logger.warning(f"Unknown Pump repeat, pump_repeat = {pump_repeat}")
256
+ SSX_LOGGER.warning(f"Unknown Pump repeat, pump_repeat = {pump_repeat}")
265
257
  return
266
258
 
267
- logger.info("Set PMAC_STRING pv.")
259
+ SSX_LOGGER.info("Set PMAC_STRING pv.")
268
260
  for key in sorted(motion_program_dict.keys()):
269
261
  v = motion_program_dict[key]
270
262
  pvar_base = prefix * 100
271
263
  pvar = pvar_base + v[0]
272
264
  value = str(v[1])
273
265
  s = f"P{pvar}={value}"
274
- logger.info(f"{key} \t {s}")
266
+ SSX_LOGGER.info(f"{key} \t {s}")
275
267
  yield from bps.abs_set(pmac.pmac_string, s, wait=True)
276
268
  yield from bps.sleep(0.02)
277
269
  yield from bps.sleep(0.2)
278
270
 
279
271
 
280
- @log.log_on_entry
272
+ @log_on_entry
281
273
  def get_prog_num(
282
274
  chip_type: ChipType, map_type: MappingType, pump_repeat: PumpProbeSetting
283
275
  ) -> int:
@@ -290,60 +282,60 @@ def get_prog_num(
290
282
  - Oxford chips with full mapping should return 13. Currently disabled, will \
291
283
  raise an error.
292
284
  """
293
- logger.info("Get Program Number for the motion program.")
294
- logger.info(f"Pump_repeat: {str(pump_repeat)} \t Chip Type: {str(chip_type)}")
285
+ SSX_LOGGER.info("Get Program Number for the motion program.")
286
+ SSX_LOGGER.info(f"Pump_repeat: {str(pump_repeat)} \t Chip Type: {str(chip_type)}")
295
287
  if pump_repeat != PumpProbeSetting.NoPP:
296
- logger.info("Assuming Map type = Mapping Lite.")
297
- logger.info("Program number: 14")
288
+ SSX_LOGGER.info("Assuming Map type = Mapping Lite.")
289
+ SSX_LOGGER.info("Program number: 14")
298
290
  return 14
299
291
 
300
292
  if chip_type not in [ChipType.Oxford, ChipType.OxfordInner]:
301
- logger.info("Program number: 11")
293
+ SSX_LOGGER.info("Program number: 11")
302
294
  return 11
303
295
 
304
296
  if map_type == MappingType.NoMap:
305
- logger.info(f"Map type: {str(map_type)}")
306
- logger.info("Program number: 11")
297
+ SSX_LOGGER.info(f"Map type: {str(map_type)}")
298
+ SSX_LOGGER.info("Program number: 11")
307
299
  return 11
308
300
  if map_type == MappingType.Lite:
309
- logger.info(f"Map type: {str(map_type)}")
310
- logger.info("Program number: 12")
301
+ SSX_LOGGER.info(f"Map type: {str(map_type)}")
302
+ SSX_LOGGER.info("Program number: 12")
311
303
  return 12
312
304
  if map_type == MappingType.Full:
313
305
  # 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")
306
+ SSX_LOGGER.info(f"Map type: {str(map_type)}")
307
+ SSX_LOGGER.info("Program number: 13")
316
308
  # TODO once reinstated return 13
317
309
  msg = "Full mapping is broken and currently disabled."
318
- logger.error(msg)
310
+ SSX_LOGGER.error(msg)
319
311
  raise ValueError(msg)
320
312
 
321
313
 
322
- @log.log_on_entry
314
+ @log_on_entry
323
315
  def datasetsizei24(
324
316
  n_exposures: int,
325
317
  chip_params: ChipDescription,
326
318
  map_type: MappingType,
327
319
  ) -> int:
328
320
  # Calculates how many images will be collected based on map type and N repeats
329
- logger.info("Calculate total number of images expected in data collection.")
321
+ SSX_LOGGER.info("Calculate total number of images expected in data collection.")
330
322
 
331
323
  if map_type == MappingType.NoMap:
332
324
  if chip_params.chip_type == ChipType.Custom:
333
325
  total_numb_imgs = chip_params.x_num_steps * chip_params.y_num_steps
334
- logger.info(
326
+ SSX_LOGGER.info(
335
327
  f"Map type: None \tCustom chip \tNumber of images {total_numb_imgs}"
336
328
  )
337
329
  else:
338
330
  chip_format = chip_params.chip_format[:4]
339
331
  total_numb_imgs = int(np.prod(chip_format))
340
- logger.info(
332
+ SSX_LOGGER.info(
341
333
  f"""Map type: None \tOxford chip {chip_params.chip_type} \t \
342
334
  Number of images {total_numb_imgs}"""
343
335
  )
344
336
 
345
337
  elif map_type == MappingType.Lite:
346
- logger.info(f"Using Mapping Lite on chip type {chip_params.chip_type}")
338
+ SSX_LOGGER.info(f"Using Mapping Lite on chip type {chip_params.chip_type}")
347
339
  chip_format = chip_params.chip_format[2:4]
348
340
  block_count = 0
349
341
  with open(LITEMAP_PATH / "currentchip.map") as f:
@@ -352,29 +344,29 @@ def datasetsizei24(
352
344
  if entry[2] == "1":
353
345
  block_count += 1
354
346
 
355
- logger.info(f"Block count={block_count}")
356
- logger.info(f"Chip format={chip_format}")
347
+ SSX_LOGGER.info(f"Block count={block_count}")
348
+ SSX_LOGGER.info(f"Chip format={chip_format}")
357
349
 
358
- logger.info(f"Number of exposures={n_exposures}")
350
+ SSX_LOGGER.info(f"Number of exposures={n_exposures}")
359
351
 
360
352
  total_numb_imgs = int(np.prod(chip_format) * block_count * n_exposures)
361
- logger.info(f"Calculated number of images: {total_numb_imgs}")
353
+ SSX_LOGGER.info(f"Calculated number of images: {total_numb_imgs}")
362
354
 
363
355
  elif map_type == MappingType.Full:
364
- logger.error("Not Set Up For Full Mapping")
356
+ SSX_LOGGER.error("Not Set Up For Full Mapping")
365
357
  raise ValueError("The beamline is currently not set for Full Mapping.")
366
358
 
367
359
  else:
368
- logger.warning(f"Unknown Map Type, map_type = {str(map_type)}")
360
+ SSX_LOGGER.warning(f"Unknown Map Type, map_type = {str(map_type)}")
369
361
  raise ValueError("Unknown map type")
370
362
 
371
- logger.info("Set PV to calculated number of images.")
363
+ SSX_LOGGER.info("Set PV to calculated number of images.")
372
364
  caput(pv.me14e_gp10, int(total_numb_imgs))
373
365
 
374
366
  return int(total_numb_imgs)
375
367
 
376
368
 
377
- @log.log_on_entry
369
+ @log_on_entry
378
370
  def start_i24(
379
371
  zebra: Zebra,
380
372
  aperture: Aperture,
@@ -390,11 +382,11 @@ def start_i24(
390
382
  Returns the start_time.
391
383
  """
392
384
 
393
- logger.info("Start I24 data collection.")
385
+ SSX_LOGGER.info("Start I24 data collection.")
394
386
  start_time = datetime.now()
395
- logger.info(f"Collection start time {start_time.ctime()}")
387
+ SSX_LOGGER.info(f"Collection start time {start_time.ctime()}")
396
388
 
397
- logger.debug("Set up beamline")
389
+ SSX_LOGGER.debug("Set up beamline")
398
390
  yield from sup.setup_beamline_for_collection_plan(
399
391
  aperture, backlight, beamstop, wait=True
400
392
  )
@@ -403,27 +395,27 @@ def start_i24(
403
395
  detector_stage, parameters.detector_distance_mm
404
396
  )
405
397
 
406
- logger.debug("Set up beamline DONE")
398
+ SSX_LOGGER.debug("Set up beamline DONE")
407
399
 
408
400
  filepath = parameters.collection_directory.as_posix()
409
401
  filename = parameters.filename
410
402
 
411
- logger.debug("Acquire Region")
403
+ SSX_LOGGER.debug("Acquire Region")
412
404
 
413
405
  num_gates = parameters.total_num_images // parameters.num_exposures
414
406
 
415
- logger.info(f"Total number of images: {parameters.total_num_images}")
416
- logger.info(f"Number of exposures: {parameters.num_exposures}")
417
- logger.info(f"Number of gates (=Total images/N exposures): {num_gates:.4f}")
407
+ SSX_LOGGER.info(f"Total number of images: {parameters.total_num_images}")
408
+ SSX_LOGGER.info(f"Number of exposures: {parameters.num_exposures}")
409
+ SSX_LOGGER.info(f"Number of gates (=Total images/N exposures): {num_gates:.4f}")
418
410
 
419
411
  if parameters.detector_name == "pilatus":
420
- logger.info("Using Pilatus detector")
421
- logger.info(f"Fastchip Pilatus setup: filepath {filepath}")
422
- logger.info(f"Fastchip Pilatus setup: filename {filename}")
423
- logger.info(
412
+ SSX_LOGGER.info("Using Pilatus detector")
413
+ SSX_LOGGER.info(f"Fastchip Pilatus setup: filepath {filepath}")
414
+ SSX_LOGGER.info(f"Fastchip Pilatus setup: filename {filename}")
415
+ SSX_LOGGER.info(
424
416
  f"Fastchip Pilatus setup: number of images {parameters.total_num_images}"
425
417
  )
426
- logger.info(
418
+ SSX_LOGGER.info(
427
419
  f"Fastchip Pilatus setup: exposure time {parameters.exposure_time_s}"
428
420
  )
429
421
 
@@ -438,7 +430,7 @@ def start_i24(
438
430
  )
439
431
 
440
432
  # DCID process depends on detector PVs being set up already
441
- logger.debug("Start DCID process")
433
+ SSX_LOGGER.debug("Start DCID process")
442
434
  dcid.generate_dcid(
443
435
  visit=parameters.visit.name,
444
436
  image_dir=filepath,
@@ -451,7 +443,7 @@ def start_i24(
451
443
  pump_status=parameters.pump_repeat.value,
452
444
  )
453
445
 
454
- logger.debug("Arm Pilatus. Arm Zebra.")
446
+ SSX_LOGGER.debug("Arm Pilatus. Arm Zebra.")
455
447
  shutter_time_offset = SHUTTER_OPEN_TIME if PumpProbeSetting.Medium1 else 0.0
456
448
  yield from setup_zebra_for_fastchip_plan(
457
449
  zebra,
@@ -472,33 +464,17 @@ def start_i24(
472
464
  sleep(1.5)
473
465
 
474
466
  elif parameters.detector_name == "eiger":
475
- logger.info("Using Eiger detector")
467
+ SSX_LOGGER.info("Using Eiger detector")
476
468
 
477
- logger.warning(
478
- """TEMPORARY HACK!
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")
469
+ SSX_LOGGER.debug(f"Creating the directory for the collection in {filepath}.")
470
+ Path(filepath).mkdir(parents=True)
495
471
 
496
- logger.info(f"Triggered Eiger setup: filepath {filepath}")
497
- logger.info(f"Triggered Eiger setup: filename {filename}")
498
- logger.info(
472
+ SSX_LOGGER.info(f"Triggered Eiger setup: filepath {filepath}")
473
+ SSX_LOGGER.info(f"Triggered Eiger setup: filename {filename}")
474
+ SSX_LOGGER.info(
499
475
  f"Triggered Eiger setup: number of images {parameters.total_num_images}"
500
476
  )
501
- logger.info(
477
+ SSX_LOGGER.info(
502
478
  f"Triggered Eiger setup: exposure time {parameters.exposure_time_s}"
503
479
  )
504
480
 
@@ -513,7 +489,7 @@ def start_i24(
513
489
  )
514
490
 
515
491
  # DCID process depends on detector PVs being set up already
516
- logger.debug("Start DCID process")
492
+ SSX_LOGGER.debug("Start DCID process")
517
493
  dcid.generate_dcid(
518
494
  visit=parameters.visit.name,
519
495
  image_dir=filepath,
@@ -526,7 +502,7 @@ def start_i24(
526
502
  pump_status=parameters.pump_repeat.value,
527
503
  )
528
504
 
529
- logger.debug("Arm Zebra.")
505
+ SSX_LOGGER.debug("Arm Zebra.")
530
506
  shutter_time_offset = SHUTTER_OPEN_TIME if PumpProbeSetting.Medium1 else 0.0
531
507
  yield from setup_zebra_for_fastchip_plan(
532
508
  zebra,
@@ -547,7 +523,7 @@ def start_i24(
547
523
 
548
524
  else:
549
525
  msg = f"Unknown Detector Type, det_type = {parameters.detector_name}"
550
- logger.error(msg)
526
+ SSX_LOGGER.error(msg)
551
527
  raise ValueError(msg)
552
528
 
553
529
  # Open the hutch shutter
@@ -556,7 +532,7 @@ def start_i24(
556
532
  return start_time
557
533
 
558
534
 
559
- @log.log_on_entry
535
+ @log_on_entry
560
536
  def finish_i24(
561
537
  zebra: Zebra,
562
538
  pmac: PMAC,
@@ -564,20 +540,22 @@ def finish_i24(
564
540
  dcm: DCM,
565
541
  parameters: FixedTargetParameters,
566
542
  ):
567
- logger.info(f"Finish I24 data collection with {parameters.detector_name} detector.")
543
+ SSX_LOGGER.info(
544
+ f"Finish I24 data collection with {parameters.detector_name} detector."
545
+ )
568
546
 
569
547
  complete_filename: str
570
548
  transmission = float(caget(pv.pilat_filtertrasm))
571
549
  wavelength = yield from bps.rd(dcm.wavelength_in_a)
572
550
 
573
551
  if parameters.detector_name == "pilatus":
574
- logger.debug("Finish I24 Pilatus")
552
+ SSX_LOGGER.debug("Finish I24 Pilatus")
575
553
  complete_filename = f"{parameters.filename}_{caget(pv.pilat_filenum)}"
576
554
  yield from reset_zebra_when_collection_done_plan(zebra)
577
555
  sup.pilatus("return-to-normal", None)
578
556
  sleep(0.2)
579
557
  elif parameters.detector_name == "eiger":
580
- logger.debug("Finish I24 Eiger")
558
+ SSX_LOGGER.debug("Finish I24 Eiger")
581
559
  yield from reset_zebra_when_collection_done_plan(zebra)
582
560
  sup.eiger("return-to-normal", None)
583
561
  complete_filename = cagetstring(pv.eiger_ODfilenameRBV) # type: ignore
@@ -585,9 +563,9 @@ def finish_i24(
585
563
  raise ValueError(f"{parameters.detector_name=} unrecognised")
586
564
 
587
565
  # Detector independent moves
588
- logger.info("Move chip back to home position by setting PMAC_STRING pv.")
566
+ SSX_LOGGER.info("Move chip back to home position by setting PMAC_STRING pv.")
589
567
  yield from bps.trigger(pmac.to_xyz_zero)
590
- logger.info("Closing shutter")
568
+ SSX_LOGGER.info("Closing shutter")
591
569
  yield from bps.abs_set(shutter, ShutterDemand.CLOSE, wait=True)
592
570
 
593
571
  # Write a record of what was collected to the processing directory
@@ -599,14 +577,14 @@ def run_aborted_plan(pmac: PMAC, dcid: DCID):
599
577
  either by pressing the Abort button or because of a timeout, and to reset the \
600
578
  P variable.
601
579
  """
602
- logger.warning("Data Collection Aborted")
580
+ SSX_LOGGER.warning("Data Collection Aborted")
603
581
  yield from bps.trigger(pmac.abort_program, wait=True)
604
582
 
605
583
  end_time = datetime.now()
606
584
  dcid.collection_complete(end_time, aborted=True)
607
585
 
608
586
 
609
- @log.log_on_entry
587
+ @log_on_entry
610
588
  def main_fixed_target_plan(
611
589
  zebra: Zebra,
612
590
  pmac: PMAC,
@@ -619,17 +597,17 @@ def main_fixed_target_plan(
619
597
  parameters: FixedTargetParameters,
620
598
  dcid: DCID,
621
599
  ) -> MsgGenerator:
622
- logger.info("Running a chip collection on I24")
600
+ SSX_LOGGER.info("Running a chip collection on I24")
623
601
 
624
- logger.info("Getting Program Dictionary")
602
+ SSX_LOGGER.info("Getting Program Dictionary")
625
603
 
626
604
  # If alignment type is Oxford inner it is still an Oxford type chip
627
605
  if parameters.chip.chip_type == ChipType.OxfordInner:
628
- logger.debug("Change chip type Oxford Inner to Oxford.")
606
+ SSX_LOGGER.debug("Change chip type Oxford Inner to Oxford.")
629
607
  parameters.chip.chip_type = ChipType.Oxford
630
608
 
631
609
  chip_prog_dict = get_chip_prog_values(parameters)
632
- logger.info("Loading Motion Program Data")
610
+ SSX_LOGGER.info("Loading Motion Program Data")
633
611
  yield from load_motion_program_data(
634
612
  pmac,
635
613
  chip_prog_dict,
@@ -646,21 +624,21 @@ def main_fixed_target_plan(
646
624
  zebra, aperture, backlight, beamstop, detector_stage, shutter, parameters, dcid
647
625
  )
648
626
 
649
- logger.info("Moving to Start")
627
+ SSX_LOGGER.info("Moving to Start")
650
628
  yield from bps.trigger(pmac.to_xyz_zero)
651
629
  sleep(2.0)
652
630
 
653
631
  # Now ready for data collection. Open fast shutter (zebra gate)
654
- logger.info("Opening fast shutter.")
632
+ SSX_LOGGER.info("Opening fast shutter.")
655
633
  yield from open_fast_shutter(zebra)
656
634
 
657
635
  # Kick off the StartOfCollect script
658
- logger.debug("Notify DCID of the start of the collection.")
636
+ SSX_LOGGER.debug("Notify DCID of the start of the collection.")
659
637
  dcid.notify_start()
660
638
 
661
639
  wavelength = yield from bps.rd(dcm.wavelength_in_a)
662
640
  if parameters.detector_name == "eiger":
663
- logger.debug("Start nexus writing service.")
641
+ SSX_LOGGER.debug("Start nexus writing service.")
664
642
  call_nexgen(
665
643
  chip_prog_dict,
666
644
  start_time,
@@ -678,7 +656,7 @@ def kickoff_and_complete_collection(pmac: PMAC, parameters: FixedTargetParameter
678
656
  yield from bps.abs_set(pmac.program_number, prog_num, group="setup_pmac")
679
657
  # Calculate approx collection time
680
658
  total_collection_time = calculate_collection_timeout(parameters)
681
- logger.info(f"Estimated collection time: {total_collection_time}s.")
659
+ SSX_LOGGER.info(f"Estimated collection time: {total_collection_time}s.")
682
660
  yield from bps.abs_set(
683
661
  pmac.collection_time, total_collection_time, group="setup_pmac"
684
662
  )
@@ -686,20 +664,20 @@ def kickoff_and_complete_collection(pmac: PMAC, parameters: FixedTargetParameter
686
664
 
687
665
  @bpp.run_decorator(md={"subplan_name": "run_ft_collection"})
688
666
  def run_collection():
689
- logger.info(f"Kick off PMAC with program number {prog_num}.")
667
+ SSX_LOGGER.info(f"Kick off PMAC with program number {prog_num}.")
690
668
  yield from bps.kickoff(pmac.run_program, wait=True)
691
669
  yield from bps.complete(pmac.run_program, wait=True)
692
- logger.info("Collection completed without errors.")
670
+ SSX_LOGGER.info("Collection completed without errors.")
693
671
 
694
672
  yield from run_collection()
695
673
 
696
674
 
697
- @log.log_on_entry
675
+ @log_on_entry
698
676
  def collection_complete_plan(
699
677
  dcid: DCID, collection_directory: Path, map_type: MappingType
700
678
  ) -> MsgGenerator:
701
679
  end_time = datetime.now()
702
- logger.debug(f"Collection end time {end_time}")
680
+ SSX_LOGGER.debug(f"Collection end time {end_time}")
703
681
  dcid.collection_complete(end_time, aborted=False)
704
682
 
705
683
  # Copy parameter file and eventual chip map to collection directory
@@ -707,7 +685,7 @@ def collection_complete_plan(
707
685
  yield from bps.null()
708
686
 
709
687
 
710
- @log.log_on_entry
688
+ @log_on_entry
711
689
  def tidy_up_after_collection_plan(
712
690
  zebra: Zebra,
713
691
  pmac: PMAC,
@@ -719,27 +697,29 @@ def tidy_up_after_collection_plan(
719
697
  """A plan to be run to tidy things up at the end af a fixed target collection, \
720
698
  both successful or aborted.
721
699
  """
722
- logger.info("Closing fast shutter")
700
+ SSX_LOGGER.info("Closing fast shutter")
723
701
  yield from close_fast_shutter(zebra)
724
702
  sleep(2.0)
725
703
 
726
704
  # This probably should go in main then
727
705
  if parameters.detector_name == "pilatus":
728
- logger.debug("Pilatus Acquire STOP")
706
+ SSX_LOGGER.debug("Pilatus Acquire STOP")
729
707
  caput(pv.pilat_acquire, 0)
730
708
  elif parameters.detector_name == "eiger":
731
- logger.debug("Eiger Acquire STOP")
709
+ SSX_LOGGER.debug("Eiger Acquire STOP")
732
710
  caput(pv.eiger_acquire, 0)
733
711
  caput(pv.eiger_ODcapture, "Done")
734
712
  sleep(0.5)
735
713
 
736
714
  yield from finish_i24(zebra, pmac, shutter, dcm, parameters)
737
715
 
738
- logger.debug("Notify DCID of end of collection.")
716
+ SSX_LOGGER.debug("Notify DCID of end of collection.")
739
717
  dcid.notify_end()
740
718
 
741
- logger.debug("Quick summary of settings")
742
- logger.debug(f"Chip name = {parameters.filename} sub_dir = {parameters.directory}")
719
+ SSX_LOGGER.debug("Quick summary of settings")
720
+ SSX_LOGGER.debug(
721
+ f"Chip name = {parameters.filename} sub_dir = {parameters.directory}"
722
+ )
743
723
 
744
724
 
745
725
  def run_fixed_target_plan(
@@ -752,12 +732,10 @@ def run_fixed_target_plan(
752
732
  shutter: HutchShutter = inject("shutter"),
753
733
  dcm: DCM = inject("dcm"),
754
734
  ) -> MsgGenerator:
755
- setup_logging()
756
-
757
735
  # in the first instance, write params here
758
736
  yield from write_parameter_file(detector_stage)
759
737
 
760
- logger.info("Getting parameters from file.")
738
+ SSX_LOGGER.info("Getting parameters from file.")
761
739
  parameters = FixedTargetParameters.from_file(PARAM_FILE_PATH_FT / PARAM_FILE_NAME)
762
740
 
763
741
  log_msg = f"""
@@ -776,7 +754,7 @@ def run_fixed_target_plan(
776
754
  pumpdelay = {parameters.laser_delay_s}
777
755
  prepumpexptime = {parameters.pre_pump_exposure_s}
778
756
  """
779
- logger.info(log_msg)
757
+ SSX_LOGGER.info(log_msg)
780
758
 
781
759
  # DCID instance - do not create yet
782
760
  dcid = DCID(