pymodaq 3.6.13__py3-none-any.whl → 4.0.1__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 pymodaq might be problematic. Click here for more details.

Files changed (233) hide show
  1. pymodaq/__init__.py +13 -6
  2. pymodaq/control_modules/__init__.py +0 -7
  3. pymodaq/control_modules/daq_move.py +965 -2
  4. pymodaq/control_modules/daq_move_ui.py +319 -0
  5. pymodaq/control_modules/daq_viewer.py +1573 -3
  6. pymodaq/control_modules/daq_viewer_ui.py +393 -0
  7. pymodaq/control_modules/mocks.py +51 -0
  8. pymodaq/control_modules/move_utility_classes.py +709 -8
  9. pymodaq/control_modules/utils.py +256 -0
  10. pymodaq/control_modules/viewer_utility_classes.py +663 -6
  11. pymodaq/daq_utils.py +89 -0
  12. pymodaq/dashboard.py +91 -72
  13. pymodaq/examples/custom_app.py +12 -11
  14. pymodaq/examples/custom_viewer.py +10 -10
  15. pymodaq/examples/function_plotter.py +16 -13
  16. pymodaq/examples/nonlinearscanner.py +8 -6
  17. pymodaq/examples/parameter_ex.py +7 -7
  18. pymodaq/examples/preset_MockCamera.xml +1 -0
  19. pymodaq/extensions/__init__.py +16 -0
  20. pymodaq/extensions/console.py +76 -0
  21. pymodaq/{daq_logger.py → extensions/daq_logger.py} +115 -65
  22. pymodaq/extensions/daq_scan.py +1339 -0
  23. pymodaq/extensions/daq_scan_ui.py +240 -0
  24. pymodaq/extensions/h5browser.py +23 -0
  25. pymodaq/{pid → extensions/pid}/__init__.py +4 -2
  26. pymodaq/{pid → extensions/pid}/daq_move_PID.py +2 -2
  27. pymodaq/{pid → extensions/pid}/pid_controller.py +48 -36
  28. pymodaq/{pid → extensions/pid}/utils.py +52 -6
  29. pymodaq/extensions/utils.py +40 -0
  30. pymodaq/post_treatment/__init__.py +6 -0
  31. pymodaq/{daq_analysis → post_treatment/daq_analysis}/daq_analysis_main.py +17 -17
  32. pymodaq/{daq_measurement → post_treatment/daq_measurement}/daq_measurement_main.py +8 -14
  33. pymodaq/post_treatment/load_and_plot.py +219 -0
  34. pymodaq/post_treatment/process_to_scalar.py +263 -0
  35. pymodaq/resources/QtDesigner_Ressources/Icon_Library/run_all.png +0 -0
  36. pymodaq/resources/QtDesigner_Ressources/Icon_Library/stop_all.png +0 -0
  37. pymodaq/resources/QtDesigner_Ressources/QtDesigner_ressources.bat +1 -1
  38. pymodaq/resources/QtDesigner_Ressources/QtDesigner_ressources.qrc +1 -0
  39. pymodaq/resources/QtDesigner_Ressources/QtDesigner_ressources_rc.py +109784 -109173
  40. pymodaq/resources/QtDesigner_Ressources/icons.svg +142 -0
  41. pymodaq/resources/VERSION +1 -1
  42. pymodaq/resources/config_template.toml +32 -13
  43. pymodaq/resources/preset_default.xml +1 -1
  44. pymodaq/{daq_utils → utils}/Tuto innosetup/script_full_setup.iss +1 -1
  45. pymodaq/utils/__init__.py +0 -29
  46. pymodaq/utils/abstract/__init__.py +48 -0
  47. pymodaq/{daq_utils → utils}/abstract/logger.py +7 -3
  48. pymodaq/utils/array_manipulation.py +379 -8
  49. pymodaq/{daq_utils → utils}/calibration_camera.py +6 -6
  50. pymodaq/{daq_utils → utils}/chrono_timer.py +1 -1
  51. pymodaq/utils/config.py +448 -0
  52. pymodaq/utils/conftests.py +5 -0
  53. pymodaq/utils/daq_utils.py +828 -8
  54. pymodaq/utils/data.py +1873 -7
  55. pymodaq/{daq_utils → utils}/db/db_logger/db_logger.py +86 -47
  56. pymodaq/{daq_utils → utils}/db/db_logger/db_logger_models.py +31 -10
  57. pymodaq/{daq_utils → utils}/enums.py +12 -7
  58. pymodaq/utils/exceptions.py +37 -0
  59. pymodaq/utils/factory.py +82 -0
  60. pymodaq/{daq_utils → utils}/gui_utils/__init__.py +1 -1
  61. pymodaq/utils/gui_utils/custom_app.py +129 -0
  62. pymodaq/utils/gui_utils/file_io.py +66 -0
  63. pymodaq/{daq_utils → utils}/gui_utils/layout.py +2 -2
  64. pymodaq/{daq_utils → utils}/gui_utils/utils.py +13 -3
  65. pymodaq/{daq_utils → utils}/gui_utils/widgets/__init__.py +2 -2
  66. pymodaq/utils/gui_utils/widgets/label.py +24 -0
  67. pymodaq/{daq_utils → utils}/gui_utils/widgets/lcd.py +12 -7
  68. pymodaq/{daq_utils → utils}/gui_utils/widgets/push.py +66 -2
  69. pymodaq/{daq_utils → utils}/gui_utils/widgets/qled.py +6 -4
  70. pymodaq/utils/gui_utils/widgets/spinbox.py +24 -0
  71. pymodaq/{daq_utils → utils}/gui_utils/widgets/table.py +2 -2
  72. pymodaq/utils/h5modules/__init__.py +1 -0
  73. pymodaq/{daq_utils/h5backend.py → utils/h5modules/backends.py} +200 -112
  74. pymodaq/utils/h5modules/browsing.py +683 -0
  75. pymodaq/utils/h5modules/data_saving.py +839 -0
  76. pymodaq/utils/h5modules/h5logging.py +110 -0
  77. pymodaq/utils/h5modules/module_saving.py +350 -0
  78. pymodaq/utils/h5modules/saving.py +914 -0
  79. pymodaq/utils/h5modules/utils.py +85 -0
  80. pymodaq/utils/logger.py +64 -6
  81. pymodaq/utils/managers/action_manager.py +460 -0
  82. pymodaq/{daq_utils → utils}/managers/batchscan_manager.py +144 -112
  83. pymodaq/{daq_utils → utils}/managers/modules_manager.py +188 -114
  84. pymodaq/{daq_utils → utils}/managers/overshoot_manager.py +3 -3
  85. pymodaq/utils/managers/parameter_manager.py +110 -0
  86. pymodaq/{daq_utils → utils}/managers/preset_manager.py +17 -13
  87. pymodaq/{daq_utils → utils}/managers/preset_manager_utils.py +8 -7
  88. pymodaq/{daq_utils → utils}/managers/remote_manager.py +7 -6
  89. pymodaq/{daq_utils → utils}/managers/roi_manager.py +148 -57
  90. pymodaq/utils/math_utils.py +546 -10
  91. pymodaq/{daq_utils → utils}/messenger.py +5 -1
  92. pymodaq/utils/parameter/__init__.py +2 -15
  93. pymodaq/{daq_utils → utils}/parameter/ioxml.py +12 -6
  94. pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/__init__.py +1 -3
  95. pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/filedir.py +1 -1
  96. pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/itemselect.py +3 -0
  97. pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/led.py +1 -1
  98. pymodaq/utils/parameter/pymodaq_ptypes/pixmap.py +161 -0
  99. pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/slide.py +1 -1
  100. pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/table.py +1 -1
  101. pymodaq/utils/parameter/utils.py +206 -11
  102. pymodaq/utils/plotting/data_viewers/__init__.py +6 -0
  103. pymodaq/utils/plotting/data_viewers/viewer.py +393 -0
  104. pymodaq/utils/plotting/data_viewers/viewer0D.py +251 -0
  105. pymodaq/utils/plotting/data_viewers/viewer1D.py +574 -0
  106. pymodaq/{daq_utils → utils}/plotting/data_viewers/viewer1Dbasic.py +8 -3
  107. pymodaq/{daq_utils → utils}/plotting/data_viewers/viewer2D.py +292 -357
  108. pymodaq/{daq_utils → utils}/plotting/data_viewers/viewer2D_basic.py +58 -75
  109. pymodaq/utils/plotting/data_viewers/viewerND.py +738 -0
  110. pymodaq/{daq_utils → utils}/plotting/gant_chart.py +2 -2
  111. pymodaq/{daq_utils → utils}/plotting/items/axis_scaled.py +4 -2
  112. pymodaq/{daq_utils → utils}/plotting/items/image.py +8 -6
  113. pymodaq/utils/plotting/navigator.py +355 -0
  114. pymodaq/utils/plotting/scan_selector.py +480 -0
  115. pymodaq/utils/plotting/utils/axes_viewer.py +88 -0
  116. pymodaq/utils/plotting/utils/filter.py +538 -0
  117. pymodaq/utils/plotting/utils/lineout.py +224 -0
  118. pymodaq/{daq_utils → utils}/plotting/utils/plot_utils.py +196 -84
  119. pymodaq/{daq_utils → utils}/plotting/utils/signalND.py +21 -13
  120. pymodaq/utils/plotting/widgets.py +76 -0
  121. pymodaq/utils/scanner/__init__.py +10 -0
  122. pymodaq/utils/scanner/scan_factory.py +204 -0
  123. pymodaq/utils/scanner/scanner.py +271 -0
  124. pymodaq/utils/scanner/scanners/_1d_scanners.py +117 -0
  125. pymodaq/utils/scanner/scanners/_2d_scanners.py +293 -0
  126. pymodaq/utils/scanner/scanners/sequential.py +192 -0
  127. pymodaq/utils/scanner/scanners/tabular.py +294 -0
  128. pymodaq/utils/scanner/utils.py +83 -0
  129. pymodaq/utils/slicing.py +47 -0
  130. pymodaq/utils/svg/__init__.py +6 -0
  131. pymodaq/utils/svg/svg_renderer.py +20 -0
  132. pymodaq/utils/svg/svg_view.py +35 -0
  133. pymodaq/utils/svg/svg_viewer2D.py +51 -0
  134. pymodaq/{daq_utils → utils}/tcp_server_client.py +36 -37
  135. pymodaq/{daq_utils → utils}/tree_layout/tree_layout_main.py +50 -35
  136. pymodaq/utils/units.py +216 -0
  137. pymodaq-4.0.1.dist-info/METADATA +159 -0
  138. {pymodaq-3.6.13.dist-info → pymodaq-4.0.1.dist-info}/RECORD +167 -170
  139. {pymodaq-3.6.13.dist-info → pymodaq-4.0.1.dist-info}/WHEEL +1 -2
  140. pymodaq-4.0.1.dist-info/entry_points.txt +8 -0
  141. pymodaq/daq_move/daq_move_gui.py +0 -279
  142. pymodaq/daq_move/daq_move_gui.ui +0 -534
  143. pymodaq/daq_move/daq_move_main.py +0 -1042
  144. pymodaq/daq_move/process_from_QtDesigner_DAQ_Move_GUI.bat +0 -2
  145. pymodaq/daq_move/utility_classes.py +0 -686
  146. pymodaq/daq_scan.py +0 -2160
  147. pymodaq/daq_utils/array_manipulation.py +0 -386
  148. pymodaq/daq_utils/config.py +0 -273
  149. pymodaq/daq_utils/conftests.py +0 -7
  150. pymodaq/daq_utils/custom_parameter_tree.py +0 -9
  151. pymodaq/daq_utils/daq_enums.py +0 -133
  152. pymodaq/daq_utils/daq_utils.py +0 -1402
  153. pymodaq/daq_utils/exceptions.py +0 -71
  154. pymodaq/daq_utils/gui_utils/custom_app.py +0 -103
  155. pymodaq/daq_utils/gui_utils/file_io.py +0 -75
  156. pymodaq/daq_utils/gui_utils/widgets/spinbox.py +0 -9
  157. pymodaq/daq_utils/h5exporter_hyperspy.py +0 -115
  158. pymodaq/daq_utils/h5exporters.py +0 -242
  159. pymodaq/daq_utils/h5modules.py +0 -1559
  160. pymodaq/daq_utils/h5utils.py +0 -241
  161. pymodaq/daq_utils/managers/action_manager.py +0 -236
  162. pymodaq/daq_utils/managers/parameter_manager.py +0 -57
  163. pymodaq/daq_utils/math_utils.py +0 -705
  164. pymodaq/daq_utils/parameter/__init__.py +0 -1
  165. pymodaq/daq_utils/parameter/oldpymodaq_ptypes.py +0 -1626
  166. pymodaq/daq_utils/parameter/pymodaq_ptypes/pixmap.py +0 -85
  167. pymodaq/daq_utils/parameter/utils.py +0 -136
  168. pymodaq/daq_utils/plotting/data_viewers/__init__.py +0 -0
  169. pymodaq/daq_utils/plotting/data_viewers/process_from_QtDesigner_0DViewer_GUI.bat +0 -2
  170. pymodaq/daq_utils/plotting/data_viewers/viewer0D.py +0 -204
  171. pymodaq/daq_utils/plotting/data_viewers/viewer0D_GUI.py +0 -89
  172. pymodaq/daq_utils/plotting/data_viewers/viewer0D_GUI.ui +0 -131
  173. pymodaq/daq_utils/plotting/data_viewers/viewer1D.py +0 -781
  174. pymodaq/daq_utils/plotting/data_viewers/viewerND.py +0 -894
  175. pymodaq/daq_utils/plotting/data_viewers/viewerbase.py +0 -64
  176. pymodaq/daq_utils/plotting/items/__init__.py +0 -0
  177. pymodaq/daq_utils/plotting/navigator.py +0 -500
  178. pymodaq/daq_utils/plotting/scan_selector.py +0 -289
  179. pymodaq/daq_utils/plotting/utils/__init__.py +0 -0
  180. pymodaq/daq_utils/plotting/utils/filter.py +0 -236
  181. pymodaq/daq_utils/plotting/viewer0D/__init__.py +0 -0
  182. pymodaq/daq_utils/plotting/viewer0D/viewer0D_main.py +0 -4
  183. pymodaq/daq_utils/plotting/viewer1D/__init__.py +0 -0
  184. pymodaq/daq_utils/plotting/viewer1D/viewer1D_main.py +0 -4
  185. pymodaq/daq_utils/plotting/viewer1D/viewer1Dbasic.py +0 -4
  186. pymodaq/daq_utils/plotting/viewer2D/viewer_2D_basic.py +0 -4
  187. pymodaq/daq_utils/plotting/viewer2D/viewer_2D_main.py +0 -4
  188. pymodaq/daq_utils/plotting/viewerND/__init__.py +0 -0
  189. pymodaq/daq_utils/plotting/viewerND/viewerND_main.py +0 -4
  190. pymodaq/daq_utils/scanner.py +0 -1289
  191. pymodaq/daq_utils/tree_layout/__init__.py +0 -0
  192. pymodaq/daq_viewer/__init__.py +0 -0
  193. pymodaq/daq_viewer/daq_gui_settings.py +0 -237
  194. pymodaq/daq_viewer/daq_gui_settings.ui +0 -441
  195. pymodaq/daq_viewer/daq_viewer_main.py +0 -2225
  196. pymodaq/daq_viewer/process_from_QtDesigner_DAQ_GUI_settings.bat +0 -2
  197. pymodaq/daq_viewer/utility_classes.py +0 -673
  198. pymodaq/examples/logger_image/__init__.py +0 -0
  199. pymodaq/examples/logger_image/logger_displayer.py +0 -121
  200. pymodaq/examples/logger_image/setup.svg +0 -3119
  201. pymodaq/examples/logger_image/setup_svg.py +0 -114
  202. pymodaq/h5browser.py +0 -39
  203. pymodaq/utils/scanner.py +0 -15
  204. pymodaq-3.6.13.dist-info/METADATA +0 -39
  205. pymodaq-3.6.13.dist-info/entry_points.txt +0 -8
  206. pymodaq-3.6.13.dist-info/top_level.txt +0 -1
  207. /pymodaq/{daq_analysis → post_treatment/daq_analysis}/__init__.py +0 -0
  208. /pymodaq/{daq_measurement → post_treatment/daq_measurement}/__init__.py +0 -0
  209. /pymodaq/{daq_measurement → post_treatment/daq_measurement}/daq_measurement_GUI.py +0 -0
  210. /pymodaq/{daq_measurement → post_treatment/daq_measurement}/daq_measurement_GUI.ui +0 -0
  211. /pymodaq/{daq_measurement → post_treatment/daq_measurement}/process_from_QtDesigner_DAQ_Measurement_GUI.bat +0 -0
  212. /pymodaq/{daq_utils → utils}/Tuto innosetup/Tuto innosetup.odt +0 -0
  213. /pymodaq/{daq_utils → utils}/Tuto innosetup/Tuto innosetup.pdf +0 -0
  214. /pymodaq/{daq_move → utils/db}/__init__.py +0 -0
  215. /pymodaq/{daq_utils → utils/db/db_logger}/__init__.py +0 -0
  216. /pymodaq/{daq_utils → utils}/gui_utils/dock.py +0 -0
  217. /pymodaq/{daq_utils → utils}/gui_utils/list_picker.py +0 -0
  218. /pymodaq/{daq_utils/abstract → utils/managers}/__init__.py +0 -0
  219. /pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/bool.py +0 -0
  220. /pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/date.py +0 -0
  221. /pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/list.py +0 -0
  222. /pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/numeric.py +0 -0
  223. /pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/tableview.py +0 -0
  224. /pymodaq/{daq_utils → utils}/parameter/pymodaq_ptypes/text.py +0 -0
  225. /pymodaq/{daq_utils/db → utils/plotting}/__init__.py +0 -0
  226. /pymodaq/{daq_utils → utils}/plotting/image_viewer.py +0 -0
  227. /pymodaq/{daq_utils/db/db_logger → utils/plotting/items}/__init__.py +0 -0
  228. /pymodaq/{daq_utils → utils}/plotting/items/crosshair.py +0 -0
  229. /pymodaq/{daq_utils/managers → utils/plotting/utils}/__init__.py +0 -0
  230. /pymodaq/{daq_utils → utils}/qvariant.py +0 -0
  231. /pymodaq/{daq_utils/plotting/viewer2D → utils/scanner/scanners}/__init__.py +0 -0
  232. /pymodaq/{daq_utils/plotting → utils/tree_layout}/__init__.py +0 -0
  233. {pymodaq-3.6.13.dist-info → pymodaq-4.0.1.dist-info/licenses}/LICENSE +0 -0
