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.
Files changed (154) hide show
  1. pymodaq/__init__.py +98 -0
  2. pymodaq/control_modules/__init__.py +1 -0
  3. pymodaq/control_modules/daq_move.py +1238 -0
  4. pymodaq/control_modules/daq_move_ui/__init__.py +0 -0
  5. pymodaq/control_modules/daq_move_ui/factory.py +48 -0
  6. pymodaq/control_modules/daq_move_ui/ui_base.py +359 -0
  7. pymodaq/control_modules/daq_move_ui/uis/__init__.py +0 -0
  8. pymodaq/control_modules/daq_move_ui/uis/binary.py +139 -0
  9. pymodaq/control_modules/daq_move_ui/uis/original.py +120 -0
  10. pymodaq/control_modules/daq_move_ui/uis/relative.py +124 -0
  11. pymodaq/control_modules/daq_move_ui/uis/simple.py +126 -0
  12. pymodaq/control_modules/daq_viewer.py +1517 -0
  13. pymodaq/control_modules/daq_viewer_ui.py +407 -0
  14. pymodaq/control_modules/mocks.py +57 -0
  15. pymodaq/control_modules/move_utility_classes.py +1141 -0
  16. pymodaq/control_modules/thread_commands.py +137 -0
  17. pymodaq/control_modules/ui_utils.py +72 -0
  18. pymodaq/control_modules/utils.py +591 -0
  19. pymodaq/control_modules/viewer_utility_classes.py +670 -0
  20. pymodaq/daq_utils/__init__.py +0 -0
  21. pymodaq/daq_utils/daq_utils.py +6 -0
  22. pymodaq/dashboard.py +2396 -0
  23. pymodaq/examples/Labview_TCP_Client/DAQ_TCP_Client.aliases +3 -0
  24. pymodaq/examples/Labview_TCP_Client/DAQ_TCP_Client.lvlps +3 -0
  25. pymodaq/examples/Labview_TCP_Client/DAQ_TCP_Client.lvproj +32 -0
  26. pymodaq/examples/Labview_TCP_Client/DAQ_TCP_Client.vi +0 -0
  27. pymodaq/examples/Labview_TCP_Client/DAQ_TCP_Server_1Dgaussian.vi +0 -0
  28. pymodaq/examples/Labview_TCP_Client/DAQ_TCP_Server_2Dgaussian.vi +0 -0
  29. pymodaq/examples/Labview_TCP_Client/DAQ_TCP_read_cmd.vi +0 -0
  30. pymodaq/examples/Labview_TCP_Client/DAQ_TCP_read_float.vi +0 -0
  31. pymodaq/examples/Labview_TCP_Client/DAQ_TCP_read_int.vi +0 -0
  32. pymodaq/examples/Labview_TCP_Client/DAQ_TCP_send_data.vi +0 -0
  33. pymodaq/examples/Labview_TCP_Client/DAQ_TCP_send_int.vi +0 -0
  34. pymodaq/examples/Labview_TCP_Client/DAQ_TCP_send_scalar.vi +0 -0
  35. pymodaq/examples/Labview_TCP_Client/DAQ_TCP_send_string.vi +0 -0
  36. pymodaq/examples/Labview_TCP_Client/client_state.ctl +0 -0
  37. pymodaq/examples/Labview_TCP_Client/cmd_types.ctl +0 -0
  38. pymodaq/examples/__init__.py +0 -0
  39. pymodaq/examples/function_plotter.py +160 -0
  40. pymodaq/examples/nonlinearscanner.py +126 -0
  41. pymodaq/examples/qt_less_standalone_module.py +165 -0
  42. pymodaq/examples/tcp_client.py +97 -0
  43. pymodaq/extensions/__init__.py +25 -0
  44. pymodaq/extensions/adaptive/__init__.py +2 -0
  45. pymodaq/extensions/adaptive/adaptive_optimization.py +179 -0
  46. pymodaq/extensions/adaptive/loss_function/_1d_loss_functions.py +73 -0
  47. pymodaq/extensions/adaptive/loss_function/_2d_loss_functions.py +73 -0
  48. pymodaq/extensions/adaptive/loss_function/__init__.py +3 -0
  49. pymodaq/extensions/adaptive/loss_function/loss_factory.py +110 -0
  50. pymodaq/extensions/adaptive/utils.py +123 -0
  51. pymodaq/extensions/bayesian/__init__.py +2 -0
  52. pymodaq/extensions/bayesian/acquisition/__init__.py +2 -0
  53. pymodaq/extensions/bayesian/acquisition/acquisition_function_factory.py +80 -0
  54. pymodaq/extensions/bayesian/acquisition/base_acquisition_function.py +105 -0
  55. pymodaq/extensions/bayesian/bayesian_optimization.py +143 -0
  56. pymodaq/extensions/bayesian/utils.py +180 -0
  57. pymodaq/extensions/console.py +73 -0
  58. pymodaq/extensions/daq_logger/__init__.py +1 -0
  59. pymodaq/extensions/daq_logger/abstract.py +52 -0
  60. pymodaq/extensions/daq_logger/daq_logger.py +519 -0
  61. pymodaq/extensions/daq_logger/db/__init__.py +0 -0
  62. pymodaq/extensions/daq_logger/db/db_logger.py +300 -0
  63. pymodaq/extensions/daq_logger/db/db_logger_models.py +100 -0
  64. pymodaq/extensions/daq_logger/h5logging.py +84 -0
  65. pymodaq/extensions/daq_scan.py +1218 -0
  66. pymodaq/extensions/daq_scan_ui.py +241 -0
  67. pymodaq/extensions/data_mixer/__init__.py +0 -0
  68. pymodaq/extensions/data_mixer/daq_0Dviewer_DataMixer.py +97 -0
  69. pymodaq/extensions/data_mixer/data_mixer.py +262 -0
  70. pymodaq/extensions/data_mixer/model.py +108 -0
  71. pymodaq/extensions/data_mixer/models/__init__.py +0 -0
  72. pymodaq/extensions/data_mixer/models/equation_model.py +91 -0
  73. pymodaq/extensions/data_mixer/models/gaussian_fit_model.py +65 -0
  74. pymodaq/extensions/data_mixer/parser.py +53 -0
  75. pymodaq/extensions/data_mixer/utils.py +23 -0
  76. pymodaq/extensions/h5browser.py +9 -0
  77. pymodaq/extensions/optimizers_base/__init__.py +0 -0
  78. pymodaq/extensions/optimizers_base/optimizer.py +1016 -0
  79. pymodaq/extensions/optimizers_base/thread_commands.py +22 -0
  80. pymodaq/extensions/optimizers_base/utils.py +427 -0
  81. pymodaq/extensions/pid/__init__.py +16 -0
  82. pymodaq/extensions/pid/actuator_controller.py +14 -0
  83. pymodaq/extensions/pid/daq_move_PID.py +154 -0
  84. pymodaq/extensions/pid/pid_controller.py +1016 -0
  85. pymodaq/extensions/pid/utils.py +189 -0
  86. pymodaq/extensions/utils.py +111 -0
  87. pymodaq/icon.ico +0 -0
  88. pymodaq/post_treatment/__init__.py +6 -0
  89. pymodaq/post_treatment/load_and_plot.py +352 -0
  90. pymodaq/resources/__init__.py +0 -0
  91. pymodaq/resources/config_template.toml +57 -0
  92. pymodaq/resources/preset_default.xml +1 -0
  93. pymodaq/resources/setup_plugin.py +73 -0
  94. pymodaq/splash.png +0 -0
  95. pymodaq/utils/__init__.py +0 -0
  96. pymodaq/utils/array_manipulation.py +6 -0
  97. pymodaq/utils/calibration_camera.py +180 -0
  98. pymodaq/utils/chrono_timer.py +203 -0
  99. pymodaq/utils/config.py +53 -0
  100. pymodaq/utils/conftests.py +5 -0
  101. pymodaq/utils/daq_utils.py +158 -0
  102. pymodaq/utils/data.py +128 -0
  103. pymodaq/utils/enums.py +6 -0
  104. pymodaq/utils/exceptions.py +38 -0
  105. pymodaq/utils/gui_utils/__init__.py +10 -0
  106. pymodaq/utils/gui_utils/loader_utils.py +75 -0
  107. pymodaq/utils/gui_utils/utils.py +18 -0
  108. pymodaq/utils/gui_utils/widgets/lcd.py +8 -0
  109. pymodaq/utils/h5modules/__init__.py +2 -0
  110. pymodaq/utils/h5modules/module_saving.py +526 -0
  111. pymodaq/utils/leco/__init__.py +25 -0
  112. pymodaq/utils/leco/daq_move_LECODirector.py +217 -0
  113. pymodaq/utils/leco/daq_xDviewer_LECODirector.py +163 -0
  114. pymodaq/utils/leco/director_utils.py +74 -0
  115. pymodaq/utils/leco/leco_director.py +166 -0
  116. pymodaq/utils/leco/pymodaq_listener.py +364 -0
  117. pymodaq/utils/leco/rpc_method_definitions.py +43 -0
  118. pymodaq/utils/leco/utils.py +74 -0
  119. pymodaq/utils/logger.py +6 -0
  120. pymodaq/utils/managers/__init__.py +0 -0
  121. pymodaq/utils/managers/batchscan_manager.py +346 -0
  122. pymodaq/utils/managers/modules_manager.py +589 -0
  123. pymodaq/utils/managers/overshoot_manager.py +242 -0
  124. pymodaq/utils/managers/preset_manager.py +229 -0
  125. pymodaq/utils/managers/preset_manager_utils.py +262 -0
  126. pymodaq/utils/managers/remote_manager.py +484 -0
  127. pymodaq/utils/math_utils.py +6 -0
  128. pymodaq/utils/messenger.py +6 -0
  129. pymodaq/utils/parameter/__init__.py +10 -0
  130. pymodaq/utils/parameter/utils.py +6 -0
  131. pymodaq/utils/scanner/__init__.py +5 -0
  132. pymodaq/utils/scanner/scan_config.py +16 -0
  133. pymodaq/utils/scanner/scan_factory.py +259 -0
  134. pymodaq/utils/scanner/scan_selector.py +477 -0
  135. pymodaq/utils/scanner/scanner.py +324 -0
  136. pymodaq/utils/scanner/scanners/_1d_scanners.py +174 -0
  137. pymodaq/utils/scanner/scanners/_2d_scanners.py +299 -0
  138. pymodaq/utils/scanner/scanners/__init__.py +1 -0
  139. pymodaq/utils/scanner/scanners/sequential.py +224 -0
  140. pymodaq/utils/scanner/scanners/tabular.py +319 -0
  141. pymodaq/utils/scanner/utils.py +110 -0
  142. pymodaq/utils/svg/__init__.py +6 -0
  143. pymodaq/utils/svg/svg_renderer.py +20 -0
  144. pymodaq/utils/svg/svg_view.py +35 -0
  145. pymodaq/utils/svg/svg_viewer2D.py +50 -0
  146. pymodaq/utils/tcp_ip/__init__.py +6 -0
  147. pymodaq/utils/tcp_ip/mysocket.py +12 -0
  148. pymodaq/utils/tcp_ip/serializer.py +13 -0
  149. pymodaq/utils/tcp_ip/tcp_server_client.py +772 -0
  150. pymodaq-5.1.6.dist-info/METADATA +238 -0
  151. pymodaq-5.1.6.dist-info/RECORD +154 -0
  152. pymodaq-5.1.6.dist-info/WHEEL +4 -0
  153. pymodaq-5.1.6.dist-info/entry_points.txt +7 -0
  154. pymodaq-5.1.6.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,259 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created the 05/12/2022
