mx-bluesky 1.5.9__py3-none-any.whl → 1.5.11__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 (87) hide show
  1. mx_bluesky/_version.py +2 -2
  2. mx_bluesky/beamlines/aithre_lasershaping/goniometer_controls.py +2 -2
  3. mx_bluesky/beamlines/i02_1/parameters/gridscan.py +1 -1
  4. mx_bluesky/beamlines/i04/experiment_plans/i04_grid_detect_then_xray_centre_plan.py +9 -9
  5. mx_bluesky/beamlines/i04/thawing_plan.py +9 -9
  6. mx_bluesky/beamlines/i24/jungfrau_commissioning/experiment_plans/do_darks.py +123 -0
  7. mx_bluesky/beamlines/i24/jungfrau_commissioning/plan_stubs/__init__.py +1 -0
  8. mx_bluesky/beamlines/i24/jungfrau_commissioning/{do_external_acquisition.py → plan_stubs/do_external_acquisition.py} +8 -7
  9. mx_bluesky/beamlines/i24/jungfrau_commissioning/{do_internal_acquisition.py → plan_stubs/do_internal_acquisition.py} +4 -3
  10. mx_bluesky/beamlines/i24/jungfrau_commissioning/{plan_utils.py → plan_stubs/plan_utils.py} +21 -28
  11. mx_bluesky/beamlines/i24/serial/__init__.py +7 -5
  12. mx_bluesky/beamlines/i24/serial/dcid.py +3 -3
  13. mx_bluesky/beamlines/i24/serial/extruder/{i24ssx_Extruder_Collect_py3v2.py → i24ssx_extruder_collect_py3v2.py} +65 -35
  14. mx_bluesky/beamlines/i24/serial/fixed_target/{i24ssx_Chip_Collect_py3v1.py → i24ssx_chip_collect_py3v1.py} +5 -5
  15. mx_bluesky/beamlines/i24/serial/fixed_target/{i24ssx_Chip_Manager_py3v1.py → i24ssx_chip_manager_py3v1.py} +46 -46
  16. mx_bluesky/beamlines/i24/serial/fixed_target/{i24ssx_Chip_StartUp_py3v1.py → i24ssx_chip_startup_py3v1.py} +3 -3
  17. mx_bluesky/beamlines/i24/serial/fixed_target/i24ssx_moveonclick.py +33 -33
  18. mx_bluesky/beamlines/i24/serial/log.py +11 -11
  19. mx_bluesky/beamlines/i24/serial/parameters/fixed_target/cs/cs_maker.json +3 -3
  20. mx_bluesky/beamlines/i24/serial/setup_beamline/ca.py +0 -12
  21. mx_bluesky/beamlines/i24/serial/setup_beamline/pv.py +13 -32
  22. mx_bluesky/beamlines/i24/serial/setup_beamline/pv_abstract.py +5 -5
  23. mx_bluesky/beamlines/i24/serial/setup_beamline/setup_beamline.py +22 -249
  24. mx_bluesky/beamlines/i24/serial/setup_beamline/setup_detector.py +2 -2
  25. mx_bluesky/beamlines/i24/serial/setup_beamline/setup_zebra_plans.py +4 -4
  26. mx_bluesky/beamlines/i24/serial/web_gui_plans/general_plans.py +102 -15
  27. mx_bluesky/beamlines/i24/serial/write_nexus.py +4 -4
  28. mx_bluesky/common/device_setup_plans/robot_load_unload.py +2 -2
  29. mx_bluesky/common/device_setup_plans/setup_oav.py +1 -1
  30. mx_bluesky/common/device_setup_plans/xbpm_feedback.py +4 -4
  31. mx_bluesky/common/experiment_plans/common_flyscan_xray_centre_plan.py +9 -9
  32. mx_bluesky/common/experiment_plans/common_grid_detect_then_xray_centre_plan.py +2 -2
  33. mx_bluesky/common/experiment_plans/inner_plans/do_fgs.py +2 -2
  34. mx_bluesky/common/experiment_plans/inner_plans/read_hardware.py +5 -5
  35. mx_bluesky/common/experiment_plans/inner_plans/udc_default_state.py +22 -1
  36. mx_bluesky/common/experiment_plans/inner_plans/write_sample_status.py +2 -2
  37. mx_bluesky/common/experiment_plans/oav_grid_detection_plan.py +2 -2
  38. mx_bluesky/common/experiment_plans/oav_snapshot_plan.py +1 -1
  39. mx_bluesky/common/external_interaction/callbacks/common/ispyb_callback_base.py +3 -3
  40. mx_bluesky/common/external_interaction/callbacks/common/plan_reactive_callback.py +1 -1
  41. mx_bluesky/common/external_interaction/callbacks/common/zocalo_callback.py +2 -2
  42. mx_bluesky/common/external_interaction/callbacks/sample_handling/sample_handling_callback.py +3 -3
  43. mx_bluesky/common/external_interaction/callbacks/xray_centre/ispyb_callback.py +7 -5
  44. mx_bluesky/common/external_interaction/callbacks/xray_centre/nexus_callback.py +2 -2
  45. mx_bluesky/common/external_interaction/config_server.py +2 -2
  46. mx_bluesky/common/external_interaction/ispyb/exp_eye_store.py +4 -2
  47. mx_bluesky/common/external_interaction/ispyb/ispyb_store.py +0 -1
  48. mx_bluesky/common/external_interaction/nexus/nexus_utils.py +2 -2
  49. mx_bluesky/common/external_interaction/nexus/write_nexus.py +3 -3
  50. mx_bluesky/common/parameters/constants.py +1 -1
  51. mx_bluesky/common/parameters/device_composites.py +2 -2
  52. mx_bluesky/common/parameters/gridscan.py +2 -2
  53. mx_bluesky/common/utils/exceptions.py +9 -7
  54. mx_bluesky/common/utils/log.py +4 -4
  55. mx_bluesky/common/utils/tracing.py +5 -5
  56. mx_bluesky/common/utils/utils.py +8 -8
  57. mx_bluesky/hyperion/__main__.py +5 -5
  58. mx_bluesky/hyperion/baton_handler.py +15 -8
  59. mx_bluesky/hyperion/device_setup_plans/smargon.py +5 -5
  60. mx_bluesky/hyperion/device_setup_plans/utils.py +1 -1
  61. mx_bluesky/hyperion/experiment_plans/experiment_registry.py +1 -1
  62. mx_bluesky/hyperion/experiment_plans/hyperion_flyscan_xray_centre_plan.py +19 -18
  63. mx_bluesky/hyperion/experiment_plans/load_centre_collect_full_plan.py +54 -40
  64. mx_bluesky/hyperion/experiment_plans/optimise_attenuation_plan.py +9 -9
  65. mx_bluesky/hyperion/experiment_plans/pin_centre_then_xray_centre_plan.py +2 -2
  66. mx_bluesky/hyperion/experiment_plans/pin_tip_centring_plan.py +5 -5
  67. mx_bluesky/hyperion/experiment_plans/rotation_scan_plan.py +3 -3
  68. mx_bluesky/hyperion/external_interaction/agamemnon.py +2 -2
  69. mx_bluesky/hyperion/external_interaction/callbacks/__main__.py +2 -2
  70. mx_bluesky/hyperion/external_interaction/callbacks/rotation/ispyb_callback.py +1 -1
  71. mx_bluesky/hyperion/external_interaction/callbacks/rotation/nexus_callback.py +2 -2
  72. mx_bluesky/hyperion/external_interaction/config_server.py +2 -2
  73. mx_bluesky/hyperion/parameters/constants.py +2 -2
  74. mx_bluesky/hyperion/parameters/device_composites.py +2 -2
  75. mx_bluesky/hyperion/parameters/gridscan.py +4 -4
  76. mx_bluesky/hyperion/parameters/rotation.py +4 -6
  77. mx_bluesky/hyperion/plan_runner.py +6 -6
  78. mx_bluesky/hyperion/runner.py +10 -8
  79. mx_bluesky/hyperion/utils/context.py +6 -1
  80. mx_bluesky/jupyter_example.ipynb +3 -3
  81. {mx_bluesky-1.5.9.dist-info → mx_bluesky-1.5.11.dist-info}/METADATA +7 -6
  82. {mx_bluesky-1.5.9.dist-info → mx_bluesky-1.5.11.dist-info}/RECORD +87 -85
  83. /mx_bluesky/beamlines/i24/jungfrau_commissioning/{__init__.py → experiment_plans/__init__.py} +0 -0
  84. {mx_bluesky-1.5.9.dist-info → mx_bluesky-1.5.11.dist-info}/WHEEL +0 -0
  85. {mx_bluesky-1.5.9.dist-info → mx_bluesky-1.5.11.dist-info}/entry_points.txt +0 -0
  86. {mx_bluesky-1.5.9.dist-info → mx_bluesky-1.5.11.dist-info}/licenses/LICENSE +0 -0
  87. {mx_bluesky-1.5.9.dist-info → mx_bluesky-1.5.11.dist-info}/top_level.txt +0 -0
