dls-dodal 1.49.0__py3-none-any.whl → 1.51.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 (72) hide show
  1. {dls_dodal-1.49.0.dist-info → dls_dodal-1.51.0.dist-info}/METADATA +3 -4
  2. {dls_dodal-1.49.0.dist-info → dls_dodal-1.51.0.dist-info}/RECORD +65 -60
  3. dodal/_version.py +2 -2
  4. dodal/beamlines/adsim.py +5 -3
  5. dodal/beamlines/b01_1.py +41 -5
  6. dodal/beamlines/b07.py +11 -1
  7. dodal/beamlines/b07_1.py +11 -1
  8. dodal/beamlines/b16.py +8 -4
  9. dodal/beamlines/b21.py +148 -0
  10. dodal/beamlines/i03.py +6 -11
  11. dodal/beamlines/i04.py +5 -5
  12. dodal/beamlines/i09.py +22 -1
  13. dodal/beamlines/i09_1.py +9 -1
  14. dodal/beamlines/i09_2.py +24 -0
  15. dodal/beamlines/i10.py +5 -6
  16. dodal/beamlines/i13_1.py +5 -5
  17. dodal/beamlines/i18.py +5 -6
  18. dodal/beamlines/i22.py +7 -1
  19. dodal/beamlines/i24.py +3 -3
  20. dodal/beamlines/p45.py +4 -3
  21. dodal/beamlines/p60.py +18 -1
  22. dodal/beamlines/p99.py +5 -5
  23. dodal/beamlines/training_rig.py +3 -3
  24. dodal/common/beamlines/beamline_utils.py +5 -2
  25. dodal/devices/aithre_lasershaping/goniometer.py +4 -5
  26. dodal/devices/aperture.py +4 -7
  27. dodal/devices/aperturescatterguard.py +2 -2
  28. dodal/devices/b07/__init__.py +3 -0
  29. dodal/devices/b07/grating.py +9 -0
  30. dodal/devices/b07_1/__init__.py +3 -0
  31. dodal/devices/b07_1/grating.py +10 -0
  32. dodal/devices/detector/detector_motion.py +19 -17
  33. dodal/devices/electron_analyser/abstract/base_driver_io.py +24 -25
  34. dodal/devices/electron_analyser/detector.py +3 -13
  35. dodal/devices/electron_analyser/specs/detector.py +9 -3
  36. dodal/devices/electron_analyser/specs/driver_io.py +5 -2
  37. dodal/devices/electron_analyser/vgscienta/detector.py +9 -3
  38. dodal/devices/electron_analyser/vgscienta/driver_io.py +5 -6
  39. dodal/devices/electron_analyser/vgscienta/region.py +0 -1
  40. dodal/devices/fast_grid_scan.py +1 -2
  41. dodal/devices/hutch_shutter.py +6 -6
  42. dodal/devices/i04/constants.py +1 -1
  43. dodal/devices/i09/__init__.py +4 -0
  44. dodal/devices/i09/dcm.py +26 -0
  45. dodal/devices/i09/grating.py +7 -0
  46. dodal/devices/i10/mirrors.py +4 -6
  47. dodal/devices/i10/rasor/rasor_motors.py +0 -14
  48. dodal/devices/i19/beamstop.py +3 -7
  49. dodal/devices/i24/aperture.py +4 -6
  50. dodal/devices/i24/beamstop.py +5 -8
  51. dodal/devices/i24/pmac.py +4 -8
  52. dodal/devices/motors.py +92 -35
  53. dodal/devices/p45.py +0 -12
  54. dodal/devices/p60/__init__.py +3 -0
  55. dodal/devices/p60/lab_xray_source.py +21 -0
  56. dodal/devices/pgm.py +1 -1
  57. dodal/devices/robot.py +11 -7
  58. dodal/devices/smargon.py +8 -9
  59. dodal/devices/zocalo/zocalo_results.py +27 -78
  60. dodal/plans/bimorph.py +333 -0
  61. dodal/plans/configure_arm_trigger_and_disarm_detector.py +7 -5
  62. dodal/devices/adsim.py +0 -13
  63. dodal/devices/i18/table.py +0 -14
  64. dodal/devices/i18/thor_labs_stage.py +0 -12
  65. dodal/devices/i24/i24_detector_motion.py +0 -12
  66. dodal/devices/scatterguard.py +0 -11
  67. dodal/devices/training_rig/__init__.py +0 -0
  68. dodal/devices/training_rig/sample_stage.py +0 -10
  69. {dls_dodal-1.49.0.dist-info → dls_dodal-1.51.0.dist-info}/WHEEL +0 -0
  70. {dls_dodal-1.49.0.dist-info → dls_dodal-1.51.0.dist-info}/entry_points.txt +0 -0
  71. {dls_dodal-1.49.0.dist-info → dls_dodal-1.51.0.dist-info}/licenses/LICENSE +0 -0
  72. {dls_dodal-1.49.0.dist-info → dls_dodal-1.51.0.dist-info}/top_level.txt +0 -0
