dls-dodal 1.34.1__py3-none-any.whl → 1.36.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. {dls_dodal-1.34.1.dist-info → dls_dodal-1.36.0.dist-info}/METADATA +4 -2
  2. dls_dodal-1.36.0.dist-info/RECORD +152 -0
  3. {dls_dodal-1.34.1.dist-info → dls_dodal-1.36.0.dist-info}/WHEEL +1 -1
  4. dodal/_version.py +2 -2
  5. dodal/beamlines/i22.py +24 -11
  6. dodal/beamlines/i24.py +4 -4
  7. dodal/beamlines/p38.py +23 -11
  8. dodal/common/beamlines/beamline_utils.py +1 -2
  9. dodal/common/crystal_metadata.py +61 -0
  10. dodal/common/signal_utils.py +10 -14
  11. dodal/devices/CTAB.py +1 -1
  12. dodal/devices/aperture.py +1 -1
  13. dodal/devices/aperturescatterguard.py +20 -8
  14. dodal/devices/apple2_undulator.py +30 -29
  15. dodal/devices/areadetector/plugins/CAM.py +3 -5
  16. dodal/devices/areadetector/plugins/MJPG.py +1 -1
  17. dodal/devices/attenuator.py +1 -1
  18. dodal/devices/backlight.py +4 -5
  19. dodal/devices/cryostream.py +3 -5
  20. dodal/devices/dcm.py +26 -2
  21. dodal/devices/detector/detector_motion.py +3 -5
  22. dodal/devices/diamond_filter.py +3 -4
  23. dodal/devices/eiger.py +88 -49
  24. dodal/devices/fast_grid_scan.py +1 -1
  25. dodal/devices/fluorescence_detector_motion.py +5 -7
  26. dodal/devices/focusing_mirror.py +12 -11
  27. dodal/devices/hutch_shutter.py +4 -5
  28. dodal/devices/i10/i10_apple2.py +20 -19
  29. dodal/devices/i10/i10_setting_data.py +2 -2
  30. dodal/devices/i22/dcm.py +43 -75
  31. dodal/devices/i22/fswitch.py +5 -5
  32. dodal/devices/i24/aperture.py +3 -5
  33. dodal/devices/i24/beamstop.py +3 -5
  34. dodal/devices/i24/dcm.py +1 -1
  35. dodal/devices/i24/dual_backlight.py +4 -6
  36. dodal/devices/i24/pmac.py +35 -46
  37. dodal/devices/i24/vgonio.py +16 -0
  38. dodal/devices/ipin.py +5 -3
  39. dodal/devices/linkam3.py +7 -7
  40. dodal/devices/oav/oav_detector.py +3 -3
  41. dodal/devices/oav/oav_to_redis_forwarder.py +8 -7
  42. dodal/devices/oav/pin_image_recognition/__init__.py +9 -7
  43. dodal/devices/oav/snapshots/grid_overlay.py +16 -16
  44. dodal/devices/oav/snapshots/snapshot_with_beam_centre.py +5 -5
  45. dodal/devices/oav/snapshots/snapshot_with_grid.py +6 -6
  46. dodal/devices/oav/utils.py +2 -2
  47. dodal/devices/p99/sample_stage.py +3 -5
  48. dodal/devices/pgm.py +5 -6
  49. dodal/devices/qbpm.py +1 -1
  50. dodal/devices/robot.py +3 -3
  51. dodal/devices/smargon.py +1 -1
  52. dodal/devices/synchrotron.py +9 -4
  53. dodal/devices/tetramm.py +7 -7
  54. dodal/devices/thawer.py +13 -7
  55. dodal/devices/undulator.py +5 -5
  56. dodal/devices/util/epics_util.py +1 -1
  57. dodal/devices/watsonmarlow323_pump.py +45 -0
  58. dodal/devices/webcam.py +9 -2
  59. dodal/devices/xbpm_feedback.py +3 -5
  60. dodal/devices/xspress3/xspress3.py +8 -9
  61. dodal/devices/xspress3/xspress3_channel.py +3 -5
  62. dodal/devices/zebra.py +7 -6
  63. dodal/devices/zebra_controlled_shutter.py +5 -6
  64. dodal/devices/zocalo/__init__.py +2 -2
  65. dodal/devices/zocalo/zocalo_constants.py +3 -0
  66. dodal/devices/zocalo/zocalo_interaction.py +2 -1
  67. dodal/devices/zocalo/zocalo_results.py +92 -79
  68. dodal/plan_stubs/__init__.py +0 -0
  69. dodal/{plans/data_session_metadata.py → plan_stubs/data_session.py} +2 -2
  70. dodal/{plans/motor_util_plans.py → plan_stubs/motor_utils.py} +2 -2
  71. dodal/plan_stubs/wrapped.py +150 -0
  72. dodal/plans/__init__.py +4 -0
  73. dodal/plans/scanspec.py +66 -0
  74. dodal/plans/wrapped.py +57 -0
  75. dodal/utils.py +4 -0
  76. dls_dodal-1.34.1.dist-info/RECORD +0 -144
  77. dodal/devices/i24/i24_vgonio.py +0 -17
  78. {dls_dodal-1.34.1.dist-info → dls_dodal-1.36.0.dist-info}/LICENSE +0 -0
  79. {dls_dodal-1.34.1.dist-info → dls_dodal-1.36.0.dist-info}/entry_points.txt +0 -0
  80. {dls_dodal-1.34.1.dist-info → dls_dodal-1.36.0.dist-info}/top_level.txt +0 -0
  81. /dodal/{plans → plan_stubs}/check_topup.py +0 -0
