PaIRS-UniNa 0.2.10__cp313-cp313-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.
- PaIRS_UniNa/Calibration_Tab.py +347 -0
- PaIRS_UniNa/Changes.txt +174 -0
- PaIRS_UniNa/Custom_Top.py +303 -0
- PaIRS_UniNa/Explorer.py +3322 -0
- PaIRS_UniNa/FolderLoop.py +562 -0
- PaIRS_UniNa/Input_Tab.py +829 -0
- PaIRS_UniNa/Input_Tab_CalVi.py +787 -0
- PaIRS_UniNa/Input_Tab_tools.py +3026 -0
- PaIRS_UniNa/Log_Tab.py +110 -0
- PaIRS_UniNa/Output_Tab.py +922 -0
- PaIRS_UniNa/PaIRS.py +18 -0
- PaIRS_UniNa/PaIRS_PIV.py +873 -0
- PaIRS_UniNa/PaIRS_pypacks.py +1374 -0
- PaIRS_UniNa/Process_Tab.py +1761 -0
- PaIRS_UniNa/Process_Tab_CalVi.py +313 -0
- PaIRS_UniNa/Process_Tab_Disp.py +170 -0
- PaIRS_UniNa/Process_Tab_Min.py +120 -0
- PaIRS_UniNa/ResizePopup.py +55 -0
- PaIRS_UniNa/SPIVCalHelp.py +155 -0
- PaIRS_UniNa/Saving_tools.py +298 -0
- PaIRS_UniNa/TabTools.py +1413 -0
- PaIRS_UniNa/Vis_Tab.py +2176 -0
- PaIRS_UniNa/Vis_Tab_CalVi.py +982 -0
- PaIRS_UniNa/Whatsnew.py +130 -0
- PaIRS_UniNa/_PaIRS_PIV.so +0 -0
- PaIRS_UniNa/__init__.py +6 -0
- PaIRS_UniNa/__main__.py +45 -0
- PaIRS_UniNa/addwidgets_ps.py +1633 -0
- PaIRS_UniNa/calib.py +1488 -0
- PaIRS_UniNa/calibView.py +833 -0
- PaIRS_UniNa/gPaIRS.py +3957 -0
- PaIRS_UniNa/gPalette.py +189 -0
- PaIRS_UniNa/icons/abort.png +0 -0
- PaIRS_UniNa/icons/about.png +0 -0
- PaIRS_UniNa/icons/align_all.png +0 -0
- PaIRS_UniNa/icons/announcement.png +0 -0
- PaIRS_UniNa/icons/automatic_levels_off.png +0 -0
- PaIRS_UniNa/icons/automatic_levels_on.png +0 -0
- PaIRS_UniNa/icons/automatic_off.png +0 -0
- PaIRS_UniNa/icons/automatic_on.png +0 -0
- PaIRS_UniNa/icons/automatic_size_off.png +0 -0
- PaIRS_UniNa/icons/automatic_size_on.png +0 -0
- PaIRS_UniNa/icons/axes.png +0 -0
- PaIRS_UniNa/icons/background.png +0 -0
- PaIRS_UniNa/icons/background_vectors.png +0 -0
- PaIRS_UniNa/icons/bin_off.png +0 -0
- PaIRS_UniNa/icons/bin_on.png +0 -0
- PaIRS_UniNa/icons/browse_file_c.png +0 -0
- PaIRS_UniNa/icons/browse_folder_c.png +0 -0
- PaIRS_UniNa/icons/brush_cursor.png +0 -0
- PaIRS_UniNa/icons/bugfix.png +0 -0
- PaIRS_UniNa/icons/cal_proc.png +0 -0
- PaIRS_UniNa/icons/cal_proc_off.png +0 -0
- PaIRS_UniNa/icons/cal_step.png +0 -0
- PaIRS_UniNa/icons/cal_step_off.png +0 -0
- PaIRS_UniNa/icons/calibrate.png +0 -0
- PaIRS_UniNa/icons/calibration_logo.png +0 -0
- PaIRS_UniNa/icons/change_folder.png +0 -0
- PaIRS_UniNa/icons/change_folder_off.png +0 -0
- PaIRS_UniNa/icons/checklist.png +0 -0
- PaIRS_UniNa/icons/clean.png +0 -0
- PaIRS_UniNa/icons/clean_run.png +0 -0
- PaIRS_UniNa/icons/close.png +0 -0
- PaIRS_UniNa/icons/close_all.png +0 -0
- PaIRS_UniNa/icons/close_project.png +0 -0
- PaIRS_UniNa/icons/close_workspace.png +0 -0
- PaIRS_UniNa/icons/colormap.png +0 -0
- PaIRS_UniNa/icons/colormaps/Accent.png +0 -0
- PaIRS_UniNa/icons/colormaps/BrBG.png +0 -0
- PaIRS_UniNa/icons/colormaps/Dark2.png +0 -0
- PaIRS_UniNa/icons/colormaps/PRGn.png +0 -0
- PaIRS_UniNa/icons/colormaps/Paired.png +0 -0
- PaIRS_UniNa/icons/colormaps/Pastel1.png +0 -0
- PaIRS_UniNa/icons/colormaps/Pastel2.png +0 -0
- PaIRS_UniNa/icons/colormaps/PiYG.png +0 -0
- PaIRS_UniNa/icons/colormaps/PuOr.png +0 -0
- PaIRS_UniNa/icons/colormaps/RdBu.png +0 -0
- PaIRS_UniNa/icons/colormaps/RdGy.png +0 -0
- PaIRS_UniNa/icons/colormaps/RdYlBu.png +0 -0
- PaIRS_UniNa/icons/colormaps/RdYlGn.png +0 -0
- PaIRS_UniNa/icons/colormaps/Set1.png +0 -0
- PaIRS_UniNa/icons/colormaps/Set2.png +0 -0
- PaIRS_UniNa/icons/colormaps/Set3.png +0 -0
- PaIRS_UniNa/icons/colormaps/Spectral.png +0 -0
- PaIRS_UniNa/icons/colormaps/Wistia.png +0 -0
- PaIRS_UniNa/icons/colormaps/afmhot.png +0 -0
- PaIRS_UniNa/icons/colormaps/autumn.png +0 -0
- PaIRS_UniNa/icons/colormaps/binary.png +0 -0
- PaIRS_UniNa/icons/colormaps/blackVector.png +0 -0
- PaIRS_UniNa/icons/colormaps/blueVector.png +0 -0
- PaIRS_UniNa/icons/colormaps/bone.png +0 -0
- PaIRS_UniNa/icons/colormaps/brg.png +0 -0
- PaIRS_UniNa/icons/colormaps/bwr.png +0 -0
- PaIRS_UniNa/icons/colormaps/cividis.png +0 -0
- PaIRS_UniNa/icons/colormaps/cool.png +0 -0
- PaIRS_UniNa/icons/colormaps/coolwarm.png +0 -0
- PaIRS_UniNa/icons/colormaps/copper.png +0 -0
- PaIRS_UniNa/icons/colormaps/cubehelix.png +0 -0
- PaIRS_UniNa/icons/colormaps/cyanVector.png +0 -0
- PaIRS_UniNa/icons/colormaps/flag.png +0 -0
- PaIRS_UniNa/icons/colormaps/gist_heat.png +0 -0
- PaIRS_UniNa/icons/colormaps/gray.png +0 -0
- PaIRS_UniNa/icons/colormaps/greenVector.png +0 -0
- PaIRS_UniNa/icons/colormaps/hot.png +0 -0
- PaIRS_UniNa/icons/colormaps/hsv.png +0 -0
- PaIRS_UniNa/icons/colormaps/inferno.png +0 -0
- PaIRS_UniNa/icons/colormaps/jet.png +0 -0
- PaIRS_UniNa/icons/colormaps/magentaVector.png +0 -0
- PaIRS_UniNa/icons/colormaps/magma.png +0 -0
- PaIRS_UniNa/icons/colormaps/ocean.png +0 -0
- PaIRS_UniNa/icons/colormaps/pink.png +0 -0
- PaIRS_UniNa/icons/colormaps/plasma.png +0 -0
- PaIRS_UniNa/icons/colormaps/prism.png +0 -0
- PaIRS_UniNa/icons/colormaps/rainbow.png +0 -0
- PaIRS_UniNa/icons/colormaps/redVector.png +0 -0
- PaIRS_UniNa/icons/colormaps/seismic.png +0 -0
- PaIRS_UniNa/icons/colormaps/spring.png +0 -0
- PaIRS_UniNa/icons/colormaps/summer.png +0 -0
- PaIRS_UniNa/icons/colormaps/tab10.png +0 -0
- PaIRS_UniNa/icons/colormaps/tab20.png +0 -0
- PaIRS_UniNa/icons/colormaps/tab20b.png +0 -0
- PaIRS_UniNa/icons/colormaps/tab20c.png +0 -0
- PaIRS_UniNa/icons/colormaps/terrain.png +0 -0
- PaIRS_UniNa/icons/colormaps/twilight.png +0 -0
- PaIRS_UniNa/icons/colormaps/viridis.png +0 -0
- PaIRS_UniNa/icons/colormaps/whiteVector.png +0 -0
- PaIRS_UniNa/icons/colormaps/winter.png +0 -0
- PaIRS_UniNa/icons/colormaps/yellowVector.png +0 -0
- PaIRS_UniNa/icons/common_region.png +0 -0
- PaIRS_UniNa/icons/common_region_off.png +0 -0
- PaIRS_UniNa/icons/completed.png +0 -0
- PaIRS_UniNa/icons/contourf_off.png +0 -0
- PaIRS_UniNa/icons/contourf_on.png +0 -0
- PaIRS_UniNa/icons/copy.png +0 -0
- PaIRS_UniNa/icons/copy_process.png +0 -0
- PaIRS_UniNa/icons/copy_process_off.png +0 -0
- PaIRS_UniNa/icons/copygrid.png +0 -0
- PaIRS_UniNa/icons/cursor_lamp.png +0 -0
- PaIRS_UniNa/icons/cut.png +0 -0
- PaIRS_UniNa/icons/cut_warnings.png +0 -0
- PaIRS_UniNa/icons/darkmode.png +0 -0
- PaIRS_UniNa/icons/debug_run.png +0 -0
- PaIRS_UniNa/icons/delete.png +0 -0
- PaIRS_UniNa/icons/deleteErr.png +0 -0
- PaIRS_UniNa/icons/disp_step.png +0 -0
- PaIRS_UniNa/icons/disp_step_off.png +0 -0
- PaIRS_UniNa/icons/down.png +0 -0
- PaIRS_UniNa/icons/edit_list.png +0 -0
- PaIRS_UniNa/icons/editing.png +0 -0
- PaIRS_UniNa/icons/example_list.png +0 -0
- PaIRS_UniNa/icons/find_all_planes.png +0 -0
- PaIRS_UniNa/icons/find_plane.png +0 -0
- PaIRS_UniNa/icons/flaticon_PaIRS.png +0 -0
- PaIRS_UniNa/icons/flaticon_PaIRS_beta.png +0 -0
- PaIRS_UniNa/icons/flaticon_PaIRS_download.png +0 -0
- PaIRS_UniNa/icons/flaticon_PaIRS_download_warning.png +0 -0
- PaIRS_UniNa/icons/flip_y_off.png +0 -0
- PaIRS_UniNa/icons/flip_y_on.png +0 -0
- PaIRS_UniNa/icons/focusErrr.png +0 -0
- PaIRS_UniNa/icons/folder_loop_cleanup.png +0 -0
- PaIRS_UniNa/icons/folder_loop_cleanup_off.png +0 -0
- PaIRS_UniNa/icons/gear.gif +0 -0
- PaIRS_UniNa/icons/gear.png +0 -0
- PaIRS_UniNa/icons/ger.png +0 -0
- PaIRS_UniNa/icons/greenv.png +0 -0
- PaIRS_UniNa/icons/guide.png +0 -0
- PaIRS_UniNa/icons/icon_CalVi.png +0 -0
- PaIRS_UniNa/icons/icon_PaIRS.png +0 -0
- PaIRS_UniNa/icons/import.png +0 -0
- PaIRS_UniNa/icons/import_set.png +0 -0
- PaIRS_UniNa/icons/information.png +0 -0
- PaIRS_UniNa/icons/information2.png +0 -0
- PaIRS_UniNa/icons/input_logo.png +0 -0
- PaIRS_UniNa/icons/issue.png +0 -0
- PaIRS_UniNa/icons/laser_NTR.png +0 -0
- PaIRS_UniNa/icons/laser_TR_double.png +0 -0
- PaIRS_UniNa/icons/laser_TR_single.png +0 -0
- PaIRS_UniNa/icons/link.png +0 -0
- PaIRS_UniNa/icons/linked.png +0 -0
- PaIRS_UniNa/icons/loaded.png +0 -0
- PaIRS_UniNa/icons/loading_2.gif +0 -0
- PaIRS_UniNa/icons/log_logo.png +0 -0
- PaIRS_UniNa/icons/logo_CalVi.png +0 -0
- PaIRS_UniNa/icons/logo_CalVi_completo.png +0 -0
- PaIRS_UniNa/icons/logo_CalVi_party.png +0 -0
- PaIRS_UniNa/icons/logo_PaIRS.png +0 -0
- PaIRS_UniNa/icons/logo_PaIRS_completo.png +0 -0
- PaIRS_UniNa/icons/logo_PaIRS_download.png +0 -0
- PaIRS_UniNa/icons/logo_PaIRS_party_rect.png +0 -0
- PaIRS_UniNa/icons/logo_PaIRS_rect.png +0 -0
- PaIRS_UniNa/icons/logo_opaco.png +0 -0
- PaIRS_UniNa/icons/mask.png +0 -0
- PaIRS_UniNa/icons/measure.png +0 -0
- PaIRS_UniNa/icons/measure_off.png +0 -0
- PaIRS_UniNa/icons/min_proc.png +0 -0
- PaIRS_UniNa/icons/min_proc_off.png +0 -0
- PaIRS_UniNa/icons/min_step.png +0 -0
- PaIRS_UniNa/icons/min_step_off.png +0 -0
- PaIRS_UniNa/icons/minus.png +0 -0
- PaIRS_UniNa/icons/mirror_u.png +0 -0
- PaIRS_UniNa/icons/mirror_v.png +0 -0
- PaIRS_UniNa/icons/mirror_x.png +0 -0
- PaIRS_UniNa/icons/mirror_y.png +0 -0
- PaIRS_UniNa/icons/mtplt.png +0 -0
- PaIRS_UniNa/icons/new.png +0 -0
- PaIRS_UniNa/icons/new_workspace.png +0 -0
- PaIRS_UniNa/icons/news.png +0 -0
- PaIRS_UniNa/icons/normal_run.png +0 -0
- PaIRS_UniNa/icons/open.png +0 -0
- PaIRS_UniNa/icons/open_image.png +0 -0
- PaIRS_UniNa/icons/open_new_window.png +0 -0
- PaIRS_UniNa/icons/open_result.png +0 -0
- PaIRS_UniNa/icons/open_workspace.png +0 -0
- PaIRS_UniNa/icons/output_logo.png +0 -0
- PaIRS_UniNa/icons/paste_above.png +0 -0
- PaIRS_UniNa/icons/paste_below.png +0 -0
- PaIRS_UniNa/icons/pause.png +0 -0
- PaIRS_UniNa/icons/paused.png +0 -0
- PaIRS_UniNa/icons/pencil_bw.png +0 -0
- PaIRS_UniNa/icons/piv_proc.png +0 -0
- PaIRS_UniNa/icons/piv_proc_off.png +0 -0
- PaIRS_UniNa/icons/piv_step.png +0 -0
- PaIRS_UniNa/icons/piv_step_off.png +0 -0
- PaIRS_UniNa/icons/plane.png +0 -0
- PaIRS_UniNa/icons/play.png +0 -0
- PaIRS_UniNa/icons/plus.png +0 -0
- PaIRS_UniNa/icons/process_logo.png +0 -0
- PaIRS_UniNa/icons/process_loop.png +0 -0
- PaIRS_UniNa/icons/project.png +0 -0
- PaIRS_UniNa/icons/pylog.png +0 -0
- PaIRS_UniNa/icons/python_warning.png +0 -0
- PaIRS_UniNa/icons/queue.png +0 -0
- PaIRS_UniNa/icons/quit.png +0 -0
- PaIRS_UniNa/icons/read.png +0 -0
- PaIRS_UniNa/icons/read_list.png +0 -0
- PaIRS_UniNa/icons/redo.png +0 -0
- PaIRS_UniNa/icons/redx.png +0 -0
- PaIRS_UniNa/icons/reset.png +0 -0
- PaIRS_UniNa/icons/reset_levels.png +0 -0
- PaIRS_UniNa/icons/resize_icon.png +0 -0
- PaIRS_UniNa/icons/restore.png +0 -0
- PaIRS_UniNa/icons/restore_undo.png +0 -0
- PaIRS_UniNa/icons/rotate_clock.png +0 -0
- PaIRS_UniNa/icons/rotate_counter.png +0 -0
- PaIRS_UniNa/icons/rotate_v_clock.png +0 -0
- PaIRS_UniNa/icons/rotate_v_counter.png +0 -0
- PaIRS_UniNa/icons/running.gif +0 -0
- PaIRS_UniNa/icons/running.png +0 -0
- PaIRS_UniNa/icons/running_warn.png +0 -0
- PaIRS_UniNa/icons/sandglass.png +0 -0
- PaIRS_UniNa/icons/save.png +0 -0
- PaIRS_UniNa/icons/save_and_stop.png +0 -0
- PaIRS_UniNa/icons/save_cfg.png +0 -0
- PaIRS_UniNa/icons/saveas.png +0 -0
- PaIRS_UniNa/icons/saveas_workspace.png +0 -0
- PaIRS_UniNa/icons/scale_all.png +0 -0
- PaIRS_UniNa/icons/scale_down.png +0 -0
- PaIRS_UniNa/icons/scale_up.png +0 -0
- PaIRS_UniNa/icons/scan_list.png +0 -0
- PaIRS_UniNa/icons/scan_path.png +0 -0
- PaIRS_UniNa/icons/scan_path_loop.png +0 -0
- PaIRS_UniNa/icons/scan_path_loop_off.png +0 -0
- PaIRS_UniNa/icons/search.png +0 -0
- PaIRS_UniNa/icons/showIW_off.png +0 -0
- PaIRS_UniNa/icons/showIW_on.png +0 -0
- PaIRS_UniNa/icons/show_all.png +0 -0
- PaIRS_UniNa/icons/sort.png +0 -0
- PaIRS_UniNa/icons/sort_reversed.png +0 -0
- PaIRS_UniNa/icons/spiv_proc.png +0 -0
- PaIRS_UniNa/icons/spiv_proc_off.png +0 -0
- PaIRS_UniNa/icons/spiv_setup_no.png +0 -0
- PaIRS_UniNa/icons/spiv_setup_ok.png +0 -0
- PaIRS_UniNa/icons/star.png +0 -0
- PaIRS_UniNa/icons/step_inheritance.png +0 -0
- PaIRS_UniNa/icons/subMIN_off.png +0 -0
- PaIRS_UniNa/icons/subMIN_on.png +0 -0
- PaIRS_UniNa/icons/tom.png +0 -0
- PaIRS_UniNa/icons/trash.png +0 -0
- PaIRS_UniNa/icons/undo.png +0 -0
- PaIRS_UniNa/icons/unedited.png +0 -0
- PaIRS_UniNa/icons/unina_dii.png +0 -0
- PaIRS_UniNa/icons/uninitialized.png +0 -0
- PaIRS_UniNa/icons/unlink.png +0 -0
- PaIRS_UniNa/icons/unwrap_items.png +0 -0
- PaIRS_UniNa/icons/up.png +0 -0
- PaIRS_UniNa/icons/updating_import.gif +0 -0
- PaIRS_UniNa/icons/updating_pairs.gif +0 -0
- PaIRS_UniNa/icons/vectorColor.png +0 -0
- PaIRS_UniNa/icons/vettore.png +0 -0
- PaIRS_UniNa/icons/view.png +0 -0
- PaIRS_UniNa/icons/view_off.png +0 -0
- PaIRS_UniNa/icons/vis_logo.png +0 -0
- PaIRS_UniNa/icons/waiting_circle.png +0 -0
- PaIRS_UniNa/icons/warning.png +0 -0
- PaIRS_UniNa/icons/warning_circle.png +0 -0
- PaIRS_UniNa/icons/window.png +0 -0
- PaIRS_UniNa/icons/workspace.png +0 -0
- PaIRS_UniNa/icons/wrap_items.png +0 -0
- PaIRS_UniNa/icons/write_list.png +0 -0
- PaIRS_UniNa/listLib.py +303 -0
- PaIRS_UniNa/mtfPIV.py +256 -0
- PaIRS_UniNa/parForMulti.py +435 -0
- PaIRS_UniNa/parForWorkers.py +593 -0
- PaIRS_UniNa/pivParFor.py +235 -0
- PaIRS_UniNa/plt_util.py +141 -0
- PaIRS_UniNa/preProcParFor.py +155 -0
- PaIRS_UniNa/procTools.py +1439 -0
- PaIRS_UniNa/readcfg.py +52 -0
- PaIRS_UniNa/rqrdpckgs.txt +9 -0
- PaIRS_UniNa/stereoPivParFor.py +227 -0
- PaIRS_UniNa/tAVarie.py +215 -0
- PaIRS_UniNa/tabSplitter.py +612 -0
- PaIRS_UniNa/ui_Calibration_Tab.py +578 -0
- PaIRS_UniNa/ui_Custom_Top.py +296 -0
- PaIRS_UniNa/ui_Input_Tab.py +1101 -0
- PaIRS_UniNa/ui_Input_Tab_CalVi.py +1283 -0
- PaIRS_UniNa/ui_Log_Tab.py +263 -0
- PaIRS_UniNa/ui_Output_Tab.py +2362 -0
- PaIRS_UniNa/ui_Process_Tab.py +3810 -0
- PaIRS_UniNa/ui_Process_Tab_CalVi.py +1549 -0
- PaIRS_UniNa/ui_Process_Tab_Disp.py +1141 -0
- PaIRS_UniNa/ui_Process_Tab_Min.py +437 -0
- PaIRS_UniNa/ui_ResizePopup.py +204 -0
- PaIRS_UniNa/ui_Vis_Tab.py +1628 -0
- PaIRS_UniNa/ui_Vis_Tab_CalVi.py +1251 -0
- PaIRS_UniNa/ui_Whatsnew.py +132 -0
- PaIRS_UniNa/ui_gPairs.py +877 -0
- PaIRS_UniNa/ui_infoPaIRS.py +551 -0
- PaIRS_UniNa/whatsnew.txt +4 -0
- pairs_unina-0.2.10.dist-info/METADATA +159 -0
- pairs_unina-0.2.10.dist-info/RECORD +333 -0
- pairs_unina-0.2.10.dist-info/WHEEL +5 -0
- pairs_unina-0.2.10.dist-info/top_level.txt +2 -0
PaIRS_UniNa/pivParFor.py
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
from .PaIRS_pypacks import *
|
|
2
|
+
from .procTools import *
|
|
3
|
+
|
|
4
|
+
def image2Float(a):
|
|
5
|
+
''' converts image to float '''
|
|
6
|
+
return lambda I: np.ascontiguousarray(I,dtype= a)
|
|
7
|
+
Image2PIV_Float=image2Float( np.float64 if PaIRS_lib.SizeOfReal()==8 else np.float32)
|
|
8
|
+
|
|
9
|
+
class WrapperOutFromPIV(PaIRS_lib.PyFunOutPIV):
|
|
10
|
+
''' Wrapper class for FunOut
|
|
11
|
+
FunOut is called periodically from the PaIRS_lib lib and if FunOut returns a value different from
|
|
12
|
+
zero the processing is stopped
|
|
13
|
+
'''
|
|
14
|
+
def __init__(self,flagFerma,eventExit) :
|
|
15
|
+
PaIRS_lib.PyFunOutPIV.__init__(self)
|
|
16
|
+
self.flagFerma=flagFerma
|
|
17
|
+
self.eventExit=eventExit
|
|
18
|
+
def FunOut(self, a, b, o) :
|
|
19
|
+
if self.eventExit.is_set():
|
|
20
|
+
self.flagFerma=-1
|
|
21
|
+
return -1
|
|
22
|
+
#print(f'flag ferma {self.flagFerma[0]} id={id(self.flagFerma)} {os.getpid()} ')
|
|
23
|
+
return 0
|
|
24
|
+
|
|
25
|
+
def initPIV(eventFerma,iImg,procId,data:dataTreePar,*args,**kwargs):
|
|
26
|
+
''' this function is called once per processor before the main function
|
|
27
|
+
eventferma is passed to the function called by PIV in order to stop the processing '''
|
|
28
|
+
#prTimeLock(0,f" initPIV")
|
|
29
|
+
|
|
30
|
+
PIV=data2PIV(data,flagSpiv=False)
|
|
31
|
+
data.OUT=OUTpar(data.Process,data.Step)
|
|
32
|
+
data.OUT.copyfromdiz(data.OUT_dict)
|
|
33
|
+
|
|
34
|
+
PIV.Inp.FlagLog=0
|
|
35
|
+
#vect=[]
|
|
36
|
+
#for v in data.PRO.Vect: vect.append(v.astype(np.intc))
|
|
37
|
+
|
|
38
|
+
#PIV.SetVect([v.astype(np.intc) for v in data.PRO.Vect])
|
|
39
|
+
if data.FlagMIN:
|
|
40
|
+
data.compMin.Imin=[np.zeros(1),np.zeros(1)]
|
|
41
|
+
for k,filename in enumerate(data.Imin[0]):
|
|
42
|
+
try:
|
|
43
|
+
data.compMin.Imin[k]=np.ascontiguousarray(Image.open(filename))
|
|
44
|
+
except Exception as inst:
|
|
45
|
+
errorMessage=f'Error while opening historical minimum background image file: {filename}. PIV process will not be executed!'
|
|
46
|
+
pri.Error.red(errorMessage+f"\n\nError details:\n{inst}\n")
|
|
47
|
+
raise (errorMessage)
|
|
48
|
+
#raise (inst)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
PIV.Media=MediaPIV()#data.mediaPIV
|
|
52
|
+
PIV.WraOut =WrapperOutFromPIV(0,eventExit=eventFerma)
|
|
53
|
+
PIV.fun=PaIRS_lib.GetPyFunction(PIV.WraOut)
|
|
54
|
+
(flagOut,VarOut) =procPIV(iImg,procId ,PIV,data,*args,**kwargs)
|
|
55
|
+
return (flagOut,VarOut,PIV)
|
|
56
|
+
def exitNoLog(flagOut,varOut):
|
|
57
|
+
''' exit without printing the log '''
|
|
58
|
+
varOut[0]=-1
|
|
59
|
+
return (flagOut,varOut)
|
|
60
|
+
def procPIV(i,procId ,PIV,data:dataTreePar,numUsedProcs,*args,**kwargs):
|
|
61
|
+
''' main proc function called for all the images one time per processor
|
|
62
|
+
k=0 always
|
|
63
|
+
In output flagOut and varOut[0] can be:
|
|
64
|
+
Already processed: varOut[0]=-1 flagOut=FLAG_PROC[k]|FLAG_READ[k]|FLAG_FINALIZED[k]
|
|
65
|
+
Error reading: varOut[0]=i flagOut=FLAG_READ_ERR[k]
|
|
66
|
+
Error processing: varOut[0]=i flagOut=FLAG_READ[k]
|
|
67
|
+
Process stoped by user: varOut[0]=-1 flagOut=FLAG_READ[k]
|
|
68
|
+
Error saving: varOut[0]=i flagOut=FLAG_PROC[k]|FLAG_READ[k]
|
|
69
|
+
Read and processed: varOut[0]=i flagOut=FLAG_PROC[k]|FLAG_READ[k]|FLAG_FINALIZED[k]|FLAG_CALLBACK_INTERNAL
|
|
70
|
+
Use:
|
|
71
|
+
numCallBackTotOk+=sum(1 if x&FLAG_CALLBACK_INTERNAL else 0 for x in flagOut)
|
|
72
|
+
to evaluate the number of total internal callbacks
|
|
73
|
+
numProcOrErrTot=sum(1 if f else 0 for f in flagOut)
|
|
74
|
+
to evaluate the number of total images processed (after a possible pause)
|
|
75
|
+
numFinalized=sum(1 if f&FLAG_FINALIZED[0] else 0 for f in flagOut)
|
|
76
|
+
to evaluate the number of total images correctly processed
|
|
77
|
+
|
|
78
|
+
where FLAG_FINALIZED_OR_ERR = [ p|e for (p,e) in zip(FLAG_FINALIZED,FLAG_READ_ERR)]
|
|
79
|
+
numProcOrErrTot=sum(1 if (f&FLAG_FINALIZED_OR_ERR[0])or(not f&FLAG_PROC[0]) else 0 for f in flagOut)
|
|
80
|
+
to delete images
|
|
81
|
+
pa='C:\\desk\\dl\\apairs\\jetcross\\'
|
|
82
|
+
no='zR2jet0_0004a'
|
|
83
|
+
I =imread([pa no '.png']);
|
|
84
|
+
I=I*0+1;
|
|
85
|
+
imwrite(I,[pa no 'black.png']);
|
|
86
|
+
'''
|
|
87
|
+
|
|
88
|
+
flagOut=0#data.list_pim[i] #0 to be processed, -1 error, 1 correctly processed
|
|
89
|
+
|
|
90
|
+
varOut=[i,'',[]] # The log will be written unless exitNoLog. If FLAG_CALLBACK_INTERNAL will be set then also the internal part will be called.
|
|
91
|
+
|
|
92
|
+
#if PIV.WraOut.flagFerma!=0: return (flagOut,VarOut)
|
|
93
|
+
j=i*2
|
|
94
|
+
kConst=0#useless. In preProc the flags are different for the first and second image in this case we only use the first (i.e. k=0)
|
|
95
|
+
try:
|
|
96
|
+
varOut[1]+=f'{data.list_Image_Files[j]}-{data.list_Image_Files[j+1]}'
|
|
97
|
+
if data.list_eim[j] and data.list_eim[j+1]:
|
|
98
|
+
if data.list_pim[i]&FLAG_FINALIZED[kConst]:
|
|
99
|
+
flagOut=FLAG_READ[kConst]|FLAG_PROC[kConst]|FLAG_FINALIZED[kConst] # It has been already processed. Exit without calling the callback core part
|
|
100
|
+
#☻prTimeLock(0,f"{i} --> {data.list_Image_Files[j]} {data.list_Image_Files[j+1]} {hex(flagOut)}")
|
|
101
|
+
return exitNoLog(flagOut,varOut)
|
|
102
|
+
else:
|
|
103
|
+
if PIV.WraOut.eventExit.is_set(): return exitNoLog(flagOut,varOut)# non si può mettere prima
|
|
104
|
+
# reading images and transforming
|
|
105
|
+
#prTimeLock(0,f"{i} --> {data.list_Image_Files[j]} {data.list_Image_Files[j+1]}")
|
|
106
|
+
I1=[None]*2
|
|
107
|
+
# tbd
|
|
108
|
+
#if i==2:1/0
|
|
109
|
+
try:
|
|
110
|
+
for k in range(2):
|
|
111
|
+
if PIV.WraOut.eventExit.is_set(): return exitNoLog(flagOut,varOut)
|
|
112
|
+
nameImg=data.inpPath+data.list_Image_Files[j+k]
|
|
113
|
+
I1[k]=np.ascontiguousarray(Image.open(nameImg))
|
|
114
|
+
if data.FlagMIN:
|
|
115
|
+
if data.FlagTR and i%2:
|
|
116
|
+
I1[k]=I1[k]-data.compMin.Imin[[1,0][k]]
|
|
117
|
+
else:
|
|
118
|
+
I1[k]=I1[k]-data.compMin.Imin[k]
|
|
119
|
+
iProc=transfIm(data.OUT,flagTransf=0,Images=I1)
|
|
120
|
+
except Exception as inst:
|
|
121
|
+
flagOut|=FLAG_READ_ERR[kConst]
|
|
122
|
+
if data.list_pim[i]&FLAG_READ_ERR[kConst]:varOut[0]=-1# no log already written
|
|
123
|
+
varOut[1]+=f"\n!!!!!!!!!! Error while reading the image {data.list_Image_Files[j+k]}:\n{inst}\n"
|
|
124
|
+
prLock(f'{varOut[1]}')
|
|
125
|
+
return (flagOut,varOut) #we can exit directly! Not calling the internal part of the callback in case of error
|
|
126
|
+
|
|
127
|
+
# no exception reading images and transforming running the process
|
|
128
|
+
flagOut|=FLAG_READ[kConst]
|
|
129
|
+
#infoPrint.white(os.getpid())
|
|
130
|
+
try:
|
|
131
|
+
PIV.SetImg([Image2PIV_Float(I) for I in iProc]) #inside try but should not happen
|
|
132
|
+
if PIV.WraOut.eventExit.is_set(): return (flagOut,varOut)
|
|
133
|
+
err=PIV.PIV_Run(PIV.fun)
|
|
134
|
+
except Exception as inst:
|
|
135
|
+
#raise (inst)
|
|
136
|
+
if ( data.list_pim[i] &FLAG_READ[kConst]):varOut[0]=-1# no log already written
|
|
137
|
+
#dum=str(inst.__cause__).split('\n')[3] #solved
|
|
138
|
+
dum='\n'.join(str(inst.args[0]).split('\n')[3:])
|
|
139
|
+
#varOut[1]+=f"\n!!!!!!!!!! Error while processing the above image pair: {dum}"
|
|
140
|
+
varOut[1]+=f"\n!!!!!!!!!! Error while processing data:\n{dum}\n"
|
|
141
|
+
#prLock(f'{varOut[1]}')
|
|
142
|
+
return (flagOut,varOut) #we can exit directly! Not calling the internal part of the callback in case of error
|
|
143
|
+
try:# no exception running the process
|
|
144
|
+
if err==-1000: #interrotto
|
|
145
|
+
return exitNoLog(flagOut,varOut) #we can exit directly no log !
|
|
146
|
+
else:
|
|
147
|
+
# Finalizing the process (means transformations and saving data)
|
|
148
|
+
flagOut|=FLAG_PROC[kConst]# per completezza aggiungo anche processato
|
|
149
|
+
x,y,u,v=transfVect(data.OUT,PIV)
|
|
150
|
+
nameFields=PIV.Media.namesPIV.instVelFields
|
|
151
|
+
otherVars=[getattr(PIV,f) for f in nameFields[4:] ]
|
|
152
|
+
campoVel=[x,y,u,v] +transfIm(data.OUT,flagTransf=1,Images=otherVars,flagRot=1)
|
|
153
|
+
nameVar=PIV.Media.namesPIV.instVel
|
|
154
|
+
PIV.Media.sum(campoVel)
|
|
155
|
+
try:
|
|
156
|
+
saveResults(data,i+1,campoVel,nameVar)
|
|
157
|
+
except Exception as inst:
|
|
158
|
+
varOut[1]+=f"\n!!!!!!!!!! Error while saving the results:\n{str(inst)}\n"
|
|
159
|
+
#prLock(f'{varOut[1]}')
|
|
160
|
+
varOut[0]=i# In any case the log will be written. If FLAG_CALLBACK_INTERNAL will be set then also the internal part will be called.
|
|
161
|
+
return (flagOut,varOut) #we can exit directly! Not calling the internal part of the callback in case of error
|
|
162
|
+
varOut[1]+="\n"+printPIVLog(PIV.PD)
|
|
163
|
+
flagOut|=FLAG_FINALIZED[kConst]
|
|
164
|
+
varOut[0]=i# In any case the log will be written. If FLAG_CALLBACK_INTERNAL will be set then also the internal part will be called.
|
|
165
|
+
flagOut|=FLAG_CALLBACK_INTERNAL# Verrà chiamata la callback
|
|
166
|
+
except Exception as inst:
|
|
167
|
+
varOut[1]+=f"\n!!!!!!!!!! Error while finalizing the PIV process:\n{str(inst)}\n"
|
|
168
|
+
#prLock(f'{varOut[1]}')
|
|
169
|
+
return (flagOut,varOut)
|
|
170
|
+
else:#if data.list_eim[j] and data.list_eim[j+1]:
|
|
171
|
+
flagOut|=FLAG_READ_ERR[kConst]
|
|
172
|
+
if data.list_pim[i]&FLAG_READ_ERR[kConst]:varOut[0]=-1# no log already written
|
|
173
|
+
jj=j+1 if data.list_eim[j] else j
|
|
174
|
+
varOut[1]+=f"\n!!!!!!!!!! Error while reading the image {data.list_Image_Files[jj]}:\nThe image file is missing!\n"
|
|
175
|
+
#prLock(f'{varOut[1]}')
|
|
176
|
+
except :
|
|
177
|
+
flagOut|=FLAG_GENERIC_ERROR
|
|
178
|
+
varOut[0]=i# In any case the log will be written. If FLAG_CALLBACK_INTERNAL will be set then also the internal part will be called.
|
|
179
|
+
varOut[1]+=printException(flagMessage=True)
|
|
180
|
+
|
|
181
|
+
# to del ma il resto dove va
|
|
182
|
+
#varOut=[i,stampa,[]] if flagOut&FLAG_FINALIZING_PROC_OK[0] else [-1,stampa,[]]
|
|
183
|
+
if (not procId%numUsedProcs) and flagOut&FLAG_FINALIZED[0]: # copiare l'img nella coda è un operazione onerosa. TA ha deciso che si copia solo quando serve
|
|
184
|
+
#prLock(f'procMIN Main proc i={i}')
|
|
185
|
+
varOut[2]=campoVel#VarOut=[i,stampa,Var]
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
return (flagOut,varOut)
|
|
190
|
+
|
|
191
|
+
def finalPIV(procId, PIV,data,*args,finalPIVPIppo=4 ,**kwargs):
|
|
192
|
+
#prLock(f'finalPIV procId={procId}')
|
|
193
|
+
return PIV.Media
|
|
194
|
+
|
|
195
|
+
def saveAndMean(procId,flagHasWorked,med,data,*args,**kwargs):
|
|
196
|
+
''' saveAndMean is the wrapUp function called once per processor '''
|
|
197
|
+
if flagHasWorked:
|
|
198
|
+
data.mediaPIV.sumMedia(med)
|
|
199
|
+
return data.mediaPIV
|
|
200
|
+
|
|
201
|
+
def callBackPIV(flag,perc,procId,flagOut,name,VarOut,signal_res):
|
|
202
|
+
'''
|
|
203
|
+
flag=true new data False just check exit
|
|
204
|
+
perc= precentage done
|
|
205
|
+
flagOutFromTasks,varOutFromTask Out varibles from task e.g.:
|
|
206
|
+
flagOut=1 #0 to be processed, -1 error, 1 correctly processed
|
|
207
|
+
varOutFromTask whatever for now a string
|
|
208
|
+
name current element in names
|
|
209
|
+
to stop the process the return value should be True otherwise sleep
|
|
210
|
+
'''
|
|
211
|
+
global FlagStopWorkers
|
|
212
|
+
|
|
213
|
+
if flag:
|
|
214
|
+
i=VarOut[0]
|
|
215
|
+
stampa=VarOut[1]
|
|
216
|
+
Var=VarOut[2]
|
|
217
|
+
#pr(f'Callback {i} getpid {os.getpid()} {len(Var)}')
|
|
218
|
+
#prLock(f'Callback {i} getpid {os.getpid()} ')
|
|
219
|
+
signal_res.emit(procId,i,flagOut,Var,stampa)
|
|
220
|
+
VarOut[2]=[]#altrimenti salvo le img
|
|
221
|
+
'''
|
|
222
|
+
if i==0:
|
|
223
|
+
callBackPIV.flagStop=True
|
|
224
|
+
if(callBackPIV.flagStop):
|
|
225
|
+
if i>=2:
|
|
226
|
+
callBackPIV.flagStop=False
|
|
227
|
+
FlagStopWorkers[0]=True
|
|
228
|
+
return True
|
|
229
|
+
#'''
|
|
230
|
+
if FlagStopWorkers[0]:
|
|
231
|
+
return True
|
|
232
|
+
else:
|
|
233
|
+
return False
|
|
234
|
+
callBackPIV.flagStop=True
|
|
235
|
+
|
PaIRS_UniNa/plt_util.py
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
''' plt utilities '''
|
|
2
|
+
from typing import List#, Set, Dict, Tuple, Optional
|
|
3
|
+
from struct import unpack
|
|
4
|
+
import numpy as np
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def writePlt(outFileName:str,mat,title:str,varNames:List[str],zoneTitle:str)->None :
|
|
9
|
+
''' write tecplot binary files'''
|
|
10
|
+
nVar=len(mat)
|
|
11
|
+
h,w=mat[0].shape
|
|
12
|
+
tecIntest=b'#!TDV71 '
|
|
13
|
+
|
|
14
|
+
def writeLong(l):
|
|
15
|
+
f.write(np.int32(l))
|
|
16
|
+
def writeFloat32(fl):
|
|
17
|
+
f.write(np.float32(fl))
|
|
18
|
+
def writeString(s):
|
|
19
|
+
for c in str.encode(s):
|
|
20
|
+
f.write(np.int32(c))
|
|
21
|
+
f.write(np.int32(0))
|
|
22
|
+
return
|
|
23
|
+
#apertura file binario di output .plt
|
|
24
|
+
f=open(outFileName,"wb")
|
|
25
|
+
|
|
26
|
+
#scrittura nel file di output del TEST
|
|
27
|
+
f.write(tecIntest)
|
|
28
|
+
#scrittura nel file di output di 1 (ordine dei bytes BO???)
|
|
29
|
+
writeLong(1)
|
|
30
|
+
#scrittura del titolo
|
|
31
|
+
writeString(title)
|
|
32
|
+
|
|
33
|
+
#scrittura numero e nome delle variabili
|
|
34
|
+
writeLong(nVar)
|
|
35
|
+
for s in varNames:
|
|
36
|
+
writeString(s)
|
|
37
|
+
writeFloat32(299.0)
|
|
38
|
+
#ZONE NAME
|
|
39
|
+
writeString(zoneTitle)
|
|
40
|
+
#scrittura del BLOCK POINT
|
|
41
|
+
writeLong(1)
|
|
42
|
+
#scrittura del COLORE
|
|
43
|
+
writeLong(-1)
|
|
44
|
+
#scrittura nel file di output della larghezza e altezza img W e H
|
|
45
|
+
writeLong(w)
|
|
46
|
+
writeLong(h)
|
|
47
|
+
#scrittura nel file di output della dimensione Z
|
|
48
|
+
writeLong(1)
|
|
49
|
+
#scrittura nel file di output di 357.0 (bo????)
|
|
50
|
+
writeFloat32(357.0)
|
|
51
|
+
#scrittura nel file di output di 299.0 (bo????)
|
|
52
|
+
writeFloat32(299.0)
|
|
53
|
+
#scrittura nel file di output di 0 (bo????)
|
|
54
|
+
writeLong(0)
|
|
55
|
+
#sizeof variabili
|
|
56
|
+
for _ in range (0,nVar):
|
|
57
|
+
writeLong(1)
|
|
58
|
+
|
|
59
|
+
#scrittura nel file di output delle matrici x,y,u,v,up,vp (variabili)
|
|
60
|
+
writeFloat32(np.ascontiguousarray(np.transpose(mat,(1,2,0))))
|
|
61
|
+
|
|
62
|
+
f.flush()
|
|
63
|
+
f.close()
|
|
64
|
+
|
|
65
|
+
return
|
|
66
|
+
def readPlt(inFileName):
|
|
67
|
+
''' read tecplot binary files
|
|
68
|
+
returns a 3d array [w,h,nVar]
|
|
69
|
+
'''
|
|
70
|
+
#nVar=len(Mat)
|
|
71
|
+
#h,w=Mat[0].shape
|
|
72
|
+
tecIntest=b'#!TDV71 '
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def readFloat32():
|
|
76
|
+
return unpack('f',f.read(4))[0]
|
|
77
|
+
|
|
78
|
+
def readLong():
|
|
79
|
+
return unpack('i',f.read(4))[0]
|
|
80
|
+
def readString():
|
|
81
|
+
s=''
|
|
82
|
+
while True:
|
|
83
|
+
ic=unpack('i',f.read(4))[0]
|
|
84
|
+
if ic==0:
|
|
85
|
+
break
|
|
86
|
+
s+=chr(ic)
|
|
87
|
+
return s
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
#apertura file binario di output .plt
|
|
91
|
+
f=open(inFileName,"rb")
|
|
92
|
+
|
|
93
|
+
#scrittura nel file di output del TEST
|
|
94
|
+
tecIntest=f.read(8)
|
|
95
|
+
if tecIntest!=b'#!TDV71 ':
|
|
96
|
+
print("ERrore")
|
|
97
|
+
if readLong()!=1:
|
|
98
|
+
print("ERrore")
|
|
99
|
+
#Lettura del titolo
|
|
100
|
+
_=readString()
|
|
101
|
+
|
|
102
|
+
#lettura numero e nome delle variabili
|
|
103
|
+
nVar=readLong()
|
|
104
|
+
varNames=[]
|
|
105
|
+
for _ in range(nVar):
|
|
106
|
+
varNames.append(readString())
|
|
107
|
+
if readFloat32()!=299:
|
|
108
|
+
print("ERrore")
|
|
109
|
+
#ZONE NAME
|
|
110
|
+
_=readString()
|
|
111
|
+
#scrittura del BLOCK POINT
|
|
112
|
+
readLong()
|
|
113
|
+
#scrittura del COLORE
|
|
114
|
+
readLong()
|
|
115
|
+
#scrittura nel file di output della larghezza e altezza img W e H
|
|
116
|
+
w=readLong()
|
|
117
|
+
h=readLong()
|
|
118
|
+
#scrittura nel file di output della dimensione Z
|
|
119
|
+
if readLong()!=1:
|
|
120
|
+
print("ERrore")#3d nonprevisto
|
|
121
|
+
if readFloat32()!=357:
|
|
122
|
+
print("ERrore")
|
|
123
|
+
if readFloat32()!=299:
|
|
124
|
+
print("ERrore")
|
|
125
|
+
readLong()
|
|
126
|
+
for _ in range(nVar):
|
|
127
|
+
dimVar=readLong()
|
|
128
|
+
ty=np.float32 if dimVar==1 else np.float64
|
|
129
|
+
aa=np.reshape(np.fromfile(f, ty,count=w*h*nVar),[h,w,nVar])
|
|
130
|
+
|
|
131
|
+
f.close()
|
|
132
|
+
return aa,varNames
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
if __name__ == "__main__":
|
|
139
|
+
i=0
|
|
140
|
+
nomeFileOut= f"{'test'}{i:0{4:d}d}.plt"
|
|
141
|
+
readPlt(nomeFileOut)
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
''' preProcParFor helper function for parfor '''
|
|
2
|
+
|
|
3
|
+
from .PaIRS_pypacks import * #OPTIMIZE TAGP rimuovere tutti gli import e mettere solo quelli necessari
|
|
4
|
+
from .procTools import *
|
|
5
|
+
|
|
6
|
+
prTime = PrintTA(PrintTA.cyan, PrintTA.faceStd, PrintTAPriority.medium).prTime
|
|
7
|
+
|
|
8
|
+
def initMIN(eventFerma,iImg,procId,data:dataTreePar,*args,**kwargs):
|
|
9
|
+
''' this function is called once per processor before the main function
|
|
10
|
+
eventferma is passed to the function called by PIV in order to stop the processing '''
|
|
11
|
+
#prLock(0,f" initMIN procId={procId}")
|
|
12
|
+
compMin=CompMin(data.ncam)
|
|
13
|
+
|
|
14
|
+
compMin.eventExit=eventFerma
|
|
15
|
+
# initially I thought that it was easier to initialize the minimum without calling procMIN but this is not possible because
|
|
16
|
+
# if an error occurs (e.g. reading) while processing the first image it is not possible to overcome this error
|
|
17
|
+
#if procId==2: prTimeLock(f"initMIN rima compmin procId={procId} ")
|
|
18
|
+
(flagOut,VarOut)=procMIN(iImg,procId,compMin,data,*args,**kwargs)
|
|
19
|
+
#if procId==2: prTimeLock(f"fine initMIN procId={procId} ")
|
|
20
|
+
return (flagOut,VarOut,compMin)
|
|
21
|
+
|
|
22
|
+
def procMIN(i,procId,compMin:CompMin,data:dataTreePar,numMaxProcs,*args,**kwargs):
|
|
23
|
+
''' main proc function called for all the images one time per processor
|
|
24
|
+
k=0 or 1 for the first and second image
|
|
25
|
+
In output flagOut and varOut[0] can be:
|
|
26
|
+
Already processed: varOut[0]=-1 flagOut=FLAG_PROC[k]|FLAG_READ[k]|FLAG_FINALIZED[k]
|
|
27
|
+
Error reading: varOut[0]=i flagOut=FLAG_READ_ERR[k]
|
|
28
|
+
Read and processed: varOut[0]=i flagOut=FLAG_PROC[k]|FLAG_READ[k]|FLAG_FINALIZED[k]|FLAG_CALLBACK_INTERNAL
|
|
29
|
+
Use:
|
|
30
|
+
numCallBackTotOk+=sum(1 if x&FLAG_CALLBACK_INTERNAL else 0 for x in flagOut)
|
|
31
|
+
to evaluate the number of total internal callbacks
|
|
32
|
+
numProcOrErrTot=sum(1 if (f&FLAG_FINALIZED_OR_ERR[0])and (f&FLAG_FINALIZED_OR_ERR[1]) else 0 for f in flagOut)
|
|
33
|
+
numProcOrErrTot=sum(1 if f else 0 for f in flagOut)
|
|
34
|
+
to evaluate the number of total images processed (after a possible pause)
|
|
35
|
+
numFinalized=sum(1 if (f&FLAG_FINALIZED[0]) and (f&FLAG_FINALIZED[1]) else 0 for f in flagOut)
|
|
36
|
+
to evaluate the number of total images correctly processed
|
|
37
|
+
where FLAG_FINALIZED_OR_ERR = [ p|e for (p,e) in zip(FLAG_FINALIZED,FLAG_READ_ERR)]
|
|
38
|
+
'''
|
|
39
|
+
flagOut=0
|
|
40
|
+
|
|
41
|
+
varOut=[-1,'',[]]
|
|
42
|
+
|
|
43
|
+
ncam=data.ncam
|
|
44
|
+
nframe=data.nframe
|
|
45
|
+
nImgMin=nframe*ncam
|
|
46
|
+
nImgMolt=2 if data.FlagTR else 1
|
|
47
|
+
|
|
48
|
+
try:
|
|
49
|
+
for j in range(nImgMin):
|
|
50
|
+
# tbd
|
|
51
|
+
k=j%nframe
|
|
52
|
+
cam=j//nframe%ncam
|
|
53
|
+
ind=nImgMolt*nframe*i + k + data.nimg*nframe*cam
|
|
54
|
+
#if i==2:1/0
|
|
55
|
+
|
|
56
|
+
#i=0 ind=0 (0)-> a ind=1 (1)->b
|
|
57
|
+
#i=1 ind=4 (2)-> a ind=5 (3)->b
|
|
58
|
+
varOut[1]+=data.list_Image_Files[ind]+"\n"
|
|
59
|
+
if data.list_eim[ind]:
|
|
60
|
+
if data.list_pim[i]&FLAG_PROC[k]:
|
|
61
|
+
flagOut|=FLAG_PROC[k]|FLAG_READ[k]|FLAG_FINALIZED[k] # It has been already processed. Exit without calling the callback core part
|
|
62
|
+
if k: return (flagOut,varOut) #second img
|
|
63
|
+
#flagOut=flagOut& ~FLAG_CALLBACK# nel caso sia stata chiamata in precedenza ed ora non venga chiamata
|
|
64
|
+
else:
|
|
65
|
+
if compMin.eventExit.is_set(): return (flagOut,varOut)
|
|
66
|
+
nameImg=data.inpPath+data.list_Image_Files[ind]
|
|
67
|
+
#if k==0: prLock(f'{i} {data.list_Image_Files[ind]} --- {data.list_Image_Files[ind+1]} ')
|
|
68
|
+
try:
|
|
69
|
+
if compMin.eventExit.is_set(): return (flagOut,varOut)
|
|
70
|
+
I=np.array(Image.open(nameImg))
|
|
71
|
+
except Exception as inst:
|
|
72
|
+
flagOut|=FLAG_READ_ERR[k]
|
|
73
|
+
#if data.list_pim[i]&FLAG_READ_ERR[k]: varOut[0]=-1# no log already written
|
|
74
|
+
varOut[1]+=f"!!!!!!!!!! Error reading {data.list_Image_Files[ind]}:\n{inst}\n"# no internal callback {str(inst.__cause__)}
|
|
75
|
+
prLock(f'{varOut[1]}',end='')
|
|
76
|
+
varOut[0]=i# In any case the log will be written. If FLAG_CALLBACK_INTERNAL will be set then also the internal part will be called.
|
|
77
|
+
else:# no exception
|
|
78
|
+
|
|
79
|
+
flagOut|=FLAG_READ[k]
|
|
80
|
+
if compMin.checkImg(I,data.SogliaNoise_Min,data.SogliaStd_Min ):
|
|
81
|
+
#flagOut=1 if k==0 else (2 if flagOut==-1 else 3)
|
|
82
|
+
compMin.minSum(I,j)
|
|
83
|
+
#prLock(f"procMIN {i}--{procId} {nameIm} flagOut={flagOut} list_pim[i]={data.list_pim[i]} ")
|
|
84
|
+
flagOut|=FLAG_PROC[k]|FLAG_FINALIZED[k]# in this case both processed and finalized
|
|
85
|
+
else:
|
|
86
|
+
varOut[1]+=f"The gray levels in {data.list_Image_Files[ind]} are too small! Please, check the image or change the minimum allowed value and standard deviation thresholds in the Validation box!\n"
|
|
87
|
+
flagOut|=FLAG_PROC[k] # in this case both processed and finalized
|
|
88
|
+
varOut[0]=i# In any case the log will be written. If FLAG_CALLBACK_INTERNAL will be set then also the internal part will be called.
|
|
89
|
+
flagOut|=FLAG_CALLBACK_INTERNAL# Verrà chiamata la callback
|
|
90
|
+
else:
|
|
91
|
+
#if data.list_pim[i]&FLAG_READ_ERR[k]: varOut[0]=-1# no log already written
|
|
92
|
+
varOut[0]=i# In any case the log will be written. If FLAG_CALLBACK_INTERNAL will be set then also the internal part will be called.
|
|
93
|
+
flagOut|=FLAG_READ_ERR[k]
|
|
94
|
+
varOut[1]+=f"!!!!!!!!!! The file {data.list_Image_Files[ind]} is missing!\n"
|
|
95
|
+
except :
|
|
96
|
+
flagOut|=FLAG_GENERIC_ERROR
|
|
97
|
+
varOut[0]=i# In any case the log will be written. If FLAG_CALLBACK_INTERNAL will be set then also the internal part will be called.
|
|
98
|
+
varOut[1]+=printException(flagMessage=True)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
if not procId%numMaxProcs and flagOut&FLAG_PROC_AB: # copying in the queue is time consuming. This is done only when needed
|
|
102
|
+
varOut[2]=compMin.Imin#VarOut=[i,stampa,Var]
|
|
103
|
+
return (flagOut,varOut)
|
|
104
|
+
|
|
105
|
+
def finalMIN( procId,compMin:CompMin,data:dataTreePar,numMaxProcs,*args,**kwargs):
|
|
106
|
+
#prLock(f'finalMIN procId={procId} {data.compMin.contab}')
|
|
107
|
+
return compMin
|
|
108
|
+
|
|
109
|
+
def saveAndMin(procId,flagHasWorked,compMin:CompMin,data:dataTreePar,numMaxProcs,*args,**kwargs):
|
|
110
|
+
''' saveAndMean is the wrapUp function called once per processor '''
|
|
111
|
+
#prTimeLock(f'saveAndMin procId={procId} {data.compMin.contab}')
|
|
112
|
+
if flagHasWorked:
|
|
113
|
+
data.compMin.calcMin(compMin)
|
|
114
|
+
#prTimeLock(f'saveAndMin fine procId={procId} {data.compMin.contab}')
|
|
115
|
+
return data.compMin
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def callBackMin(flag,perc,procId,flagOut,name,VarOut,signal_res):
|
|
119
|
+
'''
|
|
120
|
+
flag=true new data False just check exit
|
|
121
|
+
perc= precentage done
|
|
122
|
+
flagOutFromTasks,varOutFromTask Out varibles from task e.g.:
|
|
123
|
+
flagOut=1 #0 to be processed, -1 error, 1 correctly processed
|
|
124
|
+
varOutFromTask whatever for now a string
|
|
125
|
+
name current element in names
|
|
126
|
+
to stop the process the return value should be True otherwise sleep
|
|
127
|
+
'''
|
|
128
|
+
global FlagStopWorkers
|
|
129
|
+
if flag:
|
|
130
|
+
i=VarOut[0]
|
|
131
|
+
stampa=VarOut[1]
|
|
132
|
+
Var=VarOut[2]
|
|
133
|
+
#prLock(f'Callback {i} {perc} getpid {os.getpid()} {len(Var)}')
|
|
134
|
+
signal_res.emit(procId,i,flagOut,Var,stampa)
|
|
135
|
+
VarOut[2]=[]#altrimenti salvo le img
|
|
136
|
+
'''
|
|
137
|
+
if i==0:
|
|
138
|
+
callBackMin.flagStop=True
|
|
139
|
+
if(callBackMin.flagStop):
|
|
140
|
+
if i>=2:
|
|
141
|
+
callBackMin.flagStop=False
|
|
142
|
+
FlagStopWorkers[0]=True
|
|
143
|
+
return True
|
|
144
|
+
#'''
|
|
145
|
+
if FlagStopWorkers[0]:
|
|
146
|
+
return True
|
|
147
|
+
else:
|
|
148
|
+
return False
|
|
149
|
+
callBackMin.flagStop=True
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|