dodal/plans/bimorph.py ADDED
@@ -0,0 +1,333 @@
1
+ from collections.abc import Generator
2
+ from dataclasses import dataclass
3
+ from enum import Enum
4
+ from typing import Any
5
+
6
+ import bluesky.plan_stubs as bps
7
+ import bluesky.preprocessors as bpp
8
+ from bluesky.protocols import Preparable, Readable
9
+ from bluesky.utils import MsgGenerator
10
+ from numpy import linspace
11
+ from ophyd_async.core import TriggerInfo
12
+
13
+ from dodal.devices.bimorph_mirror import BimorphMirror
14
+ from dodal.devices.slits import Slits
15
+
16
+
17
+ class SlitDimension(str, Enum):
18
+ """Enum representing the dimensions of a 2d slit
19
+
20
+ Used to describe which dimension the pencil beam scan should move across.
21
+ The other dimension will be held constant.
22
+
23
+ Attributes:
24
+ X: Represents X dimension
25
+ Y: Represents Y dimension
26
+ """
27
+
28
+ X = "X"
29
+ Y = "Y"
30
+
31
+
32
+ def move_slits(slits: Slits, dimension: SlitDimension, gap: float, center: float):
33
+ """Moves ones dimension of Slits object to given position.
34
+
35
+ Args:
36
+ slits: Slits to move
37
+ dimension: SlitDimension (X or Y)
38
+ gap: float size of gap
39
+ center: float position of center
40
+ """
41
+ if dimension == SlitDimension.X:
42
+ yield from bps.mv(slits.x_gap, gap)
43
+ yield from bps.mv(slits.x_centre, center)
44
+ else:
45
+ yield from bps.mv(slits.y_gap, gap)
46
+ yield from bps.mv(slits.y_centre, center)
47
+
48
+
49
+ def check_valid_bimorph_state(
50
+ voltage_list: list[float], abs_range: float, abs_diff: float
51
+ ) -> bool:
52
+ """Checks that a set of bimorph voltages is valid.
53
+ Args:
54
+ voltage_list: float amount each actuator will be increased by per scan
55
+ abs_range: float absolute value of maximum possible voltage of each actuator
56
+ abs_diff: float absolute maximum difference between two consecutive actuators
57
+
58
+ Returns:
59
+ Bool representing state validity
60
+ """
61
+ for voltage in voltage_list:
62
+ if abs(voltage) > abs_range:
63
+ return False
64
+
65
+ for i in range(len(voltage_list) - 1):
66
+ if abs(voltage_list[i] - voltage_list[i - 1]) > abs_diff:
67
+ return False
68
+
69
+ return True
70
+
71
+
72
+ def validate_bimorph_plan(
73
+ initial_voltage_list: list[float],
74
+ voltage_increment: float,
75
+ abs_range: float,
76
+ abs_diff: float,
77
+ ) -> bool:
78
+ """Checks that every position the bimorph will move through will not error.
79
+
80
+ Args:
81
+ initial_voltage_list: float list starting position
82
+ voltage_increment: float amount each actuator will be increased by per scan
83
+ abs_range: float absolute value of maximum possible voltage of each actuator
84
+ abs_diff: float absolute maximum difference between two consecutive actuators
85
+
86
+ Raises:
87
+ Exception if the plan will lead to an error state"""
88
+ voltage_list = initial_voltage_list.copy()
89
+
90
+ if not check_valid_bimorph_state(voltage_list, abs_range, abs_diff):
91
+ raise ValueError(f"Bimorph plan reaches invalid state at: {voltage_list}")
92
+
93
+ for i in range(len(initial_voltage_list)):
94
+ voltage_list[i] += voltage_increment
95
+
96
+ if not check_valid_bimorph_state(voltage_list, abs_range, abs_diff):
97
+ raise ValueError(f"Bimorph plan reaches invalid state at: {voltage_list}")
98
+
99
+ return True
100
+
101
+
102
+ @dataclass
103
+ class BimorphState:
104
+ """Data class containing positions of BimorphMirror and Slits"""
105
+
106
+ voltages: list[float]
107
+ x_gap: float
108
+ y_gap: float
109
+ x_center: float
110
+ y_center: float
111
+
112
+
113
+ def capture_bimorph_state(mirror: BimorphMirror, slits: Slits):
114
+ """Plan stub that captures current position of BimorphMirror and Slits.
115
+
116
+ Args:
117
+ mirror: BimorphMirror to read from
118
+ slits: Slits to read from
119
+
120
+ Returns:
121
+ A BimorphState containing BimorphMirror and Slits positions"""
122
+ original_voltage_list = []
123
+
124
+ for channel in mirror.channels.values():
125
+ position = yield from bps.rd(channel.output_voltage)
126
+ original_voltage_list.append(position)
127
+
128
+ original_x_gap = yield from bps.rd(slits.x_gap)
129
+ original_y_gap = yield from bps.rd(slits.y_gap)
130
+ original_x_center = yield from bps.rd(slits.x_centre)
131
+ original_y_center = yield from bps.rd(slits.y_centre)
132
+ return BimorphState(
133
+ original_voltage_list,
134
+ original_x_gap,
135
+ original_y_gap,
136
+ original_x_center,
137
+ original_y_center,
138
+ )
139
+
140
+
141
+ def restore_bimorph_state(mirror: BimorphMirror, slits: Slits, state: BimorphState):
142
+ """Moves BimorphMirror and Slits to state given in BirmophState.
143
+
144
+ Args:
145
+ mirror: BimorphMirror to move
146
+ slits: Slits to move
147
+ state: BimorphState to move to.
148
+ """
149
+ yield from move_slits(slits, SlitDimension.X, state.x_gap, state.x_center)
150
+ yield from move_slits(slits, SlitDimension.Y, state.y_gap, state.y_center)
151
+
152
+ yield from bps.mv(mirror, state.voltages) # type: ignore
153
+
154
+
155
+ def bimorph_position_generator(
156
+ initial_voltage_list: list[float], voltage_increment: float
157
+ ) -> Generator[list[float], None, None]:
158
+ """Generator that produces bimorph positions, starting with the initial_voltage_list.
159
+
160
+ Args:
161
+ initial_voltage_list: list starting position for bimorph
162
+ voltage_increment: float amount to increase each actuator by in turn
163
+
164
+ Yields:
165
+ List bimorph positions, starting with initial_voltage_list
166
+ """
167
+ voltage_list = initial_voltage_list.copy()
168
+
169
+ for i in range(-1, len(initial_voltage_list)):
170
+ yield [
171
+ voltage + voltage_increment if i >= j else voltage
172
+ for (j, voltage) in enumerate(voltage_list)
173
+ ]
174
+
175
+
176
+ def bimorph_optimisation(
177
+ detectors: list[Readable],
178
+ mirror: BimorphMirror,
179
+ slits: Slits,
180
+ voltage_increment: float,
181
+ active_dimension: SlitDimension,
182
+ active_slit_center_start: float,
183
+ active_slit_center_end: float,
184
+ active_slit_size: float,
185
+ inactive_slit_center: float,
186
+ inactive_slit_size: float,
187
+ number_of_slit_positions: int,
188
+ bimorph_settle_time: float,
189
+ slit_settle_time: float,
190
+ initial_voltage_list: list | None = None,
191
+ metadata: dict[str, Any] | None = None,
192
+ ) -> MsgGenerator:
193
+ """Plan for performing bimorph mirror optimisation.
194
+
195
+ Bluesky plan that performs a series of pencil beam scans across one axis of a
196
+ bimorph mirror, of using a 2-dimensional slit.
197
+
198
+ Args:
199
+ detectors: list[Readable] detectors
200
+ bimorph: BimorphMirror to move
201
+ slit: Slits
202
+ voltage_increment: float voltage increment applied to each bimorph electrode
203
+ active_dimension: SlitDimension that slit will move in (X or Y)
204
+ active_slit_center_start: float start position of center of slit in active dimension
205
+ active_slit_center_end: float final position of center of slit in active dimension
206
+ active_slit_size: float size of slit in active dimension
207
+ inactive_slit_center: float center of slit in inactive dimension
208
+ inactive_slit_size: float size of slit in inactive dimension
209
+ number_of_slit_positions: int number of slit positions per pencil beam scan
210
+ bimorph_settle_time: float time in seconds to wait after bimorph move
211
+ slit_settle_time: float time in seconds to wait after slit move
212
+ initial_voltage_list: optional list[float] starting voltages for bimorph (defaults to current voltages)
213
+ metadata: optional dict[str, Any] metadata to add to start document
214
+ """
215
+
216
+ _metadata = {
217
+ "plan_args": {
218
+ "detectors": {det.name for det in detectors},
219
+ "mirror": mirror.name,
220
+ "slits": slits.name,
221
+ "voltage_increment": voltage_increment,
222
+ "active_dimension": active_dimension,
223
+ "active_slit_center_start": active_slit_center_start,
224
+ "active_slit_center_end": active_slit_center_end,
225
+ "active_slit_size": active_slit_size,
226
+ "inactive_slit_center": inactive_slit_center,
227
+ "inactive_slit_size": inactive_slit_size,
228
+ "number_of_slit_positions": number_of_slit_positions,
229
+ "bimorph_settle_time": bimorph_settle_time,
230
+ "slit_settle_time": slit_settle_time,
231
+ "initial_voltage_list": initial_voltage_list,
232
+ },
233
+ "plan_name": "bimorph_optimisation",
234
+ "shape": [len(mirror.channels), number_of_slit_positions],
235
+ **(metadata or {}),
236
+ }
237
+
238
+ state = yield from capture_bimorph_state(mirror, slits)
239
+
240
+ # If a starting set of voltages is not provided, default to current:
241
+ initial_voltage_list = initial_voltage_list or state.voltages
242
+
243
+ bimorph_positions = bimorph_position_generator(
244
+ initial_voltage_list, voltage_increment
245
+ )
246
+
247
+ validate_bimorph_plan(initial_voltage_list, voltage_increment, 1000, 500)
248
+
249
+ inactive_dimension = (
250
+ SlitDimension.Y if active_dimension == SlitDimension.X else SlitDimension.X
251
+ )
252
+
253
+ @bpp.run_decorator(md=_metadata)
254
+ @bpp.stage_decorator((*detectors, mirror, slits))
255
+ def outer_scan():
256
+ """Outer plan stub, which moves mirror and calls inner_scan."""
257
+ for detector in detectors:
258
+ if isinstance(detector, Preparable):
259
+ yield from bps.prepare(detector, TriggerInfo(), wait=True)
260
+
261
+ stream_name = "0"
262
+ yield from bps.declare_stream(*detectors, mirror, slits, name=stream_name)
263
+
264
+ # Move slits into starting position:
265
+ yield from move_slits(
266
+ slits, active_dimension, active_slit_size, active_slit_center_start
267
+ )
268
+ yield from move_slits(
269
+ slits, inactive_dimension, inactive_slit_size, inactive_slit_center
270
+ )
271
+ yield from bps.sleep(slit_settle_time)
272
+
273
+ for bimorph_position in bimorph_positions:
274
+ yield from bps.mv(
275
+ mirror, # type: ignore
276
+ bimorph_position, # type: ignore
277
+ )
278
+ yield from bps.sleep(bimorph_settle_time)
279
+
280
+ yield from bps.declare_stream(*detectors, mirror, slits, name=stream_name)
281
+
282
+ yield from inner_scan(
283
+ detectors,
284
+ mirror,
285
+ slits,
286
+ active_dimension,
287
+ active_slit_center_start,
288
+ active_slit_center_end,
289
+ active_slit_size,
290
+ number_of_slit_positions,
291
+ slit_settle_time,
292
+ stream_name,
293
+ )
294
+
295
+ stream_name = str(int(stream_name) + 1)
296
+
297
+ yield from outer_scan()
298
+
299
+ yield from restore_bimorph_state(mirror, slits, state)
300
+
301
+
302
+ def inner_scan(
303
+ detectors: list[Readable],
304
+ mirror: BimorphMirror,
305
+ slits: Slits,
306
+ active_dimension: SlitDimension,
307
+ active_slit_center_start: float,
308
+ active_slit_center_end: float,
309
+ active_slit_size: float,
310
+ number_of_slit_positions: int,
311
+ slit_settle_time: float,
312
+ stream_name: str,
313
+ ):
314
+ """Inner plan stub, which moves Slits and performs a read.
315
+
316
+ Args:
317
+ mirror: BimorphMirror to move
318
+ slit: Slits
319
+ oav: oav on-axis viewer
320
+ active_dimension: SlitDimension that slit will move in (X or Y)
321
+ active_slit_center_start: float start position of center of slit in active dimension
322
+ active_slit_center_end: float final position of center of slit in active dimension
323
+ active_slit_size: float size of slit in active dimension
324
+ number_of_slit_positions: int number of slit positions per pencil beam scan
325
+ slit_settle_time: float time in seconds to wait after slit move
326
+ stream_name: str name to pass to trigger_and_read
327
+ """
328
+ for value in linspace(
329
+ active_slit_center_start, active_slit_center_end, number_of_slit_positions
330
+ ):
331
+ yield from move_slits(slits, active_dimension, active_slit_size, value)
332
+ yield from bps.sleep(slit_settle_time)
333
+ yield from bps.trigger_and_read([*detectors, mirror, slits], name=stream_name)
@@ -3,8 +3,8 @@ import time
3
3
  import bluesky.plan_stubs as bps
