PaIRS-UniNa 0.2.9__cp310-cp310-macosx_11_0_universal2.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 (333) hide show
  1. PaIRS_UniNa/Calibration_Tab.py +346 -0
  2. PaIRS_UniNa/Changes.txt +162 -0
  3. PaIRS_UniNa/Custom_Top.py +303 -0
  4. PaIRS_UniNa/Explorer.py +3168 -0
  5. PaIRS_UniNa/FolderLoop.py +562 -0
  6. PaIRS_UniNa/Input_Tab.py +831 -0
  7. PaIRS_UniNa/Input_Tab_CalVi.py +786 -0
  8. PaIRS_UniNa/Input_Tab_tools.py +3022 -0
  9. PaIRS_UniNa/Log_Tab.py +110 -0
  10. PaIRS_UniNa/Output_Tab.py +922 -0
  11. PaIRS_UniNa/PaIRS.py +18 -0
  12. PaIRS_UniNa/PaIRS_PIV.py +873 -0
  13. PaIRS_UniNa/PaIRS_pypacks.py +1421 -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/SPIVCalHelp.py +155 -0
  20. PaIRS_UniNa/Saving_tools.py +296 -0
  21. PaIRS_UniNa/TabTools.py +1254 -0
  22. PaIRS_UniNa/Vis_Tab.py +2169 -0
  23. PaIRS_UniNa/Vis_Tab_CalVi.py +983 -0
  24. PaIRS_UniNa/Whatsnew.py +130 -0
  25. PaIRS_UniNa/_PaIRS_PIV.so +0 -0
  26. PaIRS_UniNa/__init__.py +6 -0
  27. PaIRS_UniNa/__main__.py +45 -0
  28. PaIRS_UniNa/addwidgets_ps.py +1133 -0
  29. PaIRS_UniNa/calib.py +1488 -0
  30. PaIRS_UniNa/calibView.py +833 -0
  31. PaIRS_UniNa/gPaIRS.py +3914 -0
  32. PaIRS_UniNa/gPalette.py +189 -0
  33. PaIRS_UniNa/icons/abort.png +0 -0
  34. PaIRS_UniNa/icons/about.png +0 -0
  35. PaIRS_UniNa/icons/align_all.png +0 -0
  36. PaIRS_UniNa/icons/announcement.png +0 -0
  37. PaIRS_UniNa/icons/automatic_levels_off.png +0 -0
  38. PaIRS_UniNa/icons/automatic_levels_on.png +0 -0
  39. PaIRS_UniNa/icons/automatic_off.png +0 -0
  40. PaIRS_UniNa/icons/automatic_on.png +0 -0
  41. PaIRS_UniNa/icons/automatic_size_off.png +0 -0
  42. PaIRS_UniNa/icons/automatic_size_on.png +0 -0
  43. PaIRS_UniNa/icons/axes.png +0 -0
  44. PaIRS_UniNa/icons/background.png +0 -0
  45. PaIRS_UniNa/icons/background_vectors.png +0 -0
  46. PaIRS_UniNa/icons/bin_off.png +0 -0
  47. PaIRS_UniNa/icons/bin_on.png +0 -0
  48. PaIRS_UniNa/icons/browse_file_c.png +0 -0
  49. PaIRS_UniNa/icons/browse_folder_c.png +0 -0
  50. PaIRS_UniNa/icons/brush_cursor.png +0 -0
  51. PaIRS_UniNa/icons/bugfix.png +0 -0
  52. PaIRS_UniNa/icons/cal_proc.png +0 -0
  53. PaIRS_UniNa/icons/cal_proc_off.png +0 -0
  54. PaIRS_UniNa/icons/cal_step.png +0 -0
  55. PaIRS_UniNa/icons/cal_step_off.png +0 -0
  56. PaIRS_UniNa/icons/calibrate.png +0 -0
  57. PaIRS_UniNa/icons/calibration_logo.png +0 -0
  58. PaIRS_UniNa/icons/change_folder.png +0 -0
  59. PaIRS_UniNa/icons/change_folder_off.png +0 -0
  60. PaIRS_UniNa/icons/checklist.png +0 -0
  61. PaIRS_UniNa/icons/clean.png +0 -0
  62. PaIRS_UniNa/icons/clean_run.png +0 -0
  63. PaIRS_UniNa/icons/close.png +0 -0
  64. PaIRS_UniNa/icons/close_all.png +0 -0
  65. PaIRS_UniNa/icons/close_project.png +0 -0
  66. PaIRS_UniNa/icons/close_workspace.png +0 -0
  67. PaIRS_UniNa/icons/colormap.png +0 -0
  68. PaIRS_UniNa/icons/colormaps/Accent.png +0 -0
  69. PaIRS_UniNa/icons/colormaps/BrBG.png +0 -0
  70. PaIRS_UniNa/icons/colormaps/Dark2.png +0 -0
  71. PaIRS_UniNa/icons/colormaps/PRGn.png +0 -0
  72. PaIRS_UniNa/icons/colormaps/Paired.png +0 -0
  73. PaIRS_UniNa/icons/colormaps/Pastel1.png +0 -0
  74. PaIRS_UniNa/icons/colormaps/Pastel2.png +0 -0
  75. PaIRS_UniNa/icons/colormaps/PiYG.png +0 -0
  76. PaIRS_UniNa/icons/colormaps/PuOr.png +0 -0
  77. PaIRS_UniNa/icons/colormaps/RdBu.png +0 -0
  78. PaIRS_UniNa/icons/colormaps/RdGy.png +0 -0
  79. PaIRS_UniNa/icons/colormaps/RdYlBu.png +0 -0
  80. PaIRS_UniNa/icons/colormaps/RdYlGn.png +0 -0
  81. PaIRS_UniNa/icons/colormaps/Set1.png +0 -0
  82. PaIRS_UniNa/icons/colormaps/Set2.png +0 -0
  83. PaIRS_UniNa/icons/colormaps/Set3.png +0 -0
  84. PaIRS_UniNa/icons/colormaps/Spectral.png +0 -0
  85. PaIRS_UniNa/icons/colormaps/Wistia.png +0 -0
  86. PaIRS_UniNa/icons/colormaps/afmhot.png +0 -0
  87. PaIRS_UniNa/icons/colormaps/autumn.png +0 -0
  88. PaIRS_UniNa/icons/colormaps/binary.png +0 -0
  89. PaIRS_UniNa/icons/colormaps/blackVector.png +0 -0
  90. PaIRS_UniNa/icons/colormaps/blueVector.png +0 -0
  91. PaIRS_UniNa/icons/colormaps/bone.png +0 -0
  92. PaIRS_UniNa/icons/colormaps/brg.png +0 -0
  93. PaIRS_UniNa/icons/colormaps/bwr.png +0 -0
  94. PaIRS_UniNa/icons/colormaps/cividis.png +0 -0
  95. PaIRS_UniNa/icons/colormaps/cool.png +0 -0
  96. PaIRS_UniNa/icons/colormaps/coolwarm.png +0 -0
  97. PaIRS_UniNa/icons/colormaps/copper.png +0 -0
  98. PaIRS_UniNa/icons/colormaps/cubehelix.png +0 -0
  99. PaIRS_UniNa/icons/colormaps/cyanVector.png +0 -0
  100. PaIRS_UniNa/icons/colormaps/flag.png +0 -0
  101. PaIRS_UniNa/icons/colormaps/gist_heat.png +0 -0
  102. PaIRS_UniNa/icons/colormaps/gray.png +0 -0
  103. PaIRS_UniNa/icons/colormaps/greenVector.png +0 -0
  104. PaIRS_UniNa/icons/colormaps/hot.png +0 -0
  105. PaIRS_UniNa/icons/colormaps/hsv.png +0 -0
  106. PaIRS_UniNa/icons/colormaps/inferno.png +0 -0
  107. PaIRS_UniNa/icons/colormaps/jet.png +0 -0
  108. PaIRS_UniNa/icons/colormaps/magentaVector.png +0 -0
  109. PaIRS_UniNa/icons/colormaps/magma.png +0 -0
  110. PaIRS_UniNa/icons/colormaps/ocean.png +0 -0
  111. PaIRS_UniNa/icons/colormaps/pink.png +0 -0
  112. PaIRS_UniNa/icons/colormaps/plasma.png +0 -0
  113. PaIRS_UniNa/icons/colormaps/prism.png +0 -0
  114. PaIRS_UniNa/icons/colormaps/rainbow.png +0 -0
  115. PaIRS_UniNa/icons/colormaps/redVector.png +0 -0
  116. PaIRS_UniNa/icons/colormaps/seismic.png +0 -0
  117. PaIRS_UniNa/icons/colormaps/spring.png +0 -0
  118. PaIRS_UniNa/icons/colormaps/summer.png +0 -0
  119. PaIRS_UniNa/icons/colormaps/tab10.png +0 -0
  120. PaIRS_UniNa/icons/colormaps/tab20.png +0 -0
  121. PaIRS_UniNa/icons/colormaps/tab20b.png +0 -0
  122. PaIRS_UniNa/icons/colormaps/tab20c.png +0 -0
  123. PaIRS_UniNa/icons/colormaps/terrain.png +0 -0
  124. PaIRS_UniNa/icons/colormaps/twilight.png +0 -0
  125. PaIRS_UniNa/icons/colormaps/viridis.png +0 -0
  126. PaIRS_UniNa/icons/colormaps/whiteVector.png +0 -0
  127. PaIRS_UniNa/icons/colormaps/winter.png +0 -0
  128. PaIRS_UniNa/icons/colormaps/yellowVector.png +0 -0
  129. PaIRS_UniNa/icons/common_region.png +0 -0
  130. PaIRS_UniNa/icons/common_region_off.png +0 -0
  131. PaIRS_UniNa/icons/completed.png +0 -0
  132. PaIRS_UniNa/icons/contourf_off.png +0 -0
  133. PaIRS_UniNa/icons/contourf_on.png +0 -0
  134. PaIRS_UniNa/icons/copy.png +0 -0
  135. PaIRS_UniNa/icons/copy_process.png +0 -0
  136. PaIRS_UniNa/icons/copy_process_off.png +0 -0
  137. PaIRS_UniNa/icons/copygrid.png +0 -0
  138. PaIRS_UniNa/icons/cursor_lamp.png +0 -0
  139. PaIRS_UniNa/icons/cut.png +0 -0
  140. PaIRS_UniNa/icons/cut_warnings.png +0 -0
  141. PaIRS_UniNa/icons/darkmode.png +0 -0
  142. PaIRS_UniNa/icons/debug_run.png +0 -0
  143. PaIRS_UniNa/icons/delete.png +0 -0
  144. PaIRS_UniNa/icons/deleteErr.png +0 -0
  145. PaIRS_UniNa/icons/disp_step.png +0 -0
  146. PaIRS_UniNa/icons/disp_step_off.png +0 -0
  147. PaIRS_UniNa/icons/down.png +0 -0
  148. PaIRS_UniNa/icons/edit_list.png +0 -0
  149. PaIRS_UniNa/icons/editing.png +0 -0
  150. PaIRS_UniNa/icons/example_list.png +0 -0
  151. PaIRS_UniNa/icons/find_all_planes.png +0 -0
  152. PaIRS_UniNa/icons/find_plane.png +0 -0
  153. PaIRS_UniNa/icons/flaticon_PaIRS.png +0 -0
  154. PaIRS_UniNa/icons/flaticon_PaIRS_beta.png +0 -0
  155. PaIRS_UniNa/icons/flaticon_PaIRS_download.png +0 -0
  156. PaIRS_UniNa/icons/flaticon_PaIRS_download_warning.png +0 -0
  157. PaIRS_UniNa/icons/flip_y_off.png +0 -0
  158. PaIRS_UniNa/icons/flip_y_on.png +0 -0
  159. PaIRS_UniNa/icons/focusErrr.png +0 -0
  160. PaIRS_UniNa/icons/folder_loop_cleanup.png +0 -0
  161. PaIRS_UniNa/icons/folder_loop_cleanup_off.png +0 -0
  162. PaIRS_UniNa/icons/gear.gif +0 -0
  163. PaIRS_UniNa/icons/gear.png +0 -0
  164. PaIRS_UniNa/icons/ger.png +0 -0
  165. PaIRS_UniNa/icons/greenv.png +0 -0
  166. PaIRS_UniNa/icons/guide.png +0 -0
  167. PaIRS_UniNa/icons/icon_CalVi.png +0 -0
  168. PaIRS_UniNa/icons/icon_PaIRS.png +0 -0
  169. PaIRS_UniNa/icons/import.png +0 -0
  170. PaIRS_UniNa/icons/import_set.png +0 -0
  171. PaIRS_UniNa/icons/information.png +0 -0
  172. PaIRS_UniNa/icons/information2.png +0 -0
  173. PaIRS_UniNa/icons/input_logo.png +0 -0
  174. PaIRS_UniNa/icons/issue.png +0 -0
  175. PaIRS_UniNa/icons/laser_NTR.png +0 -0
  176. PaIRS_UniNa/icons/laser_TR_double.png +0 -0
  177. PaIRS_UniNa/icons/laser_TR_single.png +0 -0
  178. PaIRS_UniNa/icons/link.png +0 -0
  179. PaIRS_UniNa/icons/linked.png +0 -0
  180. PaIRS_UniNa/icons/loaded.png +0 -0
  181. PaIRS_UniNa/icons/loading_2.gif +0 -0
  182. PaIRS_UniNa/icons/log_logo.png +0 -0
  183. PaIRS_UniNa/icons/logo_CalVi.png +0 -0
  184. PaIRS_UniNa/icons/logo_CalVi_completo.png +0 -0
  185. PaIRS_UniNa/icons/logo_CalVi_party.png +0 -0
  186. PaIRS_UniNa/icons/logo_PaIRS.png +0 -0
  187. PaIRS_UniNa/icons/logo_PaIRS_completo.png +0 -0
  188. PaIRS_UniNa/icons/logo_PaIRS_download.png +0 -0
  189. PaIRS_UniNa/icons/logo_PaIRS_party_rect.png +0 -0
  190. PaIRS_UniNa/icons/logo_PaIRS_rect.png +0 -0
  191. PaIRS_UniNa/icons/logo_opaco.png +0 -0
  192. PaIRS_UniNa/icons/mask.png +0 -0
  193. PaIRS_UniNa/icons/measure.png +0 -0
  194. PaIRS_UniNa/icons/measure_off.png +0 -0
  195. PaIRS_UniNa/icons/min_proc.png +0 -0
  196. PaIRS_UniNa/icons/min_proc_off.png +0 -0
  197. PaIRS_UniNa/icons/min_step.png +0 -0
  198. PaIRS_UniNa/icons/min_step_off.png +0 -0
  199. PaIRS_UniNa/icons/minus.png +0 -0
  200. PaIRS_UniNa/icons/mirror_u.png +0 -0
  201. PaIRS_UniNa/icons/mirror_v.png +0 -0
  202. PaIRS_UniNa/icons/mirror_x.png +0 -0
  203. PaIRS_UniNa/icons/mirror_y.png +0 -0
  204. PaIRS_UniNa/icons/mtplt.png +0 -0
  205. PaIRS_UniNa/icons/new.png +0 -0
  206. PaIRS_UniNa/icons/new_workspace.png +0 -0
  207. PaIRS_UniNa/icons/news.png +0 -0
  208. PaIRS_UniNa/icons/normal_run.png +0 -0
  209. PaIRS_UniNa/icons/open.png +0 -0
  210. PaIRS_UniNa/icons/open_image.png +0 -0
  211. PaIRS_UniNa/icons/open_new_window.png +0 -0
  212. PaIRS_UniNa/icons/open_result.png +0 -0
  213. PaIRS_UniNa/icons/open_workspace.png +0 -0
  214. PaIRS_UniNa/icons/output_logo.png +0 -0
  215. PaIRS_UniNa/icons/paste_above.png +0 -0
  216. PaIRS_UniNa/icons/paste_below.png +0 -0
  217. PaIRS_UniNa/icons/pause.png +0 -0
  218. PaIRS_UniNa/icons/paused.png +0 -0
  219. PaIRS_UniNa/icons/pencil_bw.png +0 -0
  220. PaIRS_UniNa/icons/piv_proc.png +0 -0
  221. PaIRS_UniNa/icons/piv_proc_off.png +0 -0
  222. PaIRS_UniNa/icons/piv_step.png +0 -0
  223. PaIRS_UniNa/icons/piv_step_off.png +0 -0
  224. PaIRS_UniNa/icons/plane.png +0 -0
  225. PaIRS_UniNa/icons/play.png +0 -0
  226. PaIRS_UniNa/icons/plus.png +0 -0
  227. PaIRS_UniNa/icons/process_logo.png +0 -0
  228. PaIRS_UniNa/icons/process_loop.png +0 -0
  229. PaIRS_UniNa/icons/project.png +0 -0
  230. PaIRS_UniNa/icons/pylog.png +0 -0
  231. PaIRS_UniNa/icons/python_warning.png +0 -0
  232. PaIRS_UniNa/icons/queue.png +0 -0
  233. PaIRS_UniNa/icons/quit.png +0 -0
  234. PaIRS_UniNa/icons/read.png +0 -0
  235. PaIRS_UniNa/icons/read_list.png +0 -0
  236. PaIRS_UniNa/icons/redo.png +0 -0
  237. PaIRS_UniNa/icons/redx.png +0 -0
  238. PaIRS_UniNa/icons/reset.png +0 -0
  239. PaIRS_UniNa/icons/reset_levels.png +0 -0
  240. PaIRS_UniNa/icons/resize_icon.png +0 -0
  241. PaIRS_UniNa/icons/restore.png +0 -0
  242. PaIRS_UniNa/icons/restore_undo.png +0 -0
  243. PaIRS_UniNa/icons/rotate_clock.png +0 -0
  244. PaIRS_UniNa/icons/rotate_counter.png +0 -0
  245. PaIRS_UniNa/icons/rotate_v_clock.png +0 -0
  246. PaIRS_UniNa/icons/rotate_v_counter.png +0 -0
  247. PaIRS_UniNa/icons/running.gif +0 -0
  248. PaIRS_UniNa/icons/running.png +0 -0
  249. PaIRS_UniNa/icons/running_warn.png +0 -0
  250. PaIRS_UniNa/icons/sandglass.png +0 -0
  251. PaIRS_UniNa/icons/save.png +0 -0
  252. PaIRS_UniNa/icons/save_and_stop.png +0 -0
  253. PaIRS_UniNa/icons/save_cfg.png +0 -0
  254. PaIRS_UniNa/icons/saveas.png +0 -0
  255. PaIRS_UniNa/icons/saveas_workspace.png +0 -0
  256. PaIRS_UniNa/icons/scale_all.png +0 -0
  257. PaIRS_UniNa/icons/scale_down.png +0 -0
  258. PaIRS_UniNa/icons/scale_up.png +0 -0
  259. PaIRS_UniNa/icons/scan_list.png +0 -0
  260. PaIRS_UniNa/icons/scan_path.png +0 -0
  261. PaIRS_UniNa/icons/scan_path_loop.png +0 -0
  262. PaIRS_UniNa/icons/scan_path_loop_off.png +0 -0
  263. PaIRS_UniNa/icons/search.png +0 -0
  264. PaIRS_UniNa/icons/showIW_off.png +0 -0
  265. PaIRS_UniNa/icons/showIW_on.png +0 -0
  266. PaIRS_UniNa/icons/show_all.png +0 -0
  267. PaIRS_UniNa/icons/sort.png +0 -0
  268. PaIRS_UniNa/icons/sort_reversed.png +0 -0
  269. PaIRS_UniNa/icons/spiv_proc.png +0 -0
  270. PaIRS_UniNa/icons/spiv_proc_off.png +0 -0
  271. PaIRS_UniNa/icons/spiv_setup_no.png +0 -0
  272. PaIRS_UniNa/icons/spiv_setup_ok.png +0 -0
  273. PaIRS_UniNa/icons/star.png +0 -0
  274. PaIRS_UniNa/icons/step_inheritance.png +0 -0
  275. PaIRS_UniNa/icons/subMIN_off.png +0 -0
  276. PaIRS_UniNa/icons/subMIN_on.png +0 -0
  277. PaIRS_UniNa/icons/tom.png +0 -0
  278. PaIRS_UniNa/icons/trash.png +0 -0
  279. PaIRS_UniNa/icons/undo.png +0 -0
  280. PaIRS_UniNa/icons/unedited.png +0 -0
  281. PaIRS_UniNa/icons/unina_dii.png +0 -0
  282. PaIRS_UniNa/icons/uninitialized.png +0 -0
  283. PaIRS_UniNa/icons/unlink.png +0 -0
  284. PaIRS_UniNa/icons/unwrap_items.png +0 -0
  285. PaIRS_UniNa/icons/up.png +0 -0
  286. PaIRS_UniNa/icons/updating_import.gif +0 -0
  287. PaIRS_UniNa/icons/updating_pairs.gif +0 -0
  288. PaIRS_UniNa/icons/vectorColor.png +0 -0
  289. PaIRS_UniNa/icons/vettore.png +0 -0
  290. PaIRS_UniNa/icons/view.png +0 -0
  291. PaIRS_UniNa/icons/view_off.png +0 -0
  292. PaIRS_UniNa/icons/vis_logo.png +0 -0
  293. PaIRS_UniNa/icons/waiting_circle.png +0 -0
  294. PaIRS_UniNa/icons/warning.png +0 -0
  295. PaIRS_UniNa/icons/warning_circle.png +0 -0
  296. PaIRS_UniNa/icons/window.png +0 -0
  297. PaIRS_UniNa/icons/workspace.png +0 -0
  298. PaIRS_UniNa/icons/wrap_items.png +0 -0
  299. PaIRS_UniNa/icons/write_list.png +0 -0
  300. PaIRS_UniNa/listLib.py +303 -0
  301. PaIRS_UniNa/mtfPIV.py +256 -0
  302. PaIRS_UniNa/parForMulti.py +435 -0
  303. PaIRS_UniNa/parForWorkers.py +593 -0
  304. PaIRS_UniNa/pivParFor.py +235 -0
  305. PaIRS_UniNa/plt_util.py +141 -0
  306. PaIRS_UniNa/preProcParFor.py +155 -0
  307. PaIRS_UniNa/procTools.py +1439 -0
  308. PaIRS_UniNa/readcfg.py +52 -0
  309. PaIRS_UniNa/rqrdpckgs.txt +9 -0
  310. PaIRS_UniNa/stereoPivParFor.py +227 -0
  311. PaIRS_UniNa/tAVarie.py +215 -0
  312. PaIRS_UniNa/tabSplitter.py +612 -0
  313. PaIRS_UniNa/ui_Calibration_Tab.py +578 -0
  314. PaIRS_UniNa/ui_Custom_Top.py +296 -0
  315. PaIRS_UniNa/ui_Input_Tab.py +1101 -0
  316. PaIRS_UniNa/ui_Input_Tab_CalVi.py +1283 -0
  317. PaIRS_UniNa/ui_Log_Tab.py +263 -0
  318. PaIRS_UniNa/ui_Output_Tab.py +2362 -0
  319. PaIRS_UniNa/ui_Process_Tab.py +3810 -0
  320. PaIRS_UniNa/ui_Process_Tab_CalVi.py +1549 -0
  321. PaIRS_UniNa/ui_Process_Tab_Disp.py +1141 -0
  322. PaIRS_UniNa/ui_Process_Tab_Min.py +437 -0
  323. PaIRS_UniNa/ui_ResizePopup.py +204 -0
  324. PaIRS_UniNa/ui_Vis_Tab.py +1628 -0
  325. PaIRS_UniNa/ui_Vis_Tab_CalVi.py +1251 -0
  326. PaIRS_UniNa/ui_Whatsnew.py +132 -0
  327. PaIRS_UniNa/ui_gPairs.py +877 -0
  328. PaIRS_UniNa/ui_infoPaIRS.py +551 -0
  329. PaIRS_UniNa/whatsnew.txt +6 -0
  330. pairs_unina-0.2.9.dist-info/METADATA +166 -0
  331. pairs_unina-0.2.9.dist-info/RECORD +333 -0
  332. pairs_unina-0.2.9.dist-info/WHEEL +5 -0
  333. pairs_unina-0.2.9.dist-info/top_level.txt +2 -0
