PaIRS-UniNa 0.2.5__cp313-cp313-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (323) hide show
  1. PaIRS_UniNa/Calibration_Tab.py +331 -0
  2. PaIRS_UniNa/Changes.txt +110 -0
  3. PaIRS_UniNa/Custom_Top.py +303 -0
  4. PaIRS_UniNa/Explorer.py +3069 -0
  5. PaIRS_UniNa/FolderLoop.py +372 -0
  6. PaIRS_UniNa/Input_Tab.py +719 -0
  7. PaIRS_UniNa/Input_Tab_CalVi.py +788 -0
  8. PaIRS_UniNa/Input_Tab_tools.py +3023 -0
  9. PaIRS_UniNa/Log_Tab.py +110 -0
  10. PaIRS_UniNa/Output_Tab.py +924 -0
  11. PaIRS_UniNa/PaIRS.py +18 -0
  12. PaIRS_UniNa/PaIRS_PIV.py +873 -0
  13. PaIRS_UniNa/PaIRS_pypacks.py +1250 -0
  14. PaIRS_UniNa/Process_Tab.py +1757 -0
  15. PaIRS_UniNa/Process_Tab_CalVi.py +313 -0
  16. PaIRS_UniNa/Process_Tab_Disp.py +163 -0
  17. PaIRS_UniNa/Process_Tab_Min.py +120 -0
  18. PaIRS_UniNa/ResizePopup.py +55 -0
  19. PaIRS_UniNa/Saving_tools.py +296 -0
  20. PaIRS_UniNa/TabTools.py +1251 -0
  21. PaIRS_UniNa/Vis_Tab.py +2100 -0
  22. PaIRS_UniNa/Vis_Tab_CalVi.py +983 -0
  23. PaIRS_UniNa/Whatsnew.py +118 -0
  24. PaIRS_UniNa/_PaIRS_PIV.pyd +0 -0
  25. PaIRS_UniNa/__init__.py +6 -0
  26. PaIRS_UniNa/__main__.py +45 -0
  27. PaIRS_UniNa/addwidgets_ps.py +1125 -0
  28. PaIRS_UniNa/calib.py +1488 -0
  29. PaIRS_UniNa/calibView.py +826 -0
  30. PaIRS_UniNa/gPaIRS.py +3769 -0
  31. PaIRS_UniNa/gPalette.py +189 -0
  32. PaIRS_UniNa/icons/abort.png +0 -0
  33. PaIRS_UniNa/icons/about.png +0 -0
  34. PaIRS_UniNa/icons/align_all.png +0 -0
  35. PaIRS_UniNa/icons/announcement.png +0 -0
  36. PaIRS_UniNa/icons/automatic_levels_off.png +0 -0
  37. PaIRS_UniNa/icons/automatic_levels_on.png +0 -0
  38. PaIRS_UniNa/icons/automatic_off.png +0 -0
  39. PaIRS_UniNa/icons/automatic_on.png +0 -0
  40. PaIRS_UniNa/icons/automatic_size_off.png +0 -0
  41. PaIRS_UniNa/icons/automatic_size_on.png +0 -0
  42. PaIRS_UniNa/icons/axes.png +0 -0
  43. PaIRS_UniNa/icons/background.png +0 -0
  44. PaIRS_UniNa/icons/background_vectors.png +0 -0
  45. PaIRS_UniNa/icons/bin_off.png +0 -0
  46. PaIRS_UniNa/icons/bin_on.png +0 -0
  47. PaIRS_UniNa/icons/browse_file_c.png +0 -0
  48. PaIRS_UniNa/icons/browse_folder_c.png +0 -0
  49. PaIRS_UniNa/icons/brush_cursor.png +0 -0
  50. PaIRS_UniNa/icons/bugfix.png +0 -0
  51. PaIRS_UniNa/icons/cal_proc.png +0 -0
  52. PaIRS_UniNa/icons/cal_proc_off.png +0 -0
  53. PaIRS_UniNa/icons/cal_step.png +0 -0
  54. PaIRS_UniNa/icons/cal_step_off.png +0 -0
  55. PaIRS_UniNa/icons/calibrate.png +0 -0
  56. PaIRS_UniNa/icons/calibration_logo.png +0 -0
  57. PaIRS_UniNa/icons/change_folder.png +0 -0
  58. PaIRS_UniNa/icons/change_folder_off.png +0 -0
  59. PaIRS_UniNa/icons/checklist.png +0 -0
  60. PaIRS_UniNa/icons/clean.png +0 -0
  61. PaIRS_UniNa/icons/clean_run.png +0 -0
  62. PaIRS_UniNa/icons/close.png +0 -0
  63. PaIRS_UniNa/icons/close_all.png +0 -0
  64. PaIRS_UniNa/icons/close_project.png +0 -0
  65. PaIRS_UniNa/icons/close_workspace.png +0 -0
  66. PaIRS_UniNa/icons/colormap.png +0 -0
  67. PaIRS_UniNa/icons/colormaps/Accent.png +0 -0
  68. PaIRS_UniNa/icons/colormaps/BrBG.png +0 -0
  69. PaIRS_UniNa/icons/colormaps/Dark2.png +0 -0
  70. PaIRS_UniNa/icons/colormaps/PRGn.png +0 -0
  71. PaIRS_UniNa/icons/colormaps/Paired.png +0 -0
  72. PaIRS_UniNa/icons/colormaps/Pastel1.png +0 -0
  73. PaIRS_UniNa/icons/colormaps/Pastel2.png +0 -0
  74. PaIRS_UniNa/icons/colormaps/PiYG.png +0 -0
  75. PaIRS_UniNa/icons/colormaps/PuOr.png +0 -0
  76. PaIRS_UniNa/icons/colormaps/RdBu.png +0 -0
  77. PaIRS_UniNa/icons/colormaps/RdGy.png +0 -0
  78. PaIRS_UniNa/icons/colormaps/RdYlBu.png +0 -0
  79. PaIRS_UniNa/icons/colormaps/RdYlGn.png +0 -0
  80. PaIRS_UniNa/icons/colormaps/Set1.png +0 -0
  81. PaIRS_UniNa/icons/colormaps/Set2.png +0 -0
  82. PaIRS_UniNa/icons/colormaps/Set3.png +0 -0
  83. PaIRS_UniNa/icons/colormaps/Spectral.png +0 -0
  84. PaIRS_UniNa/icons/colormaps/Wistia.png +0 -0
  85. PaIRS_UniNa/icons/colormaps/afmhot.png +0 -0
  86. PaIRS_UniNa/icons/colormaps/autumn.png +0 -0
  87. PaIRS_UniNa/icons/colormaps/binary.png +0 -0
  88. PaIRS_UniNa/icons/colormaps/blackVector.png +0 -0
  89. PaIRS_UniNa/icons/colormaps/blueVector.png +0 -0
  90. PaIRS_UniNa/icons/colormaps/bone.png +0 -0
  91. PaIRS_UniNa/icons/colormaps/brg.png +0 -0
  92. PaIRS_UniNa/icons/colormaps/bwr.png +0 -0
  93. PaIRS_UniNa/icons/colormaps/cividis.png +0 -0
  94. PaIRS_UniNa/icons/colormaps/cool.png +0 -0
  95. PaIRS_UniNa/icons/colormaps/coolwarm.png +0 -0
  96. PaIRS_UniNa/icons/colormaps/copper.png +0 -0
  97. PaIRS_UniNa/icons/colormaps/cubehelix.png +0 -0
  98. PaIRS_UniNa/icons/colormaps/cyanVector.png +0 -0
  99. PaIRS_UniNa/icons/colormaps/flag.png +0 -0
  100. PaIRS_UniNa/icons/colormaps/gist_heat.png +0 -0
  101. PaIRS_UniNa/icons/colormaps/gray.png +0 -0
  102. PaIRS_UniNa/icons/colormaps/greenVector.png +0 -0
  103. PaIRS_UniNa/icons/colormaps/hot.png +0 -0
  104. PaIRS_UniNa/icons/colormaps/hsv.png +0 -0
  105. PaIRS_UniNa/icons/colormaps/inferno.png +0 -0
  106. PaIRS_UniNa/icons/colormaps/jet.png +0 -0
  107. PaIRS_UniNa/icons/colormaps/magentaVector.png +0 -0
  108. PaIRS_UniNa/icons/colormaps/magma.png +0 -0
  109. PaIRS_UniNa/icons/colormaps/ocean.png +0 -0
  110. PaIRS_UniNa/icons/colormaps/pink.png +0 -0
  111. PaIRS_UniNa/icons/colormaps/plasma.png +0 -0
  112. PaIRS_UniNa/icons/colormaps/prism.png +0 -0
  113. PaIRS_UniNa/icons/colormaps/rainbow.png +0 -0
  114. PaIRS_UniNa/icons/colormaps/redVector.png +0 -0
  115. PaIRS_UniNa/icons/colormaps/seismic.png +0 -0
  116. PaIRS_UniNa/icons/colormaps/spring.png +0 -0
  117. PaIRS_UniNa/icons/colormaps/summer.png +0 -0
  118. PaIRS_UniNa/icons/colormaps/tab10.png +0 -0
  119. PaIRS_UniNa/icons/colormaps/tab20.png +0 -0
  120. PaIRS_UniNa/icons/colormaps/tab20b.png +0 -0
  121. PaIRS_UniNa/icons/colormaps/tab20c.png +0 -0
  122. PaIRS_UniNa/icons/colormaps/terrain.png +0 -0
  123. PaIRS_UniNa/icons/colormaps/twilight.png +0 -0
  124. PaIRS_UniNa/icons/colormaps/viridis.png +0 -0
  125. PaIRS_UniNa/icons/colormaps/whiteVector.png +0 -0
  126. PaIRS_UniNa/icons/colormaps/winter.png +0 -0
  127. PaIRS_UniNa/icons/colormaps/yellowVector.png +0 -0
  128. PaIRS_UniNa/icons/common_region.png +0 -0
  129. PaIRS_UniNa/icons/common_region_off.png +0 -0
  130. PaIRS_UniNa/icons/completed.png +0 -0
  131. PaIRS_UniNa/icons/contourf_off.png +0 -0
  132. PaIRS_UniNa/icons/contourf_on.png +0 -0
  133. PaIRS_UniNa/icons/copy.png +0 -0
  134. PaIRS_UniNa/icons/copy_process.png +0 -0
  135. PaIRS_UniNa/icons/copy_process_off.png +0 -0
  136. PaIRS_UniNa/icons/copygrid.png +0 -0
  137. PaIRS_UniNa/icons/cursor_lamp.png +0 -0
  138. PaIRS_UniNa/icons/cut.png +0 -0
  139. PaIRS_UniNa/icons/cut_warnings.png +0 -0
  140. PaIRS_UniNa/icons/darkmode.png +0 -0
  141. PaIRS_UniNa/icons/debug_run.png +0 -0
  142. PaIRS_UniNa/icons/delete.png +0 -0
  143. PaIRS_UniNa/icons/deleteErr.png +0 -0
  144. PaIRS_UniNa/icons/disp_step.png +0 -0
  145. PaIRS_UniNa/icons/disp_step_off.png +0 -0
  146. PaIRS_UniNa/icons/down.png +0 -0
  147. PaIRS_UniNa/icons/edit_list.png +0 -0
  148. PaIRS_UniNa/icons/editing.png +0 -0
  149. PaIRS_UniNa/icons/example_list.png +0 -0
  150. PaIRS_UniNa/icons/find_all_planes.png +0 -0
  151. PaIRS_UniNa/icons/find_plane.png +0 -0
  152. PaIRS_UniNa/icons/flaticon_PaIRS.png +0 -0
  153. PaIRS_UniNa/icons/flaticon_PaIRS_beta.png +0 -0
  154. PaIRS_UniNa/icons/flaticon_PaIRS_download.png +0 -0
  155. PaIRS_UniNa/icons/flip_y_off.png +0 -0
  156. PaIRS_UniNa/icons/flip_y_on.png +0 -0
  157. PaIRS_UniNa/icons/focusErrr.png +0 -0
  158. PaIRS_UniNa/icons/gear.gif +0 -0
  159. PaIRS_UniNa/icons/gear.png +0 -0
  160. PaIRS_UniNa/icons/ger.png +0 -0
  161. PaIRS_UniNa/icons/greenv.png +0 -0
  162. PaIRS_UniNa/icons/guide.png +0 -0
  163. PaIRS_UniNa/icons/icon_CalVi.png +0 -0
  164. PaIRS_UniNa/icons/icon_PaIRS.png +0 -0
  165. PaIRS_UniNa/icons/import.png +0 -0
  166. PaIRS_UniNa/icons/import_set.png +0 -0
  167. PaIRS_UniNa/icons/information.png +0 -0
  168. PaIRS_UniNa/icons/input_logo.png +0 -0
  169. PaIRS_UniNa/icons/issue.png +0 -0
  170. PaIRS_UniNa/icons/laser_NTR.png +0 -0
  171. PaIRS_UniNa/icons/laser_TR_double.png +0 -0
  172. PaIRS_UniNa/icons/laser_TR_single.png +0 -0
  173. PaIRS_UniNa/icons/link.png +0 -0
  174. PaIRS_UniNa/icons/linked.png +0 -0
  175. PaIRS_UniNa/icons/loaded.png +0 -0
  176. PaIRS_UniNa/icons/loading_2.gif +0 -0
  177. PaIRS_UniNa/icons/log_logo.png +0 -0
  178. PaIRS_UniNa/icons/logo_CalVi.png +0 -0
  179. PaIRS_UniNa/icons/logo_CalVi_completo.png +0 -0
  180. PaIRS_UniNa/icons/logo_CalVi_party.png +0 -0
  181. PaIRS_UniNa/icons/logo_PaIRS.png +0 -0
  182. PaIRS_UniNa/icons/logo_PaIRS_completo.png +0 -0
  183. PaIRS_UniNa/icons/logo_PaIRS_download.png +0 -0
  184. PaIRS_UniNa/icons/logo_PaIRS_party_rect.png +0 -0
  185. PaIRS_UniNa/icons/logo_PaIRS_rect.png +0 -0
  186. PaIRS_UniNa/icons/logo_opaco.png +0 -0
  187. PaIRS_UniNa/icons/mask.png +0 -0
  188. PaIRS_UniNa/icons/measure.png +0 -0
  189. PaIRS_UniNa/icons/measure_off.png +0 -0
  190. PaIRS_UniNa/icons/min_proc.png +0 -0
  191. PaIRS_UniNa/icons/min_proc_off.png +0 -0
  192. PaIRS_UniNa/icons/min_step.png +0 -0
  193. PaIRS_UniNa/icons/min_step_off.png +0 -0
  194. PaIRS_UniNa/icons/minus.png +0 -0
  195. PaIRS_UniNa/icons/mirror_u.png +0 -0
  196. PaIRS_UniNa/icons/mirror_v.png +0 -0
  197. PaIRS_UniNa/icons/mirror_x.png +0 -0
  198. PaIRS_UniNa/icons/mirror_y.png +0 -0
  199. PaIRS_UniNa/icons/mtplt.png +0 -0
  200. PaIRS_UniNa/icons/new.png +0 -0
  201. PaIRS_UniNa/icons/new_workspace.png +0 -0
  202. PaIRS_UniNa/icons/news.png +0 -0
  203. PaIRS_UniNa/icons/normal_run.png +0 -0
  204. PaIRS_UniNa/icons/open.png +0 -0
  205. PaIRS_UniNa/icons/open_image.png +0 -0
  206. PaIRS_UniNa/icons/open_new_window.png +0 -0
  207. PaIRS_UniNa/icons/open_result.png +0 -0
  208. PaIRS_UniNa/icons/open_workspace.png +0 -0
  209. PaIRS_UniNa/icons/output_logo.png +0 -0
  210. PaIRS_UniNa/icons/paste_above.png +0 -0
  211. PaIRS_UniNa/icons/paste_below.png +0 -0
  212. PaIRS_UniNa/icons/pause.png +0 -0
  213. PaIRS_UniNa/icons/paused.png +0 -0
  214. PaIRS_UniNa/icons/piv_proc.png +0 -0
  215. PaIRS_UniNa/icons/piv_proc_off.png +0 -0
  216. PaIRS_UniNa/icons/piv_step.png +0 -0
  217. PaIRS_UniNa/icons/piv_step_off.png +0 -0
  218. PaIRS_UniNa/icons/plane.png +0 -0
  219. PaIRS_UniNa/icons/play.png +0 -0
  220. PaIRS_UniNa/icons/plus.png +0 -0
  221. PaIRS_UniNa/icons/process_logo.png +0 -0
  222. PaIRS_UniNa/icons/process_loop.png +0 -0
  223. PaIRS_UniNa/icons/project.png +0 -0
  224. PaIRS_UniNa/icons/pylog.png +0 -0
  225. PaIRS_UniNa/icons/python_warning.png +0 -0
  226. PaIRS_UniNa/icons/queue.png +0 -0
  227. PaIRS_UniNa/icons/quit.png +0 -0
  228. PaIRS_UniNa/icons/read.png +0 -0
  229. PaIRS_UniNa/icons/read_list.png +0 -0
  230. PaIRS_UniNa/icons/redo.png +0 -0
  231. PaIRS_UniNa/icons/redx.png +0 -0
  232. PaIRS_UniNa/icons/reset.png +0 -0
  233. PaIRS_UniNa/icons/reset_levels.png +0 -0
  234. PaIRS_UniNa/icons/resize_icon.png +0 -0
  235. PaIRS_UniNa/icons/restore.png +0 -0
  236. PaIRS_UniNa/icons/restore_undo.png +0 -0
  237. PaIRS_UniNa/icons/rotate_clock.png +0 -0
  238. PaIRS_UniNa/icons/rotate_counter.png +0 -0
  239. PaIRS_UniNa/icons/rotate_v_clock.png +0 -0
  240. PaIRS_UniNa/icons/rotate_v_counter.png +0 -0
  241. PaIRS_UniNa/icons/running.gif +0 -0
  242. PaIRS_UniNa/icons/running.png +0 -0
  243. PaIRS_UniNa/icons/running_warn.png +0 -0
  244. PaIRS_UniNa/icons/sandglass.png +0 -0
  245. PaIRS_UniNa/icons/save.png +0 -0
  246. PaIRS_UniNa/icons/save_and_stop.png +0 -0
  247. PaIRS_UniNa/icons/save_cfg.png +0 -0
  248. PaIRS_UniNa/icons/saveas.png +0 -0
  249. PaIRS_UniNa/icons/saveas_workspace.png +0 -0
  250. PaIRS_UniNa/icons/scale_all.png +0 -0
  251. PaIRS_UniNa/icons/scale_down.png +0 -0
  252. PaIRS_UniNa/icons/scale_up.png +0 -0
  253. PaIRS_UniNa/icons/scan_list.png +0 -0
  254. PaIRS_UniNa/icons/scan_path.png +0 -0
  255. PaIRS_UniNa/icons/search.png +0 -0
  256. PaIRS_UniNa/icons/showIW_off.png +0 -0
  257. PaIRS_UniNa/icons/showIW_on.png +0 -0
  258. PaIRS_UniNa/icons/show_all.png +0 -0
  259. PaIRS_UniNa/icons/sort.png +0 -0
  260. PaIRS_UniNa/icons/sort_reversed.png +0 -0
  261. PaIRS_UniNa/icons/spiv_proc.png +0 -0
  262. PaIRS_UniNa/icons/spiv_proc_off.png +0 -0
  263. PaIRS_UniNa/icons/star.png +0 -0
  264. PaIRS_UniNa/icons/step_inheritance.png +0 -0
  265. PaIRS_UniNa/icons/subMIN_off.png +0 -0
  266. PaIRS_UniNa/icons/subMIN_on.png +0 -0
  267. PaIRS_UniNa/icons/tom.png +0 -0
  268. PaIRS_UniNa/icons/trash.png +0 -0
  269. PaIRS_UniNa/icons/undo.png +0 -0
  270. PaIRS_UniNa/icons/unedited.png +0 -0
  271. PaIRS_UniNa/icons/unina_dii.png +0 -0
  272. PaIRS_UniNa/icons/uninitialized.png +0 -0
  273. PaIRS_UniNa/icons/unlink.png +0 -0
  274. PaIRS_UniNa/icons/unwrap_items.png +0 -0
  275. PaIRS_UniNa/icons/up.png +0 -0
  276. PaIRS_UniNa/icons/updating_import.gif +0 -0
  277. PaIRS_UniNa/icons/updating_pairs.gif +0 -0
  278. PaIRS_UniNa/icons/vectorColor.png +0 -0
  279. PaIRS_UniNa/icons/vettore.png +0 -0
  280. PaIRS_UniNa/icons/view.png +0 -0
  281. PaIRS_UniNa/icons/view_off.png +0 -0
  282. PaIRS_UniNa/icons/vis_logo.png +0 -0
  283. PaIRS_UniNa/icons/waiting_circle.png +0 -0
  284. PaIRS_UniNa/icons/warning.png +0 -0
  285. PaIRS_UniNa/icons/warning_circle.png +0 -0
  286. PaIRS_UniNa/icons/window.png +0 -0
  287. PaIRS_UniNa/icons/workspace.png +0 -0
  288. PaIRS_UniNa/icons/wrap_items.png +0 -0
  289. PaIRS_UniNa/icons/write_list.png +0 -0
  290. PaIRS_UniNa/listLib.py +303 -0
  291. PaIRS_UniNa/mtfPIV.py +256 -0
  292. PaIRS_UniNa/parForMulti.py +435 -0
  293. PaIRS_UniNa/parForWorkers.py +593 -0
  294. PaIRS_UniNa/pivParFor.py +235 -0
  295. PaIRS_UniNa/plt_util.py +141 -0
  296. PaIRS_UniNa/preProcParFor.py +155 -0
  297. PaIRS_UniNa/procTools.py +1391 -0
  298. PaIRS_UniNa/readcfg.py +52 -0
  299. PaIRS_UniNa/rqrdpckgs.txt +8 -0
  300. PaIRS_UniNa/stereoPivParFor.py +227 -0
  301. PaIRS_UniNa/tAVarie.py +215 -0
  302. PaIRS_UniNa/tabSplitter.py +612 -0
  303. PaIRS_UniNa/ui_Calibration_Tab.py +545 -0
  304. PaIRS_UniNa/ui_Custom_Top.py +296 -0
  305. PaIRS_UniNa/ui_Input_Tab.py +1101 -0
  306. PaIRS_UniNa/ui_Input_Tab_CalVi.py +1283 -0
  307. PaIRS_UniNa/ui_Log_Tab.py +263 -0
  308. PaIRS_UniNa/ui_Output_Tab.py +2362 -0
  309. PaIRS_UniNa/ui_Process_Tab.py +3810 -0
  310. PaIRS_UniNa/ui_Process_Tab_CalVi.py +1549 -0
  311. PaIRS_UniNa/ui_Process_Tab_Disp.py +1141 -0
  312. PaIRS_UniNa/ui_Process_Tab_Min.py +437 -0
  313. PaIRS_UniNa/ui_ResizePopup.py +204 -0
  314. PaIRS_UniNa/ui_Vis_Tab.py +1628 -0
  315. PaIRS_UniNa/ui_Vis_Tab_CalVi.py +1251 -0
  316. PaIRS_UniNa/ui_Whatsnew.py +132 -0
  317. PaIRS_UniNa/ui_gPairs.py +871 -0
  318. PaIRS_UniNa/ui_infoPaIRS.py +551 -0
  319. PaIRS_UniNa/whatsnew.txt +6 -0
  320. pairs_unina-0.2.5.dist-info/METADATA +151 -0
  321. pairs_unina-0.2.5.dist-info/RECORD +323 -0
  322. pairs_unina-0.2.5.dist-info/WHEEL +5 -0
  323. pairs_unina-0.2.5.dist-info/top_level.txt +2 -0
