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
@@ -1,64 +0,0 @@
1
- from collections import OrderedDict
2
- from qtpy import QtWidgets
3
- from qtpy.QtCore import QObject, Signal, Slot
4
- from pymodaq.daq_utils.plotting.utils.filter import Filter
5
- from pymodaq.daq_utils import daq_utils as utils
6
- from pymodaq.daq_utils import gui_utils as gutils
7
- from pymodaq.daq_utils.exceptions import ViewerError
8
- import datetime
9
-
10
-
11
- DATATYPES = {'Viewer0D': 'Data0D', 'Viewer1D': 'Data1D', 'Viewer2D': 'Data2D', 'ViewerND': 'DataND',
12
- 'ViewerSequential': 'DataSequential'}
13
-
14
-
15
- class ViewerBase(QObject):
16
- data_to_export_signal = Signal(OrderedDict) # OrderedDict(name=self.DAQ_type,data0D=None,data1D=None,data2D=None)
17
- _data_to_show_signal = Signal(utils.DataFromPlugins)
18
-
19
- ROI_changed = Signal()
20
- crosshair_dragged = Signal(float, float) # Crosshair position in units of scaled top/right axes
21
- status_signal = Signal(str)
22
- crosshair_clicked = Signal(bool)
23
- sig_double_clicked = Signal(float, float)
24
-
25
- def __init__(self, parent=None, title=''):
26
- super().__init__()
27
- self.viewer_type = DATATYPES[self.__class__.__name__]
28
- self.title = title if title != '' else self.__class__.__name__
29
-
30
- self._raw_datas = None
31
- self.data_to_export = OrderedDict(name=self.title)
32
-
33
- if parent is None:
34
- parent = QtWidgets.QWidget()
35
- parent.show()
36
- self.parent = parent
37
-
38
- self._display_temporary = False
39
-
40
- def show_data(self, datas: utils.DataFromPlugins):
41
- if len(datas['data'][0].shape) != 2:
42
- raise ViewerError(f'Ndarray of dim: {len(datas["data"][0].shape)} cannot be plotted'
43
- f' using a {self.viewer_type}')
44
- self.data_to_export = OrderedDict(name=self.title, data0D=OrderedDict(), data1D=OrderedDict())
45
- self.data_to_export['acq_time_s'] = datetime.datetime.now().timestamp()
46
- self._raw_datas = datas
47
-
48
- self._display_temporary = False
49
-
50
- self._show_data(datas)
51
-
52
- def show_data_temp(self, datas: utils.DataFromPlugins):
53
- self._display_temporary = True
54
- self.show_data(datas)
55
-
56
- def _show_data(self, datas: utils.DataFromPlugins):
57
- raise NotImplementedError
58
-
59
- def add_attributes_from_view(self):
60
- """Convenience function to set attributes to self for the public API
61
- """
62
- for attribute in self.convenience_attributes:
63
- if hasattr(self.view, attribute):
64
- setattr(self, attribute, getattr(self.view, attribute))
File without changes
@@ -1,500 +0,0 @@
1
- from pymodaq.daq_utils.gui_utils.file_io import select_file
2
- from qtpy import QtGui, QtWidgets, QtCore
3
- from qtpy.QtCore import Qt, QObject, Slot, Signal
4
-
5
- import sys
6
- import os
7
- import numpy as np
8
- import tables
9
-
10
- from pyqtgraph.parametertree import Parameter, ParameterTree
11
- from pymodaq.daq_utils.plotting.data_viewers.viewer2D_basic import Viewer2DBasic
12
- from pymodaq.daq_utils.plotting.items.image import UniformImageItem, SpreadImageItem
13
- from pymodaq.daq_utils import daq_utils as utils
14
- from pymodaq.daq_utils.h5modules import H5Saver, browse_data, H5BrowserUtil
15
- from pymodaq.daq_utils import gui_utils as gutils
16
-
17
- from pymodaq.daq_utils.config import get_set_local_dir, Config
18
-
19
- local_path = get_set_local_dir()
20
- navigator_path = os.path.join(local_path, 'navigator_temp_files')
21
- if not os.path.isdir(navigator_path):
22
- os.makedirs(navigator_path)
23
-
24
- logger = utils.set_logger(utils.get_module_name(__file__))
25
-
26
- Ntick = 128
27
- colors_red = np.array([(int(r), 0, 0) for r in np.linspace(0, 255, Ntick)])
28
- colors_green = np.array([(0, int(g), 0) for g in np.linspace(0, 255, Ntick)])
29
- colors_blue = np.array([(0, 0, int(b)) for b in np.linspace(0, 255, Ntick)])
30
- config = Config()
31
-
32
-
33
- class Navigator(QObject):
34
- log_signal = Signal(str)
35
- sig_double_clicked = Signal(float, float)
36
-
37
- def __init__(self, parent=None, h5file_path=None):
38
- super().__init__(parent)
39
-
40
- if parent is None:
41
- parent = QtWidgets.QWidget()
42
- self.parent = parent
43
- self.title = 'Navigator'
44
- self.status_time = 1000
45
- self.x_range = []
46
- self.y_range = []
47
- self.filters = tables.Filters(complevel=5)
48
- self.next_scan_index = 0
49
- self.viewer = None
50
- self.overlays = [] # %list of imageItem items displaying 2D scans info
51
- self.h5module_path = h5file_path
52
- self.h5module = H5BrowserUtil()
53
-
54
- if h5file_path is not None:
55
- self.h5module.open_file(h5file_path, 'a')
56
- self.settings.child('settings', 'filepath').setValue(h5file_path)
57
- self.settings.child('settings', 'Load h5').hide()
58
- self.show_overlay()
59
-
60
- self.setupUI()
61
-
62
- def create_toolbar(self):
63
- iconload = QtGui.QIcon()
64
- iconload.addPixmap(QtGui.QPixmap(":/icons/Icon_Library/NewLayer.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
65
- self.loadaction = QtWidgets.QAction(iconload, "Load scan file (.h5)", None)
66
- self.toolbar.addAction(self.loadaction)
67
- self.loadaction.triggered.connect(self.load_data)
68
-
69
- iconloadim = QtGui.QIcon()
70
- iconloadim.addPixmap(QtGui.QPixmap(":/icons/Icon_Library/Open_File_32.png"), QtGui.QIcon.Normal,
71
- QtGui.QIcon.Off)
72
- self.loadactionim = QtWidgets.QAction(iconloadim, "Load image file (.h5)", None)
73
- self.toolbar.addAction(self.loadactionim)
74
- self.loadactionim.triggered.connect(self.load_image)
75
-
76
- icon_ratio = QtGui.QIcon()
77
- icon_ratio.addPixmap(QtGui.QPixmap(":/icons/Icon_Library/Zoom_1_1.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
78
- self.action_ratio = QtWidgets.QAction(icon_ratio, "Set viewbox aspect ratio to 1", None)
79
- self.action_ratio.setCheckable(True)
80
- self.toolbar.addAction(self.action_ratio)
81
- self.action_ratio.triggered.connect(self.set_aspect_ratio)
82
-
83
- icon_moveat = QtGui.QIcon()
84
- icon_moveat.addPixmap(QtGui.QPixmap(":/icons/Icon_Library/move_contour.png"), QtGui.QIcon.Normal,
85
- QtGui.QIcon.Off)
86
- self.moveat_action = QtWidgets.QAction(icon_moveat,
87
- "When selected, double clicking on viewbox will move DAQ_Move modules",
88
- None)
89
- self.moveat_action.setCheckable(True)
90
- self.toolbar.addAction(self.moveat_action)
91
-
92
- icon_sel_all = QtGui.QIcon()
93
- icon_sel_all.addPixmap(QtGui.QPixmap(":/icons/Icon_Library/select_all2.png"), QtGui.QIcon.Normal,
94
- QtGui.QIcon.Off)
95
- self.sel_all_action = QtWidgets.QAction(icon_sel_all, "Select (show) all 2D scans on the viewer", None)
96
- self.toolbar.addAction(self.sel_all_action)
97
- self.sel_all_action.triggered.connect(self.show_all)
98
-
99
- icon_sel_none = QtGui.QIcon()
100
- icon_sel_none.addPixmap(QtGui.QPixmap(":/icons/Icon_Library/select_none.png"), QtGui.QIcon.Normal,
101
- QtGui.QIcon.Off)
102
- self.sel_none_action = QtWidgets.QAction(icon_sel_none, "Unselect (hide) all 2D scans on the viewer", None)
103
- self.toolbar.addAction(self.sel_none_action)
104
- self.sel_none_action.triggered.connect(self.show_none)
105
-
106
- icon_histo = QtGui.QIcon()
107
- icon_histo.addPixmap(QtGui.QPixmap(":/icons/Icon_Library/Histogram.png"), QtGui.QIcon.Normal,
108
- QtGui.QIcon.Off)
109
- self.histo_action = QtWidgets.QAction(icon_histo, "Show (hide) histograms", None)
110
- self.toolbar.addAction(self.histo_action)
111
- self.histo_action.setCheckable(True)
112
- self.histo_action.triggered.connect(self.show_histo)
113
-
114
- @Slot(float, float)
115
- def move_at(self, posx, posy):
116
- if self.moveat_action.isChecked():
117
- self.sig_double_clicked.emit(posx, posy)
118
-
119
- def show_histo(self):
120
- show_state = self.histo_action.isChecked()
121
- self.viewer.histo_widget.setVisible(show_state)
122
-
123
- def show_all(self):
124
- self.show_scans()
125
-
126
- def show_none(self):
127
- self.show_scans(False)
128
-
129
- def show_scans(self, show=True):
130
- for child in self.settings.child('scans'):
131
- val = child.value()
132
- val['checked'] = show
133
- child.setValue(val)
134
- child.sigValueChanged.emit(child, val)
135
-
136
- def list_2Dscans(self):
137
- try:
138
- scans = self.h5module.get_h5file_scans()
139
- # settings=[dict(scan_name=node._v_name,path=node._v_pathname, pixmap=nparray2Qpixmap(node.read()))),...]
140
- params = []
141
- for child in self.settings.child(('scans')).children():
142
- if 'Scan' in child.name():
143
- self.settings.child(('scans')).removeChild(child)
144
- for scan in scans:
145
- params.append({'name': scan['scan_name'], 'type': 'pixmap_check',
146
- 'value': dict(data=scan['data'], checked=False, path=scan['path'],
147
- info=scan['scan_name'])})
148
- self.settings.child(('scans')).addChildren(params)
149
-
150
- for child in self.settings.child(('scans')).children():
151
- val = child.value()
152
- val.update(dict(checked=True))
153
- child.setValue(val)
154
- child.sigValueChanged.emit(child, child.value())
155
-
156
- except Exception as e:
157
- logger.exception(str(e))
158
-
159
- def load_image(self):
160
- # image_filepath = str(utils.select_file(start_path=None, save=False, ext='h5'))
161
- data, fname, node_path = browse_data(ret_all=True)
162
- if data is not None and fname != '':
163
- self.h5module_image = H5BrowserUtil()
164
- self.h5module_image.open_file(fname, 'a')
165
- node = self.h5module_image.get_node(node_path)
166
- pixmaps = self.h5module_image.get_h5file_scans(node.parent_node)
167
-
168
- self.settings.child('settings', 'imagepath').setValue(fname)
169
- other_child = [child for child in self.settings.child(('scans')).children() if 'Scan' not in child.name()]
170
- if len(other_child) >= 1:
171
- for child in other_child:
172
- self.settings.child(('scans')).removeChild(child)
173
- params = []
174
- for pixmap in pixmaps:
175
- params.append({'name': pixmap['scan_name'], 'type': 'pixmap_check',
176
- 'value': dict(data=pixmap['data'], checked=False, path=pixmap['path'])})
177
- self.settings.child(('scans')).addChildren(params)
178
-
179
- val = self.settings.child('scans', pixmaps[0]['scan_name']).value()
180
- val.update(dict(checked=True))
181
- self.settings.child('scans', pixmaps[0]['scan_name']).setValue(val)
182
- self.settings.child('scans', pixmaps[0]['scan_name']).sigValueChanged.emit(
183
- self.settings.child('scans', pixmaps[0]['scan_name']),
184
- self.settings.child('scans', pixmaps[0]['scan_name']).value())
185
-
186
- def load_data(self):
187
- self.h5module_path = str(
188
- select_file(start_path=config('data_saving', 'h5file', 'save_path'),
189
- save=False, ext='h5'))
190
- if self.h5module_path != '':
191
- self.settings.child('settings', 'filepath').setValue(self.h5module_path)
192
- if self.h5module is not None:
193
- if self.h5module.isopen():
194
- self.h5module.close_file()
195
- self.h5module.open_file(self.h5module_path, 'a')
196
- self.list_2Dscans()
197
-
198
- def set_aspect_ratio(self):
199
- if self.action_ratio.isChecked():
200
- self.viewer.image_widget.plotitem.vb.setAspectLocked(lock=True, ratio=1)
201
- else:
202
- self.viewer.image_widget.plotitem.vb.setAspectLocked(lock=False, ratio=1)
203
-
204
- def settings_changed(self, param, changes):
205
- """
206
- Check for changes in the given (parameter,change,information) tuple list.
207
- In case of value changed, update the DAQscan_settings tree consequently.
208
-
209
- =============== ============================================ ==============================
210
- **Parameters** **Type** **Description**
211
- *param* instance of pyqtgraph parameter the parameter to be checked
212
- *changes* (parameter,change,information) tuple list the current changes state
213
- =============== ============================================ ==============================
214
- """
215
- for param, change, data in changes:
216
- path = self.settings.childPath(param)
217
- if path is not None:
218
- childName = '.'.join(path)
219
- else:
220
- childName = param.name()
221
- if change == 'childAdded':
222
- pass
223
-
224
- elif change == 'value':
225
- if param.parent().name() == 'scans':
226
- if data['checked']:
227
- try:
228
- if 'Scan' in param.name():
229
- h5module = self.h5module
230
- nodes = [node for node in h5module.walk_nodes(data['path'])]
231
- else:
232
- h5module = self.h5module_image
233
- nodes = [h5module.get_node(data['path'])]
234
- ind = 0
235
- for node in nodes:
236
- flag = False
237
- if 'type' in node.attrs.attrs_name and 'data_dimension' in node.attrs.attrs_name:
238
- if 'scan_type' in node.attrs.attrs_name:
239
- if node.attrs['scan_type'] == 'scan2D' and node.attrs['data_dimension'] == '0D':
240
- # 2d scan of 0D data
241
- flag = True
242
- elif node.attrs['scan_type'] == '' and node.attrs['data_dimension'] == '2D':
243
- # image data (2D) with no scan
244
- flag = True
245
-
246
- if flag:
247
- isadaptive = 'adaptive' in node.attrs['scan_subtype'].lower()
248
- if isadaptive:
249
- im = SpreadImageItem()
250
- else:
251
- im = UniformImageItem()
252
- im.setOpacity(1)
253
- # im.setOpts(axisOrder='row-major')
254
- self.viewer.image_widget.plotitem.addItem(im)
255
- im.setCompositionMode(QtGui.QPainter.CompositionMode_Plus)
256
-
257
- if 'Scan' in param.name():
258
- if isadaptive:
259
- x_axis = h5module.get_node(h5module.get_node(data['path']).parent_node,
260
- utils.capitalize('scan_x_axis')).read()
261
- y_axis = h5module.get_node(h5module.get_node(data['path']).parent_node,
262
- utils.capitalize('scan_y_axis')).read()
263
- else:
264
- x_axis = np.unique(
265
- h5module.get_node(h5module.get_node(data['path']).parent_node,
266
- utils.capitalize('scan_x_axis')).read())
267
- y_axis = np.unique(
268
- h5module.get_node(h5module.get_node(data['path']).parent_node,
269
- utils.capitalize('scan_y_axis')).read())
270
- else:
271
- x_axis = np.unique(
272
- h5module.get_node(h5module.get_node(data['path']).parent_node,
273
- utils.capitalize('x_axis')).read())
274
- y_axis = np.unique(
275
- h5module.get_node(h5module.get_node(data['path']).parent_node,
276
- utils.capitalize('y_axis')).read())
277
- if not isadaptive:
278
- rect = QtCore.QRectF(np.min(x_axis), np.min(y_axis),
279
- (np.max(x_axis) - np.min(x_axis)),
280
- (np.max(y_axis) - np.min(y_axis)))
281
- im.setOpts(rescale=rect)
282
- im.setImage(node.read())
283
- else:
284
- im.setImage(np.vstack((x_axis, y_axis, node.read())).T)
285
-
286
- if ind == 0:
287
- # im.setLookupTable(colors_red)
288
- self.viewer.histogram_red.setImageItem(im)
289
- if not self.viewer.histogram_red.isVisible():
290
- self.viewer.histogram_red.setVisible(True)
291
- elif ind == 1:
292
- # im.setLookupTable(colors_green)
293
- self.viewer.histogram_green.setImageItem(im)
294
- if not self.viewer.histogram_green.isVisible():
295
- self.viewer.histogram_green.setVisible(True)
296
- else:
297
- # im.setLookupTable(colors_blue)
298
- self.viewer.histogram_blue.setImageItem(im)
299
- if not self.viewer.histogram_blue.isVisible():
300
- self.viewer.histogram_blue.setVisible(True)
301
-
302
- self.overlays.append(dict(name='{:s}_{:03d}'.format(param.name(), ind), image=im))
303
-
304
- ind += 1
305
- # self.viewer.image_widget.view.autoRange()
306
- except Exception as e:
307
- logger.exception(str(e))
308
-
309
- else:
310
- for overlay in self.overlays[:]:
311
- if param.name() in overlay['name']:
312
- ind = self.overlays.index(overlay)
313
- self.viewer.image_widget.plotitem.removeItem(overlay['image'])
314
- self.overlays.pop(ind)
315
-
316
- elif change == 'parent':
317
- for overlay in self.overlays[:]:
318
- if param.name() in overlay['name']:
319
- ind = self.overlays.index(overlay)
320
- self.viewer.image_widget.plotitem.removeItem(overlay['image'])
321
- self.overlays.pop(ind)
322
-
323
- def setupUI(self):
324
- self.ui = QObject()
325
- layout = QtWidgets.QVBoxLayout()
326
-
327
- self.parent.setLayout(layout)
328
- sett_widget = QtWidgets.QWidget()
329
- self.sett_layout = QtWidgets.QHBoxLayout()
330
- sett_widget.setLayout(self.sett_layout)
331
- # creating a toolbar
332
- self.toolbar = QtWidgets.QToolBar()
333
- self.create_toolbar()
334
- layout.addWidget(self.toolbar)
335
-
336
- splitter = QtWidgets.QSplitter(Qt.Horizontal)
337
- layout.addWidget(splitter)
338
-
339
- # set viewer area
340
- widg = QtWidgets.QWidget()
341
- # self.viewer = Viewer2D(widg)
342
- self.viewer = Viewer2DBasic(widg)
343
- self.viewer.histogram_red.setVisible(False)
344
- self.viewer.histogram_green.setVisible(False)
345
- self.viewer.histogram_blue.setVisible(False)
346
- self.viewer.sig_double_clicked.connect(self.move_at)
347
-
348
- # displaying the scan list tree
349
- self.settings_tree = ParameterTree()
350
- # self.settings_tree.setMaximumWidth(300)
351
- self.settings_tree.setMinimumWidth(300)
352
- # self.settings_tree.setVisible(False)
353
- params_scan = [
354
- {'title': 'Settings', 'name': 'settings', 'type': 'group', 'children': [
355
- {'title': 'Load h5:', 'name': 'Load h5', 'type': 'action'},
356
- {'title': 'h5 path:', 'name': 'filepath', 'type': 'str', 'value': '', 'readonly': True},
357
- {'title': 'Load Image:', 'name': 'Load Image', 'type': 'action'},
358
- {'title': 'Image path:', 'name': 'imagepath', 'type': 'str', 'value': '', 'readonly': True},
359
- ]},
360
- {'title': 'Scans', 'name': 'scans', 'type': 'group', 'children': []},
361
- ]
362
- self.settings = Parameter.create(name='settings', type='group', children=params_scan)
363
- self.settings_tree.setParameters(self.settings, showTop=False)
364
- self.settings.sigTreeStateChanged.connect(self.settings_changed)
365
-
366
- self.settings.child('settings', 'Load h5').sigActivated.connect(self.load_data)
367
- self.settings.child('settings', 'Load Image').sigActivated.connect(self.load_image)
368
-
369
- self.ui.statusbar = QtWidgets.QStatusBar()
370
- self.ui.statusbar.setMaximumHeight(25)
371
- layout.addWidget(self.ui.statusbar)
372
- self.ui.log_message = QtWidgets.QLabel('Initializing')
373
- self.ui.statusbar.addPermanentWidget(self.ui.log_message)
374
-
375
- self.sett_layout.addWidget(self.settings_tree)
376
- splitter.addWidget(sett_widget)
377
- splitter.addWidget(self.viewer.parent)
378
-
379
- def show_image(self, data):
380
- """
381
-
382
- Parameters
383
- ----------
384
- data: (dict) with keys 'names', 'data', 'x_axis', 'y_axis', 'pixmap2D'
385
- """
386
-
387
- if self.h5module is None:
388
- scan_path, current_filename, dataset_path = H5Saver.set_current_scan_path(navigator_path, base_name='Scan',
389
- update_h5=True,
390
- next_scan_index=self.next_scan_index,
391
- create_scan_folder=False)
392
- self.h5module = H5BrowserUtil()
393
- self.h5module.open_file(str(dataset_path.joinpath(dataset_path.name + ".h5")), 'w')
394
-
395
- else:
396
- scan_path, current_filename, dataset_path = H5Saver.set_current_scan_path(navigator_path, base_name='Scan',
397
- update_h5=False,
398
- next_scan_index=self.next_scan_index,
399
- create_scan_folder=False)
400
- if not self.h5module.isopen():
401
- self.h5module.open_file(str(dataset_path.joinpath(dataset_path.name + ".h5")), 'a')
402
-
403
- h5group = self.h5module.root()
404
- data2D_group = self.h5module.get_set_group(h5group, 'Data2D')
405
- data2D_group.attrs.type = 'data2D'
406
-
407
- self.next_scan_index += 1
408
- curr_group = self.h5module.get_set_group('/Data2D', current_filename)
409
- live_group = self.h5module.get_set_group(curr_group, 'Live_scan_2D')
410
- live_group.attrs['pixmap2D'] = data['pixmap2D']
411
-
412
- xdata = data['x_axis']
413
- if isinstance(xdata, dict):
414
- xdata = xdata['data']
415
- xarray = self.h5module.create_carray(curr_group, "Scan_x_axis", obj=xdata,
416
- title=current_filename)
417
- xarray.attrs['type'] = 'navigation_axis'
418
- xarray.attrs['data_dimension'] = '1D'
419
- xarray.attrs['nav_index'] = 0
420
-
421
- ydata = data['y_axis']
422
- if isinstance(ydata, dict):
423
- ydata = ydata['data']
424
- yarray = self.h5module.create_carray(curr_group, "Scan_y_axis", obj=ydata,
425
- title=current_filename)
426
- yarray.attrs['type'] = 'navigation_axis'
427
- yarray.attrs['data_dimension'] = '1D'
428
- yarray.attrs['nav_index'] = 1
429
-
430
- for ind_channel, name in enumerate(data['names']):
431
- try:
432
- channel_group = self.h5module.get_set_group(live_group, name)
433
- channel_group.attrs.Channel_name = name
434
- array = self.h5module.create_carray(channel_group, current_filename + '_' + name,
435
- obj=data['data'][ind_channel],
436
- title='data', )
437
- array.attrs['type'] = 'data'
438
- array.attrs['data_dimension'] = '0D'
439
- array.attrs['data_name'] = name
440
- array.attrs['scan_type'] = 'scan2D'
441
- array.attrs['scan_subtype'] = ''
442
- except Exception as e:
443
- logger.exception(str(e))
444
-
445
- self.update_2Dscans()
446
-
447
- def update_2Dscans(self):
448
- try:
449
- if not self.h5module.isopen():
450
- self.h5module.open_file(self.h5module.file_path, 'a')
451
- scans = self.h5module.get_h5file_scans(self.h5module.root())
452
- # settings=[dict(scan_name=node._v_name,path=node._v_pathname, pixmap=nparray2Qpixmap(node.read()))),...]
453
- params = []
454
- children = [child.name() for child in self.settings.child(('scans')).children()]
455
- for scan in scans:
456
- if scan['scan_name'] not in children:
457
- params.append({'name': scan['scan_name'], 'type': 'pixmap_check',
458
- 'value': dict(data=scan['data'], checked=False, path=scan['path'],
459
- info=scan['scan_name'])})
460
- self.settings.child(('scans')).addChildren(params)
461
-
462
- for child in self.settings.child(('scans')).children():
463
- if child.name() not in children:
464
- val = child.value()
465
- val.update(dict(checked=True))
466
- child.setValue(val)
467
- child.sigValueChanged.emit(child, child.value())
468
-
469
- except Exception as e:
470
- logger.exception(str(e))
471
-
472
- def update_h5file(self, h5file):
473
- if self.h5module is not None:
474
- self.h5module.h5file = h5file
475
- self.update_2Dscans()
476
-
477
- def update_status(self, txt, status_time=0, log_type=None):
478
- """
479
- Show the txt message in the status bar with a delay of status_time ms.
480
-
481
- =============== =========== =======================
482
- **Parameters** **Type** **Description**
483
- *txt* string The message to show
484
- *status_time* int the delay of showing
485
- *log_type* string the type of the log
486
- =============== =========== =======================
487
- """
488
- try:
489
- self.ui.statusbar.showMessage(txt, status_time)
490
- logger.info(txt)
491
- except Exception as e:
492
- logger.exception(str(e))
493
-
494
-
495
- if __name__ == '__main__':
496
- app = QtWidgets.QApplication(sys.argv)
497
- widg = QtWidgets.QWidget()
498
- prog = Navigator(widg)
499
- widg.show()
500
- sys.exit(app.exec_())