pymodaq 4.4.7__py3-none-any.whl → 5.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 (415) hide show
  1. pymodaq/__init__.py +57 -91
  2. pymodaq/control_modules/daq_move.py +64 -46
  3. pymodaq/control_modules/daq_move_ui.py +34 -12
  4. pymodaq/control_modules/daq_viewer.py +55 -30
  5. pymodaq/control_modules/daq_viewer_ui.py +6 -6
  6. pymodaq/control_modules/mocks.py +1 -1
  7. pymodaq/control_modules/move_utility_classes.py +51 -43
  8. pymodaq/control_modules/utils.py +43 -20
  9. pymodaq/control_modules/viewer_utility_classes.py +54 -18
  10. pymodaq/daq_utils/daq_utils.py +6 -0
  11. pymodaq/dashboard.py +639 -323
  12. pymodaq/examples/function_plotter.py +13 -12
  13. pymodaq/examples/tcp_client.py +1 -1
  14. pymodaq/extensions/__init__.py +1 -1
  15. pymodaq/extensions/bayesian/bayesian_optimisation.py +44 -32
  16. pymodaq/extensions/bayesian/utils.py +10 -10
  17. pymodaq/extensions/console.py +7 -6
  18. pymodaq/extensions/daq_logger/__init__.py +1 -0
  19. pymodaq/extensions/{daq_logger.py → daq_logger/daq_logger.py} +30 -30
  20. pymodaq/{utils/db/db_logger → extensions/daq_logger/db}/db_logger.py +16 -15
  21. pymodaq/{utils/db/db_logger → extensions/daq_logger/db}/db_logger_models.py +2 -0
  22. pymodaq/{utils/h5modules → extensions/daq_logger}/h5logging.py +7 -8
  23. pymodaq/extensions/daq_scan.py +42 -34
  24. pymodaq/extensions/daq_scan_ui.py +18 -18
  25. pymodaq/extensions/h5browser.py +2 -3
  26. pymodaq/extensions/pid/__init__.py +4 -2
  27. pymodaq/extensions/pid/daq_move_PID.py +3 -3
  28. pymodaq/extensions/pid/pid_controller.py +59 -50
  29. pymodaq/extensions/pid/utils.py +10 -5
  30. pymodaq/extensions/utils.py +33 -3
  31. pymodaq/post_treatment/load_and_plot.py +10 -7
  32. pymodaq/resources/preset_default.xml +1 -1
  33. pymodaq/updater.py +107 -0
  34. pymodaq/utils/array_manipulation.py +4 -384
  35. pymodaq/utils/calibration_camera.py +12 -9
  36. pymodaq/utils/chrono_timer.py +11 -10
  37. pymodaq/utils/config.py +3 -458
  38. pymodaq/utils/daq_utils.py +9 -715
  39. pymodaq/utils/data.py +17 -2959
  40. pymodaq/utils/enums.py +4 -74
  41. pymodaq/utils/exceptions.py +0 -4
  42. pymodaq/utils/gui_utils/__init__.py +8 -8
  43. pymodaq/utils/gui_utils/loader_utils.py +26 -1
  44. pymodaq/utils/gui_utils/utils.py +8 -162
  45. pymodaq/utils/gui_utils/widgets/lcd.py +6 -109
  46. pymodaq/utils/h5modules/__init__.py +0 -4
  47. pymodaq/utils/h5modules/module_saving.py +9 -8
  48. pymodaq/utils/leco/__init__.py +2 -2
  49. pymodaq/utils/leco/daq_move_LECODirector.py +3 -6
  50. pymodaq/utils/leco/daq_xDviewer_LECODirector.py +5 -5
  51. pymodaq/utils/leco/director_utils.py +2 -2
  52. pymodaq/utils/leco/leco_director.py +3 -3
  53. pymodaq/utils/leco/pymodaq_listener.py +4 -3
  54. pymodaq/utils/leco/utils.py +11 -9
  55. pymodaq/utils/logger.py +4 -76
  56. pymodaq/utils/managers/batchscan_manager.py +16 -19
  57. pymodaq/utils/managers/modules_manager.py +30 -17
  58. pymodaq/utils/managers/overshoot_manager.py +48 -6
  59. pymodaq/utils/managers/preset_manager.py +39 -59
  60. pymodaq/utils/managers/preset_manager_utils.py +28 -22
  61. pymodaq/utils/managers/remote_manager.py +12 -10
  62. pymodaq/utils/math_utils.py +4 -582
  63. pymodaq/utils/messenger.py +4 -64
  64. pymodaq/utils/parameter/__init__.py +6 -9
  65. pymodaq/utils/parameter/utils.py +4 -328
  66. pymodaq/utils/scanner/scan_config.py +1 -1
  67. pymodaq/utils/scanner/scan_factory.py +16 -12
  68. pymodaq/utils/{plotting → scanner}/scan_selector.py +19 -20
  69. pymodaq/utils/scanner/scanner.py +10 -8
  70. pymodaq/utils/scanner/scanners/_1d_scanners.py +8 -5
  71. pymodaq/utils/scanner/scanners/_2d_scanners.py +5 -5
  72. pymodaq/utils/scanner/scanners/sequential.py +8 -8
  73. pymodaq/utils/scanner/scanners/tabular.py +9 -9
  74. pymodaq/utils/scanner/utils.py +6 -4
  75. pymodaq/utils/svg/svg_viewer2D.py +3 -4
  76. pymodaq/utils/tcp_ip/mysocket.py +4 -110
  77. pymodaq/utils/tcp_ip/serializer.py +4 -801
  78. pymodaq/utils/tcp_ip/tcp_server_client.py +15 -13
  79. pymodaq-5.0.1.dist-info/METADATA +242 -0
  80. pymodaq-5.0.1.dist-info/RECORD +122 -0
  81. {pymodaq-4.4.7.dist-info → pymodaq-5.0.1.dist-info}/WHEEL +1 -1
  82. {pymodaq-4.4.7.dist-info → pymodaq-5.0.1.dist-info}/entry_points.txt +1 -0
  83. pymodaq/examples/custom_app.py +0 -258
  84. pymodaq/examples/custom_viewer.py +0 -112
  85. pymodaq/examples/parameter_ex.py +0 -138
  86. pymodaq/examples/preset_MockCamera.xml +0 -1
  87. pymodaq/post_treatment/daq_measurement/daq_measurement_GUI.py +0 -142
  88. pymodaq/post_treatment/daq_measurement/daq_measurement_GUI.ui +0 -232
  89. pymodaq/post_treatment/daq_measurement/daq_measurement_main.py +0 -391
  90. pymodaq/post_treatment/daq_measurement/process_from_QtDesigner_DAQ_Measurement_GUI.bat +0 -2
  91. pymodaq/post_treatment/process_to_scalar.py +0 -263
  92. pymodaq/resources/QtDesigner_Ressources/Icon_Library/1d.png +0 -0
  93. pymodaq/resources/QtDesigner_Ressources/Icon_Library/2d.png +0 -0
  94. pymodaq/resources/QtDesigner_Ressources/Icon_Library/3d.png +0 -0
  95. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Add2.png +0 -0
  96. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Add_Step.png +0 -0
  97. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Approve.png +0 -0
  98. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Approve_All.png +0 -0
  99. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Browse_Dir_Path.png +0 -0
  100. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Calculator.png +0 -0
  101. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ChnGroup.png +0 -0
  102. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ChnNum.png +0 -0
  103. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ChnText.png +0 -0
  104. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ChnTime.png +0 -0
  105. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ChnWave.png +0 -0
  106. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Close3.png +0 -0
  107. pymodaq/resources/QtDesigner_Ressources/Icon_Library/CollapseAll.png +0 -0
  108. pymodaq/resources/QtDesigner_Ressources/Icon_Library/CollapseAll_32.png +0 -0
  109. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ColorPicker.png +0 -0
  110. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Contract.png +0 -0
  111. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Create.png +0 -0
  112. pymodaq/resources/QtDesigner_Ressources/Icon_Library/DeleteLayer.png +0 -0
  113. pymodaq/resources/QtDesigner_Ressources/Icon_Library/EditOpen.png +0 -0
  114. pymodaq/resources/QtDesigner_Ressources/Icon_Library/EditRedo.png +0 -0
  115. pymodaq/resources/QtDesigner_Ressources/Icon_Library/EditUndo.png +0 -0
  116. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Ellipse.png +0 -0
  117. pymodaq/resources/QtDesigner_Ressources/Icon_Library/EllipseFilled.png +0 -0
  118. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Error.png +0 -0
  119. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ErrorMessage.png +0 -0
  120. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Error_16.png +0 -0
  121. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Exit.png +0 -0
  122. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Expand.png +0 -0
  123. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ExpandAll.png +0 -0
  124. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ExpandAll_32.png +0 -0
  125. pymodaq/resources/QtDesigner_Ressources/Icon_Library/FFT.png +0 -0
  126. pymodaq/resources/QtDesigner_Ressources/Icon_Library/HLM.ico +0 -0
  127. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Help.png +0 -0
  128. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Help_32.png +0 -0
  129. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Histogram.png +0 -0
  130. pymodaq/resources/QtDesigner_Ressources/Icon_Library/LUT_LookUpTable.png +0 -0
  131. pymodaq/resources/QtDesigner_Ressources/Icon_Library/MagnifyingGlass.png +0 -0
  132. pymodaq/resources/QtDesigner_Ressources/Icon_Library/MagnifyingGlass_24.png +0 -0
  133. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Marker.png +0 -0
  134. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Math.png +0 -0
  135. pymodaq/resources/QtDesigner_Ressources/Icon_Library/MeasurementStudio_32.png +0 -0
  136. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Move.png +0 -0
  137. pymodaq/resources/QtDesigner_Ressources/Icon_Library/MoveDown.png +0 -0
  138. pymodaq/resources/QtDesigner_Ressources/Icon_Library/MoveUp.png +0 -0
  139. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Multiply.png +0 -0
  140. pymodaq/resources/QtDesigner_Ressources/Icon_Library/NewFile.png +0 -0
  141. pymodaq/resources/QtDesigner_Ressources/Icon_Library/NewLayer.png +0 -0
  142. pymodaq/resources/QtDesigner_Ressources/Icon_Library/New_File.png +0 -0
  143. pymodaq/resources/QtDesigner_Ressources/Icon_Library/New_Folder.png +0 -0
  144. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Open.png +0 -0
  145. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Open_1D.png +0 -0
  146. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Open_2D.png +0 -0
  147. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Open_File.png +0 -0
  148. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Open_File_32.png +0 -0
  149. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Open_sim.png +0 -0
  150. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Options.png +0 -0
  151. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Oscilloscope.png +0 -0
  152. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Oscilloscope_16.png +0 -0
  153. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Pass.png +0 -0
  154. pymodaq/resources/QtDesigner_Ressources/Icon_Library/RGB.png +0 -0
  155. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Rectangle.png +0 -0
  156. pymodaq/resources/QtDesigner_Ressources/Icon_Library/RectangleFilled.png +0 -0
  157. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Redo.png +0 -0
  158. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Refresh.png +0 -0
  159. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Refresh2.png +0 -0
  160. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Refresh_32.png +0 -0
  161. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Region.png +0 -0
  162. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Rendezvous.png +0 -0
  163. pymodaq/resources/QtDesigner_Ressources/Icon_Library/SELECT.png +0 -0
  164. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Save.png +0 -0
  165. pymodaq/resources/QtDesigner_Ressources/Icon_Library/SaveAll.png +0 -0
  166. pymodaq/resources/QtDesigner_Ressources/Icon_Library/SaveAll_32.png +0 -0
  167. pymodaq/resources/QtDesigner_Ressources/Icon_Library/SaveAs.png +0 -0
  168. pymodaq/resources/QtDesigner_Ressources/Icon_Library/SaveAs_32.png +0 -0
  169. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Save_24.png +0 -0
  170. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Save_32.png +0 -0
  171. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Search.png +0 -0
  172. pymodaq/resources/QtDesigner_Ressources/Icon_Library/SelectPolygon.png +0 -0
  173. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Select_24.png +0 -0
  174. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Settings.png +0 -0
  175. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Snap&Save.png +0 -0
  176. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Snapshot.png +0 -0
  177. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Snapshot2.png +0 -0
  178. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Snapshot2_16.png +0 -0
  179. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Snapshot2_32.png +0 -0
  180. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Spreadsheet.png +0 -0
  181. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Statistics.png +0 -0
  182. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Statistics2.png +0 -0
  183. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Status.png +0 -0
  184. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Subtract.png +0 -0
  185. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Vision.png +0 -0
  186. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Volts.png +0 -0
  187. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Wait2.png +0 -0
  188. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Zoom_1_1.png +0 -0
  189. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Zoom_in.png +0 -0
  190. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Zoom_out.png +0 -0
  191. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Zoom_to_Selection.png +0 -0
  192. pymodaq/resources/QtDesigner_Ressources/Icon_Library/abort.png +0 -0
  193. pymodaq/resources/QtDesigner_Ressources/Icon_Library/advanced2.png +0 -0
  194. pymodaq/resources/QtDesigner_Ressources/Icon_Library/algo.png +0 -0
  195. pymodaq/resources/QtDesigner_Ressources/Icon_Library/autoscale.png +0 -0
  196. pymodaq/resources/QtDesigner_Ressources/Icon_Library/b_icon.png +0 -0
  197. pymodaq/resources/QtDesigner_Ressources/Icon_Library/back.png +0 -0
  198. pymodaq/resources/QtDesigner_Ressources/Icon_Library/bg_icon.png +0 -0
  199. pymodaq/resources/QtDesigner_Ressources/Icon_Library/camera.png +0 -0
  200. pymodaq/resources/QtDesigner_Ressources/Icon_Library/camera_snap.png +0 -0
  201. pymodaq/resources/QtDesigner_Ressources/Icon_Library/cartesian.png +0 -0
  202. pymodaq/resources/QtDesigner_Ressources/Icon_Library/clear2.png +0 -0
  203. pymodaq/resources/QtDesigner_Ressources/Icon_Library/clear_ROI.png +0 -0
  204. pymodaq/resources/QtDesigner_Ressources/Icon_Library/close2.png +0 -0
  205. pymodaq/resources/QtDesigner_Ressources/Icon_Library/cluster2.png +0 -0
  206. pymodaq/resources/QtDesigner_Ressources/Icon_Library/color.png +0 -0
  207. pymodaq/resources/QtDesigner_Ressources/Icon_Library/color2.png +0 -0
  208. pymodaq/resources/QtDesigner_Ressources/Icon_Library/continuous.png +0 -0
  209. pymodaq/resources/QtDesigner_Ressources/Icon_Library/data.png +0 -0
  210. pymodaq/resources/QtDesigner_Ressources/Icon_Library/delay.png +0 -0
  211. pymodaq/resources/QtDesigner_Ressources/Icon_Library/download.png +0 -0
  212. pymodaq/resources/QtDesigner_Ressources/Icon_Library/download2.png +0 -0
  213. pymodaq/resources/QtDesigner_Ressources/Icon_Library/error2.png +0 -0
  214. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ethernet.png +0 -0
  215. pymodaq/resources/QtDesigner_Ressources/Icon_Library/exit2.png +0 -0
  216. pymodaq/resources/QtDesigner_Ressources/Icon_Library/fan.png +0 -0
  217. pymodaq/resources/QtDesigner_Ressources/Icon_Library/filter2.png +0 -0
  218. pymodaq/resources/QtDesigner_Ressources/Icon_Library/g_icon.png +0 -0
  219. pymodaq/resources/QtDesigner_Ressources/Icon_Library/gear2.png +0 -0
  220. pymodaq/resources/QtDesigner_Ressources/Icon_Library/go_to.png +0 -0
  221. pymodaq/resources/QtDesigner_Ressources/Icon_Library/go_to_1.png +0 -0
  222. pymodaq/resources/QtDesigner_Ressources/Icon_Library/go_to_2.png +0 -0
  223. pymodaq/resources/QtDesigner_Ressources/Icon_Library/grab.png +0 -0
  224. pymodaq/resources/QtDesigner_Ressources/Icon_Library/graph.png +0 -0
  225. pymodaq/resources/QtDesigner_Ressources/Icon_Library/greenLight2.png +0 -0
  226. pymodaq/resources/QtDesigner_Ressources/Icon_Library/greenLight2_32.png +0 -0
  227. pymodaq/resources/QtDesigner_Ressources/Icon_Library/green_light.png +0 -0
  228. pymodaq/resources/QtDesigner_Ressources/Icon_Library/grey_icon.png +0 -0
  229. pymodaq/resources/QtDesigner_Ressources/Icon_Library/greyscale.png +0 -0
  230. pymodaq/resources/QtDesigner_Ressources/Icon_Library/help1.png +0 -0
  231. pymodaq/resources/QtDesigner_Ressources/Icon_Library/help1_32.png +0 -0
  232. pymodaq/resources/QtDesigner_Ressources/Icon_Library/home2.png +0 -0
  233. pymodaq/resources/QtDesigner_Ressources/Icon_Library/information2.png +0 -0
  234. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ini.png +0 -0
  235. pymodaq/resources/QtDesigner_Ressources/Icon_Library/input.png +0 -0
  236. pymodaq/resources/QtDesigner_Ressources/Icon_Library/integrator.png +0 -0
  237. pymodaq/resources/QtDesigner_Ressources/Icon_Library/joystick.png +0 -0
  238. pymodaq/resources/QtDesigner_Ressources/Icon_Library/light_green.png +0 -0
  239. pymodaq/resources/QtDesigner_Ressources/Icon_Library/light_green_16.png +0 -0
  240. pymodaq/resources/QtDesigner_Ressources/Icon_Library/light_red.png +0 -0
  241. pymodaq/resources/QtDesigner_Ressources/Icon_Library/light_red_16.png +0 -0
  242. pymodaq/resources/QtDesigner_Ressources/Icon_Library/light_yellow.png +0 -0
  243. pymodaq/resources/QtDesigner_Ressources/Icon_Library/light_yellow_16.png +0 -0
  244. pymodaq/resources/QtDesigner_Ressources/Icon_Library/limiter.png +0 -0
  245. pymodaq/resources/QtDesigner_Ressources/Icon_Library/load_ROI.png +0 -0
  246. pymodaq/resources/QtDesigner_Ressources/Icon_Library/meshPlot.png +0 -0
  247. pymodaq/resources/QtDesigner_Ressources/Icon_Library/meter.png +0 -0
  248. pymodaq/resources/QtDesigner_Ressources/Icon_Library/meter2.png +0 -0
  249. pymodaq/resources/QtDesigner_Ressources/Icon_Library/meter_32.png +0 -0
  250. pymodaq/resources/QtDesigner_Ressources/Icon_Library/move_contour.png +0 -0
  251. pymodaq/resources/QtDesigner_Ressources/Icon_Library/move_straight_line.png +0 -0
  252. pymodaq/resources/QtDesigner_Ressources/Icon_Library/movie.png +0 -0
  253. pymodaq/resources/QtDesigner_Ressources/Icon_Library/multi_point.png +0 -0
  254. pymodaq/resources/QtDesigner_Ressources/Icon_Library/multiplexer.png +0 -0
  255. pymodaq/resources/QtDesigner_Ressources/Icon_Library/new.png +0 -0
  256. pymodaq/resources/QtDesigner_Ressources/Icon_Library/openArrow.png +0 -0
  257. pymodaq/resources/QtDesigner_Ressources/Icon_Library/openTree.png +0 -0
  258. pymodaq/resources/QtDesigner_Ressources/Icon_Library/oscilloscope2.png +0 -0
  259. pymodaq/resources/QtDesigner_Ressources/Icon_Library/oscilloscope3.png +0 -0
  260. pymodaq/resources/QtDesigner_Ressources/Icon_Library/overlay.png +0 -0
  261. pymodaq/resources/QtDesigner_Ressources/Icon_Library/pass2.png +0 -0
  262. pymodaq/resources/QtDesigner_Ressources/Icon_Library/pass2_16.png +0 -0
  263. pymodaq/resources/QtDesigner_Ressources/Icon_Library/pass_32.png +0 -0
  264. pymodaq/resources/QtDesigner_Ressources/Icon_Library/pause.png +0 -0
  265. pymodaq/resources/QtDesigner_Ressources/Icon_Library/permute.png +0 -0
  266. pymodaq/resources/QtDesigner_Ressources/Icon_Library/phase.png +0 -0
  267. pymodaq/resources/QtDesigner_Ressources/Icon_Library/play.png +0 -0
  268. pymodaq/resources/QtDesigner_Ressources/Icon_Library/polar.png +0 -0
  269. pymodaq/resources/QtDesigner_Ressources/Icon_Library/pole_zero.png +0 -0
  270. pymodaq/resources/QtDesigner_Ressources/Icon_Library/powerMeter.png +0 -0
  271. pymodaq/resources/QtDesigner_Ressources/Icon_Library/powerSwitch.png +0 -0
  272. pymodaq/resources/QtDesigner_Ressources/Icon_Library/powerSwitch_16.png +0 -0
  273. pymodaq/resources/QtDesigner_Ressources/Icon_Library/print2.png +0 -0
  274. pymodaq/resources/QtDesigner_Ressources/Icon_Library/print2_32.png +0 -0
  275. pymodaq/resources/QtDesigner_Ressources/Icon_Library/properties.png +0 -0
  276. pymodaq/resources/QtDesigner_Ressources/Icon_Library/r_icon.png +0 -0
  277. pymodaq/resources/QtDesigner_Ressources/Icon_Library/radiocontrolbutton.png +0 -0
  278. pymodaq/resources/QtDesigner_Ressources/Icon_Library/random.png +0 -0
  279. pymodaq/resources/QtDesigner_Ressources/Icon_Library/read2.png +0 -0
  280. pymodaq/resources/QtDesigner_Ressources/Icon_Library/red_light.png +0 -0
  281. pymodaq/resources/QtDesigner_Ressources/Icon_Library/remove.png +0 -0
  282. pymodaq/resources/QtDesigner_Ressources/Icon_Library/reset.png +0 -0
  283. pymodaq/resources/QtDesigner_Ressources/Icon_Library/rgb_icon.png +0 -0
  284. pymodaq/resources/QtDesigner_Ressources/Icon_Library/robot.png +0 -0
  285. pymodaq/resources/QtDesigner_Ressources/Icon_Library/rotation2.png +0 -0
  286. pymodaq/resources/QtDesigner_Ressources/Icon_Library/run2.png +0 -0
  287. pymodaq/resources/QtDesigner_Ressources/Icon_Library/run_all.png +0 -0
  288. pymodaq/resources/QtDesigner_Ressources/Icon_Library/saturation.png +0 -0
  289. pymodaq/resources/QtDesigner_Ressources/Icon_Library/saveTree.png +0 -0
  290. pymodaq/resources/QtDesigner_Ressources/Icon_Library/save_ROI.png +0 -0
  291. pymodaq/resources/QtDesigner_Ressources/Icon_Library/scale_horizontally.png +0 -0
  292. pymodaq/resources/QtDesigner_Ressources/Icon_Library/scale_vertically.png +0 -0
  293. pymodaq/resources/QtDesigner_Ressources/Icon_Library/search2.png +0 -0
  294. pymodaq/resources/QtDesigner_Ressources/Icon_Library/select2.png +0 -0
  295. pymodaq/resources/QtDesigner_Ressources/Icon_Library/select_all.png +0 -0
  296. pymodaq/resources/QtDesigner_Ressources/Icon_Library/select_all2.png +0 -0
  297. pymodaq/resources/QtDesigner_Ressources/Icon_Library/select_none.png +0 -0
  298. pymodaq/resources/QtDesigner_Ressources/Icon_Library/sequence.png +0 -0
  299. pymodaq/resources/QtDesigner_Ressources/Icon_Library/sequence2.png +0 -0
  300. pymodaq/resources/QtDesigner_Ressources/Icon_Library/snap.png +0 -0
  301. pymodaq/resources/QtDesigner_Ressources/Icon_Library/sort_ascend.png +0 -0
  302. pymodaq/resources/QtDesigner_Ressources/Icon_Library/spectrumAnalyzer.png +0 -0
  303. pymodaq/resources/QtDesigner_Ressources/Icon_Library/start.png +0 -0
  304. pymodaq/resources/QtDesigner_Ressources/Icon_Library/status_cancelled.png +0 -0
  305. pymodaq/resources/QtDesigner_Ressources/Icon_Library/stop.png +0 -0
  306. pymodaq/resources/QtDesigner_Ressources/Icon_Library/stop2.png +0 -0
  307. pymodaq/resources/QtDesigner_Ressources/Icon_Library/stop3.png +0 -0
  308. pymodaq/resources/QtDesigner_Ressources/Icon_Library/stop_all.png +0 -0
  309. pymodaq/resources/QtDesigner_Ressources/Icon_Library/sum.png +0 -0
  310. pymodaq/resources/QtDesigner_Ressources/Icon_Library/surfacePlot.png +0 -0
  311. pymodaq/resources/QtDesigner_Ressources/Icon_Library/target.png +0 -0
  312. pymodaq/resources/QtDesigner_Ressources/Icon_Library/tree.png +0 -0
  313. pymodaq/resources/QtDesigner_Ressources/Icon_Library/updateTree.png +0 -0
  314. pymodaq/resources/QtDesigner_Ressources/Icon_Library/utility2.png +0 -0
  315. pymodaq/resources/QtDesigner_Ressources/Icon_Library/utility_small.png +0 -0
  316. pymodaq/resources/QtDesigner_Ressources/Icon_Library/vector.png +0 -0
  317. pymodaq/resources/QtDesigner_Ressources/Icon_Library/verify.png +0 -0
  318. pymodaq/resources/QtDesigner_Ressources/Icon_Library/video.png +0 -0
  319. pymodaq/resources/QtDesigner_Ressources/Icon_Library/wait.png +0 -0
  320. pymodaq/resources/QtDesigner_Ressources/Icon_Library/waterfallPlot.png +0 -0
  321. pymodaq/resources/QtDesigner_Ressources/Icon_Library/watershed.png +0 -0
  322. pymodaq/resources/QtDesigner_Ressources/Icon_Library/yellow_light.png +0 -0
  323. pymodaq/resources/QtDesigner_Ressources/Icon_Library/zip_file.png +0 -0
  324. pymodaq/resources/QtDesigner_Ressources/Icon_Library/zoomAuto.png +0 -0
  325. pymodaq/resources/QtDesigner_Ressources/Icon_Library/zoomReset.png +0 -0
  326. pymodaq/resources/QtDesigner_Ressources/QtDesigner_ressources.bat +0 -2
  327. pymodaq/resources/QtDesigner_Ressources/QtDesigner_ressources.qrc +0 -238
  328. pymodaq/resources/QtDesigner_Ressources/QtDesigner_ressources_rc.py +0 -127453
  329. pymodaq/resources/QtDesigner_Ressources/__init__.py +0 -0
  330. pymodaq/resources/QtDesigner_Ressources/credit.rst +0 -7
  331. pymodaq/resources/QtDesigner_Ressources/icons.svg +0 -142
  332. pymodaq/resources/VERSION +0 -2
  333. pymodaq/resources/config_template.toml +0 -96
  334. pymodaq/resources/triangulation_data.npy +0 -0
  335. pymodaq/utils/abstract/__init__.py +0 -48
  336. pymodaq/utils/db/__init__.py +0 -0
  337. pymodaq/utils/db/db_logger/__init__.py +0 -0
  338. pymodaq/utils/factory.py +0 -82
  339. pymodaq/utils/gui_utils/custom_app.py +0 -133
  340. pymodaq/utils/gui_utils/dock.py +0 -107
  341. pymodaq/utils/gui_utils/file_io.py +0 -94
  342. pymodaq/utils/gui_utils/layout.py +0 -34
  343. pymodaq/utils/gui_utils/list_picker.py +0 -38
  344. pymodaq/utils/gui_utils/widgets/__init__.py +0 -5
  345. pymodaq/utils/gui_utils/widgets/label.py +0 -24
  346. pymodaq/utils/gui_utils/widgets/push.py +0 -149
  347. pymodaq/utils/gui_utils/widgets/qled.py +0 -62
  348. pymodaq/utils/gui_utils/widgets/spinbox.py +0 -24
  349. pymodaq/utils/gui_utils/widgets/table.py +0 -263
  350. pymodaq/utils/gui_utils/widgets/tree_layout.py +0 -188
  351. pymodaq/utils/gui_utils/widgets/tree_toml.py +0 -110
  352. pymodaq/utils/h5modules/backends.py +0 -1022
  353. pymodaq/utils/h5modules/browsing.py +0 -627
  354. pymodaq/utils/h5modules/data_saving.py +0 -1107
  355. pymodaq/utils/h5modules/exporter.py +0 -119
  356. pymodaq/utils/h5modules/exporters/__init__.py +0 -0
  357. pymodaq/utils/h5modules/exporters/base.py +0 -111
  358. pymodaq/utils/h5modules/exporters/flimj.py +0 -63
  359. pymodaq/utils/h5modules/exporters/hyperspy.py +0 -143
  360. pymodaq/utils/h5modules/saving.py +0 -866
  361. pymodaq/utils/h5modules/utils.py +0 -115
  362. pymodaq/utils/managers/action_manager.py +0 -489
  363. pymodaq/utils/managers/parameter_manager.py +0 -279
  364. pymodaq/utils/managers/roi_manager.py +0 -740
  365. pymodaq/utils/parameter/ioxml.py +0 -545
  366. pymodaq/utils/parameter/pymodaq_ptypes/__init__.py +0 -38
  367. pymodaq/utils/parameter/pymodaq_ptypes/bool.py +0 -31
  368. pymodaq/utils/parameter/pymodaq_ptypes/date.py +0 -126
  369. pymodaq/utils/parameter/pymodaq_ptypes/filedir.py +0 -143
  370. pymodaq/utils/parameter/pymodaq_ptypes/itemselect.py +0 -265
  371. pymodaq/utils/parameter/pymodaq_ptypes/led.py +0 -44
  372. pymodaq/utils/parameter/pymodaq_ptypes/list.py +0 -150
  373. pymodaq/utils/parameter/pymodaq_ptypes/numeric.py +0 -18
  374. pymodaq/utils/parameter/pymodaq_ptypes/pixmap.py +0 -175
  375. pymodaq/utils/parameter/pymodaq_ptypes/slide.py +0 -166
  376. pymodaq/utils/parameter/pymodaq_ptypes/table.py +0 -135
  377. pymodaq/utils/parameter/pymodaq_ptypes/tableview.py +0 -149
  378. pymodaq/utils/parameter/pymodaq_ptypes/text.py +0 -142
  379. pymodaq/utils/plotting/__init__.py +0 -0
  380. pymodaq/utils/plotting/data_viewers/__init__.py +0 -10
  381. pymodaq/utils/plotting/data_viewers/base.py +0 -286
  382. pymodaq/utils/plotting/data_viewers/viewer.py +0 -275
  383. pymodaq/utils/plotting/data_viewers/viewer0D.py +0 -298
  384. pymodaq/utils/plotting/data_viewers/viewer1D.py +0 -826
  385. pymodaq/utils/plotting/data_viewers/viewer1Dbasic.py +0 -231
  386. pymodaq/utils/plotting/data_viewers/viewer2D.py +0 -1118
  387. pymodaq/utils/plotting/data_viewers/viewer2D_basic.py +0 -146
  388. pymodaq/utils/plotting/data_viewers/viewerND.py +0 -800
  389. pymodaq/utils/plotting/gant_chart.py +0 -123
  390. pymodaq/utils/plotting/image_viewer.py +0 -97
  391. pymodaq/utils/plotting/items/__init__.py +0 -0
  392. pymodaq/utils/plotting/items/axis_scaled.py +0 -93
  393. pymodaq/utils/plotting/items/crosshair.py +0 -94
  394. pymodaq/utils/plotting/items/image.py +0 -388
  395. pymodaq/utils/plotting/navigator.py +0 -353
  396. pymodaq/utils/plotting/plotter/plotter.py +0 -94
  397. pymodaq/utils/plotting/plotter/plotters/__init__.py +0 -0
  398. pymodaq/utils/plotting/plotter/plotters/matplotlib_plotters.py +0 -134
  399. pymodaq/utils/plotting/plotter/plotters/qt_plotters.py +0 -78
  400. pymodaq/utils/plotting/utils/__init__.py +0 -0
  401. pymodaq/utils/plotting/utils/axes_viewer.py +0 -88
  402. pymodaq/utils/plotting/utils/filter.py +0 -585
  403. pymodaq/utils/plotting/utils/lineout.py +0 -226
  404. pymodaq/utils/plotting/utils/plot_utils.py +0 -579
  405. pymodaq/utils/plotting/utils/signalND.py +0 -1347
  406. pymodaq/utils/plotting/widgets.py +0 -76
  407. pymodaq/utils/qvariant.py +0 -12
  408. pymodaq/utils/slicing.py +0 -63
  409. pymodaq/utils/units.py +0 -216
  410. pymodaq-4.4.7.dist-info/METADATA +0 -163
  411. pymodaq-4.4.7.dist-info/RECORD +0 -446
  412. /pymodaq/{post_treatment/daq_analysis → daq_utils}/__init__.py +0 -0
  413. /pymodaq/{utils/abstract/logger.py → extensions/daq_logger/abstract.py} +0 -0
  414. /pymodaq/{post_treatment/daq_measurement → extensions/daq_logger/db}/__init__.py +0 -0
  415. {pymodaq-4.4.7.dist-info → pymodaq-5.0.1.dist-info}/licenses/LICENSE +0 -0