4
4
  from bluesky import preprocessors as bpp
5
5
  from bluesky.run_engine import RunEngine
6
- from ophyd_async.core import DetectorTrigger
7
- from ophyd_async.fastcs.eiger import EigerDetector, EigerTriggerInfo
6
+ from ophyd_async.core import DetectorTrigger, TriggerInfo
7
+ from ophyd_async.fastcs.eiger import EigerDetector
8
8
 
9
9
  from dodal.beamlines.i03 import fastcs_eiger
10
10
  from dodal.devices.detector import DetectorParams
@@ -15,7 +15,7 @@ from dodal.log import LOGGER, do_default_logging_setup
15
15
  def configure_arm_trigger_and_disarm_detector(
16
16
  eiger: EigerDetector,
17
17
  detector_params: DetectorParams,
18
- trigger_info: EigerTriggerInfo,
18
+ trigger_info: TriggerInfo,
19
19
  ):
20
20
  assert detector_params.expected_energy_ev
21
21
  start = time.time()
@@ -132,6 +132,9 @@ def set_mx_settings_pvs(
132
132
  yield from bps.abs_set(
133
133
  eiger.drv.detector.omega_increment, detector_params.omega_increment, group
134
134
  )
135
+ yield from bps.abs_set(
136
+ eiger.drv.detector.photon_energy, detector_params.expected_energy_ev, group
137
+ )
135
138
 
136
139
  if wait:
137
140
  yield from bps.wait(group)
@@ -157,9 +160,8 @@ if __name__ == "__main__":
157
160
  use_roi_mode=False,
158
161
  det_dist_to_beam_converter_path="/dls_sw/i03/software/daq_configuration/lookup/DetDistToBeamXYConverter.txt",
159
162
  ),
