PaIRS-UniNa 0.2.7__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.
Potentially problematic release.
This version of PaIRS-UniNa might be problematic. Click here for more details.
- PaIRS_UniNa/Calibration_Tab.py +331 -0
- PaIRS_UniNa/Changes.txt +135 -0
- PaIRS_UniNa/Custom_Top.py +303 -0
- PaIRS_UniNa/Explorer.py +3086 -0
- PaIRS_UniNa/FolderLoop.py +372 -0
- PaIRS_UniNa/Input_Tab.py +722 -0
- PaIRS_UniNa/Input_Tab_CalVi.py +788 -0
- PaIRS_UniNa/Input_Tab_tools.py +3024 -0
- PaIRS_UniNa/Log_Tab.py +110 -0
- PaIRS_UniNa/Output_Tab.py +924 -0
- PaIRS_UniNa/PaIRS.py +18 -0
- PaIRS_UniNa/PaIRS_PIV.py +873 -0
- PaIRS_UniNa/PaIRS_pypacks.py +1376 -0
- PaIRS_UniNa/Process_Tab.py +1757 -0
- PaIRS_UniNa/Process_Tab_CalVi.py +313 -0
- PaIRS_UniNa/Process_Tab_Disp.py +163 -0
- PaIRS_UniNa/Process_Tab_Min.py +120 -0
- PaIRS_UniNa/ResizePopup.py +55 -0
- PaIRS_UniNa/Saving_tools.py +296 -0
- PaIRS_UniNa/TabTools.py +1254 -0
- PaIRS_UniNa/Vis_Tab.py +2148 -0
- PaIRS_UniNa/Vis_Tab_CalVi.py +983 -0
- PaIRS_UniNa/Whatsnew.py +129 -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 +1133 -0
- PaIRS_UniNa/calib.py +1488 -0
- PaIRS_UniNa/calibView.py +833 -0
- PaIRS_UniNa/gPaIRS.py +3856 -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/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/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/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/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 +1394 -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 +545 -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 +5 -0
- pairs_unina-0.2.7.dist-info/METADATA +160 -0
- pairs_unina-0.2.7.dist-info/RECORD +325 -0
- pairs_unina-0.2.7.dist-info/WHEEL +5 -0
- pairs_unina-0.2.7.dist-info/top_level.txt +2 -0
PaIRS_UniNa/procTools.py
ADDED
|
@@ -0,0 +1,1394 @@
|
|
|
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 not in (0,-10):
|
|
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
|
+
if self.flagRun:
|
|
342
|
+
self.Log=self.createLogHeader()
|
|
343
|
+
else:
|
|
344
|
+
self.Log=self.createLogHeader()+warn1
|
|
345
|
+
|
|
346
|
+
def createWarningLog(self,warning):
|
|
347
|
+
warn1=self.headerSection('WARNINGS',warning,'!')
|
|
348
|
+
return self.createLogHeader()+warn1
|
|
349
|
+
|
|
350
|
+
def headerSection(self,nameSection,Log,*args):
|
|
351
|
+
if len(Log):
|
|
352
|
+
c='-'
|
|
353
|
+
n=36
|
|
354
|
+
if len(args): c=args[0]
|
|
355
|
+
if len(args)>1: n=args[1]
|
|
356
|
+
ln=len(nameSection)
|
|
357
|
+
ns=int((n-ln)/2)
|
|
358
|
+
Log=f'{f"{c}"*n}\n{" "*ns}{nameSection}{" "*ns}\n{f"{c}"*n}\n'+Log+'\n'
|
|
359
|
+
return Log
|
|
360
|
+
|
|
361
|
+
def createLogProc(self):
|
|
362
|
+
splitAs='\n '#used to join the strings together tab or spaces may be use to indent the error
|
|
363
|
+
numImgTot=len(self.list_pim) if self.Step!=StepTypes.min else (2*len(self.list_pim))
|
|
364
|
+
LogProc=''
|
|
365
|
+
LogErr=''
|
|
366
|
+
cont=0
|
|
367
|
+
contErr=0
|
|
368
|
+
for i,p in enumerate(self.list_pim):
|
|
369
|
+
if not p or self.list_print[i]=='':
|
|
370
|
+
continue
|
|
371
|
+
if self.Step==StepTypes.min: #minimum
|
|
372
|
+
cont+=2
|
|
373
|
+
#flag=(p&FLAG_FINALIZED[0]) and (p&FLAG_FINALIZED[1])
|
|
374
|
+
if (p&FLAG_FINALIZED[0]):
|
|
375
|
+
if (p&FLAG_FINALIZED[1]):
|
|
376
|
+
LogProc+=(self.list_print[i])
|
|
377
|
+
else:
|
|
378
|
+
sAppo=self.list_print[i].split('\n')
|
|
379
|
+
LogProc+=sAppo[0]+'\n'
|
|
380
|
+
if (not p&FLAG_READ[1]) and p&FLAG_READ_ERR[1]:
|
|
381
|
+
LogErr+=splitAs.join(sAppo[1:-1])+'\n'
|
|
382
|
+
contErr+=1
|
|
383
|
+
#pri.Process.magenta(f'LogProc {i} {p} {splitAs.join(sAppo[1:-1])} {hex(p)} ')
|
|
384
|
+
else:# la b nonè stata proprio letta
|
|
385
|
+
cont-=1
|
|
386
|
+
#pri.Process.magenta(f'LogProc wrong {i} {p} {splitAs.join(sAppo[1:-1])} {hex(p)} ')
|
|
387
|
+
LogProc+='\n'
|
|
388
|
+
else:
|
|
389
|
+
sAppo=self.list_print[i].split('\n')
|
|
390
|
+
if (p&FLAG_FINALIZED[1]):
|
|
391
|
+
LogProc+=(sAppo[-2])+'\n'
|
|
392
|
+
LogErr+=splitAs.join(sAppo[0:-2])+'\n'
|
|
393
|
+
contErr+=1
|
|
394
|
+
else:
|
|
395
|
+
iDum=len(sAppo)//2
|
|
396
|
+
LogErr+=splitAs.join(sAppo[0:iDum])+'\n'+splitAs.join(sAppo[iDum:-1])+'\n'
|
|
397
|
+
contErr+=2
|
|
398
|
+
elif self.Step in (StepTypes.piv,StepTypes.disp,StepTypes.spiv): #PIV process
|
|
399
|
+
cont+=1
|
|
400
|
+
if p&FLAG_FINALIZED[0]:
|
|
401
|
+
LogProc+=self.list_print[i]+"\n"
|
|
402
|
+
#pr(f'LogProc {i} {p} {self.list_print[i]} {hex(p)} = {hex(FLAG_FINALIZED_AB)}\n')
|
|
403
|
+
else:
|
|
404
|
+
contErr+=1
|
|
405
|
+
errString=splitAs.join(self.list_print[i].split('\n')[0:-1])
|
|
406
|
+
if errString: LogErr+=errString+'\n'
|
|
407
|
+
|
|
408
|
+
if not LogProc: LogProc=self.nullLogProc()
|
|
409
|
+
|
|
410
|
+
self.FlagErr=bool(LogErr) or 'CRITICAL ERROR' in self.warnings[0]
|
|
411
|
+
if self.Step in (StepTypes.piv,StepTypes.spiv):
|
|
412
|
+
errStr=f' ({contErr}/{numImgTot} images)'
|
|
413
|
+
else:
|
|
414
|
+
errStr=''
|
|
415
|
+
if 'CRITICAL ERROR' in self.warnings[0]:
|
|
416
|
+
errStr2='!!! Critical errors occured! Please, see further information reported below.\n\n'
|
|
417
|
+
else:
|
|
418
|
+
errStr2=''
|
|
419
|
+
if self.FlagErr:
|
|
420
|
+
LogErr=f'There were errors in the current process{errStr}:\n\n{errStr2}'+LogErr
|
|
421
|
+
else:
|
|
422
|
+
LogErr=f'There were no errors in the current process!\n\n'
|
|
423
|
+
if numImgTot:
|
|
424
|
+
pProc=cont*100/numImgTot
|
|
425
|
+
else:
|
|
426
|
+
pProc=100
|
|
427
|
+
pLeft=100-pProc
|
|
428
|
+
if cont:
|
|
429
|
+
pErr=contErr*100/cont
|
|
430
|
+
else:
|
|
431
|
+
pErr=0
|
|
432
|
+
pCorr=100-pErr
|
|
433
|
+
item='pair' if self.Step!=StepTypes.disp else 'iteration'
|
|
434
|
+
sp=' '*6 if self.Step!=StepTypes.disp else ' '
|
|
435
|
+
Log_PIVCores='' if self.Step==StepTypes.min else f' PIV cores: {self.numPivOmpCores}\n'
|
|
436
|
+
LogStat=\
|
|
437
|
+
f'Percentage of {item}s\n'+\
|
|
438
|
+
f' processed: {pProc:.2f}%\n'+\
|
|
439
|
+
f' remaining: {pLeft:.2f}%\n'+\
|
|
440
|
+
f' without errors: {pCorr:.2f}%\n'+\
|
|
441
|
+
f' with errors: {pErr:.2f}%\n\n'+\
|
|
442
|
+
f'Time\n'+\
|
|
443
|
+
f' of the process: {self.deltaTime2String(self.procTime,True)}\n'+\
|
|
444
|
+
f' {sp} per {item}: {self.deltaTime2String(self.timePerImage,True)}\n'+\
|
|
445
|
+
f' to the end: {self.deltaTime2String(self.eta,True)}\n\n'+\
|
|
446
|
+
f'Multi processing\n'+\
|
|
447
|
+
Log_PIVCores+\
|
|
448
|
+
f' processing units: {floor(self.numUsedProcs)}\n'
|
|
449
|
+
#5f' processing units: {floor(self.numUsedProcs/self.numPivOmpCores)}\n'
|
|
450
|
+
self.procLog=[LogProc,LogStat,LogErr]
|
|
451
|
+
return
|
|
452
|
+
|
|
453
|
+
def nullLogProc(self):
|
|
454
|
+
return 'No output produced!\n\n'
|
|
455
|
+
|
|
456
|
+
def resetLog(self):
|
|
457
|
+
if self.procLog[0]!=self.nullLogProc():
|
|
458
|
+
self.Log=self.createLogHeader()+self.procLog[0]
|
|
459
|
+
else:
|
|
460
|
+
self.Log=self.createLogHeader()
|
|
461
|
+
return
|
|
462
|
+
|
|
463
|
+
def writeCfgProcPiv(self,filename='',FlagWarningDialog=False):
|
|
464
|
+
flagSpiv=self.Step==StepTypes.spiv
|
|
465
|
+
if filename=='':
|
|
466
|
+
outPathRoot=self.outPathRoot
|
|
467
|
+
foldOut=os.path.dirname(outPathRoot)
|
|
468
|
+
if not os.path.exists(foldOut):
|
|
469
|
+
try:
|
|
470
|
+
os.mkdir(foldOut)
|
|
471
|
+
except Exception as inst:
|
|
472
|
+
pri.Error.red(f'It was not possible to make the directory {foldOut}:\n{traceback.format_exc()}\n\n{inst}')
|
|
473
|
+
filename=f"{outPathRoot}.cfg"
|
|
474
|
+
try:
|
|
475
|
+
writeCfgProcPiv(self,filename,flagSpiv)
|
|
476
|
+
except Exception as inst:
|
|
477
|
+
warningMessage=f'Error while writing PIV configuration file to location "{filename}":\n{inst}'
|
|
478
|
+
if FlagWarningDialog: warningDialog(None,warningMessage)
|
|
479
|
+
pri.Error.red(f'{warningMessage}\n{traceback.format_exc()}\n')
|
|
480
|
+
|
|
481
|
+
class MediaPIV():
|
|
482
|
+
''' helper class to perform the avearages '''
|
|
483
|
+
def __init__(self,stepType=StepTypes.piv):
|
|
484
|
+
self.outName=''
|
|
485
|
+
self.name_proc=''
|
|
486
|
+
|
|
487
|
+
self.stepType=stepType
|
|
488
|
+
self.namesPIV=NamesPIV(Step=self.stepType)
|
|
489
|
+
|
|
490
|
+
#self.avgVel=[self.x,self.y,self.u,self.v,self.up,self.vp,self.uvp,self.FCl,self.Info,self.sn]
|
|
491
|
+
self.x=np.zeros(1)
|
|
492
|
+
self.y=np.zeros(1)
|
|
493
|
+
self.u=np.zeros(1)
|
|
494
|
+
self.v=np.zeros(1)
|
|
495
|
+
self.up=np.zeros(1)
|
|
496
|
+
self.vp=np.zeros(1)
|
|
497
|
+
self.uvp=np.zeros(1)
|
|
498
|
+
self.sn=np.zeros(1)
|
|
499
|
+
self.FCl=np.zeros(1)
|
|
500
|
+
self.Info=np.zeros(1)
|
|
501
|
+
if self.stepType==StepTypes.disp:
|
|
502
|
+
self.z=np.zeros(1)
|
|
503
|
+
self.dPar=np.zeros(1)
|
|
504
|
+
self.dOrt=np.zeros(1)
|
|
505
|
+
if self.stepType==StepTypes.spiv:
|
|
506
|
+
self.z=np.zeros(1)
|
|
507
|
+
self.w=np.zeros(1)
|
|
508
|
+
self.wp=np.zeros(1)
|
|
509
|
+
self.uwp=np.zeros(1)
|
|
510
|
+
self.vwp=np.zeros(1)
|
|
511
|
+
self.indu=3 if self.stepType==StepTypes.spiv else 2
|
|
512
|
+
|
|
513
|
+
# just for checking that the variables are the same
|
|
514
|
+
# I cannot do it automatically since variables are not recognized by vscode
|
|
515
|
+
for n in self.namesPIV.avgVelFields:
|
|
516
|
+
v=getattr(self,n)
|
|
517
|
+
|
|
518
|
+
self.cont=0
|
|
519
|
+
self.nimg=0
|
|
520
|
+
|
|
521
|
+
self.fields=[f for f,_ in self.__dict__.items()]
|
|
522
|
+
|
|
523
|
+
def sum(self,var):
|
|
524
|
+
# should start with x, y ,u ,v
|
|
525
|
+
infoSi=1
|
|
526
|
+
self.cont=self.cont+1
|
|
527
|
+
for v, n in zip(var[2:], self.namesPIV.instVelFields[2:]) :
|
|
528
|
+
f=getattr(self,n)
|
|
529
|
+
#piv.Info #verificare se sia il caso di sommare solo se =Infosi
|
|
530
|
+
setattr(self,n,f+1*(v==infoSi) if n=='Info' else f+v )
|
|
531
|
+
|
|
532
|
+
'''
|
|
533
|
+
self.u=self.u+var[2] #piv.u
|
|
534
|
+
self.v=self.v+var[3] #piv.v
|
|
535
|
+
self.FCl=self.FCl+var[4] #piv.FCl
|
|
536
|
+
self.Info=self.Info+1*(var[5]==infoSi) #piv.Info #verificare se sia il caso di sommare solo se =Infosi
|
|
537
|
+
self.sn=self.sn+var[6] #piv.sn
|
|
538
|
+
'''
|
|
539
|
+
self.up=self.up+var[self.indu]*var[self.indu] #piv.up
|
|
540
|
+
self.vp=self.vp+var[self.indu+1]*var[self.indu+1] #piv.vp
|
|
541
|
+
self.uvp=self.uvp+var[self.indu]*var[self.indu+1] #piv.uvp
|
|
542
|
+
if self.stepType==StepTypes.spiv:
|
|
543
|
+
self.wp=self.wp+var[self.indu+2]*var[self.indu+2] #piv.wp
|
|
544
|
+
self.uwp=self.uwp+var[self.indu]*var[self.indu+2] #piv.uwp
|
|
545
|
+
self.vwp=self.vwp+var[self.indu+1]*var[self.indu+2] #piv.vwp
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+
if self.x.size<=1:
|
|
549
|
+
self.x=var[0] #piv.x dovrebbero essere tutti uguali
|
|
550
|
+
self.y=var[1] #piv.y dovrebbero essere tutti uguali
|
|
551
|
+
if self.stepType==StepTypes.spiv:
|
|
552
|
+
self.z=var[2] #piv.y dovrebbero essere tutti uguali
|
|
553
|
+
|
|
554
|
+
def sumMedia(self,medToSum):
|
|
555
|
+
self.cont=self.cont+medToSum.cont
|
|
556
|
+
self.u=self.u+medToSum.u
|
|
557
|
+
self.v=self.v+medToSum.v
|
|
558
|
+
self.sn=self.sn+medToSum.sn
|
|
559
|
+
self.FCl=self.FCl+medToSum.FCl
|
|
560
|
+
self.up=self.up+medToSum.up
|
|
561
|
+
self.vp=self.vp+medToSum.vp
|
|
562
|
+
self.uvp=self.uvp+medToSum.uvp
|
|
563
|
+
self.Info=self.Info+medToSum.Info
|
|
564
|
+
if self.stepType==StepTypes.spiv:
|
|
565
|
+
self.w=self.w+medToSum.w
|
|
566
|
+
self.wp=self.wp+medToSum.wp
|
|
567
|
+
self.uwp=self.uwp+medToSum.uwp
|
|
568
|
+
self.vwp=self.vwp+medToSum.vwp
|
|
569
|
+
if self.x.size<=1:
|
|
570
|
+
self.x=medToSum.x #piv.x dovrebbero essere tutti uguali
|
|
571
|
+
self.y=medToSum.y #piv.y dovrebbero essere tutti uguali
|
|
572
|
+
if self.stepType==StepTypes.spiv:
|
|
573
|
+
self.z=medToSum.z #piv.y dovrebbero essere tutti uguali
|
|
574
|
+
|
|
575
|
+
def calcMedia(self):
|
|
576
|
+
if self.cont>0:
|
|
577
|
+
|
|
578
|
+
self.u/=self.cont
|
|
579
|
+
self.v/=self.cont
|
|
580
|
+
|
|
581
|
+
self.sn/=self.cont
|
|
582
|
+
self.FCl/=self.cont
|
|
583
|
+
self.Info/=self.cont#percentuale di vettori buoni 1=100% 0 nememno un vettore buono
|
|
584
|
+
self.up=(self.up/self.cont-self.u*self.u)#nan or inf is no good vector
|
|
585
|
+
self.vp=(self.vp/self.cont-self.v*self.v)#nan or inf is no good vector
|
|
586
|
+
self.uvp=(self.uvp/self.cont-self.u*self.v)#nan or inf is no good vector
|
|
587
|
+
if self.stepType==StepTypes.spiv:
|
|
588
|
+
self.w/=self.cont
|
|
589
|
+
self.wp=(self.wp/self.cont-self.w*self.w)#nan or inf is no good vector
|
|
590
|
+
self.uwp=(self.uwp/self.cont-self.u*self.w)#nan or inf is no good vector
|
|
591
|
+
self.vwp=(self.vwp/self.cont-self.w*self.v)#nan or inf is no good vector
|
|
592
|
+
def restoreSum(self):
|
|
593
|
+
|
|
594
|
+
#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?
|
|
595
|
+
self.up=(self.up+self.u*self.u)*self.cont # inf is no good vector
|
|
596
|
+
self.vp=(self.vp+self.v*self.v)*self.cont # inf is no good vector
|
|
597
|
+
self.uvp=(self.uvp+self.u*self.v)*self.cont # inf is no good vector
|
|
598
|
+
if self.stepType==StepTypes.spiv:
|
|
599
|
+
self.wp=(self.wp+self.w*self.w)*self.cont # inf is no good vector
|
|
600
|
+
self.uwp=(self.uwp+self.u*self.w)*self.cont # inf is no good vector
|
|
601
|
+
self.vwp=(self.vwp+self.w*self.v)*self.cont # inf is no good vector
|
|
602
|
+
self.w=self.w*self.cont
|
|
603
|
+
|
|
604
|
+
self.u=self.u*self.cont
|
|
605
|
+
self.v=self.v*self.cont
|
|
606
|
+
self.sn=self.sn*self.cont
|
|
607
|
+
self.Info=self.Info*self.cont#percentuale di vettori buoni 1=100% 0 nememno un vettore buono
|
|
608
|
+
|
|
609
|
+
class CompMin():
|
|
610
|
+
''' helper class to compute minimum '''
|
|
611
|
+
def __init__(self,ncam=1,nframe=2):
|
|
612
|
+
self.outName=''
|
|
613
|
+
self.name_proc=''
|
|
614
|
+
|
|
615
|
+
self.setup(ncam,nframe)
|
|
616
|
+
#self.cont=0
|
|
617
|
+
#self.cont0=0
|
|
618
|
+
|
|
619
|
+
self.flag_TR=None
|
|
620
|
+
self.LaserType=-1 #0 single, 1 double
|
|
621
|
+
|
|
622
|
+
self.fields=[f for f,_ in self.__dict__.items()]
|
|
623
|
+
|
|
624
|
+
def setup(self,ncam,nframe):
|
|
625
|
+
self.ncam=ncam
|
|
626
|
+
self.nframe=nframe
|
|
627
|
+
self.Imin=[np.zeros(0) for _ in range(self.ncam*self.nframe)]
|
|
628
|
+
self.med=[np.zeros(1) for _ in range(self.ncam*self.nframe)]
|
|
629
|
+
self.contab=[0 for _ in range(ncam*2)]
|
|
630
|
+
|
|
631
|
+
def minSum(self,I,k):
|
|
632
|
+
''' min '''
|
|
633
|
+
#sleep(0.15)
|
|
634
|
+
# min or max
|
|
635
|
+
if len(I):# why
|
|
636
|
+
if self.contab[k]==0:
|
|
637
|
+
self.Imin[k]=I
|
|
638
|
+
else:
|
|
639
|
+
self.Imin[k]=np.minimum(I,self.Imin[k])
|
|
640
|
+
# verage std and the like
|
|
641
|
+
self.med[k]=self.med[k]+I#+= non funziona all'inizio
|
|
642
|
+
self.contab[k]+=1
|
|
643
|
+
#prLock(f"minSum contab={self.contab[k]}")
|
|
644
|
+
def checkImg(self,I,sogliaMedia,sogliaStd)->bool:
|
|
645
|
+
''' checkImg '''
|
|
646
|
+
#dum=1/I.size
|
|
647
|
+
media=I.mean() #I.ravel().sum()*dum #faster than mean, but affected by overflow
|
|
648
|
+
dev=I.std() #np.square(I-media).ravel().sum()*dum
|
|
649
|
+
return media>sogliaMedia and dev >sogliaStd*sogliaStd
|
|
650
|
+
|
|
651
|
+
def calcMin(self,minMed):
|
|
652
|
+
''' calcMin and sum media '''
|
|
653
|
+
#pri.Time.magenta(0,f"self.cont0={self.cont0}")
|
|
654
|
+
#self.cont+=self.cont0
|
|
655
|
+
#nImg=1 if self.flag_TR else 2
|
|
656
|
+
#nImg=2
|
|
657
|
+
for k in range(len(self.Imin)):
|
|
658
|
+
if minMed.contab[k]>0:
|
|
659
|
+
if self.contab[k]==0:
|
|
660
|
+
self.Imin[k]=minMed.Imin[k]
|
|
661
|
+
else:
|
|
662
|
+
self.Imin[k]=np.minimum(minMed.Imin[k],self.Imin[k])
|
|
663
|
+
self.med[k]=self.med[k]+minMed.med[k]
|
|
664
|
+
self.contab[k]+=minMed.contab[k]# uno viene comunque sommato in min
|
|
665
|
+
|
|
666
|
+
def calcMed(self):
|
|
667
|
+
''' calcMed and sum media '''
|
|
668
|
+
pri.Time.magenta(f"calcMed contab={self.contab} ")
|
|
669
|
+
#nImg=1 if self.flag_TR else 2
|
|
670
|
+
if self.LaserType==0: # single laser
|
|
671
|
+
for cam in range(self.ncam):
|
|
672
|
+
k=self.nframe*cam
|
|
673
|
+
for j in range(1,self.nframe):
|
|
674
|
+
self.Imin[k]=np.minimum(self.Imin[k],self.Imin[k+j])
|
|
675
|
+
self.med[k]+=self.med[k+j]
|
|
676
|
+
self.contab[k]+=self.contab[k+j]
|
|
677
|
+
self.med[k]/=self.contab[k]
|
|
678
|
+
for j in range(1,self.nframe):
|
|
679
|
+
self.Imin[k+j]=self.Imin[k].copy()
|
|
680
|
+
self.med[k+j]=self.med[k].copy()
|
|
681
|
+
self.contab[k+j]=self.contab[k] #useless? I don't think so, important for restoreMin
|
|
682
|
+
else:
|
|
683
|
+
for k in range(len(self.Imin)):
|
|
684
|
+
if self.contab[k]>0:
|
|
685
|
+
self.med[k]/=self.contab[k]
|
|
686
|
+
pri.Time.magenta(f"calcMed fine contab={self.contab} ")
|
|
687
|
+
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
def restoreMin(self):
|
|
691
|
+
#pr(f"restoreMin contab={self.contab} self.cont={self.cont} self.cont0={self.cont0}")
|
|
692
|
+
#nImg=1 if self.flag_TR else 2
|
|
693
|
+
for k in range(len(self.Imin)):
|
|
694
|
+
self.med[k]*=self.contab[k]
|
|
695
|
+
|
|
696
|
+
def foList(li,formato):
|
|
697
|
+
''' format a list call with
|
|
698
|
+
where:
|
|
699
|
+
li is a list
|
|
700
|
+
format is the format that would have been used fo a single element of the list
|
|
701
|
+
e.g. print(f'{a:<4d}') -> print(f'{foList([a a],"<4d")}')
|
|
702
|
+
'''
|
|
703
|
+
return f"{''.join(f' {x:{formato}}' for x in li)}"
|
|
704
|
+
# todo delete old function
|
|
705
|
+
def writeCfgProcPivOld(data,nomeFile,flagSpiv=False):
|
|
706
|
+
PIV=data2PIV(data,flagSpiv)
|
|
707
|
+
PIV.SetVect([v.astype(np.intc) for v in data.PRO.Vect])
|
|
708
|
+
inp=PIV.Inp
|
|
709
|
+
vect=data.PRO.Vect
|
|
710
|
+
|
|
711
|
+
with open(nomeFile,'w', encoding="utf8") as f:
|
|
712
|
+
f.write('%TA000N3 Do not modify the previous string - It indicates the file version\n')
|
|
713
|
+
f.write('% PIV process configuration file - A % symbol on the first column indicates a comment\n')
|
|
714
|
+
f.write('% Windows dimensions ***************************************\n')
|
|
715
|
+
# % Windows dimensions ***************************************
|
|
716
|
+
f.write(f'[{foList(vect[0],"<3d")}], Height of the windows (rows) - insert the sequence of numbers separated by a blank character (1)\n')
|
|
717
|
+
f.write(f'[{foList(vect[2],"<3d")}], Width of the windows (columns) (2)\n')
|
|
718
|
+
f.write(f'[{foList(vect[1],"<3d")}], Grid distance along the height direction (y) (3)\n')
|
|
719
|
+
f.write(f'[{foList(vect[3],"<3d")}], Grid distance along the width direction (x) (4)\n')
|
|
720
|
+
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')
|
|
721
|
+
# % Process parameters - Interpolation ***********************************
|
|
722
|
+
f.write(f'% Process parameters - Interpolation ***********************************\n')
|
|
723
|
+
f.write(f'{inp.IntIniz}, Type of interpolation in the initial part of the process (6)\n')
|
|
724
|
+
f.write(f'{inp.IntFin}, Type of interpolation in the final part of the process (7)\n')
|
|
725
|
+
f.write(f'{inp.FlagInt}, Flag Interpolation: if >0 the final interpolation is used in the final #par iterations (8)\n')
|
|
726
|
+
f.write(f'{inp.IntCorr}, Type of interpolation of the correlation map (0=gauss classic; 1=gauss reviewed; 2=Simplex) (9)\n')
|
|
727
|
+
f.write(f'{inp.IntVel}, Type of interpolation of the velocity field (1=bilinear; 2= Simplex,...) (10)\n')
|
|
728
|
+
# % Process parameters **************************************\n')
|
|
729
|
+
f.write(f'% Process parameters **************************************\n')
|
|
730
|
+
f.write(f'{inp.FlagDirectCorr}, Flag direct correlation on the final iterations (0=no 1=yes ) (11)\n')
|
|
731
|
+
f.write(f'{inp.NIterazioni}, Number of final iterations (12)\n')
|
|
732
|
+
f.write(f'% Activation flags **************************************\n')
|
|
733
|
+
# % Activation flags - Validation **************************************
|
|
734
|
+
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')
|
|
735
|
+
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')
|
|
736
|
+
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')
|
|
737
|
+
f.write(f'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n')
|
|
738
|
+
f.write(f'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n')
|
|
739
|
+
# % Process parameters - Validation **************************************
|
|
740
|
+
|
|
741
|
+
f.write(f'% Process parameters - Validation **************************************\n')
|
|
742
|
+
f.write(f'{inp.FlagValid}, Flag median test: 0=no; 1=classic; 2=universal (Scarano, Westerweel 2005) (15)\n')
|
|
743
|
+
f.write(f'{inp.SemiDimValid}, Half-dimension of the kernel (it uses 2*(#par)+1 vectors for each direction) (16)\n')
|
|
744
|
+
f.write(f'{inp.SogliaMed:.2f}, Threshold for the median test - Advised value 2 (1.0 - 3.0) (17)\n')
|
|
745
|
+
f.write(f'{inp.ErroreMed:.2f}, Allowed Error in pixel for the median test - Advised value 0.1 (0.0 -> no limits) (18)\n')
|
|
746
|
+
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')
|
|
747
|
+
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')
|
|
748
|
+
f.write(f'{inp.SogliaFcl:.2f}, Threshold correlation coefficient (Advised value 0.25) (21)\n')
|
|
749
|
+
f.write(f'{inp.FlagSecMax}, Flag correction with the second maximum; 0=not active; otherwise it is active (22)\n')
|
|
750
|
+
f.write(f'{inp.FlagCorrezioneVel}, Flag correction vectors: 0=average on correct vectors; 1=weighted average with the distance; 2=iterative average (23)\n')
|
|
751
|
+
f.write(f'{inp.SogliaNoise:.2f}, Minimum allowed average value in the interrogation window (24)\n')
|
|
752
|
+
f.write(f'{inp.SogliaStd:.2f}, Minimum allowed std deviation value in the interrogation window(25)\n')
|
|
753
|
+
f.write(f'{inp.FlagValidNog}, Flag Nogueira Test (discontinued) : 0 --> no; !=0 -->yes (if activated disables the other validation criteria )\n')
|
|
754
|
+
f.write(f'0.2, First parameter Nogueira Test(0.20-0.35) \n')
|
|
755
|
+
f.write(f'0.1, Second parameter Nogueira Test(0.01-0.1) \n')
|
|
756
|
+
f.write(f'{0}, Hart Correction uses 4 interrogation windows W=W-W/Par e H=H-/Par 0 disables\n')
|
|
757
|
+
f.write(f'{0}, Value of info for a good vector \n')
|
|
758
|
+
f.write(f'{1}, Value of info for an outlier\n')
|
|
759
|
+
# % Windowing parameters (Astarita, Exp Flu, 2007) *************************
|
|
760
|
+
f.write(f'% Windowing parameters (Astarita EiF 2007) *************************\n')
|
|
761
|
+
f.write(f'{inp.FlagCalcVel}, Weighting window for absolute velocity (0=TopHat, 1=Nogueira, 2=Blackman,...) (26)\n')
|
|
762
|
+
f.write(f'{inp.FlagWindowing}, Weighting window for the correlation map (0=TopHat 1= Nogueira 2=Blackman 3=top hat at 50%) (27)\n')
|
|
763
|
+
f.write(f'{inp.SemiDimCalcVel}, Half-width of the filtering window (0=window dimension) (28)\n')
|
|
764
|
+
# % Adaptive PIV parameters (Astarita, Exp Flu, 2009) *************************
|
|
765
|
+
f.write(f'% Adaptive PIV parameters (Astarita EiF 2009) *************************\n')
|
|
766
|
+
f.write(f'{inp.MaxC:.3f}, Maximum value of zita (30)\n')
|
|
767
|
+
f.write(f'{inp.MinC:.3f}, Minimum value of zita (30) \n')
|
|
768
|
+
f.write(f'{inp.LarMin}, Minimum Half-width of the weighting window (31)\n')
|
|
769
|
+
f.write(f'{inp.LarMax}, Maximum Half-width of the weighting window (31)\n')
|
|
770
|
+
# % Further processing parameters *************************
|
|
771
|
+
f.write(f'% Further processing parameters *************************\n')
|
|
772
|
+
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')
|
|
773
|
+
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')
|
|
774
|
+
# % Filter parameters *************************
|
|
775
|
+
FlagFilt=0
|
|
776
|
+
CutOff=18
|
|
777
|
+
VelCut=-1
|
|
778
|
+
f.write(f'% Additional filter parameters 2009) *************************\n')
|
|
779
|
+
f.write(f'{FlagFilt:}, Flag for alternate direction filtering 0 disable 1 dense predictor 2 displacement (34)\n')
|
|
780
|
+
f.write(f'{CutOff:.2f}, Vertical Cutoff wavelength (35) \n')
|
|
781
|
+
f.write(f'{VelCut:.2f}, Vertical filter rate (36)\n')
|
|
782
|
+
f.write(f'{CutOff:.2f}, Horizontal Cutoff wavelength (35) \n')
|
|
783
|
+
f.write(f'{VelCut}, Horizontal filter rate (36)\n')
|
|
784
|
+
f.write(f'{inp.FlagRemNoise}, Flag to activate noise removal on the images (37)\n')
|
|
785
|
+
PercCap=-.001
|
|
786
|
+
PercFc=-3
|
|
787
|
+
f.write(f'{PercFc}, Parameter for noise removal (38)\n')
|
|
788
|
+
f.write(f'{PercCap}, Number of std to cap the particles (negative disables) (39)\n')
|
|
789
|
+
|
|
790
|
+
|
|
791
|
+
'''
|
|
792
|
+
try:
|
|
793
|
+
p=PaIRS_lib.PIV()
|
|
794
|
+
p.readCfgProc(nomeFile)
|
|
795
|
+
except Exception as inst:
|
|
796
|
+
pri.Error.white(inst.__cause__)
|
|
797
|
+
|
|
798
|
+
import inspect
|
|
799
|
+
notUsedKey=['FlagLog','HCellaVec','HOverlapVec','ImgH','ImgW','RisX','RisY','WCellaVec','WOverlapVec','dt','this' ]
|
|
800
|
+
diPro= dict(inspect.getmembers(PIV.Inp))
|
|
801
|
+
flagEqual=1
|
|
802
|
+
for k,v in inspect.getmembers(p.Inp):
|
|
803
|
+
if not k[0].startswith('_'):
|
|
804
|
+
if not k in notUsedKey:
|
|
805
|
+
if v!=diPro[k]:
|
|
806
|
+
flagEqual=0
|
|
807
|
+
print(f'{k}={v}->{diPro[k]}')
|
|
808
|
+
if flagEqual:
|
|
809
|
+
pr('The cfg is identical to the master')
|
|
810
|
+
#verifica uguaglianza PROpar, mancano i vettori
|
|
811
|
+
flagEqual=1
|
|
812
|
+
try:
|
|
813
|
+
pro=PIV2Pro(p)
|
|
814
|
+
pDum=data2PIV(data)
|
|
815
|
+
pDum.SetVect([v.astype(np.intc) for v in data.PRO.Vect])
|
|
816
|
+
pro=PIV2Pro(pDum)
|
|
817
|
+
|
|
818
|
+
notUsedKey=['change_top','copyfrom','copyfromdiz','duplicate','indexes','isDifferentFrom','isEqualTo','printDifferences','printPar','setup','tip','uncopied_fields','indTree','indItem']
|
|
819
|
+
listOfList=['Vect' ]
|
|
820
|
+
diPro= dict(inspect.getmembers(data.PRO))
|
|
821
|
+
#pro.printDifferences(data.PRO,[],[],True) #questo è automatico
|
|
822
|
+
for k,v in inspect.getmembers(pro):
|
|
823
|
+
if not k[0].startswith('_') and not k in notUsedKey:
|
|
824
|
+
|
|
825
|
+
if k in listOfList:
|
|
826
|
+
|
|
827
|
+
for i,(a,b) in enumerate(zip (v,diPro[k])):
|
|
828
|
+
if (a!=b).any():
|
|
829
|
+
flagEqual=0
|
|
830
|
+
print(f'{k}[{i}]={a}->{b}')
|
|
831
|
+
else:
|
|
832
|
+
if v!=diPro[k]:
|
|
833
|
+
flagEqual=0
|
|
834
|
+
print(f'{k}={v}->{diPro[k]}')
|
|
835
|
+
if flagEqual:
|
|
836
|
+
pr('The PROpar is identical to the master')
|
|
837
|
+
except Exception as inst:
|
|
838
|
+
pri.Error.red(f'{inst}')
|
|
839
|
+
|
|
840
|
+
|
|
841
|
+
#'''
|
|
842
|
+
def writeCfgProcPiv(data,nomeFile,flagSpiv=False):
|
|
843
|
+
PIV=data2PIV(data,flagSpiv)
|
|
844
|
+
inp=PIV.Inp
|
|
845
|
+
vect=PIV.GetVect()
|
|
846
|
+
vectWindowing=PIV.GetWindowingVect()
|
|
847
|
+
|
|
848
|
+
with open(nomeFile,'w', encoding="utf8") as f:
|
|
849
|
+
f.write('%TA000N5 Do not modify the previous string - It indicates the file version\n')
|
|
850
|
+
f.write('% PIV process configuration file - A % symbol on the first column indicates a comment\n')
|
|
851
|
+
f.write('% Windows dimensions position and iterations *******************************\n')
|
|
852
|
+
# % Windows dimensions position and iterations *******************************
|
|
853
|
+
f.write(f'[{foList(vect[0],"<3d")}], Height of the windows - sequence separated by a space (1)\n')
|
|
854
|
+
f.write(f'[{foList(vect[2],"<3d")}], Width of the IW if equal to -1 then square IW are used (1)\n')
|
|
855
|
+
f.write(f'[{foList(vect[1],"<3d")}], Grid distance along the height direction (y) (2)\n')
|
|
856
|
+
f.write(f'[{foList(vect[3],"<3d")}], Grid distance along x if equal to -1 then a square grid is used (2)\n')
|
|
857
|
+
f.write(f'{inp.FlagBordo}, Pos flag: 0 normal 1 1st vector is placed par#2 from the border (3)\n')
|
|
858
|
+
f.write(f'{inp.NIterazioni}, Number of final iterations (4)\n')
|
|
859
|
+
|
|
860
|
+
# % Process parameters - Interpolation ***********************************
|
|
861
|
+
f.write(f'% Process parameters - Interpolation ***********************************\n')
|
|
862
|
+
f.write(f'[{foList([inp.IntIniz,inp.FlagInt,inp.IntFin],"<3d")}], Image Interpolation: [intial; #iter; final] (5)\n')
|
|
863
|
+
f.write(f'{inp.IntCorr}, Correlation peak IS (3=gauss; 4=gauss reviewed; 5=Simplex) (6)\n')
|
|
864
|
+
f.write(f'{inp.IntVel}, Dense predictor IS (1=bilinear; 2=Simplex...) (7)\n')
|
|
865
|
+
# % Process parameters - Validation ******************************************\n')
|
|
866
|
+
f.write(f'% Process parameters - Validation ******************************************\n')
|
|
867
|
+
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')
|
|
868
|
+
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')
|
|
869
|
+
f.write(f'[{foList([inp.FlagValidNog,inp.SogliaMedia,inp.SogliaNumVet],".6g")}], Nog test:[0 no; 1 active; par1; par2] (10)\n')
|
|
870
|
+
f.write(f'[{foList([inp.SogliaNoise,inp.SogliaStd],".6g")}], Minimum threshold: [mean=2; std=3] (11)\n')
|
|
871
|
+
f.write(f'{inp.FlagCorrHart}, Hart correction 4 IW of W=W-W/Par are used o correct outliers (12)\n')
|
|
872
|
+
f.write(f'{inp.FlagSecMax}, Flag second maximum correction; 0 no 1 active (13)\n')
|
|
873
|
+
f.write(f'{inp.FlagCorrezioneVel}, Flag vectors correction: 0=average on correct vectors; 1=weighted average with the distance; 2=iterative average (14)\n')
|
|
874
|
+
f.write(f'[{foList([inp.InfoSi,inp.InfoNo],".6g")}], Output values (info): [value for good=1; value for corrected=0] (15)\n')
|
|
875
|
+
# % Windowing parameters (Astarita, Exp Flu, 2007) ***************************
|
|
876
|
+
|
|
877
|
+
f.write(f'% Windowing parameters (Astarita, Exp Flu, 2007) ***************************\n')
|
|
878
|
+
f.write(f'[{foList(vectWindowing[1],"<3d")}], WW for predictor (0=TopHat; 2=Blackman;...) (16)\n')
|
|
879
|
+
f.write(f'[{foList(vectWindowing[2],"<3d")}], WW for the correlation map (0=TopHat;2=Blackman 3=top hat at 50%)(17)\n')
|
|
880
|
+
f.write(f'[{foList(vectWindowing[3],"<3d")}], Half-width of the filtering window (0=window dimension) (18)\n')
|
|
881
|
+
f.write(f'[{foList(vectWindowing[4],"<3d")}], Flag direct correlation (0=no 1=yes ) (19)\n')
|
|
882
|
+
f.write(f'[{foList(vectWindowing[0],"<3d")}], Max displacement if <0 fraction of wa i.e. -4-> Wa/4 (20)\n')
|
|
883
|
+
f.write(f'{inp.FlagSommaProd}, Double CC operation (0 Product 1 sum) (21)\n')
|
|
884
|
+
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')
|
|
885
|
+
f.write(f'{inp.ItAtt if not -1000 else 0 }, Flag for restarting from a previous process (0 no; prev iter) (23)\n')
|
|
886
|
+
# % Filter parameters *******************************************************
|
|
887
|
+
f.write(f'% Filter parameters *******************************************************\n')
|
|
888
|
+
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')
|
|
889
|
+
f.write(f'[{foList([inp.FlagRemNoise,inp.PercFc,],".6g")}], Noise reduction removal of particles [0 no; it=2; perc=0.01] (25)\n')
|
|
890
|
+
|
|
891
|
+
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')
|
|
892
|
+
f.write('\n')
|
|
893
|
+
|
|
894
|
+
|
|
895
|
+
|
|
896
|
+
'''
|
|
897
|
+
# Mettere alla fine di updateGuiFromTree
|
|
898
|
+
tree,_=self.w_Tree.pickTree(self.w_Tree.TREpar.indTree)
|
|
899
|
+
d=tree.currentItem().data(0,Qt.UserRole)
|
|
900
|
+
data:dataTreePar=self.w_Tree.TABpar_prev[d.indTree][d.indItem][d.ind]
|
|
901
|
+
data.writeCfgProcPiv()
|
|
902
|
+
#'''
|
|
903
|
+
'''
|
|
904
|
+
try:
|
|
905
|
+
p=PaIRS_lib.PIV()
|
|
906
|
+
p.readCfgProc(nomeFile)
|
|
907
|
+
except Exception as inst:
|
|
908
|
+
pri.Error.white(inst)
|
|
909
|
+
|
|
910
|
+
import inspect
|
|
911
|
+
notUsedKey=['FlagLog','HCellaVec','HOverlapVec','ImgH','ImgW','RisX','RisY','WCellaVec','WOverlapVec','dt','this' ,'FlagCalcVelVec', 'FlagDirectCorrVec','FlagWindowingVec','MaxDispInCCVec','SemiDimCalcVelVec' ]
|
|
912
|
+
diPro= dict(inspect.getmembers(PIV.Inp))
|
|
913
|
+
app=1e-6# to avoid false detections in case of float
|
|
914
|
+
flagEqual=1
|
|
915
|
+
for k,v in inspect.getmembers(p.Inp):
|
|
916
|
+
if not k[0].startswith('_'):
|
|
917
|
+
if not k in notUsedKey:
|
|
918
|
+
if v!=diPro[k]:
|
|
919
|
+
flagEqual=0
|
|
920
|
+
print(f'{k}={v}->{diPro[k]}')
|
|
921
|
+
if flagEqual:
|
|
922
|
+
pr('The cfg is identical to the master')
|
|
923
|
+
#verifica uguaglianza PROpar, mancano i vettori
|
|
924
|
+
flagEqual=1
|
|
925
|
+
|
|
926
|
+
try:
|
|
927
|
+
#pro=PIV2Pro(p)
|
|
928
|
+
pDum=data2PIV(data)
|
|
929
|
+
pDum.SetVect([v.astype(np.intc) for v in data.PRO.Vect])
|
|
930
|
+
pro=PIV2Pro(pDum)
|
|
931
|
+
|
|
932
|
+
notUsedKey=['change_top','copyfrom','copyfromdiz','duplicate','indexes','isDifferentFrom','isEqualTo','printDifferences','printPar','setup','tip','uncopied_fields','indTree','indItem']
|
|
933
|
+
listOfList=['Vect' ]## to add ,'windowingVect'
|
|
934
|
+
diPro= dict(inspect.getmembers(data.PRO))
|
|
935
|
+
#pro.printDifferences(data.PRO,[],[],True) #questo è automatico
|
|
936
|
+
for k,v in inspect.getmembers(pro):
|
|
937
|
+
if not k[0].startswith('_') and not k in notUsedKey:
|
|
938
|
+
|
|
939
|
+
if k in listOfList:
|
|
940
|
+
|
|
941
|
+
for i,(a,b) in enumerate(zip (v,diPro[k])):
|
|
942
|
+
if (a!=b).any():
|
|
943
|
+
flagEqual=0
|
|
944
|
+
print(f'{k}[{i}]={a}->{b}')
|
|
945
|
+
else:
|
|
946
|
+
if v!=diPro[k]:
|
|
947
|
+
if isinstance(v, float) and v !=0 :
|
|
948
|
+
if abs((v-diPro[k])/v) >app:
|
|
949
|
+
flagEqual=0
|
|
950
|
+
print(f'{k}={v}->{diPro[k]}')
|
|
951
|
+
if flagEqual:
|
|
952
|
+
pr('The PROpar is identical to the master')
|
|
953
|
+
except Exception as inst:
|
|
954
|
+
pri.Error.red(f'{inst}')
|
|
955
|
+
|
|
956
|
+
|
|
957
|
+
#'''
|
|
958
|
+
# TODO rivedere quando Gerardo aggiunge i vettori
|
|
959
|
+
def PIV2Pro(piv:PaIRS_lib.PIV)-> PROpar:
|
|
960
|
+
pro=PROpar()
|
|
961
|
+
|
|
962
|
+
#PIV.SetVect([v.astype(np.intc) for v in data.PRO.Vect])
|
|
963
|
+
pro.Vect=[v.astype(np.intc) for v in piv.GetVect()]
|
|
964
|
+
#pro.windowingVect=[v.astype(np.intc) for v in piv.GetVect()]
|
|
965
|
+
|
|
966
|
+
pro.SogliaNoise=piv.Inp.SogliaNoise
|
|
967
|
+
pro.SogliaStd=piv.Inp.SogliaStd
|
|
968
|
+
pro.SogliaMed=piv.Inp.SogliaMed
|
|
969
|
+
pro.ErroreMed=piv.Inp.ErroreMed
|
|
970
|
+
# Parameters not used in PaIrs but read by readcfg.
|
|
971
|
+
# int FlagFilt;
|
|
972
|
+
# Tom_Real CutOffH; // Lunghezza d'onda massima per il filtro
|
|
973
|
+
# Tom_Real CutOffW; // Lunghezza d'onda massima per il filtro
|
|
974
|
+
# Tom_Real VelCutH; // Rateo di filtraggio
|
|
975
|
+
# Tom_Real VelCutW; //
|
|
976
|
+
# Tom_Real PercCap; // PPercentuale massimo livello di grigio non trattato
|
|
977
|
+
# Tom_Real PercFc; // Percentuale per considerare cattivo un punto
|
|
978
|
+
# int FlagCorrHart; // Flag Per Correzione Hart
|
|
979
|
+
# These parameters are not exposed in Inp if needed modify PIV_input.i
|
|
980
|
+
#Valid Nog
|
|
981
|
+
pro.SogliaMedia=0.25#piv.Inp.SogliaMedia
|
|
982
|
+
pro.SogliaNumVet=0.10#piv.Inp.SogliaNumVet
|
|
983
|
+
pro.FlagCorrHart=0#piv.Inp.SogliaNumVet
|
|
984
|
+
|
|
985
|
+
if piv.Inp.FlagValidNog==1:
|
|
986
|
+
pro.FlagNogTest=1
|
|
987
|
+
pro.FlagMedTest=0
|
|
988
|
+
pro.FlagCPTest=0
|
|
989
|
+
pro.FlagSNTest =0
|
|
990
|
+
else:
|
|
991
|
+
if piv.Inp.FlagValid>0 :
|
|
992
|
+
pro.FlagMedTest=1
|
|
993
|
+
pro.TypeMed=piv.Inp.FlagValid-1
|
|
994
|
+
pro.KernMed=piv.Inp.SemiDimValid
|
|
995
|
+
pro.FlagSecMax=piv.Inp.FlagSecMax
|
|
996
|
+
pro.FlagSNTest =1 if piv.Inp.FlagAttivaValSN&1 else 0
|
|
997
|
+
pro.FlagCPTest =1 if piv.Inp.FlagAttivaValSN&2 else 0
|
|
998
|
+
|
|
999
|
+
pro.SogliaSN=piv.Inp.SogliaSN
|
|
1000
|
+
pro.SogliaCP=piv.Inp.SogliaFcl
|
|
1001
|
+
|
|
1002
|
+
pro.IntIniz=piv.Inp.IntIniz
|
|
1003
|
+
pro.IntFin=piv.Inp.IntFin
|
|
1004
|
+
pro.FlagInt=piv.Inp.FlagInt
|
|
1005
|
+
pro.IntVel=piv.Inp.IntVel
|
|
1006
|
+
pro.FlagCorrezioneVel=piv.Inp.FlagCorrezioneVel
|
|
1007
|
+
#pro.FlagCorrHart=PIV.Inp.FlagCorrHart
|
|
1008
|
+
pro.IntCorr=piv.Inp.IntCorr
|
|
1009
|
+
pro.FlagWindowing=piv.Inp.FlagWindowing
|
|
1010
|
+
|
|
1011
|
+
pro.MaxC=piv.Inp.MaxC
|
|
1012
|
+
pro.MinC=piv.Inp.MinC
|
|
1013
|
+
pro.LarMin=piv.Inp.LarMin
|
|
1014
|
+
pro.LarMax=piv.Inp.LarMax
|
|
1015
|
+
|
|
1016
|
+
pro.FlagCalcVel=piv.Inp.FlagCalcVel
|
|
1017
|
+
pro.FlagSommaProd=piv.Inp.FlagSommaProd
|
|
1018
|
+
pro.FlagDirectCorr=piv.Inp.FlagDirectCorr
|
|
1019
|
+
pro.FlagBordo=piv.Inp.FlagBordo
|
|
1020
|
+
|
|
1021
|
+
if piv.Inp.SemiDimCalcVel<0:
|
|
1022
|
+
pro.NItAdaptative=-piv.Inp.SemiDimCalcVel
|
|
1023
|
+
pro.NIterazioni=piv.Inp.NIterazioni-pro.NItAdaptative
|
|
1024
|
+
pro.FlagAdaptative=1
|
|
1025
|
+
else:
|
|
1026
|
+
pro.SemiDimCalcVel=piv.Inp.SemiDimCalcVel
|
|
1027
|
+
pro.NIterazioni=piv.Inp.NIterazioni
|
|
1028
|
+
pro.FlagAdaptative=0
|
|
1029
|
+
|
|
1030
|
+
return pro
|
|
1031
|
+
|
|
1032
|
+
def data2PIV(data:dataTreePar,flagSpiv=False):
|
|
1033
|
+
OUT=OUTpar()
|
|
1034
|
+
OUT.copyfromdiz(data.OUT_dict)
|
|
1035
|
+
PRO=PROpar()
|
|
1036
|
+
PRO.copyfromdiz(data.PRO_dict)
|
|
1037
|
+
|
|
1038
|
+
if flagSpiv:
|
|
1039
|
+
PIV=PaIRS_lib.Stereo()
|
|
1040
|
+
else:
|
|
1041
|
+
PIV=PaIRS_lib.PIV()
|
|
1042
|
+
|
|
1043
|
+
PIV.DefaultValues()
|
|
1044
|
+
PIV.Inp.FlagNumThreads=data.numPivOmpCores
|
|
1045
|
+
#OUT=data.OUT
|
|
1046
|
+
#PRO=data.PRO
|
|
1047
|
+
|
|
1048
|
+
# % Windows dimensions position and iterations *******************************
|
|
1049
|
+
PIV.SetVect([np.array(v).astype(np.intc) for v in PRO.Vect])
|
|
1050
|
+
PIV.Inp.FlagBordo=PRO.FlagBordo
|
|
1051
|
+
PIV.Inp.NIterazioni=PRO.NIterazioni+PRO.NItAdaptative if PRO.FlagAdaptative else PRO.NIterazioni
|
|
1052
|
+
# % Process parameters - Interpolation ***********************************
|
|
1053
|
+
PIV.Inp.IntIniz=PRO.IntIniz
|
|
1054
|
+
PIV.Inp.FlagInt=PRO.FlagInt
|
|
1055
|
+
PIV.Inp.IntFin=PRO.IntFin
|
|
1056
|
+
PIV.Inp.IntCorr=PRO.IntCorr+3
|
|
1057
|
+
PIV.Inp.IntVel=PRO.IntVel
|
|
1058
|
+
|
|
1059
|
+
# % Process parameters - Validation ******************************************
|
|
1060
|
+
# Median test : [0 = no; 1 = med; 2 = univ, kernel dim = 1, thr = 2, eps = 0.1] (8)
|
|
1061
|
+
PIV.Inp.FlagValid=1 if PRO.TypeMed==0 else 2
|
|
1062
|
+
PIV.Inp.SemiDimValid=PRO.KernMed
|
|
1063
|
+
PIV.Inp.SogliaMed=PRO.SogliaMed
|
|
1064
|
+
PIV.Inp.ErroreMed=PRO.ErroreMed
|
|
1065
|
+
PIV.Inp.jumpDimValid=1
|
|
1066
|
+
# sn/CC test: [0=no; 1=sn; 2=CC; 3=both,sn thr=1.5, cc thr=0.3] (9)
|
|
1067
|
+
PIV.Inp.FlagAttivaValSN=1 if PRO.FlagSNTest else 0
|
|
1068
|
+
PIV.Inp.FlagAttivaValSN|=2 if PRO.FlagCPTest else 0
|
|
1069
|
+
PIV.Inp.SogliaSN=PRO.SogliaSN
|
|
1070
|
+
PIV.Inp.SogliaFcl=PRO.SogliaCP
|
|
1071
|
+
|
|
1072
|
+
# Nog test : [0 no; 1 active, par1, par2] (10)
|
|
1073
|
+
PIV.Inp.FlagValidNog=1 if PRO.FlagNogTest else 0
|
|
1074
|
+
PIV.Inp.SogliaMedia=PRO.SogliaMedia
|
|
1075
|
+
PIV.Inp.SogliaNumVet=PRO.SogliaNumVet
|
|
1076
|
+
|
|
1077
|
+
PIV.Inp.SogliaNoise=PRO.SogliaNoise
|
|
1078
|
+
PIV.Inp.SogliaStd=PRO.SogliaStd
|
|
1079
|
+
|
|
1080
|
+
PIV.Inp.FlagCorrHart=0 # to be seen
|
|
1081
|
+
PIV.Inp.FlagSecMax=1 if PRO.FlagSecMax else 0
|
|
1082
|
+
PIV.Inp.FlagCorrezioneVel=PRO.FlagCorrezioneVel
|
|
1083
|
+
# Output values(info) : [value for good = 1, value for corrected = 0] (16)
|
|
1084
|
+
PIV.Inp.InfoSi=1
|
|
1085
|
+
PIV.Inp.InfoNo=0
|
|
1086
|
+
|
|
1087
|
+
# % Windowing parameters (Astarita, Exp Flu, 2007) ***************************
|
|
1088
|
+
PIV.Inp.numInitIt=max(len(v) for v in PRO.Vect)
|
|
1089
|
+
PIV.Inp.FlagWindowing=PRO.FlagWindowing
|
|
1090
|
+
"""
|
|
1091
|
+
if (PIV.Inp.FlagWindowing >= 0) :
|
|
1092
|
+
FlagWindowingVec=np.array([PIV.Inp.FlagWindowing],dtype=np.intc)
|
|
1093
|
+
else :
|
|
1094
|
+
numInitIt = PIV.Inp.numInitIt +1# if negative onlhy in the final iterations
|
|
1095
|
+
FlagWindowingVec=np.array([0 if ii<numInitIt -1 else -PIV.Inp.FlagWindowing for ii in range(numInitIt) ],dtype=np.intc)
|
|
1096
|
+
"""
|
|
1097
|
+
FlagWindowingVec=np.array(PRO.vFlagWindowing,dtype=np.intc)
|
|
1098
|
+
|
|
1099
|
+
flagCalcVelVec=np.array(PRO.vFlagCalcVel,dtype=np.intc)
|
|
1100
|
+
semiDimCalcVelVec=np.array(PRO.vSemiDimCalcVel,dtype=np.intc)
|
|
1101
|
+
|
|
1102
|
+
PIV.Inp.FlagDirectCorr=PRO.FlagDirectCorr
|
|
1103
|
+
"""
|
|
1104
|
+
if (PIV.Inp.FlagDirectCorr == 0) :
|
|
1105
|
+
FlagDirectCorrVec=np.array([PIV.Inp.FlagDirectCorr],dtype=np.intc)
|
|
1106
|
+
else :
|
|
1107
|
+
numInitIt = PIV.Inp.numInitIt +(PIV.Inp.FlagDirectCorr - 1)# if equal to 2 then should be one element longer
|
|
1108
|
+
FlagDirectCorrVec=np.array([0 if ii<numInitIt -1 else 1 for ii in range(numInitIt) ],dtype=np.intc)
|
|
1109
|
+
"""
|
|
1110
|
+
FlagDirectCorrVec=np.array(PRO.vDC,dtype=np.intc)
|
|
1111
|
+
|
|
1112
|
+
maxDispInCCVec=np.array(PRO.vMaxDisp,dtype=np.intc)
|
|
1113
|
+
vect1=[maxDispInCCVec,flagCalcVelVec,FlagWindowingVec,semiDimCalcVelVec,FlagDirectCorrVec]
|
|
1114
|
+
|
|
1115
|
+
PIV.Inp.numInitIt=max(*[len(v) for v in vect1],PIV.Inp.numInitIt)
|
|
1116
|
+
|
|
1117
|
+
PIV.SetWindowingVect(vect1)
|
|
1118
|
+
PIV.Inp.FlagSommaProd=PRO.FlagSommaProd
|
|
1119
|
+
|
|
1120
|
+
# Adaptive process[0 = no; #of it, par1, par2, par3, par4](22)
|
|
1121
|
+
# questo è l'equivalente del c
|
|
1122
|
+
#PIV.Inp.flagAdaptive =-PIV.Inp.SemiDimCalcVel if PIV.Inp.SemiDimCalcVel <= -1 else 0
|
|
1123
|
+
#PIV.Inp.SemiDimCalcVel = abs(PIV.Inp.SemiDimCalcVel)
|
|
1124
|
+
#flagCalcVelVec=np.array(abs(PIV.Inp.SemiDimCalcVel),dtype=np.intc)
|
|
1125
|
+
PIV.Inp.flagAdaptive =PRO.NItAdaptative if PRO.FlagAdaptative else 0
|
|
1126
|
+
PIV.Inp.MaxC=PRO.MaxC
|
|
1127
|
+
PIV.Inp.MinC=PRO.MinC
|
|
1128
|
+
PIV.Inp.LarMin=PRO.LarMin
|
|
1129
|
+
PIV.Inp.LarMax=PRO.LarMax
|
|
1130
|
+
|
|
1131
|
+
PIV.Inp.ItAtt=-1000
|
|
1132
|
+
|
|
1133
|
+
|
|
1134
|
+
PIV.Inp.RisX=OUT.xres#*float(10.0)
|
|
1135
|
+
PIV.Inp.RisY=OUT.xres*OUT.pixAR#*float(10.0)
|
|
1136
|
+
PIV.Inp.dt=OUT.dt*float(10)
|
|
1137
|
+
PIV.Inp.ImgH=OUT.h
|
|
1138
|
+
PIV.Inp.ImgW=OUT.W
|
|
1139
|
+
''' already done in DefaultValues
|
|
1140
|
+
|
|
1141
|
+
PIV.Inp.FlagFilt = 0; # Flag filtro: 0 nessuno, 1 AD,
|
|
1142
|
+
PIV.Inp.CutOffH=18; # Lunghezza d'onda massima per il filtro
|
|
1143
|
+
PIV.Inp.VelCutH=-1; # Rateo di filtraggio
|
|
1144
|
+
PIV.Inp.CutOffW=18; # Lunghezza d'onda massima per il filtro
|
|
1145
|
+
PIV.Inp.VelCutW=-1; #
|
|
1146
|
+
PIV.Inp.FlagRemNoise = 0; # Flag per eliminare rumore 0 no,1 si
|
|
1147
|
+
PIV.Inp.PercFc=0.01; # Percentuale per considerare cattivo un punto
|
|
1148
|
+
PIV.Inp.PercCap=-1.05; # PPercentuale massimo livello di grigio non trattato
|
|
1149
|
+
'''
|
|
1150
|
+
|
|
1151
|
+
|
|
1152
|
+
return PIV
|
|
1153
|
+
|
|
1154
|
+
def data2StereoPIV(data:dataTreePar):
|
|
1155
|
+
StereoPIV=data2PIV(data,flagSpiv=True)
|
|
1156
|
+
|
|
1157
|
+
OUT=OUTpar()
|
|
1158
|
+
OUT.copyfromdiz(data.OUT_dict)
|
|
1159
|
+
PRO=PROpar()
|
|
1160
|
+
PRO.copyfromdiz(data.PRO_dict)
|
|
1161
|
+
|
|
1162
|
+
spiv=StereoPIV.SPIVIn
|
|
1163
|
+
dP=StereoPIV.dataProc
|
|
1164
|
+
inPiv=StereoPIV.Inp
|
|
1165
|
+
|
|
1166
|
+
# STEREO CFG file
|
|
1167
|
+
# A €£ indicate that the feature is not enabled in the python wrapper
|
|
1168
|
+
spiv.nomecal='' # Root of calibration constants
|
|
1169
|
+
#spiv.NomeCostPiano=data.dispFile[:-4] # Root of disparity plane constants
|
|
1170
|
+
|
|
1171
|
+
spiv.percorsocal='' # Path of calibration constants
|
|
1172
|
+
spiv.FlagParallel=0 # Type of parallel process 0 horizontal 1 vertical (faster but with less information and mor RAM occupied)
|
|
1173
|
+
dP.FlagInt=StereoPIV.Inp.IntFin # IS for image reconstruction (only used when FlagRad==0)
|
|
1174
|
+
inPiv.FlagRad=1 # 1 internal (in piv) or 0 external de-warping of the images (the latter €£)
|
|
1175
|
+
dP.FlagCoordRad=0 # when equal to 0 the de-warping is carried on with the larger resolution (pix/mm)
|
|
1176
|
+
# when equal to 1 (2) the x (y) axis resolution is used
|
|
1177
|
+
spiv.salvarad=0 # if true and FlagRad is equal to 0 then the dewarped images are saved (€£)
|
|
1178
|
+
|
|
1179
|
+
|
|
1180
|
+
# % ********************* Input/Output
|
|
1181
|
+
spiv.FirstImg=0 # # of first img to be processed (€£)
|
|
1182
|
+
spiv.LastImg=0 # # of first last to be processed (€£)
|
|
1183
|
+
spiv.Digit=0 # number of figures i.e. zeros (MAX 10) (€£)
|
|
1184
|
+
spiv.ImgRoot='' # Root of the input Images (€£)
|
|
1185
|
+
spiv.InDir='' # Path of the images (€£)
|
|
1186
|
+
spiv.InExt='' # Extension of the images (€£)
|
|
1187
|
+
spiv.OutRoot ='' # Root of the output Files (€£)
|
|
1188
|
+
spiv.OutDir ='' # Output path (€£)
|
|
1189
|
+
spiv.OutExt ='' # Output extension (€£)
|
|
1190
|
+
spiv.OutFlag = 0 # type of output file : 0 binary Tecplot 1 ascii tecplot (€£)
|
|
1191
|
+
spiv.WrtFlag = 1 # 0 only mean values are saved 1 all the instantaneous images are written (€£)
|
|
1192
|
+
|
|
1193
|
+
spiv.RigaPart=OUT.x # Starting row (€£)
|
|
1194
|
+
spiv.ColPart=OUT.y # Starting Col (€£)
|
|
1195
|
+
dP.ImgH=OUT.H # Ending row
|
|
1196
|
+
dP.ImgW=OUT.W # Starting Col
|
|
1197
|
+
# % *********************** Process parameters
|
|
1198
|
+
dP.FlagZonaCom=0 # Flag for common zone should be equal to 0
|
|
1199
|
+
# Volume ********************************
|
|
1200
|
+
dP.xinfZC = OUT.x_min # minimum x world coordinates
|
|
1201
|
+
dP.yinfZC = OUT.y_min # minimum y world coordinates
|
|
1202
|
+
dP.xsupZC = OUT.x_max # maximum x world coordinates
|
|
1203
|
+
dP.ysupZC = OUT.y_max # maximum y world coordinates
|
|
1204
|
+
spiv.FlagRis=OUT.unit # 0 displacements in m/s 1 in pixels
|
|
1205
|
+
spiv.dt=OUT.dt # time separation. If the displacements in mm are needed use 1000 (and 0 for the previous parameter)
|
|
1206
|
+
spiv.Sfas=3 # in case of images in a single file the distance between images. Normally define the name (€£)
|
|
1207
|
+
# 1=a,b (after number); 2=_1,_2 (after number); 3=a,b (before number)
|
|
1208
|
+
# % Output
|
|
1209
|
+
spiv.FlagRotImg=0 # Rotation of the img 0=no rot 1=90°, 2=180° 3= 270° clockwise (£€)
|
|
1210
|
+
inPiv.FlagLog=9 # 0=no 1=video 2=log 3=video e log 4=Log short 5=video e log short (£€)
|
|
1211
|
+
spiv.StatFlag =0 # stat on: 1 all the vectors 0 only the good ones
|
|
1212
|
+
spiv.nomecfgPiv ='' # name of the cfg file for PIV
|
|
1213
|
+
|
|
1214
|
+
# ******************************
|
|
1215
|
+
flagReadCalConst=0# if true internal reading
|
|
1216
|
+
if flagReadCalConst:
|
|
1217
|
+
StereoPIV.readCalConst()
|
|
1218
|
+
else:
|
|
1219
|
+
c=0
|
|
1220
|
+
cost=[]
|
|
1221
|
+
for c in range(2):
|
|
1222
|
+
fileName=data.calList[c]
|
|
1223
|
+
flagCal,numCostCalib,costDum=readCalFile(fileName)
|
|
1224
|
+
if c==0:
|
|
1225
|
+
dP.FlagCal=flagCal
|
|
1226
|
+
dP.NumCostCalib=numCostCalib
|
|
1227
|
+
else:
|
|
1228
|
+
if (dP.FlagCal!=flagCal):
|
|
1229
|
+
raise('error the two calibration file are not compatible')
|
|
1230
|
+
cost.append(costDum)
|
|
1231
|
+
StereoPIV.setCalConst( flagCal, numCostCalib,cost)
|
|
1232
|
+
|
|
1233
|
+
StereoPIV.vect.PianoLaser[0]=np.float32(data.OUT_dict['zconst'])
|
|
1234
|
+
StereoPIV.vect.PianoLaser[1]=np.float32(data.OUT_dict['xterm'])
|
|
1235
|
+
StereoPIV.vect.PianoLaser[2]=np.float32(data.OUT_dict['yterm'])
|
|
1236
|
+
"""
|
|
1237
|
+
flagReadPlaneConst=0# if true internal reading
|
|
1238
|
+
if flagReadPlaneConst:
|
|
1239
|
+
if StereoPIV.readPlaneConst()==0:
|
|
1240
|
+
pri.Callback.green('Laser plane constants correclty read!')
|
|
1241
|
+
else:
|
|
1242
|
+
pri.Error.red('Error while reading the file containing the laser plane constants!')
|
|
1243
|
+
data.laserConst=[const for const in StereoPIV.vect.PianoLaser]
|
|
1244
|
+
else:
|
|
1245
|
+
StereoPIV.vect.PianoLaser[0]=data.laserConst[0]
|
|
1246
|
+
StereoPIV.vect.PianoLaser[1]=data.laserConst[1]
|
|
1247
|
+
StereoPIV.vect.PianoLaser[2]=data.laserConst[2]
|
|
1248
|
+
#piv *******************************************************************************
|
|
1249
|
+
"""
|
|
1250
|
+
#StereoPIV.readCfgProc(spiv.nomecfgPiv)
|
|
1251
|
+
return StereoPIV
|
|
1252
|
+
|
|
1253
|
+
def data2Disp(data:dataTreePar):
|
|
1254
|
+
OUT=OUTpar()
|
|
1255
|
+
OUT.copyfromdiz(data.OUT_dict)
|
|
1256
|
+
PRO_Disp=PROpar_Disp()
|
|
1257
|
+
PRO_Disp.copyfromdiz(data.PRO_Disp_dict)
|
|
1258
|
+
|
|
1259
|
+
Disp=PaIRS_lib.StereoDisp()
|
|
1260
|
+
spiv=Disp.SPIVIn
|
|
1261
|
+
dP=Disp.dataProc
|
|
1262
|
+
dAC=Disp.dispAvCo
|
|
1263
|
+
|
|
1264
|
+
spiv.nomecal='' #os.path.splitext(os.path.basename(INP.calList[0])) # Root of calibration constants
|
|
1265
|
+
spiv.percorsocal='' #os.path.dirname(INP.calList[0]) #Path of calibration constants
|
|
1266
|
+
spiv.ImgRoot='' # Root input Images
|
|
1267
|
+
spiv.InExt='' # Extension of the images
|
|
1268
|
+
spiv.InDir='' #Path of the images
|
|
1269
|
+
spiv.FirstImg=0 # # of first img to be processed
|
|
1270
|
+
spiv.LastImg=0 # # of first last to be processed
|
|
1271
|
+
spiv.Digit=0 # number of figures i.e. zeros (MAX 10)
|
|
1272
|
+
|
|
1273
|
+
spiv.RigaPart=OUT.y # Starting row
|
|
1274
|
+
spiv.ColPart=OUT.x # Starting column
|
|
1275
|
+
dP.ImgH=OUT.h # Ending row
|
|
1276
|
+
dP.ImgW=OUT.w # Starting row
|
|
1277
|
+
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
|
|
1278
|
+
spiv.FlagImgTau=data.dispFrames # Img da processare: 0-entrambe; 1-solo la prima; 2-solo la seconda;PARAMETRO IGNORATO SE SFAS=0
|
|
1279
|
+
|
|
1280
|
+
#Output
|
|
1281
|
+
spiv.OutRoot = OUT.root # Root of output Files
|
|
1282
|
+
spiv.OutDir = OUT.path+OUT.subfold # Output path
|
|
1283
|
+
# Process parameters **********************
|
|
1284
|
+
dP.FlagInt=PRO_Disp.IntIniz # Metodo di raddrizzamento: 0=veloce (simp.), 1=quad…….
|
|
1285
|
+
dP.FlagZonaCom=0 # Flag per la zona comune: 0=coordinate nel piano oggetto; 1=coord. nel piano img
|
|
1286
|
+
spiv.Niter=PRO_Disp.Nit # Numero di iterazioni
|
|
1287
|
+
"""
|
|
1288
|
+
if (spiv.Niter < 0) :
|
|
1289
|
+
spiv.WrtFlag = 1
|
|
1290
|
+
spiv.Niter = -spiv.Niter
|
|
1291
|
+
else:
|
|
1292
|
+
spiv.WrtFlag = 0
|
|
1293
|
+
"""
|
|
1294
|
+
|
|
1295
|
+
dAC.HCella=PRO_Disp.Vect[0] # Correlation window Height
|
|
1296
|
+
dAC.WCella=PRO_Disp.Vect[2] # Correlation window Width
|
|
1297
|
+
dAC.HGrid=PRO_Disp.Vect[1] # Grid distance vertical
|
|
1298
|
+
dAC.WGrid=PRO_Disp.Vect[3] # Grid distance horizontal
|
|
1299
|
+
dAC.N_NormEpi=PRO_Disp.SemiWidth_Epipolar # Semiwidth in the direction normal to the epipolar line
|
|
1300
|
+
dAC.RaggioFiltro=PRO_Disp.Filter_SemiWidth # Semiwidth of the filter for the detection of the maximum in the displacement map
|
|
1301
|
+
dAC.SogliaCor = PRO_Disp.Threshold # Threshold for the determination of point used in the baricentric search of the maximum in the disp map
|
|
1302
|
+
dAC.nIterMaxValid = PRO_Disp.Nit_OutDet
|
|
1303
|
+
dAC.numStd = PRO_Disp.Std_Threshold
|
|
1304
|
+
|
|
1305
|
+
#%% Volume ********************************
|
|
1306
|
+
dP.xinfZC = OUT.x_min # Coordinata x inferiore
|
|
1307
|
+
dP.yinfZC = OUT.y_min # Coordinata y inferiore
|
|
1308
|
+
dP.xsupZC = OUT.x_max #28 # Coordinata x superiore
|
|
1309
|
+
dP.ysupZC = OUT.y_max #15 # Coordinata y superiore
|
|
1310
|
+
# ******************************
|
|
1311
|
+
flagReadCalConst=0# if true internal reading
|
|
1312
|
+
if flagReadCalConst:
|
|
1313
|
+
Disp.readCalConst()
|
|
1314
|
+
else:
|
|
1315
|
+
c=0
|
|
1316
|
+
cost=[]
|
|
1317
|
+
for c in range(2):
|
|
1318
|
+
fileName=data.calList[c]
|
|
1319
|
+
flagCal,numCostCalib,costDum=readCalFile(fileName)
|
|
1320
|
+
if c==0:
|
|
1321
|
+
dP.FlagCal=flagCal
|
|
1322
|
+
dP.NumCostCalib=numCostCalib
|
|
1323
|
+
else:
|
|
1324
|
+
if (dP.FlagCal!=flagCal):
|
|
1325
|
+
raise('error the two calibration file are not compatible')
|
|
1326
|
+
cost.append(costDum)
|
|
1327
|
+
Disp.setCalConst( flagCal, numCostCalib,cost)
|
|
1328
|
+
|
|
1329
|
+
flagReadPlaneConst=0# if true internal reading
|
|
1330
|
+
if flagReadPlaneConst:
|
|
1331
|
+
if Disp.readPlaneConst()==0:
|
|
1332
|
+
pri.Callback.green('readPlaneConst ok')
|
|
1333
|
+
else:
|
|
1334
|
+
Disp.vect.PianoLaser[0]=0
|
|
1335
|
+
Disp.vect.PianoLaser[1]=0
|
|
1336
|
+
Disp.vect.PianoLaser[2]=0
|
|
1337
|
+
return Disp
|
|
1338
|
+
|
|
1339
|
+
def printPIVLog(PD):
|
|
1340
|
+
stampa="It IW #IW #Vect/#Tot % CC CC(avg) DC%\n"# NR% Cap%\n"
|
|
1341
|
+
for j in range(len(PD.It)):
|
|
1342
|
+
riga="%3d %3dx%-3d %4dx%-4d %7d/%-7d %5.1f %8.7f %8.7f %4.1f\n" %\
|
|
1343
|
+
(PD.It[j], PD.WCella[j], PD.HCella[j], PD.W[j], PD.H[j], PD.NVect[j],\
|
|
1344
|
+
PD.W[j]*PD.H[j], 100.0*PD.NVect[j]/(PD.W[j]*PD.H[j]), PD.Fc[j],\
|
|
1345
|
+
PD.FcMedia[j], 100.0*PD.ContErorreDc[j]/(PD.W[j]*PD.H[j]))#,\
|
|
1346
|
+
#100.0*PIV.PD.ContRemNoise[j]/(PIV.Inp.ImgW*PIV.Inp.ImgH),\
|
|
1347
|
+
#100.0*PIV.PD.ContCap[j]/(PIV.Inp.ImgW*PIV.Inp.ImgH))
|
|
1348
|
+
stampa=stampa+riga
|
|
1349
|
+
return stampa
|
|
1350
|
+
|
|
1351
|
+
|
|
1352
|
+
def saveMin(data:dataTreePar,Imin=list):
|
|
1353
|
+
pri.Time.magenta('saveMin Init ')
|
|
1354
|
+
frames='ab'
|
|
1355
|
+
#nImg=1 if self.flag_TR else 2
|
|
1356
|
+
#nImg=2
|
|
1357
|
+
for j in range(len(Imin)):
|
|
1358
|
+
k=j%data.nframe
|
|
1359
|
+
cam=j//data.nframe%data.ncam
|
|
1360
|
+
name_min=f"{data.outPathRoot}_cam{cam+1}_{frames[k]}_min.png"
|
|
1361
|
+
im = Image.fromarray(Imin[j])
|
|
1362
|
+
im.save(name_min)
|
|
1363
|
+
pri.Time.magenta('saveMin End')
|
|
1364
|
+
|
|
1365
|
+
def saveResults(data:dataTreePar,i,Var,nameVar):
|
|
1366
|
+
#pri.Time.magenta('saveResults Init')
|
|
1367
|
+
if type(i)==int:
|
|
1368
|
+
if i<0:
|
|
1369
|
+
nameFileOut=data.resF('*').replace('_*','')
|
|
1370
|
+
else:
|
|
1371
|
+
nameFileOut=data.resF(i)
|
|
1372
|
+
elif type(i)==str:
|
|
1373
|
+
nameFileOut=data.resF(i)
|
|
1374
|
+
#infoPrint.white(f'---> Saving field #{i}: {nameFileOut}')
|
|
1375
|
+
|
|
1376
|
+
if '.plt' in data.outExt:
|
|
1377
|
+
writePlt(nameFileOut,Var,f'PaIRS - 2D PIV',nameVar,nameFileOut)
|
|
1378
|
+
elif '.mat' in data.outExt:
|
|
1379
|
+
dict_out={}
|
|
1380
|
+
for j in range(len(nameVar)):
|
|
1381
|
+
dict_out[nameVar[j]]=Var[j]
|
|
1382
|
+
scipy.io.savemat(nameFileOut,dict_out)
|
|
1383
|
+
#import timeit
|
|
1384
|
+
#timeit.timeit (lambda :'writePlt(nameFileOut,Var,"b16",nameVar,nameFileOut)')
|
|
1385
|
+
#timeit.timeit (lambda :'scipy.io.savemat(nameFileOut,dict_out)')
|
|
1386
|
+
#pri.Time.magenta('saveResults End')
|
|
1387
|
+
return
|
|
1388
|
+
|
|
1389
|
+
def memoryUsagePsutil():
|
|
1390
|
+
''' return the memory usage in MB '''
|
|
1391
|
+
process = psutil.Process(os.getpid())
|
|
1392
|
+
mem = process.memory_info().rss
|
|
1393
|
+
#print(f"Memory={mem/ float(2 ** 20)}MByte")
|
|
1394
|
+
return mem
|