@@ -0,0 +1,1391 @@
1
+ ''' 2d PIV helper function for parfor '''
2
+ from datetime import timedelta
3
+ import os.path
4
+
5
+ # In hex is easy 0606 both read and processed 01234156789abcdef
6
+ FLAG_READ_ERR = [1, 1<<8] #2, 256= 0001 1 0001 0000 0000
7
+ FLAG_READ = [2 ,1<<9] #1<<9=2**9=512 0010 2
8
+ FLAG_PROC = [1<<2 ,1<<10] #8 ,1024 0100 4
9
+ FLAG_FINALIZED = [1<<3 ,1<<11] #completely processed 1000 8
10
+ # In hex is easy 0E0E both read, processed and finalized
11
+ FLAG_CALLBACK_INTERNAL = 1<<16 #on if the callback has been called in its internal parts
12
+ FLAG_GENERIC_ERROR = 1<<17 #on if the callback has been called in its internal parts
13
+ FLAG_PROC_AB =FLAG_PROC[0]|FLAG_PROC[1] #4+1024=1028=x404 se si somma anche FLAG_READ 6+1536=1542=x606
14
+ FLAG_FINALIZED_AB =FLAG_FINALIZED[0]|FLAG_FINALIZED[1]
15
+ FLAG_PROC_OR_ERR=[ p|e for (p,e) in zip(FLAG_PROC,FLAG_READ_ERR)]
16
+ FLAG_FINALIZED_OR_ERR = [ p|e for (p,e) in zip(FLAG_FINALIZED,FLAG_READ_ERR)]
17
+ # usare con
18
+ # supponendo che k sia 0 (img a) o 1 (img b)
19
+ # if pim(i)&FLAG_PROC[k]: allora img i, k processata
20
+ # per annullare un bit f=f& (~FLAG_CALLBACK)
21
+
22
+ from .PaIRS_pypacks import*
23
+ from .Input_Tab import INPpar as INPpar
24
+ from .Output_Tab import OUTpar as OUTpar
25
+ from .Output_Tab import outType_dict
26
+ from .Process_Tab import PROpar as PROpar
27
+ from .Process_Tab_Min import PROpar_Min as PROpar_Min
28
+ from .Process_Tab_Disp import PROpar_Disp as PROpar_Disp
29
+ from .Vis_Tab import VISpar as VISpar
30
+ from .Vis_Tab import NamesPIV
31
+ from .TabTools import TABpar
32
+ from .readcfg import readCalFile
33
+ from .__init__ import __version__,__subversion__,__year__
34
+
35
+ processData = {
36
+ ProcessTypes.min: {'name': 'Pre-process', 'caption': 'Pre-process analysis of a set of images aimed at computing historical minimum background',
37
+ 'class': 0, 'icon': 'min_proc.png',
38
+ 'children': {StepTypes.min:True}, 'mandatory': [StepTypes.min]},
39
+ ProcessTypes.piv: {'name': 'PIV process', 'caption': 'Particle Image Velocimetry analysis for computation of the two-dimensional two-component velocity field',
40
+ 'class': 0, 'icon': 'piv_proc.png',
41
+ 'children': {StepTypes.min:False,StepTypes.piv:True}, 'mandatory': [StepTypes.piv]},
42
+ ProcessTypes.cal: {'name': 'Calibration', 'caption': 'Accurate optical calibration of single and multiple camera bundles',
43
+ 'class': 0, 'icon': 'cal_proc.png',
44
+ 'children': {StepTypes.cal:True}, 'mandatory': [StepTypes.cal]},
45
+ ProcessTypes.spiv: {'name': 'Stereo-PIV process', 'caption': 'Stereoscopic Particle Image Velocimetry analysis for computation of the two-dimensional three-component velocity field',
46
+ 'class': 0, 'icon': 'spiv_proc.png',
47
+ 'children': {StepTypes.cal:True,StepTypes.min:False,StepTypes.disp:True,StepTypes.spiv:True},'mandatory': [StepTypes.cal]},
48
+ }
49
+ for p in processData:
50
+ processData[p]['type']=p
51
+
52
+ stepData= {
53
+ StepTypes.cal: {'name': 'Camera calibration', 'caption': 'Select an appropriate camera model and estimate the parameters of the mapping functions based on calibration target images',
54
+ 'class': 1, 'icon': 'cal_step.png', 'parents': [],
55
+ 'tabs': ['Calibration','Input_CalVi','Process_CalVi','Vis_CalVi'], },
56
+ StepTypes.min: {'name': 'Image pre-processing', 'caption': 'Select a set of particle images and compute the historical minimum background for subsets corresponding to the same laser light source',
57
+ 'class': 1, 'icon': 'min_step.png', 'parents': [],
58
+ 'tabs': ['Input','Output','Process_Min','Log','Vis'], },
59
+ StepTypes.piv: {'name': 'PIV analysis', 'caption': 'Select a set of particle images, craft a custom iterative multi-grid method and compute the two-dimensional two-component displacement field',
60
+ 'class': 1, 'icon': 'piv_step.png', 'parents': [],
61
+ 'tabs': ['Input','Output','Process','Log','Vis'], },
62
+ StepTypes.disp: {'name': 'Disparity correction', 'caption': 'Select a a set of particle images and compute the laser sheet position and orientation to adjust the camera disparities in the stereo-setup',
63
+ 'class': 1, 'icon': 'disp_step.png', 'parents': [StepTypes.cal],
64
+ 'tabs': ['Input','Output','Process_Disp','Log','Vis'], },
65
+ StepTypes.spiv: {'name': 'Stereoscopic PIV analysis', 'caption': 'Select a set of particle images, craft a custom iterative multi-grid method and compute the two-dimensional three-component displacement field',
66
+ 'class': 1, 'icon': 'piv_step.png', 'parents': [StepTypes.cal,StepTypes.disp],
67
+ 'tabs': ['Input','Output','Process','Log','Vis'], },
68
+ }
69
+ for p in stepData:
70
+ stepData[p]['type']=p
71
+
72
+ class dataTreePar(TABpar):
73
+ def __init__(self,Process=ProcessTypes.null,Step=StepTypes.null):
74
+ self.setup(Process,Step)
75
+ super().__init__('dataTreePar','ITEpar')
76
+
77
+ self.setCompleteLog()
78
+
79
+ self.surname='itemTreePar.gPaIRS'
80
+ self.unchecked_fields+=['name_fields']
81
+ self.uncopied_fields+=['ind']
82
+
83
+ def setup(self,Process,Step):
84
+ #typeProc, names, icon, log: item fields
85
+ self.Process=Process
86
+ self.Step=Step
87
+ self.namesPIV=NamesPIV(Step)
88
+
89
+ if Step:
90
+ self.itemname=stepData[Step]['name']
91
+ else:
92
+ self.itemname=''
93
+ self.filename_proc = ''
94
+ self.name_proc = ''
95
+
96
+ self.Log=''
97
+ self.procLog=['','',''] #LogProc, LogStat, LogErr
98
+ self.FlagErr=False
99
+ self.warnings=['',''] #warnings once completed the process, warnings related to current state
100
+
101
+ self.item_fields=[f for f,_ in self.__dict__.items()]+['ind']
102
+
103
+ #common data
104
+ self.inpPath=''
105
+ self.outPath=''
106
+ self.outPathRoot=''
107
+ self.ndig=-1
108
+ self.outExt=''
109
+ self.compMin:CompMin=CompMin()
110
+ self.mediaPIV:MediaPIV=MediaPIV(stepType=Step)
111
+ #if Step==StepTypes.min:
112
+ self.FlagTR = False
113
+ self.LaserType = False
114
+ self.SogliaNoise_Min = 0.0
115
+ self.SogliaStd_Min = 100.0
116
+
117
+ #elif Step in (StepTypes.piv, StepTypes.disp, StepTypes.spiv):
118
+ #common
119
+ self.FlagMIN=False
120
+ self.Imin=[]
121
+
122
+ self.dispFrames=0
123
+
124
+ self.numUsedProcs=1
125
+ self.numPivOmpCores=-1 # used by PIV_ParFor_Workerfor setting the correct number of threads
126
+
127
+ self.OUT_dict={}
128
+ self.PRO_dict={}
129
+ self.PRO_Disp_dict={}
130
+
131
+ self.Nit=0
132
+ self.nimg=0
133
+ self.ncam=0
134
+ self.nframe=2
135
+ self.nsteps=0
136
+ self.list_Image_Files=[]
137
+ self.list_eim=[]
138
+ self.list_pim=[]
139
+ self.list_print=[]
140
+
141
+ #if Step in (StepTypes.disp, StepTypes.spiv):
142
+ self.calList=[]
143
+ self.calEx=[]
144
+ self.res=0
145
+ self.laserConst=[0.0 for _ in range(3)]
146
+
147
+ #if Step==StepTypes.spiv:
148
+ self.FlagDISP=False
149
+ #self.dispFile=''
150
+
151
+ fields=[f for f,_ in self.__dict__.items()]
152
+ self.numCallBackTotOk=0 #numero di callback ricevute= quelle con problema + finalized
153
+ self.numFinalized=0 #numero di processi andati a buon fine
154
+ self.numProcOrErrTot=0
155
+ self.FlagFinished=False
156
+ self.flagParForCompleted=False # par for completed
157
+
158
+ # processing time
159
+ self.initProcTime=time() #initial time qhen starting the process
160
+ self.eta=0 # expexted time to finish the process
161
+ self.procTime=0 # processing time
162
+ self.timePerImage=0
163
+
164
+ #interface
165
+ self.freset_par=''
166
+ self.procfields=[f for f,_ in self.__dict__.items() if f not in fields]+ ['compMin','mediaPIV']
167
+
168
+ self.assignDataName()
169
+ return
170
+
171
+ def resF(self,i,string=''):
172
+ if self.ndig<-1: return ''
173
+ if string=='dispMap':
174
+ fold=os.path.dirname(self.outPathRoot)
175
+ rad=os.path.splitext(os.path.basename(self.outPathRoot))[0]
176
+ if rad[-1]!='_': rad+='_'
177
+ return myStandardRoot(os.path.join(fold, f'dispMap_rot_{rad}{i}.png'))
178
+ else:
179
+ if type(i)==str:
180
+ return f"{self.outPathRoot}_{i}{self.outExt}"
181
+ elif type(i)==int:
182
+ return f"{self.outPathRoot}_{i:0{self.ndig:d}d}{self.outExt}"
183
+ else:
184
+ return ''
185
+
186
+ def setProc(self,INP:INPpar=INPpar(),OUT:OUTpar=OUTpar(),PRO:PROpar=PROpar(),PRO_Min:PROpar_Min=PROpar_Min(),PRO_Disp:PROpar_Disp=PROpar_Disp()):
187
+ if INP is None: return
188
+ self.inpPath=INP.path
189
+ self.outPath=myStandardRoot(OUT.path+OUT.subfold)
190
+ self.outPathRoot=myStandardRoot(OUT.path+OUT.subfold+OUT.root)
191
+
192
+ if self.Step==StepTypes.disp:
193
+ self.list_Image_Files=INP.imList
194
+ self.list_eim=INP.imEx
195
+ else:
196
+ self.list_Image_Files=[]
197
+ self.list_eim=[]
198
+ for c in range(INP.ncam):
199
+ for k in range(INP.nimg):
200
+ for f in range(2):
201
+ self.list_Image_Files.append(INP.imList[c][f][k])
202
+ self.list_eim.append(INP.imEx[c][f][k])
203
+ self.ncam=len(INP.imList)
204
+ self.FlagTR=INP.FlagTR
205
+ self.LaserType=INP.LaserType
206
+ self.FlagMIN=INP.FlagMIN
207
+ self.Imin=INP.imListMin
208
+
209
+ if self.Step==StepTypes.min:
210
+ self.compMin.outName = self.outPathRoot+'_data'+outExt.min
211
+ self.compMin.name_proc = self.name_proc
212
+ self.compMin.flag_TR=self.FlagTR
213
+ self.compMin.LaserType=self.LaserType
214
+ self.compMin.setup(self.ncam,self.nframe)
215
+ self.nimg=(len(self.list_Image_Files)//(2*self.ncam)+1)//2 if self.FlagTR else len(self.list_Image_Files)//(2*self.ncam)
216
+ elif self.Step in (StepTypes.piv,StepTypes.disp,StepTypes.spiv):
217
+ if self.Step==StepTypes.piv:
218
+ self.mediaPIV.outName = self.outPathRoot+'_data'+outExt.piv
219
+ self.mediaPIV.name_proc = self.name_proc
220
+ elif self.Step==StepTypes.spiv:
221
+ self.mediaPIV.outName = self.outPathRoot+'_data'+outExt.spiv
222
+ self.mediaPIV.name_proc = self.name_proc
223
+ self.nimg=INP.nimg
224
+ self.ndig=len(str(self.nimg))
225
+ self.outExt=list(outType_dict)[OUT.outType]
226
+ self.numUsedProcs=self.numUsedProcs #TODEL
227
+ if self.Step in (StepTypes.disp,StepTypes.spiv):
228
+ self.calList=INP.calList
229
+ self.calEx =INP.calEx
230
+ if self.Step==StepTypes.disp:
231
+ self.Nit = PRO_Disp.Nit
232
+ self.dispFrames = PRO_Disp.frames
233
+ #if self.Step==StepTypes.spiv:
234
+ #self.FlagDISP=INP.FlagDISP
235
+ #self.dispFile=INP.dispFile
236
+
237
+ self.nsteps=self.Nit if self.Step==StepTypes.disp else self.nimg
238
+ self.list_pim=[0]*self.nsteps
239
+ self.list_print=['']*self.nsteps
240
+
241
+ if PRO_Min:
242
+ self.SogliaNoise_Min=PRO_Min.SogliaNoise
243
+ self.SogliaStd_Min=PRO_Min.SogliaStd
244
+
245
+ for f,v in OUT.duplicate().__dict__.items():
246
+ self.OUT_dict[f]=v
247
+ if self.Step in (StepTypes.piv,StepTypes.spiv):
248
+ for f,v in PRO.duplicate().__dict__.items():
249
+ self.PRO_dict[f]=v
250
+ if self.Step == StepTypes.disp:
251
+ for f,v in PRO_Disp.duplicate().__dict__.items():
252
+ self.PRO_Disp_dict[f]=v
253
+ #self.setPIV(OUT,PRO,flagSpiv)
254
+
255
+ def assignDataName(self):
256
+ self.name_proc,_,_=identifierName(typeObject='proc')
257
+
258
+ if self.Step!=StepTypes.null:
259
+ self.itemname=stepData[self.Step]['name']
260
+ for f,v in StepTypes.__dict__.items():
261
+ if v==self.Step:
262
+ break
263
+ ext=getattr(outExt,f)
264
+ self.filename_proc=f"{self.outPathRoot}{ext}"
265
+
266
+ def procOutName(self):
267
+ return procOutName(self)
268
+
269
+ def stepOutName(self):
270
+ return stepOutName(self)
271
+
272
+ def resetTimeStat(self):
273
+ ''' reset all the TimeStat parameters should be called before starting a new process maybe it is useless ask GP'''
274
+ self.procTime=0
275
+ self.eta=0
276
+ self.timePerImage=0
277
+
278
+ def onStartTimeStat(self):
279
+ ''' Should be called whenever play is pressed '''
280
+ pri.Time.blue(f'onStartTimeStat self.procTime={self.procTime}')
281
+ self.initProcTime=time()
282
+
283
+ def onPauseTimeStat(self):
284
+ ''' Should be called whenever pause is pressed '''
285
+ actualTime=time()
286
+ self.calcTimeStat(actualTime,self.numFinalized) #if paused should evaluate the correct eta when restarting
287
+ self.procTime+=actualTime-self.initProcTime
288
+ pri.Time.blue(f'onPauseTimeStat self.procTime={self.procTime} self.eta={self.eta} self.numFinalized={self.numFinalized}')
289
+
290
+ def deltaTime2String(self,dt,FlagMilliseconds=False):
291
+ if FlagMilliseconds:
292
+ s=str(timedelta(seconds=int(dt)))
293
+ s+="."+f"{dt:#.3f}".split('.')[-1] #
294
+ else:
295
+ s=str(timedelta(seconds=round(dt)))
296
+ return s
297
+
298
+ def calcTimeStat(self,actualTime,numDone):
299
+ ''' Should be called when when the eta should be updated '''
300
+ procTime=self.procTime+actualTime-self.initProcTime
301
+ numStilToProc=self.nsteps-numDone
302
+
303
+ if numDone==0:
304
+ self.eta=0
305
+ self.timePerImage=0
306
+ else:
307
+ self.timePerImage=(procTime)/numDone
308
+ self.eta=self.timePerImage*numStilToProc
309
+
310
+ #pr(f'dt={procTime} ETA={self.eta} {self.deltaTime2String(self.eta)} dt+ETA={round(procTime+ self.eta)} timePerImage={self.timePerImage} numStilToProc={numStilToProc} numDone={numDone} ')
311
+ return self.deltaTime2String(self.eta)
312
+
313
+ def setPIV(self,flagSpiv=False):
314
+ self.PIV=data2PIV(self,flagSpiv)
315
+
316
+ def createLogHeader(self):
317
+ header=PaIRS_Header
318
+ if self.Step==StepTypes.null: #minimum
319
+ name='Welcome to PaIRS!\nEnjoy it!\n\n'
320
+ header=header+name
321
+ else:
322
+ name=f'{self.itemname} ({self.filename_proc})\n'
323
+ name+=self.name_proc
324
+ date_time=QDate.currentDate().toString('yyyy/MM/dd')+' at '+\
325
+ QTime().currentTime().toString()
326
+ header+=f'{name}\n'+'Last modified date: '+date_time+'\n\n\n'
327
+ return header
328
+
329
+ def setCompleteLog(self):
330
+ warn1=self.headerSection('WARNINGS',self.warnings[1],'!')
331
+ if self.flagRun:
332
+ warn0=''
333
+ self.createLogProc()
334
+ LogProc = self.headerSection('OUTPUT',self.procLog[0])
335
+ LogStat = self.headerSection('PROGRESS status',self.procLog[1])
336
+ LogErr = self.headerSection('ERROR report',self.procLog[2])
337
+ procLog=LogProc+LogStat+LogErr
338
+ if self.warnings[0]: warn0='*Further information:\n'+self.warnings[0]+'\n'
339
+ self.Log=self.createLogHeader()+procLog+warn0+warn1
340
+ else:
341
+ self.Log=self.createLogHeader()+warn1
342
+
343
+ def createWarningLog(self,warning):
344
+ warn1=self.headerSection('WARNINGS',warning,'!')
345
+ return self.createLogHeader()+warn1
346
+
347
+ def headerSection(self,nameSection,Log,*args):
348
+ if len(Log):
349
+ c='-'
350
+ n=36
351
+ if len(args): c=args[0]
352
+ if len(args)>1: n=args[1]
353
+ ln=len(nameSection)
354
+ ns=int((n-ln)/2)
355
+ Log=f'{f"{c}"*n}\n{" "*ns}{nameSection}{" "*ns}\n{f"{c}"*n}\n'+Log+'\n'
356
+ return Log
357
+
358
+ def createLogProc(self):
359
+ splitAs='\n '#used to join the strings together tab or spaces may be use to indent the error
360
+ numImgTot=len(self.list_pim) if self.Step!=StepTypes.min else (2*len(self.list_pim))
361
+ LogProc=''
362
+ LogErr=''
363
+ cont=0
364
+ contErr=0
365
+ for i,p in enumerate(self.list_pim):
366
+ if not p or self.list_print[i]=='':
367
+ continue
368
+ if self.Step==StepTypes.min: #minimum
369
+ cont+=2
370
+ #flag=(p&FLAG_FINALIZED[0]) and (p&FLAG_FINALIZED[1])
371
+ if (p&FLAG_FINALIZED[0]):
372
+ if (p&FLAG_FINALIZED[1]):
373
+ LogProc+=(self.list_print[i])
374
+ else:
375
+ sAppo=self.list_print[i].split('\n')
376
+ LogProc+=sAppo[0]+'\n'
377
+ if (not p&FLAG_READ[1]) and p&FLAG_READ_ERR[1]:
378
+ LogErr+=splitAs.join(sAppo[1:-1])+'\n'
379
+ contErr+=1
380
+ #pri.Process.magenta(f'LogProc {i} {p} {splitAs.join(sAppo[1:-1])} {hex(p)} ')
381
+ else:# la b nonè stata proprio letta
382
+ cont-=1
383
+ #pri.Process.magenta(f'LogProc wrong {i} {p} {splitAs.join(sAppo[1:-1])} {hex(p)} ')
384
+ LogProc+='\n'
385
+ else:
386
+ sAppo=self.list_print[i].split('\n')
387
+ if (p&FLAG_FINALIZED[1]):
388
+ LogProc+=(sAppo[-2])+'\n'
389
+ LogErr+=splitAs.join(sAppo[0:-2])+'\n'
390
+ contErr+=1
391
+ else:
392
+ iDum=len(sAppo)//2
393
+ LogErr+=splitAs.join(sAppo[0:iDum])+'\n'+splitAs.join(sAppo[iDum:-1])+'\n'
394
+ contErr+=2
395
+ elif self.Step in (StepTypes.piv,StepTypes.disp,StepTypes.spiv): #PIV process
396
+ cont+=1
397
+ if p&FLAG_FINALIZED[0]:
398
+ LogProc+=self.list_print[i]+"\n"
399
+ #pr(f'LogProc {i} {p} {self.list_print[i]} {hex(p)} = {hex(FLAG_FINALIZED_AB)}\n')
400
+ else:
401
+ contErr+=1
402
+ errString=splitAs.join(self.list_print[i].split('\n')[0:-1])
403
+ if errString: LogErr+=errString+'\n'
404
+
405
+ if not LogProc: LogProc=self.nullLogProc()
406
+
407
+ self.FlagErr=bool(LogErr) or 'CRITICAL ERROR' in self.warnings[0]
408
+ if self.Step in (StepTypes.piv,StepTypes.spiv):
409
+ errStr=f' ({contErr}/{numImgTot} images)'
410
+ else:
411
+ errStr=''
412
+ if 'CRITICAL ERROR' in self.warnings[0]:
413
+ errStr2='!!! Critical errors occured! Please, see further information reported below.\n\n'
414
+ else:
415
+ errStr2=''
416
+ if self.FlagErr:
417
+ LogErr=f'There were errors in the current process{errStr}:\n\n{errStr2}'+LogErr
418
+ else:
419
+ LogErr=f'There were no errors in the current process!\n\n'
420
+ if numImgTot:
421
+ pProc=cont*100/numImgTot
422
+ else:
423
+ pProc=100
424
+ pLeft=100-pProc
425
+ if cont:
426
+ pErr=contErr*100/cont
427
+ else:
428
+ pErr=0
429
+ pCorr=100-pErr
430
+ item='pair' if self.Step!=StepTypes.disp else 'iteration'
431
+ sp=' '*6 if self.Step!=StepTypes.disp else ' '
432
+ Log_PIVCores='' if self.Step==StepTypes.min else f' PIV cores: {self.numPivOmpCores}\n'
433
+ LogStat=\
434
+ f'Percentage of {item}s\n'+\
435
+ f' processed: {pProc:.2f}%\n'+\
436
+ f' remaining: {pLeft:.2f}%\n'+\
437
+ f' without errors: {pCorr:.2f}%\n'+\
438
+ f' with errors: {pErr:.2f}%\n\n'+\
439
+ f'Time\n'+\
440
+ f' of the process: {self.deltaTime2String(self.procTime,True)}\n'+\
441
+ f' {sp} per {item}: {self.deltaTime2String(self.timePerImage,True)}\n'+\
442
+ f' to the end: {self.deltaTime2String(self.eta,True)}\n\n'+\
443
+ f'Multi processing\n'+\
444
+ Log_PIVCores+\
445
+ f' processing units: {floor(self.numUsedProcs)}\n'
446
+ #5f' processing units: {floor(self.numUsedProcs/self.numPivOmpCores)}\n'
447
+ self.procLog=[LogProc,LogStat,LogErr]
448
+ return
449
+
450
+ def nullLogProc(self):
451
+ return 'No output produced!\n\n'
452
+
453
+ def resetLog(self):
454
+ if self.procLog[0]!=self.nullLogProc():
455
+ self.Log=self.createLogHeader()+self.procLog[0]
456
+ else:
457
+ self.Log=self.createLogHeader()
458
+ return
459
+
460
+ def writeCfgProcPiv(self,filename='',FlagWarningDialog=False):
461
+ flagSpiv=self.Step==StepTypes.spiv
462
+ if filename=='':
463
+ outPathRoot=self.outPathRoot
464
+ foldOut=os.path.dirname(outPathRoot)
465
+ if not os.path.exists(foldOut):
466
+ try:
467
+ os.mkdir(foldOut)
468
+ except Exception as inst:
469
+ pri.Error.red(f'It was not possible to make the directory {foldOut}:\n{traceback.format_exc()}\n\n{inst}')
470
+ filename=f"{outPathRoot}.cfg"
471
+ try:
472
+ writeCfgProcPiv(self,filename,flagSpiv)
473
+ except Exception as inst:
474
+ warningMessage=f'Error while writing PIV configuration file to location "{filename}":\n{inst}'
475
+ if FlagWarningDialog: warningDialog(None,warningMessage)
476
+ pri.Error.red(f'{warningMessage}\n{traceback.format_exc()}\n')
477
+
478
+ class MediaPIV():
479
+ ''' helper class to perform the avearages '''
480
+ def __init__(self,stepType=StepTypes.piv):
481
+ self.outName=''
482
+ self.name_proc=''
483
+
484
+ self.stepType=stepType
485
+ self.namesPIV=NamesPIV(Step=self.stepType)
486
+
487
+ #self.avgVel=[self.x,self.y,self.u,self.v,self.up,self.vp,self.uvp,self.FCl,self.Info,self.sn]
488
+ self.x=np.zeros(1)
489
+ self.y=np.zeros(1)
490
+ self.u=np.zeros(1)
491
+ self.v=np.zeros(1)
492
+ self.up=np.zeros(1)
493
+ self.vp=np.zeros(1)
494
+ self.uvp=np.zeros(1)
495
+ self.sn=np.zeros(1)
496
+ self.FCl=np.zeros(1)
497
+ self.Info=np.zeros(1)
498
+ if self.stepType==StepTypes.disp:
499
+ self.z=np.zeros(1)
500
+ self.dPar=np.zeros(1)
501
+ self.dOrt=np.zeros(1)
502
+ if self.stepType==StepTypes.spiv:
503
+ self.z=np.zeros(1)
504
+ self.w=np.zeros(1)
505
+ self.wp=np.zeros(1)
506
+ self.uwp=np.zeros(1)
507
+ self.vwp=np.zeros(1)
508
+ self.indu=3 if self.stepType==StepTypes.spiv else 2
509
+
510
+ # just for checking that the variables are the same
511
+ # I cannot do it automatically since variables are not recognized by vscode
512
+ for n in self.namesPIV.avgVelFields:
513
+ v=getattr(self,n)
514
+
515
+ self.cont=0
516
+ self.nimg=0
517
+
518
+ self.fields=[f for f,_ in self.__dict__.items()]
519
+
520
+ def sum(self,var):
521
+ # should start with x, y ,u ,v
522
+ infoSi=1
523
+ self.cont=self.cont+1
524
+ for v, n in zip(var[2:], self.namesPIV.instVelFields[2:]) :
525
+ f=getattr(self,n)
526
+ #piv.Info #verificare se sia il caso di sommare solo se =Infosi
527
+ setattr(self,n,f+1*(v==infoSi) if n=='Info' else f+v )
528
+
529
+ '''
530
+ self.u=self.u+var[2] #piv.u
531
+ self.v=self.v+var[3] #piv.v
532
+ self.FCl=self.FCl+var[4] #piv.FCl
533
+ self.Info=self.Info+1*(var[5]==infoSi) #piv.Info #verificare se sia il caso di sommare solo se =Infosi
534
+ self.sn=self.sn+var[6] #piv.sn
535
+ '''
536
+ self.up=self.up+var[self.indu]*var[self.indu] #piv.up
537
+ self.vp=self.vp+var[self.indu+1]*var[self.indu+1] #piv.vp
538
+ self.uvp=self.uvp+var[self.indu]*var[self.indu+1] #piv.uvp
539
+ if self.stepType==StepTypes.spiv:
540
+ self.wp=self.wp+var[self.indu+2]*var[self.indu+2] #piv.wp
541
+ self.uwp=self.uwp+var[self.indu]*var[self.indu+2] #piv.uwp
542
+ self.vwp=self.vwp+var[self.indu+1]*var[self.indu+2] #piv.vwp
543
+
544
+
545
+ if self.x.size<=1:
546
+ self.x=var[0] #piv.x dovrebbero essere tutti uguali
547
+ self.y=var[1] #piv.y dovrebbero essere tutti uguali
548
+ if self.stepType==StepTypes.spiv:
549
+ self.z=var[2] #piv.y dovrebbero essere tutti uguali
550
+
551
+ def sumMedia(self,medToSum):
552
+ self.cont=self.cont+medToSum.cont
553
+ self.u=self.u+medToSum.u
554
+ self.v=self.v+medToSum.v
555
+ self.sn=self.sn+medToSum.sn
556
+ self.FCl=self.FCl+medToSum.FCl
557
+ self.up=self.up+medToSum.up
558
+ self.vp=self.vp+medToSum.vp
559
+ self.uvp=self.uvp+medToSum.uvp
560
+ self.Info=self.Info+medToSum.Info
561
+ if self.stepType==StepTypes.spiv:
562
+ self.w=self.w+medToSum.w
563
+ self.wp=self.wp+medToSum.wp
564
+ self.uwp=self.uwp+medToSum.uwp
565
+ self.vwp=self.vwp+medToSum.vwp
566
+ if self.x.size<=1:
567
+ self.x=medToSum.x #piv.x dovrebbero essere tutti uguali
568
+ self.y=medToSum.y #piv.y dovrebbero essere tutti uguali
569
+ if self.stepType==StepTypes.spiv:
570
+ self.z=medToSum.z #piv.y dovrebbero essere tutti uguali
571
+
572
+ def calcMedia(self):
573
+ if self.cont>0:
574
+
575
+ self.u/=self.cont
576
+ self.v/=self.cont
577
+
578
+ self.sn/=self.cont
579
+ self.FCl/=self.cont
580
+ self.Info/=self.cont#percentuale di vettori buoni 1=100% 0 nememno un vettore buono
581
+ self.up=(self.up/self.cont-self.u*self.u)#nan or inf is no good vector
582
+ self.vp=(self.vp/self.cont-self.v*self.v)#nan or inf is no good vector
583
+ self.uvp=(self.uvp/self.cont-self.u*self.v)#nan or inf is no good vector
584
+ if self.stepType==StepTypes.spiv:
585
+ self.w/=self.cont
586
+ self.wp=(self.wp/self.cont-self.w*self.w)#nan or inf is no good vector
587
+ self.uwp=(self.uwp/self.cont-self.u*self.w)#nan or inf is no good vector
588
+ self.vwp=(self.vwp/self.cont-self.w*self.v)#nan or inf is no good vector
589
+ def restoreSum(self):
590
+
591
+ #OPTIMIZE TA GP gestione delle statistiche ora si usano tutti i vettori anche quelli corretti forse si dovrebbe dare la possibiltà all'utente di scegliere?
592
+ self.up=(self.up+self.u*self.u)*self.cont # inf is no good vector
593
+ self.vp=(self.vp+self.v*self.v)*self.cont # inf is no good vector
594
+ self.uvp=(self.uvp+self.u*self.v)*self.cont # inf is no good vector
595
+ if self.stepType==StepTypes.spiv:
596
+ self.wp=(self.wp+self.w*self.w)*self.cont # inf is no good vector
597
+ self.uwp=(self.uwp+self.u*self.w)*self.cont # inf is no good vector
598
+ self.vwp=(self.vwp+self.w*self.v)*self.cont # inf is no good vector
599
+ self.w=self.w*self.cont
600
+
601
+ self.u=self.u*self.cont
602
+ self.v=self.v*self.cont
603
+ self.sn=self.sn*self.cont
604
+ self.Info=self.Info*self.cont#percentuale di vettori buoni 1=100% 0 nememno un vettore buono
605
+
606
+ class CompMin():
607
+ ''' helper class to compute minimum '''
608
+ def __init__(self,ncam=1,nframe=2):
609
+ self.outName=''
610
+ self.name_proc=''
611
+
612
+ self.setup(ncam,nframe)
613
+ #self.cont=0
614
+ #self.cont0=0
615
+
616
+ self.flag_TR=None
617
+ self.LaserType=-1 #0 single, 1 double
618
+
619
+ self.fields=[f for f,_ in self.__dict__.items()]
620
+
621
+ def setup(self,ncam,nframe):
622
+ self.ncam=ncam
623
+ self.nframe=nframe
624
+ self.Imin=[np.zeros(0) for _ in range(self.ncam*self.nframe)]
625
+ self.med=[np.zeros(1) for _ in range(self.ncam*self.nframe)]
626
+ self.contab=[0 for _ in range(ncam*2)]
627
+
628
+ def minSum(self,I,k):
629
+ ''' min '''
630
+ #sleep(0.15)
631
+ # min or max
632
+ if len(I):# why
633
+ if self.contab[k]==0:
634
+ self.Imin[k]=I
635
+ else:
636
+ self.Imin[k]=np.minimum(I,self.Imin[k])
637
+ # verage std and the like
638
+ self.med[k]=self.med[k]+I#+= non funziona all'inizio
639
+ self.contab[k]+=1
640
+ #prLock(f"minSum contab={self.contab[k]}")
641
+ def checkImg(self,I,sogliaMedia,sogliaStd)->bool:
642
+ ''' checkImg '''
643
+ #dum=1/I.size
644
+ media=I.mean() #I.ravel().sum()*dum #faster than mean, but affected by overflow
645
+ dev=I.std() #np.square(I-media).ravel().sum()*dum
646
+ return media>sogliaMedia and dev >sogliaStd*sogliaStd
647
+
648
+ def calcMin(self,minMed):
649
+ ''' calcMin and sum media '''
650
+ #pri.Time.magenta(0,f"self.cont0={self.cont0}")
651
+ #self.cont+=self.cont0
652
+ #nImg=1 if self.flag_TR else 2
653
+ #nImg=2
654
+ for k in range(len(self.Imin)):
655
+ if minMed.contab[k]>0:
656
+ if self.contab[k]==0:
657
+ self.Imin[k]=minMed.Imin[k]
658
+ else:
659
+ self.Imin[k]=np.minimum(minMed.Imin[k],self.Imin[k])
660
+ self.med[k]=self.med[k]+minMed.med[k]
661
+ self.contab[k]+=minMed.contab[k]# uno viene comunque sommato in min
662
+
663
+ def calcMed(self):
664
+ ''' calcMed and sum media '''
665
+ pri.Time.magenta(f"calcMed contab={self.contab} ")
666
+ #nImg=1 if self.flag_TR else 2
667
+ if self.LaserType==0: # single laser
668
+ for cam in range(self.ncam):
669
+ k=self.nframe*cam
670
+ for j in range(1,self.nframe):
671
+ self.Imin[k]=np.minimum(self.Imin[k],self.Imin[k+j])
672
+ self.med[k]+=self.med[k+j]
673
+ self.contab[k]+=self.contab[k+j]
674
+ self.med[k]/=self.contab[k]
675
+ for j in range(1,self.nframe):
676
+ self.Imin[k+j]=self.Imin[k].copy()
677
+ self.med[k+j]=self.med[k].copy()
678
+ self.contab[k+j]=self.contab[k] #useless? I don't think so, important for restoreMin
679
+ else:
680
+ for k in range(len(self.Imin)):
681
+ if self.contab[k]>0:
682
+ self.med[k]/=self.contab[k]
683
+ pri.Time.magenta(f"calcMed fine contab={self.contab} ")
684
+
685
+
686
+
687
+ def restoreMin(self):
688
+ #pr(f"restoreMin contab={self.contab} self.cont={self.cont} self.cont0={self.cont0}")
689
+ #nImg=1 if self.flag_TR else 2
690
+ for k in range(len(self.Imin)):
691
+ self.med[k]*=self.contab[k]
692
+
693
+ def foList(li,formato):
694
+ ''' format a list call with
695
+ where:
696
+ li is a list
697
+ format is the format that would have been used fo a single element of the list
698
+ e.g. print(f'{a:<4d}') -> print(f'{foList([a a],"<4d")}')
699
+ '''
700
+ return f"{''.join(f' {x:{formato}}' for x in li)}"
701
+ # todo delete old function
702
+ def writeCfgProcPivOld(data,nomeFile,flagSpiv=False):
703
+ PIV=data2PIV(data,flagSpiv)
704
+ PIV.SetVect([v.astype(np.intc) for v in data.PRO.Vect])
705
+ inp=PIV.Inp
706
+ vect=data.PRO.Vect
707
+
708
+ with open(nomeFile,'w', encoding="utf8") as f:
709
+ f.write('%TA000N3 Do not modify the previous string - It indicates the file version\n')
710
+ f.write('% PIV process configuration file - A % symbol on the first column indicates a comment\n')
711
+ f.write('% Windows dimensions ***************************************\n')
712
+ # % Windows dimensions ***************************************
713
+ f.write(f'[{foList(vect[0],"<3d")}], Height of the windows (rows) - insert the sequence of numbers separated by a blank character (1)\n')
714
+ f.write(f'[{foList(vect[2],"<3d")}], Width of the windows (columns) (2)\n')
715
+ f.write(f'[{foList(vect[1],"<3d")}], Grid distance along the height direction (y) (3)\n')
716
+ f.write(f'[{foList(vect[3],"<3d")}], Grid distance along the width direction (x) (4)\n')
717
+ f.write(f'{inp.FlagBordo}, Flag boundary: if =1 the first vector is placed at a distance to the boundary equal to the grid distance (5)\n')
718
+ # % Process parameters - Interpolation ***********************************
719
+ f.write(f'% Process parameters - Interpolation ***********************************\n')
720
+ f.write(f'{inp.IntIniz}, Type of interpolation in the initial part of the process (6)\n')
721
+ f.write(f'{inp.IntFin}, Type of interpolation in the final part of the process (7)\n')
722
+ f.write(f'{inp.FlagInt}, Flag Interpolation: if >0 the final interpolation is used in the final #par iterations (8)\n')
723
+ f.write(f'{inp.IntCorr}, Type of interpolation of the correlation map (0=gauss classic; 1=gauss reviewed; 2=Simplex) (9)\n')
724
+ f.write(f'{inp.IntVel}, Type of interpolation of the velocity field (1=bilinear; 2= Simplex,...) (10)\n')
725
+ # % Process parameters **************************************\n')
726
+ f.write(f'% Process parameters **************************************\n')
727
+ f.write(f'{inp.FlagDirectCorr}, Flag direct correlation on the final iterations (0=no 1=yes ) (11)\n')
728
+ f.write(f'{inp.NIterazioni}, Number of final iterations (12)\n')
729
+ f.write(f'% Activation flags **************************************\n')
730
+ # % Activation flags - Validation **************************************
731
+ f.write(f'1, Flag Validation (0=default parameters (see manual); otherwise the validation parameters in the final part of the cfg file are activated) (13)\n')
732
+ f.write(f'1, Flag Windowing (0=default parameters (see manual); otherwise the windowing parameters in the final part of the cfg file are activated) (14)\n')
733
+ f.write(f'1, Flag Filter (0=default parameters (see manual); otherwise the additional filter parameters in the final part of the cfg file are activated) (29)\n')
734
+ f.write(f'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n')
735
+ f.write(f'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n')
736
+ # % Process parameters - Validation **************************************
737
+
738
+ f.write(f'% Process parameters - Validation **************************************\n')
739
+ f.write(f'{inp.FlagValid}, Flag median test: 0=no; 1=classic; 2=universal (Scarano, Westerweel 2005) (15)\n')
740
+ f.write(f'{inp.SemiDimValid}, Half-dimension of the kernel (it uses 2*(#par)+1 vectors for each direction) (16)\n')
741
+ f.write(f'{inp.SogliaMed:.2f}, Threshold for the median test - Advised value 2 (1.0 - 3.0) (17)\n')
742
+ f.write(f'{inp.ErroreMed:.2f}, Allowed Error in pixel for the median test - Advised value 0.1 (0.0 -> no limits) (18)\n')
743
+ f.write(f'{inp.FlagAttivaValSN}, Flag test sn/CC: 0=no; 1=sn; 2=CC; 3=both +4 for limiting the maximum displacement (19)\n')
744
+ f.write(f'{inp.SogliaSN:.2f}, Threshold for the signal/noise test (Advised value 1.5) - it doesn\'t work on the direct correlation (20)\n')
745
+ f.write(f'{inp.SogliaFcl:.2f}, Threshold correlation coefficient (Advised value 0.25) (21)\n')
746
+ f.write(f'{inp.FlagSecMax}, Flag correction with the second maximum; 0=not active; otherwise it is active (22)\n')
747
+ f.write(f'{inp.FlagCorrezioneVel}, Flag correction vectors: 0=average on correct vectors; 1=weighted average with the distance; 2=iterative average (23)\n')
748
+ f.write(f'{inp.SogliaNoise:.2f}, Minimum allowed average value in the interrogation window (24)\n')
749
+ f.write(f'{inp.SogliaStd:.2f}, Minimum allowed std deviation value in the interrogation window(25)\n')
750
+ f.write(f'{inp.FlagValidNog}, Flag Nogueira Test (discontinued) : 0 --> no; !=0 -->yes (if activated disables the other validation criteria )\n')
751
+ f.write(f'0.2, First parameter Nogueira Test(0.20-0.35) \n')
752
+ f.write(f'0.1, Second parameter Nogueira Test(0.01-0.1) \n')
753
+ f.write(f'{0}, Hart Correction uses 4 interrogation windows W=W-W/Par e H=H-/Par 0 disables\n')
754
+ f.write(f'{0}, Value of info for a good vector \n')
755
+ f.write(f'{1}, Value of info for an outlier\n')
756
+ # % Windowing parameters (Astarita, Exp Flu, 2007) *************************
757
+ f.write(f'% Windowing parameters (Astarita EiF 2007) *************************\n')
758
+ f.write(f'{inp.FlagCalcVel}, Weighting window for absolute velocity (0=TopHat, 1=Nogueira, 2=Blackman,...) (26)\n')
759
+ f.write(f'{inp.FlagWindowing}, Weighting window for the correlation map (0=TopHat 1= Nogueira 2=Blackman 3=top hat at 50%) (27)\n')
760
+ f.write(f'{inp.SemiDimCalcVel}, Half-width of the filtering window (0=window dimension) (28)\n')
761
+ # % Adaptive PIV parameters (Astarita, Exp Flu, 2009) *************************
762
+ f.write(f'% Adaptive PIV parameters (Astarita EiF 2009) *************************\n')
763
+ f.write(f'{inp.MaxC:.3f}, Maximum value of zita (30)\n')
764
+ f.write(f'{inp.MinC:.3f}, Minimum value of zita (30) \n')
765
+ f.write(f'{inp.LarMin}, Minimum Half-width of the weighting window (31)\n')
766
+ f.write(f'{inp.LarMax}, Maximum Half-width of the weighting window (31)\n')
767
+ # % Further processing parameters *************************
768
+ f.write(f'% Further processing parameters *************************\n')
769
+ f.write(f'{inp.FlagSommaProd}, Flag product or sum of correlation 0 prod 1 sum (only used if par 27 or 11 are !=0) (32)\n')
770
+ f.write(f'{inp.ItAtt if not -1000 else 0 }, Flag for restarting from a previous process (0 no otherwise the previous iteration) (33)\n')
771
+ # % Filter parameters *************************
772
+ FlagFilt=0
773
+ CutOff=18
774
+ VelCut=-1
775
+ f.write(f'% Additional filter parameters 2009) *************************\n')
776
+ f.write(f'{FlagFilt:}, Flag for alternate direction filtering 0 disable 1 dense predictor 2 displacement (34)\n')
777
+ f.write(f'{CutOff:.2f}, Vertical Cutoff wavelength (35) \n')
778
+ f.write(f'{VelCut:.2f}, Vertical filter rate (36)\n')
779
+ f.write(f'{CutOff:.2f}, Horizontal Cutoff wavelength (35) \n')
780
+ f.write(f'{VelCut}, Horizontal filter rate (36)\n')
781
+ f.write(f'{inp.FlagRemNoise}, Flag to activate noise removal on the images (37)\n')
782
+ PercCap=-.001
783
+ PercFc=-3
784
+ f.write(f'{PercFc}, Parameter for noise removal (38)\n')
785
+ f.write(f'{PercCap}, Number of std to cap the particles (negative disables) (39)\n')
786
+
787
+
788
+ '''
789
+ try:
790
+ p=PaIRS_lib.PIV()
791
+ p.readCfgProc(nomeFile)
792
+ except Exception as inst:
793
+ pri.Error.white(inst.__cause__)
794
+
795
+ import inspect
796
+ notUsedKey=['FlagLog','HCellaVec','HOverlapVec','ImgH','ImgW','RisX','RisY','WCellaVec','WOverlapVec','dt','this' ]
797
+ diPro= dict(inspect.getmembers(PIV.Inp))
798
+ flagEqual=1
799
+ for k,v in inspect.getmembers(p.Inp):
800
+ if not k[0].startswith('_'):
801
+ if not k in notUsedKey:
802
+ if v!=diPro[k]:
803
+ flagEqual=0
804
+ print(f'{k}={v}->{diPro[k]}')
805
+ if flagEqual:
806
+ pr('The cfg is identical to the master')
807
+ #verifica uguaglianza PROpar, mancano i vettori
808
+ flagEqual=1
809
+ try:
810
+ pro=PIV2Pro(p)
811
+ pDum=data2PIV(data)
812
+ pDum.SetVect([v.astype(np.intc) for v in data.PRO.Vect])
813
+ pro=PIV2Pro(pDum)
814
+
815
+ notUsedKey=['change_top','copyfrom','copyfromdiz','duplicate','indexes','isDifferentFrom','isEqualTo','printDifferences','printPar','setup','tip','uncopied_fields','indTree','indItem']
816
+ listOfList=['Vect' ]
817
+ diPro= dict(inspect.getmembers(data.PRO))
818
+ #pro.printDifferences(data.PRO,[],[],True) #questo è automatico
819
+ for k,v in inspect.getmembers(pro):
820
+ if not k[0].startswith('_') and not k in notUsedKey:
821
+
822
+ if k in listOfList:
823
+
824
+ for i,(a,b) in enumerate(zip (v,diPro[k])):
825
+ if (a!=b).any():
826
+ flagEqual=0
827
+ print(f'{k}[{i}]={a}->{b}')
828
+ else:
829
+ if v!=diPro[k]:
830
+ flagEqual=0
831
+ print(f'{k}={v}->{diPro[k]}')
832
+ if flagEqual:
833
+ pr('The PROpar is identical to the master')
834
+ except Exception as inst:
835
+ pri.Error.red(f'{inst}')
836
+
837
+
838
+ #'''
839
+ def writeCfgProcPiv(data,nomeFile,flagSpiv=False):
840
+ PIV=data2PIV(data,flagSpiv)
841
+ inp=PIV.Inp
842
+ vect=PIV.GetVect()
843
+ vectWindowing=PIV.GetWindowingVect()
844
+
845
+ with open(nomeFile,'w', encoding="utf8") as f:
846
+ f.write('%TA000N5 Do not modify the previous string - It indicates the file version\n')
847
+ f.write('% PIV process configuration file - A % symbol on the first column indicates a comment\n')
848
+ f.write('% Windows dimensions position and iterations *******************************\n')
849
+ # % Windows dimensions position and iterations *******************************
850
+ f.write(f'[{foList(vect[0],"<3d")}], Height of the windows - sequence separated by a space (1)\n')
851
+ f.write(f'[{foList(vect[2],"<3d")}], Width of the IW if equal to -1 then square IW are used (1)\n')
852
+ f.write(f'[{foList(vect[1],"<3d")}], Grid distance along the height direction (y) (2)\n')
853
+ f.write(f'[{foList(vect[3],"<3d")}], Grid distance along x if equal to -1 then a square grid is used (2)\n')
854
+ f.write(f'{inp.FlagBordo}, Pos flag: 0 normal 1 1st vector is placed par#2 from the border (3)\n')
855
+ f.write(f'{inp.NIterazioni}, Number of final iterations (4)\n')
856
+
857
+ # % Process parameters - Interpolation ***********************************
858
+ f.write(f'% Process parameters - Interpolation ***********************************\n')
859
+ f.write(f'[{foList([inp.IntIniz,inp.FlagInt,inp.IntFin],"<3d")}], Image Interpolation: [intial; #iter; final] (5)\n')
860
+ f.write(f'{inp.IntCorr}, Correlation peak IS (3=gauss; 4=gauss reviewed; 5=Simplex) (6)\n')
861
+ f.write(f'{inp.IntVel}, Dense predictor IS (1=bilinear; 2=Simplex...) (7)\n')
862
+ # % Process parameters - Validation ******************************************\n')
863
+ f.write(f'% Process parameters - Validation ******************************************\n')
864
+ f.write(f'[{foList([inp.FlagValid,inp.SemiDimValid,inp.SogliaMed,inp.ErroreMed],".6g")}], Median test: [0=no; 1=med; 2=univ; kernel dim=1; thr=2; eps=0.1] (8)\n')
865
+ f.write(f'[{foList([inp.FlagAttivaValSN,inp.SogliaSN,inp.SogliaFcl],".6g")}], sn/CC test: [0=no; 1=sn; 2=CC; 3=both;sn thr=1.5; cc thr=0.3] (9)\n')
866
+ f.write(f'[{foList([inp.FlagValidNog,inp.SogliaMedia,inp.SogliaNumVet],".6g")}], Nog test:[0 no; 1 active; par1; par2] (10)\n')
867
+ f.write(f'[{foList([inp.SogliaNoise,inp.SogliaStd],".6g")}], Minimum threshold: [mean=2; std=3] (11)\n')
868
+ f.write(f'{inp.FlagCorrHart}, Hart correction 4 IW of W=W-W/Par are used o correct outliers (12)\n')
869
+ f.write(f'{inp.FlagSecMax}, Flag second maximum correction; 0 no 1 active (13)\n')
870
+ f.write(f'{inp.FlagCorrezioneVel}, Flag vectors correction: 0=average on correct vectors; 1=weighted average with the distance; 2=iterative average (14)\n')
871
+ f.write(f'[{foList([inp.InfoSi,inp.InfoNo],".6g")}], Output values (info): [value for good=1; value for corrected=0] (15)\n')
872
+ # % Windowing parameters (Astarita, Exp Flu, 2007) ***************************
873
+
874
+ f.write(f'% Windowing parameters (Astarita, Exp Flu, 2007) ***************************\n')
875
+ f.write(f'[{foList(vectWindowing[1],"<3d")}], WW for predictor (0=TopHat; 2=Blackman;...) (16)\n')
876
+ f.write(f'[{foList(vectWindowing[2],"<3d")}], WW for the correlation map (0=TopHat;2=Blackman 3=top hat at 50%)(17)\n')
877
+ f.write(f'[{foList(vectWindowing[3],"<3d")}], Half-width of the filtering window (0=window dimension) (18)\n')
878
+ f.write(f'[{foList(vectWindowing[4],"<3d")}], Flag direct correlation (0=no 1=yes ) (19)\n')
879
+ f.write(f'[{foList(vectWindowing[0],"<3d")}], Max displacement if <0 fraction of wa i.e. -4-> Wa/4 (20)\n')
880
+ f.write(f'{inp.FlagSommaProd}, Double CC operation (0 Product 1 sum) (21)\n')
881
+ f.write(f'[{foList([inp.flagAdaptive,inp.MaxC,inp.MinC,inp.LarMin,inp.LarMax],".6g")}], Adaptive process [0=no;#of it; par1; par2; par3; par4] (22)\n')
882
+ f.write(f'{inp.ItAtt if not -1000 else 0 }, Flag for restarting from a previous process (0 no; prev iter) (23)\n')
883
+ # % Filter parameters *******************************************************
884
+ f.write(f'% Filter parameters *******************************************************\n')
885
+ f.write(f'[{foList([inp.FlagFilt,inp.CutOffH,inp.VelCutH,inp.CutOffW,inp.VelCutW ],".6g")}], Additional AD filter [0 no; 1 Pred; 2 disp; cutoff H;Rate H;W;W] (24)\n')
886
+ f.write(f'[{foList([inp.FlagRemNoise,inp.PercFc,],".6g")}], Noise reduction removal of particles [0 no; it=2; perc=0.01] (25)\n')
887
+
888
+ f.write(f'[{0 if inp.PercCap<0 else 1:d} {abs(inp.PercCap):.6g}], Noise reduction capping [0 no; val=1.05] (26)\n')
889
+ f.write('\n')
890
+
891
+
892
+
893
+ '''
894
+ # Mettere alla fine di updateGuiFromTree
895
+ tree,_=self.w_Tree.pickTree(self.w_Tree.TREpar.indTree)
896
+ d=tree.currentItem().data(0,Qt.UserRole)
897
+ data:dataTreePar=self.w_Tree.TABpar_prev[d.indTree][d.indItem][d.ind]
898
+ data.writeCfgProcPiv()
899
+ #'''
900
+ '''
901
+ try:
902
+ p=PaIRS_lib.PIV()
903
+ p.readCfgProc(nomeFile)
904
+ except Exception as inst:
905
+ pri.Error.white(inst)
906
+
907
+ import inspect
908
+ notUsedKey=['FlagLog','HCellaVec','HOverlapVec','ImgH','ImgW','RisX','RisY','WCellaVec','WOverlapVec','dt','this' ,'FlagCalcVelVec', 'FlagDirectCorrVec','FlagWindowingVec','MaxDispInCCVec','SemiDimCalcVelVec' ]
909
+ diPro= dict(inspect.getmembers(PIV.Inp))
910
+ app=1e-6# to avoid false detections in case of float
911
+ flagEqual=1
912
+ for k,v in inspect.getmembers(p.Inp):
913
+ if not k[0].startswith('_'):
914
+ if not k in notUsedKey:
915
+ if v!=diPro[k]:
916
+ flagEqual=0
917
+ print(f'{k}={v}->{diPro[k]}')
918
+ if flagEqual:
919
+ pr('The cfg is identical to the master')
920
+ #verifica uguaglianza PROpar, mancano i vettori
921
+ flagEqual=1
922
+
923
+ try:
924
+ #pro=PIV2Pro(p)
925
+ pDum=data2PIV(data)
926
+ pDum.SetVect([v.astype(np.intc) for v in data.PRO.Vect])
927
+ pro=PIV2Pro(pDum)
928
+
929
+ notUsedKey=['change_top','copyfrom','copyfromdiz','duplicate','indexes','isDifferentFrom','isEqualTo','printDifferences','printPar','setup','tip','uncopied_fields','indTree','indItem']
930
+ listOfList=['Vect' ]## to add ,'windowingVect'
931
+ diPro= dict(inspect.getmembers(data.PRO))
932
+ #pro.printDifferences(data.PRO,[],[],True) #questo è automatico
933
+ for k,v in inspect.getmembers(pro):
934
+ if not k[0].startswith('_') and not k in notUsedKey:
935
+
936
+ if k in listOfList:
937
+
938
+ for i,(a,b) in enumerate(zip (v,diPro[k])):
939
+ if (a!=b).any():
940
+ flagEqual=0
941
+ print(f'{k}[{i}]={a}->{b}')
942
+ else:
943
+ if v!=diPro[k]:
944
+ if isinstance(v, float) and v !=0 :
945
+ if abs((v-diPro[k])/v) >app:
946
+ flagEqual=0
947
+ print(f'{k}={v}->{diPro[k]}')
948
+ if flagEqual:
949
+ pr('The PROpar is identical to the master')
950
+ except Exception as inst:
951
+ pri.Error.red(f'{inst}')
952
+
953
+
954
+ #'''
955
+ # TODO rivedere quando Gerardo aggiunge i vettori
956
+ def PIV2Pro(piv:PaIRS_lib.PIV)-> PROpar:
957
+ pro=PROpar()
958
+
959
+ #PIV.SetVect([v.astype(np.intc) for v in data.PRO.Vect])
960
+ pro.Vect=[v.astype(np.intc) for v in piv.GetVect()]
961
+ #pro.windowingVect=[v.astype(np.intc) for v in piv.GetVect()]
962
+
963
+ pro.SogliaNoise=piv.Inp.SogliaNoise
964
+ pro.SogliaStd=piv.Inp.SogliaStd
965
+ pro.SogliaMed=piv.Inp.SogliaMed
966
+ pro.ErroreMed=piv.Inp.ErroreMed
967
+ # Parameters not used in PaIrs but read by readcfg.
968
+ # int FlagFilt;
969
+ # Tom_Real CutOffH; // Lunghezza d'onda massima per il filtro
970
+ # Tom_Real CutOffW; // Lunghezza d'onda massima per il filtro
971
+ # Tom_Real VelCutH; // Rateo di filtraggio
972
+ # Tom_Real VelCutW; //
973
+ # Tom_Real PercCap; // PPercentuale massimo livello di grigio non trattato
974
+ # Tom_Real PercFc; // Percentuale per considerare cattivo un punto
975
+ # int FlagCorrHart; // Flag Per Correzione Hart
976
+ # These parameters are not exposed in Inp if needed modify PIV_input.i
977
+ #Valid Nog
978
+ pro.SogliaMedia=0.25#piv.Inp.SogliaMedia
979
+ pro.SogliaNumVet=0.10#piv.Inp.SogliaNumVet
980
+ pro.FlagCorrHart=0#piv.Inp.SogliaNumVet
981
+
982
+ if piv.Inp.FlagValidNog==1:
983
+ pro.FlagNogTest=1
984
+ pro.FlagMedTest=0
985
+ pro.FlagCPTest=0
986
+ pro.FlagSNTest =0
987
+ else:
988
+ if piv.Inp.FlagValid>0 :
989
+ pro.FlagMedTest=1
990
+ pro.TypeMed=piv.Inp.FlagValid-1
991
+ pro.KernMed=piv.Inp.SemiDimValid
992
+ pro.FlagSecMax=piv.Inp.FlagSecMax
993
+ pro.FlagSNTest =1 if piv.Inp.FlagAttivaValSN&1 else 0
994
+ pro.FlagCPTest =1 if piv.Inp.FlagAttivaValSN&2 else 0
995
+
996
+ pro.SogliaSN=piv.Inp.SogliaSN
997
+ pro.SogliaCP=piv.Inp.SogliaFcl
998
+
999
+ pro.IntIniz=piv.Inp.IntIniz
1000
+ pro.IntFin=piv.Inp.IntFin
1001
+ pro.FlagInt=piv.Inp.FlagInt
1002
+ pro.IntVel=piv.Inp.IntVel
1003
+ pro.FlagCorrezioneVel=piv.Inp.FlagCorrezioneVel
1004
+ #pro.FlagCorrHart=PIV.Inp.FlagCorrHart
1005
+ pro.IntCorr=piv.Inp.IntCorr
1006
+ pro.FlagWindowing=piv.Inp.FlagWindowing
1007
+
1008
+ pro.MaxC=piv.Inp.MaxC
1009
+ pro.MinC=piv.Inp.MinC
1010
+ pro.LarMin=piv.Inp.LarMin
1011
+ pro.LarMax=piv.Inp.LarMax
1012
+
1013
+ pro.FlagCalcVel=piv.Inp.FlagCalcVel
1014
+ pro.FlagSommaProd=piv.Inp.FlagSommaProd
1015
+ pro.FlagDirectCorr=piv.Inp.FlagDirectCorr
1016
+ pro.FlagBordo=piv.Inp.FlagBordo
1017
+
1018
+ if piv.Inp.SemiDimCalcVel<0:
1019
+ pro.NItAdaptative=-piv.Inp.SemiDimCalcVel
1020
+ pro.NIterazioni=piv.Inp.NIterazioni-pro.NItAdaptative
1021
+ pro.FlagAdaptative=1
1022
+ else:
1023
+ pro.SemiDimCalcVel=piv.Inp.SemiDimCalcVel
1024
+ pro.NIterazioni=piv.Inp.NIterazioni
1025
+ pro.FlagAdaptative=0
1026
+
1027
+ return pro
1028
+
1029
+ def data2PIV(data:dataTreePar,flagSpiv=False):
1030
+ OUT=OUTpar()
1031
+ OUT.copyfromdiz(data.OUT_dict)
1032
+ PRO=PROpar()
1033
+ PRO.copyfromdiz(data.PRO_dict)
1034
+
1035
+ if flagSpiv:
1036
+ PIV=PaIRS_lib.Stereo()
1037
+ else:
1038
+ PIV=PaIRS_lib.PIV()
1039
+
1040
+ PIV.DefaultValues()
1041
+ PIV.Inp.FlagNumThreads=data.numPivOmpCores
1042
+ #OUT=data.OUT
1043
+ #PRO=data.PRO
1044
+
1045
+ # % Windows dimensions position and iterations *******************************
1046
+ PIV.SetVect([np.array(v).astype(np.intc) for v in PRO.Vect])
1047
+ PIV.Inp.FlagBordo=PRO.FlagBordo
1048
+ PIV.Inp.NIterazioni=PRO.NIterazioni+PRO.NItAdaptative if PRO.FlagAdaptative else PRO.NIterazioni
1049
+ # % Process parameters - Interpolation ***********************************
1050
+ PIV.Inp.IntIniz=PRO.IntIniz
1051
+ PIV.Inp.FlagInt=PRO.FlagInt
1052
+ PIV.Inp.IntFin=PRO.IntFin
1053
+ PIV.Inp.IntCorr=PRO.IntCorr+3
1054
+ PIV.Inp.IntVel=PRO.IntVel
1055
+
1056
+ # % Process parameters - Validation ******************************************
1057
+ # Median test : [0 = no; 1 = med; 2 = univ, kernel dim = 1, thr = 2, eps = 0.1] (8)
1058
+ PIV.Inp.FlagValid=1 if PRO.TypeMed==0 else 2
1059
+ PIV.Inp.SemiDimValid=PRO.KernMed
1060
+ PIV.Inp.SogliaMed=PRO.SogliaMed
1061
+ PIV.Inp.ErroreMed=PRO.ErroreMed
1062
+ PIV.Inp.jumpDimValid=1
1063
+ # sn/CC test: [0=no; 1=sn; 2=CC; 3=both,sn thr=1.5, cc thr=0.3] (9)
1064
+ PIV.Inp.FlagAttivaValSN=1 if PRO.FlagSNTest else 0
1065
+ PIV.Inp.FlagAttivaValSN|=2 if PRO.FlagCPTest else 0
1066
+ PIV.Inp.SogliaSN=PRO.SogliaSN
1067
+ PIV.Inp.SogliaFcl=PRO.SogliaCP
1068
+
1069
+ # Nog test : [0 no; 1 active, par1, par2] (10)
1070
+ PIV.Inp.FlagValidNog=1 if PRO.FlagNogTest else 0
1071
+ PIV.Inp.SogliaMedia=PRO.SogliaMedia
1072
+ PIV.Inp.SogliaNumVet=PRO.SogliaNumVet
1073
+
1074
+ PIV.Inp.SogliaNoise=PRO.SogliaNoise
1075
+ PIV.Inp.SogliaStd=PRO.SogliaStd
1076
+
1077
+ PIV.Inp.FlagCorrHart=0 # to be seen
1078
+ PIV.Inp.FlagSecMax=1 if PRO.FlagSecMax else 0
1079
+ PIV.Inp.FlagCorrezioneVel=PRO.FlagCorrezioneVel
1080
+ # Output values(info) : [value for good = 1, value for corrected = 0] (16)
1081
+ PIV.Inp.InfoSi=1
1082
+ PIV.Inp.InfoNo=0
1083
+
1084
+ # % Windowing parameters (Astarita, Exp Flu, 2007) ***************************
1085
+ PIV.Inp.numInitIt=max(len(v) for v in PRO.Vect)
1086
+ PIV.Inp.FlagWindowing=PRO.FlagWindowing
1087
+ """
1088
+ if (PIV.Inp.FlagWindowing >= 0) :
1089
+ FlagWindowingVec=np.array([PIV.Inp.FlagWindowing],dtype=np.intc)
1090
+ else :
1091
+ numInitIt = PIV.Inp.numInitIt +1# if negative onlhy in the final iterations
1092
+ FlagWindowingVec=np.array([0 if ii<numInitIt -1 else -PIV.Inp.FlagWindowing for ii in range(numInitIt) ],dtype=np.intc)
1093
+ """
1094
+ FlagWindowingVec=np.array(PRO.vFlagWindowing,dtype=np.intc)
1095
+
1096
+ flagCalcVelVec=np.array(PRO.vFlagCalcVel,dtype=np.intc)
1097
+ semiDimCalcVelVec=np.array(PRO.vSemiDimCalcVel,dtype=np.intc)
1098
+
1099
+ PIV.Inp.FlagDirectCorr=PRO.FlagDirectCorr
1100
+ """
1101
+ if (PIV.Inp.FlagDirectCorr == 0) :
1102
+ FlagDirectCorrVec=np.array([PIV.Inp.FlagDirectCorr],dtype=np.intc)
1103
+ else :
1104
+ numInitIt = PIV.Inp.numInitIt +(PIV.Inp.FlagDirectCorr - 1)# if equal to 2 then should be one element longer
1105
+ FlagDirectCorrVec=np.array([0 if ii<numInitIt -1 else 1 for ii in range(numInitIt) ],dtype=np.intc)
1106
+ """
1107
+ FlagDirectCorrVec=np.array(PRO.vDC,dtype=np.intc)
1108
+
1109
+ maxDispInCCVec=np.array(PRO.vMaxDisp,dtype=np.intc)
1110
+ vect1=[maxDispInCCVec,flagCalcVelVec,FlagWindowingVec,semiDimCalcVelVec,FlagDirectCorrVec]
1111
+
1112
+ PIV.Inp.numInitIt=max(*[len(v) for v in vect1],PIV.Inp.numInitIt)
1113
+
1114
+ PIV.SetWindowingVect(vect1)
1115
+ PIV.Inp.FlagSommaProd=PRO.FlagSommaProd
1116
+
1117
+ # Adaptive process[0 = no; #of it, par1, par2, par3, par4](22)
1118
+ # questo è l'equivalente del c
1119
+ #PIV.Inp.flagAdaptive =-PIV.Inp.SemiDimCalcVel if PIV.Inp.SemiDimCalcVel <= -1 else 0
1120
+ #PIV.Inp.SemiDimCalcVel = abs(PIV.Inp.SemiDimCalcVel)
1121
+ #flagCalcVelVec=np.array(abs(PIV.Inp.SemiDimCalcVel),dtype=np.intc)
1122
+ PIV.Inp.flagAdaptive =PRO.NItAdaptative if PRO.FlagAdaptative else 0
1123
+ PIV.Inp.MaxC=PRO.MaxC
1124
+ PIV.Inp.MinC=PRO.MinC
1125
+ PIV.Inp.LarMin=PRO.LarMin
1126
+ PIV.Inp.LarMax=PRO.LarMax
1127
+
1128
+ PIV.Inp.ItAtt=-1000
1129
+
1130
+
1131
+ PIV.Inp.RisX=OUT.xres#*float(10.0)
1132
+ PIV.Inp.RisY=OUT.xres*OUT.pixAR#*float(10.0)
1133
+ PIV.Inp.dt=OUT.dt*float(10)
1134
+ PIV.Inp.ImgH=OUT.h
1135
+ PIV.Inp.ImgW=OUT.W
1136
+ ''' already done in DefaultValues
1137
+
1138
+ PIV.Inp.FlagFilt = 0; # Flag filtro: 0 nessuno, 1 AD,
1139
+ PIV.Inp.CutOffH=18; # Lunghezza d'onda massima per il filtro
1140
+ PIV.Inp.VelCutH=-1; # Rateo di filtraggio
1141
+ PIV.Inp.CutOffW=18; # Lunghezza d'onda massima per il filtro
1142
+ PIV.Inp.VelCutW=-1; #
1143
+ PIV.Inp.FlagRemNoise = 0; # Flag per eliminare rumore 0 no,1 si
1144
+ PIV.Inp.PercFc=0.01; # Percentuale per considerare cattivo un punto
1145
+ PIV.Inp.PercCap=-1.05; # PPercentuale massimo livello di grigio non trattato
1146
+ '''
1147
+
1148
+
1149
+ return PIV
1150
+
1151
+ def data2StereoPIV(data:dataTreePar):
1152
+ StereoPIV=data2PIV(data,flagSpiv=True)
1153
+
1154
+ OUT=OUTpar()
1155
+ OUT.copyfromdiz(data.OUT_dict)
1156
+ PRO=PROpar()
1157
+ PRO.copyfromdiz(data.PRO_dict)
1158
+
1159
+ spiv=StereoPIV.SPIVIn
1160
+ dP=StereoPIV.dataProc
1161
+ inPiv=StereoPIV.Inp
1162
+
1163
+ # STEREO CFG file
1164
+ # A €£ indicate that the feature is not enabled in the python wrapper
1165
+ spiv.nomecal='' # Root of calibration constants
1166
+ #spiv.NomeCostPiano=data.dispFile[:-4] # Root of disparity plane constants
1167
+
1168
+ spiv.percorsocal='' # Path of calibration constants
1169
+ spiv.FlagParallel=0 # Type of parallel process 0 horizontal 1 vertical (faster but with less information and mor RAM occupied)
1170
+ dP.FlagInt=StereoPIV.Inp.IntFin # IS for image reconstruction (only used when FlagRad==0)
1171
+ inPiv.FlagRad=1 # 1 internal (in piv) or 0 external de-warping of the images (the latter €£)
1172
+ dP.FlagCoordRad=0 # when equal to 0 the de-warping is carried on with the larger resolution (pix/mm)
1173
+ # when equal to 1 (2) the x (y) axis resolution is used
1174
+ spiv.salvarad=0 # if true and FlagRad is equal to 0 then the dewarped images are saved (€£)
1175
+
1176
+
1177
+ # % ********************* Input/Output
1178
+ spiv.FirstImg=0 # # of first img to be processed (€£)
1179
+ spiv.LastImg=0 # # of first last to be processed (€£)
1180
+ spiv.Digit=0 # number of figures i.e. zeros (MAX 10) (€£)
1181
+ spiv.ImgRoot='' # Root of the input Images (€£)
1182
+ spiv.InDir='' # Path of the images (€£)
1183
+ spiv.InExt='' # Extension of the images (€£)
1184
+ spiv.OutRoot ='' # Root of the output Files (€£)
1185
+ spiv.OutDir ='' # Output path (€£)
1186
+ spiv.OutExt ='' # Output extension (€£)
1187
+ spiv.OutFlag = 0 # type of output file : 0 binary Tecplot 1 ascii tecplot (€£)
1188
+ spiv.WrtFlag = 1 # 0 only mean values are saved 1 all the instantaneous images are written (€£)
1189
+
1190
+ spiv.RigaPart=OUT.x # Starting row (€£)
1191
+ spiv.ColPart=OUT.y # Starting Col (€£)
1192
+ dP.ImgH=OUT.H # Ending row
1193
+ dP.ImgW=OUT.W # Starting Col
1194
+ # % *********************** Process parameters
1195
+ dP.FlagZonaCom=0 # Flag for common zone should be equal to 0
1196
+ # Volume ********************************
1197
+ dP.xinfZC = OUT.x_min # minimum x world coordinates
1198
+ dP.yinfZC = OUT.y_min # minimum y world coordinates
1199
+ dP.xsupZC = OUT.x_max # maximum x world coordinates
1200
+ dP.ysupZC = OUT.y_max # maximum y world coordinates
1201
+ spiv.FlagRis=OUT.unit # 0 displacements in m/s 1 in pixels
1202
+ spiv.dt=OUT.dt # time separation. If the displacements in mm are needed use 1000 (and 0 for the previous parameter)
1203
+ spiv.Sfas=3 # in case of images in a single file the distance between images. Normally define the name (€£)
1204
+ # 1=a,b (after number); 2=_1,_2 (after number); 3=a,b (before number)
1205
+ # % Output
1206
+ spiv.FlagRotImg=0 # Rotation of the img 0=no rot 1=90°, 2=180° 3= 270° clockwise (£€)
1207
+ inPiv.FlagLog=9 # 0=no 1=video 2=log 3=video e log 4=Log short 5=video e log short (£€)
1208
+ spiv.StatFlag =0 # stat on: 1 all the vectors 0 only the good ones
1209
+ spiv.nomecfgPiv ='' # name of the cfg file for PIV
1210
+
1211
+ # ******************************
1212
+ flagReadCalConst=0# if true internal reading
1213
+ if flagReadCalConst:
1214
+ StereoPIV.readCalConst()
1215
+ else:
1216
+ c=0
1217
+ cost=[]
1218
+ for c in range(2):
1219
+ fileName=data.calList[c]
1220
+ flagCal,numCostCalib,costDum=readCalFile(fileName)
1221
+ if c==0:
1222
+ dP.FlagCal=flagCal
1223
+ dP.NumCostCalib=numCostCalib
1224
+ else:
1225
+ if (dP.FlagCal!=flagCal):
1226
+ raise('error the two calibration file are not compatible')
1227
+ cost.append(costDum)
1228
+ StereoPIV.setCalConst( flagCal, numCostCalib,cost)
1229
+
1230
+ StereoPIV.vect.PianoLaser[0]=np.float32(data.OUT_dict['zconst'])
1231
+ StereoPIV.vect.PianoLaser[1]=np.float32(data.OUT_dict['xterm'])
1232
+ StereoPIV.vect.PianoLaser[2]=np.float32(data.OUT_dict['yterm'])
1233
+ """
1234
+ flagReadPlaneConst=0# if true internal reading
1235
+ if flagReadPlaneConst:
1236
+ if StereoPIV.readPlaneConst()==0:
1237
+ pri.Callback.green('Laser plane constants correclty read!')
1238
+ else:
1239
+ pri.Error.red('Error while reading the file containing the laser plane constants!')
1240
+ data.laserConst=[const for const in StereoPIV.vect.PianoLaser]
1241
+ else:
1242
+ StereoPIV.vect.PianoLaser[0]=data.laserConst[0]
1243
+ StereoPIV.vect.PianoLaser[1]=data.laserConst[1]
1244
+ StereoPIV.vect.PianoLaser[2]=data.laserConst[2]
1245
+ #piv *******************************************************************************
1246
+ """
1247
+ #StereoPIV.readCfgProc(spiv.nomecfgPiv)
1248
+ return StereoPIV
1249
+
1250
+ def data2Disp(data:dataTreePar):
1251
+ OUT=OUTpar()
1252
+ OUT.copyfromdiz(data.OUT_dict)
1253
+ PRO_Disp=PROpar_Disp()
1254
+ PRO_Disp.copyfromdiz(data.PRO_Disp_dict)
1255
+
1256
+ Disp=PaIRS_lib.StereoDisp()
1257
+ spiv=Disp.SPIVIn
1258
+ dP=Disp.dataProc
1259
+ dAC=Disp.dispAvCo
1260
+
1261
+ spiv.nomecal='' #os.path.splitext(os.path.basename(INP.calList[0])) # Root of calibration constants
1262
+ spiv.percorsocal='' #os.path.dirname(INP.calList[0]) #Path of calibration constants
1263
+ spiv.ImgRoot='' # Root input Images
1264
+ spiv.InExt='' # Extension of the images
1265
+ spiv.InDir='' #Path of the images
1266
+ spiv.FirstImg=0 # # of first img to be processed
1267
+ spiv.LastImg=0 # # of first last to be processed
1268
+ spiv.Digit=0 # number of figures i.e. zeros (MAX 10)
1269
+
1270
+ spiv.RigaPart=OUT.y # Starting row
1271
+ spiv.ColPart=OUT.x # Starting column
1272
+ dP.ImgH=OUT.h # Ending row
1273
+ dP.ImgW=OUT.w # Starting row
1274
+ spiv.Sfas=1 # Sfasamento sub-immagini (righe a partire dall'origine): 0 per singola img: 1=a,b (finali); 2=_1,_2 (finali); 3=a,b (prima del numero sequenziale
1275
+ spiv.FlagImgTau=data.dispFrames # Img da processare: 0-entrambe; 1-solo la prima; 2-solo la seconda;PARAMETRO IGNORATO SE SFAS=0
1276
+
1277
+ #Output
1278
+ spiv.OutRoot = OUT.root # Root of output Files
1279
+ spiv.OutDir = OUT.path+OUT.subfold # Output path
1280
+ # Process parameters **********************
1281
+ dP.FlagInt=PRO_Disp.IntIniz # Metodo di raddrizzamento: 0=veloce (simp.), 1=quad…….
1282
+ dP.FlagZonaCom=0 # Flag per la zona comune: 0=coordinate nel piano oggetto; 1=coord. nel piano img
1283
+ spiv.Niter=PRO_Disp.Nit # Numero di iterazioni
1284
+ """
1285
+ if (spiv.Niter < 0) :
1286
+ spiv.WrtFlag = 1
1287
+ spiv.Niter = -spiv.Niter
1288
+ else:
1289
+ spiv.WrtFlag = 0
1290
+ """
1291
+
1292
+ dAC.HCella=PRO_Disp.Vect[0] # Correlation window Height
1293
+ dAC.WCella=PRO_Disp.Vect[2] # Correlation window Width
1294
+ dAC.HGrid=PRO_Disp.Vect[1] # Grid distance vertical
1295
+ dAC.WGrid=PRO_Disp.Vect[3] # Grid distance horizontal
1296
+ dAC.N_NormEpi=PRO_Disp.SemiWidth_Epipolar # Semiwidth in the direction normal to the epipolar line
1297
+ dAC.RaggioFiltro=PRO_Disp.Filter_SemiWidth # Semiwidth of the filter for the detection of the maximum in the displacement map
1298
+ dAC.SogliaCor = PRO_Disp.Threshold # Threshold for the determination of point used in the baricentric search of the maximum in the disp map
1299
+ dAC.nIterMaxValid = PRO_Disp.Nit_OutDet
1300
+ dAC.numStd = PRO_Disp.Std_Threshold
1301
+
1302
+ #%% Volume ********************************
1303
+ dP.xinfZC = OUT.x_min # Coordinata x inferiore
1304
+ dP.yinfZC = OUT.y_min # Coordinata y inferiore
1305
+ dP.xsupZC = OUT.x_max #28 # Coordinata x superiore
1306
+ dP.ysupZC = OUT.y_max #15 # Coordinata y superiore
1307
+ # ******************************
1308
+ flagReadCalConst=0# if true internal reading
1309
+ if flagReadCalConst:
1310
+ Disp.readCalConst()
1311
+ else:
1312
+ c=0
1313
+ cost=[]
1314
+ for c in range(2):
1315
+ fileName=data.calList[c]
1316
+ flagCal,numCostCalib,costDum=readCalFile(fileName)
1317
+ if c==0:
1318
+ dP.FlagCal=flagCal
1319
+ dP.NumCostCalib=numCostCalib
1320
+ else:
1321
+ if (dP.FlagCal!=flagCal):
1322
+ raise('error the two calibration file are not compatible')
1323
+ cost.append(costDum)
1324
+ Disp.setCalConst( flagCal, numCostCalib,cost)
1325
+
1326
+ flagReadPlaneConst=0# if true internal reading
1327
+ if flagReadPlaneConst:
1328
+ if Disp.readPlaneConst()==0:
1329
+ pri.Callback.green('readPlaneConst ok')
1330
+ else:
1331
+ Disp.vect.PianoLaser[0]=0
1332
+ Disp.vect.PianoLaser[1]=0
1333
+ Disp.vect.PianoLaser[2]=0
1334
+ return Disp
1335
+
1336
+ def printPIVLog(PD):
1337
+ stampa="It IW #IW #Vect/#Tot % CC CC(avg) DC%\n"# NR% Cap%\n"
1338
+ for j in range(len(PD.It)):
1339
+ riga="%3d %3dx%-3d %4dx%-4d %7d/%-7d %5.1f %8.7f %8.7f %4.1f\n" %\
1340
+ (PD.It[j], PD.WCella[j], PD.HCella[j], PD.W[j], PD.H[j], PD.NVect[j],\
1341
+ PD.W[j]*PD.H[j], 100.0*PD.NVect[j]/(PD.W[j]*PD.H[j]), PD.Fc[j],\
1342
+ PD.FcMedia[j], 100.0*PD.ContErorreDc[j]/(PD.W[j]*PD.H[j]))#,\
1343
+ #100.0*PIV.PD.ContRemNoise[j]/(PIV.Inp.ImgW*PIV.Inp.ImgH),\
1344
+ #100.0*PIV.PD.ContCap[j]/(PIV.Inp.ImgW*PIV.Inp.ImgH))
1345
+ stampa=stampa+riga
1346
+ return stampa
1347
+
1348
+
1349
+ def saveMin(data:dataTreePar,Imin=list):
1350
+ pri.Time.magenta('saveMin Init ')
1351
+ frames='ab'
1352
+ #nImg=1 if self.flag_TR else 2
1353
+ #nImg=2
1354
+ for j in range(len(Imin)):
1355
+ k=j%data.nframe
1356
+ cam=j//data.nframe%data.ncam
1357
+ name_min=f"{data.outPathRoot}_cam{cam+1}_{frames[k]}_min.png"
1358
+ im = Image.fromarray(Imin[j])
1359
+ im.save(name_min)
1360
+ pri.Time.magenta('saveMin End')
1361
+
1362
+ def saveResults(data:dataTreePar,i,Var,nameVar):
1363
+ #pri.Time.magenta('saveResults Init')
1364
+ if type(i)==int:
1365
+ if i<0:
1366
+ nameFileOut=data.resF('*').replace('_*','')
1367
+ else:
1368
+ nameFileOut=data.resF(i)
1369
+ elif type(i)==str:
1370
+ nameFileOut=data.resF(i)
1371
+ #infoPrint.white(f'---> Saving field #{i}: {nameFileOut}')
1372
+
1373
+ if '.plt' in data.outExt:
1374
+ writePlt(nameFileOut,Var,f'PaIRS - 2D PIV',nameVar,nameFileOut)
1375
+ elif '.mat' in data.outExt:
1376
+ dict_out={}
1377
+ for j in range(len(nameVar)):
1378
+ dict_out[nameVar[j]]=Var[j]
1379
+ scipy.io.savemat(nameFileOut,dict_out)
1380
+ #import timeit
1381
+ #timeit.timeit (lambda :'writePlt(nameFileOut,Var,"b16",nameVar,nameFileOut)')
1382
+ #timeit.timeit (lambda :'scipy.io.savemat(nameFileOut,dict_out)')
1383
+ #pri.Time.magenta('saveResults End')
1384
+ return
1385
+
1386
+ def memoryUsagePsutil():
1387
+ ''' return the memory usage in MB '''
1388
+ process = psutil.Process(os.getpid())
1389
+ mem = process.memory_info().rss
1390
+ #print(f"Memory={mem/ float(2 ** 20)}MByte")
1391
+ return mem