160
- trigger_info=EigerTriggerInfo(
163
+ trigger_info=TriggerInfo(
161
164
  number_of_events=1,
162
- energy_ev=12800,
163
165
  trigger=DetectorTrigger.INTERNAL,
164
166
  deadtime=0.0001,
165
167
  ),
dodal/devices/adsim.py DELETED
@@ -1,13 +0,0 @@
1
- from ophyd_async.core import StandardReadable
2
- from ophyd_async.epics.motor import Motor
3
-
4
-
5
- class SimStage(StandardReadable):
6
- """Simulated Sample Stage for use with the containerised simulated beamline
7
- https://github.com/epics-containers/example-services"""
8
-
9
- def __init__(self, prefix: str, name: str = "sim"):
10
- with self.add_children_as_readables():
11
- self.x = Motor(prefix + "M1")
12
- self.y = Motor(prefix + "M2")
13
- super().__init__(name=name)
@@ -1,14 +0,0 @@
1
- from ophyd_async.core import (
2
- StandardReadable,
3
- )
4
- from ophyd_async.epics.motor import Motor
5
-
6
-
7
- class Table(StandardReadable):
8
- def __init__(self, prefix: str, name: str = "") -> None:
9
- with self.add_children_as_readables():
10
- self.x = Motor(prefix + "X")
11
- self.y = Motor(prefix + "Y")
12
- self.z = Motor(prefix + "Z")
13
- self.theta = Motor(prefix + "THETA")
14
- super().__init__(name=name)
@@ -1,12 +0,0 @@
1
- from ophyd_async.core import (
2
- StandardReadable,
3
- )
4
- from ophyd_async.epics.motor import Motor
5
-
6
-
7
- class ThorLabsStage(StandardReadable):
8
- def __init__(self, prefix: str, name: str = "") -> None:
9
- with self.add_children_as_readables():
10
- self.x = Motor(prefix + "X")
11
- self.y = Motor(prefix + "Y")
12
- super().__init__(name=name)
@@ -1,12 +0,0 @@
1
- from ophyd_async.core import StandardReadable
2
- from ophyd_async.epics.motor import Motor
3
-
4
-
5
- class DetectorMotion(StandardReadable):
6
- """Physical motion for detector travel"""
7
-
8
- def __init__(self, prefix: str, name: str = "") -> None:
9
- self.y = Motor(prefix + "Y") # Vertical
10
- self.z = Motor(prefix + "Z") # Beam
11
-
12
- super().__init__(name)
@@ -1,11 +0,0 @@
1
- from ophyd_async.core import StandardReadable
2
- from ophyd_async.epics.motor import Motor
3
-
4
-
5
- class Scatterguard(StandardReadable):
6
- """The scatterguard device."""
7
-
8
- def __init__(self, prefix: str, name: str = "") -> None:
9
- self.x = Motor(prefix + "X")
10
- self.y = Motor(prefix + "Y")
11
- super().__init__(name)
File without changes
@@ -1,10 +0,0 @@
1
- from ophyd_async.core import StandardReadable
2
- from ophyd_async.epics.motor import Motor
3
-
4
-
5
- class TrainingRigSampleStage(StandardReadable):
6
- def __init__(self, prefix: str, name: str = ""):
7
- with self.add_children_as_readables():
8
- self.x = Motor(prefix + "X")
9
- self.theta = Motor(prefix + "A")
10
- super().__init__(name)