@@ -1,1107 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """
3
- Created the 21/11/2022
4
-
5
- @author: Sebastien Weber
6
- """
7
- from time import time
8
- from typing import Union, List, Tuple, Iterable
9
- from pathlib import Path
10
-
11
- import numpy as np
12
-
13
- from pymodaq.utils.abstract import ABCMeta, abstract_attribute
14
- from pymodaq.utils.enums import enum_checker
15
- from pymodaq.utils.data import (Axis, DataDim, DataWithAxes, DataToExport, DataDistribution,
16
- DataDimError, squeeze)
17
- from .saving import DataType, H5Saver
18
- from .backends import GROUP, CARRAY, Node, EARRAY, NodeError
19
- from pymodaq.utils.daq_utils import capitalize
20
- from pymodaq.utils.scanner.utils import ScanType
21
-
22
- SPECIAL_GROUP_NAMES = dict(nav_axes='NavAxes')
23
-
24
-
25
- class AxisError(Exception):
26
- pass
27
-
28
-
29
- class DataManagement(metaclass=ABCMeta):
30
- """Base abstract class to be used for all specialized object saving and loading data to/from a h5file
31
-
32
- Attributes
33
- ----------
34
- data_type: DataType
35
- The enum for this type of data, here abstract and should be redefined
36
- """
37
- data_type: DataType = abstract_attribute()
38
- _h5saver: H5Saver = abstract_attribute()
39
-
40
- @classmethod
41
- def _format_node_name(cls, ind: int) -> str:
42
- """ Format the saved node following the data_type attribute and an integer index
43
-
44
- Parameters
45
- ----------
46
- ind: int
47
-
48
- Returns
49
- -------
50
- str: the future name of the node
51
- """
52
- return f'{capitalize(cls.data_type.value)}{ind:02d}'
53
-
54
- def __enter__(self):
55
- return self
56
-
57
- def __exit__(self, exc_type, exc_val, exc_tb):
58
- self.close_file()
59
-
60
- def close_file(self):
61
- self._h5saver.close_file()
62
-
63
- def _get_next_node_name(self, where: Union[str, Node]) -> str:
64
- """Get the formatted next node name given the ones already saved
65
-
66
- Parameters
67
- ----------
68
- where: Union[Node, str]
69
- the path of a given node or the node itself
70
-
71
- Returns
72
- -------
73
- str: the future name of the node
74
- """
75
- return self._format_node_name(self._get_next_data_type_index_in_group(where))
76
-
77
- def get_last_node_name(self, where: Union[str, Node]) -> Union[str, None]:
78
- """Get the last node name among the ones already saved
79
-
80
- Parameters
81
- ----------
82
- where: Union[Node, str]
83
- the path of a given node or the node itself
84
-
85
- Returns
86
- -------
87
- str: the name of the last saved node or None if none saved
88
- """
89
- index = self._get_next_data_type_index_in_group(where) - 1
90
- if index == -1:
91
- return None
92
- else:
93
- return self._format_node_name(index)
94
-
95
- def get_node_from_index(self, where: Union[str, Node], index: int) -> Node:
96
- return self._h5saver.get_node(where, self._format_node_name(index))
97
-
98
- def get_index_from_node_name(self, where: Union[str, Node]):
99
- node = self._h5saver.get_node(where)
100
- try:
101
- index = int(node.name.split(self.data_type.value)[1])
102
- except IndexError:
103
- return None
104
- return index
105
-
106
- def _get_next_data_type_index_in_group(self, where: Union[Node, str]) -> int:
107
- """Check how much node with a given data_type are already present within the GROUP where
108
- Parameters
109
- ----------
110
- where: Union[Node, str]
111
- the path of a given node or the node itself
112
-
113
- Returns
114
- -------
115
- int: the next available integer to index the node name
116
- """
117
- ind = 0
118
- for node in self._h5saver.walk_nodes(where):
119
- if 'data_type' in node.attrs:
120
- if node.attrs['data_type'] == self.data_type.name:
121
- ind += 1
122
- return ind
123
-
124
- def _is_node_of_data_type(self, where: Union[str, Node]) -> bool:
125
- """Check if a given node is of the data_type of the real class implementation
126
-
127
- eg 'axis' for the AxisSaverLoader
128
-
129
- Parameters
130
- ----------
131
- where: Union[Node, str]
132
- the path of a given node or the node itself
133
-
134
- Returns
135
- -------
136
- bool
137
- """
138
- node = self._get_node(where)
139
- return 'data_type' in node.attrs and node.attrs['data_type'] == self.data_type
140
-
141
- def _get_node(self, where: Union[str, Node]) -> Node:
142
- """Utility method to get a node from a node or a string"""
143
- return self._h5saver.get_node(where)
144
-
145
- def _get_nodes(self, where: Union[str, Node]) -> List[Node]:
146
- """Get Nodes hanging from where including where
147
-
148
- Parameters
149
- ----------
150
- where: Union[Node, str]
151
- the path of a given node or the node itself
152
-
153
- Returns
154
- -------
155
- List[Node]
156
- """
157
- node = self._get_node(where)
158
- if isinstance(node, GROUP):
159
- return [child_node for child_node in self._h5saver.walk_nodes(node)]
160
- else:
161
- return [node]
162
-
163
- def _get_nodes_from_data_type(self, where: Union[str, Node]) -> List[Node]:
164
- """Get the node list hanging from a parent and having the same data type as self
165
-
166
- Parameters
167
- ----------
168
- where: Union[Node, str]
169
- the path of a given node
170
-
171
- Returns
172
- -------
173
- list of Nodes
174
- """
175
- node = self._get_node(where)
176
- if isinstance(node, GROUP):
177
- parent_node = node
178
- else:
179
- parent_node = node.parent_node
180
-
181
- nodes = []
182
- for child_node in self._h5saver.walk_nodes(parent_node):
183
- if self._is_node_of_data_type(child_node):
184
- nodes.append(child_node)
185
- return nodes
186
-
187
-
188
- class AxisSaverLoader(DataManagement):
189
- """Specialized Object to save and load Axis object to and from a h5file
190
-
191
- Parameters
192
- ----------
193
- h5saver: H5Saver
194
-
195
- Attributes
196
- ----------
197
- data_type: DataType
198
- The enum for this type of data, here 'axis'
199
- """
200
- data_type = DataType['axis']
201
-
202
- def __init__(self, h5saver: H5Saver):
203
- self._h5saver = h5saver
204
- self.data_type = enum_checker(DataType, self.data_type)
205
-
206
- def add_axis(self, where: Union[Node, str], axis: Axis, enlargeable=False):
207
- """Write Axis info at a given position within a h5 file
208
-
209
- Parameters
210
- ----------
211
- where: Union[Node, str]
212
- the path of a given node or the node itself
213
- axis: Axis
214
- the Axis object to add as a node in the h5file
215
- enlargeable: bool
216
- Specify if the underlying array will be enlargebale
217
- """
218
- array = self._h5saver.add_array(where, self._get_next_node_name(where), self.data_type, title=axis.label,
219
- array_to_save=axis.get_data(), data_dimension=DataDim['Data1D'],
220
- enlargeable=enlargeable,
221
- metadata=dict(size=axis.size, label=axis.label, units=axis.units,
222
- index=axis.index, offset=axis.offset, scaling=axis.scaling,
223
- distribution='uniform' if axis.is_axis_linear() else 'spread',
224
- spread_order=axis.spread_order))
225
- return array
226
-
227
- def load_axis(self, where: Union[Node, str]) -> Axis:
228
- """create an Axis object from the data and metadata at a given node if of data_type: 'axis
229
-
230
- Parameters
231
- ----------
232
- where: Union[Node, str]
233
- the path of a given node or the node itself
234
-
235
- Returns
236
- -------
237
- Axis
238
- """
239
- axis_node = self._get_node(where)
240
- if not self._is_node_of_data_type(axis_node):
241
- raise AxisError(f'Could not create an Axis object from this node: {axis_node}')
242
- return Axis(label=axis_node.attrs['label'], units=axis_node.attrs['units'],
243
- data=squeeze(axis_node.read()), index=axis_node.attrs['index'],
244
- spread_order=axis_node.attrs['spread_order'])
245
-
246
- def get_axes(self, where: Union[Node, str]) -> List[Axis]:
247
- """Return a list of Axis objects from the Axis Nodes hanging from (or among) a given Node
248
-
249
- Parameters
250
- ----------
251
- where: Union[Node, str]
252
- the path of a given node or the node itself
253
-
254
- Returns
255
- -------
256
- List[Axis]: the list of all Axis object
257
- """
258
- axes = []
259
- for node in self._get_nodes_from_data_type(where):
260
- axis = self.load_axis(node)
261
- # if axis.size > 1:
262
- # axes.append(axis)
263
- axes.append(axis)
264
- return axes
265
-
266
-
267
- class DataSaverLoader(DataManagement):
268
- """Specialized Object to save and load DataWithAxes object to and from a h5file
269
-
270
- Parameters
271
- ----------
272
- h5saver: H5Saver or Path or str
273
-
274
- Attributes
275
- ----------
276
- data_type: DataType
277
- The enum for this type of data, here 'data'
278
- """
279
- data_type = DataType['data']
280
-
281
- def __init__(self, h5saver: Union[H5Saver, Path]):
282
- self.data_type = enum_checker(DataType, self.data_type)
283
-
284
- if isinstance(h5saver, Path) or isinstance(h5saver, str):
285
- h5saver_tmp = H5Saver()
286
- h5saver_tmp.init_file(addhoc_file_path=Path(h5saver))
287
- h5saver = h5saver_tmp
288
-
289
- self._h5saver = h5saver
290
- self._axis_saver = AxisSaverLoader(h5saver)
291
- if not isinstance(self, ErrorSaverLoader):
292
- self._error_saver = ErrorSaverLoader(h5saver)
293
-
294
- def isopen(self) -> bool:
295
- """ Get the opened status of the underlying hdf5 file"""
296
- return self._h5saver.isopen()
297
-
298
- def add_data(self, where: Union[Node, str], data: DataWithAxes, save_axes=True, **kwargs):
299
- """Adds Array nodes to a given location adding eventually axes as others nodes and metadata
300
-
301
- Parameters
302
- ----------
303
- where: Union[Node, str]
304
- the path of a given node or the node itself
305
- data: DataWithAxes
306
- save_axes: bool
307
- """
308
-
309
- for ind_data in range(len(data)):
310
- metadata = dict(timestamp=data.timestamp, label=data.labels[ind_data],
311
- source=data.source.name, distribution=data.distribution.name,
312
- origin=data.origin,
313
- units=data.units,
314
- nav_indexes=tuple(data.nav_indexes)
315
- if data.nav_indexes is not None else None,)
316
- for name in data.extra_attributes:
317
- metadata[name] = getattr(data, name)
318
- self._h5saver.add_array(where, self._get_next_node_name(where), self.data_type,
319
- title=data.name, array_to_save=data[ind_data],
320
- data_dimension=data.dim.name, metadata=metadata)
321
-
322
- if save_axes:
323
- for axis in data.axes:
324
- self._axis_saver.add_axis(where, axis)
325
-
326
- if data.errors is not None:
327
- self._error_saver.add_data(where, data.errors_as_dwa(), save_axes=False)
328
-
329
- def get_axes(self, where: Union[Node, str]) -> List[Axis]:
330
- """
331
-
332
- Parameters
333
- ----------
334
- where: Union[Node, str]
335
- the path of a given node or the node itself
336
-
337
- Returns
338
- -------
339
-
340
- """
341
- return self._axis_saver.get_axes(where)
342
-
343
- def get_bkg_nodes(self, where: Union[Node, str]):
344
- bkg_nodes = []
345
- for node in self._h5saver.walk_nodes(where):
346
- if 'data_type' in node.attrs and node.attrs['data_type'] == 'bkg':
347
- bkg_nodes.append(node)
348
- return bkg_nodes
349
-
350
- def get_data_arrays(self, where: Union[Node, str], with_bkg=False,
351
- load_all=False) -> List[np.ndarray]:
352
- """
353
-
354
- Parameters
355
- ----------
356
- where: Union[Node, str]
357
- the path of a given node or the node itself
358
- with_bkg: bool
359
- If True try to load background node and return the array with background subtraction
360
- load_all: bool
361
- If True load all similar nodes hanging from a parent
362
-
363
- Returns
364
- -------
365
- list of ndarray
366
- """
367
- where = self._get_node(where)
368
- if with_bkg:
369
- bkg_nodes = []
370
- if with_bkg:
371
- bkg_nodes = self.get_bkg_nodes(where.parent_node)
372
- if len(bkg_nodes) == 0:
373
- with_bkg = False
374
-
375
- if load_all:
376
- getter = self._get_nodes_from_data_type
377
- else:
378
- getter = self._get_nodes
379
-
380
- if with_bkg:
381
- return [squeeze(array.read()-bkg.read(),
382
- squeeze_indexes=self._get_signal_indexes_to_squeeze(array))
383
- for array, bkg in zip(getter(where), bkg_nodes)]
384
- else:
385
- return [squeeze(array.read(),
386
- squeeze_indexes=self._get_signal_indexes_to_squeeze(array))
387
- for array in getter(where)]
388
-
389
- def _get_signal_indexes_to_squeeze(self, array: Union[CARRAY, EARRAY]):
390
- """ Get the tuple of indexes in the array shape that are not navigation and should be
391
- squeezed"""
392
- sig_indexes = []
393
- for ind in range(len(array.attrs['shape'])):
394
- if ind not in array.attrs['nav_indexes'] and array.attrs['shape'][ind] == 1:
395
- sig_indexes.append(ind)
396
- return tuple(sig_indexes)
397
-
398
- def load_data(self, where, with_bkg=False, load_all=False) -> DataWithAxes:
399
- """Return a DataWithAxes object from the Data and Axis Nodes hanging from (or among) a
400
- given Node
401
-
402
- Does not include navigation axes stored elsewhere in the h5file. The node path is stored in
403
- the DatWithAxis using the attribute path
404
-
405
- Parameters
406
- ----------
407
- where: Union[Node, str]
408
- the path of a given node or the node itself
409
- with_bkg: bool
410
- If True try to load background node and return the data with background subtraction
411
- load_all: bool
412
- If True, will load all data hanging from the same parent node
413
-
414
- See Also
415
- --------
416
- load_data
417
- """
418
-
419
- data_node = self._get_node(where)
420
-
421
- if load_all:
422
- parent_node = data_node.parent_node
423
- data_nodes = self._get_nodes_from_data_type(parent_node)
424
- data_node = data_nodes[0]
425
- error_node = data_node
426
- else:
427
- parent_node = data_node.parent_node
428
- if not isinstance(data_node, CARRAY):
429
- return
430
- data_nodes = [data_node]
431
- error_node = None
432
- try:
433
- error_node_index = self.get_index_from_node_name(data_node)
434
- if error_node_index is not None:
435
- error_node = self._error_saver.get_node_from_index(parent_node, error_node_index)
436
- except NodeError as e:
437
- pass
438
-
439
- if 'axis' in self.data_type.name:
440
- ndarrays = [squeeze(data_node.read()) for data_node in data_nodes]
441
- axes = [Axis(label=data_node.attrs['label'], units=data_node.attrs['units'],
442
- data=np.linspace(0, ndarrays[0].size-1, ndarrays[0].size-1))]
443
- error_arrays = None
444
- else:
445
- ndarrays = self.get_data_arrays(data_node, with_bkg=with_bkg, load_all=load_all)
446
- axes = self.get_axes(parent_node)
447
- if error_node is not None:
448
- error_arrays = self._error_saver.get_data_arrays(error_node, load_all=load_all)
449
- if len(error_arrays) == 0:
450
- error_arrays = None
451
- else:
452
- error_arrays = None
453
-
454
- extra_attributes = data_node.attrs.to_dict()
455
- for name in ['TITLE', 'CLASS', 'VERSION', 'backend', 'source', 'data_dimension',
456
- 'distribution', 'label', 'origin', 'nav_indexes', 'dtype', 'data_type',
457
- 'subdtype', 'shape', 'size', 'EXTDIM', 'path', 'timestamp', 'units']:
458
- extra_attributes.pop(name, None)
459
-
460
- data = DataWithAxes(data_node.attrs['TITLE'],
461
- source=data_node.attrs['source'] if 'source' in data_node.attrs
462
- else 'raw',
463
- dim=data_node.attrs['data_dimension'],
464
- units=data_node.attrs['units'] if 'units' in data_node.attrs else '',
465
- distribution=data_node.attrs['distribution'],
466
- data=ndarrays,
467
- labels=[node.attrs['label'] for node in data_nodes],
468
- origin=data_node.attrs['origin'] if 'origin' in data_node.attrs else '',
469
- nav_indexes=data_node.attrs['nav_indexes'] if 'nav_indexes' in
470
- data_node.attrs else (),
471
- axes=axes,
472
- errors=error_arrays,
473
- path=data_node.path,
474
- **extra_attributes)
475
- if 'axis' not in self.data_type.name:
476
- data.timestamp = data_node.attrs['timestamp']
477
- return data
478
-
479
-
480
- class BkgSaver(DataSaverLoader):
481
- """Specialized Object to save and load DataWithAxes background object to and from a h5file
482
-
483
- Parameters
484
- ----------
485
- hsaver: H5Saver
486
-
487
- Attributes
488
- ----------
489
- data_type: DataType
490
- The enum for this type of data, here 'bkg'
491
- """
492
- data_type = DataType['bkg']
493
-
494
- def __init__(self, h5saver: H5Saver):
495
- super().__init__(h5saver)
496
-
497
-
498
- class ErrorSaverLoader(DataSaverLoader):
499
- """Specialized Object to save and load DataWithAxes errors bars to and from a h5file
500
-
501
- Parameters
502
- ----------
503
- hsaver: H5Saver
504
-
505
- Attributes
506
- ----------
507
- data_type: DataType
508
- The enum for this type of data, here 'error'
509
- """
510
- data_type = DataType['error']
511
-
512
- def __init__(self, h5saver: H5Saver):
513
- super().__init__(h5saver)
514
-
515
-
516
- class DataEnlargeableSaver(DataSaverLoader):
517
- """ Specialized Object to save and load enlargeable DataWithAxes saved object to and from a
518
- h5file
519
-
520
- Particular case of DataND with a single *nav_indexes* parameter will be appended as chunks
521
- of signal data
522
-
523
- Parameters
524
- ----------
525
- h5saver: H5Saver
526
-
527
- Attributes
528
- ----------
529
- data_type: DataType
530
- The enum for this type of data, here 'data_enlargeable'
531
-
532
- Notes
533
- -----
534
- To be used to save data from a timed logger (DAQViewer continuous saving or DAQLogger extension) or from an
535
- adaptive scan where the final shape is unknown or other module that need this feature
536
- """
537
- data_type = DataType['data_enlargeable']
538
-
539
- def __init__(self, h5saver: Union[H5Saver, Path],
540
- enl_axis_names: Iterable[str] = ('nav axis',),
541
- enl_axis_units: Iterable[str] = ('',)):
542
- super().__init__(h5saver)
543
-
544
- self._n_enl_axes = len(enl_axis_names)
545
- self._enl_axis_names = enl_axis_names
546
- self._enl_axis_units = enl_axis_units
547
-
548
- def _create_data_arrays(self, where: Union[Node, str], data: DataWithAxes, save_axes=True,
549
- add_enl_axes=True):
550
- """ Create enlargeable array to store data
551
-
552
- Parameters
553
- ----------
554
- where: Union[Node, str]
555
- the path of a given node or the node itself
556
- data: DataWithAxes
557
- save_axes: bool
558
- if True, will save signal axes as data nodes
559
- add_enl_axes: bool
560
- if True, will save enlargeable axes as data nodes (depending on the self._enl_axis_names
561
- field)
562
-
563
- Notes
564
- -----
565
- Because data will be saved at a given index in the enlargeable array, related signal axes
566
- will have their index increased by 1)
567
- """
568
-
569
- if self.get_last_node_name(where) is None:
570
- for ind_data in range(len(data)):
571
- nav_indexes = list(data.nav_indexes)
572
- nav_indexes = ([0] +
573
- list(np.array(nav_indexes, dtype=int) + 1))
574
-
575
- self._h5saver.add_array(where, self._get_next_node_name(where), self.data_type,
576
- title=data.name,
577
- array_to_save=data[ind_data],
578
- data_shape=data[ind_data].shape,
579
- array_type=data[ind_data].dtype,
580
- enlargeable=True,
581
- data_dimension=data.dim.name,
582
- metadata=dict(timestamp=data.timestamp,
583
- label=data.labels[ind_data],
584
- source=data.source.name,
585
- distribution='spread',
586
- origin=data.origin,
587
- nav_indexes=tuple(nav_indexes)))
588
- if add_enl_axes:
589
- for ind_enl_axis in range(self._n_enl_axes):
590
- self._axis_saver.add_axis(where,
591
- Axis(self._enl_axis_names[ind_enl_axis],
592
- self._enl_axis_units[ind_enl_axis],
593
- data=np.array([0., 1.]),
594
- index=0, spread_order=ind_enl_axis),
595
- enlargeable=True)
596
- if save_axes:
597
- for axis in data.axes:
598
- axis = axis.copy()
599
- axis.index += 1 # because of enlargeable data will have an extra shape
600
- self._axis_saver.add_axis(where, axis)
601
-
602
- def add_data(self, where: Union[Node, str], data: DataWithAxes,
603
- axis_values: Iterable[float] = None):
604
- """ Append data to an enlargeable array node
605
-
606
- Data of dim (0, 1 or 2) will be just appended to the enlargeable array.
607
-
608
- Uniform DataND with one navigation axis of length (Lnav) will be considered as a collection
609
- of Lnav signal data of dim (0, 1 or 2) and will therefore be appended as Lnav signal data
610
-
611
- Parameters
612
- ----------
613
- where: Union[Node, str]
614
- the path of a given node or the node itself
615
- data: DataWithAxes
616
- axis_values: optional, list of floats
617
- the new spread axis values added to the data
618
- if None the axes are not added to the h5 file
619
-
620
-
621
- """
622
- add_enl_axes = axis_values is not None
623
-
624
- if self.get_last_node_name(where) is None:
625
- if len(data.nav_indexes) == 0:
626
- data_init = data
627
- else:
628
- raise DataDimError('It is not possible to append DataND')
629
- self._create_data_arrays(where, data_init, save_axes=True, add_enl_axes=add_enl_axes)
630
-
631
- for ind_data in range(len(data)):
632
- array: EARRAY = self.get_node_from_index(where, ind_data)
633
- array.append(data[ind_data])
634
- if add_enl_axes and axis_values is not None:
635
- for ind_axis in range(self._n_enl_axes):
636
- axis_array: EARRAY = self._axis_saver.get_node_from_index(where, ind_axis)
637
- axis_array.append(np.array([axis_values[ind_axis]]))
638
- axis_array.attrs['size'] += 1
639
-
640
-
641
- class DataExtendedSaver(DataSaverLoader):
642
- """Specialized Object to save and load DataWithAxes saved object to and from a h5file in extended arrays
643
-
644
- Parameters
645
- ----------
646
- h5saver: H5Saver
647
- extended_shape: Tuple[int]
648
- the extra shape compared to the data the h5array will have
649
-
650
- Attributes
651
- ----------
652
- data_type: DataType
653
- The enum for this type of data, here 'data'
654
- """
655
- data_type = DataType['data']
656
-
657
- def __init__(self, h5saver: H5Saver, extended_shape: Tuple[int]):
658
- super().__init__(h5saver)
659
- self.extended_shape = extended_shape
660
-
661
- def _create_data_arrays(self, where: Union[Node, str], data: DataWithAxes, save_axes=True,
662
- distribution=DataDistribution['uniform']):
663
- """ Create array with extra dimensions (from scan) to store data
664
-
665
- Parameters
666
- ----------
667
- where: Union[Node, str]
668
- the path of a given node or the node itself
669
- data: DataWithAxes
670
- save_axes: bool
671
-
672
- Notes
673
- -----
674
- Because data will be saved at a given index in the "scan" array, related axes will have their index
675
- increased by the length of the scan dim (1 for scan1D, 2 for scan2D, ...)
676
- """
677
- if self.get_last_node_name(where) is None:
678
- for ind_data in range(len(data)):
679
- nav_indexes = list(data.nav_indexes)
680
- nav_indexes = [ind for ind in range(len(self.extended_shape))] +\
681
- list(np.array(nav_indexes, dtype=int) + len(self.extended_shape))
682
-
683
- self._h5saver.add_array(where, self._get_next_node_name(where), self.data_type, title=data.name,
684
- data_shape=data[ind_data].shape,
685
- array_type=data[ind_data].dtype,
686
- scan_shape=self.extended_shape,
687
- add_scan_dim=True,
688
- data_dimension=data.dim.name,
689
- metadata=dict(timestamp=data.timestamp, label=data.labels[ind_data],
690
- source=data.source.name, distribution=distribution.name,
691
- origin=data.origin,
692
- nav_indexes=tuple(nav_indexes)))
693
-
694
- if save_axes:
695
- for axis in data.axes:
696
- axis.index += len(self.extended_shape)
697
- # because there will be len(self.extended_shape) extra navigation axes
698
- self._axis_saver.add_axis(where, axis)
699
-
700
- def add_data(self, where: Union[Node, str], data: DataWithAxes, indexes: List[int],
701
- distribution=DataDistribution['uniform']):
702
- """Adds given DataWithAxes at a location within the initialized h5 array
703
-
704
- Parameters
705
- ----------
706
- where: Union[Node, str]
707
- the path of a given node or the node itself
708
- data: DataWithAxes
709
- indexes: Iterable[int]
710
- indexes where to save data in the init h5array (should have the same length as extended_shape and with values
711
- coherent with this shape
712
- """
713
- if len(indexes) != len(self.extended_shape):
714
- raise IndexError(f'Cannot put data into the h5array with extended indexes {indexes}')
715
- for ind in range(len(indexes)):
716
- if indexes[ind] > self.extended_shape[ind]:
717
- raise IndexError(f'Indexes cannot be higher than the array shape')
718
-
719
- if self.get_last_node_name(where) is None:
720
- self._create_data_arrays(where, data, save_axes=True, distribution=distribution)
721
-
722
- for ind_data in range(len(data)):
723
- #todo check that getting with index is safe...
724
- array: CARRAY = self.get_node_from_index(where, ind_data)
725
- array[tuple(indexes)] = data[ind_data]
726
- # maybe use array.__setitem__(indexes, data[ind_data]) if it's not working
727
-
728
-
729
- class DataToExportSaver:
730
- """Object used to save DataToExport object into a h5file following the PyMoDAQ convention
731
-
732
- Parameters
733
- ----------
734
- h5saver: H5Saver
735
-
736
- """
737
- def __init__(self, h5saver: Union[H5Saver, Path, str]):
738
- if isinstance(h5saver, Path) or isinstance(h5saver, str):
739
- h5saver_tmp = H5Saver()
740
- h5saver_tmp.init_file(addhoc_file_path=Path(h5saver))
741
- h5saver = h5saver_tmp
742
-
743
- self._h5saver = h5saver
744
- self._data_saver = DataSaverLoader(h5saver)
745
- self._bkg_saver = BkgSaver(h5saver)
746
-
747
- def _get_node(self, where: Union[Node, str]) -> Node:
748
- return self._h5saver.get_node(where)
749
-
750
- def close(self):
751
- self._h5saver.close()
752
-
753
- def close_file(self):
754
- self._h5saver.close_file()
755
-
756
- def __enter__(self):
757
- return self
758
-
759
- def __exit__(self, exc_type, exc_val, exc_tb):
760
- self.close_file()
761
-
762
- def isopen(self) -> bool:
763
- """ Get the opened status of the underlying hdf5 file"""
764
- return self._h5saver.isopen()
765
-
766
- @staticmethod
767
- def channel_formatter(ind: int):
768
- """All DataWithAxes included in the DataToExport will be saved into a channel group indexed
769
- and formatted as below"""
770
- return f'CH{ind:02d}'
771
-
772
- def add_data(self, where: Union[Node, str], data: DataToExport, settings_as_xml='',
773
- metadata=None, **kwargs):
774
- """
775
-
776
- Parameters
777
- ----------
778
- where: Union[Node, str]
779
- the path of a given node or the node itself
780
- data: DataToExport
781
- settings_as_xml: str
782
- The settings parameter as an XML string
783
- metadata: dict
784
- all extra metadata to be saved in the group node where data will be saved
785
-
786
- """
787
- if metadata is None:
788
- metadata = {}
789
- dims = data.get_dim_presents()
790
- for dim in dims:
791
- dim_group = self._h5saver.get_set_group(where, dim)
792
- for ind, dwa in enumerate(data.get_data_from_dim(dim)):
793
- # dwa: DataWithAxes filtered by dim
794
- dwa_group = self._h5saver.get_set_group(dim_group, self.channel_formatter(ind),
795
- dwa.name)
796
- # dwa_group = self._h5saver.add_ch_group(dim_group, dwa.name)
797
- self._data_saver.add_data(dwa_group, dwa, **kwargs)
798
-
799
- def add_bkg(self, where: Union[Node, str], data: DataToExport):
800
- dims = data.get_dim_presents()
801
- for dim in dims:
802
- dim_group = self._h5saver.get_set_group(where, dim)
803
- for ind, dwa in enumerate(data.get_data_from_dim(dim)):
804
- # dwa: DataWithAxes filtered by dim
805
- dwa_group = self._h5saver.get_set_group(dim_group,
806
- self.channel_formatter(ind), dwa.name)
807
- # dwa_group = self._get_node_from_title(dim_group, dwa.name)
808
- if dwa_group is not None:
809
- self._bkg_saver.add_data(dwa_group, dwa, save_axes=False)
810
-
811
- def add_error(self, where: Union[Node, str], data: DataToExport):
812
- dims = data.get_dim_presents()
813
- for dim in dims:
814
- dim_group = self._h5saver.get_set_group(where, dim)
815
- for ind, dwa in enumerate(data.get_data_from_dim(dim)):
816
- # dwa: DataWithAxes filtered by dim
817
- dwa_group = self._h5saver.get_set_group(dim_group,
818
- self.channel_formatter(ind), dwa.name)
819
- # dwa_group = self._get_node_from_title(dim_group, dwa.name)
820
- if dwa_group is not None:
821
- self._bkg_saver.add_data(dwa_group, dwa, save_axes=False)
822
-
823
-
824
- class DataToExportEnlargeableSaver(DataToExportSaver):
825
- """Generic object to save DataToExport objects in an enlargeable h5 array
826
-
827
- The next enlarged value should be specified in the add_data method
828
-
829
- Parameters
830
- ----------
831
- h5saver: H5Saver
832
- enl_axis_names: Iterable[str]
833
- The names of the enlargeable axis, default ['nav_axis']
834
- enl_axis_units: Iterable[str]
835
- The names of the enlargeable axis, default ['']
836
- axis_name: str, deprecated use enl_axis_names
837
- the name of the enlarged axis array
838
- axis_units: str, deprecated use enl_axis_units
839
- the units of the enlarged axis array
840
- """
841
- def __init__(self, h5saver: H5Saver,
842
- enl_axis_names: Iterable[str] = None,
843
- enl_axis_units: Iterable[str] = None,
844
- axis_name: str = 'nav axis', axis_units: str = ''):
845
-
846
- super().__init__(h5saver)
847
- if enl_axis_names is None: # for backcompatibility
848
- enl_axis_names = (axis_name,)
849
- if enl_axis_units is None: # for backcompatibilitu
850
- enl_axis_units = (axis_units,)
851
-
852
- if len(enl_axis_names) != len(enl_axis_units):
853
- raise ValueError('Both enl_axis_names and enl_axis_units should have the same length')
854
-
855
- self._enl_axis_names = enl_axis_names
856
- self._enl_axis_units = enl_axis_units
857
- self._n_enl = len(enl_axis_names)
858
-
859
- self._data_saver = DataEnlargeableSaver(h5saver)
860
- self._nav_axis_saver = AxisSaverLoader(h5saver)
861
-
862
- def add_data(self, where: Union[Node, str], data: DataToExport,
863
- axis_values: List[Union[float, np.ndarray]] = None,
864
- axis_value: Union[float, np.ndarray] = None,
865
- settings_as_xml='', metadata=None,
866
- ):
867
- """
868
-
869
- Parameters
870
- ----------
871
- where: Union[Node, str]
872
- the path of a given node or the node itself
873
- data: DataToExport
874
- The data to be saved into an enlargeable array
875
- axis_values: iterable float or np.ndarray
876
- The next value (or values) of the enlarged axis
877
- axis_value: float or np.ndarray #deprecated in 4.2.0, use axis_values
878
- The next value (or values) of the enlarged axis
879
- settings_as_xml: str
880
- The settings parameter as an XML string
881
- metadata: dict
882
- all extra metadata to be saved in the group node where data will be saved
883
- """
884
-
885
- if axis_values is None and axis_value is not None:
886
- axis_values = [axis_value]
887
-
888
- super().add_data(where, data, settings_as_xml, metadata)
889
- # a parent navigation group (same for all data nodes)
890
-
891
- where = self._get_node(where)
892
- nav_group = self._h5saver.get_set_group(where, SPECIAL_GROUP_NAMES['nav_axes'])
893
- if self._nav_axis_saver.get_last_node_name(nav_group) is None:
894
- for ind in range(self._n_enl):
895
- axis = Axis(label=self._enl_axis_names[ind],
896
- units=self._enl_axis_units[ind], data=np.array([0., 1.]),
897
- index=0, spread_order=ind)
898
- axis_array = self._nav_axis_saver.add_axis(nav_group, axis, enlargeable=True)
899
- axis_array.attrs['size'] = 0
900
-
901
- for ind in range(self._n_enl):
902
- axis_array: EARRAY = self._nav_axis_saver.get_node_from_index(nav_group, ind)
903
- axis_array.append(squeeze(np.array([axis_values[ind]])),
904
- expand=False)
905
- axis_array.attrs['size'] += 1
906
-
907
-
908
- class DataToExportTimedSaver(DataToExportEnlargeableSaver):
909
- """Specialized DataToExportEnlargeableSaver to save data as a function of a time axis
910
-
911
- Only one element ca be added at a time, the time axis value are enlarged using the data to be
912
- added timestamp
913
-
914
- Notes
915
- -----
916
- This object is made for continuous saving mode of DAQViewer and logging to h5file for DAQLogger
917
- """
918
- def __init__(self, h5saver: H5Saver):
919
- super().__init__(h5saver, enl_axis_names=('time',), enl_axis_units=('s',))
920
-
921
- def add_data(self, where: Union[Node, str], data: DataToExport, settings_as_xml='',
922
- metadata=None, **kwargs):
923
- super().add_data(where, data, axis_values=[data.timestamp], settings_as_xml=settings_as_xml,
924
- metadata=metadata)
925
-
926
-
927
- class DataToExportExtendedSaver(DataToExportSaver):
928
- """Object to save DataToExport at given indexes within arrays including extended shape
929
-
930
- Mostly used for data generated from the DAQScan
931
-
932
- Parameters
933
- ----------
934
- h5saver: H5Saver
935
- extended_shape: Tuple[int]
936
- the extra shape compared to the data the h5array will have
937
- """
938
-
939
- def __init__(self, h5saver: H5Saver, extended_shape: Tuple[int]):
940
- super().__init__(h5saver)
941
- self._data_saver = DataExtendedSaver(h5saver, extended_shape)
942
- self._nav_axis_saver = AxisSaverLoader(h5saver)
943
-
944
- def add_nav_axes(self, where: Union[Node, str], axes: List[Axis]):
945
- """Used to add navigation axes related to the extended array
946
-
947
- Notes
948
- -----
949
- For instance the scan axes in the DAQScan
950
- """
951
- where = self._get_node(where)
952
- nav_group = self._h5saver.get_set_group(where, SPECIAL_GROUP_NAMES['nav_axes'])
953
- if self._nav_axis_saver.get_last_node_name(nav_group) is None:
954
- for axis in axes:
955
- self._nav_axis_saver.add_axis(nav_group, axis)
956
-
957
- def add_data(self, where: Union[Node, str], data: DataToExport, indexes: Iterable[int],
958
- distribution=DataDistribution['uniform'],
959
- settings_as_xml='', metadata={}):
960
- """
961
-
962
- Parameters
963
- ----------
964
- where: Union[Node, str]
965
- the path of a given node or the node itself
966
- data: DataToExport
967
- indexes: List[int]
968
- indexes where to save data in the init h5array (should have the same length as
969
- extended_shape and with values coherent with this shape
970
- settings_as_xml: str
971
- The settings parameter as an XML string
972
- metadata: dict
973
- all extra metadata to be saved in the group node where data will be saved
974
-
975
- """
976
- dims = data.get_dim_presents()
977
- for dim in dims:
978
- dim_group = self._h5saver.get_set_group(where, dim)
979
- for ind, dwa in enumerate(data.get_data_from_dim(dim)):
980
- # dwa: DataWithAxes filtered by dim
981
- dwa_group = self._h5saver.get_set_group(dim_group,
982
- self.channel_formatter(ind), dwa.name)
983
- self._data_saver.add_data(dwa_group, dwa, indexes=indexes,
984
- distribution=distribution)
985
-
986
-
987
- class DataLoader:
988
- """Specialized Object to load DataWithAxes object from a h5file
989
-
990
- On the contrary to DataSaverLoader, does include navigation axes stored elsewhere in the h5file
991
- (for instance if saved from the DAQ_Scan)
992
-
993
- Parameters
994
- ----------
995
- h5saver: H5Saver
996
- """
997
-
998
- def __init__(self, h5saver: Union[H5Saver, Path]):
999
- self._axis_loader: AxisSaverLoader = None
1000
- self._data_loader: DataSaverLoader = None
1001
-
1002
- if isinstance(h5saver, Path) or isinstance(h5saver, str):
1003
- h5saver_tmp = H5Saver()
1004
- h5saver_tmp.init_file(addhoc_file_path=Path(h5saver))
1005
- h5saver = h5saver_tmp
1006
-
1007
- self.h5saver = h5saver
1008
-
1009
- @property
1010
- def h5saver(self):
1011
- return self._h5saver
1012
-
1013
- def __enter__(self):
1014
- return self
1015
-
1016
- def __exit__(self, exc_type, exc_val, exc_tb):
1017
- self.close_file()
1018
-
1019
- def close_file(self):
1020
- self._h5saver.close_file()
1021
-
1022
- def walk_nodes(self, where: Union[str, Node] = '/'):
1023
- """Return a Node generator iterating over the h5file content"""
1024
- return self.h5saver.walk_nodes(where)
1025
-
1026
- @h5saver.setter
1027
- def h5saver(self, h5saver: H5Saver):
1028
- self._h5saver = h5saver
1029
- self._axis_loader = AxisSaverLoader(h5saver)
1030
- self._data_loader = DataSaverLoader(h5saver)
1031
-
1032
- def get_node(self, where: Union[Node, str], name: str = None) -> Node:
1033
- """ Convenience method to get node"""
1034
- return self.h5saver.get_node(where, name)
1035
-
1036
- def get_nav_group(self, where: Union[Node, str]) -> Union[Node, None]:
1037
- """
1038
-
1039
- Parameters
1040
- ----------
1041
- where: Union[Node, str]
1042
- the path of a given node or the node itself
1043
-
1044
- Returns
1045
- -------
1046
- GROUP: returns the group named SPECIAL_GROUP_NAMES['nav_axes'] holding all NavAxis for
1047
- those data
1048
-
1049
- See Also
1050
- --------
1051
- SPECIAL_GROUP_NAMES
1052
- """
1053
- node = self._h5saver.get_node(where)
1054
- while node is not None: # means we reached the root level
1055
- if isinstance(node, GROUP):
1056
- if self._h5saver.is_node_in_group(node, SPECIAL_GROUP_NAMES['nav_axes']):
1057
- return self._h5saver.get_node(node, SPECIAL_GROUP_NAMES['nav_axes'])
1058
- node = node.parent_node
1059
-
1060
- def load_data(self, where: Union[Node, str], with_bkg=False, load_all=False) -> DataWithAxes:
1061
- """Load data from a node (or channel node)
1062
-
1063
- Loaded data contains also nav_axes if any and with optional background subtraction
1064
-
1065
- Parameters
1066
- ----------
1067
- where: Union[Node, str]
1068
- the path of a given node or the node itself
1069
- with_bkg: bool
1070
- If True will attempt to substract a background data node before loading
1071
- load_all: bool
1072
- If True, will load all data hanging from the same parent node
1073
-
1074
- Returns
1075
- -------
1076
-
1077
- """
1078
- node_data_type = DataType[self._h5saver.get_node(where).attrs['data_type']]
1079
- self._data_loader.data_type = node_data_type
1080
- data = self._data_loader.load_data(where, with_bkg=with_bkg, load_all=load_all)
1081
- if 'axis' not in node_data_type.name:
1082
- nav_group = self.get_nav_group(where)
1083
- if nav_group is not None:
1084
- nav_axes = self._axis_loader.get_axes(nav_group)
1085
- axes = data.axes[:]
1086
- axes.extend(nav_axes)
1087
- data.axes = axes
1088
- data.get_dim_from_data_axes()
1089
- data.create_missing_axes()
1090
- return data
1091
-
1092
- def load_all(self, where: GROUP, data: DataToExport, with_bkg=False) -> DataToExport:
1093
-
1094
- where = self._h5saver.get_node(where)
1095
- children_dict = where.children()
1096
- data_list = []
1097
- for child in children_dict:
1098
- if isinstance(children_dict[child], GROUP):
1099
- self.load_all(children_dict[child], data, with_bkg=with_bkg)
1100
- elif ('data_type' in children_dict[child].attrs and 'data' in
1101
- children_dict[child].attrs['data_type']):
1102
-
1103
- data_list.append(self.load_data(children_dict[child].path,
1104
- with_bkg=with_bkg, load_all=True))
1105
- break
1106
- data_tmp = DataToExport(name=where.name, data=data_list)
1107
- data.append(data_tmp)