mxcubecore 1.403.0__py3-none-any.whl → 1.404.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.
Potentially problematic release.
This version of mxcubecore might be problematic. Click here for more details.
- {mxcubecore-1.403.0.dist-info → mxcubecore-1.404.0.dist-info}/METADATA +1 -1
- {mxcubecore-1.403.0.dist-info → mxcubecore-1.404.0.dist-info}/RECORD +5 -21
- mxcubecore/HardwareObjects/LNLS/EPICSActuator.py +0 -78
- mxcubecore/HardwareObjects/LNLS/EPICSMotor.py +0 -104
- mxcubecore/HardwareObjects/LNLS/EPICSNState.py +0 -87
- mxcubecore/HardwareObjects/LNLS/LNLSAperture.py +0 -69
- mxcubecore/HardwareObjects/LNLS/LNLSBeam.py +0 -125
- mxcubecore/HardwareObjects/LNLS/LNLSCamera.py +0 -507
- mxcubecore/HardwareObjects/LNLS/LNLSCollect.py +0 -482
- mxcubecore/HardwareObjects/LNLS/LNLSDetDistMotor.py +0 -76
- mxcubecore/HardwareObjects/LNLS/LNLSDiffractometer.py +0 -538
- mxcubecore/HardwareObjects/LNLS/LNLSEnergy.py +0 -81
- mxcubecore/HardwareObjects/LNLS/LNLSPilatusDet.py +0 -478
- mxcubecore/HardwareObjects/LNLS/LNLSSlits.py +0 -48
- mxcubecore/HardwareObjects/LNLS/LNLSTransmission.py +0 -82
- mxcubecore/HardwareObjects/LNLS/LNLSZoom.py +0 -93
- mxcubecore/HardwareObjects/LNLS/read_transmission_mnc.py +0 -149
- mxcubecore/HardwareObjects/LNLS/set_transmission_mnc.py +0 -306
- {mxcubecore-1.403.0.dist-info → mxcubecore-1.404.0.dist-info}/COPYING +0 -0
- {mxcubecore-1.403.0.dist-info → mxcubecore-1.404.0.dist-info}/COPYING.LESSER +0 -0
- {mxcubecore-1.403.0.dist-info → mxcubecore-1.404.0.dist-info}/WHEEL +0 -0
|
@@ -1,538 +0,0 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Project name: MXCuBE
|
|
3
|
-
# https://github.com/mxcube.
|
|
4
|
-
#
|
|
5
|
-
# This file is part of MXCuBE software.
|
|
6
|
-
#
|
|
7
|
-
# MXCuBE is free software: you can redistribute it and/or modify
|
|
8
|
-
# it under the terms of the GNU General Public License as published by
|
|
9
|
-
# the Free Software Foundation, either version 3 of the License, or
|
|
10
|
-
# (at your option) any later version.
|
|
11
|
-
#
|
|
12
|
-
# MXCuBE is distributed in the hope that it will be useful,
|
|
13
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
-
# GNU General Public License for more details.
|
|
16
|
-
#
|
|
17
|
-
# You should have received a copy of the GNU General Public License
|
|
18
|
-
# along with MXCuBE. If not, see <http://www.gnu.org/licenses/>.
|
|
19
|
-
|
|
20
|
-
import ast
|
|
21
|
-
import logging
|
|
22
|
-
import random
|
|
23
|
-
import time
|
|
24
|
-
import warnings
|
|
25
|
-
|
|
26
|
-
from gevent.event import AsyncResult
|
|
27
|
-
|
|
28
|
-
from mxcubecore import HardwareRepository as HWR
|
|
29
|
-
from mxcubecore.HardwareObjects.GenericDiffractometer import GenericDiffractometer
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
class LNLSDiffractometer(GenericDiffractometer):
|
|
33
|
-
"""
|
|
34
|
-
Descript. :
|
|
35
|
-
"""
|
|
36
|
-
|
|
37
|
-
def __init__(self, *args):
|
|
38
|
-
"""
|
|
39
|
-
Descript. :
|
|
40
|
-
"""
|
|
41
|
-
GenericDiffractometer.__init__(self, *args)
|
|
42
|
-
|
|
43
|
-
def init(self):
|
|
44
|
-
"""
|
|
45
|
-
Descript. :
|
|
46
|
-
"""
|
|
47
|
-
# self.image_width = 100
|
|
48
|
-
# self.image_height = 100
|
|
49
|
-
|
|
50
|
-
GenericDiffractometer.init(self)
|
|
51
|
-
# Bzoom: 1.86 um/pixel (or 0.00186 mm/pixel) at minimum zoom
|
|
52
|
-
self.x_calib = 0.00186
|
|
53
|
-
self.y_calib = 0.00186
|
|
54
|
-
self.last_centred_position = [318, 238]
|
|
55
|
-
|
|
56
|
-
self.pixels_per_mm_x = 1.0 / self.x_calib
|
|
57
|
-
self.pixels_per_mm_y = 1.0 / self.y_calib
|
|
58
|
-
if "zoom" not in self.motor_hwobj_dict.keys():
|
|
59
|
-
self.motor_hwobj_dict["zoom"] = self.get_object_by_role("zoom")
|
|
60
|
-
calibration_x = self.zoom.getProperty("mm_per_pixel_x")
|
|
61
|
-
calibration_y = self.zoom.getProperty("mm_per_pixel_y")
|
|
62
|
-
self.zoom_calibration_x = ast.literal_eval(calibration_x)
|
|
63
|
-
self.zoom_calibration_y = ast.literal_eval(calibration_y)
|
|
64
|
-
|
|
65
|
-
self.beam_position = [318, 238]
|
|
66
|
-
|
|
67
|
-
self.current_phase = GenericDiffractometer.PHASE_CENTRING
|
|
68
|
-
|
|
69
|
-
self.cancel_centring_methods = {}
|
|
70
|
-
self.current_motor_positions = {
|
|
71
|
-
"phiy": 1.0,
|
|
72
|
-
"sampx": 0.0,
|
|
73
|
-
"sampy": -1.0,
|
|
74
|
-
"zoom": 8.53,
|
|
75
|
-
"focus": -0.42,
|
|
76
|
-
"phiz": 1.1,
|
|
77
|
-
"phi": 311.1,
|
|
78
|
-
"kappa": 11,
|
|
79
|
-
"kappa_phi": 22.0,
|
|
80
|
-
}
|
|
81
|
-
# self.move_motors(self._get_random_centring_position())
|
|
82
|
-
|
|
83
|
-
self.current_state_dict = {}
|
|
84
|
-
self.centring_status = {"valid": False}
|
|
85
|
-
self.centring_time = 0
|
|
86
|
-
|
|
87
|
-
# self.image_width = 400
|
|
88
|
-
# self.image_height = 400
|
|
89
|
-
|
|
90
|
-
self.mount_mode = self.getProperty("sample_mount_mode")
|
|
91
|
-
if self.mount_mode is None:
|
|
92
|
-
self.mount_mode = "manual"
|
|
93
|
-
|
|
94
|
-
self.equipment_ready()
|
|
95
|
-
|
|
96
|
-
# TODO FFS get this cleared up - one function, one name
|
|
97
|
-
self.getPositions = self.get_positions
|
|
98
|
-
# self.moveMotors = self.move_motors
|
|
99
|
-
|
|
100
|
-
self.connect(
|
|
101
|
-
self.motor_hwobj_dict["phi"], "positionChanged", self.phi_motor_moved
|
|
102
|
-
)
|
|
103
|
-
self.connect(
|
|
104
|
-
self.motor_hwobj_dict["phiy"], "positionChanged", self.phiy_motor_moved
|
|
105
|
-
)
|
|
106
|
-
self.connect(
|
|
107
|
-
self.motor_hwobj_dict["phiz"], "positionChanged", self.phiz_motor_moved
|
|
108
|
-
)
|
|
109
|
-
self.connect(
|
|
110
|
-
self.motor_hwobj_dict["kappa"], "positionChanged", self.kappa_motor_moved
|
|
111
|
-
)
|
|
112
|
-
self.connect(
|
|
113
|
-
self.motor_hwobj_dict["kappa_phi"],
|
|
114
|
-
"positionChanged",
|
|
115
|
-
self.kappa_phi_motor_moved,
|
|
116
|
-
)
|
|
117
|
-
self.connect(
|
|
118
|
-
self.motor_hwobj_dict["sampx"], "positionChanged", self.sampx_motor_moved
|
|
119
|
-
)
|
|
120
|
-
self.connect(
|
|
121
|
-
self.motor_hwobj_dict["sampy"], "positionChanged", self.sampy_motor_moved
|
|
122
|
-
)
|
|
123
|
-
|
|
124
|
-
def getStatus(self):
|
|
125
|
-
"""
|
|
126
|
-
Descript. :
|
|
127
|
-
"""
|
|
128
|
-
return "ready"
|
|
129
|
-
|
|
130
|
-
def execute_server_task(self, method, timeout=30, *args):
|
|
131
|
-
return
|
|
132
|
-
|
|
133
|
-
def in_plate_mode(self):
|
|
134
|
-
return self.mount_mode == "plate"
|
|
135
|
-
|
|
136
|
-
def use_sample_changer(self):
|
|
137
|
-
return self.mount_mode == "sample_changer"
|
|
138
|
-
|
|
139
|
-
def is_reversing_rotation(self):
|
|
140
|
-
return True
|
|
141
|
-
|
|
142
|
-
def get_grid_direction(self):
|
|
143
|
-
"""
|
|
144
|
-
Descript. :
|
|
145
|
-
"""
|
|
146
|
-
return self.grid_direction
|
|
147
|
-
|
|
148
|
-
def manual_centring(self):
|
|
149
|
-
"""
|
|
150
|
-
Descript. :
|
|
151
|
-
"""
|
|
152
|
-
for click in range(3):
|
|
153
|
-
self.user_clicked_event = AsyncResult()
|
|
154
|
-
x, y = self.user_clicked_event.get()
|
|
155
|
-
if click < 2:
|
|
156
|
-
self.motor_hwobj_dict["phi"].set_value_relative(90)
|
|
157
|
-
self.last_centred_position[0] = x
|
|
158
|
-
self.last_centred_position[1] = y
|
|
159
|
-
centred_pos_dir = self._get_random_centring_position()
|
|
160
|
-
return centred_pos_dir
|
|
161
|
-
|
|
162
|
-
def automatic_centring(self):
|
|
163
|
-
"""Automatic centring procedure"""
|
|
164
|
-
centred_pos_dir = self._get_random_centring_position()
|
|
165
|
-
self.emit("newAutomaticCentringPoint", centred_pos_dir)
|
|
166
|
-
return centred_pos_dir
|
|
167
|
-
|
|
168
|
-
def _get_random_centring_position(self):
|
|
169
|
-
"""Get random centring result for current positions"""
|
|
170
|
-
|
|
171
|
-
# Names of motors to vary during centring
|
|
172
|
-
vary_motor_names = ("sampx", "sampy", "phiy")
|
|
173
|
-
|
|
174
|
-
# Range of random variation
|
|
175
|
-
var_range = 0.08
|
|
176
|
-
|
|
177
|
-
# absolute value limit for varied motors
|
|
178
|
-
var_limit = 2.0
|
|
179
|
-
|
|
180
|
-
result = self.current_motor_positions.copy()
|
|
181
|
-
for tag in vary_motor_names:
|
|
182
|
-
val = result.get(tag)
|
|
183
|
-
if val is not None:
|
|
184
|
-
random_num = random.random()
|
|
185
|
-
var = (random_num - 0.5) * var_range
|
|
186
|
-
val += var
|
|
187
|
-
if abs(val) > var_limit:
|
|
188
|
-
val *= 1 - var_range / var_limit
|
|
189
|
-
result[tag] = val
|
|
190
|
-
return result
|
|
191
|
-
|
|
192
|
-
def is_ready(self):
|
|
193
|
-
"""
|
|
194
|
-
Descript. :
|
|
195
|
-
"""
|
|
196
|
-
return True
|
|
197
|
-
|
|
198
|
-
def isValid(self):
|
|
199
|
-
"""
|
|
200
|
-
Descript. :
|
|
201
|
-
"""
|
|
202
|
-
return True
|
|
203
|
-
|
|
204
|
-
def invalidate_centring(self):
|
|
205
|
-
"""
|
|
206
|
-
Descript. :
|
|
207
|
-
"""
|
|
208
|
-
if self.current_centring_procedure is None and self.centring_status["valid"]:
|
|
209
|
-
self.centring_status = {"valid": False}
|
|
210
|
-
# self.emitProgressMessage("")
|
|
211
|
-
self.emit("centringInvalid", ())
|
|
212
|
-
|
|
213
|
-
def get_centred_point_from_coord(self, x, y, return_by_names=None):
|
|
214
|
-
"""
|
|
215
|
-
Descript. :
|
|
216
|
-
"""
|
|
217
|
-
centred_pos_dir = self._get_random_centring_position()
|
|
218
|
-
return centred_pos_dir
|
|
219
|
-
|
|
220
|
-
def get_calibration_data(self, offset):
|
|
221
|
-
"""
|
|
222
|
-
Descript. :
|
|
223
|
-
"""
|
|
224
|
-
# return (1.0 / self.x_calib, 1.0 / self.y_calib)
|
|
225
|
-
return (1.0 / self.x_calib, 1.0 / self.y_calib)
|
|
226
|
-
|
|
227
|
-
def refresh_omega_reference_position(self):
|
|
228
|
-
"""
|
|
229
|
-
Descript. :
|
|
230
|
-
"""
|
|
231
|
-
return
|
|
232
|
-
|
|
233
|
-
# def get_omega_axis_position(self):
|
|
234
|
-
# """
|
|
235
|
-
# Descript. :
|
|
236
|
-
# """
|
|
237
|
-
# return self.current_positions_dict.get("phi")
|
|
238
|
-
|
|
239
|
-
def beam_position_changed(self, value):
|
|
240
|
-
"""
|
|
241
|
-
Descript. :
|
|
242
|
-
"""
|
|
243
|
-
self.beam_position = value
|
|
244
|
-
|
|
245
|
-
def get_current_centring_method(self):
|
|
246
|
-
"""
|
|
247
|
-
Descript. :
|
|
248
|
-
"""
|
|
249
|
-
return self.current_centring_method
|
|
250
|
-
|
|
251
|
-
def motor_positions_to_screen(self, centred_positions_dict):
|
|
252
|
-
"""
|
|
253
|
-
Descript. :
|
|
254
|
-
"""
|
|
255
|
-
return self.last_centred_position[0], self.last_centred_position[1]
|
|
256
|
-
|
|
257
|
-
def moveToCentredPosition(self, centred_position, wait=False):
|
|
258
|
-
"""
|
|
259
|
-
Descript. :
|
|
260
|
-
"""
|
|
261
|
-
try:
|
|
262
|
-
return self.move_to_centred_position(centred_position)
|
|
263
|
-
except BaseException:
|
|
264
|
-
logging.exception("Could not move to centred position")
|
|
265
|
-
|
|
266
|
-
def phi_motor_moved(self, pos):
|
|
267
|
-
"""
|
|
268
|
-
Descript. :
|
|
269
|
-
"""
|
|
270
|
-
self.current_motor_positions["phi"] = pos
|
|
271
|
-
self.emit("phiMotorMoved", pos)
|
|
272
|
-
|
|
273
|
-
def phiy_motor_moved(self, pos):
|
|
274
|
-
self.current_motor_positions["phiy"] = pos
|
|
275
|
-
|
|
276
|
-
def phiz_motor_moved(self, pos):
|
|
277
|
-
self.current_motor_positions["phiz"] = pos
|
|
278
|
-
|
|
279
|
-
def sampx_motor_moved(self, pos):
|
|
280
|
-
self.current_motor_positions["sampx"] = pos
|
|
281
|
-
|
|
282
|
-
def sampy_motor_moved(self, pos):
|
|
283
|
-
self.current_motor_positions["sampy"] = pos
|
|
284
|
-
|
|
285
|
-
def kappa_motor_moved(self, pos):
|
|
286
|
-
"""
|
|
287
|
-
Descript. :
|
|
288
|
-
"""
|
|
289
|
-
self.current_motor_positions["kappa"] = pos
|
|
290
|
-
if time.time() - self.centring_time > 1.0:
|
|
291
|
-
self.invalidate_centring()
|
|
292
|
-
self.emit_diffractometer_moved()
|
|
293
|
-
self.emit("kappaMotorMoved", pos)
|
|
294
|
-
|
|
295
|
-
def kappa_phi_motor_moved(self, pos):
|
|
296
|
-
"""
|
|
297
|
-
Descript. :
|
|
298
|
-
"""
|
|
299
|
-
self.current_motor_positions["kappa_phi"] = pos
|
|
300
|
-
if time.time() - self.centring_time > 1.0:
|
|
301
|
-
self.invalidate_centring()
|
|
302
|
-
self.emit_diffractometer_moved()
|
|
303
|
-
self.emit("kappaPhiMotorMoved", pos)
|
|
304
|
-
|
|
305
|
-
def refresh_video(self):
|
|
306
|
-
"""
|
|
307
|
-
Descript. :
|
|
308
|
-
"""
|
|
309
|
-
self.emit("minidiffStateChanged", "testState")
|
|
310
|
-
if HWR.beamline.beam:
|
|
311
|
-
HWR.beamline.beam.beam_pos_hor_changed(300)
|
|
312
|
-
HWR.beamline.beam.beam_pos_ver_changed(200)
|
|
313
|
-
|
|
314
|
-
def start_auto_focus(self):
|
|
315
|
-
"""
|
|
316
|
-
Descript. :
|
|
317
|
-
"""
|
|
318
|
-
return
|
|
319
|
-
|
|
320
|
-
def calculate_move_to_beam_pos(self, x, y):
|
|
321
|
-
"""
|
|
322
|
-
Descript. : calculate motor positions to put sample on the beam.
|
|
323
|
-
Returns: dict of motor positions
|
|
324
|
-
"""
|
|
325
|
-
# Update beam position
|
|
326
|
-
self.beam_position[0], self.beam_position[1] = (
|
|
327
|
-
HWR.beamline.beam.get_beam_position_on_screen()
|
|
328
|
-
)
|
|
329
|
-
|
|
330
|
-
print(
|
|
331
|
-
(
|
|
332
|
-
"moving to beam position: %d %d"
|
|
333
|
-
% (
|
|
334
|
-
self.beam_position[0],
|
|
335
|
-
self.beam_position[1],
|
|
336
|
-
)
|
|
337
|
-
)
|
|
338
|
-
)
|
|
339
|
-
|
|
340
|
-
# Set velocity of omega to move during centring
|
|
341
|
-
# self.set_omega_default_velocity()
|
|
342
|
-
|
|
343
|
-
# Set scale of pixels per mm according to current zoom
|
|
344
|
-
# self.pixels_per_mm_x = self.motor_zoom_hwobj.getPixelsPerMm(0)
|
|
345
|
-
# self.pixels_per_mm_y = self.motor_zoom_hwobj.getPixelsPerMm(1)
|
|
346
|
-
|
|
347
|
-
# Get clicked position of mouse pointer
|
|
348
|
-
# self.user_clicked_event = AsyncResult()
|
|
349
|
-
# x, y = self.user_clicked_event.get()
|
|
350
|
-
# Last clicked position
|
|
351
|
-
self.last_centred_position[0] = x
|
|
352
|
-
self.last_centred_position[1] = y
|
|
353
|
-
|
|
354
|
-
# Get current value of involved motors
|
|
355
|
-
omega_pos = self.motor_hwobj_dict["phi"].get_value()
|
|
356
|
-
# For now, phiz refers to gonio x motor
|
|
357
|
-
goniox_pos = self.motor_hwobj_dict["phiz"].get_value()
|
|
358
|
-
sampx_pos = self.motor_hwobj_dict["sampx"].get_value()
|
|
359
|
-
sampy_pos = self.motor_hwobj_dict["sampy"].get_value()
|
|
360
|
-
|
|
361
|
-
# Pixels to move axis X of whole goniometer
|
|
362
|
-
import math
|
|
363
|
-
|
|
364
|
-
drx_goniox = abs(-x - y + 1152) / math.sqrt(2)
|
|
365
|
-
if y <= (-x + 1152):
|
|
366
|
-
dir_goniox = 1
|
|
367
|
-
else:
|
|
368
|
-
dir_goniox = -1
|
|
369
|
-
move_goniox = dir_goniox * drx_goniox
|
|
370
|
-
# mm to move
|
|
371
|
-
move_goniox = move_goniox / self.pixels_per_mm_x
|
|
372
|
-
|
|
373
|
-
# Move absolute
|
|
374
|
-
move_goniox += goniox_pos
|
|
375
|
-
|
|
376
|
-
# Calculate new position of X
|
|
377
|
-
dry_samp = abs(x - y - 128) / math.sqrt(2)
|
|
378
|
-
if y >= x - 128:
|
|
379
|
-
dir_samp = 1
|
|
380
|
-
else:
|
|
381
|
-
dir_samp = -1
|
|
382
|
-
move_samp = dir_samp * dry_samp
|
|
383
|
-
print("move_samp = " + str(move_samp))
|
|
384
|
-
|
|
385
|
-
move_sampx = math.sin(math.radians(omega_pos)) * move_samp
|
|
386
|
-
# print("math.cos(math.radians(omega_pos)): ", math.cos(math.radians(omega_pos)))
|
|
387
|
-
# print("self.beam_position[1]: ", self.beam_position[1])
|
|
388
|
-
# print("float(last_centred_position[1])", float(last_centred_position[1]))
|
|
389
|
-
# print("move_sampx = (math.cos(math.radians(omega_pos)) * (self.beam_position[1] - float(last_centred_position[1]))): ", move_sampx)
|
|
390
|
-
# move_sampx = move_sampx / self.pixels_per_mm_x
|
|
391
|
-
move_sampx = (move_sampx / self.pixels_per_mm_x) * -1
|
|
392
|
-
# print("move_sampx = move_sampx / self.pixels_per_mm_x: ", move_sampx)
|
|
393
|
-
# Move absolute
|
|
394
|
-
move_sampx += sampx_pos
|
|
395
|
-
# print("move_sampx += sampx_pos: ", move_sampx)
|
|
396
|
-
|
|
397
|
-
# Calculate new position of Y
|
|
398
|
-
move_sampy = math.cos(math.radians(omega_pos)) * move_samp
|
|
399
|
-
# print("math.sin(math.radians(omega_pos)): ", math.sin(math.radians(omega_pos)))
|
|
400
|
-
# print("self.beam_position[1]: ", self.beam_position[1])
|
|
401
|
-
# print("float(last_centred_position[1])", float(last_centred_position[1]))
|
|
402
|
-
# print("move_sampy = (math.sin(math.radians(omega_pos)) * (self.beam_position[1] - float(last_centred_position[1]))): ", move_sampy)
|
|
403
|
-
move_sampy = move_sampy / self.pixels_per_mm_y
|
|
404
|
-
print("move_sampy = " + str(move_sampy))
|
|
405
|
-
# move_sampy = move_sampy / self.pixels_per_mm_y
|
|
406
|
-
# print("move_sampy = move_sampy / self.pixels_per_mm_y: ", move_sampy)
|
|
407
|
-
# Move absolute
|
|
408
|
-
move_sampy += sampy_pos
|
|
409
|
-
# print("move_sampy += sampy_pos: ", move_sampy)
|
|
410
|
-
centred_pos_dir = {
|
|
411
|
-
"phiz": move_goniox,
|
|
412
|
-
"sampx": move_sampx,
|
|
413
|
-
"sampy": move_sampy,
|
|
414
|
-
}
|
|
415
|
-
print("Target pos = " + str(centred_pos_dir))
|
|
416
|
-
return centred_pos_dir
|
|
417
|
-
|
|
418
|
-
def move_to_beam(self, x, y, omega=None):
|
|
419
|
-
"""
|
|
420
|
-
Descript. : function to create a centring point based on all motors
|
|
421
|
-
positions.
|
|
422
|
-
"""
|
|
423
|
-
|
|
424
|
-
centred_pos_dir = self.calculate_move_to_beam_pos(x, y)
|
|
425
|
-
print("Moving motors to beam...")
|
|
426
|
-
self.move_to_motors_positions(centred_pos_dir, wait=True)
|
|
427
|
-
return centred_pos_dir
|
|
428
|
-
|
|
429
|
-
def move_to_coord(self, x, y, omega=None):
|
|
430
|
-
"""
|
|
431
|
-
Descript. : function to create a centring point based on all motors
|
|
432
|
-
positions.
|
|
433
|
-
"""
|
|
434
|
-
warnings.warn(
|
|
435
|
-
"Deprecated method, call move_to_beam instead", DeprecationWarning
|
|
436
|
-
)
|
|
437
|
-
return self.move_to_beam(x, y, omega)
|
|
438
|
-
|
|
439
|
-
def start_move_to_beam(self, coord_x=None, coord_y=None, omega=None):
|
|
440
|
-
"""
|
|
441
|
-
Descript. :
|
|
442
|
-
"""
|
|
443
|
-
self.last_centred_position[0] = coord_x
|
|
444
|
-
self.last_centred_position[1] = coord_y
|
|
445
|
-
self.centring_time = time.time()
|
|
446
|
-
curr_time = time.strftime("%Y-%m-%d %H:%M:%S")
|
|
447
|
-
self.centring_status = {
|
|
448
|
-
"valid": True,
|
|
449
|
-
"startTime": curr_time,
|
|
450
|
-
"endTime": curr_time,
|
|
451
|
-
}
|
|
452
|
-
motors = self.get_positions()
|
|
453
|
-
motors["beam_x"] = 0.1
|
|
454
|
-
motors["beam_y"] = 0.1
|
|
455
|
-
self.last_centred_position[0] = coord_x
|
|
456
|
-
self.last_centred_position[1] = coord_y
|
|
457
|
-
self.centring_status["motors"] = motors
|
|
458
|
-
self.centring_status["valid"] = True
|
|
459
|
-
self.centring_status["angleLimit"] = False
|
|
460
|
-
self.emit_progress_message("")
|
|
461
|
-
self.accept_centring()
|
|
462
|
-
self.current_centring_method = None
|
|
463
|
-
self.current_centring_procedure = None
|
|
464
|
-
|
|
465
|
-
def update_values(self):
|
|
466
|
-
self.emit("zoomMotorPredefinedPositionChanged", None, None)
|
|
467
|
-
omega_ref = [0, 238]
|
|
468
|
-
self.emit("omegaReferenceChanged", omega_ref)
|
|
469
|
-
|
|
470
|
-
def move_kappa_and_phi(self, kappa, kappa_phi):
|
|
471
|
-
return
|
|
472
|
-
|
|
473
|
-
def get_osc_max_speed(self):
|
|
474
|
-
return 66
|
|
475
|
-
|
|
476
|
-
def get_osc_limits(self):
|
|
477
|
-
if self.in_plate_mode:
|
|
478
|
-
return (170, 190)
|
|
479
|
-
else:
|
|
480
|
-
return (-360, 360)
|
|
481
|
-
|
|
482
|
-
def get_scan_limits(self, speed=None, num_images=None, exp_time=None):
|
|
483
|
-
if self.in_plate_mode:
|
|
484
|
-
return (170, 190)
|
|
485
|
-
else:
|
|
486
|
-
return (-360, 360)
|
|
487
|
-
|
|
488
|
-
def get_osc_dynamic_limits(self):
|
|
489
|
-
"""Returns dynamic limits of oscillation axis"""
|
|
490
|
-
return (0, 20)
|
|
491
|
-
|
|
492
|
-
def get_scan_dynamic_limits(self, speed=None):
|
|
493
|
-
return (-360, 360)
|
|
494
|
-
|
|
495
|
-
def move_omega_relative(self, relative_angle):
|
|
496
|
-
self.motor_hwobj_dict["phi"].syncMoveRelative(relative_angle, 5)
|
|
497
|
-
|
|
498
|
-
def set_phase(self, phase, timeout=None):
|
|
499
|
-
self.current_phase = str(phase)
|
|
500
|
-
self.emit("minidiffPhaseChanged", (self.current_phase,))
|
|
501
|
-
|
|
502
|
-
def get_point_from_line(self, point_one, point_two, index, images_num):
|
|
503
|
-
return point_one.as_dict()
|
|
504
|
-
|
|
505
|
-
@property
|
|
506
|
-
def zoom(self):
|
|
507
|
-
"""
|
|
508
|
-
Override method.
|
|
509
|
-
"""
|
|
510
|
-
return self.motor_hwobj_dict.get("zoom")
|
|
511
|
-
|
|
512
|
-
def get_zoom_calibration(self):
|
|
513
|
-
"""Returns tuple with current zoom calibration (px per mm)."""
|
|
514
|
-
zoom_enum = self.zoom.get_value() # Get current zoom enum
|
|
515
|
-
zoom_enum_str = zoom_enum.name # as str
|
|
516
|
-
self.x_calib = self.zoom_calibration_x.get(zoom_enum_str)
|
|
517
|
-
self.y_calib = self.zoom_calibration_y.get(zoom_enum_str)
|
|
518
|
-
try:
|
|
519
|
-
float(self.x_calib)
|
|
520
|
-
float(self.y_calib)
|
|
521
|
-
self.pixels_per_mm_x = 1.0 / self.x_calib
|
|
522
|
-
self.pixels_per_mm_y = 1.0 / self.y_calib
|
|
523
|
-
except Exception as e:
|
|
524
|
-
print("[Zoom] Error on calibration: " + str(e))
|
|
525
|
-
return (self.pixels_per_mm_x, self.pixels_per_mm_y)
|
|
526
|
-
|
|
527
|
-
def get_pixels_per_mm(self):
|
|
528
|
-
"""
|
|
529
|
-
Override method.
|
|
530
|
-
"""
|
|
531
|
-
pixels_per_mm_x, pixels_per_mm_y = self.get_zoom_calibration()
|
|
532
|
-
return (pixels_per_mm_x, pixels_per_mm_y)
|
|
533
|
-
|
|
534
|
-
def update_zoom_calibration(self):
|
|
535
|
-
"""
|
|
536
|
-
Override method.
|
|
537
|
-
"""
|
|
538
|
-
self.emit("pixelsPerMmChanged", ((self.pixels_per_mm_x, self.pixels_per_mm_y)))
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Project name: MXCuBE
|
|
3
|
-
# https://github.com/mxcube.
|
|
4
|
-
#
|
|
5
|
-
# This file is part of MXCuBE software.
|
|
6
|
-
#
|
|
7
|
-
# MXCuBE is free software: you can redistribute it and/or modify
|
|
8
|
-
# it under the terms of the GNU Lesser General Public License as published by
|
|
9
|
-
# the Free Software Foundation, either version 3 of the License, or
|
|
10
|
-
# (at your option) any later version.
|
|
11
|
-
#
|
|
12
|
-
# MXCuBE is distributed in the hope that it will be useful,
|
|
13
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
-
# GNU Lesser General Public License for more details.
|
|
16
|
-
#
|
|
17
|
-
# You should have received a copy of the GNU General Lesser Public License
|
|
18
|
-
# along with MXCuBE. If not, see <http://www.gnu.org/licenses/>.
|
|
19
|
-
|
|
20
|
-
"""LNLS Energy"""
|
|
21
|
-
|
|
22
|
-
from mxcubecore.HardwareObjects.abstract.AbstractEnergy import AbstractEnergy
|
|
23
|
-
from mxcubecore.HardwareObjects.LNLS.EPICSActuator import EPICSActuator
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
class LNLSEnergy(EPICSActuator, AbstractEnergy):
|
|
27
|
-
"""LNLSEnergy class"""
|
|
28
|
-
|
|
29
|
-
def init(self):
|
|
30
|
-
"""Initialise default properties"""
|
|
31
|
-
super(LNLSEnergy, self).init()
|
|
32
|
-
self.update_state(self.STATES.READY)
|
|
33
|
-
self.detector = self.get_object_by_role("detector")
|
|
34
|
-
|
|
35
|
-
def set_value(self):
|
|
36
|
-
"""Override method."""
|
|
37
|
-
pass
|
|
38
|
-
|
|
39
|
-
def get_value(self):
|
|
40
|
-
"""Read the actuator position.
|
|
41
|
-
Returns:
|
|
42
|
-
float: Actuator position.
|
|
43
|
-
"""
|
|
44
|
-
value = super().get_value()
|
|
45
|
-
# Nominal value stores last energy value with valid threshold energy
|
|
46
|
-
# if abs(self._nominal_value - value) < 0.001:
|
|
47
|
-
# self.log.info("Pilatus threshold is still okay.")
|
|
48
|
-
# return value
|
|
49
|
-
|
|
50
|
-
threshold_ok = self.check_threshold_energy(value)
|
|
51
|
-
if threshold_ok:
|
|
52
|
-
self._nominal_value = value
|
|
53
|
-
else:
|
|
54
|
-
value = None # Invalid energy because threshold is invalid
|
|
55
|
-
|
|
56
|
-
return value
|
|
57
|
-
|
|
58
|
-
def check_threshold_energy(self, energy):
|
|
59
|
-
"""Returns whether detector threshold energy is valid or not."""
|
|
60
|
-
|
|
61
|
-
# self.log.info(
|
|
62
|
-
# "Checking Pilatus threshold. Please wait..."
|
|
63
|
-
# )
|
|
64
|
-
# for i in range(3):
|
|
65
|
-
# logging.getLogger("user_level_log").info(
|
|
66
|
-
# "Checking Pilatus threshold. Please wait..."
|
|
67
|
-
# )
|
|
68
|
-
threshold_ok = self.detector.set_threshold_energy(energy)
|
|
69
|
-
|
|
70
|
-
if threshold_ok:
|
|
71
|
-
self.log.info("Pilatus threshold is okay.")
|
|
72
|
-
# logging.getLogger("user_level_log").info(
|
|
73
|
-
# "Pilatus threshold is okay."
|
|
74
|
-
# )
|
|
75
|
-
return True
|
|
76
|
-
|
|
77
|
-
self.log.error("Pilatus threshold is not okay.")
|
|
78
|
-
# logging.getLogger("user_level_log").error(
|
|
79
|
-
# "Pilatus threshold is not okay."
|
|
80
|
-
# )
|
|
81
|
-
return False
|