@@ -0,0 +1,45 @@
1
+ from ophyd_async.core import StandardReadable, StandardReadableFormat, StrictEnum
2
+ from ophyd_async.epics.core import epics_signal_rw
3
+
4
+
5
+ class WatsonMarlow323PumpEnable(StrictEnum):
6
+ DISABLED = "Disabled"
7
+ ENABLED = "Enabled"
8
+
9
+
10
+ class WatsonMarlow323PumpDirection(StrictEnum):
11
+ CLOCKWISE = "CW"
12
+ COUNTER_CLOCKWISE = "CCW"
13
+
14
+
15
+ class WatsonMarlow323PumpState(StrictEnum):
16
+ STOPPED = "STOP"
17
+ STARTED = "START"
18
+
19
+
20
+ class WatsonMarlow323Pump(StandardReadable):
21
+ """Watson Marlow 323 Peristaltic Pump device"""
22
+
23
+ def __init__(self, prefix: str, name: str = "") -> None:
24
+ with self.add_children_as_readables():
25
+ self.direction = epics_signal_rw(
26
+ WatsonMarlow323PumpDirection,
27
+ read_pv=prefix + "INFO:DIR",
28
+ write_pv=prefix + "SET:DIR",
29
+ )
30
+ self.state = epics_signal_rw(
31
+ WatsonMarlow323PumpState,
32
+ read_pv=prefix + "INFO:RUN",
33
+ write_pv=prefix + "SET:RUN",
34
+ )
35
+ self.speed = epics_signal_rw(
36
+ float, read_pv=prefix + "INFO:SPD", write_pv=prefix + "SET:SPD"
37
+ )
38
+
39
+ with self.add_children_as_readables(StandardReadableFormat.CONFIG_SIGNAL):
40
+ self.enabled = epics_signal_rw(
41
+ WatsonMarlow323PumpEnable,
42
+ prefix + "DISABLE",
43
+ )
44
+
45
+ super().__init__(name=name)
dodal/devices/webcam.py CHANGED
@@ -5,7 +5,12 @@ from pathlib import Path
5
5
  import aiofiles
6
6
  from aiohttp import ClientSession
7
7
  from bluesky.protocols import Triggerable
