pymodaq 5.1.6__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/__init__.py +98 -0
- pymodaq/control_modules/__init__.py +1 -0
- pymodaq/control_modules/daq_move.py +1238 -0
- pymodaq/control_modules/daq_move_ui/__init__.py +0 -0
- pymodaq/control_modules/daq_move_ui/factory.py +48 -0
- pymodaq/control_modules/daq_move_ui/ui_base.py +359 -0
- pymodaq/control_modules/daq_move_ui/uis/__init__.py +0 -0
- pymodaq/control_modules/daq_move_ui/uis/binary.py +139 -0
- pymodaq/control_modules/daq_move_ui/uis/original.py +120 -0
- pymodaq/control_modules/daq_move_ui/uis/relative.py +124 -0
- pymodaq/control_modules/daq_move_ui/uis/simple.py +126 -0
- pymodaq/control_modules/daq_viewer.py +1517 -0
- pymodaq/control_modules/daq_viewer_ui.py +407 -0
- pymodaq/control_modules/mocks.py +57 -0
- pymodaq/control_modules/move_utility_classes.py +1141 -0
- pymodaq/control_modules/thread_commands.py +137 -0
- pymodaq/control_modules/ui_utils.py +72 -0
- pymodaq/control_modules/utils.py +591 -0
- pymodaq/control_modules/viewer_utility_classes.py +670 -0
- pymodaq/daq_utils/__init__.py +0 -0
- pymodaq/daq_utils/daq_utils.py +6 -0
- pymodaq/dashboard.py +2396 -0
- pymodaq/examples/Labview_TCP_Client/DAQ_TCP_Client.aliases +3 -0
- pymodaq/examples/Labview_TCP_Client/DAQ_TCP_Client.lvlps +3 -0
- pymodaq/examples/Labview_TCP_Client/DAQ_TCP_Client.lvproj +32 -0
- pymodaq/examples/Labview_TCP_Client/DAQ_TCP_Client.vi +0 -0
- pymodaq/examples/Labview_TCP_Client/DAQ_TCP_Server_1Dgaussian.vi +0 -0
- pymodaq/examples/Labview_TCP_Client/DAQ_TCP_Server_2Dgaussian.vi +0 -0
- pymodaq/examples/Labview_TCP_Client/DAQ_TCP_read_cmd.vi +0 -0
- pymodaq/examples/Labview_TCP_Client/DAQ_TCP_read_float.vi +0 -0
- pymodaq/examples/Labview_TCP_Client/DAQ_TCP_read_int.vi +0 -0
- pymodaq/examples/Labview_TCP_Client/DAQ_TCP_send_data.vi +0 -0
- pymodaq/examples/Labview_TCP_Client/DAQ_TCP_send_int.vi +0 -0
- pymodaq/examples/Labview_TCP_Client/DAQ_TCP_send_scalar.vi +0 -0
- pymodaq/examples/Labview_TCP_Client/DAQ_TCP_send_string.vi +0 -0
- pymodaq/examples/Labview_TCP_Client/client_state.ctl +0 -0
- pymodaq/examples/Labview_TCP_Client/cmd_types.ctl +0 -0
- pymodaq/examples/__init__.py +0 -0
- pymodaq/examples/function_plotter.py +160 -0
- pymodaq/examples/nonlinearscanner.py +126 -0
- pymodaq/examples/qt_less_standalone_module.py +165 -0
- pymodaq/examples/tcp_client.py +97 -0
- pymodaq/extensions/__init__.py +25 -0
- pymodaq/extensions/adaptive/__init__.py +2 -0
- pymodaq/extensions/adaptive/adaptive_optimization.py +179 -0
- pymodaq/extensions/adaptive/loss_function/_1d_loss_functions.py +73 -0
- pymodaq/extensions/adaptive/loss_function/_2d_loss_functions.py +73 -0
- pymodaq/extensions/adaptive/loss_function/__init__.py +3 -0
- pymodaq/extensions/adaptive/loss_function/loss_factory.py +110 -0
- pymodaq/extensions/adaptive/utils.py +123 -0
- pymodaq/extensions/bayesian/__init__.py +2 -0
- pymodaq/extensions/bayesian/acquisition/__init__.py +2 -0
- pymodaq/extensions/bayesian/acquisition/acquisition_function_factory.py +80 -0
- pymodaq/extensions/bayesian/acquisition/base_acquisition_function.py +105 -0
- pymodaq/extensions/bayesian/bayesian_optimization.py +143 -0
- pymodaq/extensions/bayesian/utils.py +180 -0
- pymodaq/extensions/console.py +73 -0
- pymodaq/extensions/daq_logger/__init__.py +1 -0
- pymodaq/extensions/daq_logger/abstract.py +52 -0
- pymodaq/extensions/daq_logger/daq_logger.py +519 -0
- pymodaq/extensions/daq_logger/db/__init__.py +0 -0
- pymodaq/extensions/daq_logger/db/db_logger.py +300 -0
- pymodaq/extensions/daq_logger/db/db_logger_models.py +100 -0
- pymodaq/extensions/daq_logger/h5logging.py +84 -0
- pymodaq/extensions/daq_scan.py +1218 -0
- pymodaq/extensions/daq_scan_ui.py +241 -0
- pymodaq/extensions/data_mixer/__init__.py +0 -0
- pymodaq/extensions/data_mixer/daq_0Dviewer_DataMixer.py +97 -0
- pymodaq/extensions/data_mixer/data_mixer.py +262 -0
- pymodaq/extensions/data_mixer/model.py +108 -0
- pymodaq/extensions/data_mixer/models/__init__.py +0 -0
- pymodaq/extensions/data_mixer/models/equation_model.py +91 -0
- pymodaq/extensions/data_mixer/models/gaussian_fit_model.py +65 -0
- pymodaq/extensions/data_mixer/parser.py +53 -0
- pymodaq/extensions/data_mixer/utils.py +23 -0
- pymodaq/extensions/h5browser.py +9 -0
- pymodaq/extensions/optimizers_base/__init__.py +0 -0
- pymodaq/extensions/optimizers_base/optimizer.py +1016 -0
- pymodaq/extensions/optimizers_base/thread_commands.py +22 -0
- pymodaq/extensions/optimizers_base/utils.py +427 -0
- pymodaq/extensions/pid/__init__.py +16 -0
- pymodaq/extensions/pid/actuator_controller.py +14 -0
- pymodaq/extensions/pid/daq_move_PID.py +154 -0
- pymodaq/extensions/pid/pid_controller.py +1016 -0
- pymodaq/extensions/pid/utils.py +189 -0
- pymodaq/extensions/utils.py +111 -0
- pymodaq/icon.ico +0 -0
- pymodaq/post_treatment/__init__.py +6 -0
- pymodaq/post_treatment/load_and_plot.py +352 -0
- pymodaq/resources/__init__.py +0 -0
- pymodaq/resources/config_template.toml +57 -0
- pymodaq/resources/preset_default.xml +1 -0
- pymodaq/resources/setup_plugin.py +73 -0
- pymodaq/splash.png +0 -0
- pymodaq/utils/__init__.py +0 -0
- pymodaq/utils/array_manipulation.py +6 -0
- pymodaq/utils/calibration_camera.py +180 -0
- pymodaq/utils/chrono_timer.py +203 -0
- pymodaq/utils/config.py +53 -0
- pymodaq/utils/conftests.py +5 -0
- pymodaq/utils/daq_utils.py +158 -0
- pymodaq/utils/data.py +128 -0
- pymodaq/utils/enums.py +6 -0
- pymodaq/utils/exceptions.py +38 -0
- pymodaq/utils/gui_utils/__init__.py +10 -0
- pymodaq/utils/gui_utils/loader_utils.py +75 -0
- pymodaq/utils/gui_utils/utils.py +18 -0
- pymodaq/utils/gui_utils/widgets/lcd.py +8 -0
- pymodaq/utils/h5modules/__init__.py +2 -0
- pymodaq/utils/h5modules/module_saving.py +526 -0
- pymodaq/utils/leco/__init__.py +25 -0
- pymodaq/utils/leco/daq_move_LECODirector.py +217 -0
- pymodaq/utils/leco/daq_xDviewer_LECODirector.py +163 -0
- pymodaq/utils/leco/director_utils.py +74 -0
- pymodaq/utils/leco/leco_director.py +166 -0
- pymodaq/utils/leco/pymodaq_listener.py +364 -0
- pymodaq/utils/leco/rpc_method_definitions.py +43 -0
- pymodaq/utils/leco/utils.py +74 -0
- pymodaq/utils/logger.py +6 -0
- pymodaq/utils/managers/__init__.py +0 -0
- pymodaq/utils/managers/batchscan_manager.py +346 -0
- pymodaq/utils/managers/modules_manager.py +589 -0
- pymodaq/utils/managers/overshoot_manager.py +242 -0
- pymodaq/utils/managers/preset_manager.py +229 -0
- pymodaq/utils/managers/preset_manager_utils.py +262 -0
- pymodaq/utils/managers/remote_manager.py +484 -0
- pymodaq/utils/math_utils.py +6 -0
- pymodaq/utils/messenger.py +6 -0
- pymodaq/utils/parameter/__init__.py +10 -0
- pymodaq/utils/parameter/utils.py +6 -0
- pymodaq/utils/scanner/__init__.py +5 -0
- pymodaq/utils/scanner/scan_config.py +16 -0
- pymodaq/utils/scanner/scan_factory.py +259 -0
- pymodaq/utils/scanner/scan_selector.py +477 -0
- pymodaq/utils/scanner/scanner.py +324 -0
- pymodaq/utils/scanner/scanners/_1d_scanners.py +174 -0
- pymodaq/utils/scanner/scanners/_2d_scanners.py +299 -0
- pymodaq/utils/scanner/scanners/__init__.py +1 -0
- pymodaq/utils/scanner/scanners/sequential.py +224 -0
- pymodaq/utils/scanner/scanners/tabular.py +319 -0
- pymodaq/utils/scanner/utils.py +110 -0
- pymodaq/utils/svg/__init__.py +6 -0
- pymodaq/utils/svg/svg_renderer.py +20 -0
- pymodaq/utils/svg/svg_view.py +35 -0
- pymodaq/utils/svg/svg_viewer2D.py +50 -0
- pymodaq/utils/tcp_ip/__init__.py +6 -0
- pymodaq/utils/tcp_ip/mysocket.py +12 -0
- pymodaq/utils/tcp_ip/serializer.py +13 -0
- pymodaq/utils/tcp_ip/tcp_server_client.py +772 -0
- pymodaq-5.1.6.dist-info/METADATA +238 -0
- pymodaq-5.1.6.dist-info/RECORD +154 -0
- pymodaq-5.1.6.dist-info/WHEEL +4 -0
- pymodaq-5.1.6.dist-info/entry_points.txt +7 -0
- pymodaq-5.1.6.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Created the 05/12/2022
|
|
4
|
+
|
|
5
|
+
@author: Sebastien Weber
|
|
6
|
+
"""
|
|
7
|
+
from typing import List, Tuple, TYPE_CHECKING, Iterable
|
|
8
|
+
|
|
9
|
+
import numpy as np
|
|
10
|
+
|
|
11
|
+
from qtpy import QtCore, QtWidgets
|
|
12
|
+
from pymodaq_data.data import Axis, DataDistribution
|
|
13
|
+
from pymodaq_data import Q_
|
|
14
|
+
from pymodaq_gui.utils import SpinBoxDelegate
|
|
15
|
+
from pymodaq_utils.logger import set_logger, get_module_name
|
|
16
|
+
|
|
17
|
+
from pymodaq_utils import config as configmod
|
|
18
|
+
from pymodaq_gui import utils as gutils
|
|
19
|
+
from ..scan_factory import ScannerFactory, ScannerBase, ScanParameterManager
|
|
20
|
+
from pymodaq_gui.parameter import utils as putils
|
|
21
|
+
from pymodaq_gui.parameter.pymodaq_ptypes import TableViewCustom
|
|
22
|
+
from pymodaq.utils.scanner.scan_selector import Selector
|
|
23
|
+
from pymodaq_gui.plotting.utils.plot_utils import Point, get_sub_segmented_positions
|
|
24
|
+
|
|
25
|
+
if TYPE_CHECKING:
|
|
26
|
+
from pymodaq.control_modules.daq_move import DAQ_Move
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
logger = set_logger(get_module_name(__file__))
|
|
30
|
+
config = configmod.Config()
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class TableModelTabular(gutils.TableModel):
|
|
34
|
+
"""Table Model for the Model/View Qt framework dedicated to the Tabular scan mode"""
|
|
35
|
+
def __init__(self, data, axes_name=None, **kwargs):
|
|
36
|
+
if axes_name is None:
|
|
37
|
+
if 'header' in kwargs: # when saved as XML the header will be saved and restored here
|
|
38
|
+
axes_name = [h for h in kwargs['header']]
|
|
39
|
+
kwargs.pop('header')
|
|
40
|
+
else:
|
|
41
|
+
raise Exception('Invalid header')
|
|
42
|
+
header = [name for name in axes_name]
|
|
43
|
+
editable = [True for name in axes_name]
|
|
44
|
+
super().__init__(data, header, editable=editable, cast=str, **kwargs)
|
|
45
|
+
|
|
46
|
+
def __len__(self):
|
|
47
|
+
return len(self._data)
|
|
48
|
+
|
|
49
|
+
def add_data(self, row, data=None):
|
|
50
|
+
if data is not None:
|
|
51
|
+
self.insert_data(row, [f'{d}' for d in data])
|
|
52
|
+
else:
|
|
53
|
+
self.insert_data(row, ['0.' for name in self.header])
|
|
54
|
+
|
|
55
|
+
def remove_data(self, row):
|
|
56
|
+
self.remove_row(row)
|
|
57
|
+
|
|
58
|
+
def load_txt(self):
|
|
59
|
+
fname = gutils.select_file(start_path=None, save=False, ext='*')
|
|
60
|
+
if fname is not None and fname != '':
|
|
61
|
+
while self.rowCount(self.index(-1, -1)) > 0:
|
|
62
|
+
self.remove_row(0)
|
|
63
|
+
|
|
64
|
+
data = np.loadtxt(fname)
|
|
65
|
+
if len(data.shape) == 1:
|
|
66
|
+
data = data.reshape((data.size, 1))
|
|
67
|
+
self.set_data_all(data)
|
|
68
|
+
|
|
69
|
+
def save_txt(self):
|
|
70
|
+
fname = gutils.select_file(start_path=None, save=True, ext='dat')
|
|
71
|
+
if fname is not None and fname != '':
|
|
72
|
+
np.savetxt(fname, self.get_data_all(), delimiter='\t')
|
|
73
|
+
|
|
74
|
+
def __repr__(self):
|
|
75
|
+
return f'{self.__class__.__name__} from module {self.__class__.__module__}'
|
|
76
|
+
|
|
77
|
+
def validate_data(self, row, col, value):
|
|
78
|
+
"""
|
|
79
|
+
make sure the values and signs of the start, stop and step values are "correct"
|
|
80
|
+
Parameters
|
|
81
|
+
----------
|
|
82
|
+
row: (int) row within the table that is to be changed
|
|
83
|
+
col: (int) col within the table that is to be changed
|
|
84
|
+
value: (float) new value for the value defined by row and col
|
|
85
|
+
|
|
86
|
+
Returns
|
|
87
|
+
-------
|
|
88
|
+
bool: True is the new value is fine (change some other values if needed) otherwise False
|
|
89
|
+
"""
|
|
90
|
+
|
|
91
|
+
return True
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
class TableModelTabularReadOnly(TableModelTabular):
|
|
95
|
+
def setData(self, index, value, role):
|
|
96
|
+
return False
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
@ScannerFactory.register()
|
|
100
|
+
class TabularScanner(ScannerBase):
|
|
101
|
+
scan_type = 'Tabular'
|
|
102
|
+
scan_subtype = 'Linear'
|
|
103
|
+
save_settings = False # not easy to save table content in a toml...
|
|
104
|
+
params = [
|
|
105
|
+
{'title': 'Positions', 'name': 'tabular_table', 'type': 'table_view', 'delegate': gutils.SpinBoxDelegate,
|
|
106
|
+
'menu': True},
|
|
107
|
+
]
|
|
108
|
+
distribution = DataDistribution['spread']
|
|
109
|
+
|
|
110
|
+
def __init__(self, actuators: List['DAQ_Move'], display_units=True, **kwargs):
|
|
111
|
+
self.table_model: TableModelTabular = None
|
|
112
|
+
self.table_view: TableViewCustom = None
|
|
113
|
+
super().__init__(actuators=actuators, display_units=display_units)
|
|
114
|
+
self.delegates: Iterable[SpinBoxDelegate] = []
|
|
115
|
+
|
|
116
|
+
def set_units(self):
|
|
117
|
+
pass
|
|
118
|
+
|
|
119
|
+
@property
|
|
120
|
+
def actuators(self):
|
|
121
|
+
return self._actuators
|
|
122
|
+
|
|
123
|
+
@actuators.setter
|
|
124
|
+
def actuators(self, actuators):
|
|
125
|
+
self._actuators = actuators
|
|
126
|
+
base_path = self.actuators_name + [self.scan_type, self.scan_subtype]
|
|
127
|
+
self.config_saver_loader.base_path = base_path
|
|
128
|
+
self.update_model()
|
|
129
|
+
|
|
130
|
+
def update_model(self, init_data=None):
|
|
131
|
+
if init_data is None:
|
|
132
|
+
if self.display_units:
|
|
133
|
+
init_data = [[f'0. {act.units}' for act in self._actuators]]
|
|
134
|
+
else:
|
|
135
|
+
init_data = [['0.' for _ in self._actuators]]
|
|
136
|
+
|
|
137
|
+
self.table_model = TableModelTabular(init_data, [act.title for act in self._actuators])
|
|
138
|
+
self.table_view = putils.get_widget_from_tree(self.settings_tree, TableViewCustom)[0]
|
|
139
|
+
self.settings.child('tabular_table').setValue(self.table_model)
|
|
140
|
+
self.n_axes = len(self._actuators)
|
|
141
|
+
self.update_table_view()
|
|
142
|
+
|
|
143
|
+
def update_table_view(self):
|
|
144
|
+
self.table_view.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.ResizeMode.Stretch)
|
|
145
|
+
# self.table_view.horizontalHeader().setStretchLastSection(True)
|
|
146
|
+
self.table_view.setSelectionBehavior(QtWidgets.QTableView.SelectRows)
|
|
147
|
+
self.table_view.setSelectionMode(QtWidgets.QTableView.SingleSelection)
|
|
148
|
+
self.delegates = [] # ItemDelegates should have parents and be instance attribute to work with setItemDelegateForColumn
|
|
149
|
+
for ind_actuator, actuator in enumerate(self.actuators):
|
|
150
|
+
|
|
151
|
+
self.delegates.append(gutils.SpinBoxDelegate(self.table_view,
|
|
152
|
+
units=actuator.units if self.display_units else None))
|
|
153
|
+
self.table_view.setItemDelegateForColumn(
|
|
154
|
+
ind_actuator, self.delegates[-1])
|
|
155
|
+
|
|
156
|
+
self.table_view.setDragEnabled(True)
|
|
157
|
+
self.table_view.setDropIndicatorShown(True)
|
|
158
|
+
self.table_view.setAcceptDrops(True)
|
|
159
|
+
self.table_view.viewport().setAcceptDrops(True)
|
|
160
|
+
self.table_view.setDefaultDropAction(QtCore.Qt.MoveAction)
|
|
161
|
+
self.table_view.setDragDropMode(QtWidgets.QTableView.InternalMove)
|
|
162
|
+
self.table_view.setDragDropOverwriteMode(False)
|
|
163
|
+
|
|
164
|
+
self.table_view.add_data_signal[int].connect(self.table_model.add_data)
|
|
165
|
+
self.table_view.remove_row_signal[int].connect(self.table_model.remove_data)
|
|
166
|
+
self.table_view.load_data_signal.connect(self.table_model.load_txt)
|
|
167
|
+
self.table_view.save_data_signal.connect(self.table_model.save_txt)
|
|
168
|
+
|
|
169
|
+
def evaluate_steps(self):
|
|
170
|
+
return len(self.table_model)
|
|
171
|
+
|
|
172
|
+
def set_scan(self):
|
|
173
|
+
positions = np.array([[Q_(elt).magnitude for elt in line] for line in self.table_model.get_data_all()])
|
|
174
|
+
self.get_info_from_positions(positions)
|
|
175
|
+
|
|
176
|
+
def update_tabular_positions(self, positions: np.ndarray = None):
|
|
177
|
+
"""Convenience function to write positions directly into the tabular table
|
|
178
|
+
|
|
179
|
+
Parameters
|
|
180
|
+
----------
|
|
181
|
+
positions: ndarray
|
|
182
|
+
a 2D ndarray with as many columns as selected actuators
|
|
183
|
+
"""
|
|
184
|
+
try:
|
|
185
|
+
if positions is None:
|
|
186
|
+
if self.settings.child('tabular_settings',
|
|
187
|
+
'tabular_selection').value() == 'Polylines': # from ROI
|
|
188
|
+
viewer = self.scan_selector.selector_source
|
|
189
|
+
|
|
190
|
+
if self.settings.child('tabular_settings', 'tabular_subtype').value() == 'Linear':
|
|
191
|
+
positions = self.scan_selector.scan_selector.getArrayIndexes(
|
|
192
|
+
spacing=self.settings.child('tabular_settings', 'tabular_step').value())
|
|
193
|
+
elif self.settings.child('tabular_settings',
|
|
194
|
+
'tabular_subtype').value() == 'Adaptive':
|
|
195
|
+
positions = self.scan_selector.scan_selector.get_vertex()
|
|
196
|
+
|
|
197
|
+
steps_x, steps_y = zip(*positions)
|
|
198
|
+
steps_x, steps_y = viewer.scale_axis(np.array(steps_x), np.array(steps_y))
|
|
199
|
+
positions = np.transpose(np.array([steps_x, steps_y]))
|
|
200
|
+
self.update_model(init_data=positions)
|
|
201
|
+
else:
|
|
202
|
+
self.update_model()
|
|
203
|
+
elif isinstance(positions, np.ndarray):
|
|
204
|
+
self.update_model(init_data=positions)
|
|
205
|
+
else:
|
|
206
|
+
pass
|
|
207
|
+
except Exception as e:
|
|
208
|
+
logger.exception(str(e))
|
|
209
|
+
|
|
210
|
+
def get_nav_axes(self) -> List[Axis]:
|
|
211
|
+
return [Axis(label=f'{act.title}', units=act.units, data=self.positions[:, ind], index=0,
|
|
212
|
+
spread_order=ind)
|
|
213
|
+
for ind, act in enumerate(self.actuators)]
|
|
214
|
+
|
|
215
|
+
def get_indexes_from_scan_index(self, scan_index: int) -> Tuple[int]:
|
|
216
|
+
"""To be reimplemented. Calculations of indexes within the scan"""
|
|
217
|
+
return scan_index,
|
|
218
|
+
|
|
219
|
+
def get_scan_shape(self) -> Tuple[int]:
|
|
220
|
+
return len(self.table_model),
|
|
221
|
+
|
|
222
|
+
def update_from_scan_selector(self, scan_selector: Selector):
|
|
223
|
+
coordinates = scan_selector.get_coordinates()
|
|
224
|
+
self.update_model(init_data=coordinates)
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
@ScannerFactory.register()
|
|
228
|
+
class TabularScannerSubSegmented(TabularScanner):
|
|
229
|
+
|
|
230
|
+
scan_subtype = 'SubSegmented'
|
|
231
|
+
save_settings = False
|
|
232
|
+
params = [{'title': 'Step:', 'name': 'tabular_step', 'type': 'float', 'value': 0.1},
|
|
233
|
+
{'title': 'Points', 'name': 'tabular_points', 'type': 'table_view',
|
|
234
|
+
'delegate': gutils.SpinBoxDelegate,
|
|
235
|
+
'menu': True},
|
|
236
|
+
] + TabularScanner.params
|
|
237
|
+
|
|
238
|
+
def __init__(self, actuators: List['DAQ_Move'], display_units=True):
|
|
239
|
+
self.table_model: TableModelTabularReadOnly = None
|
|
240
|
+
self.table_view: TableViewCustom = None
|
|
241
|
+
self.table_model_points: TableModelTabular = None
|
|
242
|
+
self.table_view_points: TableViewCustom = None
|
|
243
|
+
super().__init__(actuators=actuators, display_units=display_units)
|
|
244
|
+
|
|
245
|
+
@property
|
|
246
|
+
def actuators(self):
|
|
247
|
+
return self._actuators
|
|
248
|
+
|
|
249
|
+
@actuators.setter
|
|
250
|
+
def actuators(self, actuators_name):
|
|
251
|
+
self._actuators = actuators_name
|
|
252
|
+
self.update_model()
|
|
253
|
+
self.update_model_points()
|
|
254
|
+
|
|
255
|
+
def update_model(self, init_data=None):
|
|
256
|
+
if init_data is None:
|
|
257
|
+
init_data = [['0.' for _ in self._actuators]]
|
|
258
|
+
|
|
259
|
+
self.table_model = TableModelTabularReadOnly(init_data, [act.title for act in self._actuators])
|
|
260
|
+
self.table_view = putils.get_widget_from_tree(self.settings_tree, TableViewCustom)[1]
|
|
261
|
+
self.settings.child('tabular_table').setValue(self.table_model)
|
|
262
|
+
self.n_axes = len(self._actuators)
|
|
263
|
+
self.update_table_view()
|
|
264
|
+
|
|
265
|
+
def update_model_points(self, init_data=None):
|
|
266
|
+
if init_data is None:
|
|
267
|
+
init_data = [['0.' for _ in self._actuators]]
|
|
268
|
+
|
|
269
|
+
self.table_model_points = TableModelTabular(init_data, [act.title for act in self._actuators])
|
|
270
|
+
self.table_view_points = putils.get_widget_from_tree(self.settings_tree, TableViewCustom)[0]
|
|
271
|
+
self.settings.child('tabular_points').setValue(self.table_model_points)
|
|
272
|
+
self.update_table_view_points()
|
|
273
|
+
|
|
274
|
+
def update_table_view(self):
|
|
275
|
+
self.table_view.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.ResizeMode.Stretch)
|
|
276
|
+
self.table_view.setSelectionBehavior(QtWidgets.QTableView.SelectRows)
|
|
277
|
+
self.table_view.setSelectionMode(QtWidgets.QTableView.SingleSelection)
|
|
278
|
+
self.delegates = []
|
|
279
|
+
for ind_actuator, actuator in enumerate(self.actuators):
|
|
280
|
+
self.delegates.append(gutils.SpinBoxDelegate(self.table_view,
|
|
281
|
+
units=actuator.units if self.display_units else None))
|
|
282
|
+
self.table_view.setItemDelegateForColumn(
|
|
283
|
+
ind_actuator, self.delegates[-1])
|
|
284
|
+
|
|
285
|
+
def update_table_view_points(self):
|
|
286
|
+
self.table_view_points.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.ResizeMode.Stretch)
|
|
287
|
+
self.table_view_points.setSelectionBehavior(QtWidgets.QTableView.SelectRows)
|
|
288
|
+
self.table_view_points.setSelectionMode(QtWidgets.QTableView.SingleSelection)
|
|
289
|
+
self.delegates_points = []
|
|
290
|
+
for ind_actuator, actuator in enumerate(self.actuators):
|
|
291
|
+
self.delegates_points.append(gutils.SpinBoxDelegate(self.table_view,
|
|
292
|
+
units=actuator.units if self.display_units else None))
|
|
293
|
+
self.table_view.setItemDelegateForColumn(
|
|
294
|
+
ind_actuator, self.delegates_points[-1])
|
|
295
|
+
|
|
296
|
+
self.table_view_points.setDragEnabled(True)
|
|
297
|
+
self.table_view_points.setDropIndicatorShown(True)
|
|
298
|
+
self.table_view_points.setAcceptDrops(True)
|
|
299
|
+
self.table_view_points.viewport().setAcceptDrops(True)
|
|
300
|
+
self.table_view_points.setDefaultDropAction(QtCore.Qt.MoveAction)
|
|
301
|
+
self.table_view_points.setDragDropMode(QtWidgets.QTableView.InternalMove)
|
|
302
|
+
self.table_view_points.setDragDropOverwriteMode(False)
|
|
303
|
+
|
|
304
|
+
self.table_view_points.add_data_signal[int].connect(self.table_model_points.add_data)
|
|
305
|
+
self.table_view_points.remove_row_signal[int].connect(self.table_model_points.remove_data)
|
|
306
|
+
self.table_view_points.load_data_signal.connect(self.table_model_points.load_txt)
|
|
307
|
+
self.table_view_points.save_data_signal.connect(self.table_model_points.save_txt)
|
|
308
|
+
|
|
309
|
+
def set_scan(self):
|
|
310
|
+
points = [Point(coordinates) for coordinates in self.table_model_points.get_data_all()]
|
|
311
|
+
positions = get_sub_segmented_positions(self.settings['tabular_step'], points)
|
|
312
|
+
self.table_model.set_data_all(positions)
|
|
313
|
+
positions = np.array([[Q_(elt).magnitude for elt in line] for line in self.table_model.get_data_all()])
|
|
314
|
+
self.get_info_from_positions(positions)
|
|
315
|
+
|
|
316
|
+
def update_from_scan_selector(self, scan_selector: Selector):
|
|
317
|
+
coordinates = scan_selector.get_coordinates()
|
|
318
|
+
self.update_model_points(init_data=coordinates)
|
|
319
|
+
self.set_scan()
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Created the 05/12/2022
|
|
4
|
+
|
|
5
|
+
@author: Sebastien Weber
|
|
6
|
+
"""
|
|
7
|
+
from importlib import import_module
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
from pymodaq_utils.logger import set_logger, get_module_name
|
|
12
|
+
from pymodaq_utils.config import Config
|
|
13
|
+
from pymodaq_utils.utils import get_entrypoints
|
|
14
|
+
from pymodaq_utils.enums import BaseEnum
|
|
15
|
+
|
|
16
|
+
from pymodaq.utils.scanner.scan_factory import ScannerFactory
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
logger = set_logger(get_module_name(__file__))
|
|
20
|
+
config = Config()
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def register_scanner(parent_module_name: str = 'pymodaq.utils.scanner'):
|
|
24
|
+
scanners = []
|
|
25
|
+
try:
|
|
26
|
+
scanner_module = import_module(f'{parent_module_name}.scanners')
|
|
27
|
+
|
|
28
|
+
scanner_path = Path(scanner_module.__path__[0])
|
|
29
|
+
|
|
30
|
+
for file in scanner_path.iterdir():
|
|
31
|
+
if file.is_file() and 'py' in file.suffix and file.stem != '__init__':
|
|
32
|
+
try:
|
|
33
|
+
scanners.append(import_module(f'.{file.stem}', scanner_module.__name__))
|
|
34
|
+
except (ModuleNotFoundError, Exception) as e:
|
|
35
|
+
pass
|
|
36
|
+
except ModuleNotFoundError:
|
|
37
|
+
pass
|
|
38
|
+
finally:
|
|
39
|
+
return scanners
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def register_scanners() -> list:
|
|
43
|
+
scanners = register_scanner('pymodaq.utils.scanner')
|
|
44
|
+
discovered_scanners_plugins = get_entrypoints('pymodaq.scanners')
|
|
45
|
+
for entry in discovered_scanners_plugins:
|
|
46
|
+
scanners.extend(register_scanner(entry.value))
|
|
47
|
+
return scanners
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
register_scanners()
|
|
51
|
+
scanner_factory = ScannerFactory()
|
|
52
|
+
ScanType = BaseEnum('ScanType', ['NoScan'] + scanner_factory.scan_types())
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class ScannerException(Exception):
|
|
56
|
+
"""Raised when there is an error related to the Scanner class (see pymodaq.da_utils.scanner)"""
|
|
57
|
+
pass
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class ScanInfo:
|
|
61
|
+
"""Container class for a given scan details
|
|
62
|
+
|
|
63
|
+
It includes the number of steps and all the positions for the selected actuators. It also contains these positions
|
|
64
|
+
as scan axes for easier use.
|
|
65
|
+
|
|
66
|
+
Parameters
|
|
67
|
+
----------
|
|
68
|
+
|
|
69
|
+
Nsteps: int
|
|
70
|
+
Number of steps of the scan
|
|
71
|
+
positions: ndarray
|
|
72
|
+
multidimensional array. the first dimension has a length of Nsteps and each element is an actuator position
|
|
73
|
+
positions_indexes: ndarray
|
|
74
|
+
multidimensional array of Nsteps 0th dimension length where each element is the index
|
|
75
|
+
of the corresponding positions within the axis_unique
|
|
76
|
+
axes_unique: list of ndarray
|
|
77
|
+
list of sorted (and with unique values) 1D arrays of unique positions of each defined axes
|
|
78
|
+
selected_actuators: List[str]
|
|
79
|
+
The actuators to be used for this scan
|
|
80
|
+
kwargs: dict of other named parameters to be saved as attributes
|
|
81
|
+
|
|
82
|
+
Attributes
|
|
83
|
+
----------
|
|
84
|
+
Nsteps: int
|
|
85
|
+
Number of steps of the scan
|
|
86
|
+
positions: ndarray
|
|
87
|
+
multidimensional array. the first dimension has a length of Nsteps and each element is an actuator position
|
|
88
|
+
positions_indexes: ndarray
|
|
89
|
+
multidimensional array of Nsteps 0th dimension length where each element is the index
|
|
90
|
+
of the corresponding positions within the axis_unique
|
|
91
|
+
axes_unique: list of ndarray
|
|
92
|
+
list of sorted (and with unique values) 1D arrays of unique positions of each defined axes
|
|
93
|
+
kwargs: dict of other named attributes
|
|
94
|
+
"""
|
|
95
|
+
def __init__(self, Nsteps=0, positions=None, axes_indexes=None, axes_unique=None, selected_actuators=[],
|
|
96
|
+
**kwargs):
|
|
97
|
+
self.Nsteps = Nsteps
|
|
98
|
+
self.positions = positions
|
|
99
|
+
self.axes_indexes = axes_indexes
|
|
100
|
+
self.axes_unique = axes_unique
|
|
101
|
+
self.selected_actuators = selected_actuators
|
|
102
|
+
for k in kwargs:
|
|
103
|
+
setattr(self, k, kwargs[k])
|
|
104
|
+
|
|
105
|
+
def __repr__(self):
|
|
106
|
+
return f'Scan of {self.selected_actuators} with {self.Nsteps} positions'
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Created the 06/01/2023
|
|
4
|
+
|
|
5
|
+
@author: Sebastien Weber
|
|
6
|
+
"""
|
|
7
|
+
import sys
|
|
8
|
+
|
|
9
|
+
from qtpy import QtSvg, QtWidgets
|
|
10
|
+
from qtpy.QtSvg import QSvgWidget
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
if __name__ == '__main__':
|
|
14
|
+
app = QtWidgets.QApplication(sys.argv)
|
|
15
|
+
|
|
16
|
+
widget = QSvgWidget()
|
|
17
|
+
widget.show()
|
|
18
|
+
widget.load(r'C:\Users\weber\Labo\Projet-Dossier candidature\Technical project\GDSII\wafer.svg')
|
|
19
|
+
|
|
20
|
+
sys.exit(app.exec_())
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Created the 06/01/2023
|
|
4
|
+
|
|
5
|
+
@author: Sebastien Weber
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import sys
|
|
9
|
+
from qtpy import QtWidgets, QtCore, QtSvg
|
|
10
|
+
from pyqtgraph.widgets.GraphicsView import GraphicsView
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class SVGView:
|
|
14
|
+
|
|
15
|
+
def __init__(self, parent: QtWidgets.QWidget = None):
|
|
16
|
+
if parent is None:
|
|
17
|
+
parent = QtWidgets.QWidget()
|
|
18
|
+
self.parent_widget = parent
|
|
19
|
+
self.parent_widget.setLayout(QtWidgets.QHBoxLayout())
|
|
20
|
+
self.graphicsView = GraphicsView()
|
|
21
|
+
self.parent_widget.layout().addWidget(self.graphicsView)
|
|
22
|
+
|
|
23
|
+
svg_item = QtSvg.QGraphicsSvgItem(r'C:\Users\weber\Labo\Projet-Dossier candidature\Technical project\GDSII\wafer.svg')
|
|
24
|
+
|
|
25
|
+
self.graphicsView.sceneObj.addItem(svg_item)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
if __name__ == '__main__':
|
|
29
|
+
app = QtWidgets.QApplication(sys.argv)
|
|
30
|
+
|
|
31
|
+
widget = QtWidgets.QWidget()
|
|
32
|
+
prog = SVGView(widget)
|
|
33
|
+
widget.show()
|
|
34
|
+
|
|
35
|
+
sys.exit(app.exec_())
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Created the 06/01/2023
|
|
4
|
+
|
|
5
|
+
@author: Sebastien Weber
|
|
6
|
+
"""
|
|
7
|
+
import sys
|
|
8
|
+
|
|
9
|
+
import numpy as np
|
|
10
|
+
|
|
11
|
+
from qtpy import QtWidgets
|
|
12
|
+
from pymodaq_gui.plotting.data_viewers.viewer2D import Viewer2D
|
|
13
|
+
from pymodaq.utils.data import Axis, DataFromRoi, DataFromPlugins
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def main():
|
|
17
|
+
app = QtWidgets.QApplication(sys.argv)
|
|
18
|
+
widget = QtWidgets.QWidget()
|
|
19
|
+
|
|
20
|
+
Nx = 100
|
|
21
|
+
Ny = 200
|
|
22
|
+
data_random = np.random.normal(size=(Ny, Nx))
|
|
23
|
+
x = np.linspace(-Nx/2, Nx/2 - 1, Nx)
|
|
24
|
+
y = 0.2 * np.linspace(-Ny/2, Ny/2 - 1, Ny)
|
|
25
|
+
|
|
26
|
+
from pymodaq.utils.math_utils import gauss2D
|
|
27
|
+
|
|
28
|
+
data_red = 3 * np.sin(x/5)**2 * gauss2D(x, 5, Nx / 10,
|
|
29
|
+
y, -1, Ny / 10, 1, 90) \
|
|
30
|
+
+ 0.1 * data_random
|
|
31
|
+
data_green = 10 * gauss2D(x, -20, Nx / 10,
|
|
32
|
+
y, -10, Ny / 20, 1, 0)
|
|
33
|
+
data_green[70:80, 7:12] = np.nan
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
prog = Viewer2D(widget)
|
|
37
|
+
widget.show()
|
|
38
|
+
prog.show_data(DataFromPlugins(name='mydata', distribution='uniform', data=[data_red, data_green],
|
|
39
|
+
axes=[Axis('xaxis', units='xpxl', data=x, index=1),
|
|
40
|
+
Axis('yaxis', units='ypxl', data=y, index=0),]))
|
|
41
|
+
|
|
42
|
+
prog.view.show_roi_target(True)
|
|
43
|
+
prog.view.move_scale_roi_target((50, 40), (20, 20))
|
|
44
|
+
|
|
45
|
+
QtWidgets.QApplication.processEvents()
|
|
46
|
+
sys.exit(app.exec_())
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
if __name__ == '__main__': # pragma: no cover
|
|
50
|
+
main()
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Created the 26/10/2023
|
|
4
|
+
|
|
5
|
+
@author: Sebastien Weber
|
|
6
|
+
"""
|
|
7
|
+
from pymodaq_data.serialize.mysocket import Socket
|
|
8
|
+
|
|
9
|
+
from pymodaq_utils.utils import deprecation_msg
|
|
10
|
+
|
|
11
|
+
deprecation_msg('Importing Socket from pymodaq is deprecated in PyMoDAQ >= 5,'
|
|
12
|
+
'import it from pymodaq_data.serialize.mysocket')
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Created the 20/10/2023
|
|
4
|
+
|
|
5
|
+
@author: Sebastien Weber
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from pymodaq_utils.utils import deprecation_msg
|
|
9
|
+
|
|
10
|
+
from pymodaq_utils.serialize.serializer_legacy import Serializer, DeSerializer, SocketString, Socket
|
|
11
|
+
|
|
12
|
+
deprecation_msg('Importing Serializer, DeSerializer from pymodaq is deprecated in PyMoDAQ >= 5,'
|
|
13
|
+
'import them from pymodaq_data.serialize.serializer')
|