PaIRS_UniNa/mtfPIV.py ADDED
@@ -0,0 +1,256 @@
1
+ ''' '''
2
+ import numpy as np
3
+ import matplotlib.pyplot as plt
4
+ from math import factorial
5
+ def winLoc(H, winType ):
6
+ '''
7
+ Returns the WW
8
+ '''
9
+ datBlack = [ [0.42, 0.5, 0.08, 0.],
10
+ [7938. / 18608, 9240. / 18608, 1430. / 18608, 0.0],
11
+ [0.42323 , 0.49755 , 0.07922 , 0.0],
12
+ [0.44959, 0.49364 , 0.05677 , 0.0],
13
+ [0.35875 , 0.48829 , 0.14128 , 0.01168],
14
+ [0.40217 , 0.49703 , 0.09392 , 0.00183]]
15
+ nameBlack = ('Edged Blackman', 'Exact Blackman', 'Harris 3 term -67', 'Harris 3 term -61', 'Harris 4 term -92', 'Harris 4 term -74')
16
+ sCutBlack = ('EBL', 'ExBL', 'HA67', 'HA61', 'HA92', 'HA74' )
17
+ # if needed insert the type *************************
18
+ i=np.arange(0,H)
19
+
20
+ if winType==0: #no win
21
+ win=np.ones(H)
22
+ name='Top Hat'
23
+ sCut='TH'
24
+ elif winType==1: #Nogueira
25
+ WH = abs((H - 1) / 2.0 - i) / H
26
+ win= (4*WH*WH - 4*WH+1)
27
+ name='Nogueira 1999'
28
+ sCut='NOG'
29
+ elif winType==2: # Blackman ridotta
30
+ WH = (i+1) / (H+1)
31
+ win = (0.42 - 0.5*np.cos(2*np.pi*WH)+0.08*np.cos(4*np.pi*WH))
32
+ name='Blackman'
33
+ sCut='BL'
34
+ elif winType==3: # doppia finestra quadrata
35
+ lar = 0.25
36
+ WH = abs((H - 1) / 2.0 - i) / H
37
+ win =np.ones(H) # if needed insert the type *************************
38
+ win[WH > lar]= 0
39
+ name='Double TH'
40
+ sCut='DTH'
41
+ elif winType==4: # doppia finestra quadrata bordo 1
42
+ win =np.ones(H) # if needed insert the type *************************
43
+ win[0]= 0
44
+ win[-1]= 0
45
+ name='Edged TH'
46
+ sCut='ETH'
47
+ elif 5<=winType<=10: # Various Windows
48
+ ind = winType - 5
49
+ WH = i / (H - 1)
50
+ win = (datBlack[ind][0]-datBlack[ind][1]*np.cos(2*np.pi*WH)+datBlack[ind][2]*np.cos(4*np.pi*WH)-datBlack[ind][3]*np.cos(6*np.pi*WH))
51
+ name=nameBlack[ind]
52
+ sCut=sCutBlack[ind]
53
+ elif winType==21: # Nogueira new
54
+ WH = abs((H - 1) / 2.0 - i) / H
55
+ win = ((3*(4*WH*WH - 4*WH+1)+.15*np.cos(4*np.pi*WH)+.2*np.cos(6*np.pi*WH)+.1*np.cos(8*np.pi*WH)+.05*np.cos(10*np.pi*WH)) / 3.5)
56
+ name='Nogueira 2005'
57
+ sCut='NOG05'
58
+ elif winType==22: # Bartlett ridotta diversa da triang di matlab
59
+ ii=np.arange(0,(H+2) / 2-1,dtype=int)
60
+ WH = 2*abs((ii+1) / (H+1))
61
+ win=np.ones(H)
62
+ win[H - ii-1] =WH
63
+ win[ii] = WH
64
+ name='Triangular'
65
+ sCut='TR'
66
+ elif winType==23: # Hann ridotta
67
+ WH = (i+1) / (H+1)
68
+ win = (0.5 - 0.5*np.cos(2*np.pi*WH))
69
+ name='Hann'
70
+ sCut='HA'
71
+ elif 101<=winType<=200: # Gaussian
72
+ alpha = ((winType - 100.0) / 10.0)
73
+ WH = (2*alpha*((H - 1) / 2.0 - i) / H)
74
+ win = np.exp(-0.5*WH*WH)
75
+ #as=sprintf(f'{alpha,"#.1f"}')
76
+ name='Gaussian '+f'{alpha:.1f}'
77
+ sCut='GA'+f'{alpha:.1f}'
78
+ return (win,name,sCut)
79
+
80
+ def mtfSpline(o,n):
81
+ '''
82
+ n=order
83
+ see Frequency Domain Analysis of B-Spline Interpolation
84
+ by Zeljka MihajloviC*, Alan Goluban**, Mario Zagar**
85
+ doi:10.1109/ISIE.1999.801783
86
+ and of course Unser 1993 a and b
87
+ '''
88
+ k=np.arange(0,n+1)
89
+ fa=lambda k:np.array([factorial(v) for v in k ])
90
+
91
+ bSpline =lambda x: np.sum(( ((-1)**k)*(n+1)*((x+(n+1)/2-k)**n)*np.heaviside(x+(n+1)/2-k,1) )/(fa(k)*fa(n+1-k)))
92
+ aa=bSpline(0)
93
+ for kk in np.arange(1,n/2+1):
94
+ aa=aa+2*bSpline(kk)*np.cos(2*np.pi*kk*o)
95
+ mtf=np.sinc(o)**(n+1)/aa
96
+ return mtf
97
+
98
+ def mtfPIV1(Wa,FlagWindowing,hWb, FlagCalcVel,Wc, IntVel, oMaxC, WBase,nPointPlot,Niter,flagLambda):
99
+ '''
100
+ # Input **********************************
101
+ #Niter=[2 10 40 1000 inf]# Number of final iteration
102
+ #nPointPlot=1000
103
+ #WBase=16# scaltura plot
104
+ # A correlation window
105
+ #Wa=32
106
+ #FlagWindowing=0 # Weighting window for the correlation map (0=TopHat 1= Nogueira 2=Blackman 3=top hat at 50#).
107
+ # B weighted average
108
+ #FlagCalcVel=0 # Weighting window for absolute velocity (0=TopHat, 1=Nogueira, 2=Blackman,...)
109
+ #hWb=4# Half-width of the filtering window (0=window dimension).
110
+ # C dense predictor
111
+ #IntVel=1 # Type of interpolation of the velocity (1=bilinear, 52-70 Bspline)
112
+ #Wc=4 #Grid distance (overlap)
113
+ #oMax=0.5 # frequenza massima per c (legata all'overlap ov/lambda) non penso che abbia senso oltre 0,5 perchè
114
+ # andremmo oltre Nyquist
115
+ # flagLambda se =1 allora equispazia lambda con un massimo di WBase*4 normalizza il grafico fra
116
+ # same as done by PIV software
117
+ '''
118
+ if(np.mod(hWb,2)==1): #dispari
119
+ Wb=2*hWb-1
120
+ else:
121
+ if hWb==0:
122
+ Wb=Wa
123
+ else:
124
+ Wb=2*hWb
125
+
126
+
127
+
128
+ # Windows
129
+ [WinA,nameA,sCutA]=winLoc(Wa, FlagWindowing)
130
+ WinA=WinA/sum(WinA)
131
+ [WinB,nameB,sCutB]=winLoc(Wb, FlagCalcVel)
132
+ WinB=WinB/sum(WinB)
133
+
134
+ # omega W/lambda
135
+ if flagLambda:
136
+ lam=np.linspace(Wc/oMaxC,WBase*4,nPointPlot)
137
+ oC=Wc/lam
138
+ else:
139
+ oC=np.linspace(oMaxC/nPointPlot,oMaxC,nPointPlot)
140
+ lam=Wc/oC
141
+ oBase=oC*WBase/Wc
142
+ oA=oC*Wa/Wc
143
+ oB=oC*Wb/Wc
144
+ # Windows MTF *******
145
+ MTFWin=lambda Win,o,W: np.sum((np.tile(Win,(o.size,1))*np.cos(np.reshape(o, (-1, 1))*(2*np.pi*(np.arange(1,W+1)-W/2-0.5))/W)),1)
146
+ a=MTFWin(WinA,oA,Wa)
147
+ b=MTFWin(WinB,oB,Wb)
148
+
149
+
150
+
151
+ '''
152
+ for FlagWindowing=[0:10 21:23 101:10:200]
153
+ figure (1)clf
154
+ [WinA,nameA,sCutA]=winLoc(Wa, FlagWindowing)
155
+ plot(WinA)
156
+ title ([nameA,' -- ',sCutA])
157
+ pause
158
+ end
159
+ '''
160
+ # Interpolation MTF *******
161
+ if (IntVel==1):
162
+ c=(np.sin(np.pi*oC)/(Wc*np.sin(np.pi*oC/Wc)))**2
163
+ order=1
164
+ elif (52<=IntVel<=70):
165
+ c=mtfSpline(oC,IntVel-50)
166
+ order=IntVel-50
167
+ else:
168
+ c=1+0*oC
169
+ order=-1
170
+
171
+ # verify stability **********************
172
+ flagUnstable=0
173
+ if (np.sum(abs(c*(b-a))>1)!=0):
174
+ flagUnstable=1
175
+
176
+
177
+ # calc MTF **********************
178
+ MTF=np.zeros((Niter.size,oBase.size))
179
+ for j in range(Niter.size):
180
+ ii=Niter[j]
181
+ if(ii==np.inf):
182
+ MTF[j]=a/(1-(c*(b-a)))
183
+ else:
184
+ MTF[j]=a*(1-(c*(b-a))**ii)/(1-(c*(b-a)))
185
+
186
+ return (WinA,nameA,sCutA,Wa,WinB,nameB,sCutB,Wb, order,flagUnstable, oBase,lam,MTF,a,b,c)
187
+
188
+
189
+ def main():
190
+ ''' main '''
191
+
192
+
193
+ '''
194
+ FlagWindowing=2
195
+ Wa=15
196
+ for FlagWindowing in np.concatenate ((np.arange(0,11) ,[21,22,23], np.arange(101,200,10))):
197
+ (win,name,sCut)=winLoc(Wa,FlagWindowing )
198
+ plt.title (name+' -- '+sCut)
199
+ plt.plot(win,'.-') # Plot some data on the axes.
200
+ plt.grid()
201
+ plt.show()
202
+ '''
203
+ Niter=np.array([1, 2, 3, np.inf])## Number of final iteration
204
+ nPointPlot=1000
205
+ WBase=16# scalatura plot
206
+
207
+ # A correlation window
208
+ Wa=32
209
+ FlagWindowing=0 # Weighting window for the correlation map (0=TopHat 1= Nogueira 2=Blackman 3=top hat at 50#).
210
+ # B weighted average
211
+ FlagCalcVel=0 # Weighting window for absolute velocity (0=TopHat, 1=Nogueira, 2=Blackman,...)
212
+ hWb=8# Half-width of the filtering window (0=window dimension).
213
+ # C dense predictor
214
+ IntVel=52 # Type of interpolation of the velocity (1=bilinear, 52-70 Bspline)
215
+ Wc=4# Grid distance (overlap)
216
+ # end input *********************************************
217
+
218
+ oMax=0.5 # frequenza massima per c (legata all'overlap ov/lambda) non penso che abbia senso oltre 0,5 perchè
219
+ # andremmo oltre Nyquist
220
+
221
+ WBase=2*Wa# scalatura plot the maximmum lambda is 4 *WBase in this case we are using a maximum of 8*Wa
222
+ flagLambda=1
223
+
224
+ (WinA,nameA,sCutA,Wa,WinB,nameB,sCutB,Wb,order,flagUnstable,oBase,lam,MTF,a,b,c)= mtfPIV1(Wa,FlagWindowing,hWb, FlagCalcVel,Wc, IntVel, oMax, WBase,nPointPlot,Niter,flagLambda)
225
+
226
+
227
+
228
+ fig, ax = plt.subplots()
229
+ ax.plot(oBase,a,'b')#plt.hold on grid on
230
+ ax.plot(oBase,b,'r')
231
+ ax.plot(oBase,c)
232
+ ax.grid()
233
+ fig2, ax2= plt.subplots()
234
+ ax2.plot(WinA)
235
+ ax2.plot(WinB)
236
+ ax2.grid()
237
+
238
+
239
+ fig4, ax4= plt.subplots()
240
+ ax4.grid()
241
+ ax4.plot(lam,MTF.T)
242
+ ax4.set(xlim=(1, max(lam)), ylim=(-.50, 1),)
243
+
244
+
245
+ fig3, ax3= plt.subplots()
246
+ ax3.grid()
247
+ ax3.plot(oBase,MTF.T)
248
+ ax3.set(xlim=(0, max(oBase)), ylim=(-.50, 1),)
249
+
250
+ plt.show()
251
+
252
+
253
+
254
+ if __name__ == "__main__":
255
+
256
+ main()
@@ -0,0 +1,435 @@
1
+ ''' Parallel for for PIV '''
2
+ #import os
3
+ import traceback
4
+ import queue
5
+ import asyncio
6
+ #import random
7
+ import multiprocessing as mp
8
+ from time import sleep, time
9
+ from .tAVarie import PrintTA, PrintTAPriority
10
+ from .__init__ import __version__,__year__,__mail__
11
+ #import numpy as np
12
+ #import scipy as sc
13
+
14
+ prTime=PrintTA(PrintTA.blue, PrintTA.faceStd, PrintTAPriority.medium).prTime
15
+ pr=PrintTA(PrintTA.blue, PrintTA.faceStd, PrintTAPriority.medium).prTime
16
+ # pylint: disable=unused-argument
17
+ lock=None
18
+ def prLock( *args,**kwargs):
19
+ ''' print in parallel pool without overlap (slower)'''
20
+ try:
21
+ with lock:
22
+ PrintTA(PrintTA.blue, PrintTA.faceStd, PrintTAPriority.medium).pr( *args,**kwargs)
23
+ except :
24
+ print(ParForMul.printExceptionPFM(flagMessage=True))
25
+
26
+ def prTimeLock( *args,**kwargs):
27
+ ''' print in parallel pool without overlap (slower)'''
28
+ try:
29
+ with lock:
30
+ PrintTA(PrintTA.blue, PrintTA.faceStd, PrintTAPriority.medium).prTime( *args,**kwargs)
31
+ except:
32
+ print(ParForMul.printExceptionPFM(flagMessage=True))
33
+
34
+ def printExceptionMasterParFor(stringa='',flagMessage=False): #timemilliseconds=-1 ***
35
+ ''' used to print when an exception is raised TA has decided that the printing function is a simple
36
+ print in this way we cannot have any problems when printing in non-compatible terminals
37
+ use with something like
38
+
39
+ try:
40
+ a=1/0
41
+ except :#non need to put a variable al the info are in traceback
42
+ printException()
43
+ * stringa is an additional string (to specify the point where the error comes from)
44
+ * flagMessage is a flag, if true the error message is generated; default value is Flag_DEBUG
45
+ * flagDispDialog is a flag, if true a critical dialog appears after the exception
46
+ '''
47
+ #print(f'***** ParForMul Exception ***** Deltat={time()-PrintTA.startTime}\n{traceback.format_exc()}',*args,**kwargs)
48
+ #print(sys.exc_info()[2])
49
+ Message=""
50
+ if flagMessage:
51
+ Message+=f'Please, mail to: {__mail__}\n\n'
52
+ Message+=f'***** PaIRS Exception ***** time={time()-PrintTA.startTime}\n'+stringa
53
+ Message+=f'***** traceback.print_exc() ***** \n'
54
+ Message+=traceback.format_exc()
55
+ Message+=f'***** traceback.extract_stack() ***** \n'
56
+ # to print all the queue comment if not needed
57
+ for st in traceback.format_list( traceback.extract_stack()):
58
+ if 'PAIRS_GUI' in st and 'printException'not in st:# limits to files that have PAIRS_GUI in the path
59
+ Message+=st
60
+ Message+=f'***** PaIRS Exception -> End *****'
61
+ return Message
62
+
63
+
64
+
65
+ def fakePIV(iImg,procId, p, procTime, flagOutput=False, mes="fakePIV"):
66
+ ''' fakePIV'''
67
+ startTime = time()
68
+ #print(f'reading Img {iImg} pid={os.getpid()} pid={mp.current_process().pid}')
69
+ #print(f'reading Img {iImg} pid={mp.current_process().pid} procId={procId}')
70
+ #sleep(0.5)
71
+ #print(f'Finished reading Img {iImg}')
72
+
73
+ a=0
74
+ count=1*1000*1000#on my pc 10*1000*1000=1sec
75
+ nIt=1
76
+ while nIt<2000000:
77
+ for _ in range(count):
78
+ a+=5#random.random()
79
+ if time()-startTime>procTime:
80
+ break
81
+ nIt+=1
82
+ if flagOutput:
83
+ print(f'fine proc Img {iImg} Nit={nIt} t={time()-startTime} mes={mes}')
84
+ return (0,f'fine proc Img {iImg} Nit={nIt} t={time()-startTime} mes={mes}')
85
+
86
+ #return iImg
87
+
88
+ class ParForCom():
89
+ ''' Comunication varibles used by ParFor'''
90
+ def __init__(self):
91
+ #prTime(0,'Dentro ParForCom Com')
92
+ manager=mp.Manager()#si potrebbe creare un lock al posto della variabile globale qui cercare su internet
93
+ #prTime(0,'Dentro ParForCom dopo manager')
94
+ self.q = manager.Queue()
95
+ self.qOut= manager.Queue()
96
+ self.qProcessed= manager.Queue()
97
+ self.eventExit = manager.Event()
98
+
99
+ def clearAll(self):
100
+ ''' Clears all the queues'''
101
+ self.clear(self.q)
102
+ self.clear(self.qOut)
103
+ self.clear(self.qProcessed)
104
+
105
+
106
+
107
+ def clear(self,q:queue):
108
+ '''clears a Queue'''
109
+ try:
110
+ while True:
111
+ q.get_nowait()
112
+ except queue.Empty:
113
+ pass
114
+
115
+
116
+
117
+ class ParForMul():
118
+ ''' class Parallel for for PIV '''
119
+ printExceptionPFM=printExceptionMasterParFor #class variable
120
+ def __init__(self):
121
+ #prTime(0,'Dentro ParForMul inizio')
122
+ self.parForCom:ParForCom=ParForCom()
123
+ # valori impostabili dall'esterno
124
+ self.sleepTime=1. # waiting to do things
125
+ self.nonProcessed=0 # waiting to do things
126
+ #self.numUsedCores =psutil.cpu_count(logical=False)
127
+ ## numUsedCores is the number of cores used fo processing and can be different from numCoresParPool that is the number of cores used in the parPool
128
+ self.numCoresParPool=self.numUsedCores = mp.cpu_count()//2#da decidere per intel /2 sono i processori reali
129
+ #prTime(0,'Dentro ParForMul fine')
130
+ self.numCalledCallbacks=0 # identify the times that the callbacks have been called
131
+ self.p=None
132
+ self.flagError=False
133
+ self.exception=None
134
+
135
+
136
+ def initTask(self,eventExit,name,procId,*args,**kwargs):
137
+ ''' dummy InitTask sample
138
+ id is the id of the task should be a numeber between 1 and numUsedCores
139
+ if needed initTask should call the main task with name
140
+ '''
141
+
142
+ (flag,var)=fakePIV(name, procId,('initTask',2), *args,**kwargs)
143
+ return (flag,var,('initTask',2))
144
+
145
+ def wrapUp(self,procId,flagHasWorked,P,*args,**kwargs):
146
+ ''' Dummy wrapUp function '''
147
+ if flagHasWorked:#do something
148
+ pass
149
+ return P
150
+
151
+ def callBack(self,flag,perc,procId,flagOutFromTask, name,varOutFromTask):
152
+ ''' Dummy callBack function
153
+ perc=percentage of processed images
154
+ flag=true new data False just check exit
155
+ perc= precentage done
156
+ flagOutFromTasks,varOutFromTask Out variables from task e.g.:
157
+ flagOutFromTasks= 0 success, 1 skipped, -1 error, -2 blocked from caller
158
+ varOutFromTask whatever for now string
159
+ name current element in names
160
+ to stop the process the return value should be True otherwise sleep '''
161
+ if not flag:
162
+ return False
163
+ return False
164
+
165
+ def finalTask(self,procId,*args,**kwargs):
166
+ ''' dummy final finalTask function
167
+ id is the id of the task should be a numeber between 1 and numUsedCores'''
168
+ return ('finalTask',2)
169
+
170
+ def launchTask(self,procId,task,initTask,finalTask, *args,**kwargs):
171
+ ''' the main parallel function first calls initTask (eventExit is an event that enables the safe exit)
172
+ then for all the element in the queue q calls task with the variable returned by initTask
173
+ finally calls finalTask puts in the queue qOut the final result '''
174
+ # aggiunto try così almeno ci rendiamo conto se c'è un errore
175
+ '''
176
+ try:
177
+ procId=mp.current_process()._identity[0]
178
+ except:
179
+ procId=0 # '''
180
+ #pid=mp.current_process().pid
181
+ flagHasWorked=False#if true the task has processed at least one element
182
+ #if procId==2: prTimeLock(f"launchTask |||||||||||| Inizio procId={procId} flagHasWorked={flagHasWorked} ")
183
+ media=None
184
+ try:
185
+ i,n=self.parForCom.q.get()# the first time task must be called by initTask
186
+ if i!=-1:
187
+ flagHasWorked=True
188
+ (flag,var,P)=initTask(self.parForCom.eventExit,n,procId,*args,**kwargs)
189
+ self.parForCom.qProcessed.put((procId,flag,i,var))
190
+ while True:
191
+ i,n=self.parForCom.q.get()
192
+ if i==-1:
193
+ break
194
+ (flag,var)=task(n,procId,P,*args,**kwargs)
195
+ self.parForCom.qProcessed.put((procId,flag,i,var))
196
+ media=finalTask(procId,P,*args,**kwargs)# media should be different from None
197
+ except Exception as e:
198
+ raise(e) # I do not really care to have a full report if in debug it may be important
199
+ #ParForMul.printExceptionPFM()
200
+ flagHasWorked=False if media is None else flagHasWorked #if true the task has processed at least one element and media should be different from None
201
+ return (procId,flagHasWorked,media)
202
+
203
+ def readQOutProcess(self,strOutput,flagProcessed,callBack,names,nElements):
204
+ ''' reads the qOut queue save the data and calls callback'''
205
+ com=self.parForCom
206
+ while not com.qProcessed.empty():
207
+ (procId,flag,i,var)=com.qProcessed.get_nowait()
208
+ perc=1-(com.q.qsize()-self.numUsedCores)/nElements#
209
+ strOutput[i]=var
210
+ flagProcessed[i]=flag
211
+
212
+ #prLock(f'callBack {i} {perc} {com.q.qsize()}')
213
+ if callBack(True,perc,procId,flag,names[i],var):
214
+ com.eventExit.set()# in this case the process will stop
215
+ self.numCalledCallbacks+=1
216
+
217
+ def errorHandler(self,error):
218
+ ''' error function '''
219
+ #self.errorMessage=ParForMul.printExceptionPFM(flagMessage=True)
220
+ self.exception=error
221
+ self.flagError=True
222
+ self.parForCom.eventExit.set()# in this case the process will stop
223
+ #raise(error)
224
+ def parForExtPool(self,parPool,task,names,*args,initTask=None,finalTask=None,wrapUp=None,callBack=None,**kwargs):
225
+ ''' parallel for main function with external mp pool
226
+ task is the main function that is called for each value in names.
227
+ optionally initTask and finalTask are called only one time per worker
228
+ args and kwargs are passed to all the functions.add()
229
+ callBack is called frequently and can be used to stop the parFor
230
+ Finally the WrapUp function is called one time per worker to wrap things up
231
+ '''
232
+ #prTime(0,'Dentro parForExtPool')
233
+
234
+ com=self.parForCom
235
+ com.eventExit.clear()
236
+ initTask=self.initTask if initTask is None else initTask
237
+ finalTask=self.finalTask if finalTask is None else finalTask
238
+ wrapUp=self.wrapUp if wrapUp is None else wrapUp
239
+ callBack=self.callBack if callBack is None else callBack
240
+ self.flagError=False
241
+ self.numCalledCallbacks=0 # reset the number of called callbacks
242
+ nElements=len(names)
243
+ flagProcessed=[self.nonProcessed]*nElements #lista delle immagini processate inizialmente tutti -1 ma possiamo modificarla
244
+ strOutput = [None]*nElements #lista dei messaggi in output in realtà potrebbe essere di qualunque tipo
245
+ def callWrapUp(var):
246
+ self.p=wrapUp(*var,*args,**kwargs)
247
+ self.parForCom.qOut.put((var[0:2])) #procid , flagHasWorked
248
+ #prTime(f"callWrapUp fine procid={var[0]} ")
249
+
250
+ # per ora -1 non processato, -2 errore ,numero positivo processato
251
+ for i,n in enumerate(names):
252
+ com.q.put((i,n))
253
+ for _ in range(self.numUsedCores):
254
+ com.q.put((-1,-1))
255
+
256
+ for i in range(self.numUsedCores):
257
+ _=parPool.apply_async(self.launchTask,(i,task, initTask,finalTask)+args,kwargs,callback=callWrapUp, error_callback=self.errorHandler)
258
+ #_=parPool.apply_async(self.launchTask,(task, initTask,finalTask)+args,kwargs, error_callback=self.errorHandler)
259
+ #prTime(0,'Dopo apply async in parForExtPool ++++++++++++++++++++++++++++++++++')
260
+ nThreadEnd=0
261
+ while True:
262
+ try:
263
+ #(procId,flagHasWorked)=com.qOut.get_nowait()
264
+ (_,_)=com.qOut.get_nowait()
265
+ #p=wrapUp(procId,flagHasWorked,p,*args,**kwargs)
266
+ nThreadEnd+=1
267
+ #if nThreadEnd==1: prTime(f"fine nThreadEnd={nThreadEnd} procId={procId}")
268
+ if nThreadEnd==self.numUsedCores:
269
+ break
270
+ except queue.Empty :
271
+ #prTime(' except queue.Empty Prima ')
272
+ if self.flagError : break # in this case a critical exception has been raised we should exit
273
+ if com.qProcessed.empty():
274
+ if callBack(False,None,None,None,None,None):
275
+ com.eventExit.set()# in this case the process will be stopped
276
+ #print("com.eventExit.set()# in this case the process will be stopped")
277
+ else:
278
+ self.readQOutProcess(strOutput,flagProcessed,callBack,names,nElements)
279
+ #prTime('********************************\n******************************dopo ')
280
+ sleep(self.sleepTime)
281
+
282
+ #prTime(f"fine parForExtPool")
283
+ # some of the processes may have finished without saving the data
284
+ self.readQOutProcess(strOutput,flagProcessed,callBack,names,nElements)
285
+ com.clearAll()# just to be sure ideally only needed when self.flagError is True
286
+
287
+ return self.p,flagProcessed,strOutput,self.flagError
288
+
289
+ def simpleFor(self,parPool,task,names,*args,initTask=None,finalTask=None,wrapUp=None,callBack=None,**kwargs):
290
+ ''' parallel for main function
291
+ task is the main function that is called for each value in names.
292
+ optionally initTask and finalTask are called only one time per worker
293
+ args and kwargs are passed to all the functions.add()
294
+ Finally the WrapUp function is called one time per worker to wrap things up
295
+ '''
296
+ com=self.parForCom
297
+ com.eventExit.clear()
298
+ initTask=self.initTask if initTask is None else initTask
299
+ finalTask=self.finalTask if finalTask is None else finalTask
300
+ wrapUp=self.wrapUp if wrapUp is None else wrapUp
301
+ callBack=self.callBack if callBack is None else callBack
302
+ self.flagError=False
303
+ self.numCalledCallbacks=0 # reset the number of called callbacks
304
+ nElements=len(names)
305
+ flagProcessed=[self.nonProcessed]*nElements #lista delle immagini processate inizialmente tutti -1 ma possiamo modificarla
306
+ strOutput = [None]*nElements #lista dei messaggi in output in realtà potrebbe essere di qualunque tipo
307
+
308
+ def callWrapUp(var):
309
+ self.p=wrapUp(*var,*args,**kwargs)
310
+ self.parForCom.qOut.put((var[0:2]))
311
+
312
+ # per ora -1 non processato, -2 errore ,numero positivo processato
313
+ for i,n in enumerate(names):
314
+ com.q.put((i,n))
315
+ for _ in range(1):
316
+ com.q.put((-1,-1))
317
+ #with mp.Pool(self.numUsedCores) as pp:
318
+ procId=0
319
+ var=self.launchTask(procId,task, initTask,finalTask,*args,**kwargs)
320
+ callWrapUp(var)
321
+ nThreadEnd=0
322
+ while True:
323
+ try:
324
+ #(procId,flagHasWorked)=com.qOut.get_nowait()
325
+ (_,_)=com.qOut.get_nowait()
326
+ #p=wrapUp(procId,flagHasWorked,p,*args,**kwargs)
327
+ nThreadEnd+=1
328
+ #prTime(f"fine nThreadEnd={nThreadEnd} procId={procId} flagHasWorked={flagHasWorked}")
329
+ if nThreadEnd==1:
330
+ break
331
+ except queue.Empty :
332
+ #prTime('********************************\n******************************Prima ')
333
+ if self.flagError : break # in this case a critical exception has been raised we should exit
334
+ if com.qProcessed.empty():
335
+ if callBack(False,None,None,None,None,None):
336
+ com.eventExit.set()# in this case the process will be stopped
337
+ #print("com.eventExit.set()# in this case the process will be stopped")
338
+ else:
339
+ self.readQOutProcess(strOutput,flagProcessed,callBack,names,nElements)
340
+ #prTime('********************************\n******************************dopo ')
341
+ sleep(self.sleepTime)
342
+ # some of the processes may have finished without saving the data
343
+ self.readQOutProcess(strOutput,flagProcessed,callBack,names,nElements)
344
+ return self.p,flagProcessed,strOutput ,self.flagError
345
+
346
+
347
+ def parFor(self,task,names,*args,initTask=None,finalTask=None,wrapUp=None,callBack=None,**kwargs):
348
+ ''' parallel for main function
349
+ task is the main function that is called for each value in names.
350
+ optionally initTask and finalTask are called only one time per worker
351
+ args and kwargs are passed to all the functions.add()
352
+ callBack is called frequently and can be used to stop the parFor
353
+ Finally the WrapUp function is called one time per worker to wrap things up
354
+ '''
355
+ prTime(0,'Dentro parFor')
356
+ pfPool=ParForPool()
357
+ pfPool.startParPool(self.numUsedCores)
358
+ (p,flagProcessed,strOutput)=self.parForExtPool(pfPool.parPool,task,names,*args,initTask=initTask,finalTask=finalTask,wrapUp=wrapUp,callBack=callBack,**kwargs)
359
+ pfPool.closeParPool()
360
+ return p,flagProcessed,strOutput
361
+
362
+
363
+
364
+ def initPoolProcesses(the_lock):
365
+ '''Initialize each process with a global variable lock.
366
+ '''
367
+ global lock
368
+ lock = the_lock
369
+
370
+ class ParForPool():
371
+ ''' Saves the pool '''
372
+ def __init__(self):
373
+ self.parPool=None
374
+ self.numCoresParPool = mp.cpu_count()//2#da decidere per intel sono /2 son i processori reali
375
+ async def startParPoolAsync(self,numCoresParPool):
376
+ ''' dummy function to call startParPool in async'''
377
+ self.startParPool(numCoresParPool)
378
+ def startParPool(self,numCoresParPool):
379
+ ''' Starts the pool'''
380
+ the_lock = mp.Lock() # neded for prLock and the like
381
+ if self.parPool is None:
382
+ self.parPool=mp.Pool(numCoresParPool,initializer=initPoolProcesses, initargs=(the_lock,))
383
+ elif self.numCoresParPool!=numCoresParPool:
384
+ self.parPool.close()# Si potrebbe usare terminate che ammazza tutti i processi in essere
385
+ self.parPool=mp.Pool(numCoresParPool)
386
+ self.numCoresParPool=numCoresParPool
387
+ def closeParPool(self):
388
+ ''' Closes the pool'''
389
+ if self.parPool is not None:
390
+ self.parPool.close()# Si potrebbe usare terminate che ammazza tutti i processi in essere
391
+
392
+ async def initParForAsync(numCoresParPool):
393
+ ''' initialise the parPool'''
394
+ #prTime(0,'PIV_ParFor_Worker init')
395
+ pfPool=ParForPool()
396
+ t1=asyncio.create_task(pfPool.startParPoolAsync(numCoresParPool))
397
+ parForMul=ParForMul()
398
+ parForMul.numUsedCores=parForMul.numCoresParPool=numCoresParPool
399
+ await t1
400
+ #prTime(0,'PIV_ParFor_Worker Dopo ParForPool')
401
+ return (pfPool,parForMul)
402
+
403
+
404
+ def main():
405
+ ''' main '''
406
+ prTime(6,'start')
407
+
408
+ pp=ParForMul()
409
+ #prTime(0,'Dopo ParForMul ****************')
410
+
411
+ pp.sleepTime=.1 # time between calls of callBack not used in this example
412
+ procTime=.02
413
+ nImg= [x for x in range(20)]
414
+ #startTime = time()
415
+ args=(procTime,)
416
+ kwargs={"flagOutput":False, "mes":"fakePIV"}
417
+ #pp.initParPool()
418
+ #pp.parForCache(fakePIV,nImg,*args,**kwargs)
419
+
420
+ pfPool=ParForPool()
421
+ pfPool.startParPool(pfPool.numCoresParPool)
422
+ #pp.simpleFor(fakePIV,nImg,*args,**kwargs)
423
+ pp.numUsedCores =4
424
+
425
+ #pp.parForExtPool(pfPool.parPool,fakePIV,nImg,*args,**kwargs)
426
+ pp.parForExtPool(pfPool.parPool,fakePIV,nImg,*args,**kwargs)
427
+ pfPool.closeParPool()
428
+ pp.parFor(fakePIV,nImg,*args,**kwargs)
429
+ #pp.parFor(fakePIV,nImg,*args,**kwargs)
430
+ prTime(0,'Fine')
431
+
432
+
433
+
434
+ if __name__ == "__main__":
435
+ main()