4
+
5
+ @author: Sebastien Weber
6
+ """
7
+ from __future__ import annotations
8
+
9
+ from abc import ABCMeta, abstractmethod
10
+ from typing import Callable, Union, List, Tuple, TYPE_CHECKING
11
+
12
+
13
+ import numpy as np
14
+ from qtpy import QtWidgets
15
+
16
+ from pymodaq_utils.factory import ObjectFactory
17
+ from pymodaq_utils.logger import set_logger, get_module_name
18
+ from pymodaq_utils.abstract import abstract_attribute
19
+ from pymodaq_utils import math_utils as mutils
20
+ from pymodaq_utils import config as configmod
21
+
22
+ from pymodaq_gui.managers.parameter_manager import ParameterManager, Parameter
23
+ from pymodaq_data.data import Axis, DataDistribution
24
+
25
+ from pymodaq.utils.scanner.scan_config import ScanConfig
26
+
27
+ try:
28
+ from pymodaq_gui.config_saver_loader import ConfigSaverLoader
29
+ except ModuleNotFoundError:
30
+ from pymodaq_gui.config import ConfigSaverLoader
31
+
32
+ from pymodaq.utils.config import Config as ControlModulesConfig
33
+
34
+
35
+ if TYPE_CHECKING:
36
+ from pymodaq.control_modules.daq_move import DAQ_Move
37
+ from pymodaq.utils.scanner.scan_selector import Selector
38
+
39
+
40
+ logger = set_logger(get_module_name(__file__))
41
+
42
+ config_utils = configmod.Config()
43
+ config = ControlModulesConfig()
44
+
45
+ class ScanParameterManager(ParameterManager):
46
+ settings_name = 'scanner_settings'
47
+
48
+ def __init__(self):
49
+ super().__init__()
50
+ self.settings_tree.header().setVisible(True)
51
+ self.settings_tree.header().setSectionResizeMode(QtWidgets.QHeaderView.ResizeMode.Interactive)
52
+ self.settings_tree.header().setMinimumSectionSize(150)
53
+ self.settings_tree.setMinimumHeight(150)
54
+
55
+
56
+ class ScannerBase(ScanParameterManager, metaclass=ABCMeta):
57
+ """Abstract class for all Scanners
58
+
59
+ Attributes
60
+ ----------
61
+ scan_type: str
62
+ String defining the main identifier
63
+ scan_subtype: str
64
+ String defining the second identifier
65
+ params: List[dict]
66
+ list specifying the scanner set of parameters to properly configure all the scan steps
67
+ positions: np.ndarray
68
+ ndarray of all positions. First dimension is number of actuators, second is positions of a given actuator at
69
+ each step
70
+ axes_unique: List[np.ndarray]
71
+ list of ndarrays representing unique values of steps for each actuator in the scan
72
+ axes_indexes: np.ndarray
73
+ ndarray of indexes from axes_unique for each value in positions
74
+ n_steps: int
75
+ Number of scan steps. Equal to the second dimension of positions
76
+ n_axes: int
77
+ Number of actuators/scan axes. Equal to the first dimension of positions
78
+ """
79
+ scan_type: str = abstract_attribute()
80
+ scan_subtype: str = abstract_attribute()
81
+
82
+ params: List[dict] = abstract_attribute()
83
+ axes_unique: List[np.ndarray] = abstract_attribute()
84
+ axes_indexes: np.ndarray = abstract_attribute()
85
+ n_steps: int = abstract_attribute()
86
+ n_axes: int = abstract_attribute()
87
+ distribution: DataDistribution = abstract_attribute()
88
+ save_settings = True
89
+
90
+ def __init__(self, actuators: List[DAQ_Move] = None, display_units=True):
91
+ super().__init__()
92
+ self.positions: np.ndarray = None
93
+ self.n_steps = 1
94
+ self.config = ScanConfig()
95
+ self.display_units = display_units
96
+ base_path = [act.title for act in actuators] + [self.scan_type, self.scan_subtype]
97
+
98
+ self.config_saver_loader = ConfigSaverLoader(self.settings,
99
+ self.config,
100
+ base_path)
101
+
102
+ self.actuators: List[DAQ_Move] = actuators
103
+
104
+ self.set_settings_titles()
105
+ self.set_settings_values()
106
+ if len(actuators) > 0:
107
+ self.set_units()
108
+
109
+ if self.check_steps():
110
+ self.set_scan()
111
+
112
+ @abstractmethod
113
+ def set_units(self):
114
+ """ Update settings units depending on the scanner type and the display_units boolean"""
115
+ ...
116
+
117
+ def set_settings_titles(self):
118
+ """Update the settings accordingly with the selected actuators"""
119
+ ...
120
+
121
+ def set_settings_values(self, param: Parameter = None):
122
+ self.config_saver_loader.load_config(param)
123
+
124
+ @property
125
+ def actuators(self) -> List[DAQ_Move]:
126
+ return self._actuators
127
+
128
+ @actuators.setter
129
+ def actuators(self, actuators: List[DAQ_Move]):
130
+ self._actuators = actuators
131
+ base_path = self.actuators_name + [self.scan_type, self.scan_subtype]
132
+ self.config_saver_loader.base_path = base_path
133
+
134
+ @property
135
+ def actuators_name(self) -> List[str]:
136
+ return [act.title for act in self.actuators]
137
+
138
+ def check_steps(self):
139
+ steps_limit = config('scan', 'steps_limit')
140
+ n_steps = self.evaluate_steps()
141
+ return n_steps <= steps_limit
142
+
143
+ def __call__(self, **kwargs):
144
+ return self(**kwargs)
145
+
146
+ @abstractmethod
147
+ def set_scan(self):
148
+ """To be reimplemented. Calculations of all mandatory attributes from the settings"""
149
+ ...
150
+
151
+ @abstractmethod
152
+ def get_nav_axes(self) -> List[Axis]:
153
+ """To be reimplemented. Calculations of all navigation axes from attributes"""
154
+ ...
155
+
156
+ @abstractmethod
157
+ def get_scan_shape(self) -> Tuple[int]:
158
+ """To be reimplemented. Calculations of all the final shape of the scan"""
159
+ ...
160
+
161
+ @abstractmethod
162
+ def get_indexes_from_scan_index(self, scan_index: int) -> Tuple[int]:
163
+ """To be reimplemented. Calculations of indexes within the scan"""
164
+ ...
165
+
166
+ def get_info_from_positions(self, positions: np.ndarray):
167
+ """Set mandatory attributes from a ndarray of positions"""
168
+ if positions is not None:
169
+ if len(positions.shape) == 1:
170
+ positions = np.expand_dims(positions, 1)
171
+ axes_unique = []
172
+ for ax in positions.T:
173
+ axes_unique.append(np.unique(ax))
174
+ axes_indexes = np.zeros_like(positions, dtype=int)
175
+ for ind in range(positions.shape[0]):
176
+ for ind_pos, pos in enumerate(positions[ind]):
177
+ axes_indexes[ind, ind_pos] = mutils.find_index(axes_unique[ind_pos], pos)[0][0]
178
+
179
+ self.n_axes = len(axes_unique)
180
+ self.axes_unique = axes_unique
181
+ self.axes_indexes = axes_indexes
182
+ self.positions = positions
183
+ self.n_steps = positions.shape[0]
184
+
185
+ @abstractmethod
186
+ def evaluate_steps(self):
187
+ """To be reimplemented. Quick evaluation of the number of steps to stop the calculation if the evaluation os above the
188
+ configured limit
189
+ """
190
+ ...
191
+
192
+ def update_model(self):
193
+ """Method to reimplement and use for scanners using table_view types Parameters to set and apply the underlying
194
+ model
195
+
196
+ See Also
197
+ --------
198
+ SequentialScanner, TabularScanner, pymodaq.utils.parameter.pymodaq_ptypes.tableview
199
+ """
200
+ ...
201
+
202
+ def save_scan_parameters(self):
203
+ if self.save_settings:
204
+ self.config_saver_loader.save_config()
205
+
206
+ @abstractmethod
207
+ def update_from_scan_selector(self, scan_selector: Selector):
208
+ """To be reimplemented. Process the Selector object to set the Scanner settings
209
+
210
+ See Also
211
+ --------
212
+ Selector, ScanSelector
213
+ """
214
+ ...
215
+
216
+
217
+ class ScannerFactory(ObjectFactory):
218
+ """Factory class registering and storing Scanners"""
219
+
220
+ @classmethod
221
+ def register(cls) -> Callable:
222
+ """ To be used as a decorator
223
+
224
+ Register in the class registry a new scanner class using its 2 identifiers: scan_type and scan_sub_type
225
+ """
226
+ def inner_wrapper(wrapped_class: ScannerBase) -> Callable:
227
+ if cls.__name__ not in cls._builders:
228
+ cls._builders[cls.__name__] = {}
229
+ key = wrapped_class.scan_type
230
+ sub_key = wrapped_class.scan_subtype
231
+
232
+ if key not in cls._builders[cls.__name__]:
233
+ cls._builders[cls.__name__][key] = {}
234
+ if sub_key not in cls._builders[cls.__name__][key]:
235
+ cls._builders[cls.__name__][key][sub_key] = wrapped_class
236
+ else:
237
+ logger.warning(f'The {cls.__name__}/{key}/{sub_key} builder is already registered. Replacing it')
238
+ return wrapped_class
239
+
240
+ return inner_wrapper
241
+
242
+ @classmethod
243
+ def create(cls, key, sub_key, **kwargs) -> ScannerBase:
244
+ builder = cls._builders[cls.__name__].get(key).get(sub_key)
245
+ if not builder:
246
+ raise ValueError(key)
247
+ return builder(**kwargs)
248
+
249
+ def get(self, scan_type, scan_sub_type, **kwargs):
250
+ return self.create(scan_type, scan_sub_type, **kwargs)
251
+
252
+ def scan_types(self) -> List[str]:
253
+ """Returns the list of scan types, main identifier of a given scanner"""
254
+ return sorted(list(self.builders[self.__class__.__name__].keys()))
255
+
256
+ def scan_sub_types(self, scan_type: str) -> List[str]:
257
+ """Returns the list of scan subtypes, second identifier of a given scanner of type scan_type"""
258
+ return list(self.builders[self.__class__.__name__][scan_type].keys())
259
+