pymodaq_plugins_andor 5.0.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.
- pymodaq_plugins_andor/__init__.py +13 -0
- pymodaq_plugins_andor/daq_move_plugins/__init__.py +14 -0
- pymodaq_plugins_andor/daq_move_plugins/daq_move_Shamrock.py +241 -0
- pymodaq_plugins_andor/daq_viewer_plugins/__init__.py +0 -0
- pymodaq_plugins_andor/daq_viewer_plugins/plugins_0D/__init__.py +14 -0
- pymodaq_plugins_andor/daq_viewer_plugins/plugins_1D/__init__.py +14 -0
- pymodaq_plugins_andor/daq_viewer_plugins/plugins_1D/daq_1Dviewer_ShamrockCCD.py +186 -0
- pymodaq_plugins_andor/daq_viewer_plugins/plugins_1D/daq_1Dviewer_ShamrockCCDComposition.py +197 -0
- pymodaq_plugins_andor/daq_viewer_plugins/plugins_1D/daq_1Dviewer_ShamrockSCMOS.py +248 -0
- pymodaq_plugins_andor/daq_viewer_plugins/plugins_1D/daq_1Dviewer_ShamrockSCMOSComposition.py +259 -0
- pymodaq_plugins_andor/daq_viewer_plugins/plugins_2D/__init__.py +15 -0
- pymodaq_plugins_andor/daq_viewer_plugins/plugins_2D/daq_2Dviewer_AndorCCD.py +572 -0
- pymodaq_plugins_andor/daq_viewer_plugins/plugins_2D/daq_2Dviewer_AndorSCMOS.py +714 -0
- pymodaq_plugins_andor/hardware/__init__.py +0 -0
- pymodaq_plugins_andor/hardware/andor_sdk2/__init__.py +0 -0
- pymodaq_plugins_andor/hardware/andor_sdk2/sdk2.py +1148 -0
- pymodaq_plugins_andor/hardware/andor_sdk3/__init__.py +24 -0
- pymodaq_plugins_andor/hardware/andor_sdk3/api.py +285 -0
- pymodaq_plugins_andor/hardware/andor_sdk3/sdk3.py +326 -0
- pymodaq_plugins_andor/hardware/andor_sdk3/sdk3cam.py +182 -0
- pymodaq_plugins_andor/hardware/andor_sdk3/testNeo.py +97 -0
- pymodaq_plugins_andor/hardware/shamrock_sdk.py +250 -0
- pymodaq_plugins_andor/resources/__init__.py +0 -0
- pymodaq_plugins_andor/resources/config_template.toml +2 -0
- pymodaq_plugins_andor/utils.py +15 -0
- pymodaq_plugins_andor-5.0.0.dist-info/METADATA +93 -0
- pymodaq_plugins_andor-5.0.0.dist-info/RECORD +30 -0
- pymodaq_plugins_andor-5.0.0.dist-info/WHEEL +4 -0
- pymodaq_plugins_andor-5.0.0.dist-info/entry_points.txt +5 -0
- pymodaq_plugins_andor-5.0.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
from pymodaq_utils.logger import set_logger, get_module_name
|
|
4
|
+
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from .utils import Config
|
|
7
|
+
from pymodaq_utils.utils import get_version, PackageNotFoundError
|
|
8
|
+
|
|
9
|
+
config = Config()
|
|
10
|
+
try:
|
|
11
|
+
__version__ = get_version(__package__)
|
|
12
|
+
except PackageNotFoundError:
|
|
13
|
+
__version__ = '0.0.0dev'
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import importlib
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from .. import set_logger
|
|
4
|
+
|
|
5
|
+
logger = set_logger('move_plugins', add_to_console=False)
|
|
6
|
+
|
|
7
|
+
for path in Path(__file__).parent.iterdir():
|
|
8
|
+
try:
|
|
9
|
+
if '__init__' not in str(path):
|
|
10
|
+
importlib.import_module('.' + path.stem, __package__)
|
|
11
|
+
except Exception as e:
|
|
12
|
+
logger.warning("{:} plugin couldn't be loaded due to some missing packages or errors: {:}".format(path.stem, str(e)))
|
|
13
|
+
pass
|
|
14
|
+
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
|
|
2
|
+
from easydict import EasyDict as edict
|
|
3
|
+
from pymodaq.control_modules.move_utility_classes import DAQ_Move_base, comon_parameters_fun, main
|
|
4
|
+
from pymodaq_utils.utils import ThreadCommand
|
|
5
|
+
from pymodaq_plugins_andor.hardware import shamrock_sdk
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
libpath = shamrock_sdk.dllpath
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class DAQ_Move_Shamrock(DAQ_Move_base):
|
|
12
|
+
|
|
13
|
+
_controller_units = 'nm'
|
|
14
|
+
is_multiaxes = False
|
|
15
|
+
axes_names = [] # "list of strings of the multiaxes
|
|
16
|
+
_epsilon = 0.1
|
|
17
|
+
|
|
18
|
+
params = [
|
|
19
|
+
{'title': 'Dll library:', 'name': 'andor_lib', 'type': 'browsepath', 'value': str(libpath), 'readonly': True},
|
|
20
|
+
{'title': 'Spectro Settings:', 'name': 'spectro_settings', 'type': 'group', 'expanded': True,
|
|
21
|
+
'children': [
|
|
22
|
+
{'title': 'Spectro SN:', 'name': 'spectro_serialnumber', 'type': 'str', 'value': '',
|
|
23
|
+
'readonly': True},
|
|
24
|
+
{'title': 'Wavelength (nm):', 'name': 'spectro_wl', 'type': 'float', 'value': 600, 'min': 0,
|
|
25
|
+
'readonly': True},
|
|
26
|
+
{'title': 'Home Wavelength (nm):', 'name': 'spectro_wl_home', 'type': 'float', 'value': 600, 'min': 0,
|
|
27
|
+
'readonly': False},
|
|
28
|
+
{'title': 'Grating Settings:', 'name': 'grating_settings', 'type': 'group', 'expanded': True,
|
|
29
|
+
'children': [
|
|
30
|
+
{'title': 'Grating:', 'name': 'grating', 'type': 'list'},
|
|
31
|
+
{'title': 'Lines (/mm):', 'name': 'lines', 'type': 'int', 'readonly': True},
|
|
32
|
+
{'title': 'Blaze WL (nm):', 'name': 'blaze', 'type': 'str', 'readonly': True},
|
|
33
|
+
]},
|
|
34
|
+
{'title': 'Flip wavelength axis:', 'name': 'flip_wavelength', 'type': 'bool', 'value': False,
|
|
35
|
+
'visible': False},
|
|
36
|
+
{'title': 'Go to zero order:', 'name': 'zero_order', 'type': 'bool'},
|
|
37
|
+
]},
|
|
38
|
+
] + comon_parameters_fun(is_multiaxes, axes_names, epsilon=_epsilon)
|
|
39
|
+
|
|
40
|
+
def commit_settings(self, param):
|
|
41
|
+
"""
|
|
42
|
+
| Activate parameters changes on the hardware from parameter's name.
|
|
43
|
+
|
|
|
44
|
+
|
|
45
|
+
=============== ================================ =========================
|
|
46
|
+
**Parameters** **Type** **Description**
|
|
47
|
+
*param* instance of pyqtgraph parameter The parameter to activate
|
|
48
|
+
=============== ================================ =========================
|
|
49
|
+
|
|
50
|
+
Three profile of parameter :
|
|
51
|
+
* **bin_x** : set binning camera from bin_x parameter's value
|
|
52
|
+
* **bin_y** : set binning camera from bin_y parameter's value
|
|
53
|
+
* **set_point** : Set the camera's temperature from parameter's value.
|
|
54
|
+
|
|
55
|
+
"""
|
|
56
|
+
try:
|
|
57
|
+
if param.name() == 'grating':
|
|
58
|
+
index_grating = self.grating_list.index(param.value())
|
|
59
|
+
self.get_set_grating(index_grating)
|
|
60
|
+
self.set_wavelength(self.settings.child('spectro_settings', 'spectro_wl').value())
|
|
61
|
+
|
|
62
|
+
elif param.name() == 'spectro_wl':
|
|
63
|
+
self.set_wavelength(param.value())
|
|
64
|
+
|
|
65
|
+
elif param.name() == 'zero_order':
|
|
66
|
+
if param.value():
|
|
67
|
+
param.setValue(False)
|
|
68
|
+
self.emit_status(ThreadCommand('show_splash', "Moving to zero order, please wait!"))
|
|
69
|
+
err = self.shamrock_controller.GotoZeroOrderSR(0)
|
|
70
|
+
if err != 'SHAMROCK_SUCCESS':
|
|
71
|
+
raise Exception(err)
|
|
72
|
+
self.check_position()
|
|
73
|
+
self.emit_status(ThreadCommand('close_splash'))
|
|
74
|
+
|
|
75
|
+
except Exception as e:
|
|
76
|
+
self.emit_status(ThreadCommand('Update_Status', [str(e), 'log']))
|
|
77
|
+
|
|
78
|
+
def ini_stage(self, controller=None):
|
|
79
|
+
"""Actuator communication initialization
|
|
80
|
+
|
|
81
|
+
Parameters
|
|
82
|
+
----------
|
|
83
|
+
controller: (object) custom object of a PyMoDAQ plugin (Slave case). None if only one actuator by controller (Master case)
|
|
84
|
+
|
|
85
|
+
Returns
|
|
86
|
+
-------
|
|
87
|
+
self.status (edict): with initialization status: three fields:
|
|
88
|
+
* info (str)
|
|
89
|
+
* controller (object) initialized controller
|
|
90
|
+
*initialized: (bool): False if initialization failed otherwise True
|
|
91
|
+
"""
|
|
92
|
+
self.shamrock_controller = self.ini_stage_init(old_controller=controller,
|
|
93
|
+
new_controller=shamrock_sdk.ShamrockSDK())
|
|
94
|
+
|
|
95
|
+
self.emit_status(ThreadCommand('show_splash', "Set/Get Shamrock's settings"))
|
|
96
|
+
self.ini_spectro()
|
|
97
|
+
|
|
98
|
+
initialized = True
|
|
99
|
+
self.emit_status(ThreadCommand('close_splash'))
|
|
100
|
+
return '', initialized
|
|
101
|
+
|
|
102
|
+
def get_actuator_value(self):
|
|
103
|
+
"""Get the current position from the hardware with scaling conversion.
|
|
104
|
+
|
|
105
|
+
Returns
|
|
106
|
+
-------
|
|
107
|
+
float: The position obtained after scaling conversion.
|
|
108
|
+
"""
|
|
109
|
+
pos = self.get_wavelength()
|
|
110
|
+
##
|
|
111
|
+
|
|
112
|
+
pos = self.get_position_with_scaling(pos)
|
|
113
|
+
return pos
|
|
114
|
+
|
|
115
|
+
def move_abs(self, position):
|
|
116
|
+
""" Move the actuator to the absolute target defined by position
|
|
117
|
+
|
|
118
|
+
Parameters
|
|
119
|
+
----------
|
|
120
|
+
position: (flaot) value of the absolute target positioning
|
|
121
|
+
"""
|
|
122
|
+
|
|
123
|
+
position = self.check_bound(position) # if user checked bounds, the defined bounds are applied here
|
|
124
|
+
position = self.set_position_with_scaling(position) # apply scaling if the user specified one
|
|
125
|
+
|
|
126
|
+
self.set_wavelength(position)
|
|
127
|
+
|
|
128
|
+
##############################
|
|
129
|
+
|
|
130
|
+
self.target_position = position
|
|
131
|
+
self.poll_moving() # start a loop to poll the current actuator value and compare it with target position
|
|
132
|
+
|
|
133
|
+
def move_rel(self, position):
|
|
134
|
+
""" Move the actuator to the relative target actuator value defined by position
|
|
135
|
+
|
|
136
|
+
Parameters
|
|
137
|
+
----------
|
|
138
|
+
position: (flaot) value of the relative target positioning
|
|
139
|
+
"""
|
|
140
|
+
position = self.check_bound(self.current_position + position) - self.current_position
|
|
141
|
+
self.target_position = position + self.current_position
|
|
142
|
+
|
|
143
|
+
self.set_wavelength(self.target_position)
|
|
144
|
+
##############################
|
|
145
|
+
|
|
146
|
+
self.poll_moving()
|
|
147
|
+
|
|
148
|
+
def move_home(self):
|
|
149
|
+
"""
|
|
150
|
+
|
|
151
|
+
"""
|
|
152
|
+
self.move_abs(self.settings.child('spectro_settings', 'spectro_wl_home').value())
|
|
153
|
+
|
|
154
|
+
def stop_motion(self):
|
|
155
|
+
"""
|
|
156
|
+
Call the specific move_done function (depending on the hardware).
|
|
157
|
+
|
|
158
|
+
See Also
|
|
159
|
+
--------
|
|
160
|
+
move_done
|
|
161
|
+
"""
|
|
162
|
+
|
|
163
|
+
self.move_done() # to let the interface know the actuator stopped. Direct call as the setwavelength call is
|
|
164
|
+
# blocking anyway
|
|
165
|
+
|
|
166
|
+
def close(self):
|
|
167
|
+
"""
|
|
168
|
+
|
|
169
|
+
"""
|
|
170
|
+
if self.shamrock_controller is not None:
|
|
171
|
+
self.shamrock_controller.close()
|
|
172
|
+
|
|
173
|
+
def set_wavelength(self, wavelength):
|
|
174
|
+
self.emit_status(ThreadCommand('show_splash', "Setting wavelength, please wait!"))
|
|
175
|
+
err = self.shamrock_controller.SetWavelengthSR(0, wavelength)
|
|
176
|
+
self.emit_status(ThreadCommand('close_splash'))
|
|
177
|
+
|
|
178
|
+
if err != 'SHAMROCK_SUCCESS':
|
|
179
|
+
raise IOError(err)
|
|
180
|
+
|
|
181
|
+
self.get_wavelength()
|
|
182
|
+
|
|
183
|
+
def get_wavelength(self):
|
|
184
|
+
err, wl = self.shamrock_controller.GetWavelengthSR(0)
|
|
185
|
+
if err == "SHAMROCK_SUCCESS":
|
|
186
|
+
self.settings.child('spectro_settings', 'spectro_wl').setValue(wl)
|
|
187
|
+
return float(wl)
|
|
188
|
+
|
|
189
|
+
def ini_spectro(self):
|
|
190
|
+
self.settings.child('spectro_settings', 'spectro_serialnumber').setValue(
|
|
191
|
+
self.shamrock_controller.GetSerialNumberSR(0)[1].decode())
|
|
192
|
+
|
|
193
|
+
# get grating info
|
|
194
|
+
(err, Ngratings) = self.shamrock_controller.GetNumberGratingsSR(0)
|
|
195
|
+
self.grating_list = []
|
|
196
|
+
for ind_grating in range(1, Ngratings + 1):
|
|
197
|
+
(err, lines, blaze, home, offset) = self.shamrock_controller.GetGratingInfoSR(0, ind_grating)
|
|
198
|
+
self.grating_list.append(str(int(lines)))
|
|
199
|
+
|
|
200
|
+
self.settings.child('spectro_settings', 'grating_settings', 'grating').setLimits(self.grating_list)
|
|
201
|
+
err, ind_grating = self.shamrock_controller.GetGratingSR(0)
|
|
202
|
+
self.settings.child('spectro_settings', 'grating_settings', 'grating').setValue(
|
|
203
|
+
self.grating_list[ind_grating - 1])
|
|
204
|
+
|
|
205
|
+
self.get_set_grating(ind_grating - 1)
|
|
206
|
+
|
|
207
|
+
def get_set_grating(self, ind_grating):
|
|
208
|
+
"""
|
|
209
|
+
set the current grating to ind_grating+1. ind_grating corresponds to the index in the GUI graitng list while the SDK index starts at 1...
|
|
210
|
+
|
|
211
|
+
"""
|
|
212
|
+
self.emit_status(ThreadCommand('show_splash', "Moving grating please wait"))
|
|
213
|
+
err = self.shamrock_controller.SetGratingSR(0, ind_grating + 1)
|
|
214
|
+
err, ind_grating = self.shamrock_controller.GetGratingSR(0)
|
|
215
|
+
|
|
216
|
+
(err, lines, blaze, home, offset) = self.shamrock_controller.GetGratingInfoSR(0, ind_grating)
|
|
217
|
+
self.settings.child('spectro_settings', 'grating_settings', 'grating').setValue(
|
|
218
|
+
self.grating_list[ind_grating - 1])
|
|
219
|
+
self.settings.child('spectro_settings', 'grating_settings', 'lines').setValue(lines)
|
|
220
|
+
self.settings.child('spectro_settings', 'grating_settings', 'blaze').setValue(blaze)
|
|
221
|
+
|
|
222
|
+
(err, wl_min, wl_max) = self.shamrock_controller.GetWavelengthLimitsSR(0, ind_grating)
|
|
223
|
+
|
|
224
|
+
if err == "SHAMROCK_SUCCESS":
|
|
225
|
+
self.settings.child('spectro_settings',
|
|
226
|
+
'spectro_wl').setOpts(limits=(wl_min, wl_max),
|
|
227
|
+
tip=f'Possible values are within {wl_min} and {wl_max} for'
|
|
228
|
+
f' the selected grating')
|
|
229
|
+
self.settings.child('spectro_settings',
|
|
230
|
+
'spectro_wl_home').setOpts(limits=(wl_min, wl_max),
|
|
231
|
+
tip=f'Possible values are within {wl_min} and {wl_max} for'
|
|
232
|
+
f' the selected grating')
|
|
233
|
+
|
|
234
|
+
self.emit_status(ThreadCommand('close_splash'))
|
|
235
|
+
|
|
236
|
+
def stop(self):
|
|
237
|
+
pass
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
if __name__ == '__main__':
|
|
241
|
+
main(__file__, True)
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import importlib
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from ... import set_logger, get_module_name
|
|
4
|
+
|
|
5
|
+
logger = set_logger('move_plugins', add_to_console=False)
|
|
6
|
+
|
|
7
|
+
for path in Path(__file__).parent.iterdir():
|
|
8
|
+
try:
|
|
9
|
+
if '__init__' not in str(path):
|
|
10
|
+
importlib.import_module('.' + path.stem, __package__)
|
|
11
|
+
except Exception as e:
|
|
12
|
+
logger.warning("{:} plugin couldn't be loaded due to some missing packages or errors: {:}".format(path.stem, str(e)))
|
|
13
|
+
pass
|
|
14
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import importlib
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from ... import set_logger, get_module_name
|
|
4
|
+
|
|
5
|
+
logger = set_logger('move_plugins', add_to_console=False)
|
|
6
|
+
|
|
7
|
+
for path in Path(__file__).parent.iterdir():
|
|
8
|
+
try:
|
|
9
|
+
if '__init__' not in str(path):
|
|
10
|
+
importlib.import_module('.' + path.stem, __package__)
|
|
11
|
+
except Exception as e:
|
|
12
|
+
logger.warning("{:} plugin couldn't be loaded due to some missing packages or errors: {:}".format(path.stem, str(e)))
|
|
13
|
+
pass
|
|
14
|
+
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
from qtpy import QtWidgets
|
|
3
|
+
|
|
4
|
+
from pymodaq_utils.logger import set_logger, get_module_name
|
|
5
|
+
from pymodaq_utils.utils import ThreadCommand, find_dict_in_list_from_key_val
|
|
6
|
+
|
|
7
|
+
from pymodaq_gui.parameter import utils as putils
|
|
8
|
+
|
|
9
|
+
from pymodaq.utils.data import Axis, DataFromPlugins
|
|
10
|
+
from pymodaq.control_modules.viewer_utility_classes import main
|
|
11
|
+
|
|
12
|
+
from pymodaq_plugins_andor.daq_viewer_plugins.plugins_2D.daq_2Dviewer_AndorCCD import DAQ_2DViewer_AndorCCD
|
|
13
|
+
from pymodaq_plugins_andor.daq_move_plugins.daq_move_Shamrock import DAQ_Move_Shamrock
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
logger = set_logger(get_module_name(__file__))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class DAQ_1DViewer_ShamrockCCD(DAQ_2DViewer_AndorCCD, DAQ_Move_Shamrock):
|
|
20
|
+
"""
|
|
21
|
+
=============== ==================
|
|
22
|
+
|
|
23
|
+
=============== ==================
|
|
24
|
+
|
|
25
|
+
See Also
|
|
26
|
+
--------
|
|
27
|
+
utility_classes.DAQ_Viewer_base
|
|
28
|
+
"""
|
|
29
|
+
param_camera = DAQ_2DViewer_AndorCCD.params
|
|
30
|
+
params_shamrock = DAQ_Move_Shamrock.params
|
|
31
|
+
putils.get_param_dict_from_name(params_shamrock, 'andor_lib', pop=True)
|
|
32
|
+
|
|
33
|
+
d = putils.get_param_dict_from_name(params_shamrock, 'spectro_wl')
|
|
34
|
+
if d is not None:
|
|
35
|
+
d['readonly'] = False
|
|
36
|
+
d = putils.get_param_dict_from_name(params_shamrock, 'flip_wavelength')
|
|
37
|
+
if d is not None:
|
|
38
|
+
d['visible'] = True
|
|
39
|
+
|
|
40
|
+
params = [{'title': 'Get Calibration:', 'name': 'get_calib', 'type': 'bool_push', 'value': False,
|
|
41
|
+
'label': 'Update!'}] + param_camera + params_shamrock
|
|
42
|
+
|
|
43
|
+
def __init__(self, parent=None, params_state=None):
|
|
44
|
+
DAQ_Move_Shamrock.__init__(self, parent, params_state)
|
|
45
|
+
DAQ_2DViewer_AndorCCD.__init__(self, parent, params_state)
|
|
46
|
+
|
|
47
|
+
self.camera_controller = None # this will be the controller attribute of the DAQ_2DViewer_AndorCCD instance
|
|
48
|
+
self.shamrock_controller = None # this will be the controller attribute of the DAQ_Move_Shamrock instance
|
|
49
|
+
# both plugins don't have the generic controller name 'controller' but specific one for this reason
|
|
50
|
+
|
|
51
|
+
self.x_axis: Axis = None
|
|
52
|
+
self.is_calibrated = False
|
|
53
|
+
|
|
54
|
+
def commit_settings(self, param):
|
|
55
|
+
|
|
56
|
+
if param.name() == 'flip_wavelength':
|
|
57
|
+
self.get_xaxis()
|
|
58
|
+
elif 'camera_settings' in putils.get_param_path(param):
|
|
59
|
+
DAQ_2DViewer_AndorCCD.commit_settings(self, param)
|
|
60
|
+
elif 'spectro_settings' in putils.get_param_path(param):
|
|
61
|
+
DAQ_Move_Shamrock.commit_settings(self, param)
|
|
62
|
+
QtWidgets.QApplication.processEvents()
|
|
63
|
+
if param.name() == 'spectro_wl':
|
|
64
|
+
self.is_calibrated = False
|
|
65
|
+
self.get_xaxis()
|
|
66
|
+
elif param.name() == 'zero_order':
|
|
67
|
+
self.is_calibrated = False
|
|
68
|
+
elif param.name() == 'flip_wavelength':
|
|
69
|
+
self.get_xaxis()
|
|
70
|
+
elif param.name() == 'readout' or param.name() in \
|
|
71
|
+
putils.iter_children(self.settings.child('camera_settings', 'readout_settings')):
|
|
72
|
+
self.get_xaxis()
|
|
73
|
+
elif param.name() == 'get_calib':
|
|
74
|
+
if param.value():
|
|
75
|
+
self.get_xaxis()
|
|
76
|
+
param.setValue(False)
|
|
77
|
+
|
|
78
|
+
def ini_detector(self, controller=None):
|
|
79
|
+
_, shamrock_initialized = DAQ_Move_Shamrock.ini_stage(self, controller)
|
|
80
|
+
QtWidgets.QApplication.processEvents()
|
|
81
|
+
# if status_shamrock.initialized:
|
|
82
|
+
# self.move_Home()
|
|
83
|
+
|
|
84
|
+
_, camera_initialized = DAQ_2DViewer_AndorCCD.ini_detector(self, controller)
|
|
85
|
+
QtWidgets.QApplication.processEvents()
|
|
86
|
+
|
|
87
|
+
initialized = shamrock_initialized and camera_initialized
|
|
88
|
+
|
|
89
|
+
self.setCalibration()
|
|
90
|
+
#self.emit_status(ThreadCommand('close_splash'))
|
|
91
|
+
return '', initialized
|
|
92
|
+
|
|
93
|
+
def setCalibration(self):
|
|
94
|
+
#setNpixels
|
|
95
|
+
width, height = self.get_pixel_size()
|
|
96
|
+
err = self.shamrock_controller.SetNumberPixelsSR(0, self.get_ROI_size_x())
|
|
97
|
+
err = self.shamrock_controller.SetPixelWidthSR(0, width)
|
|
98
|
+
|
|
99
|
+
self.get_wavelength()
|
|
100
|
+
self.x_axis = self.get_xaxis()
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def getCalibration(self):
|
|
104
|
+
|
|
105
|
+
if self.shamrock_controller is not None:
|
|
106
|
+
(err, calib) = self.shamrock_controller.GetCalibrationSR(0, self.get_ROI_size_x())
|
|
107
|
+
if err != "SHAMROCK_SUCCESS":
|
|
108
|
+
raise Exception(err)
|
|
109
|
+
|
|
110
|
+
calib = np.array(calib)
|
|
111
|
+
else:
|
|
112
|
+
raise(Exception('controller not defined'))
|
|
113
|
+
self.is_calibrated = True
|
|
114
|
+
return calib
|
|
115
|
+
|
|
116
|
+
def get_xaxis(self):
|
|
117
|
+
"""
|
|
118
|
+
Obtain the horizontal axis of the image.
|
|
119
|
+
|
|
120
|
+
Returns
|
|
121
|
+
-------
|
|
122
|
+
1D numpy array
|
|
123
|
+
Contains a vector of integer corresponding to the horizontal camera pixels.
|
|
124
|
+
"""
|
|
125
|
+
|
|
126
|
+
if np.abs(self.settings.child('spectro_settings', 'spectro_wl').value()) < 1e-3:
|
|
127
|
+
DAQ_2DViewer_AndorCCD.get_xaxis(self)
|
|
128
|
+
else:
|
|
129
|
+
calib = self.getCalibration()
|
|
130
|
+
|
|
131
|
+
if (calib.astype('int') != 0).all(): # check if calib values are equal to zero
|
|
132
|
+
if self.settings.child('spectro_settings', 'flip_wavelength').value():
|
|
133
|
+
calib = calib[::-1]
|
|
134
|
+
|
|
135
|
+
else:
|
|
136
|
+
self.settings.child('spectro_settings', 'flip_wavelength').setValue(False)
|
|
137
|
+
#self.emit_status(ThreadCommand('Update_Status', ['Impossible to flip wavelength', "log"]))
|
|
138
|
+
|
|
139
|
+
self.x_axis = Axis(data=calib, label='Wavelength (nm)')
|
|
140
|
+
return self.x_axis
|
|
141
|
+
|
|
142
|
+
def get_exposure_ms(self):
|
|
143
|
+
#for compatibility with PyMoDAQ Spectro module
|
|
144
|
+
self.emit_status(ThreadCommand('exposure_ms', [self.settings.child('camera_settings', 'exposure').value()]))
|
|
145
|
+
|
|
146
|
+
def set_exposure_ms(self, exposure):
|
|
147
|
+
self.settings.child('camera_settings', 'exposure').setValue(exposure)
|
|
148
|
+
QtWidgets.QApplication.processEvents()
|
|
149
|
+
self.emit_status(ThreadCommand('exposure_ms', [self.settings.child('camera_settings', 'exposure').value()]))
|
|
150
|
+
|
|
151
|
+
def stop(self):
|
|
152
|
+
DAQ_2DViewer_AndorCCD.stop(self)
|
|
153
|
+
|
|
154
|
+
def close(self):
|
|
155
|
+
if self.camera_controller is not None:
|
|
156
|
+
DAQ_2DViewer_AndorCCD.stop(self)
|
|
157
|
+
if self.shamrock_controller is not None:
|
|
158
|
+
DAQ_Move_Shamrock.stop(self)
|
|
159
|
+
|
|
160
|
+
def grab_data(self, Naverage=1, **kwargs):
|
|
161
|
+
if not self.is_calibrated:
|
|
162
|
+
self.get_xaxis()
|
|
163
|
+
DAQ_2DViewer_AndorCCD.grab_data(self, Naverage, **kwargs)
|
|
164
|
+
|
|
165
|
+
def emit_data(self):
|
|
166
|
+
"""
|
|
167
|
+
overloadded function from DAQ_2DViewer_AndorCCD
|
|
168
|
+
"""
|
|
169
|
+
try:
|
|
170
|
+
self.ind_grabbed += 1
|
|
171
|
+
sizey = self.settings.child('camera_settings', 'image_size', 'Ny').value()
|
|
172
|
+
sizex = self.settings.child('camera_settings', 'image_size', 'Nx').value()
|
|
173
|
+
self.camera_controller.GetAcquiredDataNumpy(self.data_pointer, sizex * sizey)
|
|
174
|
+
self.data_grabed_signal.emit([DataFromPlugins(name='Camera',
|
|
175
|
+
data=[np.squeeze(
|
|
176
|
+
self.data.reshape((sizey, sizex)).astype(float))],
|
|
177
|
+
dim=self.data_shape,
|
|
178
|
+
axes=[self.x_axis]),])
|
|
179
|
+
QtWidgets.QApplication.processEvents() # here to be sure the timeevents are executed even if in continuous grab mode
|
|
180
|
+
|
|
181
|
+
except Exception as e:
|
|
182
|
+
self.emit_status(ThreadCommand('Update_Status', [str(e), 'log']))
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
if __name__ == '__main__':
|
|
186
|
+
main(__file__, True)
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
from qtpy import QtWidgets
|
|
3
|
+
|
|
4
|
+
from pymodaq_utils.logger import set_logger, get_module_name
|
|
5
|
+
from pymodaq_utils.utils import ThreadCommand, find_dict_in_list_from_key_val
|
|
6
|
+
|
|
7
|
+
from pymodaq_gui.parameter import utils as putils
|
|
8
|
+
|
|
9
|
+
from pymodaq.utils.data import Axis, DataFromPlugins, DataToExport
|
|
10
|
+
from pymodaq.control_modules.viewer_utility_classes import main, DAQ_Viewer_base, comon_parameters
|
|
11
|
+
|
|
12
|
+
from pymodaq_plugins_andor.daq_viewer_plugins.plugins_2D.daq_2Dviewer_AndorCCD import DAQ_2DViewer_AndorCCD
|
|
13
|
+
from pymodaq_plugins_andor.daq_move_plugins.daq_move_Shamrock import DAQ_Move_Shamrock
|
|
14
|
+
|
|
15
|
+
logger = set_logger(get_module_name(__file__))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class DAQ_1DViewer_ShamrockCCDComposition(DAQ_2DViewer_AndorCCD):
|
|
19
|
+
"""
|
|
20
|
+
=============== ==================
|
|
21
|
+
|
|
22
|
+
=============== ==================
|
|
23
|
+
|
|
24
|
+
See Also
|
|
25
|
+
--------
|
|
26
|
+
utility_classes.DAQ_Viewer_base
|
|
27
|
+
"""
|
|
28
|
+
param_camera = DAQ_2DViewer_AndorCCD.params
|
|
29
|
+
params_shamrock = DAQ_Move_Shamrock.params
|
|
30
|
+
putils.get_param_dict_from_name(params_shamrock, 'andor_lib', pop=True)
|
|
31
|
+
|
|
32
|
+
d = putils.get_param_dict_from_name(params_shamrock, 'spectro_wl')
|
|
33
|
+
if d is not None:
|
|
34
|
+
d['readonly'] = False
|
|
35
|
+
d = putils.get_param_dict_from_name(params_shamrock, 'flip_wavelength')
|
|
36
|
+
if d is not None:
|
|
37
|
+
d['visible'] = True
|
|
38
|
+
|
|
39
|
+
params = [{'title': 'Get Calibration:', 'name': 'get_calib', 'type': 'bool_push', 'value': False,
|
|
40
|
+
'label': 'Update!'},] + param_camera + [
|
|
41
|
+
{'title': 'Shamrock Settings:', 'name': 'sham_settings', 'type': 'group', 'children': params_shamrock},
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def ini_attributes(self):
|
|
46
|
+
self.controller: DAQ_2DViewer_AndorCCD = None
|
|
47
|
+
self.shamrock_controller: DAQ_Move_Shamrock = None
|
|
48
|
+
|
|
49
|
+
self.x_axis: Axis = None
|
|
50
|
+
self.is_calibrated = False
|
|
51
|
+
|
|
52
|
+
super().ini_attributes()
|
|
53
|
+
|
|
54
|
+
def commit_settings(self, param):
|
|
55
|
+
|
|
56
|
+
if param.name() == 'flip_wavelength':
|
|
57
|
+
self.get_xaxis()
|
|
58
|
+
elif 'camera_settings' in putils.get_param_path(param):
|
|
59
|
+
super().commit_settings(param)
|
|
60
|
+
elif 'spectro_settings' in putils.get_param_path(param):
|
|
61
|
+
self.shamrock_controller.commit_settings(param)
|
|
62
|
+
QtWidgets.QApplication.processEvents()
|
|
63
|
+
if param.name() == 'spectro_wl':
|
|
64
|
+
self.is_calibrated = False
|
|
65
|
+
self.get_xaxis()
|
|
66
|
+
elif param.name() == 'zero_order':
|
|
67
|
+
self.is_calibrated = False
|
|
68
|
+
elif param.name() == 'flip_wavelength':
|
|
69
|
+
self.get_xaxis()
|
|
70
|
+
elif param.name() == 'readout' or param.name() in \
|
|
71
|
+
putils.iter_children(self.settings.child('camera_settings', 'readout_settings')):
|
|
72
|
+
self.get_xaxis()
|
|
73
|
+
elif param.name() == 'get_calib':
|
|
74
|
+
if param.value():
|
|
75
|
+
self.get_xaxis()
|
|
76
|
+
param.setValue(False)
|
|
77
|
+
|
|
78
|
+
def ini_detector(self, controller=None):
|
|
79
|
+
cam_status, cam_init = super().ini_detector(controller)
|
|
80
|
+
QtWidgets.QApplication.processEvents()
|
|
81
|
+
|
|
82
|
+
self.shamrock_controller = DAQ_Move_Shamrock(None, self.settings.child('sham_settings').saveState())
|
|
83
|
+
self.shamrock_controller.settings = self.settings.child('sham_settings')
|
|
84
|
+
self.shamrock_controller.emit_status = self.emit_status
|
|
85
|
+
sham_status, sham_init = self.shamrock_controller.ini_stage(controller)
|
|
86
|
+
|
|
87
|
+
QtWidgets.QApplication.processEvents()
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
initialized = sham_init and cam_init
|
|
91
|
+
|
|
92
|
+
self.setCalibration()
|
|
93
|
+
return sham_status + cam_status, initialized
|
|
94
|
+
|
|
95
|
+
def setCalibration(self):
|
|
96
|
+
#setNpixels
|
|
97
|
+
width, height = self.get_pixel_size()
|
|
98
|
+
err = self.shamrock_controller.controller.SetNumberPixelsSR(0, self.get_ROI_size_x())
|
|
99
|
+
err = self.shamrock_controller.controller.SetPixelWidthSR(0, width)
|
|
100
|
+
|
|
101
|
+
self.shamrock_controller.get_wavelength()
|
|
102
|
+
self.x_axis = self.get_xaxis()
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def getCalibration(self):
|
|
106
|
+
|
|
107
|
+
if self.shamrock_controller is not None and self.shamrock_controller.controller is not None:
|
|
108
|
+
(err, calib) = self.shamrock_controller.controller.GetCalibrationSR(0, self.get_ROI_size_x())
|
|
109
|
+
if err != "SHAMROCK_SUCCESS":
|
|
110
|
+
raise Exception(err)
|
|
111
|
+
|
|
112
|
+
calib = np.array(calib)
|
|
113
|
+
else:
|
|
114
|
+
raise(Exception('controller not defined'))
|
|
115
|
+
self.is_calibrated = True
|
|
116
|
+
return calib
|
|
117
|
+
|
|
118
|
+
def get_xaxis(self):
|
|
119
|
+
"""
|
|
120
|
+
Obtain the horizontal axis of the image.
|
|
121
|
+
|
|
122
|
+
Returns
|
|
123
|
+
-------
|
|
124
|
+
1D numpy array
|
|
125
|
+
Contains a vector of integer corresponding to the horizontal camera pixels.
|
|
126
|
+
"""
|
|
127
|
+
|
|
128
|
+
if self.shamrock_controller is None or np.abs(self.settings.child('sham_settings', 'spectro_settings', 'spectro_wl').value()) < 1e-3:
|
|
129
|
+
nx = self.get_ROI_size_x()
|
|
130
|
+
calib = np.linspace(0, nx, nx-1)
|
|
131
|
+
self.x_axis = Axis(data=calib, label='Wavelength (nm)')
|
|
132
|
+
else:
|
|
133
|
+
calib = self.getCalibration()
|
|
134
|
+
|
|
135
|
+
if (calib.astype('int') != 0).all(): # check if calib values are equal to zero
|
|
136
|
+
if self.settings.child('sham_settings', 'spectro_settings', 'flip_wavelength').value():
|
|
137
|
+
calib = calib[::-1]
|
|
138
|
+
|
|
139
|
+
else:
|
|
140
|
+
self.settings.child('sham_settings', 'spectro_settings', 'flip_wavelength').setValue(False)
|
|
141
|
+
#self.emit_status(ThreadCommand('Update_Status', ['Impossible to flip wavelength', "log"]))
|
|
142
|
+
|
|
143
|
+
self.x_axis = Axis(data=calib, label='Wavelength (nm)')
|
|
144
|
+
return self.x_axis
|
|
145
|
+
|
|
146
|
+
def get_exposure_ms(self):
|
|
147
|
+
#for compatibility with PyMoDAQ Spectro module
|
|
148
|
+
self.emit_status(ThreadCommand('exposure_ms', [self.settings.child('camera_settings', 'exposure').value()]))
|
|
149
|
+
|
|
150
|
+
def set_exposure_ms(self, exposure):
|
|
151
|
+
self.settings.child('camera_settings', 'exposure').setValue(exposure)
|
|
152
|
+
QtWidgets.QApplication.processEvents()
|
|
153
|
+
self.emit_status(ThreadCommand('exposure_ms', [self.settings.child('camera_settings', 'exposure').value()]))
|
|
154
|
+
|
|
155
|
+
def stop(self):
|
|
156
|
+
if self.controller is not None:
|
|
157
|
+
super().stop()
|
|
158
|
+
if self.shamrock_controller is not None:
|
|
159
|
+
self.shamrock_controller.stop()
|
|
160
|
+
|
|
161
|
+
def close(self):
|
|
162
|
+
self.stop()
|
|
163
|
+
if self.shamrock_controller is not None:
|
|
164
|
+
self.shamrock_controller.close()
|
|
165
|
+
super().close()
|
|
166
|
+
|
|
167
|
+
def grab_data(self, Naverage=1, **kwargs):
|
|
168
|
+
if not self.is_calibrated:
|
|
169
|
+
self.get_xaxis()
|
|
170
|
+
super().grab_data( Naverage, **kwargs)
|
|
171
|
+
|
|
172
|
+
def emit_data(self):
|
|
173
|
+
"""
|
|
174
|
+
overloadded function from DAQ_2DViewer_AndorCCD
|
|
175
|
+
"""
|
|
176
|
+
try:
|
|
177
|
+
self.ind_grabbed += 1
|
|
178
|
+
sizey = self.settings.child('camera_settings', 'image_size', 'Ny').value()
|
|
179
|
+
sizex = self.settings.child('camera_settings', 'image_size', 'Nx').value()
|
|
180
|
+
self.controller.GetAcquiredDataNumpy(self.data_pointer, sizex * sizey)
|
|
181
|
+
self.dte_signal.emit(
|
|
182
|
+
DataToExport('Spectro',
|
|
183
|
+
data=[
|
|
184
|
+
DataFromPlugins(name='Camera',
|
|
185
|
+
data=[np.atleast_1d(np.squeeze(self.data.reshape(
|
|
186
|
+
(sizey, sizex)))).astype(float)],
|
|
187
|
+
dim=self.data_shape,
|
|
188
|
+
axes=[self.x_axis]),
|
|
189
|
+
]))
|
|
190
|
+
QtWidgets.QApplication.processEvents() # here to be sure the timeevents are executed even if in continuous grab mode
|
|
191
|
+
|
|
192
|
+
except Exception as e:
|
|
193
|
+
self.emit_status(ThreadCommand('Update_Status', [str(e), 'log']))
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
if __name__ == '__main__':
|
|
197
|
+
main(__file__, True)
|