@@ -0,0 +1,294 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created the 05/12/2022
4
+
5
+ @author: Sebastien Weber
6
+ """
7
+ from typing import List, Tuple
8
+
9
+ import numpy as np
10
+
11
+ from qtpy import QtCore, QtWidgets
12
+ from pymodaq.utils.data import Axis, DataDistribution
13
+ from pymodaq.utils.logger import set_logger, get_module_name
14
+ from pymodaq.utils import math_utils as mutils
15
+ from pymodaq.utils import config as configmod
16
+ from pymodaq.utils import gui_utils as gutils
17
+ from ..scan_factory import ScannerFactory, ScannerBase, ScanParameterManager
18
+ from pymodaq.utils.parameter import utils as putils
19
+ from pymodaq.utils.parameter.pymodaq_ptypes import TableViewCustom
20
+ from pymodaq.utils.plotting.scan_selector import Selector
21
+ from pymodaq.utils.plotting.utils.plot_utils import Point, get_sub_segmented_positions
22
+
23
+
24
+ logger = set_logger(get_module_name(__file__))
25
+ config = configmod.Config()
26
+
27
+
28
+ class TableModelTabular(gutils.TableModel):
29
+ """Table Model for the Model/View Qt framework dedicated to the Tabular scan mode"""
30
+ def __init__(self, data, axes_name=None, **kwargs):
31
+ if axes_name is None:
32
+ if 'header' in kwargs: # when saved as XML the header will be saved and restored here
33
+ axes_name = [h for h in kwargs['header']]
34
+ kwargs.pop('header')
35
+ else:
36
+ raise Exception('Invalid header')
37
+
38
+ header = [name for name in axes_name]
39
+ editable = [True for name in axes_name]
40
+ super().__init__(data, header, editable=editable, **kwargs)
41
+
42
+ def __len__(self):
43
+ return len(self._data)
44
+
45
+ def add_data(self, row, data=None):
46
+ if data is not None:
47
+ self.insert_data(row, [float(d) for d in data])
48
+ else:
49
+ self.insert_data(row, [0. for name in self.header])
50
+
51
+ def remove_data(self, row):
52
+ self.remove_row(row)
53
+
54
+ def load_txt(self):
55
+ fname = gutils.select_file(start_path=None, save=False, ext='*')
56
+ if fname is not None and fname != '':
57
+ while self.rowCount(self.index(-1, -1)) > 0:
58
+ self.remove_row(0)
59
+
60
+ data = np.loadtxt(fname)
61
+ if len(data.shape) == 1:
62
+ data = data.reshape((data.size, 1))
63
+ self.set_data_all(data)
64
+
65
+ def save_txt(self):
66
+ fname = gutils.select_file(start_path=None, save=True, ext='dat')
67
+ if fname is not None and fname != '':
68
+ np.savetxt(fname, self.get_data_all(), delimiter='\t')
69
+
70
+ def __repr__(self):
71
+ return f'{self.__class__.__name__} from module {self.__class__.__module__}'
72
+
73
+ def validate_data(self, row, col, value):
74
+ """
75
+ make sure the values and signs of the start, stop and step values are "correct"
76
+ Parameters
77
+ ----------
78
+ row: (int) row within the table that is to be changed
79
+ col: (int) col within the table that is to be changed
80
+ value: (float) new value for the value defined by row and col
81
+
82
+ Returns
83
+ -------
84
+ bool: True is the new value is fine (change some other values if needed) otherwise False
85
+ """
86
+
87
+ return True
88
+
89
+
90
+ class TableModelTabularReadOnly(TableModelTabular):
91
+ def setData(self, index, value, role):
92
+ return False
93
+
94
+
95
+ @ScannerFactory.register('Tabular', 'Linear')
96
+ class TabularScanner(ScannerBase):
97
+ params = [
98
+ {'title': 'Positions', 'name': 'tabular_table', 'type': 'table_view', 'delegate': gutils.SpinBoxDelegate,
99
+ 'menu': True},
100
+ ]
101
+ distribution = DataDistribution['spread']
102
+
103
+ def __init__(self, actuators: List[str]):
104
+ self.table_model: TableModelTabular = None
105
+ self.table_view: TableViewCustom = None
106
+ super().__init__(actuators=actuators)
107
+ self.update_model()
108
+
109
+ @property
110
+ def actuators(self):
111
+ return self._actuators
112
+
113
+ @actuators.setter
114
+ def actuators(self, actuators_name):
115
+ self._actuators = actuators_name
116
+ self.update_model()
117
+
118
+ def update_model(self, init_data=None):
119
+ if init_data is None:
120
+ init_data = [[0. for _ in self._actuators]]
121
+
122
+ self.table_model = TableModelTabular(init_data, [act.title for act in self._actuators])
123
+ self.table_view = putils.get_widget_from_tree(self.settings_tree, TableViewCustom)[0]
124
+ self.settings.child('tabular_table').setValue(self.table_model)
125
+ self.n_axes = len(self._actuators)
126
+ self.update_table_view()
127
+
128
+ def update_table_view(self):
129
+ self.table_view.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents)
130
+ self.table_view.horizontalHeader().setStretchLastSection(True)
131
+ self.table_view.setSelectionBehavior(QtWidgets.QTableView.SelectRows)
132
+ self.table_view.setSelectionMode(QtWidgets.QTableView.SingleSelection)
133
+ styledItemDelegate = QtWidgets.QStyledItemDelegate()
134
+ styledItemDelegate.setItemEditorFactory(gutils.SpinBoxDelegate())
135
+ self.table_view.setItemDelegate(styledItemDelegate)
136
+
137
+ self.table_view.setDragEnabled(True)
138
+ self.table_view.setDropIndicatorShown(True)
139
+ self.table_view.setAcceptDrops(True)
140
+ self.table_view.viewport().setAcceptDrops(True)
141
+ self.table_view.setDefaultDropAction(QtCore.Qt.MoveAction)
142
+ self.table_view.setDragDropMode(QtWidgets.QTableView.InternalMove)
143
+ self.table_view.setDragDropOverwriteMode(False)
144
+
145
+ self.table_view.add_data_signal[int].connect(self.table_model.add_data)
146
+ self.table_view.remove_row_signal[int].connect(self.table_model.remove_data)
147
+ self.table_view.load_data_signal.connect(self.table_model.load_txt)
148
+ self.table_view.save_data_signal.connect(self.table_model.save_txt)
149
+
150
+ def evaluate_steps(self):
151
+ return len(self.table_model)
152
+
153
+ def set_scan(self):
154
+ positions = np.array(self.table_model.get_data_all())
155
+ self.get_info_from_positions(positions)
156
+
157
+ def update_tabular_positions(self, positions: np.ndarray = None):
158
+ """Convenience function to write positions directly into the tabular table
159
+
160
+ Parameters
161
+ ----------
162
+ positions: ndarray
163
+ a 2D ndarray with as many columns as selected actuators
164
+ """
165
+ try:
166
+ if positions is None:
167
+ if self.settings.child('tabular_settings',
168
+ 'tabular_selection').value() == 'Polylines': # from ROI
169
+ viewer = self.scan_selector.selector_source
170
+
171
+ if self.settings.child('tabular_settings', 'tabular_subtype').value() == 'Linear':
172
+ positions = self.scan_selector.scan_selector.getArrayIndexes(
173
+ spacing=self.settings.child('tabular_settings', 'tabular_step').value())
174
+ elif self.settings.child('tabular_settings',
175
+ 'tabular_subtype').value() == 'Adaptive':
176
+ positions = self.scan_selector.scan_selector.get_vertex()
177
+
178
+ steps_x, steps_y = zip(*positions)
179
+ steps_x, steps_y = viewer.scale_axis(np.array(steps_x), np.array(steps_y))
180
+ positions = np.transpose(np.array([steps_x, steps_y]))
181
+ self.update_model(init_data=positions)
182
+ else:
183
+ self.update_model()
184
+ elif isinstance(positions, np.ndarray):
185
+ self.update_model(init_data=positions)
186
+ else:
187
+ pass
188
+ except Exception as e:
189
+ logger.exception(str(e))
190
+
191
+ def get_nav_axes(self) -> List[Axis]:
192
+ return [Axis(label=f'{act.title}', units=act.units, data=self.positions[:, ind], index=0,
193
+ spread_order=ind)
194
+ for ind, act in enumerate(self.actuators)]
195
+
196
+ def get_indexes_from_scan_index(self, scan_index: int) -> Tuple[int]:
197
+ """To be reimplemented. Calculations of indexes within the scan"""
198
+ return scan_index,
199
+
200
+ def get_scan_shape(self) -> Tuple[int]:
201
+ return len(self.table_model),
202
+
203
+ def update_from_scan_selector(self, scan_selector: Selector):
204
+ coordinates = scan_selector.get_coordinates()
205
+ self.update_model(init_data=coordinates)
206
+
207
+
208
+ @ScannerFactory.register('Tabular', 'Subsegmented')
209
+ class TabularScannerSubsegmented(TabularScanner):
210
+
211
+ params = [{'title': 'Step:', 'name': 'tabular_step', 'type': 'float', 'value': 0.1},
212
+ {'title': 'Points', 'name': 'tabular_points', 'type': 'table_view', 'delegate': gutils.SpinBoxDelegate,
213
+ 'menu': True},
214
+ ] + TabularScanner.params
215
+
216
+ def __init__(self, actuators: List[str]):
217
+ self.table_model: TableModelTabularReadOnly = None
218
+ self.table_view: TableViewCustom = None
219
+ self.table_model_points: TableModelTabular = None
220
+ self.table_view_points: TableViewCustom = None
221
+ super().__init__(actuators=actuators)
222
+ self.update_model()
223
+ self.update_model_points()
224
+
225
+ @property
226
+ def actuators(self):
227
+ return self._actuators
228
+
229
+ @actuators.setter
230
+ def actuators(self, actuators_name):
231
+ self._actuators = actuators_name
232
+ self.update_model()
233
+ self.update_model_points()
234
+
235
+ def update_model(self, init_data=None):
236
+ if init_data is None:
237
+ init_data = [[0. for _ in self._actuators]]
238
+
239
+ self.table_model = TableModelTabularReadOnly(init_data, [act.title for act in self._actuators])
240
+ self.table_view = putils.get_widget_from_tree(self.settings_tree, TableViewCustom)[1]
241
+ self.settings.child('tabular_table').setValue(self.table_model)
242
+ self.n_axes = len(self._actuators)
243
+ self.update_table_view()
244
+
245
+ def update_model_points(self, init_data=None):
246
+ if init_data is None:
247
+ init_data = [[0. for _ in self._actuators]]
248
+
249
+ self.table_model_points = TableModelTabular(init_data, [act.title for act in self._actuators])
250
+ self.table_view_points = putils.get_widget_from_tree(self.settings_tree, TableViewCustom)[0]
251
+ self.settings.child('tabular_points').setValue(self.table_model_points)
252
+ self.update_table_view_points()
253
+
254
+ def update_table_view(self):
255
+ self.table_view.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents)
256
+ self.table_view.horizontalHeader().setStretchLastSection(True)
257
+ self.table_view.setSelectionBehavior(QtWidgets.QTableView.SelectRows)
258
+ self.table_view.setSelectionMode(QtWidgets.QTableView.SingleSelection)
259
+ # self.table_view.setEnabled(False)
260
+
261
+ def update_table_view_points(self):
262
+ self.table_view_points.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents)
263
+ self.table_view_points.horizontalHeader().setStretchLastSection(True)
264
+ self.table_view_points.setSelectionBehavior(QtWidgets.QTableView.SelectRows)
265
+ self.table_view_points.setSelectionMode(QtWidgets.QTableView.SingleSelection)
266
+ styledItemDelegate = QtWidgets.QStyledItemDelegate()
267
+ styledItemDelegate.setItemEditorFactory(gutils.SpinBoxDelegate())
268
+ self.table_view.setItemDelegate(styledItemDelegate)
269
+
270
+ self.table_view_points.setDragEnabled(True)
271
+ self.table_view_points.setDropIndicatorShown(True)
272
+ self.table_view_points.setAcceptDrops(True)
273
+ self.table_view_points.viewport().setAcceptDrops(True)
274
+ self.table_view_points.setDefaultDropAction(QtCore.Qt.MoveAction)
275
+ self.table_view_points.setDragDropMode(QtWidgets.QTableView.InternalMove)
276
+ self.table_view_points.setDragDropOverwriteMode(False)
277
+
278
+ self.table_view_points.add_data_signal[int].connect(self.table_model_points.add_data)
279
+ self.table_view_points.remove_row_signal[int].connect(self.table_model_points.remove_data)
280
+ self.table_view_points.load_data_signal.connect(self.table_model_points.load_txt)
281
+ self.table_view_points.save_data_signal.connect(self.table_model_points.save_txt)
282
+
283
+ def set_scan(self):
284
+ points = [Point(coordinates) for coordinates in self.table_model_points.get_data_all()]
285
+ positions = get_sub_segmented_positions(self.settings['tabular_step'], points)
286
+
287
+ self.table_model.set_data_all(positions)
288
+ positions = np.array(self.table_model.get_data_all())
289
+ self.get_info_from_positions(positions)
290
+
291
+ def update_from_scan_selector(self, scan_selector: Selector):
292
+ coordinates = scan_selector.get_coordinates()
293
+ self.update_model_points(init_data=coordinates)
294
+ self.set_scan()
@@ -0,0 +1,83 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created the 05/12/2022
4
+
5
+ @author: Sebastien Weber
6
+ """
7
+
8
+
9
+ import numpy as np
10
+ from qtpy import QtCore
11
+ from qtpy.QtCore import Slot
12
+
13
+ from pymodaq.utils.plotting.utils.plot_utils import QVector
14
+ import pymodaq.utils.math_utils as mutils
15
+ from pymodaq.utils import gui_utils as gutils
16
+ from pymodaq.utils.logger import set_logger, get_module_name
17
+ from pymodaq.utils.config import Config
18
+ from pymodaq.utils.scanner.scan_factory import ScannerFactory
19
+ from pymodaq.utils.enums import BaseEnum
20
+
21
+ logger = set_logger(get_module_name(__file__))
22
+ config = Config()
23
+
24
+ scanner_factory = ScannerFactory()
25
+ ScanType = BaseEnum('ScanType', ['NoScan'] + scanner_factory.scan_types())
26
+
27
+
28
+ class ScannerException(Exception):
29
+ """Raised when there is an error related to the Scanner class (see pymodaq.da_utils.scanner)"""
30
+ pass
31
+
32
+
33
+ class ScanInfo:
34
+ """Container class for a given scan details
35
+
36
+ It includes the number of steps and all the positions for the selected actuators. It also contains these positions
37
+ as scan axes for easier use.
38
+
39
+ Parameters
40
+ ----------
41
+
42
+ Nsteps: int
43
+ Number of steps of the scan
44
+ positions: ndarray
45
+ multidimensional array. the first dimension has a length of Nsteps and each element is an actuator position
46
+ positions_indexes: ndarray
47
+ multidimensional array of Nsteps 0th dimension length where each element is the index
48
+ of the corresponding positions within the axis_unique
49
+ axes_unique: list of ndarray
50
+ list of sorted (and with unique values) 1D arrays of unique positions of each defined axes
51
+ selected_actuators: List[str]
52
+ The actuators to be used for this scan
53
+ kwargs: dict of other named parameters to be saved as attributes
54
+
55
+ Attributes
56
+ ----------
57
+ Nsteps: int
58
+ Number of steps of the scan
59
+ positions: ndarray
60
+ multidimensional array. the first dimension has a length of Nsteps and each element is an actuator position
61
+ positions_indexes: ndarray
62
+ multidimensional array of Nsteps 0th dimension length where each element is the index
63
+ of the corresponding positions within the axis_unique
64
+ axes_unique: list of ndarray
65
+ list of sorted (and with unique values) 1D arrays of unique positions of each defined axes
66
+ kwargs: dict of other named attributes
67
+ """
68
+ def __init__(self, Nsteps=0, positions=None, axes_indexes=None, axes_unique=None, selected_actuators=[],
69
+ **kwargs):
70
+ self.Nsteps = Nsteps
71
+ self.positions = positions
72
+ self.axes_indexes = axes_indexes
73
+ self.axes_unique = axes_unique
74
+ self.selected_actuators = selected_actuators
75
+ for k in kwargs:
76
+ setattr(self, k, kwargs[k])
77
+
78
+ def __repr__(self):
79
+ return f'Scan of {self.selected_actuators} with {self.Nsteps} positions'
80
+
81
+
82
+
83
+
@@ -0,0 +1,47 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created the 07/11/2022
4
+
5
+ @author: Sebastien Weber
6
+ """
7
+ import numpy as np
8
+
9
+
10
+ class SpecialSlicers(object):
11
+ """make it elegant to apply a slice to navigation or signal dimensions"""
12
+ def __init__(self, obj, is_navigation):
13
+ self.is_navigation = is_navigation
14
+ self.obj = obj
15
+
16
+ def __getitem__(self, slices):
17
+ return self.obj._slicer(slices, self.is_navigation)
18
+
19
+
20
+ class SpecialSlicersData(SpecialSlicers):
21
+
22
+ def __setitem__(self, i, j):
23
+ """x.__setitem__(i, y) <==> x[i]=y
24
+ """
25
+ raise NotImplementedError
26
+ if hasattr(j, 'data'):
27
+ j = j.data
28
+ array_slices = self.obj._get_array_slices(i, self.is_navigation)
29
+ self.obj.data[array_slices] = j
30
+
31
+ def __len__(self):
32
+ return self.obj.axes_manager.sig_shape[0]
33
+
34
+
35
+ if __name__ == '__main__':
36
+ from pymodaq.utils.data import DataWithAxes, DataRaw, Axis
37
+ shape = (4, 10, 5, 7)
38
+ dat = np.arange(np.prod(shape))
39
+ dat = dat.reshape(shape)
40
+ data = DataRaw('mydata', data=[dat], nav_indexes=(0, 1, 2),
41
+ axes=[Axis(f'axis_{ind:02d}',
42
+ data=np.linspace(0, shape[ind]-1, shape[ind]),
43
+ index=ind) for ind in range(len(shape))])
44
+ subdata_sig = data.inav[2, 2, 3].data
45
+ subdata_nav = data.isig[3].data
46
+ data.isig[:]
47
+ pass
@@ -0,0 +1,6 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created the 06/01/2023
4
+
5
+ @author: Sebastien Weber
6
+ """
@@ -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,51 @@
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, QtCore, QtSvg
12
+ from pyqtgraph.widgets.GraphicsView import GraphicsView
13
+ from pymodaq.utils.plotting.data_viewers.viewer2D import Viewer2D
14
+ from pymodaq.utils.data import Axis, DataToExport, DataFromRoi, DataFromPlugins, DataRaw
15
+
16
+
17
+ def main():
18
+ app = QtWidgets.QApplication(sys.argv)
19
+ widget = QtWidgets.QWidget()
20
+
21
+ Nx = 100
22
+ Ny = 200
23
+ data_random = np.random.normal(size=(Ny, Nx))
24
+ x = np.linspace(-Nx/2, Nx/2 - 1, Nx)
25
+ y = 0.2 * np.linspace(-Ny/2, Ny/2 - 1, Ny)
26
+
27
+ from pymodaq.utils.math_utils import gauss2D
28
+
29
+ data_red = 3 * np.sin(x/5)**2 * gauss2D(x, 5, Nx / 10,
30
+ y, -1, Ny / 10, 1, 90) \
31
+ + 0.1 * data_random
32
+ data_green = 10 * gauss2D(x, -20, Nx / 10,
33
+ y, -10, Ny / 20, 1, 0)
34
+ data_green[70:80, 7:12] = np.nan
35
+
36
+
37
+ prog = Viewer2D(widget)
38
+ widget.show()
39
+ prog.show_data(DataFromPlugins(name='mydata', distribution='uniform', data=[data_red, data_green],
40
+ axes=[Axis('xaxis', units='xpxl', data=x, index=1),
41
+ Axis('yaxis', units='ypxl', data=y, index=0),]))
42
+
43
+ prog.view.show_roi_target(True)
44
+ prog.view.move_scale_roi_target((50, 40), (20, 20))
45
+
46
+ QtWidgets.QApplication.processEvents()
47
+ sys.exit(app.exec_())
48
+
49
+
50
+ if __name__ == '__main__': # pragma: no cover
51
+ main()