PaIRS-UniNa 0.2.0__cp310-cp310-win_amd64.whl → 0.2.8__cp310-cp310-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- PaIRS_UniNa/Calibration_Tab.py +39 -23
- PaIRS_UniNa/Changes.txt +127 -8
- PaIRS_UniNa/Custom_Top.py +12 -9
- PaIRS_UniNa/Explorer.py +534 -165
- PaIRS_UniNa/FolderLoop.py +562 -0
- PaIRS_UniNa/Input_Tab.py +261 -100
- PaIRS_UniNa/Input_Tab_CalVi.py +24 -25
- PaIRS_UniNa/Input_Tab_tools.py +967 -405
- PaIRS_UniNa/Output_Tab.py +324 -130
- PaIRS_UniNa/PaIRS_PIV.py +58 -1
- PaIRS_UniNa/PaIRS_pypacks.py +1415 -1039
- PaIRS_UniNa/Process_Tab.py +15 -19
- PaIRS_UniNa/Process_Tab_Disp.py +12 -5
- PaIRS_UniNa/Saving_tools.py +27 -13
- PaIRS_UniNa/TabTools.py +176 -59
- PaIRS_UniNa/Vis_Tab.py +664 -256
- PaIRS_UniNa/Vis_Tab_CalVi.py +114 -45
- PaIRS_UniNa/Whatsnew.py +58 -9
- PaIRS_UniNa/_PaIRS_PIV.pyd +0 -0
- PaIRS_UniNa/__init__.py +4 -3
- PaIRS_UniNa/addwidgets_ps.py +150 -63
- PaIRS_UniNa/calib.py +6 -3
- PaIRS_UniNa/calibView.py +19 -6
- PaIRS_UniNa/gPaIRS.py +1397 -543
- PaIRS_UniNa/icons/align_all.png +0 -0
- PaIRS_UniNa/icons/announcement.png +0 -0
- PaIRS_UniNa/icons/bugfix.png +0 -0
- PaIRS_UniNa/icons/change_folder.png +0 -0
- PaIRS_UniNa/icons/change_folder_off.png +0 -0
- PaIRS_UniNa/icons/close_all.png +0 -0
- PaIRS_UniNa/icons/copy_process_off.png +0 -0
- PaIRS_UniNa/icons/flaticon_PaIRS_beta.png +0 -0
- PaIRS_UniNa/icons/flaticon_PaIRS_download_warning.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/linked.png +0 -0
- PaIRS_UniNa/icons/logo_opaco.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/process_loop.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/restore_undo.png +0 -0
- PaIRS_UniNa/icons/save_and_stop.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_path_loop.png +0 -0
- PaIRS_UniNa/icons/scan_path_loop_off.png +0 -0
- PaIRS_UniNa/icons/show_all.png +0 -0
- PaIRS_UniNa/icons/star.png +0 -0
- PaIRS_UniNa/icons/step_inheritance.png +0 -0
- PaIRS_UniNa/icons/subMIN_on.png +0 -0
- PaIRS_UniNa/icons/unedited.png +0 -0
- PaIRS_UniNa/icons/uninitialized.png +0 -0
- PaIRS_UniNa/icons/window.png +0 -0
- PaIRS_UniNa/listLib.py +3 -2
- PaIRS_UniNa/parForMulti.py +7 -5
- PaIRS_UniNa/parForWorkers.py +174 -140
- PaIRS_UniNa/pivParFor.py +9 -11
- PaIRS_UniNa/preProcParFor.py +4 -4
- PaIRS_UniNa/procTools.py +120 -44
- PaIRS_UniNa/rqrdpckgs.txt +9 -0
- PaIRS_UniNa/stereoPivParFor.py +16 -22
- PaIRS_UniNa/tabSplitter.py +17 -7
- PaIRS_UniNa/ui_Input_Tab.py +56 -57
- PaIRS_UniNa/ui_Input_Tab_CalVi.py +71 -64
- PaIRS_UniNa/ui_Log_Tab.py +8 -6
- PaIRS_UniNa/ui_Output_Tab.py +180 -4
- PaIRS_UniNa/ui_Process_Tab.py +19 -19
- PaIRS_UniNa/ui_Process_Tab_Disp.py +181 -10
- PaIRS_UniNa/ui_Vis_Tab.py +332 -196
- PaIRS_UniNa/ui_Whatsnew.py +13 -13
- PaIRS_UniNa/ui_gPairs.py +140 -71
- PaIRS_UniNa/ui_infoPaIRS.py +156 -31
- PaIRS_UniNa/whatsnew.txt +6 -4
- {PaIRS_UniNa-0.2.0.dist-info → pairs_unina-0.2.8.dist-info}/METADATA +62 -26
- {PaIRS_UniNa-0.2.0.dist-info → pairs_unina-0.2.8.dist-info}/RECORD +82 -54
- {PaIRS_UniNa-0.2.0.dist-info → pairs_unina-0.2.8.dist-info}/WHEEL +1 -1
- PaIRS_UniNa/icons/order.png +0 -0
- PaIRS_UniNa/icons/order_reverse.png +0 -0
- PaIRS_UniNa/icons/run_piv.png +0 -0
- PaIRS_UniNa/stereo.py +0 -685
- PaIRS_UniNa/ui_infoCalVi.py +0 -428
- PaIRS_UniNa-0.2.0.dist-info/LICENSE +0 -19
- {PaIRS_UniNa-0.2.0.dist-info → pairs_unina-0.2.8.dist-info}/top_level.txt +0 -0
PaIRS_UniNa/Vis_Tab.py
CHANGED
|
@@ -25,6 +25,7 @@ spin_tips={
|
|
|
25
25
|
'ymax' : 'Maximum y coordinate',
|
|
26
26
|
'nclev': 'Number of color levels',
|
|
27
27
|
'vecsize': 'Size of velocity vectors',
|
|
28
|
+
'vecwid': 'Width of velocity vectors',
|
|
28
29
|
'vecspac': 'Spacing of velocity vectors',
|
|
29
30
|
'streamdens': 'Density of streamlines',
|
|
30
31
|
'img': 'Image number',
|
|
@@ -54,6 +55,11 @@ button_tips={
|
|
|
54
55
|
'cvec': 'Color of vectors/streamlines',
|
|
55
56
|
'view': 'Inspect pre-existing results',
|
|
56
57
|
'ShowCR': 'Show common region',
|
|
58
|
+
'dx_left': 'View zone moved to left',
|
|
59
|
+
'dx_right': 'View zone moved to right',
|
|
60
|
+
'dy_down': 'View zone moved down',
|
|
61
|
+
'dy_up': 'View zone moved up',
|
|
62
|
+
'FocusIW': 'Resize to interrogation window size',
|
|
57
63
|
}
|
|
58
64
|
combo_tips={
|
|
59
65
|
'map_var': 'Map variable',
|
|
@@ -101,6 +107,7 @@ class NamesPIV(TABpar):
|
|
|
101
107
|
self.Step = Step
|
|
102
108
|
|
|
103
109
|
self.img='img'
|
|
110
|
+
self.dispMap='dispMap'
|
|
104
111
|
self.X='X'
|
|
105
112
|
self.Y='Y'
|
|
106
113
|
self.Z='Z'
|
|
@@ -117,6 +124,7 @@ class NamesPIV(TABpar):
|
|
|
117
124
|
self.uvp='uv'
|
|
118
125
|
self.uwp='uw'
|
|
119
126
|
self.vwp='vw'
|
|
127
|
+
self.ZVort='ZVort'
|
|
120
128
|
self.dPar='dPar'
|
|
121
129
|
self.dOrt='dOrt'
|
|
122
130
|
self.sn='SN'
|
|
@@ -128,6 +136,7 @@ class NamesPIV(TABpar):
|
|
|
128
136
|
self.allFields=allFields
|
|
129
137
|
self.combo_dict={
|
|
130
138
|
self.img: 'image intesity',
|
|
139
|
+
self.dispMap: 'disparity maps',
|
|
131
140
|
self.Mod: 'magnitude',
|
|
132
141
|
self.z: 'z',
|
|
133
142
|
self.u: 'U',
|
|
@@ -135,10 +144,11 @@ class NamesPIV(TABpar):
|
|
|
135
144
|
self.w: 'W',
|
|
136
145
|
self.up: "<u'u'>",
|
|
137
146
|
self.vp: "<v'v'>",
|
|
138
|
-
self.
|
|
147
|
+
self.wp: "<w'w'>",
|
|
139
148
|
self.uvp: "<u'v'>",
|
|
140
149
|
self.uwp: "<u'w'>",
|
|
141
150
|
self.vwp: "<v'w'>",
|
|
151
|
+
self.ZVort: "z-vorticity",
|
|
142
152
|
self.dPar: "epipolar || disp.",
|
|
143
153
|
self.dOrt: "epipolar ⊥ disp.",
|
|
144
154
|
self.sn: "S/N",
|
|
@@ -149,6 +159,7 @@ class NamesPIV(TABpar):
|
|
|
149
159
|
for k,v in self.combo_dict.items(): self.combo_dict_keys[v]=k
|
|
150
160
|
self.titles_dict={
|
|
151
161
|
self.img: 'intensity',
|
|
162
|
+
self.dispMap: 'disparity maps',
|
|
152
163
|
self.Mod: "velocity magnitude",
|
|
153
164
|
self.z: "z coordinate",
|
|
154
165
|
self.u: "x-velocity component",
|
|
@@ -160,6 +171,7 @@ class NamesPIV(TABpar):
|
|
|
160
171
|
self.uvp: "xy tangential Reynolds stress",
|
|
161
172
|
self.uwp: "xz tangential Reynolds stress",
|
|
162
173
|
self.vwp: "yz tangential Reynolds stress",
|
|
174
|
+
self.ZVort: "z-vorticity component",
|
|
163
175
|
self.dPar: "epipolar parallel displacement",
|
|
164
176
|
self.dOrt: "epipolar orthogonal displacement",
|
|
165
177
|
self.sn: "signal-to-noise ratio",
|
|
@@ -168,6 +180,7 @@ class NamesPIV(TABpar):
|
|
|
168
180
|
}
|
|
169
181
|
self.titles_cb_dict={
|
|
170
182
|
self.img: '',
|
|
183
|
+
self.dispMap: '',
|
|
171
184
|
self.Mod: "|Vel|",
|
|
172
185
|
self.z: "z",
|
|
173
186
|
self.u: "U",
|
|
@@ -181,6 +194,7 @@ class NamesPIV(TABpar):
|
|
|
181
194
|
self.vwp: "<v'w'>",
|
|
182
195
|
self.dPar: "d par.",
|
|
183
196
|
self.dOrt: "d ort.",
|
|
197
|
+
self.ZVort: "ωz",
|
|
184
198
|
self.sn: "S/N",
|
|
185
199
|
self.Info: "i",
|
|
186
200
|
self.FCl: "CC"
|
|
@@ -201,14 +215,14 @@ class NamesPIV(TABpar):
|
|
|
201
215
|
self.avgVel_plot=copy.deepcopy(self.instVel_plot)
|
|
202
216
|
elif Step==StepTypes.spiv:
|
|
203
217
|
self.instVel=[self.x,self.y,self.z,self.u,self.v,self.w,self.FCl,self.Info,self.sn]
|
|
204
|
-
self.instVel_plot=[self.Mod,self.u,self.v,self.w,self.FCl,self.Info,self.sn]
|
|
218
|
+
self.instVel_plot=[self.Mod,self.u,self.v,self.w,self.ZVort,self.FCl,self.Info,self.sn]
|
|
205
219
|
self.avgVel=[self.x,self.y,self.z,self.u,self.v,self.w,self.up,self.vp,self.wp,self.uvp,self.uwp,self.vwp,self.FCl,self.Info,self.sn]
|
|
206
|
-
self.avgVel_plot=[self.Mod,self.u,self.v,self.w,self.up,self.vp,self.wp,self.uvp,self.uwp,self.vwp,self.FCl,self.Info,self.sn]
|
|
220
|
+
self.avgVel_plot=[self.Mod,self.u,self.v,self.w,self.up,self.vp,self.wp,self.uvp,self.uwp,self.vwp,self.ZVort,self.FCl,self.Info,self.sn]
|
|
207
221
|
else: # for now should be StepTypes.piv
|
|
208
222
|
self.instVel=[self.x,self.y,self.u,self.v,self.FCl,self.Info,self.sn]
|
|
209
|
-
self.instVel_plot=[self.Mod,self.u,self.v,self.FCl,self.Info,self.sn]
|
|
223
|
+
self.instVel_plot=[self.Mod,self.u,self.v,self.ZVort,self.FCl,self.Info,self.sn]
|
|
210
224
|
self.avgVel=[self.x,self.y,self.u,self.v,self.up,self.vp,self.uvp,self.FCl,self.Info,self.sn]
|
|
211
|
-
self.avgVel_plot=[self.Mod,self.u,self.v,self.up,self.vp,self.uvp,self.FCl,self.Info,self.sn]
|
|
225
|
+
self.avgVel_plot=[self.Mod,self.u,self.v,self.up,self.vp,self.uvp,self.ZVort,self.FCl,self.Info,self.sn]
|
|
212
226
|
|
|
213
227
|
self.instVelFields=[self.allFields[f] for f in self.instVel ]
|
|
214
228
|
self.instVel_plot_ind=[self.fields.index(f) for f in self.instVel_plot if f in self.fields]
|
|
@@ -220,8 +234,7 @@ class NamesPIV(TABpar):
|
|
|
220
234
|
|
|
221
235
|
class VISpar(TABpar):
|
|
222
236
|
FlagVis=True
|
|
223
|
-
|
|
224
|
-
FlagAutoSizes=True
|
|
237
|
+
|
|
225
238
|
class OUT(TABpar):
|
|
226
239
|
def __init__(self):
|
|
227
240
|
self.x = 0
|
|
@@ -238,6 +251,10 @@ class VISpar(TABpar):
|
|
|
238
251
|
self.xres = 1
|
|
239
252
|
self.pixAR = 1
|
|
240
253
|
|
|
254
|
+
self.zconst = 0.0
|
|
255
|
+
self.xterm = 0.0
|
|
256
|
+
self.yterm = 0.0
|
|
257
|
+
|
|
241
258
|
super().__init__('VISpar.Out','Vis')
|
|
242
259
|
|
|
243
260
|
class PRO(TABpar):
|
|
@@ -251,12 +268,12 @@ class VISpar(TABpar):
|
|
|
251
268
|
def __init__(self,Process=ProcessTypes.null,Step=StepTypes.null):
|
|
252
269
|
self.setup(Process,Step)
|
|
253
270
|
super().__init__('VISpar','Vis')
|
|
254
|
-
self.unchecked_fields+=['
|
|
271
|
+
self.unchecked_fields+=['setPage']
|
|
272
|
+
self.uncopied_fields+=['graphics_fields']
|
|
255
273
|
|
|
256
274
|
def setup(self,Process,Step):
|
|
257
275
|
self.Process = Process
|
|
258
276
|
self.Step = Step
|
|
259
|
-
self.type = 0
|
|
260
277
|
self.FlagView = False
|
|
261
278
|
|
|
262
279
|
self.img=-1
|
|
@@ -275,6 +292,8 @@ class VISpar(TABpar):
|
|
|
275
292
|
self.result_file=''
|
|
276
293
|
self.FlagResult=False
|
|
277
294
|
|
|
295
|
+
fields_noGraphics=[f for f,_ in self.__dict__.items()]
|
|
296
|
+
self.type = 0
|
|
278
297
|
self.FlagMIN = False
|
|
279
298
|
self.FlagTR = False
|
|
280
299
|
self.LaserType = 0
|
|
@@ -282,6 +301,7 @@ class VISpar(TABpar):
|
|
|
282
301
|
self.imListMin=[[[],[]]*self.ncam]
|
|
283
302
|
|
|
284
303
|
self.image_file_Min=''
|
|
304
|
+
self.image_file_Disp=''
|
|
285
305
|
self.result_file_Mean=''
|
|
286
306
|
self.image_file_Current=''
|
|
287
307
|
self.result_file_Current=''
|
|
@@ -293,25 +313,29 @@ class VISpar(TABpar):
|
|
|
293
313
|
self.variableKey=''
|
|
294
314
|
self.field_rep=0
|
|
295
315
|
|
|
316
|
+
self.FlagAutoLevels=True
|
|
317
|
+
self.FlagAutoSizes=True
|
|
296
318
|
self.FlagYInvert=[False,False]
|
|
297
319
|
self.FlagResetLevels=True
|
|
298
320
|
self.FlagResetSizes=True
|
|
299
321
|
self.setPage=0
|
|
300
322
|
|
|
301
|
-
|
|
302
|
-
|
|
323
|
+
namesPIV=NamesPIV()
|
|
324
|
+
img=namesPIV.img
|
|
325
|
+
dispMap=namesPIV.dispMap
|
|
326
|
+
self.vcolorMap={img: 'gray', dispMap: 'gray'}
|
|
303
327
|
self.colorMap='gray'
|
|
304
|
-
self.vvectorColor={img: 'green'}
|
|
328
|
+
self.vvectorColor={img: 'green', dispMap: 'green'}
|
|
305
329
|
self.vectorColor='green'
|
|
306
|
-
self.vLim={img: 1}
|
|
307
|
-
self.vmin_default={img: 0}
|
|
308
|
-
self.vmax_default={img: 1}
|
|
309
|
-
self.vmean_default={img: 0.5}
|
|
310
|
-
self.vrange_default={img: 1}
|
|
311
|
-
self.vmin={img: 0}
|
|
312
|
-
self.vmax={img: 1}
|
|
313
|
-
self.vmean={img: 0.5}
|
|
314
|
-
self.vrange={img: 1}
|
|
330
|
+
self.vLim={img: 1, dispMap: 1}
|
|
331
|
+
self.vmin_default={img: 0, dispMap: 0}
|
|
332
|
+
self.vmax_default={img: 1, dispMap: 0}
|
|
333
|
+
self.vmean_default={img: 0.5, dispMap: 0.5}
|
|
334
|
+
self.vrange_default={img: 1, dispMap: 1}
|
|
335
|
+
self.vmin={img: 0, dispMap: 0}
|
|
336
|
+
self.vmax={img: 1, dispMap: 1}
|
|
337
|
+
self.vmean={img: 0.5, dispMap: 0.5}
|
|
338
|
+
self.vrange={img: 1, dispMap: 1}
|
|
315
339
|
self.min=0
|
|
316
340
|
self.max=1
|
|
317
341
|
self.mean=0.5
|
|
@@ -327,11 +351,14 @@ class VISpar(TABpar):
|
|
|
327
351
|
|
|
328
352
|
self.nclev=30
|
|
329
353
|
self.vecsize=1
|
|
354
|
+
self.vecwid=1
|
|
330
355
|
self.vecspac=1
|
|
331
356
|
self.streamdens=1
|
|
332
357
|
|
|
333
|
-
self.FlagContourf=
|
|
358
|
+
self.FlagContourf=True
|
|
334
359
|
|
|
360
|
+
self.graphics_fields=[f for f,_ in self.__dict__.items() if f not in fields_noGraphics]
|
|
361
|
+
|
|
335
362
|
self.Out=self.OUT()
|
|
336
363
|
self.Pro=self.PRO()
|
|
337
364
|
|
|
@@ -339,13 +366,18 @@ class VISpar(TABpar):
|
|
|
339
366
|
self.calList = []
|
|
340
367
|
self.calEx = []
|
|
341
368
|
|
|
342
|
-
self.FlagDISP = Step==StepTypes.disp
|
|
343
|
-
self.dispFile = ''
|
|
369
|
+
#self.FlagDISP = Step==StepTypes.disp
|
|
370
|
+
#self.dispFile = ''
|
|
344
371
|
|
|
345
|
-
def resF(self,i):
|
|
372
|
+
def resF(self,i,string=''):
|
|
346
373
|
fres=self.fres
|
|
347
374
|
if not fres: return ''
|
|
348
375
|
outPathRoot=fres[0]
|
|
376
|
+
if string=='dispMap':
|
|
377
|
+
fold=os.path.dirname(self.outPathRoot)
|
|
378
|
+
rad=os.path.splitext(os.path.basename(self.outPathRoot))[0]
|
|
379
|
+
if rad[-1]!='_': rad+='_'
|
|
380
|
+
return myStandardRoot(os.path.join(fold, f'dispMap_rot_{rad}{i}.png'))
|
|
349
381
|
ndig=fres[1]
|
|
350
382
|
outExt=fres[2]
|
|
351
383
|
if type(i)==str:
|
|
@@ -368,6 +400,7 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
368
400
|
self.ui: Ui_VisTab
|
|
369
401
|
self.Ptoolbar=None
|
|
370
402
|
self.addPlotToolBar()
|
|
403
|
+
self.ui.plot.axes.format_coord=lambda x,y: self.custom_format_coord(x,y)
|
|
371
404
|
|
|
372
405
|
self.ui.sliders=self.findChildren(QSlider)
|
|
373
406
|
for slider in (self.ui.slider_min,self.ui.slider_max,self.ui.slider_mean,self.ui.slider_range):
|
|
@@ -386,8 +419,11 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
386
419
|
setAppGuiPalette(self)
|
|
387
420
|
|
|
388
421
|
#------------------------------------- Graphical interface: miscellanea
|
|
389
|
-
self.brush_cursor= QCursor(QPixmap(icons_path+"brush_cursor.png").scaled(24,24))
|
|
422
|
+
self.brush_cursor= QCursor(QPixmap(icons_path+"brush_cursor.png").scaled(24,24,mode=Qt.TransformationMode.SmoothTransformation))
|
|
390
423
|
self.FlagNormalCursor=True
|
|
424
|
+
self.CursorTimer = QTimer(self)
|
|
425
|
+
self.CursorTimer.setSingleShot(True)
|
|
426
|
+
self.CursorTimer.timeout.connect(self.forceRestoreArrowCursor)
|
|
391
427
|
|
|
392
428
|
self.img=None
|
|
393
429
|
self.imgshow=None
|
|
@@ -400,6 +436,7 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
400
436
|
self.qui=None
|
|
401
437
|
self.stream=None
|
|
402
438
|
self.CR=None
|
|
439
|
+
self.RF=None
|
|
403
440
|
|
|
404
441
|
self.namesPIV=NamesPIV()
|
|
405
442
|
|
|
@@ -451,7 +488,7 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
451
488
|
self.setupWid() #---------------- IMPORTANT
|
|
452
489
|
|
|
453
490
|
FlagPreventAddPrev_Slider=False
|
|
454
|
-
for n in ('min','max','mean','range','nclev','vecsize','vecspac','streamdens'):
|
|
491
|
+
for n in ('min','max','mean','range','nclev','vecsize','vecwid','vecspac','streamdens'):
|
|
455
492
|
def defineSliderCallbackSet(n):
|
|
456
493
|
spin:QSpinBox=getattr(self.ui,'spin_'+n)
|
|
457
494
|
slider:QSlider=getattr(self.ui,'slider_'+n)
|
|
@@ -460,7 +497,7 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
460
497
|
changingAction=lambda: self.sliderLevels_changing(spin,slider,FlagPreventAddPrev_Slider)
|
|
461
498
|
callback=self.wrappedCallback(spin_tips[n],changingAction)
|
|
462
499
|
action=lambda: self.spinLevels_action(spin)
|
|
463
|
-
elif n in ('nclev','vecsize','vecspac','streamdens'):
|
|
500
|
+
elif n in ('nclev','vecsize','vecwid','vecspac','streamdens'):
|
|
464
501
|
changingAction=lambda: self.sliderFieldRep_changing(spin,slider,FlagPreventAddPrev_Slider)
|
|
465
502
|
callback=self.wrappedCallback(spin_tips[n],changingAction)
|
|
466
503
|
action=lambda: self.spinFieldRep_action(spin)
|
|
@@ -514,8 +551,8 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
514
551
|
self.setTABlayout=self.setVISlayout
|
|
515
552
|
|
|
516
553
|
self.FlagReset=True
|
|
517
|
-
self.FlagResetLevels=
|
|
518
|
-
self.FlagResetSizes =
|
|
554
|
+
self.FlagResetLevels=False
|
|
555
|
+
self.FlagResetSizes =False
|
|
519
556
|
|
|
520
557
|
self.image_file=''
|
|
521
558
|
self.image_raw=None
|
|
@@ -523,6 +560,9 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
523
560
|
self.image_file_Min=''
|
|
524
561
|
self.image_Min_raw=None
|
|
525
562
|
self.image_Min=None
|
|
563
|
+
self.image_file_Disp=''
|
|
564
|
+
self.image_Disp_raw=None
|
|
565
|
+
self.image_Disp=None
|
|
526
566
|
self.nbits=0
|
|
527
567
|
self.result_file=''
|
|
528
568
|
self.result=None
|
|
@@ -590,7 +630,7 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
590
630
|
if self.VISpar.ncam and not self.VISpar.cam: self.VISpar.cam=1
|
|
591
631
|
self.VISpar.nimg=len(self.VISpar.imList[0][0]) if len(self.VISpar.imList[0]) else 0 if self.VISpar.ncam else 0
|
|
592
632
|
if not self.VISpar.nimg and self.VISpar.img:
|
|
593
|
-
FlagResults=self.image_file_Min!='' or self.result_file_Mean!=''
|
|
633
|
+
FlagResults=self.image_file_Min!='' or self.result_file_Mean!='' or self.image_file_Disp!=''
|
|
594
634
|
self.VISpar.img=0 if FlagResults else -1
|
|
595
635
|
|
|
596
636
|
FlagNewImage, FlagNewResult = self.adjustImport()
|
|
@@ -598,7 +638,7 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
598
638
|
FlagNew=(not self.VISpar.type and FlagNewImage) or (self.VISpar.type==1 and FlagNewResult)
|
|
599
639
|
FlagDiff=self.VISpar.isDifferentFrom(self.VISpar_old,fields=['img','cam','frame']) or FlagNew
|
|
600
640
|
|
|
601
|
-
if (VISpar.FlagAutoLevels and (FlagNewImage or FlagNewResult)):
|
|
641
|
+
if (self.VISpar.FlagAutoLevels and (FlagNewImage or FlagNewResult)):
|
|
602
642
|
self.resetAllLevels()
|
|
603
643
|
if FlagDiff or self.FlagResetLevels:
|
|
604
644
|
self.FlagResetLevels=False
|
|
@@ -607,7 +647,7 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
607
647
|
self.FlagResetLevels=False
|
|
608
648
|
self.resetLevels()
|
|
609
649
|
|
|
610
|
-
if (VISpar.FlagAutoSizes and (FlagNewImage or FlagNewResult)):
|
|
650
|
+
if (self.VISpar.FlagAutoSizes and (FlagNewImage or FlagNewResult)):
|
|
611
651
|
self.resetAllXYLims()
|
|
612
652
|
if FlagDiff or self.FlagResetSizes:
|
|
613
653
|
self.FlagResetSizes=False
|
|
@@ -615,21 +655,33 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
615
655
|
elif self.FlagResetSizes:
|
|
616
656
|
self.FlagResetSizes=False
|
|
617
657
|
self.resetXYLims()
|
|
658
|
+
|
|
659
|
+
self.adjustFieldRep()
|
|
660
|
+
|
|
618
661
|
|
|
619
662
|
def adjustImport(self):
|
|
620
|
-
self.VISpar.image_file=self.VISpar.image_file_Min=''
|
|
663
|
+
self.VISpar.image_file=self.VISpar.image_file_Min=self.VISpar.image_file_Disp=''
|
|
621
664
|
if self.VISpar.img%2==0 and self.VISpar.FlagTR and not self.VISpar.LaserType:
|
|
622
665
|
f=[1,0][self.VISpar.frame-1]
|
|
623
666
|
else: f=self.VISpar.frame-1
|
|
624
|
-
|
|
667
|
+
self.VISpar.image_file_Disp=''
|
|
668
|
+
FlagDisparity=self.VISpar.Step==StepTypes.disp and (resultCheck(self,self.VISpar,ind=self.VISpar.ind) or self.VISpar.FlagView)
|
|
669
|
+
if FlagDisparity:
|
|
670
|
+
dispMap_filename=self.VISpar.resF(f'it{self.VISpar.it}',string='dispMap')
|
|
671
|
+
if os.path.exists(dispMap_filename):
|
|
672
|
+
self.VISpar.image_file_Disp=dispMap_filename
|
|
673
|
+
self.VISpar.image_file_Min=''
|
|
674
|
+
ITEs=self.gui.ui.Explorer.ITEsfromInd(self.VISpar.ind)
|
|
675
|
+
ind_min=list(ITEs[0].children).index(StepTypes.min)
|
|
676
|
+
FlagMinimum=(self.VISpar.FlagMIN or self.VISpar.Step==StepTypes.min) and (resultCheck(self,self.VISpar,ind=ITEs[ind_min+1].ind) or self.VISpar.FlagView)
|
|
677
|
+
if FlagMinimum:
|
|
625
678
|
if 0<=self.VISpar.cam-1<self.VISpar.ncam:
|
|
626
679
|
if 0<=f<len(self.VISpar.imListMin[self.VISpar.cam-1]):
|
|
627
680
|
self.VISpar.image_file_Min=self.VISpar.imListMin[self.VISpar.cam-1][f]
|
|
628
|
-
else: self.VISpar.image_file_Min=''
|
|
629
681
|
if self.VISpar.img>0:
|
|
630
682
|
self.VISpar.image_file=self.VISpar.path+self.VISpar.imList[self.VISpar.cam-1][self.VISpar.frame-1][self.VISpar.img-1] if len(self.VISpar.imList[self.VISpar.cam-1][self.VISpar.frame-1]) else ''
|
|
631
683
|
elif self.VISpar.img==0:
|
|
632
|
-
self.VISpar.image_file=self.VISpar.image_file_Current if self.VISpar.flagRun==-2 else self.VISpar.image_file_Min
|
|
684
|
+
self.VISpar.image_file=self.VISpar.image_file_Current if self.VISpar.flagRun==-2 and self.VISpar.variableKey!=self.namesPIV.dispMap else self.VISpar.image_file_Disp if self.VISpar.variableKey==self.namesPIV.dispMap else self.VISpar.image_file_Min
|
|
633
685
|
else:
|
|
634
686
|
self.VISpar.image_file=self.image_file_Load
|
|
635
687
|
|
|
@@ -640,21 +692,7 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
640
692
|
if (self.VISpar.Step==StepTypes.disp and self.VISpar.it==self.VISpar.Nit) or self.VISpar.Step!=StepTypes.disp:
|
|
641
693
|
self.VISpar.result_file=self.VISpar.result_file_Current
|
|
642
694
|
else:
|
|
643
|
-
|
|
644
|
-
if not self.VISpar.FlagView and (self.VISpar.FlagView!=self.VISpar_old.FlagView or self.VISpar.ind[:-1]!=self.VISpar_old.ind[:-1]):
|
|
645
|
-
self.VISpar.FlagResult=False
|
|
646
|
-
filename=procOutName(self.VISpar)
|
|
647
|
-
if os.path.exists(filename):
|
|
648
|
-
try:
|
|
649
|
-
from .Saving_tools import loadList
|
|
650
|
-
data=loadList(filename)
|
|
651
|
-
ind=list(data[0][0][0].children).index(self.VISpar.Step)+1
|
|
652
|
-
self.VISpar.FlagResult=data[0][0][ind].procdata.name_proc==self.window().ui.Explorer.ITEpar.procdata.name_proc
|
|
653
|
-
except:
|
|
654
|
-
pri.Error.red(f'[VIS] Error while reading the file: {filename}.')
|
|
655
|
-
else: self.VISpar.FlagResult=True
|
|
656
|
-
else:
|
|
657
|
-
self.VISpar.FlagResult=self.VISpar.FlagView
|
|
695
|
+
self.VISpar.FlagResult=self.VISpar.Step!=StepTypes.min and (resultCheck(self,self.VISpar) or self.VISpar.FlagView)
|
|
658
696
|
if self.VISpar.FlagResult:
|
|
659
697
|
if self.VISpar.Step==StepTypes.disp:
|
|
660
698
|
self.VISpar.result_file_Mean=self.VISpar.resF(f'it{self.VISpar.it}')
|
|
@@ -666,7 +704,13 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
666
704
|
else:
|
|
667
705
|
self.VISpar.result_file=self.VISpar.resF(self.VISpar.img)
|
|
668
706
|
elif self.VISpar.img==0:
|
|
669
|
-
self.VISpar.result_file=self.VISpar.result_file_Mean
|
|
707
|
+
self.VISpar.result_file=self.VISpar.result_file_Mean
|
|
708
|
+
if not self.VISpar.FlagView:
|
|
709
|
+
ITE=self.gui.ui.Explorer.ITEfromInd(self.VISpar.ind)
|
|
710
|
+
id=ITE.procdata.name_proc
|
|
711
|
+
self.VISpar.FlagResult=fileIdenitifierCheck(id,self.VISpar.result_file)
|
|
712
|
+
if not self.VISpar.FlagResult: self.VISpar.result_file=''
|
|
713
|
+
|
|
670
714
|
|
|
671
715
|
FlagNewImage, FlagNewResult, _=self.importFiles()
|
|
672
716
|
return FlagNewImage, FlagNewResult
|
|
@@ -674,23 +718,28 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
674
718
|
def importFiles(self):
|
|
675
719
|
if self.VISpar.image_file_Min!=self.image_file_Min or self.VISpar.FlagMIN!=self.VISpar_old.FlagMIN or self.FlagReset:
|
|
676
720
|
self.image_file_Min,self.image_Min_raw=self.readImageFile(self.VISpar.image_file_Min)
|
|
721
|
+
if self.VISpar.image_file_Disp!=self.image_file_Disp or self.FlagReset:
|
|
722
|
+
self.image_file_Disp,self.image_Disp_raw=self.readImageFile(self.VISpar.image_file_Disp)
|
|
677
723
|
if self.VISpar.result_file_Mean!=self.result_file_Mean or self.VISpar.FlagResult!=self.VISpar_old.FlagResult or self.FlagReset:
|
|
678
724
|
self.result_file_Mean,self.result_Mean=self.readResultFile(self.VISpar.result_file_Mean)
|
|
679
725
|
|
|
680
|
-
FlagNewImage=self.VISpar.image_file!=self.image_file
|
|
726
|
+
FlagNewImage=self.VISpar.image_file!=self.image_file or self.VISpar.ind[:-1]!=self.VISpar_old.ind[:-1]
|
|
681
727
|
if FlagNewImage or self.FlagReset:
|
|
682
728
|
self.image_file=self.VISpar.image_file
|
|
683
729
|
if self.VISpar.img==0:
|
|
684
730
|
if self.VISpar.flagRun==-2:
|
|
685
|
-
self.image_raw=self.image_Current_raw[self.VISpar.frame] if self.image_Current_raw else None
|
|
731
|
+
self.image_raw=self.image_Disp_raw if self.VISpar.variableKey==self.namesPIV.dispMap else self.image_Current_raw[self.VISpar.frame] if self.image_Current_raw else None
|
|
686
732
|
else:
|
|
687
|
-
self.image_raw=self.image_Min_raw
|
|
733
|
+
self.image_raw=self.image_Disp_raw if self.VISpar.variableKey==self.namesPIV.dispMap else self.image_Min_raw
|
|
688
734
|
else:
|
|
689
735
|
self.image_file,self.image_raw=self.readImageFile(self.VISpar.image_file)
|
|
690
|
-
|
|
691
|
-
|
|
736
|
+
mapVariableList=[]
|
|
737
|
+
#if self.image_raw is None and self.VISpar.img==0: mapVariableList=[]
|
|
738
|
+
#else:
|
|
739
|
+
if self.image_Disp_raw is not None and self.VISpar.img==0: mapVariableList+=[self.namesPIV.dispMap]
|
|
740
|
+
if (self.image_Min_raw is not None and self.VISpar.img==0) or self.VISpar.img!=0: mapVariableList+=[self.namesPIV.img]
|
|
692
741
|
|
|
693
|
-
FlagNewResult=self.VISpar.result_file!=self.result_file
|
|
742
|
+
FlagNewResult=self.VISpar.result_file!=self.result_file or self.VISpar.ind[:-1]!=self.VISpar_old.ind[:-1]
|
|
694
743
|
if FlagNewResult or self.FlagReset:
|
|
695
744
|
self.result_file=self.VISpar.result_file
|
|
696
745
|
if self.VISpar.img==0:
|
|
@@ -702,7 +751,10 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
702
751
|
self.result_file,self.result=self.readResultFile(self.VISpar.result_file)
|
|
703
752
|
|
|
704
753
|
if self.image_raw is not None:
|
|
705
|
-
self.
|
|
754
|
+
if self.VISpar.img>=0 and self.VISpar.variableKey!=self.namesPIV.dispMap:
|
|
755
|
+
self.image=transfIm(self.VISpar.Out,Images=[self.image_raw])[0]
|
|
756
|
+
else:
|
|
757
|
+
self.image=self.image_raw
|
|
706
758
|
self.getImageInfo()
|
|
707
759
|
else:
|
|
708
760
|
self.image=None
|
|
@@ -710,6 +762,10 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
710
762
|
self.image_Min=transfIm(self.VISpar.Out,Images=[self.image_Min_raw])[0]
|
|
711
763
|
else:
|
|
712
764
|
self.image_Min=None
|
|
765
|
+
if self.image_Disp_raw is not None:
|
|
766
|
+
self.image_Disp=self.image_Disp_raw #transfIm(self.VISpar.Out,Images=[self.image_Disp_raw])[0]
|
|
767
|
+
else:
|
|
768
|
+
self.image_Disp=None
|
|
713
769
|
if self.result is not None:
|
|
714
770
|
self.getResultInfo()
|
|
715
771
|
|
|
@@ -717,42 +773,81 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
717
773
|
[mapVariableList.append(r) for r in list(self.result)]
|
|
718
774
|
self.FlagReset=False
|
|
719
775
|
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
776
|
+
comboItemsList=[]
|
|
777
|
+
if self.namesPIV.img in mapVariableList: comboItemsList+=[self.namesPIV.combo_dict[self.namesPIV.img]]
|
|
778
|
+
if self.namesPIV.dispMap in mapVariableList: comboItemsList+=[self.namesPIV.combo_dict[self.namesPIV.dispMap]]
|
|
779
|
+
for f in list(self.namesPIV.combo_dict)[2:]:
|
|
723
780
|
if f in mapVariableList: comboItemsList.append(self.namesPIV.combo_dict[f])
|
|
724
781
|
if len(comboItemsList)==0: comboItemsList=[self.namesPIV.combo_dict[self.namesPIV.img]]
|
|
725
782
|
if self.VISpar.variable not in comboItemsList:
|
|
726
783
|
self.VISpar.variable=comboItemsList[0]
|
|
727
784
|
self.VISpar.variableKey=self.namesPIV.combo_dict_keys[self.VISpar.variable]
|
|
728
|
-
self.VISpar.
|
|
785
|
+
if self.VISpar.variableKey==self.namesPIV.img and self.VISpar.img==0:
|
|
786
|
+
if self.VISpar.image_file!=self.VISpar.image_file_Min:
|
|
787
|
+
self.VISpar.image_file=self.VISpar.image_file_Min
|
|
788
|
+
self.image=self.image_Min
|
|
789
|
+
self.getImageInfo()
|
|
790
|
+
elif self.VISpar.variableKey==self.namesPIV.dispMap and self.VISpar.img==0:
|
|
791
|
+
if self.VISpar.image_file!=self.VISpar.image_file_Disp:
|
|
792
|
+
self.VISpar.image_file=self.VISpar.image_file_Disp
|
|
793
|
+
self.image=self.image_Disp
|
|
794
|
+
self.getImageInfo()
|
|
795
|
+
self.VISpar.type=int(self.VISpar.variableKey not in (self.namesPIV.img, self.namesPIV.dispMap) )
|
|
729
796
|
|
|
730
797
|
return FlagNewImage, FlagNewResult, comboItemsList
|
|
731
798
|
|
|
799
|
+
def checkVISTab(self,ind=None):
|
|
800
|
+
if ind is None: VIS:VISpar=self.VISpar
|
|
801
|
+
else: VIS:VISpar=self.TABpar_at(ind)
|
|
802
|
+
VIS.OptionDone=1 if (VIS.flagRun>0 and resultCheck(self,VIS)) or VIS.flagRun<=0 else 0
|
|
803
|
+
|
|
804
|
+
def adjustFieldRep(self):
|
|
805
|
+
if self.VISpar_old.field_rep!=self.VISpar.field_rep and self.result:
|
|
806
|
+
if not self.VISpar.unit[self.VISpar.type]:
|
|
807
|
+
xres,yres=self.getXYRes(type=1)
|
|
808
|
+
else: xres=yres=1.0
|
|
809
|
+
if self.namesPIV.x in self.result and self.namesPIV.y in self.result:
|
|
810
|
+
X=self.result[self.namesPIV.x]*xres
|
|
811
|
+
Y=self.result[self.namesPIV.y]*yres
|
|
812
|
+
elif self.namesPIV.X in self.result and self.namesPIV.Y in self.result:
|
|
813
|
+
X=self.result[self.namesPIV.X]*xres
|
|
814
|
+
Y=self.result[self.namesPIV.Y]*yres
|
|
815
|
+
else: return
|
|
816
|
+
dX=np.sqrt((X[0,1]-X[0,0])**2+(Y[1,0]-Y[0,0])**2)
|
|
817
|
+
dW=[X.max()-X.min(),Y.max()-Y.min()]
|
|
818
|
+
size_pixels=self.ui.plot.fig.get_size_inches()*self.ui.plot.fig.get_dpi()*self.ui.plot.axes.get_position().bounds[2:]
|
|
819
|
+
spaPixels=dX*size_pixels/dW
|
|
820
|
+
fac_spa=np.max(nPixelsPerVector/spaPixels).astype(int).item()
|
|
821
|
+
self.VISpar.vecspac=max([1,fac_spa])
|
|
822
|
+
self.VISpar.vecsize=5
|
|
823
|
+
self.VISpar.vecwid=1
|
|
824
|
+
|
|
732
825
|
#*************************************************** Layout
|
|
733
826
|
def setVISlayout(self):
|
|
734
827
|
_, _, comboItemsList=self.importFiles()
|
|
828
|
+
self.checkResVariables()
|
|
735
829
|
|
|
736
830
|
FlagLoad=self.image_file_Load!='' or self.result_file_Load!=''
|
|
737
|
-
FlagResults=self.image_file_Min!='' or self.result_file_Mean!=''
|
|
831
|
+
FlagResults=self.image_file_Min!='' or self.result_file_Mean!='' or self.image_file_Disp!=''
|
|
738
832
|
FlagSpinsEnabled=self.VISpar.nimg or FlagLoad
|
|
833
|
+
FlagDispMap=self.VISpar.variableKey==self.namesPIV.dispMap
|
|
739
834
|
#self.ui.Plot_tools.setEnabled(FlagSpinsEnabled)
|
|
740
835
|
|
|
741
|
-
FlagIW=self.VISpar.type==0 and self.VISpar.Step in (StepTypes.piv,StepTypes.disp,StepTypes.spiv)
|
|
836
|
+
FlagIW=self.VISpar.type==0 and self.VISpar.Step in (StepTypes.piv,StepTypes.disp,StepTypes.spiv) and not FlagDispMap
|
|
742
837
|
self.ui.button_ShowIW.setVisible(FlagIW)
|
|
743
838
|
if FlagIW:
|
|
744
839
|
tip=f"{'Hide' if self.ui.button_ShowIW.isChecked() else 'Show'} Interrogation Window scheme"
|
|
745
840
|
self.ui.button_ShowIW.setToolTip(tip)
|
|
746
841
|
self.ui.button_ShowIW.setStatusTip(tip)
|
|
747
842
|
|
|
748
|
-
FlagCR=self.VISpar.type==0 and self.VISpar.Step in (StepTypes.disp,StepTypes.spiv)
|
|
843
|
+
FlagCR=self.VISpar.type==0 and self.VISpar.Step in (StepTypes.disp,StepTypes.spiv) and not FlagDispMap
|
|
749
844
|
self.ui.button_ShowCR.setVisible(FlagCR)
|
|
750
845
|
if FlagCR:
|
|
751
846
|
tip=f"{'Hide' if self.ui.button_ShowCR.isChecked() else 'Show'} common region"
|
|
752
847
|
self.ui.button_ShowCR.setToolTip(tip)
|
|
753
848
|
self.ui.button_ShowCR.setStatusTip(tip)
|
|
754
849
|
|
|
755
|
-
FlagMIN=self.VISpar.type==0 and self.image_Min is not None and self.VISpar.FlagMIN
|
|
850
|
+
FlagMIN=self.VISpar.type==0 and self.image_Min is not None and self.VISpar.img>0 #and self.VISpar.FlagMIN
|
|
756
851
|
self.ui.button_SubMIN.setVisible(FlagMIN)
|
|
757
852
|
if FlagMIN:
|
|
758
853
|
tip=f"{'Add' if self.ui.button_SubMIN.isChecked() else 'Subtract'} historical minimum background"
|
|
@@ -776,27 +871,31 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
776
871
|
self.ui.combo_map_var.clear()
|
|
777
872
|
self.ui.combo_map_var.addItems(comboItemsList)
|
|
778
873
|
|
|
779
|
-
FlagResult=self.result is not None and "U" in self.result and "V" in self.result
|
|
874
|
+
FlagResult=self.result is not None and "U" in self.result and "V" in self.result and (self.VISpar.type>0 or self.VISpar.Step==StepTypes.piv)
|
|
780
875
|
self.ui.button_cvec.setVisible(FlagResult and self.VISpar.field_rep!=0)
|
|
781
876
|
self.ui.label_field_rep.setVisible(FlagResult)
|
|
782
877
|
self.ui.combo_field_rep.setVisible(FlagResult)
|
|
783
878
|
|
|
784
879
|
i=self.VISpar.setPage
|
|
785
|
-
c=self.ui.image_levels.count()-1-int(not FlagResult) #or (not self.VISpar.FlagContourf and not self.VISpar.field_rep))
|
|
880
|
+
c=self.ui.image_levels.count()-1-int(not FlagResult or (self.VISpar.type==0 and self.VISpar.field_rep==0)) #or (not self.VISpar.FlagContourf and not self.VISpar.field_rep))
|
|
786
881
|
if i>c: i=0
|
|
787
882
|
self.ui.image_levels.setCurrentIndex(i)
|
|
788
883
|
self.ui.label_title.setText(f"Settings ({i+1}/{c+1})")
|
|
789
884
|
|
|
790
|
-
|
|
885
|
+
if self.VISpar.variableKey in self.VISpar.vLim:
|
|
886
|
+
Lim=self.VISpar.vLim[self.VISpar.variableKey]
|
|
887
|
+
else:
|
|
888
|
+
Lim=1.0
|
|
791
889
|
step=Lim/nStepsSlider
|
|
792
|
-
|
|
890
|
+
FlagLim= self.VISpar.type or FlagDispMap
|
|
891
|
+
self.ui.spin_min.setMinimum(-Lim if FlagLim else 0)
|
|
793
892
|
self.ui.spin_min.setMaximum(Lim-2*step)
|
|
794
|
-
self.ui.spin_max.setMinimum(-Lim+2*step if
|
|
893
|
+
self.ui.spin_max.setMinimum(-Lim+2*step if FlagLim else 2*step)
|
|
795
894
|
self.ui.spin_max.setMaximum(Lim)
|
|
796
|
-
self.ui.spin_mean.setMinimum(-Lim+step if
|
|
895
|
+
self.ui.spin_mean.setMinimum(-Lim+step if FlagLim else step)
|
|
797
896
|
self.ui.spin_mean.setMaximum(Lim-step)
|
|
798
897
|
self.ui.spin_range.setMinimum(2*step)
|
|
799
|
-
self.ui.spin_range.setMaximum(2*Lim if
|
|
898
|
+
self.ui.spin_range.setMaximum(2*Lim if FlagLim else step)
|
|
800
899
|
self.ui.spin_vecspac.setMaximum(self.VISpar.size[1][4])
|
|
801
900
|
|
|
802
901
|
self.ui.label_vecspac.setVisible(self.VISpar.field_rep==1)
|
|
@@ -805,6 +904,9 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
805
904
|
self.ui.label_vecsize.setVisible(self.VISpar.field_rep==1)
|
|
806
905
|
self.ui.slider_vecsize.setVisible(self.VISpar.field_rep==1)
|
|
807
906
|
self.ui.spin_vecsize.setVisible(self.VISpar.field_rep==1)
|
|
907
|
+
self.ui.label_vecwid.setVisible(self.VISpar.field_rep==1)
|
|
908
|
+
self.ui.slider_vecwid.setVisible(self.VISpar.field_rep==1)
|
|
909
|
+
self.ui.spin_vecwid.setVisible(self.VISpar.field_rep==1)
|
|
808
910
|
self.ui.spin_vecspac.setMaximum(self.VISpar.size_default[1][-1])
|
|
809
911
|
self.ui.label_streamdens.setVisible(self.VISpar.field_rep==2)
|
|
810
912
|
self.ui.slider_streamdens.setVisible(self.VISpar.field_rep==2)
|
|
@@ -817,12 +919,12 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
817
919
|
self.ui.spin_cam.setMaximum(self.VISpar.ncam)
|
|
818
920
|
self.ui.spin_cam.setEnabled(FlagSpinsEnabled and self.VISpar.ncam>1)
|
|
819
921
|
|
|
820
|
-
FlagCamFrame=self.VISpar.img>-1 and self.VISpar.type==0
|
|
922
|
+
FlagCamFrame=self.VISpar.img>-1 and self.VISpar.type==0 and not FlagDispMap
|
|
821
923
|
self.ui.label_frame.setVisible(FlagCamFrame)
|
|
822
924
|
self.ui.spin_frame.setVisible(FlagCamFrame)
|
|
823
925
|
self.ui.label_cam.setVisible(FlagCamFrame)
|
|
824
926
|
self.ui.spin_cam.setVisible(FlagCamFrame)
|
|
825
|
-
FlagDispResult=self.VISpar.img==0 and self.VISpar.Step==StepTypes.disp and self.VISpar.type==1
|
|
927
|
+
FlagDispResult=self.VISpar.img==0 and self.VISpar.Step==StepTypes.disp #and self.VISpar.variableKey is not self.namesPIV.img #and self.VISpar.type==1
|
|
826
928
|
self.ui.label_it.setVisible(FlagDispResult)
|
|
827
929
|
self.ui.spin_it.setVisible(FlagDispResult)
|
|
828
930
|
self.ui.spin_it.setMinimum(1)
|
|
@@ -841,8 +943,10 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
841
943
|
self.ui.name_var.setToolTip(f'{dataType} file: {dataName}')
|
|
842
944
|
self.ui.name_var.setStatusTip(self.ui.name_var.toolTip())
|
|
843
945
|
|
|
844
|
-
self.VISpar.
|
|
845
|
-
|
|
946
|
+
if self.VISpar.variableKey in self.VISpar.vcolorMap:
|
|
947
|
+
self.VISpar.colorMap=self.VISpar.vcolorMap[self.VISpar.variableKey]
|
|
948
|
+
if self.VISpar.variableKey in self.VISpar.vvectorColor:
|
|
949
|
+
self.VISpar.vectorColor=self.VISpar.vvectorColor[self.VISpar.variableKey]
|
|
846
950
|
|
|
847
951
|
self.ui.button_cmap.setIcon(QIcon(icons_path+'colormaps/'+self.VISpar.colorMap+'.png'))
|
|
848
952
|
self.ui.button_cvec.setIcon(QIcon(icons_path+'colormaps/'+self.VISpar.vectorColor+'Vector.png'))
|
|
@@ -856,35 +960,52 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
856
960
|
self.VISpar.xmax=self.VISpar.size[self.VISpar.type][1]*self.xres
|
|
857
961
|
self.VISpar.ymin=self.VISpar.size[self.VISpar.type][2]*self.yres
|
|
858
962
|
self.VISpar.ymax=self.VISpar.size[self.VISpar.type][3]*self.yres
|
|
963
|
+
|
|
964
|
+
self.checkVISTab()
|
|
965
|
+
self.setVISwarn()
|
|
859
966
|
return
|
|
860
967
|
|
|
861
968
|
def setLevels(self):
|
|
862
|
-
self.VISpar.
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
969
|
+
if self.VISpar.variableKey in self.VISpar.vmin:
|
|
970
|
+
self.VISpar.min=self.VISpar.vmin[self.VISpar.variableKey]
|
|
971
|
+
self.VISpar.max=self.VISpar.vmax[self.VISpar.variableKey]
|
|
972
|
+
self.VISpar.mean=self.VISpar.vmean[self.VISpar.variableKey]
|
|
973
|
+
self.VISpar.range=self.VISpar.vrange[self.VISpar.variableKey]
|
|
866
974
|
|
|
867
975
|
def resetLevels(self):
|
|
868
|
-
self.VISpar.
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
976
|
+
if self.VISpar.variableKey in self.VISpar.vmin_default:
|
|
977
|
+
self.VISpar.vmin[self.VISpar.variableKey]=self.VISpar.vmin_default[self.VISpar.variableKey]
|
|
978
|
+
self.VISpar.vmax[self.VISpar.variableKey]=self.VISpar.vmax_default[self.VISpar.variableKey]
|
|
979
|
+
self.VISpar.vmean[self.VISpar.variableKey]=self.VISpar.vmean_default[self.VISpar.variableKey]
|
|
980
|
+
self.VISpar.vrange[self.VISpar.variableKey]=self.VISpar.vrange_default[self.VISpar.variableKey]
|
|
981
|
+
#self.setLevels()
|
|
982
|
+
|
|
983
|
+
def resetAllLevels(self, ind=None):
|
|
984
|
+
if ind is None: VIS:VISpar=self.VISpar
|
|
985
|
+
else: VIS:VISpar=self.TABpar_at(ind)
|
|
986
|
+
for field in ('min','max','mean','range'):
|
|
987
|
+
v=getattr(VIS,'v'+field)
|
|
988
|
+
w=getattr(VIS,'v'+field+'_default')
|
|
989
|
+
for f in list(w):
|
|
990
|
+
v[f]=w[f]
|
|
991
|
+
#self.setLevels()
|
|
873
992
|
|
|
874
|
-
def
|
|
993
|
+
def checkResVariables(self):
|
|
875
994
|
for field in ('min','max','mean','range'):
|
|
876
995
|
v=getattr(self.VISpar,'v'+field)
|
|
877
996
|
w=getattr(self.VISpar,'v'+field+'_default')
|
|
878
997
|
for f in list(w):
|
|
879
|
-
v
|
|
880
|
-
|
|
998
|
+
if f not in list(v):
|
|
999
|
+
v[f]=w[f]
|
|
881
1000
|
|
|
882
1001
|
def resetXYLims(self):
|
|
883
1002
|
self.VISpar.size[self.VISpar.type][::]=self.VISpar.size_default[self.VISpar.type][::]
|
|
884
1003
|
|
|
885
|
-
def resetAllXYLims(self):
|
|
1004
|
+
def resetAllXYLims(self, ind=None):
|
|
1005
|
+
if ind is None: VIS:VISpar=self.VISpar
|
|
1006
|
+
else: VIS:VISpar=self.TABpar_at(ind)
|
|
886
1007
|
for t in (0,1):
|
|
887
|
-
|
|
1008
|
+
VIS.size[t][::]=self.VISpar.size_default[t][::]
|
|
888
1009
|
|
|
889
1010
|
def readImageFile(self,filename):
|
|
890
1011
|
I=None
|
|
@@ -897,25 +1018,42 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
897
1018
|
self.nbits=img.getextrema()[1].bit_length()
|
|
898
1019
|
#I=transfIm(self.VISpar.Out,Images=[I])[0]
|
|
899
1020
|
except Exception as inst:
|
|
900
|
-
pri.Error.red(f'Error opening image file: {filename}\n{traceback.
|
|
1021
|
+
pri.Error.red(f'Error opening image file: {filename}\n{traceback.format_exc()}\n{inst}')
|
|
901
1022
|
I=None
|
|
902
1023
|
return filename, I
|
|
903
1024
|
|
|
904
|
-
def getImageInfo(self):
|
|
905
|
-
I=self.image
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
self.VISpar.
|
|
911
|
-
self.
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
1025
|
+
def getImageInfo(self,image=None,ind=None):
|
|
1026
|
+
if image is None: I=self.image
|
|
1027
|
+
else: I=image
|
|
1028
|
+
if I is None: return
|
|
1029
|
+
if ind is None: VIS:VISpar=self.VISpar
|
|
1030
|
+
else: VIS:VISpar=self.TABpar_at(ind)
|
|
1031
|
+
variableKey=self.VISpar.variableKey
|
|
1032
|
+
if variableKey is self.namesPIV.dispMap:
|
|
1033
|
+
variableKey=self.namesPIV.dispMap
|
|
1034
|
+
if image is None:
|
|
1035
|
+
CC_16bit=self.image.astype(np.float64) # Convert back to float
|
|
1036
|
+
I=(CC_16bit / 65535.0) * 2.0 - 1.0 # Reverse the normalization
|
|
1037
|
+
self.image=I
|
|
1038
|
+
mean=np.mean(I).item()
|
|
1039
|
+
std=np.std(I).item()
|
|
1040
|
+
VIS.vLim[variableKey]=1.0
|
|
1041
|
+
VIS.vmin_default[variableKey]=max([mean-2*std,-1.0])
|
|
1042
|
+
VIS.vmax_default[variableKey]=min([mean+2*std,1.0])
|
|
1043
|
+
else:
|
|
1044
|
+
mean=np.mean(I).item()
|
|
1045
|
+
std=np.std(I).item()
|
|
1046
|
+
VIS.vLim[variableKey]=min([2*I.max().item(),2**(self.nbits+1)])
|
|
1047
|
+
VIS.vmin_default[variableKey]=np.round(max([mean-2*std,0])).item()
|
|
1048
|
+
VIS.vmax_default[variableKey]=np.round(min([mean+2*std,VIS.vLim[variableKey]])).item()
|
|
1049
|
+
|
|
1050
|
+
VIS.vmean_default[variableKey]=0.5*(VIS.vmin_default[variableKey]+VIS.vmax_default[variableKey])
|
|
1051
|
+
VIS.vrange_default[variableKey]=VIS.vmax_default[variableKey]-VIS.vmin_default[variableKey]
|
|
1052
|
+
VIS.size_default[0]=[0,np.size(I,1),0,np.size(I,0),1]
|
|
1053
|
+
if variableKey not in VIS.vcolorMap:
|
|
1054
|
+
VIS.vcolorMap[variableKey]='gray' if variableKey in ('img','dispMap') else 'jet'
|
|
1055
|
+
if variableKey not in VIS.vvectorColor:
|
|
1056
|
+
VIS.vvectorColor[variableKey]='green' if variableKey in ('img','dispMap') else 'black'
|
|
919
1057
|
|
|
920
1058
|
def readResultFile(self,filename):
|
|
921
1059
|
res=None
|
|
@@ -931,42 +1069,71 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
931
1069
|
res={}
|
|
932
1070
|
for j, n in enumerate(tres[1]):
|
|
933
1071
|
res[n]=tres[0][:,:,j]
|
|
934
|
-
if
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
res["Mod"]=np.sqrt(res["U"]**2+res["V"]**2)
|
|
1072
|
+
if self.namesPIV.u in res and self.namesPIV.v in res:
|
|
1073
|
+
res=self.calcMagnitude(res)
|
|
1074
|
+
FlagUnit=self.VISpar.Out.xres!=1.0 or self.VISpar.Out.pixAR!=1.0
|
|
1075
|
+
res=self.calcZVorticity(res,FlagUnit)
|
|
939
1076
|
for f in list(res):
|
|
940
1077
|
if not f in self.namesPIV.allFields: del res[f]
|
|
941
1078
|
except Exception as inst:
|
|
942
|
-
pri.Error.red(f'Error opening image file: {filename}\n{traceback.
|
|
1079
|
+
pri.Error.red(f'Error opening image file: {filename}\n{traceback.format_exc()}\n{inst}')
|
|
943
1080
|
res=None
|
|
944
1081
|
return filename, res
|
|
945
1082
|
|
|
946
|
-
def
|
|
947
|
-
res
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
1083
|
+
def calcMagnitude(self,res):
|
|
1084
|
+
if self.namesPIV.u in res and self.namesPIV.v in res:
|
|
1085
|
+
if self.namesPIV.w in res:
|
|
1086
|
+
res[self.namesPIV.Mod]=np.sqrt(res[self.namesPIV.u]**2+res[self.namesPIV.v]**2+res[self.namesPIV.w]**2)
|
|
1087
|
+
else:
|
|
1088
|
+
res[self.namesPIV.Mod]=np.sqrt(res[self.namesPIV.u]**2+res[self.namesPIV.v]**2)
|
|
1089
|
+
return res
|
|
1090
|
+
|
|
1091
|
+
def calcZVorticity(self,res,FlagUnit=False):
|
|
1092
|
+
if self.namesPIV.x in res and self.namesPIV.y in res and self.namesPIV.u in res and self.namesPIV.v in res:
|
|
1093
|
+
if FlagUnit: xres=yres=1/1000
|
|
1094
|
+
else: xres=yres=1.0
|
|
1095
|
+
try:
|
|
1096
|
+
du_dy, _=np.gradient(res[self.namesPIV.u],res[self.namesPIV.y][:,0]*yres,res[self.namesPIV.x][0,:]*xres) # Derivate di u rispetto a y e x
|
|
1097
|
+
_, dv_dx=np.gradient(res[self.namesPIV.v],res[self.namesPIV.y][:,0]*yres,res[self.namesPIV.x][0,:]*xres) # Derivate di v rispetto a y e x
|
|
1098
|
+
res[self.namesPIV.ZVort]=dv_dx-du_dy
|
|
1099
|
+
except:
|
|
1100
|
+
pri.Error.red(f'Error while computing vorticity field:\n{traceback.format_exc()}\n\n')
|
|
1101
|
+
return res
|
|
1102
|
+
|
|
1103
|
+
def getResultInfo(self,result=None,ind=None):
|
|
1104
|
+
if result is None: res=self.result
|
|
1105
|
+
else: res=result
|
|
1106
|
+
if res is None: return
|
|
1107
|
+
if ind is None: VIS:VISpar=self.VISpar
|
|
1108
|
+
else: VIS:VISpar=self.TABpar_at(ind)
|
|
1109
|
+
for i in list(VIS.vmin_default):
|
|
1110
|
+
if i not in (self.namesPIV.img,self.namesPIV.dispMap):
|
|
1111
|
+
del VIS.vmin_default[i]
|
|
1112
|
+
del VIS.vmax_default[i]
|
|
1113
|
+
del VIS.vmean_default[i]
|
|
1114
|
+
del VIS.vrange_default[i]
|
|
1115
|
+
del VIS.vLim[i]
|
|
955
1116
|
|
|
956
1117
|
for f in list(res):
|
|
957
|
-
V:np=res[f]
|
|
958
|
-
m=np.mean(V).item()
|
|
959
|
-
r=np.std(V).item()
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
1118
|
+
V:np=res[f][~np.isnan(res[f])]
|
|
1119
|
+
#m=np.mean(V).item()
|
|
1120
|
+
#r=np.std(V).item()
|
|
1121
|
+
#VIS.vLim[f]=max([m+5*r,abs(m-5*r)])
|
|
1122
|
+
amax=np.max(np.abs(V))*5.0
|
|
1123
|
+
m=np.mean(V)
|
|
1124
|
+
r=(np.max(V)-np.min(V))*2.50
|
|
1125
|
+
rmax=np.abs(m+r)
|
|
1126
|
+
rmin=np.abs(m-r)
|
|
1127
|
+
VIS.vLim[f]=float(max([amax,rmax,rmin]))
|
|
1128
|
+
if VIS.vLim[f]<0.1: VIS.vLim[f]=1
|
|
1129
|
+
VIS.vmin_default[f]=float(np.percentile(V,1)) #np.round(m-2*r).item()
|
|
1130
|
+
VIS.vmax_default[f]=float(np.percentile(V,99)) #np.round(m+2*r).item()
|
|
1131
|
+
VIS.vmean_default[f]=0.5*(VIS.vmin_default[f]+VIS.vmax_default[f])
|
|
1132
|
+
VIS.vrange_default[f]=VIS.vmax_default[f]-VIS.vmin_default[f]
|
|
1133
|
+
if f not in VIS.vcolorMap:
|
|
1134
|
+
VIS.vcolorMap[f]='jet'
|
|
1135
|
+
if f not in VIS.vvectorColor:
|
|
1136
|
+
VIS.vvectorColor[f]='black'
|
|
970
1137
|
pass
|
|
971
1138
|
|
|
972
1139
|
FlagSize=False
|
|
@@ -980,11 +1147,15 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
980
1147
|
FlagSize=True
|
|
981
1148
|
if FlagSize:
|
|
982
1149
|
if np.size(X) and np.size(Y):
|
|
983
|
-
|
|
1150
|
+
VIS.size_default[1]=[X.min().item(),X.max().item(),Y.min().item(),Y.max().item(),int(max([np.size(X,0),np.size(X,1)])/4)]
|
|
984
1151
|
else:
|
|
985
|
-
|
|
1152
|
+
VIS.size_default[1]=[0,1,0,1,1]
|
|
986
1153
|
|
|
987
|
-
|
|
1154
|
+
def setVISwarn(self,ind=None):
|
|
1155
|
+
if ind is None: VIS:VISpar=self.VISpar
|
|
1156
|
+
else: VIS:VISpar=self.TABpar_at(ind)
|
|
1157
|
+
VIS.warningMessage='Result files correctly identified!' if VIS.OptionDone==1 else 'Result files corresponding to the current step appear to be missing from the specified output path.'
|
|
1158
|
+
|
|
988
1159
|
#*************************************************** Plot tools
|
|
989
1160
|
#******************** Actions
|
|
990
1161
|
def button_view_action(self):
|
|
@@ -992,7 +1163,7 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
992
1163
|
|
|
993
1164
|
def button_ShowIW_action(self):
|
|
994
1165
|
self.VISpar.FlagShowIW=self.ui.button_ShowIW.isChecked()
|
|
995
|
-
self.resetXYLims()
|
|
1166
|
+
#if self.VISpar.FlagShowIW: self.resetXYLims()
|
|
996
1167
|
|
|
997
1168
|
def button_SubMIN_action(self):
|
|
998
1169
|
self.VISpar.FlagSubMIN=self.ui.button_SubMIN.isChecked()
|
|
@@ -1021,11 +1192,21 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
1021
1192
|
self.setLevels()
|
|
1022
1193
|
|
|
1023
1194
|
def button_automatic_levels_action(self):
|
|
1024
|
-
VISpar.FlagAutoLevels=self.ui.button_automatic_levels.isChecked()
|
|
1195
|
+
self.VISpar.FlagAutoLevels=self.ui.button_automatic_levels.isChecked()
|
|
1025
1196
|
return True
|
|
1026
1197
|
|
|
1027
1198
|
def button_automatic_sizes_action(self):
|
|
1028
|
-
VISpar.FlagAutoSizes=self.ui.button_automatic_sizes.isChecked()
|
|
1199
|
+
self.VISpar.FlagAutoSizes=self.ui.button_automatic_sizes.isChecked()
|
|
1200
|
+
if self.VISpar.FlagAutoSizes is False and self.VISpar.Process==ProcessTypes.piv:
|
|
1201
|
+
type2=0 if self.VISpar.type==1 else 1
|
|
1202
|
+
if self.VISpar.unit[self.VISpar.type]!=self.VISpar.unit[type2]:
|
|
1203
|
+
xres,yres=self.getXYRes(type=self.VISpar.unit[self.VISpar.type])
|
|
1204
|
+
else: xres=yres=1.0
|
|
1205
|
+
if (type2==0 and self.VISpar.unit[type2]) or (type2==1 and not self.VISpar.unit[type2]):
|
|
1206
|
+
xres2,yres2=self.getXYRes(type=type2)
|
|
1207
|
+
else: xres2=yres2=1.0
|
|
1208
|
+
self.VISpar.size[type2][0:2]=[s*xres/xres2 for s in [self.VISpar.xmin, self.VISpar.xmax]]
|
|
1209
|
+
self.VISpar.size[type2][2:4]=[s*yres/yres2 for s in [self.VISpar.ymin, self.VISpar.ymax]]
|
|
1029
1210
|
return True
|
|
1030
1211
|
|
|
1031
1212
|
def button_restore_action(self):
|
|
@@ -1128,7 +1309,86 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
1128
1309
|
spin_value=getattr(self.VISpar,n)
|
|
1129
1310
|
res=self.xres if k<2 else self.yres
|
|
1130
1311
|
self.VISpar.size[self.VISpar.type][k]=spin_value/res
|
|
1131
|
-
|
|
1312
|
+
|
|
1313
|
+
def button_dx_left_action(self):
|
|
1314
|
+
dx=(self.VISpar.xmax-self.VISpar.xmin)/self.xres
|
|
1315
|
+
self.VISpar.size[self.VISpar.type][0]-=dx
|
|
1316
|
+
self.VISpar.size[self.VISpar.type][1]-=dx
|
|
1317
|
+
|
|
1318
|
+
def button_dx_right_action(self):
|
|
1319
|
+
dx=(self.VISpar.xmax-self.VISpar.xmin)/self.xres
|
|
1320
|
+
self.VISpar.size[self.VISpar.type][0]+=dx
|
|
1321
|
+
self.VISpar.size[self.VISpar.type][1]+=dx
|
|
1322
|
+
|
|
1323
|
+
def button_dy_down_action(self):
|
|
1324
|
+
dy=(self.VISpar.ymax-self.VISpar.ymin)/self.yres
|
|
1325
|
+
self.VISpar.size[self.VISpar.type][2]-=dy
|
|
1326
|
+
self.VISpar.size[self.VISpar.type][3]-=dy
|
|
1327
|
+
|
|
1328
|
+
def button_dy_up_action(self):
|
|
1329
|
+
dy=(self.VISpar.ymax-self.VISpar.ymin)/self.yres
|
|
1330
|
+
self.VISpar.size[self.VISpar.type][2]+=dy
|
|
1331
|
+
self.VISpar.size[self.VISpar.type][3]+=dy
|
|
1332
|
+
|
|
1333
|
+
def button_FocusIW_action(self):
|
|
1334
|
+
"""
|
|
1335
|
+
Show a popup menu with options 'H x W' and return the selected index (int) or None.
|
|
1336
|
+
Labels are formatted as f"{Vect[2][i]} x {Vect[0][i]}".
|
|
1337
|
+
"""
|
|
1338
|
+
FlagDisp=self.VISpar.variableKey is self.namesPIV.dispMap
|
|
1339
|
+
if FlagDisp: it=-1
|
|
1340
|
+
else:
|
|
1341
|
+
# Ensure consistent length between lists 0 (width values) and 2 (height values)
|
|
1342
|
+
ve=self.VISpar.Pro.Vect if isinstance(self.VISpar.Pro.Vect[0],list) else [[v] for v in self.VISpar.Pro.Vect]
|
|
1343
|
+
Vect = [[val for val in v] for v in ve]
|
|
1344
|
+
n = min(len(Vect[0]), len(Vect[2]))
|
|
1345
|
+
if n == 0:
|
|
1346
|
+
return None
|
|
1347
|
+
|
|
1348
|
+
# Create a context menu and populate it with the available sizes
|
|
1349
|
+
menu = QMenu(self)
|
|
1350
|
+
for i in range(n):
|
|
1351
|
+
label = f"{Vect[2][i]} x {Vect[0][i]}"
|
|
1352
|
+
act = menu.addAction(label)
|
|
1353
|
+
act.setData(i)
|
|
1354
|
+
|
|
1355
|
+
# Display the menu at the current cursor position and wait for user selection
|
|
1356
|
+
chosen = menu.exec(QCursor.pos())
|
|
1357
|
+
it = None if chosen is None else chosen.data()
|
|
1358
|
+
if it is not None: self.FocusIW_it(it)
|
|
1359
|
+
|
|
1360
|
+
def FocusIW_it(self,it=-1):
|
|
1361
|
+
ve=self.VISpar.Pro.Vect if isinstance(self.VISpar.Pro.Vect[0],list) else [[v] for v in self.VISpar.Pro.Vect]
|
|
1362
|
+
Vect = [[val for val in v] for v in ve]
|
|
1363
|
+
if self.VISpar.unit[self.VISpar.type] and self.VISpar.type!=0:
|
|
1364
|
+
yres=self.VISpar.Out.xres*self.VISpar.Out.pixAR
|
|
1365
|
+
for k in range(2): Vect[k]=[val/self.VISpar.Out.xres for val in Vect[k]]
|
|
1366
|
+
for k in range(2,4): Vect[k]=[val/yres for val in Vect[k]]
|
|
1367
|
+
else: yres=1.0
|
|
1368
|
+
W=Vect[2][it]
|
|
1369
|
+
FlagDisp=self.VISpar.variableKey is self.namesPIV.dispMap
|
|
1370
|
+
if FlagDisp:
|
|
1371
|
+
H=self.gui.w_Process_Disp.PROpar.SemiWidth_Epipolar*2+1
|
|
1372
|
+
H/=yres
|
|
1373
|
+
FlagBordo=False
|
|
1374
|
+
else:
|
|
1375
|
+
H=Vect[0][it]
|
|
1376
|
+
FlagBordo=self.VISpar.Pro.FlagBordo
|
|
1377
|
+
if abs(self.VISpar.size[self.VISpar.type][1]-self.VISpar.size[self.VISpar.type][0]-W)<1 and abs(self.VISpar.size[self.VISpar.type][3]-self.VISpar.size[self.VISpar.type][2]-H)<1:
|
|
1378
|
+
dW=W if FlagDisp else Vect[3][it]
|
|
1379
|
+
boundDist=W/2 if not FlagBordo else dW
|
|
1380
|
+
x0=int((self.VISpar.size[self.VISpar.type][0]-boundDist+W/2)/dW)*dW+boundDist-W/2 if self.VISpar.size[self.VISpar.type][0]>boundDist else boundDist-W/2
|
|
1381
|
+
dH=H if FlagDisp else Vect[1][it]
|
|
1382
|
+
boundDist=H/2 if not FlagBordo else dH
|
|
1383
|
+
y0=int((self.VISpar.size[self.VISpar.type][2]-boundDist+H/2)/dH)*dH+boundDist-H/2 if self.VISpar.size[self.VISpar.type][2]>boundDist else boundDist-H/2
|
|
1384
|
+
self.VISpar.size[self.VISpar.type][0]=x0
|
|
1385
|
+
self.VISpar.size[self.VISpar.type][2]=y0
|
|
1386
|
+
self.VISpar.size[self.VISpar.type][1]=x0+W
|
|
1387
|
+
self.VISpar.size[self.VISpar.type][3]=y0+H
|
|
1388
|
+
else:
|
|
1389
|
+
self.VISpar.size[self.VISpar.type][1]=self.VISpar.size[self.VISpar.type][0]+W
|
|
1390
|
+
self.VISpar.size[self.VISpar.type][3]=self.VISpar.size[self.VISpar.type][2]+H
|
|
1391
|
+
|
|
1132
1392
|
#******************** Settings
|
|
1133
1393
|
def button_view_set(self):
|
|
1134
1394
|
self.ui.button_view.setChecked(self.VISpar.FlagView)
|
|
@@ -1149,10 +1409,10 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
1149
1409
|
self.ui.button_Contourf.setChecked(self.VISpar.FlagContourf)
|
|
1150
1410
|
|
|
1151
1411
|
def button_automatic_levels_set(self):
|
|
1152
|
-
self.ui.button_automatic_levels.setChecked(VISpar.FlagAutoLevels)
|
|
1412
|
+
self.ui.button_automatic_levels.setChecked(self.VISpar.FlagAutoLevels)
|
|
1153
1413
|
|
|
1154
1414
|
def button_automatic_sizes_set(self):
|
|
1155
|
-
self.ui.button_automatic_sizes.setChecked(VISpar.FlagAutoSizes)
|
|
1415
|
+
self.ui.button_automatic_sizes.setChecked(self.VISpar.FlagAutoSizes)
|
|
1156
1416
|
|
|
1157
1417
|
def button_invert_y_set(self):
|
|
1158
1418
|
self.ui.button_invert_y.setChecked(self.VISpar.FlagYInvert[self.VISpar.type])
|
|
@@ -1183,14 +1443,18 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
1183
1443
|
self.VISpar.size[self.VISpar.type][:2]=[xmin/self.xres,xmax/self.xres]
|
|
1184
1444
|
self.VISpar.size[self.VISpar.type][2:4]=[ymin/self.yres,ymax/self.yres]
|
|
1185
1445
|
|
|
1446
|
+
def forceRestoreArrowCursor(self):
|
|
1447
|
+
if self.CursorTimer.isActive():
|
|
1448
|
+
self.CursorTimer.stop()
|
|
1449
|
+
while QApplication.overrideCursor() is not None:
|
|
1450
|
+
QApplication.restoreOverrideCursor()
|
|
1451
|
+
self.FlagNormalCursor = True
|
|
1452
|
+
|
|
1186
1453
|
def brushCursor(self):
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
QApplication.restoreOverrideCursor()
|
|
1192
|
-
self.FlagNormalCursor=True
|
|
1193
|
-
QTimer.singleShot(250,lambda: restoreCursor())
|
|
1454
|
+
self.forceRestoreArrowCursor()
|
|
1455
|
+
self.FlagNormalCursor=False
|
|
1456
|
+
QApplication.setOverrideCursor(self.brush_cursor)
|
|
1457
|
+
self.CursorTimer.start(250)
|
|
1194
1458
|
|
|
1195
1459
|
def setMapVar(self):
|
|
1196
1460
|
pri.PlotTime.magenta(f'{"/"*25} Plotting image - start')
|
|
@@ -1199,7 +1463,7 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
1199
1463
|
if self.VISpar.type==0:
|
|
1200
1464
|
fields=['image_file','variable','unit','FlagSubMIN','Out','colorMap']
|
|
1201
1465
|
img=self.image
|
|
1202
|
-
if self.VISpar.img and self.VISpar.FlagSubMIN and self.image_Min is not None:
|
|
1466
|
+
if img is not None and self.VISpar.img>0 and self.VISpar.FlagSubMIN and self.image_Min is not None:
|
|
1203
1467
|
img=img-self.image_Min
|
|
1204
1468
|
self.img=img
|
|
1205
1469
|
FlagDraw=self.showImg(fields)
|
|
@@ -1207,34 +1471,48 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
1207
1471
|
FlagIW=self.VISpar.isDifferentFrom(self.VISpar_old,fields=['FlagShowIW','Pro'])
|
|
1208
1472
|
if FlagIW or FlagDraw: self.showRect()
|
|
1209
1473
|
FlagDraw=FlagDraw or FlagIW
|
|
1474
|
+
if self.image is not None and self.VISpar.FlagShowCR and self.VISpar.variableKey!=self.namesPIV.dispMap:
|
|
1475
|
+
self.showCommonRegion()
|
|
1476
|
+
FlagDraw=FlagDraw or self.CR is not None
|
|
1477
|
+
else:
|
|
1478
|
+
self.cleanCommonRegion()
|
|
1210
1479
|
else:
|
|
1211
1480
|
if self.orect: self.cleanRect()
|
|
1481
|
+
self.cleanCommonRegion()
|
|
1212
1482
|
fields=['result_file','variable','unit','min','max','nclev','FlagContourf','colorMap']
|
|
1213
|
-
if not self.
|
|
1214
|
-
|
|
1215
|
-
|
|
1483
|
+
if self.VISpar.variableKey not in self.result: raise('Variable not found in result structure!')
|
|
1484
|
+
V=self.result[self.VISpar.variableKey]
|
|
1485
|
+
if not self.VISpar.FlagContourf:
|
|
1486
|
+
self.img,Ximg,Yimg,FlagInterp,size=self.calcMap(V,size_pixels=[np.size(V,0), np.size(V,1)])
|
|
1487
|
+
FlagDraw=self.showImg(fields,size)
|
|
1216
1488
|
else:
|
|
1217
|
-
|
|
1489
|
+
self.img,Ximg,Yimg,FlagInterp,size=self.calcMap(V)
|
|
1490
|
+
if FlagInterp:
|
|
1491
|
+
FlagDraw=self.showImg(fields,size)
|
|
1492
|
+
else:
|
|
1493
|
+
FlagDraw=self.showMap(fields)
|
|
1494
|
+
if self.contour is None:
|
|
1495
|
+
FlagDraw=self.showImg(fields,size)
|
|
1218
1496
|
fields=['result_file','variable','FlagContourf','field_rep','unit','vectorColor']
|
|
1219
|
-
if self.VISpar.field_rep==1: fields+=['vecsize','vecspac']
|
|
1497
|
+
if self.VISpar.field_rep==1: fields+=['vecsize','vecwid','vecspac']
|
|
1220
1498
|
elif self.VISpar.field_rep==2: fields+=['streamdens']
|
|
1499
|
+
if self.VISpar.Step!=StepTypes.piv: fields+=['type']
|
|
1221
1500
|
FlagVecField=self.VISpar.isDifferentFrom(self.VISpar_old,fields=fields)
|
|
1222
1501
|
if FlagVecField and self.result:
|
|
1223
1502
|
self.showVecField()
|
|
1503
|
+
elif self.result is None: self.cleanVecField()
|
|
1224
1504
|
FlagDraw=FlagDraw or FlagVecField
|
|
1225
1505
|
|
|
1226
|
-
if self.image is not None and self.VISpar.FlagShowCR:
|
|
1227
|
-
self.showCommonRegion()
|
|
1228
|
-
FlagDraw=FlagDraw or self.CR is not None
|
|
1229
1506
|
if FlagDraw:
|
|
1230
1507
|
#self.ui.plot.draw()
|
|
1231
1508
|
self.ui.plot.draw_idle()
|
|
1232
1509
|
except:
|
|
1510
|
+
pri.Error.red(f'Error while generating plot:\n{traceback.format_exc()}\n\n')
|
|
1233
1511
|
printException()
|
|
1234
1512
|
#self.exitVISerr(False)
|
|
1235
1513
|
pri.PlotTime.magenta(f'{"%"*25} Plotting image - end')
|
|
1236
1514
|
|
|
1237
|
-
def showImg(self,fields):
|
|
1515
|
+
def showImg(self,fields,size:list=None):
|
|
1238
1516
|
img=self.img
|
|
1239
1517
|
if img is None:
|
|
1240
1518
|
self.cleanAxes(FlagAxis=False)
|
|
@@ -1252,16 +1530,18 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
1252
1530
|
|
|
1253
1531
|
if self.imgshow is None or self.VISpar_old.FlagContourf!=self.VISpar.FlagContourf or FlagOut:
|
|
1254
1532
|
self.cleanAxes()
|
|
1255
|
-
self.imgshow=self.ui.plot.axes.imshow(img,extent=self.imgExtent(), origin='lower', vmin=self.VISpar.min,vmax=self.VISpar.max,zorder=0)
|
|
1533
|
+
self.imgshow=self.ui.plot.axes.imshow(img,extent=self.imgExtent(size), origin='lower', vmin=self.VISpar.min,vmax=self.VISpar.max,zorder=0)
|
|
1534
|
+
self.imgshow.format_cursor_data=lambda v: self.custom_format_cursor_data(v)
|
|
1256
1535
|
cmap,_=self.colorMap()
|
|
1257
1536
|
self.imgshow.set_cmap(cmap)
|
|
1258
1537
|
divider = make_axes_locatable(self.ui.plot.axes)
|
|
1259
1538
|
cax = divider.append_axes("right", size="5%", pad=0.05)
|
|
1260
1539
|
self.cb=self.ui.plot.fig.colorbar(self.imgshow,cax=cax)
|
|
1261
1540
|
self.setTitleLabels()
|
|
1541
|
+
FlagXLim=True
|
|
1262
1542
|
else:
|
|
1263
1543
|
self.imgshow.set_data(img)
|
|
1264
|
-
extent=self.imgExtent()
|
|
1544
|
+
extent=self.imgExtent(size)
|
|
1265
1545
|
if extent!=self.imgshow.get_extent():
|
|
1266
1546
|
self.imgshow.set_extent(extent)
|
|
1267
1547
|
FlagExtent=True
|
|
@@ -1301,7 +1581,7 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
1301
1581
|
return cmap, levs
|
|
1302
1582
|
|
|
1303
1583
|
def getXYRes(self,type=None):
|
|
1304
|
-
if
|
|
1584
|
+
if type is None: type=self.VISpar.type
|
|
1305
1585
|
xres=yres=1.0
|
|
1306
1586
|
if self.VISpar.Process==ProcessTypes.piv and not self.VISpar.Out.FlagNone:
|
|
1307
1587
|
if type==0: #mm/pixels
|
|
@@ -1312,8 +1592,8 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
1312
1592
|
yres=self.VISpar.Out.xres*self.VISpar.Out.pixAR
|
|
1313
1593
|
return xres, yres
|
|
1314
1594
|
|
|
1315
|
-
def imgExtent(self):
|
|
1316
|
-
size=self.VISpar.size_default[self.VISpar.type]
|
|
1595
|
+
def imgExtent(self,size=None):
|
|
1596
|
+
if size is None: size=self.VISpar.size_default[self.VISpar.type]
|
|
1317
1597
|
return [k*self.xres for k in size[:2]]+[k*self.yres for k in size[2:4]]
|
|
1318
1598
|
|
|
1319
1599
|
def setAxisLim(self):
|
|
@@ -1342,45 +1622,48 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
1342
1622
|
FlagCMap=self.VISpar_old.colorMap!=self.VISpar.colorMap
|
|
1343
1623
|
FlagCLim=self.VISpar.isDifferentFrom(self.VISpar_old,fields=['min','max'])
|
|
1344
1624
|
|
|
1345
|
-
if FlagNewPlot or self.VISpar_old.nclev!=self.VISpar.nclev:
|
|
1625
|
+
if FlagNewPlot or self.VISpar_old.FlagContourf!=self.VISpar.FlagContourf or self.VISpar_old.nclev!=self.VISpar.nclev:
|
|
1626
|
+
self.cleanAxes()
|
|
1346
1627
|
if not self.VISpar.unit[self.VISpar.type]:
|
|
1347
1628
|
xres,yres=self.getXYRes(type=1)
|
|
1348
1629
|
else: xres=yres=1.0
|
|
1349
1630
|
X=result[self.namesPIV.x]*xres
|
|
1350
1631
|
Y=result[self.namesPIV.y]*yres
|
|
1632
|
+
if self.VISpar.variableKey not in self.result: raise('Variable not found in result structure!')
|
|
1351
1633
|
V=result[self.VISpar.variableKey]
|
|
1352
|
-
self.map=V
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
if self.contour:
|
|
1356
|
-
for coll in self.contour.collections:
|
|
1357
|
-
coll.remove()
|
|
1634
|
+
self.map=[X,Y,V]
|
|
1635
|
+
|
|
1358
1636
|
cmap,levs=self.colorMap()
|
|
1359
|
-
|
|
1360
|
-
|
|
1637
|
+
try:
|
|
1638
|
+
self.contour=self.ui.plot.axes.contourf(X, Y, V, levs, \
|
|
1639
|
+
cmap=cmap, origin='lower', extend='both', zorder=0)
|
|
1640
|
+
self.contour.format_cursor_data=lambda v: self.custom_format_cursor_data(v)
|
|
1641
|
+
except:
|
|
1642
|
+
pri.Error.red(f'Error while generating contour lines:\n{traceback.format_exc()}\n\n')
|
|
1643
|
+
self.contour=None
|
|
1644
|
+
return
|
|
1361
1645
|
self.contour.set_clim(levs[0],levs[-1])
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
self.cb=self.ui.plot.fig.colorbar(self.contour,cax=cax)
|
|
1646
|
+
divider = make_axes_locatable(self.ui.plot.axes)
|
|
1647
|
+
cax = divider.append_axes("right", size="5%", pad=0.05)
|
|
1648
|
+
self.cb=self.ui.plot.fig.colorbar(self.contour,cax=cax)
|
|
1366
1649
|
self.setTitleLabels()
|
|
1650
|
+
FlagXLim=True
|
|
1367
1651
|
else:
|
|
1368
1652
|
if FlagCMap:
|
|
1369
1653
|
cmap,_=self.colorMap()
|
|
1370
1654
|
self.contour.set_cmap(cmap)
|
|
1371
1655
|
if FlagCLim:
|
|
1372
1656
|
self.contour.set_clim(self.VISpar.min,self.VISpar.max)
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1657
|
+
if FlagXLim:
|
|
1658
|
+
self.setAxisLim()
|
|
1659
|
+
self.Ptoolbar.update()
|
|
1376
1660
|
|
|
1377
1661
|
FlagDraw=FlagNewPlot or FlagXLim or FlagCMap or FlagCLim
|
|
1378
1662
|
return FlagDraw
|
|
1379
1663
|
|
|
1380
|
-
def calcMap(self,V):
|
|
1664
|
+
def calcMap(self,V,size_pixels=[1000]*2):
|
|
1381
1665
|
#size_pixels=self.ui.plot.fig.get_size_inches()*self.ui.plot.fig.get_dpi()
|
|
1382
1666
|
#size_pixels=np.minimum(np.round(0.5*size_pixels).astype(int),1000)
|
|
1383
|
-
size_pixels=[1000]*2
|
|
1384
1667
|
FlagSize=False
|
|
1385
1668
|
if "X" in list(self.result) and "Y" in list(self.result):
|
|
1386
1669
|
X=self.result["X"]
|
|
@@ -1394,17 +1677,59 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
1394
1677
|
xmin,xmax,ymin,ymax=[X.min(),X.max(),Y.min(),Y.max()]
|
|
1395
1678
|
else:
|
|
1396
1679
|
xmin,xmax,ymin,ymax=[0,np.size(V,1),0,np.size(V,0)]
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1680
|
+
xstep_half=(xmax-xmin)/(np.size(V,1)-1)*0.5
|
|
1681
|
+
x = self.mylinspace(xmin,xmax, np.size(V,1))
|
|
1682
|
+
ystep_half=(ymax-ymin)/(np.size(V,0)-1)*0.5
|
|
1683
|
+
y = self.mylinspace(ymin,ymax, np.size(V,0))
|
|
1684
|
+
FlagInterp=False
|
|
1685
|
+
if (np.size(V,1)<size_pixels[1] or np.size(V,0)<size_pixels[0]) and not bool(np.any(np.isnan(V))):
|
|
1686
|
+
x_new = self.mylinspace(xmin, xmax, size_pixels[0])
|
|
1687
|
+
y_new = self.mylinspace(ymin, ymax, size_pixels[1])
|
|
1688
|
+
try:
|
|
1689
|
+
f = scipy.interpolate.RectBivariateSpline(y, x, V)
|
|
1690
|
+
V_new = f(y_new, x_new)
|
|
1691
|
+
FlagInterp=True
|
|
1692
|
+
except:
|
|
1693
|
+
try:
|
|
1694
|
+
x_flat, y_flat = np.meshgrid(x, y) # Griglia 2D
|
|
1695
|
+
points = np.column_stack((x_flat.ravel(), y_flat.ravel())) # Punti 2D
|
|
1696
|
+
X_new, Y_new = np.meshgrid(x_new, y_new)
|
|
1697
|
+
V_new = scipy.interpolate.griddata(points, V.ravel(), (X_new, Y_new), method='cubic') #'nearest', 'linear', 'cubic'
|
|
1698
|
+
FlagInterp=True
|
|
1699
|
+
pass
|
|
1700
|
+
except:
|
|
1701
|
+
pri.Error.red(f'Error while interpolating map variable field for contour representation:\n{traceback.format_exc()}\n\n')
|
|
1702
|
+
x_new=x
|
|
1703
|
+
y_new=y
|
|
1704
|
+
V_new=V
|
|
1705
|
+
FlagInterp=False
|
|
1706
|
+
pass
|
|
1707
|
+
else:
|
|
1708
|
+
x_new=x
|
|
1709
|
+
y_new=y
|
|
1710
|
+
V_new=V
|
|
1711
|
+
FlagInterp=not bool(np.any(np.isnan(V)))
|
|
1712
|
+
X_new, Y_new = np.meshgrid(x_new, y_new)
|
|
1713
|
+
return V_new, X_new, Y_new, FlagInterp, (xmin-xstep_half,xmax+ystep_half,ymin-ystep_half,ymax+ystep_half)
|
|
1714
|
+
|
|
1715
|
+
def mylinspace(self,xmin,xmax,N):
|
|
1716
|
+
step=(xmax-xmin)/(N-1)
|
|
1717
|
+
return xmin+np.arange(0,N,1)*step
|
|
1718
|
+
|
|
1719
|
+
def cleanVecField(self):
|
|
1720
|
+
if self.qui!=None:
|
|
1721
|
+
self.qui.remove()
|
|
1722
|
+
self.qui=None
|
|
1723
|
+
if self.stream is not None:
|
|
1724
|
+
self.stream.lines.remove()
|
|
1725
|
+
for ax in self.ui.plot.axes.get_children():
|
|
1726
|
+
if isinstance(ax, mpl.patches.FancyArrowPatch):
|
|
1727
|
+
ax.remove()
|
|
1728
|
+
self.stream=None
|
|
1405
1729
|
|
|
1406
1730
|
def showVecField(self):
|
|
1407
1731
|
ind=self.VISpar.field_rep
|
|
1732
|
+
self.cleanVecField()
|
|
1408
1733
|
if self.qui!=None:
|
|
1409
1734
|
self.qui.remove()
|
|
1410
1735
|
self.qui=None
|
|
@@ -1414,7 +1739,7 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
1414
1739
|
if isinstance(ax, mpl.patches.FancyArrowPatch):
|
|
1415
1740
|
ax.remove()
|
|
1416
1741
|
self.stream=None
|
|
1417
|
-
if ind in (1,2):
|
|
1742
|
+
if ind in (1,2) and (self.VISpar.type>0 or self.VISpar.Step==StepTypes.piv):
|
|
1418
1743
|
if not self.VISpar.unit[self.VISpar.type]:
|
|
1419
1744
|
xres,yres=self.getXYRes(type=1)
|
|
1420
1745
|
else: xres=yres=1.0
|
|
@@ -1429,45 +1754,73 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
1429
1754
|
Mod=np.sqrt(U**2+V**2)
|
|
1430
1755
|
if ind==1:
|
|
1431
1756
|
dX=np.sqrt((X[0,1]-X[0,0])**2+(Y[1,0]-Y[0,0])**2)
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
size_pixels=self.ui.plot.fig.get_size_inches()*self.ui.plot.fig.get_dpi()*self.ui.plot.axes.get_position().bounds[2:]
|
|
1435
|
-
spaPixels=dX*size_pixels/dW
|
|
1436
|
-
fac_spa=np.max(nPixelsPerVector/spaPixels).astype(int).item()
|
|
1437
|
-
spa=self.VISpar.vecspac=max([1,fac_spa])
|
|
1438
|
-
vecsize=self.VISpar.vecsize=1.5
|
|
1439
|
-
self.ui.spin_vecspac.setValue(spa)
|
|
1440
|
-
self.ui.spin_vecsize.setValue(vecsize)
|
|
1441
|
-
else:
|
|
1442
|
-
spa=self.VISpar.vecspac
|
|
1443
|
-
vecsize=self.VISpar.vecsize
|
|
1757
|
+
spa=self.VISpar.vecspac
|
|
1758
|
+
vecsize=self.VISpar.vecsize
|
|
1444
1759
|
fac=dX*vecsize*spa
|
|
1445
1760
|
Modq= Mod[::spa,::spa]
|
|
1446
1761
|
Uq=np.divide(U[::spa,::spa], Modq, where=Modq!=0)*fac
|
|
1447
1762
|
Vq=np.divide(V[::spa,::spa], Modq, where=Modq!=0)*fac
|
|
1448
1763
|
w=0.15*fac
|
|
1449
|
-
|
|
1450
|
-
|
|
1764
|
+
n=3
|
|
1765
|
+
wmax=min([X.max()-X.min(),Y.max()-Y.min()])*0.001
|
|
1766
|
+
qwidth=min([w,wmax])*self.VISpar.vecwid**2
|
|
1451
1767
|
hwidth=4 if vecsize<4 else vecsize
|
|
1452
1768
|
self.qui=self.ui.plot.axes.quiver(
|
|
1453
1769
|
X[::spa,::spa],Y[::spa,::spa],Uq,Vq, color=VIS_VectorColors[self.VISpar.vectorColor], clip_on=True,
|
|
1454
1770
|
angles='xy',scale_units='xy',scale=1.0,
|
|
1455
1771
|
units='xy',width=qwidth,headwidth=hwidth,headlength=1.25*hwidth,headaxislength=0.75*hwidth,zorder=10)
|
|
1456
1772
|
elif ind==2:
|
|
1457
|
-
|
|
1773
|
+
size_pixels=np.shape(U)
|
|
1774
|
+
Up,_,_,_,_=self.calcMap(U,size_pixels=size_pixels)
|
|
1775
|
+
Vp,Xp,Yp,_,_=self.calcMap(V,size_pixels=size_pixels)
|
|
1776
|
+
Xp=Xp*xres
|
|
1777
|
+
Yp=Yp*yres
|
|
1778
|
+
self.stream=self.ui.plot.axes.streamplot(Xp,Yp,Up,Vp,color=VIS_VectorColors[self.VISpar.vectorColor],density=self.VISpar.streamdens,zorder=10)
|
|
1458
1779
|
|
|
1459
1780
|
def cleanAxes(self,FlagAxis=True):
|
|
1460
|
-
self.imgshow=self.contour=None
|
|
1461
|
-
self.
|
|
1781
|
+
self.imgshow=self.contour=self.CR=self.RF=None
|
|
1782
|
+
self.orect=[]
|
|
1783
|
+
self.qui=self.stream=None
|
|
1784
|
+
"""
|
|
1785
|
+
self.cleanCommonRegion()
|
|
1786
|
+
self.cleanReferenceFrame()
|
|
1787
|
+
self.cleanRect()
|
|
1788
|
+
self.cleanVecField()
|
|
1789
|
+
if self.contour:
|
|
1790
|
+
for coll in self.contour.collections:
|
|
1791
|
+
coll.remove()
|
|
1792
|
+
"""
|
|
1462
1793
|
if self.cb:
|
|
1463
|
-
|
|
1464
|
-
self.cb.remove()
|
|
1465
|
-
except:
|
|
1466
|
-
pass
|
|
1794
|
+
self.cb.remove()
|
|
1467
1795
|
self.cb=None
|
|
1796
|
+
self.ui.plot.axes.cla()
|
|
1468
1797
|
self.ui.plot.axes.axis('on' if FlagAxis else 'off')
|
|
1469
1798
|
#self.ui.Plot_tools.setEnabled(FlagAxis)
|
|
1470
1799
|
|
|
1800
|
+
def custom_format_coord(self,x,y):
|
|
1801
|
+
if self.contour is not None:
|
|
1802
|
+
X=self.map[0]
|
|
1803
|
+
Y=self.map[1]
|
|
1804
|
+
|
|
1805
|
+
if X.min() <= x <= X.max() and Y.min() <= y <= Y.max():
|
|
1806
|
+
# Trova l'indice più vicino nella matrice
|
|
1807
|
+
col = np.searchsorted(X[0,:],x) - 1
|
|
1808
|
+
row = np.searchsorted(Y[:,0],y) - 1
|
|
1809
|
+
Z=self.map[2]
|
|
1810
|
+
|
|
1811
|
+
# Estrai il valore dal dato Z
|
|
1812
|
+
if 0 <= row < Z.shape[0] and 0 <= col < Z.shape[1]:
|
|
1813
|
+
value = Z[row, col]
|
|
1814
|
+
formatted_value = f"{value:.4f}".rstrip('0').rstrip('.')
|
|
1815
|
+
return f"(x, y)=({x:.2f}, {y:.2f})\n[{formatted_value}]"
|
|
1816
|
+
return f"(x, y)=({x:.2f}, {y:.2f})"
|
|
1817
|
+
else:
|
|
1818
|
+
return f"(x, y)=({x:.2f}, {y:.2f})"
|
|
1819
|
+
|
|
1820
|
+
def custom_format_cursor_data(self,value):
|
|
1821
|
+
formatted_value = f"{value:.4f}".rstrip('0').rstrip('.')
|
|
1822
|
+
return f"[{formatted_value}]"
|
|
1823
|
+
|
|
1471
1824
|
def cleanRect(self):
|
|
1472
1825
|
if len(self.orect):
|
|
1473
1826
|
for r in self.orect:
|
|
@@ -1551,34 +1904,42 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
1551
1904
|
else:
|
|
1552
1905
|
yin0=0
|
|
1553
1906
|
xin0=xmax
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1907
|
+
if self.VISpar.FlagShowIW and self.VISpar.isDifferentFrom(self.VISpar_old,fields=['FlagShowIW']):
|
|
1908
|
+
xlim=self.ui.plot.axes.get_xlim()
|
|
1909
|
+
xlim_min=min([xlim[0],xlim_min])
|
|
1910
|
+
xlim_max=max([xlim[1],xlim_max])
|
|
1911
|
+
self.ui.plot.axes.set_xlim(xlim_min,xlim_max)
|
|
1912
|
+
if self.VISpar.FlagYInvert[self.VISpar.type]:
|
|
1913
|
+
ylim=self.ui.plot.axes.get_ylim()
|
|
1914
|
+
ylim_max=min([ylim[1],ylim_min])
|
|
1915
|
+
ylim_min=max([ylim[0],ylim_max])
|
|
1916
|
+
else:
|
|
1917
|
+
ylim=self.ui.plot.axes.get_ylim()
|
|
1918
|
+
ylim_min=min([ylim[0],ylim_min])
|
|
1919
|
+
ylim_max=max([ylim[1],ylim_max])
|
|
1920
|
+
self.ui.plot.axes.set_ylim(ylim_min,ylim_max)
|
|
1921
|
+
self.VISpar.xmin,self.VISpar.xmax=list(self.ui.plot.axes.get_xlim())
|
|
1922
|
+
self.VISpar.ymin,self.VISpar.ymax=list(self.ui.plot.axes.get_ylim())
|
|
1923
|
+
|
|
1924
|
+
def cleanCommonRegion(self):
|
|
1571
1925
|
if self.CR:
|
|
1572
1926
|
self.CR.remove()
|
|
1573
1927
|
self.CR=None
|
|
1928
|
+
self.ui.plot.draw_idle()
|
|
1929
|
+
self.cleanReferenceFrame()
|
|
1574
1930
|
|
|
1931
|
+
def showCommonRegion(self):
|
|
1932
|
+
self.cleanCommonRegion()
|
|
1575
1933
|
try:
|
|
1576
1934
|
mapFun=PaIRS_lib.MappingFunction()
|
|
1577
1935
|
mapFun.readCal(self.VISpar.calList)
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1936
|
+
|
|
1937
|
+
#if self.VISpar.Step==StepTypes.spiv:
|
|
1938
|
+
# planeConst=self.readLaserPlaneConst(self.VISpar.dispFile)
|
|
1939
|
+
#else:
|
|
1940
|
+
# planeConst=[0.0,0.0,0.0]
|
|
1941
|
+
planeConst=[self.VISpar.Out.zconst,self.VISpar.Out.xterm,self.VISpar.Out.yterm]
|
|
1942
|
+
|
|
1582
1943
|
o=self.VISpar.Out
|
|
1583
1944
|
points=[ [o.x_min, o.y_min], [o.x_max, o.y_min], [o.x_max, o.y_max], [o.x_min, o.y_max]]
|
|
1584
1945
|
zLaser=lambda xy: self.zLaser(xy[0],xy[1],planeConst)
|
|
@@ -1590,30 +1951,68 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
1590
1951
|
x_values = [Xp[0] for Xp in X]+[X[0][0]]
|
|
1591
1952
|
y_values = [Xp[1] for Xp in X]+[X[0][1]]
|
|
1592
1953
|
self.CR,=self.ui.plot.axes.plot(x_values, y_values, 'b-',clip_on=False)
|
|
1954
|
+
self.showReferenceFrame(mapFun=mapFun)
|
|
1593
1955
|
except Exception as exc:
|
|
1594
1956
|
pri.Error.red(f"[VIS] Error while plotting common zone!\n{traceback.format_exc()}\n")
|
|
1595
1957
|
return
|
|
1596
1958
|
|
|
1597
1959
|
def zLaser(self,x,y,planeConst):
|
|
1598
1960
|
return planeConst[0]+planeConst[1]*x+planeConst[2]*y
|
|
1599
|
-
|
|
1600
|
-
def
|
|
1961
|
+
|
|
1962
|
+
def cleanReferenceFrame(self):
|
|
1963
|
+
if self.RF:
|
|
1964
|
+
for p in self.RF:
|
|
1965
|
+
p.remove()
|
|
1966
|
+
self.RF=None
|
|
1967
|
+
self.ui.plot.draw_idle()
|
|
1968
|
+
|
|
1969
|
+
def showReferenceFrame(self,mapFun=None):
|
|
1970
|
+
self.cleanReferenceFrame()
|
|
1601
1971
|
try:
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1972
|
+
if mapFun is None:
|
|
1973
|
+
mapFun=PaIRS_lib.MappingFunction()
|
|
1974
|
+
mapFun.readCal(self.VISpar.calList)
|
|
1975
|
+
|
|
1976
|
+
labels=['O','x','y','z']
|
|
1977
|
+
unit=1
|
|
1978
|
+
|
|
1979
|
+
points=[ [0, 0, 0], [unit, 0, 0], [0, unit, 0], [0, 0, unit]]
|
|
1980
|
+
points_array=np.array(points,dtype=np.float64,order='C')
|
|
1981
|
+
cam=self.VISpar.cam-1
|
|
1982
|
+
X=mapFun.worldToImg(points_array,cam,None)# In output X1 is equal to X if correctly allocated
|
|
1983
|
+
|
|
1984
|
+
self.RF=[]
|
|
1985
|
+
origin=X[0]
|
|
1986
|
+
hp,=self.ui.plot.axes.plot(origin[0], origin[1], 'o', color='darkblue') # 'ko' indica un pallino nero
|
|
1987
|
+
self.RF.append(hp)
|
|
1988
|
+
length=0.25*min([q for q in self.image.shape])
|
|
1989
|
+
qwidth=length/25
|
|
1990
|
+
hwidth=4
|
|
1991
|
+
vnorm = np.linalg.norm(X[2]-origin)
|
|
1992
|
+
#colors=['darkred','darkgreen','darkmagenta']
|
|
1993
|
+
for k in range(1,len(X)-1): #-1 exclude z
|
|
1994
|
+
P=X[k]
|
|
1995
|
+
v=P-origin
|
|
1996
|
+
if vnorm!=0: v=v/vnorm*length
|
|
1997
|
+
hp=self.ui.plot.axes.quiver(origin[0], origin[1], v[0], v[1],
|
|
1998
|
+
color='darkblue',#color=colors[k-1],
|
|
1999
|
+
angles='xy',scale_units='xy',scale=1.0,
|
|
2000
|
+
units='xy',width=qwidth,headwidth=hwidth,headlength=1.25*hwidth,headaxislength=0.75*hwidth,zorder=10)
|
|
2001
|
+
self.RF.append(hp)
|
|
2002
|
+
T=origin+v*1.2
|
|
2003
|
+
ha=self.ui.plot.axes.text(T[0], T[1], f'{labels[k]}', color='darkblue', fontsize=fontPixelSize)
|
|
2004
|
+
self.RF.append(ha)
|
|
2005
|
+
"""
|
|
2006
|
+
X[k]=T
|
|
2007
|
+
T=0.5*(X[1]+X[2])
|
|
2008
|
+
T=origin-0.1*(T-origin)
|
|
2009
|
+
ha=self.ui.plot.axes.text(T[0], T[1], f'{labels[0]}', color='darkblue', fontsize=fontPixelSize)
|
|
2010
|
+
self.RF.append(ha)
|
|
2011
|
+
"""
|
|
2012
|
+
except Exception as exc:
|
|
2013
|
+
pri.Error.red(f"[VIS] Error while plotting reference frame!\n{traceback.format_exc()}\n")
|
|
2014
|
+
return
|
|
2015
|
+
|
|
1617
2016
|
"""
|
|
1618
2017
|
def getZonaCom(self,c:int):
|
|
1619
2018
|
return (min (self.disp.vect.Xinf[c],self.disp.vect.Xsup[c]),
|
|
@@ -1626,19 +2025,26 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
1626
2025
|
def contextMenuEvent(self, event):
|
|
1627
2026
|
contextMenu = QMenu(self)
|
|
1628
2027
|
copy2clipboard = contextMenu.addAction("Copy to clipboard ("+self.QS_copy2clipboard.key().toString(QKeySequence.NativeText)+")")
|
|
2028
|
+
copy2clipboard.setIcon(self.ui.plot.copyIcon)
|
|
1629
2029
|
copy2newfig = contextMenu.addAction("Open in new figure ("+self.QS_copy2newfig.key().toString(QKeySequence.NativeText)+")")
|
|
2030
|
+
copy2newfig.setIcon(self.ui.plot.openNewWindowIcon)
|
|
1630
2031
|
contextMenu.addSeparator()
|
|
1631
|
-
if len(self.ui.plot.fig2)>
|
|
2032
|
+
if len(self.ui.plot.fig2)>0:
|
|
1632
2033
|
showAll = contextMenu.addAction("Show all")
|
|
1633
|
-
|
|
2034
|
+
showAll.setIcon(self.ui.plot.showAllIcon)
|
|
1634
2035
|
alignAll = contextMenu.addAction("Align all")
|
|
2036
|
+
alignAll.setIcon(self.ui.plot.alignAllIcon)
|
|
2037
|
+
closeAll = contextMenu.addAction("Close all")
|
|
2038
|
+
closeAll.setIcon(self.ui.plot.closeAllIcon)
|
|
1635
2039
|
contextMenu.addSeparator()
|
|
1636
2040
|
else:
|
|
1637
2041
|
showAll = None
|
|
1638
2042
|
closeAll= None
|
|
1639
2043
|
alignAll= None
|
|
1640
2044
|
loadImg = contextMenu.addAction("Load image")
|
|
2045
|
+
loadImg.setIcon(self.ui.plot.loadImageIcon)
|
|
1641
2046
|
loadRes = contextMenu.addAction("Load result")
|
|
2047
|
+
loadRes.setIcon(self.ui.plot.loadResultIcon)
|
|
1642
2048
|
|
|
1643
2049
|
action = contextMenu.exec(self.mapToGlobal(event.pos()))
|
|
1644
2050
|
if action == copy2clipboard:
|
|
@@ -1669,6 +2075,7 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
1669
2075
|
self.image=None
|
|
1670
2076
|
|
|
1671
2077
|
self.ui.spin_img.setMinimum(-1)
|
|
2078
|
+
self.VISpar.image_file=''
|
|
1672
2079
|
self.VISpar.img=-1
|
|
1673
2080
|
self.VISpar.type=0
|
|
1674
2081
|
self.VISpar.variable=self.namesPIV.combo_dict[self.namesPIV.img]
|
|
@@ -1685,6 +2092,7 @@ class Vis_Tab(gPaIRS_Tab):
|
|
|
1685
2092
|
self.result_file_Load=filename
|
|
1686
2093
|
self.result=None
|
|
1687
2094
|
self.ui.spin_img.setMinimum(-1)
|
|
2095
|
+
self.VISpar.result_file=''
|
|
1688
2096
|
self.VISpar.img=-1
|
|
1689
2097
|
self.VISpar.variable=self.namesPIV.combo_dict[self.namesPIV.Mod]
|
|
1690
2098
|
self.VISpar.variableKey=self.namesPIV.combo_dict_keys[self.VISpar.variable]
|