8
- from ophyd_async.core import AsyncStatus, HintedSignal, StandardReadable, soft_signal_rw
8
+ from ophyd_async.core import (
9
+ AsyncStatus,
10
+ StandardReadable,
11
+ StandardReadableFormat,
12
+ soft_signal_rw,
13
+ )
9
14
  from PIL import Image
10
15
 
11
16
  from dodal.log import LOGGER
@@ -27,7 +32,9 @@ class Webcam(StandardReadable, Triggerable):
27
32
  self.directory = soft_signal_rw(str, name="directory")
28
33
  self.last_saved_path = soft_signal_rw(str, name="last_saved_path")
29
34
 
30
- self.add_readables([self.last_saved_path], wrapper=HintedSignal)
35
+ self.add_readables(
36
+ [self.last_saved_path], format=StandardReadableFormat.HINTED_SIGNAL
37
+ )
31
38
  super().__init__(name=name)
32
39
 
33
40
  async def _write_image(self, file_path: str, image: ByteString):
@@ -1,11 +1,9 @@
1
- from enum import Enum
2
-
3
1
  from bluesky.protocols import Triggerable
4
- from ophyd_async.core import AsyncStatus, Device, observe_value
5
- from ophyd_async.epics.signal import epics_signal_r, epics_signal_rw
2
+ from ophyd_async.core import AsyncStatus, Device, StrictEnum, observe_value
3
+ from ophyd_async.epics.core import epics_signal_r, epics_signal_rw
6
4
 
7
5
 
8
- class Pause(str, Enum):
6
+ class Pause(StrictEnum):
9
7
  PAUSE = "Paused" # 0
10
8
  RUN = "Ok to Run" # 1
11
9
 
@@ -1,15 +1,14 @@
1
- from enum import Enum
2
-
3
1
  from bluesky.protocols import Stageable
4
2
  from numpy import float64
5
- from numpy.typing import NDArray
6
3
  from ophyd_async.core import (
4
+ Array1D,
7
5
  AsyncStatus,
8
6
  Device,
9
7
  DeviceVector,
8
+ StrictEnum,
10
9
  wait_for_value,
11
10
  )