@@ -46,7 +46,7 @@ from mx_bluesky.beamlines.i24.serial.setup_beamline import (
46
46
  )
47
47
  from mx_bluesky.beamlines.i24.serial.setup_beamline import setup_beamline as sup
48
48
  from mx_bluesky.beamlines.i24.serial.setup_beamline.setup_detector import (
49
- UnknownDetectorType,
49
+ UnknownDetectorTypeError,
50
50
  get_detector_type,
51
51
  )
52
52
  from mx_bluesky.beamlines.i24.serial.setup_beamline.setup_zebra_plans import (
@@ -113,17 +113,17 @@ def laser_check(
113
113
  """
114
114
  SSX_LOGGER.debug(f"Laser check: {mode}")
115
115
 
116
- LASER_TTL = zebra.mapping.outputs.TTL_PILATUS # Update with dodal changes
116
+ laser_ttl = zebra.mapping.outputs.TTL_PILATUS # Update with dodal changes
117
117
 
118
118
  if mode == "laseron":
119
119
  yield from bps.abs_set(
120
- zebra.output.out_pvs[LASER_TTL], zebra.mapping.sources.SOFT_IN3
120
+ zebra.output.out_pvs[laser_ttl], zebra.mapping.sources.SOFT_IN3
121
121
  )
122
122
  yield from set_shutter_mode(zebra, "auto")
123
123
 
124
124
  if mode == "laseroff":
125
125
  yield from bps.abs_set(
126
- zebra.output.out_pvs[LASER_TTL], zebra.mapping.sources.DISCONNECT
126
+ zebra.output.out_pvs[laser_ttl], zebra.mapping.sources.DISCONNECT
127
127
  )
128
128
  yield from set_shutter_mode(zebra, "manual")
129
129
 
@@ -230,7 +230,7 @@ def main_extruder_plan(
230
230
 
231
231
  SSX_LOGGER.debug(f"Creating the directory for the collection in {filepath}.")
232
232
 
233
- caput(pv.eiger_seqID, int(caget(pv.eiger_seqID)) + 1)
233
+ caput(pv.eiger_seq_id, int(caget(pv.eiger_seq_id)) + 1)
234
234
  SSX_LOGGER.info(f"Eiger quickshot setup: filepath {filepath}")
235
235
  SSX_LOGGER.info(f"Eiger quickshot setup: filepath {parameters.filename}")
236
236
  SSX_LOGGER.info(
@@ -282,7 +282,7 @@ def main_extruder_plan(
282
282
  else:
283
283
  err = f"Unknown Detector Type, det_type = {parameters.detector_name}"
284
284
  SSX_LOGGER.error(err)
285
- raise UnknownDetectorType(err)
285
+ raise UnknownDetectorTypeError(err)
286
286
 
287
287
  beam_settings = yield from read_beam_info_from_hardware(
288
288
  dcm, mirrors, beam_center_device, parameters.detector_name
@@ -291,7 +291,7 @@ def main_extruder_plan(
291
291
  # Do DCID creation BEFORE arming the detector
292
292
  filetemplate = f"{parameters.filename}.nxs"
293
293
  if parameters.detector_name == "eiger":
294
- complete_filename = cagetstring(pv.eiger_ODfilenameRBV)
294
+ complete_filename = cagetstring(pv.eiger_od_filename_rbv)
295
295
  filetemplate = f"{complete_filename}.nxs"
296
296
  dcid.generate_dcid(
297
297
  beam_settings=beam_settings,
@@ -387,7 +387,7 @@ def tidy_up_at_collection_end_plan(
387
387
  # Clean Up
388
388
  if parameters.detector_name == "eiger":
389
389
  yield from sup.eiger("return-to-normal", None, dcm)
390
- SSX_LOGGER.debug(f"{parameters.filename}_{caget(pv.eiger_seqID)}")
390
+ SSX_LOGGER.debug(f"{parameters.filename}_{caget(pv.eiger_seq_id)}")
391
391
  SSX_LOGGER.debug("End of Run")
392
392
  SSX_LOGGER.info("Close hutch shutter")
393
393
  yield from bps.abs_set(shutter, ShutterDemand.CLOSE, wait=True)
@@ -402,7 +402,7 @@ def collection_complete_plan(
402
402
  if detector_name == "eiger":
403
403
  SSX_LOGGER.info("Eiger Acquire STOP")
404
404
  caput(pv.eiger_acquire, 0)
405
- caput(pv.eiger_ODcapture, "Done")
405
+ caput(pv.eiger_od_capture, "Done")
406
406
 
407
407
  yield from bps.sleep(0.5)
408
408
 
@@ -413,32 +413,20 @@ def collection_complete_plan(
413
413
  yield from bps.null()
414
414
 
415
415
 
416
- def run_extruder_plan(
417
- zebra: Zebra = inject("zebra"),
418
- aperture: Aperture = inject("aperture"),
419
- backlight: DualBacklight = inject("backlight"),
420
- beamstop: Beamstop = inject("beamstop"),
421
- detector_stage: YZStage = inject("detector_motion"),
422
- shutter: HutchShutter = inject("shutter"),
423
- dcm: DCM = inject("dcm"),
424
- mirrors: FocusMirrorsMode = inject("focus_mirrors"),
425
- attenuator: ReadOnlyAttenuator = inject("attenuator"),
426
- beam_center_eiger: DetectorBeamCenter = inject("eiger_bc"),
416
+ def run_plan_in_wrapper(
417
+ zebra: Zebra,
418
+ aperture: Aperture,
419
+ backlight: DualBacklight,
420
+ beamstop: Beamstop,
421
+ detector_stage: YZStage,
422
+ shutter: HutchShutter,
423
+ dcm: DCM,
424
+ mirrors: FocusMirrorsMode,
425
+ beam_center_eiger: DetectorBeamCenter,
426
+ parameters: ExtruderParameters,
427
+ dcid: DCID,
428
+ start_time: datetime,
427
429
  ) -> MsgGenerator:
428
- start_time = datetime.now()
429
- SSX_LOGGER.info(f"Collection start time: {start_time.ctime()}")
430
-
431
- parameters: ExtruderParameters = yield from read_parameters(
432
- detector_stage, attenuator
433
- )
434
- # Create collection directory
435
- parameters.collection_directory.mkdir(parents=True, exist_ok=True)
436
-
437
- beam_center_device = beam_center_eiger
438
-
439
- # DCID - not generated yet
440
- dcid = DCID(emit_errors=False, expt_params=parameters)
441
-
442
430
  yield from bpp.contingency_wrapper(
443
431
  main_extruder_plan(
444
432
  zebra=zebra,
@@ -449,7 +437,7 @@ def run_extruder_plan(
449
437
  shutter=shutter,
450
438
  dcm=dcm,
451
439
  mirrors=mirrors,
452
- beam_center_device=beam_center_device,
440
+ beam_center_device=beam_center_eiger,
453
441
  parameters=parameters,
454
442
  dcid=dcid,
455
443
  start_time=start_time,
@@ -469,3 +457,45 @@ def run_extruder_plan(
469
457
  ),
470
458
  auto_raise=False,
471
459
  )
460
+
461
+
462
+ def run_extruder_plan(
463
+ zebra: Zebra = inject("zebra"),
464
+ aperture: Aperture = inject("aperture"),
465
+ backlight: DualBacklight = inject("backlight"),
466
+ beamstop: Beamstop = inject("beamstop"),
467
+ detector_stage: YZStage = inject("detector_motion"),
468
+ shutter: HutchShutter = inject("shutter"),
469
+ dcm: DCM = inject("dcm"),
470
+ mirrors: FocusMirrorsMode = inject("focus_mirrors"),
471
+ attenuator: ReadOnlyAttenuator = inject("attenuator"),
472
+ beam_center_eiger: DetectorBeamCenter = inject("eiger_bc"),
473
+ ) -> MsgGenerator:
474
+ start_time = datetime.now()
475
+ SSX_LOGGER.info(f"Collection start time: {start_time.ctime()}")
476
+
477
+ parameters: ExtruderParameters = yield from read_parameters(
478
+ detector_stage, attenuator
479
+ )
480
+ # Create collection directory
481
+ parameters.collection_directory.mkdir(parents=True, exist_ok=True)
482
+
483
+ beam_center_device = beam_center_eiger
484
+
485
+ # DCID - not generated yet
486
+ dcid = DCID(emit_errors=False, expt_params=parameters)
487
+
488
+ yield from run_plan_in_wrapper(
489
+ zebra,
490
+ aperture,
491
+ backlight,
492
+ beamstop,
493
+ detector_stage,
494
+ shutter,
495
+ dcm,
496
+ mirrors,
497
+ beam_center_device,
498
+ parameters,
499
+ dcid,
500
+ start_time,
501
+ )
@@ -31,7 +31,7 @@ from mx_bluesky.beamlines.i24.serial.fixed_target.ft_utils import (
31
31
  MappingType,
32
32
  PumpProbeSetting,
33
33
  )
34
- from mx_bluesky.beamlines.i24.serial.fixed_target.i24ssx_Chip_Manager_py3v1 import (
34
+ from mx_bluesky.beamlines.i24.serial.fixed_target.i24ssx_chip_manager_py3v1 import (
35
35
  read_parameters,
36
36
  upload_chip_map_to_geobrick,
37
37
  )
@@ -335,7 +335,7 @@ def start_i24(
335
335
 
336
336
  # DCID process depends on detector PVs being set up already
337
337
  SSX_LOGGER.debug("Start DCID process")
338
- complete_filename = cagetstring(pv.eiger_ODfilenameRBV)
338
+ complete_filename = cagetstring(pv.eiger_od_filename_rbv)
339
339
  filetemplate = f"{complete_filename}.nxs"
340
340
  dcid.generate_dcid(
341
341
  beam_settings=beam_settings,
@@ -401,7 +401,7 @@ def finish_i24(
401
401
  SSX_LOGGER.debug("Finish I24 Eiger")
402
402
  yield from reset_zebra_when_collection_done_plan(zebra)
403
403
  yield from sup.eiger("return-to-normal", None, dcm)
404
- complete_filename = cagetstring(pv.eiger_ODfilenameRBV) # type: ignore
404
+ complete_filename = cagetstring(pv.eiger_od_filename_rbv) # type: ignore
405
405
  else:
406
406
  raise ValueError(f"{parameters.detector_name} unrecognised")
407
407
 
@@ -538,7 +538,7 @@ def collection_complete_plan(
538
538
  SSX_LOGGER.debug(f"Collection end time {end_time}")
539
539
  dcid.collection_complete(end_time, aborted=False)
540
540
 
541
- # NOTE no files to copy anymore but shoud write userlog here
541
+ # NOTE no files to copy anymore but should write userlog here
542
542
  yield from bps.null()
543
543
 
544
544
 
@@ -562,7 +562,7 @@ def tidy_up_after_collection_plan(
562
562
  if parameters.detector_name == "eiger":
563
563
  SSX_LOGGER.debug("Eiger Acquire STOP")
564
564
  caput(pv.eiger_acquire, 0)
565
- caput(pv.eiger_ODcapture, "Done")
565
+ caput(pv.eiger_od_capture, "Done")
566
566
  yield from bps.sleep(0.5)
567
567
 
568
568
  yield from finish_i24(zebra, pmac, shutter, dcm, parameters)
@@ -459,7 +459,7 @@ def load_lite_map() -> MsgGenerator:
459
459
  SSX_LOGGER.debug("Run load stock map with 'clear' setting.")
460
460
  yield from load_stock_map("clear")
461
461
  # fmt: off
462
- # Oxford_block_dict is wrong (columns and rows need to flip) added in script below to generate it automatically however kept this for backwards compatiability/reference
462
+ # Oxford_block_dict is wrong (columns and rows need to flip) added in script below to generate it automatically however kept this for backwards compatibility/reference
463
463
  oxford_block_dict = { # noqa: F841
464
464
  'A1': '01', 'A2': '02', 'A3': '03', 'A4': '04', 'A5': '05', 'A6': '06', 'A7': '07', 'A8': '08',
465
465
  'B1': '16', 'B2': '15', 'B3': '14', 'B4': '13', 'B5': '12', 'B6': '11', 'B7': '10', 'B8': '09',
@@ -523,7 +523,7 @@ def load_lite_map() -> MsgGenerator:
523
523
  def moveto(place: str = "origin", pmac: PMAC = inject("pmac")) -> MsgGenerator:
524
524
  SSX_LOGGER.info(f"Move to: {place}")
525
525
  if place == Fiducials.zero:
526
- SSX_LOGGER.info("Chip aspecific move.")
526
+ SSX_LOGGER.info("Chip moving to zero")
527
527
  yield from bps.trigger(pmac.to_xyz_zero)
528
528
  return
529
529
 
@@ -705,7 +705,7 @@ def cs_maker(pmac: PMAC = inject("pmac")) -> MsgGenerator:
705
705
 
706
706
  Skew:
707
707
  Skew is the difference between the Sz1 and Sz2 after rotation is taken out.
708
- This should be measured in situ prior to expriment, ie. measure by hand using
708
+ This should be measured in situ prior to experiment, ie. measure by hand using
709
709
  opposite and adjacent RBV after calibration of scale factors.
710
710
  """
711
711
  chip_type = int(caget(CHIPTYPE_PV))
@@ -738,10 +738,10 @@ def cs_maker(pmac: PMAC = inject("pmac")) -> MsgGenerator:
738
738
  float(cs_info["scalez"]),
739
739
  )
740
740
  skew = float(cs_info["skew"])
741
- Sx_dir, Sy_dir, Sz_dir = (
742
- int(cs_info["Sx_dir"]),
743
- int(cs_info["Sy_dir"]),
744
- int(cs_info["Sz_dir"]),
741
+ sx_dir, sy_dir, sz_dir = (
742
+ int(cs_info["sx_dir"]),
743
+ int(cs_info["sy_dir"]),
744
+ int(cs_info["sz_dir"]),
745
745
  )
746
746
  except KeyError:
747
747
  SSX_LOGGER.error("Wrong or missing key in the cs json file.")
@@ -751,60 +751,60 @@ def cs_maker(pmac: PMAC = inject("pmac")) -> MsgGenerator:
751
751
  if val not in [1, -1]:
752
752
  raise ValueError("Wrong value for direction. Please set to either -1 or 1.")
753
753
 
754
- check_dir(Sx_dir)
755
- check_dir(Sy_dir)
756
- check_dir(Sz_dir)
754
+ check_dir(sx_dir)
755
+ check_dir(sy_dir)
756
+ check_dir(sz_dir)
757
757
 
758
758
  # Rotation Around Z
759
- # If stages upsidedown (I24) change sign of Sz
760
- Sz1 = -1 * f1_y / fiducial_dict[chip_type][0]
761
- Sz2 = f2_x / fiducial_dict[chip_type][1]
762
- Sz = Sz_dir * ((Sz1 + Sz2) / 2)
763
- Cz = np.sqrt(1 - Sz**2)
764
- SSX_LOGGER.info(f"Sz1 , {Sz1:1.4f}, {np.degrees(np.arcsin(Sz1)):1.4f}")
765
- SSX_LOGGER.info(f"Sz2 , {Sz2:1.4f}, {np.degrees(np.arcsin(Sz2)):1.4f}")
766
- SSX_LOGGER.info(f"Sz , {Sz:1.4f}, {np.degrees(np.arcsin(Sz)):1.4f}")
767
- SSX_LOGGER.info(f"Cz , {Cz:1.4f}, {np.degrees(np.arcsin(Cz)):1.4f}")
759
+ # If stages upsidedown (I24) change sign of sz
760
+ sz1 = -1 * f1_y / fiducial_dict[chip_type][0]
761
+ sz2 = f2_x / fiducial_dict[chip_type][1]
762
+ sz = sz_dir * ((sz1 + sz2) / 2)
763
+ cz = np.sqrt(1 - sz**2)
764
+ SSX_LOGGER.info(f"sz1 , {sz1:1.4f}, {np.degrees(np.arcsin(sz1)):1.4f}")
765
+ SSX_LOGGER.info(f"sz2 , {sz2:1.4f}, {np.degrees(np.arcsin(sz2)):1.4f}")
766
+ SSX_LOGGER.info(f"sz , {sz:1.4f}, {np.degrees(np.arcsin(sz)):1.4f}")
767
+ SSX_LOGGER.info(f"cz , {cz:1.4f}, {np.degrees(np.arcsin(cz)):1.4f}")
768
768
  # Rotation Around Y
769
- Sy = Sy_dir * f1_z / fiducial_dict[chip_type][0]
770
- Cy = np.sqrt(1 - Sy**2)
771
- SSX_LOGGER.info(f"Sy , {Sy:1.4f}, {np.degrees(np.arcsin(Sy)):1.4f}")
772
- SSX_LOGGER.info(f"Cy , {Cy:1.4f}, {np.degrees(np.arcsin(Cy)):1.4f}")
769
+ sy = sy_dir * f1_z / fiducial_dict[chip_type][0]
770
+ cy = np.sqrt(1 - sy**2)
771
+ SSX_LOGGER.info(f"sy , {sy:1.4f}, {np.degrees(np.arcsin(sy)):1.4f}")
772
+ SSX_LOGGER.info(f"cy , {cy:1.4f}, {np.degrees(np.arcsin(cy)):1.4f}")
773
773
  # Rotation Around X
774
- # If stages upsidedown (I24) change sign of Sx
775
- Sx = Sx_dir * f2_z / fiducial_dict[chip_type][1]
776
- Cx = np.sqrt(1 - Sx**2)
777
- SSX_LOGGER.info(f"Sx , {Sx:1.4f}, {np.degrees(np.arcsin(Sx)):1.4f}")
778
- SSX_LOGGER.info(f"Cx , {Cx:1.4f}, {np.degrees(np.arcsin(Cx)):1.4f}")
774
+ # If stages upsidedown (I24) change sign of sx
775
+ sx = sx_dir * f2_z / fiducial_dict[chip_type][1]
776
+ cx = np.sqrt(1 - sx**2)
777
+ SSX_LOGGER.info(f"sx , {sx:1.4f}, {np.degrees(np.arcsin(sx)):1.4f}")
778
+ SSX_LOGGER.info(f"cx , {cx:1.4f}, {np.degrees(np.arcsin(cx)):1.4f}")
779
779
 
780
- x1factor = mtr1_dir * scalex * (Cy * Cz)
781
- y1factor = mtr2_dir * scaley * (-1.0 * Cx * Sz)
782
- z1factor = mtr3_dir * scalez * Sy
780
+ x1factor = mtr1_dir * scalex * (cy * cz)
781
+ y1factor = mtr2_dir * scaley * (-1.0 * cx * sz)
782
+ z1factor = mtr3_dir * scalez * sy
783
783
 
784
- x2factor = mtr1_dir * scalex * ((Sx * Sy * Cz) + (Cx * Sz))
785
- y2factor = mtr2_dir * scaley * ((Cx * Cz) - (Sx * Sy * Sz))
786
- z2factor = mtr3_dir * scalez * (-1.0 * Sx * Cy)
784
+ x2factor = mtr1_dir * scalex * ((sx * sy * cz) + (cx * sz))
785
+ y2factor = mtr2_dir * scaley * ((cx * cz) - (sx * sy * sz))
786
+ z2factor = mtr3_dir * scalez * (-1.0 * sx * cy)
787
787
 
788
- x3factor = mtr1_dir * scalex * ((Sx * Sz) - (Cx * Sy * Cz))
789
- y3factor = mtr2_dir * scaley * ((Cx * Sy * Sz) + (Sx * Cz))
790
- z3factor = mtr3_dir * scalez * (Cx * Cy)
788
+ x3factor = mtr1_dir * scalex * ((sx * sz) - (cx * sy * cz))
789
+ y3factor = mtr2_dir * scaley * ((cx * sy * sz) + (sx * cz))
790
+ z3factor = mtr3_dir * scalez * (cx * cy)
791
791
 
792
792
  SSX_LOGGER.info(f"Skew being used is: {skew:1.4f}")
793
- s1 = np.degrees(np.arcsin(Sz1))
794
- s2 = np.degrees(np.arcsin(Sz2))
795
- rot = np.degrees(np.arcsin((Sz1 + Sz2) / 2))
793
+ s1 = np.degrees(np.arcsin(sz1))
794
+ s2 = np.degrees(np.arcsin(sz2))
795
+ rot = np.degrees(np.arcsin((sz1 + sz2) / 2))
796
796
  calc_skew = (s1 - rot) - (s2 - rot)
797
797
  SSX_LOGGER.info(f"s1:{s1:1.4f} s2:{s2:1.4f} rot:{rot:1.4f}")
798
798
  SSX_LOGGER.info(f"Calculated rotation from current fiducials is: {rot:1.4f}")
799
799
  SSX_LOGGER.info(f"Calculated Skew from current fiducials is: {calc_skew:1.4f}")
800
800
  SSX_LOGGER.info("Calculated Skew has been known to have the wrong sign")
801
801
 
802
- sinD = np.sin((skew / 2) * (np.pi / 180))
803
- cosD = np.cos((skew / 2) * (np.pi / 180))
804
- new_x1factor = (x1factor * cosD) + (y1factor * sinD)
805
- new_y1factor = (x1factor * sinD) + (y1factor * cosD)
806
- new_x2factor = (x2factor * cosD) + (y2factor * sinD)
807
- new_y2factor = (x2factor * sinD) + (y2factor * cosD)
802
+ sin_d = np.sin((skew / 2) * (np.pi / 180))
803
+ cod_d = np.cos((skew / 2) * (np.pi / 180))
804
+ new_x1factor = (x1factor * cod_d) + (y1factor * sin_d)
805
+ new_y1factor = (x1factor * sin_d) + (y1factor * cod_d)
806
+ new_x2factor = (x2factor * cod_d) + (y2factor * sin_d)
807
+ new_y2factor = (x2factor * sin_d) + (y2factor * cod_d)
808
808
 
809
809
  cs1 = f"#1->{new_x1factor:+1.3f}X{new_y1factor:+1.3f}Y{z1factor:+1.3f}Z"
810
810
  cs2 = f"#2->{new_x2factor:+1.3f}X{new_y2factor:+1.3f}Y{z2factor:+1.3f}Z"
@@ -70,10 +70,10 @@ def pathli(l_in=None, way="typewriter", reverse=False):
70
70
  def zippum(list_1_args, list_2_args):
71
71
  list_1, type_1, reverse_1 = list_1_args
72
72
  list_2, type_2, reverse_2 = list_2_args
73
- A_path = pathli(list_1, type_1, reverse_1)
74
- B_path = pathli(list_2, type_2, reverse_2)
73
+ a_path = pathli(list_1, type_1, reverse_1)
74
+ b_path = pathli(list_2, type_2, reverse_2)
75
75
  zipped_list = []
76
- for a, b in zip(A_path, B_path, strict=False):
76
+ for a, b in zip(a_path, b_path, strict=False):
77
77
  zipped_list.append(a + b)
78
78
  return zipped_list
79
79
 
@@ -13,7 +13,7 @@ from dodal.devices.i24.pmac import PMAC
13
13
  from dodal.devices.oav.oav_detector import OAV
14
14
 
15
15
  from mx_bluesky.beamlines.i24.serial.fixed_target import (
16
- i24ssx_Chip_Manager_py3v1 as manager,
16
+ i24ssx_chip_manager_py3v1 as manager,
17
17
  )
18
18
  from mx_bluesky.beamlines.i24.serial.fixed_target.ft_utils import Fiducials
19
19
  from mx_bluesky.beamlines.i24.serial.log import SSX_LOGGER
@@ -52,12 +52,12 @@ def _move_on_mouse_click_plan(
52
52
  position coordinates.
53
53
  """
54
54
  zoomcalibrator = yield from _calculate_zoom_calibrator(oav)
55
- beamX, beamY = yield from _get_beam_centre(oav)
55
+ beam_x, beam_y = yield from _get_beam_centre(oav)
56
56
  x, y = clicked_position
57
- xmove = -10 * (beamX - x) * zoomcalibrator
58
- ymove = 10 * (beamY - y) * zoomcalibrator
57
+ xmove = -10 * (beam_x - x) * zoomcalibrator
58
+ ymove = 10 * (beam_y - y) * zoomcalibrator
59
59
  SSX_LOGGER.info(f"Zoom calibrator {zoomcalibrator}")
60
- SSX_LOGGER.info(f"Beam centre {beamX} {beamY}")
60
+ SSX_LOGGER.info(f"Beam centre {beam_x} {beam_y}")
61
61
  SSX_LOGGER.info(f"Moving X and Y {xmove} {ymove}")
62
62
  xmovepmacstring = "&2#5J:" + str(xmove)
63
63
  ymovepmacstring = "&2#6J:" + str(ymove)
@@ -66,22 +66,22 @@ def _move_on_mouse_click_plan(
66
66
 
67
67
 
68
68
  # Register clicks and move chip stages
69
- def onMouse(event, x, y, flags, param):
69
+ def on_mouse(event, x, y, flags, param):
70
70
  if event == cv.EVENT_LBUTTONUP:
71
- RE = param[0]
71
+ run_engine = param[0]
72
72
  pmac = param[1]
73
73
  oav = param[2]
74
74
  SSX_LOGGER.info(f"Clicked X and Y {x} {y}")
75
- RE(_move_on_mouse_click_plan(oav, pmac, (x, y)))
75
+ run_engine(_move_on_mouse_click_plan(oav, pmac, (x, y)))
76
76
 
77
77
 
78
- def update_ui(oav, frame, RE):
78
+ def update_ui(oav, frame, run_engine):
79
79
  # Get beam x and y values
80
- beamX, beamY = RE(_get_beam_centre(oav)).plan_result
80
+ beam_x, beam_y = run_engine(_get_beam_centre(oav)).plan_result
81
81
 
82
82
  # Overlay text and beam centre
83
83
  cv.ellipse(
84
- frame, (beamX, beamY), (12, 8), 0.0, 0.0, 360, (0, 255, 255), thickness=2
84
+ frame, (beam_x, beam_y), (12, 8), 0.0, 0.0, 360, (0, 255, 255), thickness=2
85
85
  )
86
86
  cv.putText(
87
87
  frame,
@@ -156,13 +156,13 @@ def update_ui(oav, frame, RE):
156
156
  cv.imshow("OAV1view", frame)
157
157
 
158
158
 
159
- def start_viewer(oav: OAV, pmac: PMAC, RE: RunEngine, oav1: str = OAV1_CAM):
160
- # Create a video caputure from OAV1
159
+ def start_viewer(oav: OAV, pmac: PMAC, run_engine: RunEngine, oav1: str = OAV1_CAM):
160
+ # Create a video capture from OAV1
161
161
  cap = cv.VideoCapture(oav1)
162
162
 
163
163
  # Create window named OAV1view and set onmouse to this
164
164
  cv.namedWindow("OAV1view")
165
- cv.setMouseCallback("OAV1view", onMouse, param=[RE, pmac, oav]) # type: ignore
165
+ cv.setMouseCallback("OAV1view", on_mouse, param=[run_engine, pmac, oav]) # type: ignore
166
166
 
167
167
  SSX_LOGGER.info("Showing camera feed. Press escape to close")
168
168
  # Read captured video and store them in success and frame
@@ -172,44 +172,44 @@ def start_viewer(oav: OAV, pmac: PMAC, RE: RunEngine, oav1: str = OAV1_CAM):
172
172
  while success:
173
173
  success, frame = cap.read()
174
174
 
175
- update_ui(oav, frame, RE)
175
+ update_ui(oav, frame, run_engine)
176
176
 
177
177
  k = cv.waitKey(1)
178
178
  if k == 113: # Q
179
- RE(manager.moveto(Fiducials.zero, pmac))
179
+ run_engine(manager.moveto(Fiducials.zero, pmac))
180
180
  if k == 119: # W
181
- RE(manager.moveto(Fiducials.fid1, pmac))
181
+ run_engine(manager.moveto(Fiducials.fid1, pmac))
182
182
  if k == 101: # E
183
- RE(manager.moveto(Fiducials.fid2, pmac))
183
+ run_engine(manager.moveto(Fiducials.fid2, pmac))
184
184
  if k == 97: # A
185
- RE(bps.trigger(pmac.home, wait=True))
185
+ run_engine(bps.trigger(pmac.home, wait=True))
186
186
  print("Current position set as origin")
187
187
  if k == 115: # S
188
- RE(manager.fiducial(1))
188
+ run_engine(manager.fiducial(1))
189
189
  if k == 100: # D
190
- RE(manager.fiducial(2))
190
+ run_engine(manager.fiducial(2))
191
191
  if k == 99: # C
192
- RE(manager.cs_maker(pmac))
192
+ run_engine(manager.cs_maker(pmac))
193
193
  if k == 98: # B
194
- RE(
194
+ run_engine(
195
195
  manager.block_check()
196
196
  ) # doesn't work well for blockcheck as image doesn't update
197
197
  if k == 104: # H
198
- RE(bps.abs_set(pmac.pmac_string, "&2#6J:-10", wait=True))
198
+ run_engine(bps.abs_set(pmac.pmac_string, "&2#6J:-10", wait=True))
199
199
  if k == 110: # N
200
- RE(bps.abs_set(pmac.pmac_string, "&2#6J:10", wait=True))
200
+ run_engine(bps.abs_set(pmac.pmac_string, "&2#6J:10", wait=True))
201
201
  if k == 109: # M
202
- RE(bps.abs_set(pmac.pmac_string, "&2#5J:-10", wait=True))
202
+ run_engine(bps.abs_set(pmac.pmac_string, "&2#5J:-10", wait=True))
203
203
  if k == 98: # B
204
- RE(bps.abs_set(pmac.pmac_string, "&2#5J:10", wait=True))
204
+ run_engine(bps.abs_set(pmac.pmac_string, "&2#5J:10", wait=True))
205
205
  if k == 105: # I
206
- RE(bps.abs_set(pmac.pmac_string, "&2#7J:-150", wait=True))
206
+ run_engine(bps.abs_set(pmac.pmac_string, "&2#7J:-150", wait=True))
207
207
  if k == 111: # O
208
- RE(bps.abs_set(pmac.pmac_string, "&2#7J:150", wait=True))
208
+ run_engine(bps.abs_set(pmac.pmac_string, "&2#7J:150", wait=True))
209
209
  if k == 117: # U
210
- RE(bps.abs_set(pmac.pmac_string, "&2#7J:-1000", wait=True))
210
+ run_engine(bps.abs_set(pmac.pmac_string, "&2#7J:-1000", wait=True))
211
211
  if k == 112: # P
212
- RE(bps.abs_set(pmac.pmac_string, "&2#7J:1000", wait=True))
212
+ run_engine(bps.abs_set(pmac.pmac_string, "&2#7J:1000", wait=True))
213
213
  if k == 0x1B: # esc
214
214
  cv.destroyWindow("OAV1view")
215
215
  print("Pressed escape. Closing window")
@@ -220,8 +220,8 @@ def start_viewer(oav: OAV, pmac: PMAC, RE: RunEngine, oav1: str = OAV1_CAM):
220
220
 
221
221
 
222
222
  if __name__ == "__main__":
223
- RE = RunEngine(call_returns_result=True)
223
+ run_engine = RunEngine(call_returns_result=True)
224
224
  # Get devices out of dodal
225
225
  oav: OAV = i24.oav(connect_immediately=True)
226
226
  pmac: PMAC = i24.pmac(connect_immediately=True)
227
- start_viewer(oav, pmac, RE)
227
+ start_viewer(oav, pmac, run_engine)
@@ -9,7 +9,7 @@ import bluesky.plan_stubs as bps
9
9
  from bluesky.log import logger as bluesky_logger
10
10
  from bluesky.utils import MsgGenerator
11
11
  from dodal.log import DEFAULT_GRAYLOG_PORT, ophyd_async_logger
12
- from dodal.log import LOGGER as dodal_logger
12
+ from dodal.log import LOGGER as DODAL_LOGGER
13
13
 
14
14
  from mx_bluesky.common.utils.log import do_default_logging_setup
15
15
 
@@ -19,7 +19,7 @@ VISIT_PATH = Path("/dls_sw/i24/etc/ssx_current_visit.txt")
19
19
  # Logging set up
20
20
  SSX_LOGGER = logging.getLogger("I24serial")
21
21
  SSX_LOGGER.addHandler(logging.NullHandler())
22
- SSX_LOGGER.parent = dodal_logger
22
+ SSX_LOGGER.parent = DODAL_LOGGER
23
23
 
24
24
 
25
25
  logging_config = {
@@ -101,14 +101,14 @@ def config(
101
101
  """
102
102
  if logfile:
103
103
  logs = _get_logging_file_path() / logfile
104
- fileFormatter = logging.Formatter(
104
+ file_formatter = logging.Formatter(
105
105
  "%(asctime)s %(levelname)s: \t(%(name)s) %(message)s",
106
106
  datefmt="%d-%m-%Y %I:%M:%S",
107
107
  )
108
- FH = logging.FileHandler(logs, mode=write_mode, encoding="utf-8", delay=delayed)
109
- FH.setLevel(logging.DEBUG)
110
- FH.setFormatter(fileFormatter)
111
- SSX_LOGGER.addHandler(FH)
108
+ fh = logging.FileHandler(logs, mode=write_mode, encoding="utf-8", delay=delayed)
109
+ fh.setLevel(logging.DEBUG)
110
+ fh.setFormatter(file_formatter)
111
+ SSX_LOGGER.addHandler(fh)
112
112
  do_default_logging_setup(
113
113
  "mx-bluesky.log",
114
114
  DEFAULT_GRAYLOG_PORT,
@@ -116,8 +116,8 @@ def config(
116
116
  integrate_all_logs=False,
117
117
  )
118
118
  # Remove dodal StreamHandler to avoid duplication of messages above debug
119
- dodal_logger.removeHandler(dodal_logger.handlers[0])
120
- _integrate_bluesky_logs(dodal_logger)
119
+ DODAL_LOGGER.removeHandler(DODAL_LOGGER.handlers[0])
120
+ _integrate_bluesky_logs(DODAL_LOGGER)
121
121
 
122
122
 
123
123
  def log_on_entry(func):
@@ -151,6 +151,6 @@ def clean_up_log_config_at_end() -> MsgGenerator:
151
151
  # See https://github.com/DiamondLightSource/mx-bluesky/issues/609
152
152
  for handler in SSX_LOGGER.handlers:
153
153
  SSX_LOGGER.removeHandler(handler)
154
- for handler in dodal_logger.handlers:
155
- dodal_logger.removeHandler(handler)
154
+ for handler in DODAL_LOGGER.handlers:
155
+ DODAL_LOGGER.removeHandler(handler)
156
156
  yield from bps.null()
@@ -3,7 +3,7 @@
3
3
  "scaley": 10011.9,
4
4
  "scalez": 10000.0,
5
5
  "skew": 0.025,
6
- "Sx_dir": 1,
7
- "Sy_dir": 1,
8
- "Sz_dir": 1
6
+ "sx_dir": 1,
7
+ "sy_dir": 1,
8
+ "sz_dir": 1
9
9
  }
@@ -38,15 +38,3 @@ def caput(pv, new_val):
38
38
  else:
39
39
  a = Popen(["caput", pv, str(new_val)], stdout=PIPE, stderr=PIPE)
40
40
  a_stdout, a_stderr = a.communicate()
41
-
42
-
43
- def evaluate(val):
44
- try:
45
- int(val)
46
- return int(val)
47
- except Exception:
48
- try:
49
- float(val)
50
- return float(val)
51
- except ValueError:
52
- return val