pymodaq 3.6.12__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.12.dist-info → pymodaq-4.0.1.dist-info}/RECORD +167 -170
  139. {pymodaq-3.6.12.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 -671
  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.12.dist-info/METADATA +0 -39
  205. pymodaq-3.6.12.dist-info/entry_points.txt +0 -8
  206. pymodaq-3.6.12.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.12.dist-info → pymodaq-4.0.1.dist-info/licenses}/LICENSE +0 -0
@@ -1,289 +0,0 @@
1
- from qtpy import QtWidgets
2
- from qtpy.QtCore import QObject, Slot, QThread, Signal
3
- import sys
4
- from collections import OrderedDict
5
- from pyqtgraph import ROI, RectROI, PolyLineROI, Point
6
-
7
- from pyqtgraph.parametertree import Parameter, ParameterTree
8
- from pyqtgraph.dockarea import Dock
9
- from pymodaq.daq_utils.gui_utils import DockArea
10
- from pymodaq.daq_utils.plotting.utils.plot_utils import QVector
11
- from pymodaq.daq_utils import daq_utils as utils
12
-
13
- logger = utils.set_logger(utils.get_module_name(__file__))
14
-
15
-
16
- class PolyLineROI_custom(PolyLineROI):
17
- def __init__(self, *args, **kwargs):
18
- super(PolyLineROI_custom, self).__init__(*args, **kwargs)
19
-
20
- def get_vertex(self):
21
- return [h['item'].pos() for h in self.handles]
22
-
23
- def get_vectors(self):
24
- imgPts = self.get_vertex()
25
- d = []
26
- for i in range(len(imgPts) - 1):
27
- d.append(QVector(imgPts[i], Point(imgPts[i + 1])))
28
- return d
29
-
30
- def getArrayIndexes(self, spacing=1, **kwds):
31
- imgPts = self.get_vertex()
32
- positions = []
33
- for i in range(len(imgPts) - 1):
34
- d = Point(imgPts[i + 1] - imgPts[i])
35
- o = Point(imgPts[i])
36
- vect = Point(d.norm())
37
- Npts = 0
38
- while Npts * spacing < d.length():
39
- positions.append(((o + Npts * spacing * vect).x(), (o + Npts * spacing * vect).y()))
40
- Npts += 1
41
- # add_last point not taken into account
42
- positions.append((imgPts[-1].x(), imgPts[-1].y()))
43
- return positions
44
-
45
-
46
- class ScanSelector(QObject):
47
- scan_select_signal = Signal(ROI)
48
-
49
- params = [
50
- {'title': 'Scan options', 'name': 'scan_options', 'type': 'group', 'children': [
51
- {'title': 'Sources:', 'name': 'sources', 'type': 'list', },
52
- {'title': 'Viewers:', 'name': 'viewers', 'type': 'list', },
53
- {'title': 'Scan type:', 'name': 'scan_type', 'type': 'list', 'limits': ['Tabular', 'Scan2D'],
54
- 'value': 'Scan2D'},
55
- ]},
56
- {'title': 'Scan Area', 'name': 'scan_area', 'type': 'group', 'children': [
57
- {'title': 'ROI select:', 'name': 'ROIselect', 'type': 'group', 'visible': True, 'children': [
58
- {'title': 'x0:', 'name': 'x0', 'type': 'int', 'value': 0, 'min': 0},
59
- {'title': 'y0:', 'name': 'y0', 'type': 'int', 'value': 0, 'min': 0},
60
- {'title': 'width:', 'name': 'width', 'type': 'int', 'value': 10, 'min': 1},
61
- {'title': 'height:', 'name': 'height', 'type': 'int', 'value': 10, 'min': 1},
62
- ]},
63
- {'title': 'Coordinates:', 'name': 'coordinates', 'type': 'itemselect', 'visible': True},
64
- ]},
65
- ]
66
-
67
- def __init__(self, viewer_items=[], scan_type='Scan2D', positions=[]):
68
- """
69
-
70
- Parameters
71
- ----------
72
- viewer_items: dict where the keys are the titles of the sources while the values are dict with keys
73
- viewers: list of plotitems
74
- names: list of viewer titles
75
- scan_type: (str) either 'Tabular' corresponding to a polyline ROI or 'Scan2D' for a rect Roi
76
- positions: list
77
- in case of 'Tabular', should be a sequence of 2 floats sequence [(x1,y1),(x2,y2),(x3,y3),...]
78
- in case of 'Scan2D', should be a sequence of 4 floats (x, y , w, h)
79
- """
80
- super(ScanSelector, self).__init__()
81
- self._viewers_items = viewer_items
82
- self.sources_names = list(viewer_items.keys())
83
- if len(viewer_items) != 0:
84
- self.scan_selector_source = viewer_items[self.sources_names[0]]['viewers'][0]
85
- else:
86
- self.scan_selector_source = None
87
- self.scan_selector = None
88
- self.setupUI()
89
- self.settings.child('scan_options', 'scan_type').setValue(scan_type)
90
-
91
- self.remove_scan_selector()
92
- if self.scan_selector_source is not None:
93
- if len(viewer_items[self.sources_names[0]]['viewers']) == 1:
94
- self.settings.child('scan_options', 'viewers').hide()
95
- else:
96
- self.settings.child('scan_options', 'viewers').hide()
97
- self.update_scan_area_type()
98
-
99
- if scan_type == "Scan1D" and positions != []:
100
- self.scan_selector.setPoints(positions)
101
- elif scan_type == 'Scan2D' and positions != []:
102
- self.scan_selector.setPos(positions[:2])
103
- self.scan_selector.setSize(positions[3:])
104
-
105
- @property
106
- def viewers_items(self):
107
- return self._viewers_items
108
-
109
- @viewers_items.setter
110
- def viewers_items(self, items):
111
- self._viewers_items = items
112
- self.sources_names = list(items.keys())
113
- self.scan_selector_source = items[self.sources_names[0]]['viewers'][0]
114
- self.settings.child('scan_options', 'sources').setOpts(limits=self.sources_names)
115
- viewer_names = self._viewers_items[self.sources_names[0]]['names']
116
- self.settings.child('scan_options', 'viewers').setOpts(limits=viewer_names)
117
-
118
- def show(self, visible=True):
119
- self.show_scan_selector(visible)
120
- if visible:
121
- self.widget.show()
122
- else:
123
- self.widget.hide()
124
-
125
- def hide(self):
126
- self.show(False)
127
-
128
- def setupUI(self):
129
- self.widget = QtWidgets.QWidget()
130
- layout = QtWidgets.QVBoxLayout()
131
-
132
- self.settings_tree = ParameterTree()
133
- layout.addWidget(self.settings_tree, 10)
134
- self.settings_tree.setMinimumWidth(300)
135
- self.settings = Parameter.create(name='Settings', type='group', children=self.params)
136
- self.settings_tree.setParameters(self.settings, showTop=False)
137
-
138
- self.settings.child('scan_options', 'sources').setOpts(limits=self.sources_names)
139
- if len(self.viewers_items):
140
- viewer_names = self._viewers_items[self.sources_names[0]]['names']
141
- else:
142
- viewer_names = []
143
- self.settings.child('scan_options', 'viewers').setOpts(limits=viewer_names)
144
-
145
- self.settings.sigTreeStateChanged.connect(self.source_changed)
146
- self.widget.setLayout(layout)
147
-
148
- # self.widget.show()
149
- self.widget.setWindowTitle('Scan Selector')
150
-
151
- def source_changed(self, param, changes):
152
- for param, change, data in changes:
153
- path = self.settings.childPath(param)
154
- if path is not None:
155
- childName = '.'.join(path)
156
- else:
157
- childName = param.name()
158
- if change == 'childAdded':
159
- pass
160
-
161
- elif change == 'value':
162
- if param.name() == 'sources' and param.value() is not None:
163
- viewer_names = self._viewers_items[param.value()]['names']
164
- self.settings.child('scan_options', 'viewers').setOpts(limits=viewer_names)
165
- if len(viewer_names) == 1:
166
- self.settings.child('scan_options', 'viewers').hide()
167
-
168
- self.remove_scan_selector()
169
- self.scan_selector_source = self._viewers_items[param.value()]['viewers'][0]
170
- self.update_scan_area_type()
171
-
172
- if param.name() == 'scan_type':
173
-
174
- if param.value() == 'Tabular':
175
- self.settings.child('scan_area', 'ROIselect').hide()
176
- self.settings.child('scan_area', 'coordinates').show()
177
- self.remove_scan_selector()
178
- self.update_scan_area_type()
179
- else:
180
- self.settings.child('scan_area', 'ROIselect').show()
181
- self.settings.child('scan_area', 'coordinates').hide()
182
- self.remove_scan_selector()
183
- self.update_scan_area_type()
184
- self.scan_selector.sigRegionChangeFinished.emit(self.scan_selector)
185
-
186
- elif change == 'parent':
187
- pass
188
-
189
- def remove_scan_selector(self):
190
- if self.scan_selector_source is not None:
191
- try:
192
- self.scan_selector_source.image_widget.plotitem.removeItem(self.scan_selector)
193
- except Exception as e:
194
- logger.exception(str(e))
195
- pass
196
-
197
- Slot(str)
198
-
199
- def update_scan_area_type(self):
200
-
201
- if self.settings.child('scan_options', 'scan_type').value() == 'Tabular':
202
- scan_area_type = 'PolyLines'
203
- else:
204
- scan_area_type = 'Rect'
205
-
206
- self.remove_scan_selector()
207
- if scan_area_type == 'Rect':
208
- self.scan_selector = RectROI([0, 0], [10, 10])
209
-
210
- elif scan_area_type == 'PolyLines':
211
- self.scan_selector = PolyLineROI_custom([(0, 0), [10, 10]])
212
- if self.scan_selector_source is not None:
213
- self.scan_selector.sigRegionChangeFinished.connect(self.update_scan)
214
- self.scan_selector_source.image_widget.plotitem.addItem(self.scan_selector)
215
- self.show_scan_selector()
216
-
217
- self.scan_selector.sigRegionChangeFinished.emit(self.scan_selector)
218
-
219
- def show_scan_selector(self, visible=True):
220
- self.scan_selector.setVisible(visible)
221
-
222
- def update_scan(self, roi):
223
- if self.scan_selector_source is not None:
224
- if isinstance(roi, RectROI):
225
- self.settings.child('scan_area', 'ROIselect', 'x0').setValue(roi.pos().x())
226
- self.settings.child('scan_area', 'ROIselect', 'y0').setValue(roi.pos().y())
227
- self.settings.child('scan_area', 'ROIselect', 'width').setValue(roi.size().x())
228
- self.settings.child('scan_area', 'ROIselect', 'height').setValue(roi.size().y())
229
- elif isinstance(roi, PolyLineROI_custom):
230
- self.settings.child('scan_area', 'coordinates').setValue(
231
- dict(all_items=['({:.03f} , {:.03f})'.format(pt.x(),
232
- pt.y()) for pt in roi.get_vertex()], selected=[]))
233
-
234
- self.scan_select_signal.emit(roi)
235
-
236
-
237
- if __name__ == '__main__':
238
- from pymodaq.daq_utils.plotting.data_viewers.viewer2D import Viewer2D
239
- from pymodaq.daq_viewer.daq_viewer_main import DAQ_Viewer
240
-
241
- class UI:
242
- def __init__(self):
243
- pass
244
-
245
- class FakeDaqScan:
246
-
247
- def __init__(self, area):
248
- self.area = area
249
- self.detector_modules = None
250
- self.ui = UI()
251
- self.dock = Dock('2D scan', size=(500, 300), closable=False)
252
-
253
- form = QtWidgets.QWidget()
254
- self.ui.scan2D_graph = Viewer2D(form)
255
- self.dock.addWidget(form)
256
- self.area.addDock(self.dock)
257
-
258
- app = QtWidgets.QApplication(sys.argv)
259
- win = QtWidgets.QMainWindow()
260
- area = DockArea()
261
-
262
- win.setCentralWidget(area)
263
- win.resize(1000, 500)
264
- win.setWindowTitle('pymodaq main')
265
- fake = FakeDaqScan(area)
266
-
267
- prog = DAQ_Viewer(area, title="Testing", DAQ_type='DAQ2D', parent_scan=fake)
268
- prog.ui.IniDet_pb.click()
269
- QThread.msleep(1000)
270
- QtWidgets.QApplication.processEvents()
271
- prog2 = DAQ_Viewer(area, title="Testing2", DAQ_type='DAQ2D', parent_scan=fake)
272
- prog2.ui.IniDet_pb.click()
273
- QThread.msleep(1000)
274
- QtWidgets.QApplication.processEvents()
275
-
276
- fake.detector_modules = [prog, prog2]
277
- items = OrderedDict()
278
- items[prog.title] = dict(viewers=[view for view in prog.ui.viewers],
279
- names=[view.title for view in prog.ui.viewers],
280
- )
281
- items[prog2.title] = dict(viewers=[view for view in prog2.ui.viewers],
282
- names=[view.title for view in prog2.ui.viewers])
283
- items["DaqScan"] = dict(viewers=[fake.ui.scan2D_graph],
284
- names=["DaqScan"])
285
-
286
- selector = ScanSelector(items, scan_type='Tabular', positions=[(10, -10), (4, 4), (80, 50)])
287
-
288
- win.show()
289
- sys.exit(app.exec_())
File without changes
@@ -1,236 +0,0 @@
1
- import numpy as np
2
- from qtpy.QtCore import QPointF, Slot
3
- from pymodaq.daq_utils import daq_utils as utils
4
- from pymodaq.daq_utils.managers.roi_manager import ROIManager
5
- from pymodaq.daq_utils.plotting.items.crosshair import Crosshair
6
- from pymodaq.daq_utils.plotting.items.image import UniformImageItem
7
-
8
-
9
- class Filter:
10
- def __init__(self):
11
- self._is_active = False
12
- self._slot_to_send_data = None
13
-
14
- def register_activation_signal(self, activation_signal):
15
- activation_signal.connect(lambda x: self.set_active(x))
16
-
17
- def register_target_slot(self, slot):
18
- self._slot_to_send_data = slot
19
-
20
- @Slot(bool)
21
- def set_active(self, activate=True):
22
- self._is_active = activate
23
-
24
- def filter_data(self, data: utils.DataFromPlugins):
25
- if self._is_active:
26
- filtered_data = self._filter_data(data)
27
- if filtered_data is not None and self._slot_to_send_data is not None:
28
- self._slot_to_send_data(filtered_data)
29
-
30
- def _filter_data(self, data: utils.DataFromPlugins):
31
- raise NotImplementedError
32
-
33
-
34
- class FilterFromCrosshair(Filter):
35
- def __init__(self, crosshair: Crosshair, graph_items, image_keys):
36
- """
37
- Extract data along a crosshair using coordinates and data displayed in graph_items such as imageItems
38
- Parameters
39
- ----------
40
- crosshair : (Crosshair)
41
- graph_items : (dict)
42
- image_keys : (list) list of string identifier to link datas to their graph_items. This means that in
43
- _filter_data, datas['data'][key] is plotted on graph_items[key] for key in image_keys
44
- """
45
- super().__init__()
46
- self._graph_items = graph_items
47
- self._image_keys = image_keys
48
- self.crosshair = crosshair
49
- self._x, self._y = 0., 0.
50
-
51
- def _filter_data(self, datas: utils.DataFromPlugins):
52
- data_dict = dict([])
53
- if datas is not None:
54
- self._x, self._y = self.crosshair.get_positions()
55
- data_type = datas['distribution']
56
- for data_index in range(len(self._image_keys)):
57
- if data_index < len(datas['data']):
58
- data = datas['data'][data_index]
59
- image_type = self._image_keys[data_index]
60
- if data_type == 'uniform':
61
- data_dict[image_type] = self.get_data_from_uniform(image_type, data)
62
- elif data_type == 'spread':
63
- data_dict[image_type] = self.get_data_from_spread(image_type, data)
64
- return data_dict
65
-
66
- def get_data_from_uniform(self, data_key, data):
67
- hor_axis, ver_axis = \
68
- np.linspace(0, self._graph_items[data_key].width() - 1, self._graph_items[data_key].width()),\
69
- np.linspace(0, self._graph_items[data_key].height() - 1, self._graph_items[data_key].height())
70
-
71
- indx, indy = self.mapfromview(self._x, self._y, data_key)
72
-
73
- data_H_index = slice(None, None, 1)
74
- data_V_index = slice(None, None, 1)
75
- H_indexes = (utils.rint(indy), data_H_index)
76
- V_indexes = (data_V_index, utils.rint(indx))
77
-
78
- out_of_bounds = False
79
- if 0 <= H_indexes[0] < len(ver_axis):
80
- hor_data = data[H_indexes]
81
- else:
82
- out_of_bounds = True
83
- hor_data = np.zeros(hor_axis.shape)
84
- if 0 <= V_indexes[1] < len(hor_axis):
85
- ver_data = data[V_indexes]
86
- else:
87
- out_of_bounds = True
88
- ver_data = np.zeros(ver_axis.shape)
89
- if out_of_bounds:
90
- ind_data = 0.
91
- else:
92
- ind_data = data[utils.rint(indy), utils.rint(indx)]
93
- return LineoutData(hor_axis=hor_axis, ver_axis=ver_axis, hor_data=hor_data, ver_data=ver_data,
94
- int_data=ind_data)
95
-
96
- def get_data_from_spread(self, data_key, data):
97
- data_H_index = slice(None, None, 1)
98
- data_V_index = slice(None, None, 1)
99
- posx, posy = self.mapfromview(self._x, self._y, data_key)
100
-
101
- points, data = self._graph_items[data_key].get_points_at(axis='y', val=posy)
102
- x_sorted_indexes = np.argsort(points[:, 0])
103
- hor_axis = points[x_sorted_indexes, 0][data_H_index]
104
-
105
- hor_data = data[x_sorted_indexes][data_H_index]
106
-
107
- points, data = self._graph_items[data_key].get_points_at(axis='x', val=posx)
108
- y_sorted_indexes = np.argsort(points[:, 1])
109
- ver_axis = points[y_sorted_indexes, 1][data_V_index]
110
-
111
- ver_data = data[y_sorted_indexes][data_V_index]
112
-
113
- return LineoutData(hor_axis=hor_axis, ver_axis=ver_axis, hor_data=hor_data, ver_data=ver_data,
114
- int_data=self._graph_items[data_key].get_val_at((posx, posy)))
115
-
116
-
117
-
118
- def mapfromview(self, x, y, item_key='red'):
119
- """
120
- get item coordinates from view coordinates
121
- Parameters
122
- ----------
123
- x: (float) x coordinate in the view reference frame
124
- y: (float) y coordinate in the view refernece frame
125
-
126
- Returns
127
- -------
128
- x: (float) coordinate in the item reference frame
129
- y: (float) coordinate in the item reference frame
130
- """
131
- point = self._graph_items[item_key].mapFromView(QPointF(x, y))
132
- return point.x(), point.y()
133
-
134
-
135
- class FilterFromRois(Filter):
136
- def __init__(self, roi_manager: ROIManager, graph_item: UniformImageItem, image_keys):
137
- """
138
-
139
- Parameters
140
- ----------
141
- roi_manager
142
- graph_item
143
- image_keys : (list) list of string identifier to link datas to their graph_items. This means that in
144
- _filter_data, datas['data'][key] is plotted on graph_items[key] for key in image_keys
145
- """
146
- super().__init__()
147
- self._roi_settings = roi_manager.settings
148
- self._image_keys = image_keys
149
- self._graph_item = graph_item
150
- self.axes = (0, 1)
151
- self._ROIs = roi_manager.ROIs
152
-
153
- def _filter_data(self, datas: utils.DataFromPlugins) -> dict:
154
- data_dict = dict([])
155
- if datas is not None:
156
- for roi_key, roi in self._ROIs.items():
157
- image_key = self._roi_settings.child('ROIs', roi_key, 'use_channel').value()
158
- image_index = self._image_keys.index(image_key)
159
-
160
- data_type = datas['distribution']
161
- data = datas['data'][image_index]
162
- data_dict[roi_key] = self.get_xydata_from_roi(data_type, roi, data)
163
- return data_dict
164
-
165
-
166
-
167
- def get_xydata_from_roi(self, data_type, roi, data):
168
-
169
- if data is not None:
170
- if data_type == 'spread':
171
- xvals, yvals, data = self.get_xydata_spread(data, roi)
172
- ind_xaxis = np.argsort(xvals)
173
- ind_yaxis = np.argsort(yvals)
174
- xvals = xvals[ind_xaxis]
175
- yvals = yvals[ind_yaxis]
176
- data_H = data[ind_xaxis]
177
- data_V = data[ind_yaxis]
178
- int_data = np.array([np.mean(data)])
179
- else:
180
- xvals, yvals, data = self.get_xydata(data, roi)
181
- data_H = np.mean(data, axis=0)
182
- data_V = np.mean(data, axis=1)
183
- int_data = np.array([np.mean(data)])
184
-
185
- return LineoutData(hor_axis=xvals, ver_axis=yvals, hor_data=data_H, ver_data=data_V, int_data=int_data)
186
-
187
- def get_xydata(self, data, roi):
188
- data, coords = self.data_from_roi(data, roi)
189
-
190
- if data is not None:
191
- xvals = np.linspace(np.min(np.min(coords[1, :, :])), np.max(np.max(coords[1, :, :])),
192
- data.shape[1])
193
- yvals = np.linspace(np.min(np.min(coords[0, :, :])), np.max(np.max(coords[0, :, :])),
194
- data.shape[0])
195
- else:
196
- xvals = yvals = data = np.array([])
197
- return xvals, yvals, data
198
-
199
- def data_from_roi(self, data, roi):
200
- data, coords = roi.getArrayRegion(data, self._graph_item, self.axes, returnMappedCoords=True)
201
- return data, coords
202
-
203
- def get_xydata_spread(self, data, roi):
204
- xvals = []
205
- yvals = []
206
- data_out = []
207
- for ind in range(data.shape[0]):
208
- # invoke the QPainterpath of the ROI (from the shape method)
209
- if roi.shape().contains(QPointF(data[ind, 0] - roi.pos().x(),
210
- data[ind, 1] - roi.pos().y())):
211
- xvals.append(data[ind, 0])
212
- yvals.append(data[ind, 1])
213
- data_out.append(data[ind, 2])
214
- data_out = np.array(data_out)
215
- xvals = np.array(xvals)
216
- yvals = np.array(yvals)
217
- return xvals, yvals, data_out
218
-
219
-
220
- class LineoutData:
221
- def __init__(self, hor_axis=np.array([]), ver_axis=np.array([]), hor_data=np.array([]), ver_data=np.array([]),
222
- int_data=None):
223
- super().__init__()
224
- if len(hor_axis) != len(hor_data):
225
- raise ValueError(f'Horizontal lineout data and axis must have the same size')
226
- if len(ver_axis) != len(ver_data):
227
- raise ValueError(f'Horizontal lineout data and axis must have the same size')
228
-
229
- self.hor_axis = hor_axis
230
- self.ver_axis = ver_axis
231
- self.hor_data = hor_data
232
- self.ver_data = ver_data
233
- if int_data is None:
234
- self.int_data = np.array([np.sum(self.ver_data)])
235
- else:
236
- self.int_data = int_data
File without changes
@@ -1,4 +0,0 @@
1
- from pymodaq.daq_utils.messenger import deprecation_msg
2
- from ..data_viewers.viewer0D import Viewer0D
3
-
4
- deprecation_msg('Viewer0D should now be imported from pymodaq.daq_utils.plotting.data_viewers')
File without changes
@@ -1,4 +0,0 @@
1
- from pymodaq.daq_utils.messenger import deprecation_msg
2
- from ..data_viewers.viewer1D import Viewer1D
3
-
4
- deprecation_msg('Viewer1D should now be imported from pymodaq.daq_utils.plotting.data_viewers')
@@ -1,4 +0,0 @@
1
- from pymodaq.daq_utils.messenger import deprecation_msg
2
- from ..data_viewers.viewer1D import Viewer1DBasic
3
-
4
- deprecation_msg('Viewer1DBasic should now be imported from pymodaq.daq_utils.plotting.data_viewers')
@@ -1,4 +0,0 @@
1
- from pymodaq.daq_utils.messenger import deprecation_msg
2
- from ..data_viewers.viewer2D_basic import Viewer2DBasic
3
-
4
- deprecation_msg('Viewer2DBasic should now be imported from pymodaq.daq_utils.plotting.data_viewers')
@@ -1,4 +0,0 @@
1
- from pymodaq.daq_utils.messenger import deprecation_msg
2
- from ..data_viewers.viewer2D import Viewer2D
3
-
4
- deprecation_msg('Viewer2D should now be imported from pymodaq.daq_utils.plotting.data_viewers')
File without changes
@@ -1,4 +0,0 @@
1
- from pymodaq.daq_utils.messenger import deprecation_msg
2
- from ..data_viewers.viewerND import ViewerND
3
-
4
- deprecation_msg('ViewerND should now be imported from pymodaq.daq_utils.plotting.data_viewers')