12
- from ophyd_async.epics.signal import (
11
+ from ophyd_async.epics.core import (
13
12
  epics_signal_r,
14
13
  epics_signal_rw,
15
14
  epics_signal_rw_rbv,
@@ -23,7 +22,7 @@ from dodal.devices.xspress3.xspress3_channel import (
23
22
  from dodal.log import LOGGER
24
23
 
25
24
 
26
- class TriggerMode(str, Enum):
25
+ class TriggerMode(StrictEnum):
27
26
  SOFTWARE = "Software"
28
27
  HARDWARE = "Hardware"
29
28
  BURST = "Burst"
@@ -35,17 +34,17 @@ class TriggerMode(str, Enum):
35
34
  LVDS_both = "LVDS Both"
36
35
 
37
36
 
38
- class UpdateRBV(str, Enum):
37
+ class UpdateRBV(StrictEnum):
39
38
  DISABLED = "Disabled"
40
39
  ENABLED = "Enabled"
41
40
 
42
41
 
43
- class AcquireRBVState(str, Enum):
42
+ class AcquireRBVState(StrictEnum):
44
43
  DONE = "Done"
45
44
  ACQUIRE = "Acquiring"
46
45
 
47
46
 
48
- class DetectorState(str, Enum):
47
+ class DetectorState(StrictEnum):
49
48
  IDLE = "Idle"
50
49
  ACQUIRE = "Acquire"
51
50
  READOUT = "Readout"
@@ -101,7 +100,7 @@ class Xspress3(Device, Stageable):
101
100
  """signal for the corrected MCA spectrum (1d array)"""
102
101
  self.dt_corrected_latest_mca = DeviceVector(
103
102
  {
104
- i: epics_signal_r(NDArray[float64], f"{prefix}ARR{i}:ArrayData")
103
+ i: epics_signal_r(Array1D[float64], f"{prefix}ARR{i}:ArrayData")
105
104
  for i in range(1, num_channels + 1)
106
105
  }
107
106
  )
@@ -1,10 +1,8 @@
1
- from enum import Enum
1
+ from ophyd_async.core import Device, StrictEnum
2
+ from ophyd_async.epics.core import epics_signal_r, epics_signal_rw
2
3
 
3
- from ophyd_async.core import Device
4
- from ophyd_async.epics.signal import epics_signal_r, epics_signal_rw
5
4
 
6
-
7
- class AcquireState(str, Enum):
5
+ class AcquireState(StrictEnum):
8
6
  DONE = "Done"
9
7
  ACQUIRE = "Acquire"
10
8
 
dodal/devices/zebra.py CHANGED
@@ -9,9 +9,10 @@ from ophyd_async.core import (
9
9
  DeviceVector,
10
10
  SignalRW,
11
11
  StandardReadable,
12
+ StrictEnum,
12
13
  observe_value,
13
14
  )
14
- from ophyd_async.epics.signal import epics_signal_r, epics_signal_rw
15
+ from ophyd_async.epics.core import epics_signal_r, epics_signal_rw
15
16
 
16
17
  # These constants refer to I03's Zebra. See https://github.com/DiamondLightSource/dodal/issues/772
17
18
  # Sources
@@ -46,18 +47,18 @@ AUTO_SHUTTER_INPUT_1 = 1
46
47
  AUTO_SHUTTER_INPUT_2 = 2
47
48
 
48
49
 
49
- class ArmSource(str, Enum):
50
+ class ArmSource(StrictEnum):
50
51
  SOFT = "Soft"
51
52
  EXTERNAL = "External"
52
53
 
53
54
 
54
- class TrigSource(str, Enum):
55
+ class TrigSource(StrictEnum):
55
56
  POSITION = "Position"
56
57
  TIME = "Time"
57
58
  EXTERNAL = "External"
58
59
 
59
60
 
60
- class EncEnum(str, Enum):
61
+ class EncEnum(StrictEnum):
61
62
  Enc1 = "Enc1"
62
63
  Enc2 = "Enc2"
63
64
  Enc3 = "Enc3"
@@ -79,7 +80,7 @@ class I24Axes:
79
80
  VGON_YH = EncEnum.Enc4
80
81
 
81
82
 
82
- class RotationDirection(str, Enum):
83
+ class RotationDirection(StrictEnum):
83
84
  POSITIVE = "Positive"
84
85
  NEGATIVE = "Negative"
85
86
 
@@ -93,7 +94,7 @@ class ArmDemand(Enum):
93
94
  DISARM = 0
94
95
 
95
96
 
96
- class SoftInState(str, Enum):
97
+ class SoftInState(StrictEnum):
97
98
  YES = "Yes"
98
99
  NO = "No"
99
100
 
@@ -1,21 +1,20 @@
1
- from enum import Enum
2
-
3
1
  from bluesky.protocols import Movable
4
2
  from ophyd_async.core import (
5
3
  DEFAULT_TIMEOUT,
6
4
  AsyncStatus,
7
5
  StandardReadable,
6
+ StrictEnum,
8
7
  wait_for_value,
9
8
  )
10
- from ophyd_async.epics.signal import epics_signal_r, epics_signal_rw, epics_signal_w
9
+ from ophyd_async.epics.core import epics_signal_r, epics_signal_rw, epics_signal_w
11
10
 
12
11
 
13
- class ZebraShutterState(str, Enum):
12
+ class ZebraShutterState(StrictEnum):
14
13
  CLOSE = "Close"
15
14
  OPEN = "Open"
16
15
 
17
16
 
18
- class ZebraShutterControl(str, Enum):
17
+ class ZebraShutterControl(StrictEnum):
19
18
  MANUAL = "Manual"
20
19
  AUTO = "Auto"
21
20
 
@@ -26,7 +25,7 @@ class ZebraShutter(StandardReadable, Movable):
26
25
  Internally in the zebra there are two AND gates, one for manual control and one for
27
26
  automatic control. A soft input (aliased to control_mode) will switch between
28
27
  which of these AND gates to use. For the manual gate the shutter is then controlled
29
- by a different soft input (aliased to _manual_position_setpoint). Both these AND
28
+ by a different soft input (aliased to manual_position_setpoint). Both these AND
30
29
  gates then feed into an OR gate, which then feeds to the shutter."""
31
30
 
32
31
  def __init__(self, prefix: str, name: str):
@@ -4,14 +4,14 @@ from dodal.devices.zocalo.zocalo_results import (
4
4
  NoZocaloSubscription,
5
5
  XrcResult,
6
6
  ZocaloResults,
7
- get_processing_result,
7
+ get_full_processing_results,
8
8
  )
9
9
 
10
10
  __all__ = [
11
11
  "ZocaloResults",
12
12
  "XrcResult",
13
13
  "ZocaloTrigger",
14
- "get_processing_result",
14
+ "get_full_processing_results",
15
15
  "ZOCALO_READING_PLAN_NAME",
16
16
  "NoResultsFromZocalo",
17
17
  "NoZocaloSubscription",
@@ -0,0 +1,3 @@
1
+ from dodal.utils import is_test_mode
2
+
3
+ ZOCALO_ENV = "dev_bluesky" if is_test_mode() else "bluesky"
@@ -7,6 +7,7 @@ from dataclasses import dataclass
7
7
  import zocalo.configuration
8
8
  from workflows.transport import lookup
9
9
 
10
+ from dodal.devices.zocalo.zocalo_constants import ZOCALO_ENV
10
11
  from dodal.log import LOGGER
11
12
 
12
13
 
@@ -56,7 +57,7 @@ class ZocaloTrigger:
56
57
 
57
58
  see https://github.com/DiamondLightSource/dodal/wiki/How-to-Interact-with-Zocalo"""
58
59
 
59
- def __init__(self, environment: str = "artemis"):
60
+ def __init__(self, environment: str = ZOCALO_ENV):
60
61
  self.zocalo_environment: str = environment
61
62
 
62
63
  def _send_to_zocalo(self, parameters: dict):
@@ -1,7 +1,7 @@
1
1
  import asyncio
2
- from collections import OrderedDict
3
2
  from collections.abc import Generator, Sequence
4
3
  from enum import Enum
4
+ from inspect import get_annotations
5
5
  from queue import Empty, Queue
6
6
  from typing import Any, TypedDict
7
7
 
@@ -9,17 +9,19 @@ import bluesky.plan_stubs as bps
9
9
  import numpy as np
10
10
  import workflows.recipe
11
11
  import workflows.transport
12
- from bluesky.protocols import Descriptor, Triggerable
12
+ from bluesky.protocols import Triggerable
13
+ from bluesky.utils import Msg
13
14
  from deepdiff import DeepDiff
14
15
  from numpy.typing import NDArray
15
16
  from ophyd_async.core import (
16
17
  AsyncStatus,
17
- HintedSignal,
18
18
  StandardReadable,
19
+ StandardReadableFormat,
19
20
  soft_signal_r_and_setter,
20
21
  )
21
22
  from workflows.transport.common_transport import CommonTransport
22
23
 
24
+ from dodal.devices.zocalo.zocalo_constants import ZOCALO_ENV
23
25
  from dodal.devices.zocalo.zocalo_interaction import _get_zocalo_connection
24
26
  from dodal.log import LOGGER
25
27
 
@@ -51,7 +53,7 @@ ZOCALO_STAGE_GROUP = "clear zocalo queue"
51
53
 
52
54
 
53
55
  class XrcResult(TypedDict):
54
- centre_of_mass: list[int]
56
+ centre_of_mass: list[float]
55
57
  max_voxel: list[int]
56
58
  max_count: int
57
59
  n_voxels: int
@@ -114,7 +116,7 @@ class ZocaloResults(StandardReadable, Triggerable):
114
116
  def __init__(
115
117
  self,
116
118
  name: str = "zocalo",
117
- zocalo_environment: str = "dev_artemis",
119
+ zocalo_environment: str = ZOCALO_ENV,
118
120
  channel: str = "xrc.i03",
119
121
  sort_key: str = DEFAULT_SORT_KEY.value,
120
122
  timeout_s: float = DEFAULT_TIMEOUT,
@@ -130,14 +132,23 @@ class ZocaloResults(StandardReadable, Triggerable):
130
132
  self.transport: CommonTransport | None = None
131
133
  self.use_cpu_and_gpu = use_cpu_and_gpu
132
134
 
133
- self.results, self._results_setter = soft_signal_r_and_setter(
134
- list[XrcResult], name="results"
135
+ self.centre_of_mass, self._com_setter = soft_signal_r_and_setter(
136
+ NDArray[np.uint64], name="centre_of_mass"
135
137
  )
136
- self.centres_of_mass, self._com_setter = soft_signal_r_and_setter(
137
- NDArray[np.uint64], name="centres_of_mass"
138
+ self.bounding_box, self._bounding_box_setter = soft_signal_r_and_setter(
139
+ NDArray[np.uint64], name="bounding_box"
138
140
  )
139
- self.bbox_sizes, self._bbox_setter = soft_signal_r_and_setter(
140
- NDArray[np.uint64], "bbox_sizes", self.name
141
+ self.max_voxel, self._max_voxel_setter = soft_signal_r_and_setter(
142
+ NDArray[np.uint64], name="max_voxel"
143
+ )
144
+ self.max_count, self._max_count_setter = soft_signal_r_and_setter(
145
+ NDArray[np.uint64], name="max_count"
146
+ )
147
+ self.n_voxels, self._n_voxels_setter = soft_signal_r_and_setter(
148
+ NDArray[np.uint64], name="n_voxels"
149
+ )
150
+ self.total_count, self._total_count_setter = soft_signal_r_and_setter(
151
+ NDArray[np.uint64], name="total_count"
141
152
  )
142
153
  self.ispyb_dcid, self._ispyb_dcid_setter = soft_signal_r_and_setter(
143
154
  int, name="ispyb_dcid"
@@ -147,22 +158,27 @@ class ZocaloResults(StandardReadable, Triggerable):
147
158
  )
148
159
  self.add_readables(
149
160
  [
150
- self.results,
151
- self.centres_of_mass,
152
- self.bbox_sizes,
161
+ self.max_voxel,
162
+ self.max_count,
163
+ self.n_voxels,
164
+ self.total_count,
165
+ self.centre_of_mass,
166
+ self.bounding_box,
153
167
  self.ispyb_dcid,
154
168
  self.ispyb_dcgid,
155
169
  ],
156
- wrapper=HintedSignal,
170
+ format=StandardReadableFormat.HINTED_SIGNAL,
157
171
  )
158
172
  super().__init__(name)
159
173
 
160
174
  async def _put_results(self, results: Sequence[XrcResult], recipe_parameters):
161
- self._results_setter(list(results))
162
175
  centres_of_mass = np.array([r["centre_of_mass"] for r in results])
163
- bbox_sizes = np.array([bbox_size(r) for r in results])
164
176
  self._com_setter(centres_of_mass)
165
- self._bbox_setter(bbox_sizes)
177
+ self._bounding_box_setter(np.array([r["bounding_box"] for r in results]))
178
+ self._max_voxel_setter(np.array([r["max_voxel"] for r in results]))
179
+ self._max_count_setter(np.array([r["max_count"] for r in results]))
180
+ self._n_voxels_setter(np.array([r["n_voxels"] for r in results]))
181
+ self._total_count_setter(np.array([r["total_count"] for r in results]))
166
182
  self._ispyb_dcid_setter(recipe_parameters["dcid"])
167
183
  self._ispyb_dcgid_setter(recipe_parameters["dcgid"])
168
184
 
@@ -286,48 +302,6 @@ class ZocaloResults(StandardReadable, Triggerable):
286
302
  finally:
287
303
  self._kickoff_run = False
288
304
 
289
- async def describe(self) -> dict[str, Descriptor]:
290
- zocalo_array_type: Descriptor = {
291
- "source": f"zocalo_service:{self.zocalo_environment}",
292
- "dtype": "array",
293
- "shape": [-1, 3],
294
- }
295
- zocalo_int_type: Descriptor = {
296
- "source": f"zocalo_service:{self.zocalo_environment}",
297
- "dtype": "integer",
298
- "shape": [0],
299
- }
300
- return OrderedDict(
301
- [
302
- (
303
- self._name + "-results",
304
- {
305
- "source": f"zocalo_service:{self.zocalo_environment}",
306
- "dtype": "array",
307
- "shape": [
308
- -1,
309
- ], # TODO describe properly - see https://github.com/DiamondLightSource/dodal/issues/253
310
- },
311
- ),
312
- (
313
- self._name + "-centres_of_mass",
314
- zocalo_array_type,
315
- ),
316
- (
317
- self._name + "-bbox_sizes",
318
- zocalo_array_type,
319
- ),
320
- (
321
- self._name + "-ispyb_dcid",
322
- zocalo_int_type,
323
- ),
324
- (
325
- self._name + "-ispyb_dcgid",
326
- zocalo_int_type,
327
- ),
328
- ],
329
- )
330
-
331
305
  def _subscribe_to_results(self):
332
306
  self.transport = _get_zocalo_connection(self.zocalo_environment)
333
307
 
@@ -364,23 +338,62 @@ class ZocaloResults(StandardReadable, Triggerable):
364
338
  )
365
339
 
366
340
 
367
- def get_processing_result(
341
+ def _corrected_xrc_result(uncorrected: XrcResult) -> XrcResult:
342
+ corrected = XrcResult(**uncorrected)
343
+ corrected["centre_of_mass"] = [
344
+ coord - 0.5 for coord in uncorrected["centre_of_mass"]
345
+ ]
346
+ return corrected
347
+
348
+
349
+ def get_full_processing_results(
368
350
  zocalo: ZocaloResults,
369
- ) -> Generator[Any, Any, tuple[np.ndarray, np.ndarray] | tuple[None, None]]:
370
- """A minimal plan which will extract the top ranked xray centre and crystal bounding
371
- box size from the zocalo results. Returns (None, None) if no crystals were found."""
372
-
373
- LOGGER.info("Getting zocalo processing results.")
374
- centres_of_mass = yield from bps.rd(zocalo.centres_of_mass, default_value=[]) # type: ignore
375
- LOGGER.debug(f"Centres of mass: {centres_of_mass}")
376
- centre_of_mass = (
377
- None
378
- if len(centres_of_mass) == 0 # type: ignore
379
- else centres_of_mass[0] - np.array([0.5, 0.5, 0.5]) # type: ignore
380
- )
381
- LOGGER.debug(f"Adjusted top centring result: {centre_of_mass}")
382
- bbox_sizes = yield from bps.rd(zocalo.bbox_sizes, default_value=[]) # type: ignore
383
- LOGGER.debug(f"Bounding box sizes: {centres_of_mass}")
384
- bbox_size = None if len(bbox_sizes) == 0 else bbox_sizes[0] # type: ignore
385
- LOGGER.debug(f"Top bbox size: {bbox_size}")
386
- return centre_of_mass, bbox_size
351
+ ) -> Generator[Msg, Any, Sequence[XrcResult]]:
352
+ """A plan that will return the raw zocalo results, ranked in descending order according to the sort key.
353
+ Returns empty list in the event no results found."""
354
+ LOGGER.info("Retrieving raw zocalo processing results")
355
+ com = yield from bps.rd(zocalo.centre_of_mass, default_value=[]) # type: ignore
356
+ max_voxel = yield from bps.rd(zocalo.max_voxel, default_value=[]) # type: ignore
357
+ max_count = yield from bps.rd(zocalo.max_count, default_value=[]) # type: ignore
358
+ n_voxels = yield from bps.rd(zocalo.n_voxels, default_value=[]) # type: ignore
359
+ total_count = yield from bps.rd(zocalo.total_count, default_value=[]) # type: ignore
360
+ bounding_box = yield from bps.rd(zocalo.bounding_box, default_value=[]) # type: ignore
361
+ return [
362
+ _corrected_xrc_result(
363
+ XrcResult(
364
+ centre_of_mass=com.tolist(),
365
+ max_voxel=mv.tolist(),
366
+ max_count=int(mc),
367
+ n_voxels=int(n),
368
+ total_count=int(tc),
369
+ bounding_box=bb.tolist(),
370
+ )
371
+ )
372
+ for com, mv, mc, n, tc, bb in zip(
373
+ com, max_voxel, max_count, n_voxels, total_count, bounding_box, strict=True
374
+ )
375
+ ]
376
+
377
+
378
+ def get_processing_results_from_event(
379
+ device_name: str, doc: dict
380
+ ) -> Sequence[XrcResult]:
381
+ """
382
+ Decode an event document into the corresponding x-ray centring results
383
+
384
+ Args:
385
+ doc A bluesky event document containing the signals read from the ZocaloResults
386
+ device_name The device name prefix to prepend to the document keys
387
+
388
+ Returns:
389
+ The list of XrcResults decoded from the event document
390
+ """
391
+ results_keys = get_annotations(XrcResult).keys()
392
+ results_dict = {k: doc["data"][f"{device_name}-{k}"] for k in results_keys}
393
+ results_values = [results_dict[k].tolist() for k in results_keys]
394
+
395
+ def create_result(*argv):
396
+ kwargs = dict(zip(results_keys, argv, strict=False))
397
+ return XrcResult(**kwargs)
398
+
399
+ return list(map(create_result, *results_values))
File without changes
@@ -2,7 +2,7 @@ from bluesky import plan_stubs as bps
2
2
  from bluesky import preprocessors as bpp
3
3
  from bluesky.utils import MsgGenerator, make_decorator
4
4
 
5
- from dodal.common.beamlines import beamline_utils
5
+ from dodal.common.beamlines.beamline_utils import get_path_provider
6
6
  from dodal.common.types import UpdatingPathProvider
7
7
 
8
8
  DATA_SESSION = "data_session"
@@ -31,7 +31,7 @@ def attach_data_session_metadata_wrapper(
31
31
  Iterator[Msg]: Plan messages
32
32
  """
33
33
  if provider is None:
34
- provider = beamline_utils.get_path_provider()
34
+ provider = get_path_provider()
35
35
  yield from bps.wait_for([provider.update])
36
36
  ress = yield from bps.wait_for([provider.data_session])
37
37
  data_session = ress[0].result()
@@ -23,7 +23,7 @@ class MoveTooLarge(Exception):
23
23
  super().__init__(*args)
24
24
 
25
25
 
26
- def _check_and_cache_values(
26
+ def check_and_cache_values(
27
27
  devices_and_positions: dict[MovableReadableDevice, float],
28
28
  smallest_move: float,
29
29
  maximum_move: float,
@@ -89,7 +89,7 @@ def move_and_reset_wrapper(
89
89
  on. If false it is left up to the caller to wait on
90
90
  them. Defaults to True.
91
91
  """
92
- initial_positions = yield from _check_and_cache_values(
92
+ initial_positions = yield from check_and_cache_values(
93
93
  device_and_positions, smallest_move, maximum_move
94
94
  )
95
95