1 | %'civ': function associated with the interface 'civ.fig' for PIV, spline interpolation and stereo PIV (patch) |
---|
2 | %------------------------------------------------------------------------ |
---|
3 | % provides an interface for the software CIVx |
---|
4 | % function varargout = civ(varargin) |
---|
5 | % provides an interface for the software CIVx |
---|
6 | % |
---|
7 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
8 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org. |
---|
9 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
10 | % This file is part of the toolbox UVMAT. |
---|
11 | % |
---|
12 | % UVMAT is free software; you can redistribute it and/or modify |
---|
13 | % it under the terms of the GNU General Public License as published by |
---|
14 | % the Free Software Foundation; either version 2 of the License, or |
---|
15 | % (at your option) any later version. |
---|
16 | % |
---|
17 | % UVMAT is distributed in the hope that it will be useful, |
---|
18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
20 | % GNU General Public License (file UVMAT/COPYING.txt) for more details. |
---|
21 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
22 | function varargout = civ(varargin) |
---|
23 | |
---|
24 | % Last Modified by GUIDE v2.5 11-Mar-2011 08:21:21 |
---|
25 | % Begin initialization code - DO NOT EDIT |
---|
26 | gui_Singleton = 1; |
---|
27 | gui_State = struct('gui_Name', mfilename, ... |
---|
28 | 'gui_Singleton', gui_Singleton, ... |
---|
29 | 'gui_OpeningFcn', @civ_OpeningFcn, ... |
---|
30 | 'gui_OutputFcn', @civ_OutputFcn, ... |
---|
31 | 'gui_LayoutFcn', [] , ... |
---|
32 | 'gui_Callback', []); |
---|
33 | if nargin && ischar(varargin{1}) |
---|
34 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
35 | end |
---|
36 | |
---|
37 | if nargout |
---|
38 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
39 | else |
---|
40 | gui_mainfcn(gui_State, varargin{:}); |
---|
41 | end |
---|
42 | % End initialization code - DO NOT EDIT |
---|
43 | |
---|
44 | %------------------------------------------------------------------------ |
---|
45 | % --- Executes just before civ is made visible. |
---|
46 | function civ_OpeningFcn(hObject, eventdata, handles, param) |
---|
47 | %------------------------------------------------------------------------ |
---|
48 | % This function has no output args, see OutputFcn. |
---|
49 | % hObject handle to figure |
---|
50 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
51 | % handles structure with handles and user data (see GUIDATA) |
---|
52 | % varargin command line arguments to civ (see VARARGIN) |
---|
53 | global patch_newBin %=1 if new patch processing available |
---|
54 | %filebase: root name |
---|
55 | %nom_type: nomencalture used ('png_old','_i_j'...) |
---|
56 | %list of field numbers to process |
---|
57 | %subdir: subdirectory of the opened netcdf file |
---|
58 | %ind_opening: operation number advised for beginning (1=civ1,2=fix1,3=patch1,4=civ2,5=fix2,6=patch2), |
---|
59 | %ind_a_opening ind_b_opening chosen pair from the opened netcdf file |
---|
60 | % Choose default command line output for civ |
---|
61 | handles.output = hObject; |
---|
62 | % Update handles structure |
---|
63 | guidata(hObject, handles); |
---|
64 | set(hObject,'WindowButtonDownFcn',{'mouse_alt_gui',handles}) % allows mouse action with right button (zoom for uicontrol display) |
---|
65 | %default initial parameters |
---|
66 | filebase=''; % root file name ('filebase'.civ) |
---|
67 | ext=[]; |
---|
68 | set(handles.CivAll,'String',{'CivX';'CivAll';'CivUvmat'}) |
---|
69 | set(handles.subdomain_patch1,'String','1500')% default values |
---|
70 | set(handles.subdomain_patch2,'String','1500') |
---|
71 | delete(handles.grid_patch1) |
---|
72 | delete(handles.get_gridpatch1) |
---|
73 | delete(handles.grid_patch2) |
---|
74 | delete(handles.get_gridpatch2) |
---|
75 | |
---|
76 | %default input parameters: |
---|
77 | num_i1=1; % set of field i numbers |
---|
78 | num_i2=1; % set of field i numbers |
---|
79 | num_j1=1; % set of field j numbers (fields a) |
---|
80 | num_j2=1; % second set of field j numbers (fields b) |
---|
81 | subdir='A'; % subdir for the netcdf result files |
---|
82 | ind_opening=1; % proposed operation number (1=civ1,2=fix1,3=patch1,4=civ2,5=fix2,6=patch2) |
---|
83 | %load the initial parameters if the interface is started from uvmat |
---|
84 | if exist('param','var')&&isstruct(param)% the interface is opened from uvmat |
---|
85 | filebase=param.RootName; |
---|
86 | nom_type_read=param.NomType; |
---|
87 | num_i1=param.num1; |
---|
88 | if isnan(num_i1),num_i1=1;end |
---|
89 | num_i2=param.num2; |
---|
90 | if isnan(num_i2),num_i2=num_i1;end |
---|
91 | num_j1=param.num_a; |
---|
92 | if isnan(num_j1),num_j1=1;end |
---|
93 | num_j2=param.num_b; |
---|
94 | if isnan(num_j2),num_j2=num_j1;end |
---|
95 | subdir=param.SubDir; |
---|
96 | ind_opening=param.IndOpening; |
---|
97 | ext=param.ImaExt; |
---|
98 | end |
---|
99 | browse.num_i1=num_i1; |
---|
100 | browse.num_i2=num_i2; |
---|
101 | browse.num_j1=num_j1; |
---|
102 | browse.num_j2=num_j2; |
---|
103 | if ~isempty(ext) && (~isempty(imformats(ext(2:end)))||strcmpi(ext,'.avi'));%if an image file has been opened by uvmat |
---|
104 | set(handles.ImaExt,'String',ext) |
---|
105 | browse.ext_ima=ext; |
---|
106 | if exist('nom_type_read','var') |
---|
107 | browse.nom_type_ima=nom_type_read; % the image nomenclature is stored |
---|
108 | end |
---|
109 | elseif isequal(ext,'.nc') |
---|
110 | if exist('nom_type_read','var') |
---|
111 | browse.nom_type_nc=nom_type_read;% the netcdf nomenclature is stored |
---|
112 | end |
---|
113 | end |
---|
114 | set(handles.RootName,'String',filebase); |
---|
115 | set(handles.ImaDoc,'String',ext) |
---|
116 | |
---|
117 | %read names of the .exe file to adjust the interface according to available binaries |
---|
118 | path_uvmat=which('uvmat');% check the path detected for source file uvmat |
---|
119 | path_UVMAT=fileparts(path_uvmat); %path to UVMAT |
---|
120 | errormsg=[];%default error message |
---|
121 | xmlfile='PARAM.xml'; |
---|
122 | if exist(xmlfile,'file') |
---|
123 | try |
---|
124 | t=xmltree(xmlfile); |
---|
125 | sparam=convert(t); |
---|
126 | catch |
---|
127 | errormsg={' Unable to read the file PARAM.xml defining the civx binaries:'; lasterr}; |
---|
128 | return |
---|
129 | end |
---|
130 | else |
---|
131 | errormsg=[xmlfile ' not found: path to civx binaries undefined']; |
---|
132 | return |
---|
133 | end |
---|
134 | |
---|
135 | |
---|
136 | if ~isempty(errormsg) |
---|
137 | msgbox_uvmat('ERROR',errormsg); |
---|
138 | end |
---|
139 | % patch_newBin=''; |
---|
140 | test_batch=0;%default: ,no batch mode available |
---|
141 | if isfield(sparam,'BatchParam') && isfield(sparam.BatchParam,'BatchMode') |
---|
142 | test_batch=strcmp(sparam.BatchParam.BatchMode,'sge'); %sge is currently the only implemented batch mod |
---|
143 | end |
---|
144 | if test_batch==0 |
---|
145 | set(handles.BATCH,'Enable','off')% put the BATCH button in grey (unactivated) |
---|
146 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784])% put the BATCH button in grey (unactivated) |
---|
147 | end |
---|
148 | if isfield(sparam.RunParam,'CivBin') |
---|
149 | if ~exist(sparam.RunParam.CivBin,'file') |
---|
150 | sparam.RunParam.CivBin=fullfile(path_UVMAT,sparam.RunParam.CivBin); |
---|
151 | end |
---|
152 | else |
---|
153 | sparam.RunParam.CivBin=''; |
---|
154 | end |
---|
155 | patch_newBin=exist(sparam.RunParam.CivBin,'file'); |
---|
156 | set(handles.subdir_civ1,'String',subdir)%default subdir on which uvmat was working |
---|
157 | set(handles.subdir_civ2,'String',subdir)%default subdir on which uvmat was working |
---|
158 | |
---|
159 | %initiate advised operations |
---|
160 | if isequal(ind_opening,[]) |
---|
161 | ind_opening=1; % default |
---|
162 | end |
---|
163 | % set default operation options |
---|
164 | enable_civ1(handles,'off') |
---|
165 | enable_civ2(handles,'off') |
---|
166 | enable_pair1(handles,'on') |
---|
167 | enable_fix1(handles,'off') |
---|
168 | desable_patch1(handles) |
---|
169 | desable_fix2(handles) |
---|
170 | desable_patch2(handles) |
---|
171 | set(handles.CIV1,'Value',0) |
---|
172 | set(handles.FIX1,'Value',0) |
---|
173 | set(handles.PATCH1,'Value',0) |
---|
174 | set(handles.CIV2,'Value',0) |
---|
175 | set(handles.FIX2,'Value',0) |
---|
176 | set(handles.PATCH2,'Value',0) |
---|
177 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
178 | if isequal(ind_opening,1) |
---|
179 | set(handles.CIV1,'Value',1) |
---|
180 | enable_civ1(handles,'on') |
---|
181 | elseif isequal(ind_opening,2) |
---|
182 | set(handles.FIX1,'Value',1) |
---|
183 | enable_fix1(handles,'on') |
---|
184 | elseif isequal(ind_opening,3) |
---|
185 | set(handles.PATCH1,'Value',1) |
---|
186 | enable_patch1(handles) |
---|
187 | elseif isequal(ind_opening,4) |
---|
188 | set(handles.CIV2,'Value',1) |
---|
189 | enable_civ2(handles,'on') |
---|
190 | elseif isequal(ind_opening,5) |
---|
191 | set(handles.FIX2,'Value',1) |
---|
192 | enable_fix2(handles) |
---|
193 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
194 | set(handles.list_pair_civ2,'Enable','On') |
---|
195 | set(handles.list_pair_civ2,'Enable','On') |
---|
196 | enable_pair1(handles,'off') |
---|
197 | elseif isequal(ind_opening,6) |
---|
198 | set(handles.PATCH2,'Value',1) |
---|
199 | enable_patch2(handles) |
---|
200 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
201 | set(handles.list_pair_civ2,'Enable','On') |
---|
202 | enable_pair1(handles,'off') |
---|
203 | end |
---|
204 | |
---|
205 | % set the range of fields (1:1 by default) and selected pair |
---|
206 | if isequal(num_i2,num_i1) |
---|
207 | num_ref_i=num_i1; |
---|
208 | else |
---|
209 | num_ref_i=floor((num_i1+num_i2)/2); |
---|
210 | browse.incr_pair(1)=num_i2-num_i1; |
---|
211 | browse.incr_pair(2)=0; |
---|
212 | end |
---|
213 | if isequal(num_j1,num_j2) |
---|
214 | if isnan(num_j1) |
---|
215 | num_ref_j=1; |
---|
216 | else |
---|
217 | num_ref_j=num_j1; |
---|
218 | end |
---|
219 | else |
---|
220 | num_ref_j=floor((num_j1+num_j2)/2); |
---|
221 | browse.incr_pair(2)=num_j2-num_j1; |
---|
222 | end |
---|
223 | set(handles.first_i,'String',num2str(num_ref_i)); |
---|
224 | set(handles.last_i,'String',num2str(num_ref_i)); |
---|
225 | set(handles.first_j,'String',num2str(num_ref_j)); |
---|
226 | set(handles.last_j,'String',num2str(num_ref_j)); |
---|
227 | set(handles.ref_i,'String',num2str(num_ref_i)); |
---|
228 | set(handles.ref_j,'String',num2str(num_ref_j)); |
---|
229 | set(handles.ref_i_civ2,'String',num2str(num_ref_i)); |
---|
230 | set(handles.ref_j_civ2,'String',num2str(num_ref_j)); |
---|
231 | set(handles.browse_root,'UserData',browse); |
---|
232 | if exist('param','var') && isfield(param,'RootName') && ~isempty(param.RootName)%varargin the interface is opened from uvmat |
---|
233 | RootName_Callback(hObject, eventdata, handles); |
---|
234 | end |
---|
235 | |
---|
236 | % set(handles.waitbar_1,'Position',[0.946 0.877 0.03 0.001]) |
---|
237 | % set(handles.waitbar_patch1,'Position',[0.946 0.626 0.03 0.001]) |
---|
238 | % set(handles.waitbar_civ2,'Position',[0.946 0.406 0.03 0.001]) |
---|
239 | % set(handles.waitbar_patch2,'Position',[0.946 0.187 0.03 0.001]) |
---|
240 | |
---|
241 | %------------------------------------------------------------------------ |
---|
242 | % --- Outputs from this function are returned to the command line. |
---|
243 | function varargout = civ_OutputFcn(hObject, eventdata, handles) |
---|
244 | %------------------------------------------------------------------------ |
---|
245 | % varargout cell array for returning output args (see VARARGOUT); |
---|
246 | % hObject handle to figure |
---|
247 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
248 | % handles structure with handles and user data (see GUIDATA) |
---|
249 | % Get default command line output from handles structure |
---|
250 | varargout{1} = handles.output; |
---|
251 | |
---|
252 | %------------------------------------------------------------------------ |
---|
253 | % --- Executes on button press in browse_root. |
---|
254 | function browse_root_Callback(hObject, eventdata, handles) |
---|
255 | %------------------------------------------------------------------------ |
---|
256 | %get the input file properties |
---|
257 | filebase=get(handles.RootName,'String'); |
---|
258 | oldfile=''; %default |
---|
259 | if isempty(filebase)|| isequal(filebase,'')%loads the previously stored file name and set it as default in the file_input box |
---|
260 | dir_perso=prefdir; |
---|
261 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
262 | if exist(profil_perso,'file') |
---|
263 | h=load (profil_perso); |
---|
264 | if isfield(h,'filebase')&& ischar(h.filebase) |
---|
265 | oldfile=h.filebase; |
---|
266 | end |
---|
267 | if isfield(h,'RootPath') && ischar(h.RootPath) |
---|
268 | oldfile=h.RootPath; |
---|
269 | end |
---|
270 | end |
---|
271 | else |
---|
272 | oldfile=filebase; |
---|
273 | end |
---|
274 | ind_opening=1;%default |
---|
275 | browse.incr_pair=[0 0]; %default |
---|
276 | menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)'; |
---|
277 | '*.xml', '.xml files '; ... |
---|
278 | '*.civ', '.civ files '; ... |
---|
279 | '*.png','.png image files'; ... |
---|
280 | '*.jpg',' jpeg image files'; ... |
---|
281 | '*.tif','.tif image files'; ... |
---|
282 | '*.avi;*.AVI','.avi movie files'; ... |
---|
283 | '*.nc','.netcdf files'; ... |
---|
284 | '*.*', 'All Files (*.*)'}; |
---|
285 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile); |
---|
286 | fileinput=[PathName FileName];%complete file name |
---|
287 | sizf=size(fileinput); |
---|
288 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
289 | [path,name,ext]=fileparts(fileinput); |
---|
290 | testeditxml=0; |
---|
291 | if isequal(ext,'.xml') |
---|
292 | testeditxml=1; |
---|
293 | t_browse=xmltree(fileinput); |
---|
294 | head_element=get(t_browse,1); |
---|
295 | if isfield(head_element,'name')&& isequal(head_element.name,'ImaDoc') |
---|
296 | testeditxml=0; |
---|
297 | end |
---|
298 | end |
---|
299 | if testeditxml==1 || isequal(ext,'.xls') |
---|
300 | heditxml=editxml({fileinput}); |
---|
301 | set(heditxml,'Tag','browser') |
---|
302 | waitfor(heditxml,'Tag','idle') |
---|
303 | if ~ishandle(heditxml) |
---|
304 | return |
---|
305 | end |
---|
306 | attr=findobj(get(heditxml,'children'),'Tag','CurrentAttributes'); |
---|
307 | set(handles.browse,'UserData',fileinput)% store for future opening with browser |
---|
308 | fileinput=get(attr,'UserData'); |
---|
309 | if ~exist(fileinput,'file') |
---|
310 | return |
---|
311 | end |
---|
312 | end |
---|
313 | [RootPath,RootFile,str1,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput); |
---|
314 | filebase=fullfile(RootPath,RootFile); |
---|
315 | num_i1=str2double(str1); |
---|
316 | if isnan(num_i1),num_i1=1;end |
---|
317 | num_i2=str2double(str2); |
---|
318 | if isnan(num_i2),num_i2=num_i1;end |
---|
319 | num_j1=stra2num(str_a); |
---|
320 | if isnan(num_j1),num_j1=1;end |
---|
321 | num_j2=stra2num(str_b); |
---|
322 | if isnan(num_j2),num_j2=num_j1;end |
---|
323 | if isequal(get(handles.compare,'Value'),1) |
---|
324 | browse=[];%initialisation |
---|
325 | else |
---|
326 | browse=get(handles.browse_root,'UserData'); |
---|
327 | end |
---|
328 | browse.num_i1=num_i1; |
---|
329 | browse.num_i2=num_i2; |
---|
330 | browse.num_j1=num_j1; |
---|
331 | browse.num_j2=num_j2; |
---|
332 | if length(ext)>1 && (~isempty(imformats(ext(2:end)))||strcmpi(ext,'.avi'));%if an image file has been opened by uvmat |
---|
333 | browse.nom_type_ima=nom_type; |
---|
334 | browse.ext_ima=ext; |
---|
335 | set(handles.ImaExt,'String',ext) |
---|
336 | end |
---|
337 | set(handles.ImaDoc,'String',ext); |
---|
338 | |
---|
339 | %%%%% read the state of the selected netcdf file to advise default operation |
---|
340 | if isequal(ext,'.nc') |
---|
341 | browse.nom_type_nc=nom_type; |
---|
342 | ind_opening=2;% propose 'fix' as the default option |
---|
343 | Data=nc2struct(fileinput,'ListGlobalAttribute','CivStage','absolut_time_T0','fix','patch','civ2','fix2'); |
---|
344 | if ~isempty(Data.CivStage)%test for civ files |
---|
345 | ind_opening=Data.CivStage; |
---|
346 | set(handles.CivAll,'Value',3) |
---|
347 | end |
---|
348 | if ~isempty(Data.absolut_time_T0)%test for civx files |
---|
349 | set(handles.CivAll,'Value',1) |
---|
350 | if isfield(Data,'fix') && isequal(Data.fix,1) |
---|
351 | ind_opening=3; |
---|
352 | end |
---|
353 | if isequal(Data.patch,1) |
---|
354 | ind_opening=4; |
---|
355 | end |
---|
356 | if isequal(Data.civ2,1) |
---|
357 | ind_opening=5; |
---|
358 | end |
---|
359 | if isequal(Data.fix2,1) |
---|
360 | ind_opening=6; |
---|
361 | end |
---|
362 | testciv=1; %TO SUPPRESS WITH NEW VERSION OF CIVX |
---|
363 | else |
---|
364 | ind_opening=3; %GUI used only for patch |
---|
365 | testciv=0; |
---|
366 | end |
---|
367 | set(handles.subdir_civ1,'String',subdir);%set the default subdir directories for installing the .nc results |
---|
368 | set(handles.subdir_civ2,'String',subdir); |
---|
369 | browse.testciv=testciv; |
---|
370 | browse.ind_opening=ind_opening; |
---|
371 | end |
---|
372 | set(handles.RootName,'String',filebase); |
---|
373 | set(handles.ImaDoc,'String',ext); |
---|
374 | if ~isempty(num_i1) |
---|
375 | ref_i=num_i1; |
---|
376 | if ~isempty(num_i2) |
---|
377 | ref_i=floor((ref_i+num_i2)/2);% reference image number corresponding to the file |
---|
378 | browse.incr_pair(1)=num_i2-num_i1; |
---|
379 | browse.incr_pair(2)=0; |
---|
380 | end |
---|
381 | set(handles.first_i,'String',num2str(ref_i)); |
---|
382 | set(handles.last_i,'String',num2str(ref_i)); |
---|
383 | set(handles.ref_i,'String',num2str(ref_i)); |
---|
384 | set(handles.ref_i_civ2,'String',num2str(ref_i)) |
---|
385 | end |
---|
386 | if isempty(num_j1) |
---|
387 | set(handles.ref_j,'String','1'); |
---|
388 | set(handles.ref_j_civ2,'String','1'); |
---|
389 | else |
---|
390 | ref_j=num_j1; |
---|
391 | if ~isempty(num_j2) |
---|
392 | ref_j=floor((num_j1+num_j2)/2); |
---|
393 | browse.incr_pair(2)=num_j2-num_j1; |
---|
394 | end |
---|
395 | set(handles.first_j,'String',num2str(ref_j)); |
---|
396 | set(handles.last_j,'String',num2str(ref_j)); |
---|
397 | set(handles.ref_j,'String',num2str(ref_j)); |
---|
398 | set(handles.ref_j_civ2,'String',num2str(ref_j)); |
---|
399 | end |
---|
400 | |
---|
401 | % set default operation options |
---|
402 | enable_civ1(handles,'off') |
---|
403 | enable_civ2(handles,'off') |
---|
404 | enable_pair1(handles,'on') |
---|
405 | enable_fix1(handles,'off') |
---|
406 | desable_patch1(handles) |
---|
407 | desable_fix2(handles) |
---|
408 | desable_patch2(handles) |
---|
409 | set(handles.CIV1,'Value',0) |
---|
410 | set(handles.FIX1,'Value',0) |
---|
411 | set(handles.PATCH1,'Value',0) |
---|
412 | set(handles.CIV2,'Value',0) |
---|
413 | set(handles.FIX2,'Value',0) |
---|
414 | set(handles.PATCH2,'Value',0) |
---|
415 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
416 | if isequal(ind_opening,1) |
---|
417 | set(handles.CIV1,'Value',1) |
---|
418 | enable_civ1(handles,'on') |
---|
419 | elseif isequal(ind_opening,2) |
---|
420 | set(handles.FIX1,'Value',1) |
---|
421 | enable_fix1(handles,'on') |
---|
422 | elseif isequal(ind_opening,3) |
---|
423 | set(handles.PATCH1,'Value',1) |
---|
424 | enable_patch1(handles) |
---|
425 | elseif isequal(ind_opening,4) |
---|
426 | set(handles.CIV2,'Value',1) |
---|
427 | enable_civ2(handles,'on') |
---|
428 | elseif isequal(ind_opening,5) |
---|
429 | enable_pair1(handles,'off') |
---|
430 | set(handles.FIX2,'Value',1) |
---|
431 | enable_fix2(handles) |
---|
432 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
433 | set(handles.list_pair_civ2,'Enable','On') |
---|
434 | set(handles.list_pair_civ2,'Enable','On') |
---|
435 | elseif isequal(ind_opening,6) |
---|
436 | enable_pair1(handles,'off') |
---|
437 | set(handles.PATCH2,'Value',1) |
---|
438 | enable_patch2(handles) |
---|
439 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
440 | set(handles.list_pair_civ2,'Enable','On') |
---|
441 | end |
---|
442 | set(handles.browse_root,'UserData',browse);% store information from browser |
---|
443 | |
---|
444 | RootName_Callback(hObject, eventdata, handles); |
---|
445 | |
---|
446 | %------------------------------------------------------------------------ |
---|
447 | function ImaDoc_Callback(hObject, eventdata, handles) |
---|
448 | %------------------------------------------------------------------------ |
---|
449 | RootName_Callback(hObject, eventdata, handles) |
---|
450 | |
---|
451 | %------------------------------------------------------------------------ |
---|
452 | % --- function activated when a new filebase (image series) is introduced |
---|
453 | function RootName_Callback(hObject, eventdata, handles) |
---|
454 | %------------------------------------------------------------------------ |
---|
455 | set(handles.compare,'Visible','on') |
---|
456 | ext_ima='';%default |
---|
457 | nom_type_ima=[];%default |
---|
458 | field_count=1;%default |
---|
459 | nom_type_nc=[]; |
---|
460 | time=[]; |
---|
461 | TimeUnit='frame'; %default |
---|
462 | CoordUnit='px';%default |
---|
463 | pxcmx_search=[];%default |
---|
464 | pxcmy_search=[];%default |
---|
465 | filebase=get(handles.RootName,'String'); |
---|
466 | ext_imadoc=get(handles.ImaDoc,'String'); |
---|
467 | browse=get(handles.browse_root,'UserData');%default |
---|
468 | if isfield(browse,'nom_type_ima') |
---|
469 | nom_type_ima=browse.nom_type_ima;% get an image nomenclature type already determined by an input image name |
---|
470 | end |
---|
471 | if isfield(browse,'ext_ima') |
---|
472 | ext_ima=browse.ext_ima; |
---|
473 | end |
---|
474 | if isfield(browse,'nom_type_nc') |
---|
475 | nom_type_nc=browse.nom_type_nc;% get an image nomenclature type already determined by an input image name |
---|
476 | end |
---|
477 | if isfield(browse,'num_i1') |
---|
478 | field_count=browse.num_i1;% get an image index type already determined by an input file |
---|
479 | end |
---|
480 | set(handles.civ,'UserData',[]); %refresh list of previous civ files (for STATUS) |
---|
481 | |
---|
482 | %default first_i and j and increments |
---|
483 | first_i=str2double(get(handles.first_i,'String'));%value possibly set by uvmat_Opening |
---|
484 | if isnan(first_i)|| first_i < 1 |
---|
485 | first_i=1; %default first_i |
---|
486 | end |
---|
487 | last_i=str2double(get(handles.last_i,'String')); |
---|
488 | if isnan(last_i)|| last_i < first_i |
---|
489 | last_i=first_i; %default last_i |
---|
490 | end |
---|
491 | first_j=str2double(get(handles.first_j,'String')); |
---|
492 | if isnan(first_j)|| first_j < 1 |
---|
493 | first_j=1; %default first_j |
---|
494 | end |
---|
495 | last_j=str2double(get(handles.last_j,'String')); |
---|
496 | if isnan(last_j)|| last_j < first_j |
---|
497 | last_j=first_j; %default last_j |
---|
498 | end |
---|
499 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
500 | if isnan(incr_i) || incr_i < 1; |
---|
501 | set(handles.incr_i,'String','1') %default incr_i |
---|
502 | end |
---|
503 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
504 | if isnan(incr_j) || incr_j < 1; |
---|
505 | set(handles.incr_j,'String','1') %default incr_j |
---|
506 | end |
---|
507 | dt=[];%default |
---|
508 | testmode=0;%default |
---|
509 | nbfield=[]; %default |
---|
510 | nburst=[];%default |
---|
511 | pxcmx=1; |
---|
512 | pxcmy=1; |
---|
513 | |
---|
514 | %look for an image documentation file |
---|
515 | if ~strcmp(ext_imadoc,'.xml') && ~strcmp(ext_imadoc,'.civ')&& ~strcmpi(ext_imadoc,'.avi') |
---|
516 | if exist([filebase '.xml'],'file') |
---|
517 | ext_imadoc='.xml'; |
---|
518 | elseif exist([filebase '.civxml'],'file') |
---|
519 | ext_imadoc='.civxml'; |
---|
520 | elseif exist([filebase '.civ'],'file') |
---|
521 | ext_imadoc='.civ'; |
---|
522 | elseif exist([filebase '.avi'],'file') |
---|
523 | ext_imadoc='.avi'; |
---|
524 | elseif exist([filebase '.AVI'],'file') |
---|
525 | ext_imadoc='.AVI'; |
---|
526 | end |
---|
527 | set(handles.ImaDoc,'String',ext_imadoc) |
---|
528 | end |
---|
529 | |
---|
530 | %%%%%%%% read image documentation file %%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
531 | mode=''; %default |
---|
532 | set(handles.ImaDoc,'BackgroundColor',[1 1 0]) |
---|
533 | drawnow |
---|
534 | if isequal(ext_imadoc,'.civxml') || isequal(ext_imadoc,'.xml')|| isequal(ext_imadoc,'.civ') |
---|
535 | set(handles.ref_i,'Visible','On')%use a reference index |
---|
536 | set(handles.ref_j,'Visible','On') |
---|
537 | elseif isequal(ext_imadoc,'.avi') || isequal(ext_imadoc,'.AVI') |
---|
538 | set(handles.ref_j,'Visible','Off') |
---|
539 | else |
---|
540 | set(handles.ref_i,'Visible','Off') |
---|
541 | set(handles.ref_j,'Visible','Off') |
---|
542 | end |
---|
543 | testima_xml=0; |
---|
544 | if isequal(ext_imadoc,'.civxml')%TO ABANDON |
---|
545 | [nbfield,nbfield2,time]=read_civxml([filebase '.civxml']); |
---|
546 | mode='pair j1-j2'; |
---|
547 | if isempty(nom_type_ima)% dtermine types by default if not already selected by browser or uvmat |
---|
548 | nom_type_ima='_i_j'; |
---|
549 | end |
---|
550 | elseif isequal(ext_imadoc,'.xml') |
---|
551 | [XmlData,warntext]=imadoc2struct([filebase '.xml']); |
---|
552 | ext_ima_read=[]; |
---|
553 | nom_type_read=[]; |
---|
554 | if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')&&ischar(XmlData.Heading.ImageName)% get image nom type and extension from the xml file |
---|
555 | [PP,FF,fc,str2,str_a,str_b,ext_ima_read,nom_type_read]=name2display(XmlData.Heading.ImageName); |
---|
556 | fullname=fullfile(fileparts(filebase),XmlData.Heading.ImageName); %full name (including path) of the first image defined by the xmle file, |
---|
557 | if ~exist(fullname,'file') |
---|
558 | msgbox_uvmat('WARNING',['FirstImage ' fullname ' defined in the xml file does not exist']) |
---|
559 | end |
---|
560 | end |
---|
561 | if isfield(XmlData,'Time') |
---|
562 | time=XmlData.Time; |
---|
563 | nbfield=size(time,1); |
---|
564 | nbfield2=size(time,2); |
---|
565 | %transform .Time to a column vector if it is a line vector thenomenclature uses a single index: correct possible bug in xml |
---|
566 | if isequal(nbfield,1) && ~isequal(nbfield2,1)% .Time is a line vector |
---|
567 | if numel(nom_type_read)>=2 && isempty(regexp(nom_type_read(2:end),'\D')) |
---|
568 | time=time'; |
---|
569 | nbfield=nbfield2; |
---|
570 | nbfield2=1; |
---|
571 | end |
---|
572 | end |
---|
573 | end |
---|
574 | if isfield(XmlData,'TimeUnit') |
---|
575 | TimeUnit=XmlData.TimeUnit; |
---|
576 | end |
---|
577 | if isfield(XmlData,'Npx') |
---|
578 | npx=XmlData.Npx; |
---|
579 | npy=XmlData.Npy; |
---|
580 | end |
---|
581 | pxcmx_search=1; |
---|
582 | pxcmy_search=1; |
---|
583 | if isfield(XmlData,'GeometryCalib') |
---|
584 | tsai=XmlData.GeometryCalib; |
---|
585 | if isfield(tsai,'f') && isfield(tsai,'Tz') && isfield(tsai,'dpx') && isfield(tsai,'dpy')&& isfield(tsai,'R') |
---|
586 | rot2D=tsai.R(1:2,[1,2]); |
---|
587 | pxcmx_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpx); |
---|
588 | pxcmy_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpy); |
---|
589 | end |
---|
590 | if isfield(tsai,'CoordUnit') |
---|
591 | CoordUnit=tsai.CoordUnit; |
---|
592 | end |
---|
593 | end |
---|
594 | elseif strcmp(ext_imadoc,'.civ')% case of .civ image documentation file |
---|
595 | [error,time,TimeUnit,mode,npx,npy]=read_imatext([filebase '.civ']); |
---|
596 | if error==2, msgbox_uvmat('WARNING',['no file ' filebase '.civ']); |
---|
597 | elseif error==1, msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file'); |
---|
598 | end |
---|
599 | nom_type_ima='001a'; |
---|
600 | elseif strcmpi(ext_imadoc,'.avi') |
---|
601 | nom_type_ima='*'; |
---|
602 | ext_ima=ext_imadoc; |
---|
603 | set(handles.mode,'Value',1); |
---|
604 | set(handles.mode,'String',{'series(Di)'}) |
---|
605 | dt=0.04;%default |
---|
606 | if exist([filebase ext_imadoc],'file')==2 |
---|
607 | info=aviinfo([filebase ext_imadoc]);%read infos on the avi movie |
---|
608 | dt=1/info.FramesPerSecond;%time interval between successive frames |
---|
609 | nbfield=info.NumFrames;%number of frames |
---|
610 | end |
---|
611 | time=(dt*(0:nbfield-1))';%list of image times |
---|
612 | end |
---|
613 | if isempty(time) |
---|
614 | set(handles.ImaDoc,'String',''); %xml file not used for timing |
---|
615 | end |
---|
616 | set(handles.ImaDoc,'BackgroundColor',[1 1 1]) |
---|
617 | |
---|
618 | %get the imabe nomenclature type if not defined by the input file nor by the xml file |
---|
619 | dirima=[];%default |
---|
620 | if isempty(nom_type_ima) |
---|
621 | %look for double image series '_i_j' |
---|
622 | dirima=dir([filebase '_' num2str(first_i) '_' num2str(first_j) '.*']); |
---|
623 | if isempty(dirima) |
---|
624 | % look for images series with sub marker '_' |
---|
625 | dirima=dir([filebase '_*' num2str(first_i) '.*']); |
---|
626 | if isempty(dirima) |
---|
627 | % look for other images series |
---|
628 | dirima=dir([filebase '*' num2str(first_i) '.*']); |
---|
629 | if isempty(dirima) |
---|
630 | % look for other images series witth letter appendix |
---|
631 | appendix=char(96+first_j); |
---|
632 | dirima=dir([filebase '*' num2str(first_i) appendix '.*']); |
---|
633 | end |
---|
634 | end |
---|
635 | end |
---|
636 | end |
---|
637 | for ilist=1:numel(dirima) |
---|
638 | [pp,ff,fc,str2,str_a,str_b,ext_list,nom_type_list]=name2display(dirima(ilist).name); |
---|
639 | form=imformats(ext_list(2:end)); |
---|
640 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
641 | ext_ima=ext_list; |
---|
642 | nom_type_ima=nom_type_list; |
---|
643 | break |
---|
644 | end |
---|
645 | end |
---|
646 | % no image documentation file found: look for a series of existing files,images by priority or .nc files |
---|
647 | if isempty(nom_type_ima) |
---|
648 | ext_search=ext_imadoc; |
---|
649 | nom_type_search=nom_type_nc; |
---|
650 | else |
---|
651 | ext_search=ext_ima; |
---|
652 | nom_type_search=nom_type_ima; |
---|
653 | end |
---|
654 | if isempty(time) && ~strcmp(nom_type_search,'none') && ~strcmp(nom_type_search,'') && ~strcmp(nom_type_search,'*') |
---|
655 | subdir=get(handles.subdir_civ1,'String'); |
---|
656 | incr_pair=[0 0];%default |
---|
657 | if isfield(browse,'incr_pair') |
---|
658 | incr_pair=browse.incr_pair; |
---|
659 | end |
---|
660 | % nbdetect=0;%test of detected images |
---|
661 | field_i=browse.num_i2; |
---|
662 | imagename=name_generator(filebase,field_i,1,ext_search,nom_type_search); |
---|
663 | imagename_plus=''; |
---|
664 | idetect=1; |
---|
665 | while idetect %look for the maximum file number in the series |
---|
666 | imagename_plus=name_generator(filebase,field_i+1,1,ext_search,nom_type_search); |
---|
667 | idetect=(exist(imagename_plus,'file')==2)&& ~strcmp(imagename,imagename_plus); |
---|
668 | if idetect |
---|
669 | field_i=field_i+1; |
---|
670 | end |
---|
671 | %SEE CASE OF NETCDF FILES |
---|
672 | % nbdetect=nbdetect+(exist(imagename,'file')==2); |
---|
673 | end |
---|
674 | nbfield=field_i;% last detected field number |
---|
675 | field_i=browse.num_i1;%look for the minimum file number in the series |
---|
676 | imagename_min=''; |
---|
677 | idetect=1; |
---|
678 | while idetect==1 |
---|
679 | imagename_min=name_generator(filebase,field_i-1,1,ext_search,nom_type_search); |
---|
680 | idetect=(exist(imagename_min,'file')==2)&& ~strcmp(imagename,imagename_min); |
---|
681 | if idetect |
---|
682 | field_i=field_i-1; |
---|
683 | end |
---|
684 | end |
---|
685 | first_i=max(field_i,1); |
---|
686 | if numel(regexp(nom_type_search,'\D'))>=1%two indices i and j |
---|
687 | field_i=browse.num_i1; |
---|
688 | field_j=browse.num_j2; |
---|
689 | imagename=name_generator(filebase,field_i,field_j,ext_search,nom_type_search); |
---|
690 | imagename_plus=''; |
---|
691 | jdetect=1; |
---|
692 | while jdetect==1 %look for the maximum file number in the series |
---|
693 | imagename_plus=name_generator(filebase,field_i,field_j+1,ext_search,nom_type_search); |
---|
694 | jdetect=(exist(imagename_plus,'file')==2)&& ~strcmp(imagename,imagename_plus); |
---|
695 | if jdetect |
---|
696 | field_j=field_j+1; |
---|
697 | end |
---|
698 | %SEE CASE OF NETCDF FILES |
---|
699 | % nbdetect=nbdetect+(exist(imagename,'file')==2); |
---|
700 | end |
---|
701 | nbfield2=field_j;% last detected field number |
---|
702 | end |
---|
703 | |
---|
704 | %determine the set of times and possible intervals for CIV |
---|
705 | % dt=(1/1000)*str2double(get(handles.dt,'String')); |
---|
706 | time=(0:nbfield-1)';% time=file index -1 by default |
---|
707 | if numel(regexp(nom_type_search,'\D'))>=1%two indices i and j |
---|
708 | [x,y]=meshgrid(0:nbfield2-1,0:nbfield-1); |
---|
709 | time=x+y; |
---|
710 | end |
---|
711 | end |
---|
712 | |
---|
713 | if exist('time','var') |
---|
714 | if size(time,1)+size(time,2)>=3 % if there are at least two time values to define dt |
---|
715 | nbfield=size(time,1); |
---|
716 | nbfield2=size(time,2); |
---|
717 | set(handles.RootName,'UserData',time); %store the set of times |
---|
718 | set(handles.dt_unit,'String',['dt in m' TimeUnit]); |
---|
719 | set(handles.dt_unit_civ2,'String',['dt in m' TimeUnit]); |
---|
720 | set(handles.TimeUnit,'String',TimeUnit); |
---|
721 | set(handles.nb_field,'String',num2str(nbfield)); |
---|
722 | set(handles.nb_field2,'String',num2str(nbfield2)); |
---|
723 | end |
---|
724 | end |
---|
725 | set(handles.CoordUnit,'String',CoordUnit) |
---|
726 | set(handles.calcul_search,'UserData',[pxcmx_search pxcmy_search]); |
---|
727 | % npxy=[npy npx]; |
---|
728 | set(handles.ImaExt,'String',ext_ima) |
---|
729 | set(handles.first_i,'String',num2str(first_i)); |
---|
730 | set(handles.last_i,'String',num2str(last_i));% |
---|
731 | set(handles.first_j,'String',num2str(first_j)); |
---|
732 | set(handles.last_j,'String',num2str(last_j));% |
---|
733 | browse.nom_type_ima=nom_type_ima; |
---|
734 | set(handles.browse_root,'UserData',browse)% store the nomenclature type |
---|
735 | |
---|
736 | %%%%%%%%%%% set the menus of image pairs and default selection for civ %%%%%%%%%%%%%%%%%%% |
---|
737 | test_ima_i=numel(nom_type_ima)>1 && isempty(regexp(nom_type_ima(2:end),'\D','once'));%images with single indexing |
---|
738 | if test_ima_i || isequal(nom_type_nc,'_i1-i2')||~(exist('nbfield2','var')&&(nbfield2~=1)) |
---|
739 | set(handles.mode,'Value',1) |
---|
740 | set(handles.mode,'String',{'series(Di)'}) |
---|
741 | elseif (nbfield==1)% simple series in j |
---|
742 | set(handles.mode,'Value',1) |
---|
743 | set(handles.mode,'String',{'series(Dj)'}) |
---|
744 | else |
---|
745 | set(handles.mode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice |
---|
746 | if nbfield2 <= 10 |
---|
747 | set(handles.mode,'Value',1)% advice 'pair j1-j2' for small burst |
---|
748 | end |
---|
749 | end |
---|
750 | |
---|
751 | %update the subdir |
---|
752 | pathdir=fileparts(filebase);%path to the current xml file |
---|
753 | listot=dir(pathdir); |
---|
754 | idir=0; |
---|
755 | listdir={''};%default |
---|
756 | for ilist=1:length(listot) |
---|
757 | if listot(ilist).isdir |
---|
758 | name=listot(ilist).name; |
---|
759 | if ~isequal(name,'.') && ~isequal(name,'..') |
---|
760 | idir=idir+1; |
---|
761 | listdir{idir,1}=listot(ilist).name; |
---|
762 | end |
---|
763 | end |
---|
764 | end |
---|
765 | set(handles.list_subdir_civ1,'Value',1) |
---|
766 | set(handles.list_subdir_civ2,'Value',1) |
---|
767 | set(handles.list_subdir_civ1,'String',[{'browse...'};listdir]) |
---|
768 | set(handles.list_subdir_civ2,'String',[{'browse...'};listdir]) |
---|
769 | %check wether the current subdir exists: |
---|
770 | subdir_civ1=get(handles.subdir_civ1,'String'); |
---|
771 | subdir_civ2=get(handles.subdir_civ2,'String'); |
---|
772 | |
---|
773 | mode_Callback(hObject, eventdata, handles) |
---|
774 | |
---|
775 | %% desable status and RUN button |
---|
776 | % set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001]) |
---|
777 | % set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001]) |
---|
778 | % set(handles.waitbar_civ2,'Position',[0.946 0.219 0.03 0.001]) |
---|
779 | % set(handles.waitbar_patch2,'Position',[0.946 0.0 0.03 0.001]) |
---|
780 | set(handles.RUN, 'Enable','On') |
---|
781 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
782 | set(handles.BATCH,'Enable','On') |
---|
783 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
784 | if isfield(handles,'status') |
---|
785 | set(handles.status,'Value',0);%suppress status display |
---|
786 | status_Callback(hObject, eventdata, handles) |
---|
787 | end |
---|
788 | |
---|
789 | %% store the root input filename for future opening |
---|
790 | dir_perso=prefdir; |
---|
791 | profil_perso=fullfile(prefdir,'uvmat_perso.mat'); |
---|
792 | RootPath=fileparts(filebase); |
---|
793 | if exist(profil_perso,'file') |
---|
794 | save (profil_perso,'RootPath','-append'); %store the root name for future opening of uvmat |
---|
795 | else |
---|
796 | txt=ver('MATLAB'); |
---|
797 | Release=txt.Release; |
---|
798 | relnumb=str2double(Release(3:4)); |
---|
799 | if relnumb >= 14 |
---|
800 | save (profil_perso,'RootPath','-V6'); %store the root name for future opening of uvmat |
---|
801 | else |
---|
802 | save (profil_perso,'RootPath'); %store the root name for future opening of uvmat |
---|
803 | end |
---|
804 | end |
---|
805 | |
---|
806 | %------------------------------------------------------------------------ |
---|
807 | % --- Executes on button press in mode. |
---|
808 | function mode_Callback(hObject, eventdata, handles) |
---|
809 | %------------------------------------------------------------------------ |
---|
810 | browse=get(handles.browse_root,'UserData'); |
---|
811 | compare_list=get(handles.compare,'String'); |
---|
812 | val=get(handles.compare,'Value'); |
---|
813 | compare=compare_list{val}; |
---|
814 | if strcmp(compare,'displacement') |
---|
815 | mode='displacement'; |
---|
816 | else |
---|
817 | mode_list=get(handles.mode,'String'); |
---|
818 | if ischar(mode_list) |
---|
819 | mode_list={mode_list}; |
---|
820 | end |
---|
821 | mode_value=get(handles.mode,'Value'); |
---|
822 | mode=mode_list{mode_value}; |
---|
823 | end |
---|
824 | displ_num=[];%default |
---|
825 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
826 | % last_i=str2num(get(handles.last_i,'String')); |
---|
827 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
828 | siztime=size(time); |
---|
829 | nbfield=siztime(1); |
---|
830 | nbfield2=siztime(2); |
---|
831 | indchosen=1; %%first pair selected by default |
---|
832 | if isequal(mode,'pair j1-j2')%| isequal(mode,'st_pair j1-j2') |
---|
833 | dt=1; |
---|
834 | displ=''; |
---|
835 | index=0; |
---|
836 | numlist_a=[]; |
---|
837 | numlist_B=[]; |
---|
838 | %get all the time intervals in bursts |
---|
839 | displ_dt=1;%default |
---|
840 | nbfield2=min(nbfield2,10);%limitate the number of pairs to 10x10 |
---|
841 | for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'pair j1-j2' mode |
---|
842 | for numod_b=(numod_a+1):nbfield2 |
---|
843 | index=index+1; |
---|
844 | numlist_a(index)=numod_a; |
---|
845 | numlist_b(index)=numod_b; |
---|
846 | if ~isempty(time) |
---|
847 | dt(numod_a,numod_b)=time(ref_i,numod_b)-time(ref_i,numod_a);%first time interval dt |
---|
848 | displ_dt(index)=dt(numod_a,numod_b); |
---|
849 | else |
---|
850 | displ_dt(index)=1; |
---|
851 | end |
---|
852 | end |
---|
853 | end |
---|
854 | [dtsort,indsort]=sort(displ_dt); |
---|
855 | if ~isempty(numlist_a) |
---|
856 | displ_num(1,:)=numlist_a(indsort); |
---|
857 | displ_num(2,:)=numlist_b(indsort); |
---|
858 | end |
---|
859 | displ_num(3,:)=0; |
---|
860 | displ_num(4,:)=0; |
---|
861 | set(handles.jtext,'Visible','Off') |
---|
862 | set(handles.first_j,'Visible','Off') |
---|
863 | set(handles.last_j,'Visible','Off') |
---|
864 | set(handles.incr_j,'Visible','Off') |
---|
865 | set(handles.nb_field2,'Visible','Off') |
---|
866 | set(handles.ref_j,'Visible','Off') |
---|
867 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') |
---|
868 | for index=1:min(nbfield2-1,200) |
---|
869 | displ_num(1,index)=-floor(index/2); |
---|
870 | displ_num(2,index)=ceil(index/2); |
---|
871 | displ_num(3,index)=0; |
---|
872 | displ_num(4,index)=0; |
---|
873 | end |
---|
874 | set(handles.jtext,'Visible','On') |
---|
875 | set(handles.first_j,'Visible','On') |
---|
876 | set(handles.last_j,'Visible','On') |
---|
877 | set(handles.incr_j,'Visible','On') |
---|
878 | set(handles.nb_field2,'Visible','On') |
---|
879 | set(handles.ref_j,'Visible','On') |
---|
880 | if nbfield > 1 |
---|
881 | set(handles.itext,'Visible','On') |
---|
882 | set(handles.first_i,'Visible','On') |
---|
883 | set(handles.last_i,'Visible','On') |
---|
884 | set(handles.incr_i,'Visible','On') |
---|
885 | set(handles.nb_field,'Visible','On') |
---|
886 | set(handles.ref_i,'Visible','On') |
---|
887 | else |
---|
888 | set(handles.itext,'Visible','Off') |
---|
889 | set(handles.first_i,'Visible','Off') |
---|
890 | set(handles.last_i,'Visible','Off') |
---|
891 | set(handles.incr_i,'Visible','Off') |
---|
892 | set(handles.nb_field,'Visible','Off') |
---|
893 | set(handles.ref_i,'Visible','Off') |
---|
894 | end |
---|
895 | elseif isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
896 | for index=1:200%min(nbfield-1,200) |
---|
897 | displ_num(1,index)=0; |
---|
898 | displ_num(2,index)=0; |
---|
899 | displ_num(3,index)=-floor(index/2); |
---|
900 | displ_num(4,index)=ceil(index/2); |
---|
901 | end |
---|
902 | set(handles.itext,'Visible','On') |
---|
903 | set(handles.first_i,'Visible','On') |
---|
904 | set(handles.last_i,'Visible','On') |
---|
905 | set(handles.incr_i,'Visible','On') |
---|
906 | set(handles.nb_field,'Visible','On') |
---|
907 | set(handles.ref_i,'Visible','On') |
---|
908 | if nbfield2 > 1 |
---|
909 | set(handles.jtext,'Visible','On') |
---|
910 | set(handles.first_j,'Visible','On') |
---|
911 | set(handles.last_j,'Visible','On') |
---|
912 | set(handles.incr_j,'Visible','On') |
---|
913 | set(handles.nb_field2,'Visible','On') |
---|
914 | set(handles.ref_j,'Visible','On') |
---|
915 | else |
---|
916 | set(handles.jtext,'Visible','Off') |
---|
917 | set(handles.first_j,'Visible','Off') |
---|
918 | set(handles.last_j,'Visible','Off') |
---|
919 | set(handles.incr_j,'Visible','Off') |
---|
920 | set(handles.nb_field2,'Visible','Off') |
---|
921 | set(handles.ref_j,'Visible','Off') |
---|
922 | end |
---|
923 | elseif isequal(mode,'displacement')%the pairs have the same indices |
---|
924 | displ_num(1,1)=0; |
---|
925 | displ_num(2,1)=0; |
---|
926 | displ_num(3,1)=0; |
---|
927 | displ_num(4,1)=0; |
---|
928 | if nbfield > 1 |
---|
929 | set(handles.itext,'Visible','On') |
---|
930 | set(handles.first_i,'Visible','On') |
---|
931 | set(handles.last_i,'Visible','On') |
---|
932 | set(handles.incr_i,'Visible','On') |
---|
933 | set(handles.nb_field,'Visible','On') |
---|
934 | set(handles.ref_i,'Visible','On') |
---|
935 | else |
---|
936 | set(handles.itext,'Visible','Off') |
---|
937 | set(handles.first_i,'Visible','Off') |
---|
938 | set(handles.last_i,'Visible','Off') |
---|
939 | set(handles.incr_i,'Visible','Off') |
---|
940 | set(handles.nb_field,'Visible','Off') |
---|
941 | set(handles.ref_i,'Visible','Off') |
---|
942 | end |
---|
943 | if nbfield2 > 1 |
---|
944 | set(handles.jtext,'Visible','On') |
---|
945 | set(handles.first_j,'Visible','On') |
---|
946 | set(handles.last_j,'Visible','On') |
---|
947 | set(handles.incr_j,'Visible','On') |
---|
948 | set(handles.nb_field2,'Visible','On') |
---|
949 | set(handles.ref_j,'Visible','On') |
---|
950 | else |
---|
951 | set(handles.jtext,'Visible','Off') |
---|
952 | set(handles.first_j,'Visible','Off') |
---|
953 | set(handles.last_j,'Visible','Off') |
---|
954 | set(handles.incr_j,'Visible','Off') |
---|
955 | set(handles.nb_field2,'Visible','Off') |
---|
956 | set(handles.ref_j,'Visible','Off') |
---|
957 | end |
---|
958 | end |
---|
959 | set(handles.list_pair_civ1,'UserData',displ_num); |
---|
960 | find_netcpair_civ1(hObject, eventdata, handles) |
---|
961 | find_netcpair_civ2(hObject, eventdata, handles) |
---|
962 | |
---|
963 | %------------------------------------------------------------------------ |
---|
964 | % determine the menu for civ1 pairs depending on existing netcdf file at the middle of |
---|
965 | % the field series set by first_i, incr, last_i |
---|
966 | function find_netcpair_civ1(hObject, eventdata, handles) |
---|
967 | %------------------------------------------------------------------------ |
---|
968 | set(gcf,'Pointer','watch') |
---|
969 | %nomenclature types |
---|
970 | filebase=get(handles.RootName,'String'); |
---|
971 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
972 | browse=get(handles.browse_root,'UserData'); |
---|
973 | compare_list=get(handles.compare,'String'); |
---|
974 | val=get(handles.compare,'Value'); |
---|
975 | compare=compare_list{val}; |
---|
976 | if strcmp(compare,'displacement') |
---|
977 | mode='displacement'; |
---|
978 | else |
---|
979 | mode_list=get(handles.mode,'String'); |
---|
980 | mode_value=get(handles.mode,'Value'); |
---|
981 | mode=mode_list{mode_value}; |
---|
982 | end |
---|
983 | |
---|
984 | % nomenclature type of the .nc files |
---|
985 | nom_type_ima=[];%default |
---|
986 | if isfield(browse,'nom_type_ima') |
---|
987 | nom_type_ima=browse.nom_type_ima; |
---|
988 | end |
---|
989 | |
---|
990 | %determine nom_type_nc: |
---|
991 | nom_type_nc=[];%default |
---|
992 | if isfield(browse,'nom_type_nc') |
---|
993 | nom_type_nc=browse.nom_type_nc; |
---|
994 | end |
---|
995 | if isempty(nom_type_nc) |
---|
996 | [nom_type_nc]=nomtype2pair(nom_type_ima,isequal(mode,'series(Di)'),isequal(mode,'series(Dj)')); |
---|
997 | end |
---|
998 | browse.nom_type_nc=nom_type_nc; |
---|
999 | set(handles.browse_root,'UserData',browse) |
---|
1000 | |
---|
1001 | %reads .nc subdirectoy and image numbers from the interface |
---|
1002 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
1003 | % first_i=str2num(get(handles.first_i,'String')); |
---|
1004 | % last_i=str2num(get(handles.last_i,'String')); |
---|
1005 | % incr=str2num(get(handles.incr_i,'String')); |
---|
1006 | % num1=first_i:incr:last_i; |
---|
1007 | % if isempty(num1) |
---|
1008 | % set(handles.list_pair_civ1,'String',{''}); |
---|
1009 | % return |
---|
1010 | % end |
---|
1011 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
1012 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
1013 | ref_j=0; |
---|
1014 | else |
---|
1015 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
1016 | end |
---|
1017 | time=get(handles.RootName,'UserData');%get the set of times |
---|
1018 | if isempty(time) |
---|
1019 | time=[0 1]; |
---|
1020 | end |
---|
1021 | %dt_unit=str2double(get(handles.dt,'String'));% used when there is no image documentation file |
---|
1022 | dt_unit=1000;%default |
---|
1023 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
1024 | |
---|
1025 | %eliminate the first pairs inconsistent with the position |
---|
1026 | if isempty(displ_num) |
---|
1027 | nbpair=0; |
---|
1028 | else |
---|
1029 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
1030 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
1031 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
1032 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
1033 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
1034 | end |
---|
1035 | end |
---|
1036 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
1037 | |
---|
1038 | %look for existing processed pairs involving the field at the middle of the series if civ1 will not |
---|
1039 | % be performed, while the result is needed for next steps. |
---|
1040 | displ_pair={''}; |
---|
1041 | select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs |
---|
1042 | testpair=0; |
---|
1043 | if get(handles.CIV1,'Value')==0 % |
---|
1044 | if ~exist(fullfile(filepath,subdir_civ1,ext_dir),'dir') |
---|
1045 | msgbox_uvmat('ERROR',['no civ1 file available: subdirectory ' subdir_civ1 ' does not exist']); |
---|
1046 | set(handles.list_pair_civ1,'String',{}); |
---|
1047 | return |
---|
1048 | end |
---|
1049 | for ipair=1:nbpair |
---|
1050 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
1051 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
1052 | select(ipair)=exist(filename,'file')==2; |
---|
1053 | end |
---|
1054 | if ~exist('select','var') || isequal(select,zeros(size(1:nbpair))) |
---|
1055 | if isfield(browse,'incr_pair') |
---|
1056 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
1057 | num_i2=ref_i+ceil(browse.incr_pair(1)/2); |
---|
1058 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
1059 | num_j2=ref_j+ceil(browse.incr_pair(2)/2); |
---|
1060 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ1); |
---|
1061 | select(1)=exist(filename,'file')==2; |
---|
1062 | testpair=1; |
---|
1063 | else |
---|
1064 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
1065 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1]); |
---|
1066 | else |
---|
1067 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ1]); |
---|
1068 | end |
---|
1069 | set(handles.list_pair_civ1,'String',{''}); |
---|
1070 | %COMPLETER CAS STEREO |
---|
1071 | return |
---|
1072 | end |
---|
1073 | end |
---|
1074 | end |
---|
1075 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
1076 | if testpair |
---|
1077 | displ_pair{1}=['Di= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
1078 | % elseif ~isequal(get(handles.root_txt,'String'),'dt(ms)=') |
---|
1079 | % for ipair=1:nbpair |
---|
1080 | % if select(ipair) |
---|
1081 | % if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
1082 | % dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));%time interval dt |
---|
1083 | % displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
1084 | % end |
---|
1085 | % else |
---|
1086 | % displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
1087 | % end |
---|
1088 | % end |
---|
1089 | else |
---|
1090 | for ipair=1:nbpair |
---|
1091 | if select(ipair) |
---|
1092 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
1093 | dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));%time interval dt |
---|
1094 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
1095 | else |
---|
1096 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
1097 | end |
---|
1098 | end |
---|
1099 | end |
---|
1100 | end |
---|
1101 | elseif isequal(mode,'series(Dj)')%|isequal(mode,'st_series(Dj)')% series on the j index |
---|
1102 | if testpair |
---|
1103 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
1104 | else |
---|
1105 | for ipair=1:nbpair |
---|
1106 | if select(ipair) |
---|
1107 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
1108 | dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));%time interval dt |
---|
1109 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
1110 | end |
---|
1111 | elseif testpair |
---|
1112 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(2)/2)) '|' num2str(ceil(browse.incr_pair(2)/2))]; |
---|
1113 | else |
---|
1114 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
1115 | end |
---|
1116 | end |
---|
1117 | end |
---|
1118 | elseif isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2')%case of pairs |
---|
1119 | for ipair=1:nbpair |
---|
1120 | if select(ipair) |
---|
1121 | dt=time(ref_i+displ_num(4,ipair),displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),displ_num(1,ipair));%time interval dt |
---|
1122 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
1123 | ' :dt= ' num2str(dt*1000)]; |
---|
1124 | else |
---|
1125 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
1126 | end |
---|
1127 | end |
---|
1128 | elseif isequal(mode,'displacement') |
---|
1129 | displ_pair={'Di=Dj=0'}; |
---|
1130 | end |
---|
1131 | set(handles.list_pair_civ1,'String',displ_pair'); |
---|
1132 | ichoice=find(select,1); |
---|
1133 | if (isempty(ichoice) || ichoice < 1); ichoice=1; end; |
---|
1134 | initial=get(handles.list_pair_civ1,'Value');%initial choice of pair |
---|
1135 | if initial>nbpair |
---|
1136 | set(handles.list_pair_civ1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
1137 | end |
---|
1138 | if numel(select)>=initial && ~isequal(select(initial),1) |
---|
1139 | set(handles.list_pair_civ1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
1140 | end |
---|
1141 | |
---|
1142 | %set(handles.list_pair_civ2,'String',displ_pair'); |
---|
1143 | initial=get(handles.list_pair_civ2,'Value'); |
---|
1144 | if initial>length(displ_pair')%|~isequal(select(initial),1) |
---|
1145 | if ichoice <= length(displ_pair') |
---|
1146 | set(handles.list_pair_civ2,'Value',ichoice);% same pair proposed by default for civ2 |
---|
1147 | else |
---|
1148 | set(handles.list_pair_civ2,'Value',1);% same pair proposed by default for civ2 |
---|
1149 | end |
---|
1150 | end |
---|
1151 | set(handles.list_pair_civ2,'String',displ_pair'); |
---|
1152 | set(gcf,'Pointer','arrow') |
---|
1153 | |
---|
1154 | %------------------------------------------------------------------------ |
---|
1155 | % determine the menu for civ2 pairs depending on the existing netcdf file at the |
---|
1156 | %middle of the series set by first_i, incr, last_i |
---|
1157 | function find_netcpair_civ2(hObject, eventdata, handles) |
---|
1158 | %------------------------------------------------------------------------ |
---|
1159 | set(gcf,'Pointer','watch') |
---|
1160 | %nomenclature types |
---|
1161 | filebase=get(handles.RootName,'String'); |
---|
1162 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
1163 | browse=get(handles.browse_root,'UserData'); |
---|
1164 | compare_list=get(handles.compare,'String'); |
---|
1165 | val=get(handles.compare,'Value'); |
---|
1166 | compare=compare_list{val}; |
---|
1167 | if strcmp(compare,'displacement') |
---|
1168 | mode='displacement'; |
---|
1169 | else |
---|
1170 | mode_list=get(handles.mode,'String') |
---|
1171 | mode_value=get(handles.mode,'Value') |
---|
1172 | mode=mode_list{mode_value}; |
---|
1173 | end |
---|
1174 | |
---|
1175 | % nomenclature type of the .nc files |
---|
1176 | nom_type_ima='ima_num';%default |
---|
1177 | if isfield(browse,'nom_type_ima') |
---|
1178 | nom_type_ima=browse.nom_type_ima; |
---|
1179 | end |
---|
1180 | nom_type_nc='_i1-i2';%default |
---|
1181 | if isfield(browse,'nom_type_nc') |
---|
1182 | nom_type_nc=browse.nom_type_nc; |
---|
1183 | end |
---|
1184 | if isequal(nom_type_ima,'png_old') || isequal(nom_type_ima,'netc_old')|| isequal(nom_type_ima,'raw_SMD')|| isequal(nom_type_nc,'netc_old') |
---|
1185 | nom_type_nc='netc_old';%nom_type for the netcdf files |
---|
1186 | elseif isequal(nom_type_ima,'none')||isequal(nom_type_nc,'none') |
---|
1187 | nom_type_nc='none'; |
---|
1188 | elseif isequal(nom_type_ima,'avi')||isequal(nom_type_ima,'_i')||isequal(nom_type_ima,'ima_num')||isequal(nom_type_nc,'_i1-i2') |
---|
1189 | nom_type_nc='_i1-i2'; |
---|
1190 | else |
---|
1191 | if isequal(mode,'series(Di)')%|isequal(mode,'st_series(Di)') |
---|
1192 | nom_type_nc='_i1-i2_j'; % PIV in volume |
---|
1193 | else |
---|
1194 | nom_type_nc='_i_j1-j2'; |
---|
1195 | end |
---|
1196 | end |
---|
1197 | browse.nom_type_nc=nom_type_nc; |
---|
1198 | set(handles.browse_root,'UserData',browse) |
---|
1199 | |
---|
1200 | %reads .nc subdirectory and image numbers from the interface |
---|
1201 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
1202 | subdir_civ2=get(handles.subdir_civ2,'String');%subdirectory subdir_civ2 for the netcdf data |
---|
1203 | % first_i=str2num(get(handles.first_i,'String')); |
---|
1204 | % last_i=str2num(get(handles.last_i,'String')); |
---|
1205 | % incr=str2num(get(handles.incr_i,'String')); |
---|
1206 | % num1=first_i:incr:last_i; |
---|
1207 | % if isempty(num1) |
---|
1208 | % set(handles.list_pair_civ2,'Value',1); |
---|
1209 | % set(handles.list_pair_civ2,'String',{''}); |
---|
1210 | % return |
---|
1211 | % end |
---|
1212 | ref_i=str2double(get(handles.ref_i_civ2,'String')); |
---|
1213 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
1214 | ref_j=0; |
---|
1215 | else |
---|
1216 | ref_j=str2double(get(handles.ref_j_civ2,'String')); |
---|
1217 | end |
---|
1218 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
1219 | if isempty(time) |
---|
1220 | time=[0 1];%default |
---|
1221 | end |
---|
1222 | %dt_unit=str2num(get(handles.dt,'String'));% used when there is no image documentation file |
---|
1223 | %dt_unit=1000; |
---|
1224 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
1225 | |
---|
1226 | |
---|
1227 | %eliminate the first pairs inconsistent with the position |
---|
1228 | if isempty(displ_num) |
---|
1229 | nbpair=0; |
---|
1230 | else |
---|
1231 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
1232 | if isequal(mode,'series(Di)')% | isequal(mode,'st_series(Di)') |
---|
1233 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
1234 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
1235 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
1236 | end |
---|
1237 | end |
---|
1238 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
1239 | |
---|
1240 | %look for existing processed pairs involving the field at the middle of the series if civ1 will not |
---|
1241 | % be performed, while the result is needed for next steps. |
---|
1242 | displ_pair={''}; %default |
---|
1243 | select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs |
---|
1244 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0%&... |
---|
1245 | if ~exist(fullfile(filepath,subdir_civ2,ext_dir),'dir') |
---|
1246 | errordlg(['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist']) |
---|
1247 | set(handles.list_pair_civ2,'Value',1); |
---|
1248 | set(handles.list_pair_civ2,'String',{''}); |
---|
1249 | return |
---|
1250 | end |
---|
1251 | for ipair=1:nbpair |
---|
1252 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
1253 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
1254 | select(ipair)=exist(filename,'file')==2; |
---|
1255 | end |
---|
1256 | if isequal(select,zeros(size(1:nbpair))) |
---|
1257 | if isfield(browse,'incr_pair') |
---|
1258 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
1259 | num_i2=ref_i+floor((browse.incr_pair(1)+1)/2); |
---|
1260 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
1261 | num_j2=ref_j+floor((browse.incr_pair(2)+1)/2); |
---|
1262 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ2); |
---|
1263 | select(1)=exist(filename,'file')==2; |
---|
1264 | else |
---|
1265 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
1266 | errordlg(['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2]) |
---|
1267 | else |
---|
1268 | errordlg(['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2]) |
---|
1269 | end |
---|
1270 | set(handles.list_pair_civ2,'Value',1); |
---|
1271 | set(handles.list_pair_civ2,'String',{''}); |
---|
1272 | return |
---|
1273 | end |
---|
1274 | end |
---|
1275 | end |
---|
1276 | if isequal(mode,'series(Di)') % | isequal(mode,'st_series(Di)') |
---|
1277 | for ipair=1:nbpair |
---|
1278 | if select(ipair) |
---|
1279 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
1280 | dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));%time interval dt |
---|
1281 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
1282 | end |
---|
1283 | else |
---|
1284 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
1285 | end |
---|
1286 | end |
---|
1287 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') % series on the j index |
---|
1288 | for ipair=1:nbpair |
---|
1289 | if select(ipair) |
---|
1290 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
1291 | dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));%time interval dt |
---|
1292 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
1293 | end |
---|
1294 | else |
---|
1295 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
1296 | end |
---|
1297 | end |
---|
1298 | elseif isequal(mode,'pair j1-j2')% | isequal(mode,'st_pair j1-j2') %case of pairs |
---|
1299 | for ipair=1:nbpair |
---|
1300 | if select(ipair) |
---|
1301 | dt=time(ref_i+displ_num(4,ipair),displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),displ_num(1,ipair));%time interval dt |
---|
1302 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
1303 | ' :dt= ' num2str(dt*1000)]; |
---|
1304 | else |
---|
1305 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
1306 | end |
---|
1307 | end |
---|
1308 | elseif isequal(mode,'displacement') |
---|
1309 | displ_pair={'Di=Dj=0'}; |
---|
1310 | end |
---|
1311 | val=get(handles.list_pair_civ2,'Value'); |
---|
1312 | ichoice=find(select,1); |
---|
1313 | if (isempty(ichoice) || ichoice < 1); ichoice=1; end; |
---|
1314 | if get(handles.CIV2,'Value')==0 && get(handles.CIV1,'Value')==0 && get(handles.FIX1,'Value')==0 && get(handles.PATCH1,'Value')==0 |
---|
1315 | val=ichoice;% first valid pair proposed by default in the menu |
---|
1316 | end |
---|
1317 | if val>length(displ_pair') |
---|
1318 | set(handles.list_pair_civ2,'Value',1);% first valid pair proposed by default in the menu |
---|
1319 | else |
---|
1320 | set(handles.list_pair_civ2,'Value',val); |
---|
1321 | end |
---|
1322 | set(handles.list_pair_civ2,'String',displ_pair'); |
---|
1323 | set(gcf,'Pointer','arrow') |
---|
1324 | |
---|
1325 | |
---|
1326 | |
---|
1327 | |
---|
1328 | %------------------------------------------------------------------------ |
---|
1329 | % --- Executes on selection change in list_pair_civ1. |
---|
1330 | function list_pair_civ1_Callback(hObject, eventdata, handles) |
---|
1331 | %------------------------------------------------------------------------ |
---|
1332 | %reproduce by default the chosen pair in the civ2 menu |
---|
1333 | list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs |
---|
1334 | index_pair=get(handles.list_pair_civ1,'Value'); |
---|
1335 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
1336 | % num_a=displ_num(1,index_pair); |
---|
1337 | % num_b=displ_num(2,index_pair); |
---|
1338 | list_pair2=get(handles.list_pair_civ2,'String');%get the menu of image pairs |
---|
1339 | if index_pair<=length(list_pair2) |
---|
1340 | set(handles.list_pair_civ2,'Value',index_pair); |
---|
1341 | end |
---|
1342 | |
---|
1343 | %update first_i and last_i according to the chosen image pairs |
---|
1344 | mode_list=get(handles.mode,'String'); |
---|
1345 | mode_value=get(handles.mode,'Value'); |
---|
1346 | mode=mode_list{mode_value}; |
---|
1347 | if isequal(mode,'series(Di)') |
---|
1348 | first_i=str2double(get(handles.first_i,'String')); |
---|
1349 | last_i=str2double(get(handles.last_i,'String')); |
---|
1350 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
1351 | num1=first_i:incr_i:last_i; |
---|
1352 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
1353 | if ~isnan(lastfield) |
---|
1354 | test_find=(num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
1355 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield); |
---|
1356 | num1=num1(test_find); |
---|
1357 | end |
---|
1358 | set(handles.first_i,'String',num2str(num1(1))); |
---|
1359 | set(handles.last_i,'String',num2str(num1(end))); |
---|
1360 | elseif isequal(mode,'series(Dj)') |
---|
1361 | first_j=str2double(get(handles.first_j,'String')); |
---|
1362 | last_j=str2double(get(handles.last_j,'String')); |
---|
1363 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
1364 | num_j=first_j:incr_j:last_j; |
---|
1365 | lastfield2=str2double(get(handles.nb_field2,'String')); |
---|
1366 | if ~isnan(lastfield2) |
---|
1367 | test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
1368 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2); |
---|
1369 | num1=num_j(test_find); |
---|
1370 | end |
---|
1371 | set(handles.first_j,'String',num2str(num1(1))); |
---|
1372 | set(handles.last_j,'String',num2str(num1(end))); |
---|
1373 | end |
---|
1374 | |
---|
1375 | %------------------------------------------------------------------------ |
---|
1376 | % --- Executes on selection change in list_pair_civ2. |
---|
1377 | function list_pair_civ2_Callback(hObject, eventdata, handles) |
---|
1378 | %------------------------------------------------------------------------ |
---|
1379 | index_pair=get(handles.list_pair_civ2,'Value');%get the selected position index in the menu |
---|
1380 | |
---|
1381 | %update first_i and last_i according to the chosen image pairs |
---|
1382 | mode_list=get(handles.mode,'String'); |
---|
1383 | mode_value=get(handles.mode,'Value'); |
---|
1384 | mode=mode_list{mode_value}; |
---|
1385 | if isequal(mode,'series(Di)') |
---|
1386 | first_i=str2double(get(handles.first_i,'String')); |
---|
1387 | last_i=str2double(get(handles.last_i,'String')); |
---|
1388 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
1389 | num1=first_i:incr_i:last_i; |
---|
1390 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
1391 | if ~isnan(lastfield) |
---|
1392 | test_find=(num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
1393 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield); |
---|
1394 | num1=num1(test_find); |
---|
1395 | end |
---|
1396 | set(handles.first_i,'String',num2str(num1(1))); |
---|
1397 | set(handles.last_i,'String',num2str(num1(end))); |
---|
1398 | elseif isequal(mode,'series(Dj)') |
---|
1399 | first_j=str2double(get(handles.first_j,'String')); |
---|
1400 | last_j=str2double(get(handles.last_j,'String')); |
---|
1401 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
1402 | num_j=first_j:incr_j:last_j; |
---|
1403 | lastfield2=str2double(get(handles.nb_field2,'String')); |
---|
1404 | if ~isnan(lastfield2) |
---|
1405 | test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
1406 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2); |
---|
1407 | num1=num_j(test_find); |
---|
1408 | end |
---|
1409 | set(handles.first_j,'String',num2str(num1(1))); |
---|
1410 | set(handles.last_j,'String',num2str(num1(end))); |
---|
1411 | end |
---|
1412 | |
---|
1413 | %------------------------------------------------------------------------ |
---|
1414 | % --- Executes on button press in RUN: processing on local computer |
---|
1415 | function RUN_Callback(hObject, eventdata, handles) |
---|
1416 | %------------------------------------------------------------------------ |
---|
1417 | set(handles.RUN, 'Enable','Off') |
---|
1418 | set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) |
---|
1419 | batch=0; |
---|
1420 | errormsg=launch_jobs(hObject, eventdata, handles,batch); |
---|
1421 | set(handles.RUN, 'Enable','On') |
---|
1422 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
1423 | |
---|
1424 | % start status callback to visualise results |
---|
1425 | if ~isempty(errormsg) |
---|
1426 | display(errormsg) |
---|
1427 | msgbox_uvmat('ERROR',errormsg) |
---|
1428 | elseif isfield(handles,'status') %&& ~isequal(get(handles.CivAll,'Value'),3) |
---|
1429 | set(handles.status,'Value',1);%suppress status display |
---|
1430 | status_Callback(hObject, eventdata, handles) |
---|
1431 | end |
---|
1432 | |
---|
1433 | %------------------------------------------------------------------------ |
---|
1434 | % --- Executes on button press in BATCH: remote processing |
---|
1435 | function BATCH_Callback(hObject, eventdata, handles) |
---|
1436 | % ----------------------------------------------------------------------- |
---|
1437 | set(handles.BATCH, 'Enable','Off') |
---|
1438 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784]) |
---|
1439 | batch=1; |
---|
1440 | errormsg=launch_jobs(hObject, eventdata, handles, batch); |
---|
1441 | set(handles.BATCH, 'Enable','On') |
---|
1442 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
1443 | |
---|
1444 | % start status callback to visualise results |
---|
1445 | if ~isempty(errormsg) |
---|
1446 | display(errormsg) |
---|
1447 | msgbox_uvmat('ERROR',errormsg) |
---|
1448 | elseif isfield(handles,'status') |
---|
1449 | set(handles.status,'Value',1);%suppress status display |
---|
1450 | status_Callback(hObject, eventdata, handles) |
---|
1451 | end |
---|
1452 | |
---|
1453 | %------------------------------------------------------------------------ |
---|
1454 | % --- Lauch command called by RUN and BATCH: remote processing |
---|
1455 | function errormsg=launch_jobs(hObject, eventdata, handles, batch) |
---|
1456 | %----------------------------------------------------------------------- |
---|
1457 | errormsg='';%default |
---|
1458 | %% check the selected list of operations: |
---|
1459 | operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'}; |
---|
1460 | box_test(1)=get(handles.CIV1,'Value'); |
---|
1461 | box_test(2)=get(handles.FIX1,'Value'); |
---|
1462 | box_test(3)=get(handles.PATCH1,'Value'); |
---|
1463 | box_test(4)=get(handles.CIV2,'Value'); |
---|
1464 | box_test(5)=get(handles.FIX2,'Value'); |
---|
1465 | box_test(6)=get(handles.PATCH2,'Value'); |
---|
1466 | index_first=find(box_test==1,1); |
---|
1467 | if isempty(index_first) |
---|
1468 | errormsg='no selected operation'; |
---|
1469 | return |
---|
1470 | end |
---|
1471 | index_last=find(box_test==1,1,'last'); |
---|
1472 | box_used=box_test(index_first : index_last); |
---|
1473 | [box_missing,ind_missing]=min(box_used); |
---|
1474 | if isequal(box_missing,0); %there is a missing step in the sequence of operations |
---|
1475 | errormsg=['missing' cell2mat(operations(ind_missing))]; |
---|
1476 | return |
---|
1477 | end |
---|
1478 | |
---|
1479 | %% check mask if selecetd |
---|
1480 | if isequal(get(handles.get_mask_civ1,'Value'),1) |
---|
1481 | maskname=get(handles.mask_civ1,'String'); |
---|
1482 | if ~exist(maskname,'file') |
---|
1483 | get_mask_civ1_Callback(hObject, eventdata, handles); |
---|
1484 | end |
---|
1485 | end |
---|
1486 | if isequal(get(handles.get_mask_fix1,'Value'),1) |
---|
1487 | maskname=get(handles.mask_fix1,'String'); |
---|
1488 | if ~exist(maskname,'file') |
---|
1489 | get_mask_fix1_Callback(hObject, eventdata, handles); |
---|
1490 | end |
---|
1491 | end |
---|
1492 | if isequal(get(handles.get_mask_civ2,'Value'),1) |
---|
1493 | maskname=get(handles.mask_civ2,'String'); |
---|
1494 | if ~exist(maskname,'file') |
---|
1495 | get_mask_civ2_Callback(hObject, eventdata, handles); |
---|
1496 | end |
---|
1497 | end |
---|
1498 | if isequal(get(handles.get_mask_fix2,'Value'),1) |
---|
1499 | maskname=get(handles.mask_fix2,'String'); |
---|
1500 | if ~exist(maskname,'file') |
---|
1501 | get_mask_fix2_Callback(hObject, eventdata, handles); |
---|
1502 | end |
---|
1503 | end |
---|
1504 | |
---|
1505 | %% reinitialise status callback |
---|
1506 | if isfield(handles,'status') |
---|
1507 | set(handles.status,'Value',0);%suppress status display |
---|
1508 | status_Callback(hObject, eventdata, handles) |
---|
1509 | end |
---|
1510 | |
---|
1511 | %% set the list of files and check them |
---|
1512 | display('checking the files...') |
---|
1513 | [ref_i,ref_j,errormsg]=find_ref_indices(handles); |
---|
1514 | if ~isempty(errormsg) |
---|
1515 | return |
---|
1516 | end |
---|
1517 | [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc]=... |
---|
1518 | set_civ_filenames(handles,ref_i,ref_j,box_test); |
---|
1519 | set(handles.civ,'UserData',filecell);%store for futur use of status callback |
---|
1520 | if isempty(filecell)% (error message displayed in fct set_civ_filenames) |
---|
1521 | return |
---|
1522 | end |
---|
1523 | nbfield=numel(num1_civ1); |
---|
1524 | nbslice=numel(num_a_civ1); |
---|
1525 | |
---|
1526 | %% read names of the .exe files for PIV and patch |
---|
1527 | path_UVMAT=fileparts(which('uvmat')); %path to the source directory of uvmat |
---|
1528 | xmlfile='PARAM.xml'; |
---|
1529 | if exist(xmlfile,'file')% search parameter xml file in the whole matlab path |
---|
1530 | t=xmltree(xmlfile); |
---|
1531 | s=convert(t); |
---|
1532 | end |
---|
1533 | test_interp=0; |
---|
1534 | if batch |
---|
1535 | if isfield(s,'BatchParam') |
---|
1536 | sparam=s.BatchParam; |
---|
1537 | |
---|
1538 | if ~ismember(sparam.BatchMode,{'sge','oar'}) |
---|
1539 | errormsg=['batch mode ' sparam.BatchMode ' not supported by UVMAT']; |
---|
1540 | return |
---|
1541 | end |
---|
1542 | else |
---|
1543 | errormsg='no batch civ binaries defined in PARAM.xml'; |
---|
1544 | return |
---|
1545 | end |
---|
1546 | if isfield(sparam,'BatchMode') |
---|
1547 | batch_mode=sparam.BatchMode; |
---|
1548 | end |
---|
1549 | % choice of batch priority: |
---|
1550 | ind_answer=2; |
---|
1551 | [s,w]=unix('qstat -q civ.q|grep job_| wc -l'); %check the waiting list (command unix) |
---|
1552 | if isequal(s,0) |
---|
1553 | w(end)=[]; |
---|
1554 | str_displ={[w ' jobs in the waiting list'];... |
---|
1555 | '***********************';... |
---|
1556 | 'JOBS PRIORITY POLICY';... |
---|
1557 | '- urgent = less than 100 images pairs';... |
---|
1558 | '- normal = during the experiments';... |
---|
1559 | '- low = post processing';... |
---|
1560 | '***********************';... |
---|
1561 | 'Select a priority:'}; |
---|
1562 | ' ';... |
---|
1563 | str={'urgent';'normal';'low'}; |
---|
1564 | [ind_answer,v] = listdlg('PromptString',str_displ,... |
---|
1565 | 'SelectionMode','single',... |
---|
1566 | 'ListString',str,'ListSize',[200 100],'Name','job priority','InitialValue',3); |
---|
1567 | if isequal(v,0) % to handle Cancel button and figure close, |
---|
1568 | errormsg='job cancelled'; |
---|
1569 | return % a better way should be create |
---|
1570 | end |
---|
1571 | else |
---|
1572 | msgbox_uvmat('ERROR','sge batch system not available') |
---|
1573 | return |
---|
1574 | end |
---|
1575 | else |
---|
1576 | if isfield(s,'RunParam') |
---|
1577 | sparam=s.RunParam; |
---|
1578 | else |
---|
1579 | msgbox_uvmat('ERROR','no run civ binaries defined in PARAM.xml') |
---|
1580 | return |
---|
1581 | end |
---|
1582 | end |
---|
1583 | |
---|
1584 | %% choose the civ program |
---|
1585 | ProgList=get(handles.CivAll,'String'); |
---|
1586 | index=get(handles.CivAll,'Value'); |
---|
1587 | CivX=isequal(ProgList{index},'CivX'); |
---|
1588 | CivAll=isequal(ProgList{index},'CivAll'); |
---|
1589 | CivUvmat=isequal(ProgList{index},'CivUvmat'); |
---|
1590 | %CivAll=isequal(get(handles.CivAll,'Value'),2); % Boolean for new civ programs |
---|
1591 | if CivAll && isfield(sparam,'CivBin') |
---|
1592 | CivBin=sparam.CivBin; |
---|
1593 | if ~exist(CivBin,'file') || ~isempty(which(CivBin))% if path defined as relative to uvmat |
---|
1594 | sparam.CivBin=fullfile(path_UVMAT,CivBin); |
---|
1595 | if ~exist(sparam.CivBin,'file') |
---|
1596 | msgbox_uvmat('ERROR',['CIVx binary ' CivBin ' defined in PARAM.xm does not exist']) |
---|
1597 | return |
---|
1598 | end |
---|
1599 | end |
---|
1600 | end |
---|
1601 | if isfield(sparam,'Civ1Bin') |
---|
1602 | Civ1Bin=sparam.Civ1Bin; |
---|
1603 | if ~exist(Civ1Bin,'file')||~isempty(which(Civ1Bin))% if path defined as relative to uvmat |
---|
1604 | sparam.Civ1Bin=fullfile(path_UVMAT,Civ1Bin); |
---|
1605 | if ~exist(sparam.Civ1Bin,'file') |
---|
1606 | msgbox_uvmat('ERROR',['civ1 binary ' Civ1Bin ' defined in PARAM.xm does not exist']) |
---|
1607 | return |
---|
1608 | end |
---|
1609 | end |
---|
1610 | end |
---|
1611 | if isfield(sparam,'Civ2Bin') |
---|
1612 | Civ2Bin=sparam.Civ2Bin; |
---|
1613 | if ~exist(Civ2Bin,'file')||~isempty(which(Civ2Bin))% if path defined as relative to uvmat |
---|
1614 | sparam.Civ2Bin=fullfile(path_UVMAT,Civ2Bin); |
---|
1615 | if ~exist(sparam.Civ2Bin,'file') |
---|
1616 | msgbox_uvmat('ERROR',['civ2 binary ' Civ2Bin ' defined in PARAM.xm does not exist']) |
---|
1617 | return |
---|
1618 | end |
---|
1619 | end |
---|
1620 | end |
---|
1621 | if isfield(sparam,'PatchBin') |
---|
1622 | if ~exist(sparam.PatchBin,'file')||~isempty(which(sparam.PatchBin))% if path defined as relative to uvmat |
---|
1623 | sparam.PatchBin=fullfile(path_UVMAT,sparam.PatchBin); |
---|
1624 | end |
---|
1625 | end |
---|
1626 | if isfield(sparam,'FixBin') |
---|
1627 | if ~exist(sparam.FixBin,'file')||~isempty(which(sparam.FixBin))% if path defined as relative to uvmat |
---|
1628 | sparam.FixBin=fullfile(path_UVMAT,sparam.FixBin); |
---|
1629 | end |
---|
1630 | end |
---|
1631 | |
---|
1632 | |
---|
1633 | |
---|
1634 | %% get civ1 parameters: |
---|
1635 | display('files OK, processing...') |
---|
1636 | if box_test(1)==1 |
---|
1637 | par_civ1=read_param_civ1(handles,filecell.ima1.civ1{1,1}); |
---|
1638 | end |
---|
1639 | |
---|
1640 | %% get fix1 parameters |
---|
1641 | if box_test(2)==1 |
---|
1642 | flagindex1(1)=get(handles.vec_Fmin2, 'Value'); |
---|
1643 | flagindex1(2)=get(handles.vec_F3, 'Value'); |
---|
1644 | flagindex1(3)=get(handles.vec_F2, 'Value'); |
---|
1645 | thresh_vecC1=str2double(get(handles.thresh_vecC,'String'));%threshold on image correlation vec_C |
---|
1646 | thresh_vel1=str2double(get(handles.thresh_vel,'String'));%threshold on velocity modulus |
---|
1647 | test_mask=get(handles.get_mask_fix1,'Value'); |
---|
1648 | nbslice_mask=get(handles.mask_fix1,'UserData'); % get the number of slices (= number of masks) |
---|
1649 | %%%%%%%%%%%%%COMPLETER LE PROGRAMME FIX |
---|
1650 | % inf_sup=get(handles.inf_sup1,'Value');80 |
---|
1651 | % fileref=get(handles.ref_fix1,'String'); |
---|
1652 | % refpath=get(handles.ref_fix1,'UserData'); |
---|
1653 | % fileref=fullfile(refpath,fileref); |
---|
1654 | menu=get(handles.field_ref1,'String'); |
---|
1655 | index=get(handles.field_ref1,'Value'); |
---|
1656 | if isempty(menu) |
---|
1657 | fieldchoice=''; |
---|
1658 | else |
---|
1659 | fieldchoice=menu{index}; |
---|
1660 | msgbox_uvmat('WARNING','reference field is not used presently with batch, use RUN option') |
---|
1661 | end |
---|
1662 | end |
---|
1663 | |
---|
1664 | %% get patch1 parameters |
---|
1665 | if box_test(3)==1 |
---|
1666 | rho_patch1=str2double(get(handles.rho_patch1,'String')); |
---|
1667 | if isnan(rho_patch1) |
---|
1668 | rho_patch1='1000'; |
---|
1669 | set(handles.rho_patch1,'String','1') |
---|
1670 | else |
---|
1671 | rho_patch1=num2str(1000*rho_patch1); |
---|
1672 | end |
---|
1673 | nx_patch1=get(handles.nx_patch1,'String'); |
---|
1674 | ny_patch1=get(handles.ny_patch1,'String'); |
---|
1675 | if isnan(str2double(nx_patch1)) |
---|
1676 | nx_patch1='50' ;%default |
---|
1677 | set(handles.nx_patch1,'String','50'); |
---|
1678 | end |
---|
1679 | if isnan(str2double(ny_patch1)) |
---|
1680 | ny_patch1='50' ;%default |
---|
1681 | set(handles.ny_patch1,'String','50'); |
---|
1682 | end |
---|
1683 | subdomain_patch1=get(handles.subdomain_patch1,'String'); |
---|
1684 | thresh_patch1=get(handles.thresh_patch1,'String'); |
---|
1685 | end |
---|
1686 | |
---|
1687 | %% get civ2 parameters: |
---|
1688 | if box_test(4)==1 |
---|
1689 | par_civ2=read_param_civ2(handles,cell2mat(filecell.ima1.civ2(1,1))); |
---|
1690 | end |
---|
1691 | |
---|
1692 | %% get fix2 parameters |
---|
1693 | if box_test(5)==1 |
---|
1694 | flagindex2(1)=get(handles.vec_Fmin2_2, 'Value'); |
---|
1695 | flagindex2(2)=get(handles.vec_F3_2, 'Value'); |
---|
1696 | flagindex2(3)=get(handles.vec_F4, 'Value'); |
---|
1697 | thresh_vec2C=str2double(get(handles.thresh_vec2C,'String'));%threshold on image correlation vec_C |
---|
1698 | thresh_vel2=str2double(get(handles.thresh_vel2,'String'));%threshold on velocity modulus |
---|
1699 | test_mask=get(handles.get_mask_fix2,'Value'); |
---|
1700 | nbslice_mask=get(handles.mask_fix2,'UserData'); % get the number of slices (= number of masks) |
---|
1701 | %%%%%%%%%%%%%COMPLETER LE PROGRAMME FIX AVEC REF FILE ET OPTION inf_sup=2 |
---|
1702 | % inf_sup=get(handles.inf_sup2,'Value'); |
---|
1703 | % ref=get(handles.ref_fix2,'UserData'); |
---|
1704 | |
---|
1705 | %%%%%%%%%%%%%%%%%%% |
---|
1706 | end |
---|
1707 | |
---|
1708 | %% get patch2 parameters |
---|
1709 | if box_test(6)==1 |
---|
1710 | rho_patch2=str2double(get(handles.rho_patch2,'String')); |
---|
1711 | if isnan(rho_patch2) |
---|
1712 | rho_patch2='1000'; |
---|
1713 | set(handles.rho_patch2,'String','1') |
---|
1714 | else |
---|
1715 | rho_patch2=num2str(1000*rho_patch2); |
---|
1716 | end |
---|
1717 | nx_patch2=get(handles.nx_patch2,'String'); |
---|
1718 | ny_patch2=get(handles.ny_patch2,'String'); |
---|
1719 | if isnan(str2double(nx_patch2)) |
---|
1720 | nx_patch2='50' ;%default |
---|
1721 | set(handles.nx_patch2,'String','50'); |
---|
1722 | end |
---|
1723 | if isnan(str2double(ny_patch2)) |
---|
1724 | ny_patch2='50' ;%default |
---|
1725 | set(handles.ny_patch2,'String','50'); |
---|
1726 | end |
---|
1727 | subdomain_patch2=get(handles.subdomain_patch2,'String'); |
---|
1728 | thresh_patch2=get(handles.thresh_patch2,'String'); |
---|
1729 | % test_interp=get(handles.test_interp,'Value'); |
---|
1730 | end |
---|
1731 | |
---|
1732 | %% MAIN LOOP |
---|
1733 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
1734 | super_cmd=[]; |
---|
1735 | |
---|
1736 | for ifile=1:nbfield |
---|
1737 | for j=1:nbslice |
---|
1738 | i_cmd=0; |
---|
1739 | cmd=''; |
---|
1740 | if isunix % check: necessaire aussi en RUN? |
---|
1741 | cmd='#!/bin/bash \n'; |
---|
1742 | cmd=[cmd '#$ -cwd \n']; |
---|
1743 | cmd=[cmd 'hostname && date \n']; |
---|
1744 | cmd=[cmd 'umask 002 \n'];%allow writting access to created files for user group |
---|
1745 | end |
---|
1746 | if CivAll |
---|
1747 | CivAllxml=xmltree;% xml contents, all parameters |
---|
1748 | CivAllCmd=''; |
---|
1749 | CivAllxml=set(CivAllxml,1,'name','CivDoc'); |
---|
1750 | end |
---|
1751 | [Rootbat,Filebat]=fileparts(filecell.nc.civ1{ifile,j});%output netcdf file (without extention) |
---|
1752 | flname=fullfile(Rootbat,Filebat); |
---|
1753 | if batch |
---|
1754 | filename_bat=fullfile(Rootbat,['job_' Filebat]); |
---|
1755 | else |
---|
1756 | filename_bat=flname; |
---|
1757 | end |
---|
1758 | filename_bat=[filename_bat '.bat']; |
---|
1759 | |
---|
1760 | %CIV1 |
---|
1761 | if box_test(1)==1 |
---|
1762 | par_civ1.filename_ima_a=filecell.ima1.civ1{ifile,j}; |
---|
1763 | par_civ1.filename_ima_b=filecell.ima2.civ1{ifile,j}; |
---|
1764 | par_civ1.Dt=num2str(time(num2_civ1(ifile),num_b_civ1(j))-time(num1_civ1(ifile),num_a_civ1(j))); |
---|
1765 | par_civ1.T0=num2str((time(num2_civ1(ifile),num_b_civ1(j))+time(num1_civ1(ifile),num_a_civ1(j)))/2); |
---|
1766 | par_civ1.term_a=num2stra(num_a_civ1(j),nom_type_nc);%UTILITE? |
---|
1767 | par_civ1.term_b=num2stra(num_b_civ1(j),nom_type_nc);% |
---|
1768 | test_mask=get(handles.get_mask_civ1,'Value'); |
---|
1769 | if test_mask==0 |
---|
1770 | par_civ1.maskname='noFile use default'; |
---|
1771 | par_civ1.maskflag='n'; |
---|
1772 | else |
---|
1773 | maskdispl=get(handles.mask_civ1,'String'); |
---|
1774 | if exist(maskdispl,'file') |
---|
1775 | par_civ1.maskname=maskdispl; |
---|
1776 | par_civ1.maskflag='y'; |
---|
1777 | else |
---|
1778 | maskbase=[filecell.filebase '_' maskdispl]; % |
---|
1779 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
1780 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
1781 | par_civ1.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
1782 | if exist(par_civ1.maskname,'file') |
---|
1783 | par_civ1.maskflag='y'; |
---|
1784 | else |
---|
1785 | par_civ1.maskname='noFile use default'; |
---|
1786 | par_civ1.maskflag='n'; |
---|
1787 | end |
---|
1788 | end |
---|
1789 | end |
---|
1790 | |
---|
1791 | test_grid=get(handles.browse_gridciv1,'Value'); |
---|
1792 | if test_grid |
---|
1793 | par_civ1.gridflag='y'; |
---|
1794 | gridname=get(handles.grid_civ1,'String'); |
---|
1795 | if isequal(gridname(end-3:end),'grid') |
---|
1796 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
1797 | if ~isnan(nbslice_grid) |
---|
1798 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
1799 | par_civ1.gridname=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
1800 | if ~exist(par_civ1.gridname,'file') |
---|
1801 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
1802 | end |
---|
1803 | elseif exist(gridname,'file') |
---|
1804 | par_civ1.gridname=gridname; |
---|
1805 | else |
---|
1806 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
1807 | end |
---|
1808 | end |
---|
1809 | else |
---|
1810 | par_civ1.gridname='noFile use default'; |
---|
1811 | par_civ1.gridflag='n'; |
---|
1812 | end |
---|
1813 | % |
---|
1814 | i_cmd=i_cmd+1; |
---|
1815 | if isequal(CivAll,0) |
---|
1816 | civ1_exe=CIV1_CMD(fullfile(Rootbat,Filebat),'',par_civ1,handles,sparam);%create the parameter file .civ1.cmx and set the execution string civ1_exe |
---|
1817 | % if(isunix) |
---|
1818 | % cmd=[cmd 'cp -f ' flname '.civ1.cmx ' flname '.cmx\n']; |
---|
1819 | % else |
---|
1820 | % flname=regexprep(flname,'\\','\\\\'); |
---|
1821 | % cmd=[cmd 'copy /Y "' flname '.civ1.cmx" "' flname '.cmx"\n']; |
---|
1822 | % end |
---|
1823 | cmd=[cmd civ1_exe '\n']; |
---|
1824 | else |
---|
1825 | CivAllCmd=[CivAllCmd ' civ1 ']; |
---|
1826 | str=CIV1_CMD_Unified(fullfile(Rootbat,Filebat),'',par_civ1); |
---|
1827 | fieldnames=fields(str); |
---|
1828 | [CivAllxml,uid_civ1]=add(CivAllxml,1,'element','civ1'); |
---|
1829 | for ilist=1:length(fieldnames) |
---|
1830 | val=eval(['str.' fieldnames{ilist}]); |
---|
1831 | if ischar(val) |
---|
1832 | [CivAllxml,uid_t]=add(CivAllxml,uid_civ1,'element',fieldnames{ilist}); |
---|
1833 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
1834 | end |
---|
1835 | end |
---|
1836 | end |
---|
1837 | end |
---|
1838 | |
---|
1839 | % FIX1 |
---|
1840 | if box_test(2)==1 |
---|
1841 | test_mask=get(handles.get_mask_fix1,'Value'); |
---|
1842 | if test_mask==0 |
---|
1843 | maskname=''; |
---|
1844 | else |
---|
1845 | maskdispl=get(handles.mask_fix1,'String'); |
---|
1846 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
1847 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
1848 | maskbase=[filecell.filebase '_' maskdispl]; |
---|
1849 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
1850 | end |
---|
1851 | if CivX |
---|
1852 | if isunix %unix system |
---|
1853 | cmd_FIX=[sparam.FixBin ' -f ' filecell.nc.civ1{ifile,j} ' -fi1 ' num2str(flagindex1(1)) ... |
---|
1854 | ' -fi2 ' num2str(flagindex1(2)) ' -fi3 ' num2str(flagindex1(3)) ... |
---|
1855 | ' -threshC ' num2str(thresh_vecC1) ' -threshV ' num2str(thresh_vel1) ' -maskName ' maskname]; |
---|
1856 | else %windows system |
---|
1857 | cmd_FIX=['"' sparam.FixBin '" -f "' filecell.nc.civ1{ifile,j} '" -fi1 ' num2str(flagindex1(1)) ... |
---|
1858 | ' -fi2 ' num2str(flagindex1(2)) ' -fi3 ' num2str(flagindex1(3)) ... |
---|
1859 | ' -threshC ' num2str(thresh_vecC1) ' -threshV ' num2str(thresh_vel1) ' -maskName "' maskname '"']; |
---|
1860 | cmd_FIX=regexprep(cmd_FIX,'\\','\\\\'); |
---|
1861 | end |
---|
1862 | cmd=[cmd cmd_FIX '\n']; |
---|
1863 | elseif CivAll |
---|
1864 | fix1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
1865 | fix1.fi1=num2str(flagindex1(1)); |
---|
1866 | fix1.fi2=num2str(flagindex1(2)); |
---|
1867 | fix1.fi3=num2str(flagindex1(3)); |
---|
1868 | fix1.threshC=num2str(thresh_vecC1); |
---|
1869 | fix1.threshV=num2str(thresh_vel1); |
---|
1870 | fieldnames=fields(fix1); |
---|
1871 | [CivAllxml,uid_fix1]=add(CivAllxml,1,'element','fix1'); |
---|
1872 | for ilist=1:length(fieldnames) |
---|
1873 | val=eval(['fix1.' fieldnames{ilist}]); |
---|
1874 | if ischar(val) |
---|
1875 | [CivAllxml,uid_t]=add(CivAllxml,uid_fix1,'element',fieldnames{ilist}); |
---|
1876 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
1877 | end |
---|
1878 | end |
---|
1879 | CivAllCmd=[CivAllCmd ' fix1 ']; |
---|
1880 | end |
---|
1881 | end |
---|
1882 | |
---|
1883 | %PATCH1 |
---|
1884 | if box_test(3)==1 |
---|
1885 | if isequal(CivAll,0) |
---|
1886 | cmd_PATCH=PATCH_CMD(filecell.nc.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp,sparam.PatchBin); |
---|
1887 | cmd=[cmd cmd_PATCH '\n']; |
---|
1888 | else |
---|
1889 | patch1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
1890 | patch1.nopt=subdomain_patch1; |
---|
1891 | patch1.maxdiff=thresh_patch1; |
---|
1892 | patch1.ro=rho_patch1; |
---|
1893 | test_grid=get(handles.get_gridpatch1,'Value'); |
---|
1894 | if test_grid |
---|
1895 | patch1.gridflag='y'; |
---|
1896 | gridname=get(handles.grid_patch1,'String'); |
---|
1897 | if isequal(gridname(end-3:end),'grid') |
---|
1898 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
1899 | if ~isnan(nbslice_grid) |
---|
1900 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
1901 | patch1.gridPatch=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
1902 | if ~exist(patch1.gridPatch,'file') |
---|
1903 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
1904 | end |
---|
1905 | elseif exist(gridname,'file') |
---|
1906 | patch1.gridPatch=gridname; |
---|
1907 | else |
---|
1908 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
1909 | end |
---|
1910 | end |
---|
1911 | else |
---|
1912 | patch1.gridPatch='none'; |
---|
1913 | patch1.gridflag='n'; |
---|
1914 | patch1.m=nx_patch1; |
---|
1915 | patch1.n=ny_patch1; |
---|
1916 | end |
---|
1917 | patch1.convectFlow='n'; |
---|
1918 | fieldnames=fields(patch1); |
---|
1919 | [CivAllxml,uid_patch1]=add(CivAllxml,1,'element','patch1'); |
---|
1920 | for ilist=1:length(fieldnames) |
---|
1921 | val=eval(['patch1.' fieldnames{ilist}]); |
---|
1922 | if ischar(val) |
---|
1923 | [CivAllxml,uid_t]=add(CivAllxml,uid_patch1,'element',fieldnames{ilist}); |
---|
1924 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
1925 | end |
---|
1926 | end |
---|
1927 | CivAllCmd=[CivAllCmd ' patch1 ']; |
---|
1928 | end |
---|
1929 | end |
---|
1930 | |
---|
1931 | if box_test(4)==1 || box_test(5)==1 || box_test(6)==1 |
---|
1932 | filename_cmx=filecell.nc.civ2{ifile,j};%output netcdf file |
---|
1933 | filename_cmx(end-1:end+1)='cmx';%name of cmx file |
---|
1934 | end |
---|
1935 | |
---|
1936 | if box_test(4)==1 |
---|
1937 | par_civ2.filename_ima_a=filecell.ima1.civ2{ifile,j}; |
---|
1938 | par_civ2.filename_ima_b=filecell.ima2.civ2{ifile,j}; |
---|
1939 | [Rootbat,Filebat]=fileparts(filecell.nc.civ2{ifile,j});%output netcdf file (without extention) |
---|
1940 | par_civ2.Dt=num2str(time(num2_civ2(ifile),num_b_civ2(j))-time(num1_civ2(ifile),num_a_civ2(j))); |
---|
1941 | par_civ2.T0=num2str((time(num2_civ1(ifile),num_b_civ2(j))+time(num1_civ2(ifile),num_a_civ2(j)))/2); |
---|
1942 | par_civ2.term_a=num2stra(num_a_civ2(j),nom_type_nc); |
---|
1943 | par_civ2.term_b=num2stra(num_b_civ2(j),nom_type_nc); |
---|
1944 | par_civ2.filename_nc1=filecell.nc.civ1{ifile,j}; |
---|
1945 | par_civ2.filename_nc1(end-2:end)=[]; % remove '.nc' |
---|
1946 | test_mask=get(handles.get_mask_civ2,'Value'); |
---|
1947 | if test_mask==0 |
---|
1948 | par_civ2.maskname='noFile use default'; |
---|
1949 | par_civ2.maskflag='n'; |
---|
1950 | else |
---|
1951 | maskdispl=get(handles.mask_civ2,'String'); |
---|
1952 | if exist(maskdispl,'file') |
---|
1953 | par_civ2.maskname=maskdispl; |
---|
1954 | par_civ2.maskflag='y'; |
---|
1955 | else |
---|
1956 | maskbase=[filecell.filebase '_' maskdispl]; % |
---|
1957 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
1958 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
1959 | par_civ2.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
1960 | if exist(par_civ2.maskname,'file') |
---|
1961 | par_civ2.maskflag='y'; |
---|
1962 | else |
---|
1963 | par_civ2.maskname='noFile use default'; |
---|
1964 | par_civ2.maskflag='n'; |
---|
1965 | end |
---|
1966 | end |
---|
1967 | end |
---|
1968 | %TESTgrid |
---|
1969 | %test_grid=get(handles.browse_gridciv2,'Value'); |
---|
1970 | gridname=get(handles.grid_civ2,'String'); |
---|
1971 | %gridflag='y'; |
---|
1972 | if numel(gridname)>=4 && isequal(gridname(end-3:end),'grid') |
---|
1973 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
1974 | if ~isnan(nbslice_grid) |
---|
1975 | par_civ2.gridflag='y'; |
---|
1976 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
1977 | par_civ2.gridname=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
1978 | if exist(par_civ2.gridname,'file') |
---|
1979 | par_civ2.gridflag='y'; |
---|
1980 | else |
---|
1981 | par_civ2.gridname='noFile use default'; |
---|
1982 | par_civ2.gridflag='n'; |
---|
1983 | end |
---|
1984 | elseif exist(gridname,'file') |
---|
1985 | par_civ2.gridflag='y'; |
---|
1986 | else |
---|
1987 | par_civ2.gridname='noFile use default'; |
---|
1988 | par_civ2.gridflag='n'; |
---|
1989 | end |
---|
1990 | end |
---|
1991 | i_cmd=i_cmd+1; |
---|
1992 | flname=fullfile(Rootbat,Filebat); |
---|
1993 | |
---|
1994 | if isequal(CivAll,0) |
---|
1995 | cmd_CIV2=CIV2_CMD(flname,[],par_civ2,sparam);%creates the cmx file [fullfile(Rootbat,Filebat) '.civ2.cmx] |
---|
1996 | % if(isunix) |
---|
1997 | cmd=[cmd cmd_CIV2 '\n']; |
---|
1998 | % else |
---|
1999 | % flname=regexprep(flname,'\\','\\\\'); |
---|
2000 | % cmd=[cmd 'copy /Y "' flname '.civ2.cmx" "' flname '.cmx"\n' cmd_CIV2 '\n']; |
---|
2001 | % end |
---|
2002 | else |
---|
2003 | CivAllCmd=[CivAllCmd ' civ2 ']; |
---|
2004 | str=CIV2_CMD_Unified(flname,'',par_civ2); |
---|
2005 | fieldnames=fields(str); |
---|
2006 | [CivAllxml,uid_civ2]=add(CivAllxml,1,'element','civ2'); |
---|
2007 | for ilist=1:length(fieldnames) |
---|
2008 | val=eval(['str.' fieldnames{ilist}]); |
---|
2009 | if ischar(val) |
---|
2010 | [CivAllxml,uid_t]=add(CivAllxml,uid_civ2,'element',fieldnames{ilist}); |
---|
2011 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
2012 | end |
---|
2013 | end |
---|
2014 | end |
---|
2015 | end |
---|
2016 | |
---|
2017 | % FIX2 |
---|
2018 | if box_test(5)==1 |
---|
2019 | test_mask=get(handles.get_mask_fix2,'Value'); |
---|
2020 | if test_mask==0 |
---|
2021 | maskname=''; %no mask used |
---|
2022 | else |
---|
2023 | maskdispl=get(handles.mask_fix2,'String'); |
---|
2024 | maskbase=[filecell.filebase '_' maskdispl]; % |
---|
2025 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
2026 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
2027 | maskname =name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
2028 | end |
---|
2029 | if isequal(CivAll,0) |
---|
2030 | if isunix |
---|
2031 | cmd_FIX=[sparam.FixBin ' -f ' filecell.nc.civ2{ifile,j} ' -fi1 ' num2str(flagindex2(1)) ... |
---|
2032 | ' -fi2 ' num2str(flagindex2(2)) ' -fi3 ' num2str(flagindex2(3)) ... |
---|
2033 | ' -threshC ' num2str(thresh_vec2C) ' -threshV ' num2str(thresh_vel2) ' -maskName ' maskname]; |
---|
2034 | else |
---|
2035 | cmd_FIX=['"' sparam.FixBin '" -f "' filecell.nc.civ2{ifile,j} '" -fi1 ' num2str(flagindex2(1)) ... |
---|
2036 | ' -fi2 ' num2str(flagindex2(2)) ' -fi3 ' num2str(flagindex2(3)) ... |
---|
2037 | ' -threshC ' num2str(thresh_vec2C) ' -threshV ' num2str(thresh_vel2) ' -maskName "' maskname '"']; |
---|
2038 | cmd_FIX=regexprep(cmd_FIX,'\\','\\\\'); |
---|
2039 | end |
---|
2040 | cmd=[cmd cmd_FIX '\n']; |
---|
2041 | else |
---|
2042 | fix2.inputFileName=filecell.nc.civ2{ifile,j} ; |
---|
2043 | fix2.fi1=num2str(flagindex2(1)); |
---|
2044 | fix2.fi2=num2str(flagindex2(2)); |
---|
2045 | fix2.fi3=num2str(flagindex2(3)); |
---|
2046 | fix2.threshC=num2str(thresh_vec2C); |
---|
2047 | fix2.threshV=num2str(thresh_vel2); |
---|
2048 | fieldnames=fields(fix2); |
---|
2049 | [CivAllxml,uid_fix2]=add(CivAllxml,1,'element','fix2'); |
---|
2050 | for ilist=1:length(fieldnames) |
---|
2051 | val=eval(['fix2.' fieldnames{ilist}]); |
---|
2052 | if ischar(val) |
---|
2053 | [CivAllxml,uid_t]=add(CivAllxml,uid_fix2,'element',fieldnames{ilist}); |
---|
2054 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
2055 | end |
---|
2056 | end |
---|
2057 | CivAllCmd=[CivAllCmd ' fix2 ']; |
---|
2058 | end |
---|
2059 | end |
---|
2060 | |
---|
2061 | %PATCH2 |
---|
2062 | if box_test(6)==1 |
---|
2063 | if isequal(CivAll,0) |
---|
2064 | cmd_PATCH=PATCH_CMD(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,test_interp,sparam.PatchBin); |
---|
2065 | cmd=[cmd cmd_PATCH '\n']; |
---|
2066 | else |
---|
2067 | patch2.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
2068 | patch2.nopt=subdomain_patch2; |
---|
2069 | patch2.maxdiff=thresh_patch2; |
---|
2070 | patch2.ro=rho_patch2; |
---|
2071 | test_grid=get(handles.get_gridpatch2,'Value'); |
---|
2072 | if test_grid |
---|
2073 | patch2.gridflag='y'; |
---|
2074 | gridname=get(handles.grid_patch2,'String'); |
---|
2075 | if isequal(gridname(end-3:end),'grid') |
---|
2076 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
2077 | if ~isnan(nbslice_grid) |
---|
2078 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
2079 | patch2.gridPatch=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
2080 | if ~exist(patch2.gridPatch,'file') |
---|
2081 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
2082 | end |
---|
2083 | elseif exist(gridname,'file') |
---|
2084 | patch2.gridPatch=gridname; |
---|
2085 | else |
---|
2086 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
2087 | end |
---|
2088 | end |
---|
2089 | else |
---|
2090 | patch2.gridPatch='none'; |
---|
2091 | patch2.gridflag='n'; |
---|
2092 | patch2.m=nx_patch2; |
---|
2093 | patch2.n=ny_patch2; |
---|
2094 | end |
---|
2095 | patch2.convectFlow='n'; |
---|
2096 | fieldnames=fields(patch2); |
---|
2097 | [CivAllxml,uid_patch2]=add(CivAllxml,1,'element','patch2'); |
---|
2098 | for ilist=1:length(fieldnames) |
---|
2099 | val=eval(['patch2.' fieldnames{ilist}]); |
---|
2100 | if ischar(val) |
---|
2101 | [CivAllxml,uid_t]=add(CivAllxml,uid_patch2,'element',fieldnames{ilist}); |
---|
2102 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
2103 | end |
---|
2104 | end |
---|
2105 | CivAllCmd=[CivAllCmd ' patch2 ']; |
---|
2106 | end |
---|
2107 | end |
---|
2108 | if CivAll |
---|
2109 | save(CivAllxml,[flname '.xml']); |
---|
2110 | cmd=[cmd sparam.CivBin ' -f ' flname '.xml ' CivAllCmd ' >' flname '.log' '\n']; |
---|
2111 | end |
---|
2112 | % create the .bat file: |
---|
2113 | [fid,message]=fopen(filename_bat,'w'); |
---|
2114 | if isequal(fid,-1) |
---|
2115 | msgbox_uvmat('ERROR', ['creation of .bat file: ' message]) |
---|
2116 | return |
---|
2117 | end |
---|
2118 | fprintf(fid,cmd); |
---|
2119 | fclose(fid); |
---|
2120 | if batch |
---|
2121 | switch batch_mode |
---|
2122 | case 'sge' |
---|
2123 | pvalue=num2str((1-ind_answer)*500); |
---|
2124 | display(['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]); |
---|
2125 | eval( ['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]); |
---|
2126 | case 'oar' |
---|
2127 | % pvalue=num2str((1-ind_answer)*500); |
---|
2128 | % display(['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]); |
---|
2129 | eval( ['!chmod +x ' filename_bat]); |
---|
2130 | eval( ['!oarsub -l /nodes=1/cpu=1,walltime=00:10:00 ' filename_bat]); |
---|
2131 | end |
---|
2132 | elseif ~CivUvmat |
---|
2133 | %% to lauch the jobs locally : |
---|
2134 | if(isunix) |
---|
2135 | cmd_str=['. ' filename_bat]; |
---|
2136 | else %case of Windows |
---|
2137 | cmd_str=['@call "' regexprep(filename_bat,'\\','\\\\') '"']; |
---|
2138 | end |
---|
2139 | super_cmd=[super_cmd cmd_str '\n']; |
---|
2140 | disp(cmd_str); |
---|
2141 | else %run PIVlab if selected |
---|
2142 | drawnow |
---|
2143 | if box_test(1)==1 |
---|
2144 | Param.Civ1=par_civ1; |
---|
2145 | end |
---|
2146 | if box_test(2)==1 |
---|
2147 | fix1.WarnFlags=[]; |
---|
2148 | if get(handles.vec_Fmin2,'Value') |
---|
2149 | fix1.WarnFlags=[fix1.WarnFlags -2]; |
---|
2150 | end |
---|
2151 | if get(handles.vec_F3,'Value') |
---|
2152 | fix1.WarnFlags=[fix1.WarnFlags 3]; |
---|
2153 | end |
---|
2154 | fix1.LowerBoundCorr=thresh_vecC1; |
---|
2155 | if get(handles.inf_sup1,'Value') |
---|
2156 | fix1.UppperBoundVel=thresh_vel1; |
---|
2157 | else |
---|
2158 | fix1.LowerBoundVel=thresh_vel1; |
---|
2159 | end |
---|
2160 | if get(handles.get_mask_fix1,'Value') |
---|
2161 | fix1.MaskName=maskname; |
---|
2162 | end |
---|
2163 | Param.Fix1=fix1; |
---|
2164 | end |
---|
2165 | if box_test(3)==1 |
---|
2166 | Param.Patch1.Rho=rho_patch1; |
---|
2167 | Param.Patch1.Threshold=thresh_patch1; |
---|
2168 | Param.Patch1.SubDomain=subdomain_patch1; |
---|
2169 | end |
---|
2170 | if box_test(4)==1 |
---|
2171 | Param.Civ2=par_civ2; |
---|
2172 | end |
---|
2173 | if box_test(5)==1 |
---|
2174 | fix2.WarnFlags=[]; |
---|
2175 | if get(handles.vec_Fmin2_2,'Value') |
---|
2176 | fix2.WarnFlags=[fix2.WarnFlags -2]; |
---|
2177 | end |
---|
2178 | if get(handles.vec_F4,'Value') |
---|
2179 | fix2.WarnFlags=[fix2.WarnFlags 4]; |
---|
2180 | end |
---|
2181 | if get(handles.vec_F3_2,'Value') |
---|
2182 | fix2.WarnFlags=[fix2.WarnFlags 3]; |
---|
2183 | end |
---|
2184 | fix2.LowerBoundCorr=thresh_vec2C; |
---|
2185 | if get(handles.inf_sup2,'Value') |
---|
2186 | fix2.UppperBoundVel=thresh_vel2; |
---|
2187 | else |
---|
2188 | fix2.LowerBoundVel=thresh_vel2; |
---|
2189 | end |
---|
2190 | if get(handles.get_mask_fix2,'Value') |
---|
2191 | fix2.MaskName=maskname; |
---|
2192 | end |
---|
2193 | Param.Fix2=fix2; |
---|
2194 | end |
---|
2195 | [Data,erromsg]=civ_uvmat(Param,filecell.nc.civ1{ifile,j}); |
---|
2196 | if isempty(errormsg) |
---|
2197 | display([filecell.nc.civ1{ifile,j} ' written']) |
---|
2198 | else |
---|
2199 | msgbox_uvmat('ERROR',errormsg) |
---|
2200 | end |
---|
2201 | end |
---|
2202 | end |
---|
2203 | end |
---|
2204 | |
---|
2205 | if ~batch && ~CivUvmat |
---|
2206 | [Rootbat,Filebat,extbat]=fileparts(filename_bat); |
---|
2207 | filename_superbat=fullfile(Rootbat,'job_list.bat'); |
---|
2208 | fid=fopen(filename_superbat,'w'); |
---|
2209 | fprintf(fid,super_cmd'); |
---|
2210 | fclose(fid); |
---|
2211 | if(isunix) |
---|
2212 | system(['chmod +x ' filename_superbat]) |
---|
2213 | end |
---|
2214 | system([filename_superbat ' &'])% execute main commmand |
---|
2215 | end |
---|
2216 | |
---|
2217 | %% save interface state |
---|
2218 | if isfield(filecell,'nc') |
---|
2219 | if isfield(filecell.nc,'civ2') |
---|
2220 | fileresu=filecell.nc.civ2{1,1}; |
---|
2221 | else |
---|
2222 | fileresu=filecell.nc.civ1{1,1}; |
---|
2223 | end |
---|
2224 | end |
---|
2225 | [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileresu); |
---|
2226 | namedoc=fullfile(RootPath,subdir,RootFile); |
---|
2227 | detect=1; |
---|
2228 | while detect==1 |
---|
2229 | namefigfull=[namedoc '.fig']; |
---|
2230 | hh=dir(namefigfull); |
---|
2231 | if ~isempty(hh) |
---|
2232 | detect=1; |
---|
2233 | namedoc=[namedoc '.0']; |
---|
2234 | else |
---|
2235 | detect=0; |
---|
2236 | end |
---|
2237 | end |
---|
2238 | saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) |
---|
2239 | |
---|
2240 | %------------------------------------------------------------------------ |
---|
2241 | % --- determine the list of reference indices of processing file |
---|
2242 | function [ref_i,ref_j,errormsg]=find_ref_indices(handles) |
---|
2243 | %------------------------------------------------------------------------ |
---|
2244 | errormsg=''; %default error message |
---|
2245 | first_i=str2double(get(handles.first_i,'String'));%first index i |
---|
2246 | last_i=str2double(get(handles.last_i,'String'));%last index i |
---|
2247 | incr_i=str2double(get(handles.incr_i,'String'));% increment |
---|
2248 | if isequal(get(handles.first_j,'Visible'),'on') |
---|
2249 | first_j=str2double(get(handles.first_j,'String'));%first index j |
---|
2250 | last_j=str2double(get(handles.last_j,'String'));%last index j |
---|
2251 | incr_j=str2double(get(handles.incr_j,'String'));% increment |
---|
2252 | else |
---|
2253 | first_j=1; |
---|
2254 | last_j=1; |
---|
2255 | incr_j=1; |
---|
2256 | end |
---|
2257 | ref_i=first_i:incr_i:last_i;% list of i indices (reference values for each pair) |
---|
2258 | ref_j=first_j:incr_j:last_j;% list of j indices (reference values for each pair) |
---|
2259 | if isnan(first_i)||isnan(first_j) |
---|
2260 | errormsg='first field number not defined'; |
---|
2261 | elseif isnan(last_i)||isnan(last_j) |
---|
2262 | errormsg='last field number not defined'; |
---|
2263 | elseif isnan(incr_i)||isnan(incr_j) |
---|
2264 | errormsg='increment in field number not defined'; |
---|
2265 | elseif last_i < first_i || last_j < first_j |
---|
2266 | errormsg='last field number must be larger than the first one'; |
---|
2267 | end |
---|
2268 | |
---|
2269 | %------------------------------------------------------------------------ |
---|
2270 | % --- determine the list of filenames and indices needed for launch_job |
---|
2271 | function [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc,file_ref_fix1,file_ref_fix2]=... |
---|
2272 | set_civ_filenames(handles,ref_i,ref_j,box_test) |
---|
2273 | %------------------------------------------------------------------------ |
---|
2274 | filecell=[];%default |
---|
2275 | |
---|
2276 | %% get the root names nomenclature and numbers |
---|
2277 | filebase=get(handles.RootName,'String'); |
---|
2278 | |
---|
2279 | if isempty(filebase)||isequal(filebase,'') |
---|
2280 | msgbox_uvmat('ERROR','no input files') |
---|
2281 | return |
---|
2282 | end |
---|
2283 | |
---|
2284 | %filebase=regexprep(filebase,'\.fsnet','fsnet');% temporary fix for cluster Coriolis |
---|
2285 | filecell.filebase=filebase; |
---|
2286 | |
---|
2287 | browse=get(handles.browse_root,'UserData'); |
---|
2288 | compare_list=get(handles.compare,'String'); |
---|
2289 | val=get(handles.compare,'Value'); |
---|
2290 | compare=compare_list{val}; |
---|
2291 | if strcmp(compare,'displacement') |
---|
2292 | mode='displacement'; |
---|
2293 | else |
---|
2294 | mode_list=get(handles.mode,'String'); |
---|
2295 | mode_value=get(handles.mode,'Value'); |
---|
2296 | mode=mode_list{mode_value}; |
---|
2297 | end |
---|
2298 | %time=get(handles.RootName,'UserData'); %get the set of times |
---|
2299 | ext_ima=get(handles.ImaExt,'String'); |
---|
2300 | nom_type_nc=browse.nom_type_nc; |
---|
2301 | if isfield(browse,'nom_type_ima') |
---|
2302 | nom_type_ima2=browse.nom_type_ima; |
---|
2303 | end |
---|
2304 | if isempty(nom_type_ima2),nom_type_ima2='1';end; %default |
---|
2305 | if isempty(nom_type_nc),nom_type_nc='_i1-i2';end; %default |
---|
2306 | [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
2307 | find_pair_indices(handles,ref_i,ref_j,mode); |
---|
2308 | %determine the new filebase for 'displacement' mode (comparison of two series) |
---|
2309 | filebase_B=filebase;% root name of the second field series for stereo |
---|
2310 | if strcmp(compare,'displacement') || strcmp(compare,'stereo PIV') |
---|
2311 | % test_disp=1; |
---|
2312 | nom_type_ima1=browse.nom_type_ima_1; %nomenclature type of the second file series |
---|
2313 | [Path2,Name2]=fileparts(filebase_B); |
---|
2314 | Path1=Path2; |
---|
2315 | Name1=get(handles.RootName_1,'String');% root name of the first field series for stereo |
---|
2316 | filebase_A=fullfile(Path1,Name1); |
---|
2317 | if length(Name1)>6 |
---|
2318 | Name1=Name1(end-5:end); |
---|
2319 | end |
---|
2320 | if length(Name2)>6 |
---|
2321 | Name2=Name2(end-5:end); |
---|
2322 | end |
---|
2323 | filebase_AB=fullfile(Path2,[Name2 '-' Name1]); |
---|
2324 | else |
---|
2325 | % test_disp=0; |
---|
2326 | filebase_A=filebase; |
---|
2327 | nom_type_ima1=nom_type_ima2; |
---|
2328 | filebase_AB=filebase; |
---|
2329 | end |
---|
2330 | if strcmp(compare,'displacement') |
---|
2331 | filebase_ima1=filebase_A; |
---|
2332 | filebase_ima2=filebase_B; |
---|
2333 | filebase_nc=filebase_AB; %root name for the result of civ2 |
---|
2334 | else |
---|
2335 | filebase_ima1=filebase_B; |
---|
2336 | filebase_ima2=filebase_B; |
---|
2337 | filebase_nc=filebase_B; |
---|
2338 | end |
---|
2339 | |
---|
2340 | %determine reference files for fix: |
---|
2341 | file_ref_fix1={};%default |
---|
2342 | file_ref_fix2={}; |
---|
2343 | nbfield=length(num1_civ1); |
---|
2344 | nbslice=length(num_a_civ1); |
---|
2345 | if box_test(2)==1% fix1 performed |
---|
2346 | ref=get(handles.ref_fix1,'UserData');%read data on the ref file stored by get_ref_fix1_Callback |
---|
2347 | if ~isempty(ref) |
---|
2348 | first_i=str2double(get(handles.first_i,'String')); |
---|
2349 | last_i=str2double(get(handles.last_i,'String')); |
---|
2350 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
2351 | first_j=str2double(get(handles.first_j,'String')); |
---|
2352 | last_j=str2double(get(handles.last_j,'String')); |
---|
2353 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
2354 | num_i_ref=first_i:incr_i:last_i; |
---|
2355 | num_j_ref=first_j:incr_j:last_j; |
---|
2356 | if isequal(mode,'displacement') |
---|
2357 | num_i1=num_i_ref; |
---|
2358 | num_i2=num_i_ref; |
---|
2359 | num_j1=num_j_ref; |
---|
2360 | num_j2=num_j_ref; |
---|
2361 | elseif isequal(mode,'pair j1-j2')% isequal(mode,'st_pair j1-j2') |
---|
2362 | num_i1=num_i_ref; |
---|
2363 | num_i2=num_i1; |
---|
2364 | num_j1=ref.num_a*ones(size(num_i_ref)); |
---|
2365 | num_j2=ref.num_b*ones(size(num_i_ref)); |
---|
2366 | elseif isequal(mode,'series(Di)') % isequal(mode,'st_series(Di)') |
---|
2367 | delta1=floor((ref.num2-ref.num1)/2); |
---|
2368 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
2369 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
2370 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
2371 | if isempty(ref.num_a) |
---|
2372 | ref.num_a=1; |
---|
2373 | end |
---|
2374 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
2375 | num_j2=num_j1; |
---|
2376 | elseif isequal(mode,'series(Dj)')%| isequal(mode,'st_series(Dj)') |
---|
2377 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
2378 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
2379 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
2380 | num_i2=num_i1; |
---|
2381 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
2382 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
2383 | end |
---|
2384 | for ifile=1:nbfield |
---|
2385 | for j=1:nbslice |
---|
2386 | file_ref=name_generator(ref.filebase,num_i1(ifile),num_j1(j),'.nc',ref.nom_type,1,num_i2(ifile),num_j2(j),ref.subdir);% |
---|
2387 | file_ref_fix1(ifile,j)={file_ref}; |
---|
2388 | if ~exist(file_ref,'file') |
---|
2389 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix1']) |
---|
2390 | filecell=[]; |
---|
2391 | return |
---|
2392 | end |
---|
2393 | end |
---|
2394 | end |
---|
2395 | end |
---|
2396 | end |
---|
2397 | |
---|
2398 | %determine reference files for fix2: |
---|
2399 | if box_test(5)==1% fix2 performed |
---|
2400 | ref=get(handles.ref_fix2,'UserData'); |
---|
2401 | if ~isempty(ref) |
---|
2402 | first_i=str2double(get(handles.first_i,'String')); |
---|
2403 | last_i=str2double(get(handles.last_i,'String')); |
---|
2404 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
2405 | first_j=str2double(get(handles.first_j,'String')); |
---|
2406 | last_j=str2double(get(handles.last_j,'String')); |
---|
2407 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
2408 | num_i_ref=first_i:incr_i:last_i; |
---|
2409 | num_j_ref=first_j:incr_j:last_j; |
---|
2410 | if isequal(mode,'displacement') |
---|
2411 | num_i1=num_i_ref; |
---|
2412 | num_i2=num_i_ref; |
---|
2413 | num_j1=num_j_ref; |
---|
2414 | num_j2=num_j_ref; |
---|
2415 | elseif isequal(mode,'pair j1-j2') |
---|
2416 | num_i1=num_i_ref; |
---|
2417 | num_i2=num_i1; |
---|
2418 | num_j1=ref.num_a; |
---|
2419 | num_j2=ref.num_b; |
---|
2420 | elseif isequal(mode,'series(Di)') |
---|
2421 | delta1=floor((ref.num2-ref.num1)/2); |
---|
2422 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
2423 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
2424 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
2425 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
2426 | num_j2=num_j1; |
---|
2427 | elseif isequal(mode,'series(Dj)') |
---|
2428 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
2429 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
2430 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
2431 | num_i2=num_i1; |
---|
2432 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
2433 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
2434 | end |
---|
2435 | for ifile=1:nbfield |
---|
2436 | for j=1:nbslice |
---|
2437 | file_ref=name_generator(ref.filebase,num_i1(ifile),num_j1(j),'.nc',ref.nom_type,1,num_i2(ifile),num_j2(j),ref.subdir);% |
---|
2438 | file_ref_fix2(ifile,j)={file_ref}; |
---|
2439 | if ~exist(file_ref,'file') |
---|
2440 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix2']) |
---|
2441 | filecell={}; |
---|
2442 | return |
---|
2443 | end |
---|
2444 | end |
---|
2445 | end |
---|
2446 | end |
---|
2447 | end |
---|
2448 | |
---|
2449 | %check dir |
---|
2450 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf output data |
---|
2451 | subdir_civ2=get(handles.subdir_civ2,'String'); |
---|
2452 | if isequal(subdir_civ1,''),subdir_civ1='CIV'; end% put default subdir |
---|
2453 | if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end% put default subdir |
---|
2454 | currentdir=pwd;%store the current working directory |
---|
2455 | [Path_ima,Name]=fileparts(filebase);%Path of the image files (.civ) |
---|
2456 | if ~exist(Path_ima,'dir') |
---|
2457 | msgbox_uvmat('ERROR',['path to images ' Path_ima ' not found']) |
---|
2458 | filecell={}; |
---|
2459 | return |
---|
2460 | end |
---|
2461 | [xx,message]=fileattrib(Path_ima); |
---|
2462 | if ~isempty(message) && ~isequal(message.UserWrite,1) |
---|
2463 | msgbox_uvmat('ERROR',['No writting access to ' Path_ima]) |
---|
2464 | filecell={}; |
---|
2465 | cd(currentdir); |
---|
2466 | return |
---|
2467 | end |
---|
2468 | |
---|
2469 | %check the existence of the netcdf and image files involved |
---|
2470 | % %%%%%%%%%%%% case CIV1 activated %%%%%%%%%%%%% |
---|
2471 | if box_test(1)==1; |
---|
2472 | detect=1; |
---|
2473 | vers=0; |
---|
2474 | subdir_civ1_new=subdir_civ1; |
---|
2475 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
2476 | for ifile=1:nbfield |
---|
2477 | for j=1:nbslice |
---|
2478 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1_new); |
---|
2479 | detect=exist(filename,'file')==2; |
---|
2480 | if detect% if a netcdf file already exists |
---|
2481 | indstr=regexp(subdir_civ1_new,'\D'); |
---|
2482 | if indstr(end)<length(subdir_civ1_new) %subdir_civ1 ends by a number |
---|
2483 | vers=str2double(subdir_civ1_new(indstr(end)+1:end))+1; |
---|
2484 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) num2str(vers)]; |
---|
2485 | else |
---|
2486 | vers=vers+1; |
---|
2487 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) '_' num2str(vers)]; |
---|
2488 | end |
---|
2489 | subdir_civ2=subdir_civ1_new; |
---|
2490 | break |
---|
2491 | end |
---|
2492 | filecell.nc.civ1(ifile,j)={filename}; |
---|
2493 | end |
---|
2494 | if detect% if a netcdf file already exists |
---|
2495 | break |
---|
2496 | end |
---|
2497 | end |
---|
2498 | |
---|
2499 | %create the new subdir_civ1 |
---|
2500 | if ~exist(fullfile(Path_ima,subdir_civ1_new),'dir') |
---|
2501 | cd(Path_ima); |
---|
2502 | [xx,msg1]=mkdir(subdir_civ1_new); |
---|
2503 | |
---|
2504 | if ~strcmp(msg1,'') |
---|
2505 | msgbox_uvmat('ERROR',['cannot create ' subdir_civ1_new ': ' msg1])%error message for directory creation |
---|
2506 | filecell={}; |
---|
2507 | return |
---|
2508 | elseif isunix |
---|
2509 | [xx,msg2] = fileattrib(subdir_civ1_new,'+w','g'); %yield writing access (+w) to user group (g) |
---|
2510 | if ~strcmp(msg2,'') |
---|
2511 | msgbox_uvmat('ERROR',['pb of permission for ' subdir_civ1_new ': ' msg2])%error message for directory creation |
---|
2512 | filecell={}; |
---|
2513 | return |
---|
2514 | end |
---|
2515 | end |
---|
2516 | cd(currentdir); |
---|
2517 | end |
---|
2518 | if strcmp(compare,'stereo PIV')&&(strcmp(mode,'pair j1-j2')||strcmp(mode,'series(Dj)')||strcmp(mode,'series(Di)'))%check second nc series |
---|
2519 | for ifile=1:nbfield |
---|
2520 | for j=1:nbslice |
---|
2521 | filename=name_generator(filebase_A,num1_civ1(ifile),num_a_civ1(j),'.nc',nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1_new);% |
---|
2522 | detect=exist(filename,'file')==2; |
---|
2523 | if detect% if a netcdf file already exists |
---|
2524 | indstr=regexp(subdir_civ1_new,'\D'); |
---|
2525 | if indstr(end)<length(subdir_civ1_new) %subdir_civ1 ends by a number |
---|
2526 | vers=str2double(subdir_civ1_new(indstr(end)+1:end))+1; |
---|
2527 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) num2str(vers)]; |
---|
2528 | else |
---|
2529 | vers=vers+1; |
---|
2530 | subdir_civ1_new=[subdir_civ1_new '_' num2str(vers)]; |
---|
2531 | end |
---|
2532 | subdir_civ2=subdir_civ1; |
---|
2533 | break |
---|
2534 | end |
---|
2535 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
2536 | end |
---|
2537 | if detect% if a netcdf file already exists |
---|
2538 | break |
---|
2539 | end |
---|
2540 | end |
---|
2541 | %create the new subdir_civ1 |
---|
2542 | if exist(fullfile(Path_ima,subdir_civ1_new),'dir') |
---|
2543 | cd(Path_ima); |
---|
2544 | [xx,msg1]=mkdir(subdir_civ1_new); |
---|
2545 | cd(currentdir); |
---|
2546 | if ~strcmp(msg1,'') |
---|
2547 | msgbox_uvmat('ERROR',['cannot create ' subdir_civ1_new ': ' msg1]) |
---|
2548 | cd(currentdir) |
---|
2549 | filecell={}; |
---|
2550 | return |
---|
2551 | else |
---|
2552 | [xx,msg2] = fileattrib(subdir_civ1_new,'+w','g'); %yield writing access (+w) to user group (g) |
---|
2553 | if ~strcmp(msg2,'') |
---|
2554 | msgbox_uvmat('ERROR',['pb of permission for ' subdir_civ1_new ': ' msg2])%error message for directory creation |
---|
2555 | cd(currentdir) |
---|
2556 | filecell={}; |
---|
2557 | return |
---|
2558 | end |
---|
2559 | end |
---|
2560 | end |
---|
2561 | end |
---|
2562 | end |
---|
2563 | subdir_civ1=subdir_civ1_new; |
---|
2564 | % get image names |
---|
2565 | for ifile=1:nbfield |
---|
2566 | for j=1:nbslice |
---|
2567 | filename=name_generator(filebase_ima1, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
2568 | idetect(j)=exist(filename,'file')==2; |
---|
2569 | filecell.ima1.civ1(ifile,j)={filename}; %first image |
---|
2570 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
2571 | idetect_1(j)=exist(filename,'file')==2; |
---|
2572 | filecell.ima2.civ1(ifile,j)={filename};%second image |
---|
2573 | end |
---|
2574 | [idetectmin,indexj]=min(idetect); |
---|
2575 | if idetectmin==0, |
---|
2576 | msgbox_uvmat('ERROR',[filecell.ima1.civ1{ifile,indexj} ' not found']) |
---|
2577 | filecell={}; |
---|
2578 | cd(currentdir) |
---|
2579 | return |
---|
2580 | end |
---|
2581 | [idetectmin,indexj]=min(idetect_1); |
---|
2582 | if idetectmin==0, |
---|
2583 | msgbox_uvmat('ERROR',[filecell.ima2.civ1{ifile,indexj} ' not found']) |
---|
2584 | filecell={}; |
---|
2585 | cd(currentdir) |
---|
2586 | return |
---|
2587 | end |
---|
2588 | end |
---|
2589 | if strcmp(compare,'stereo PIV') && (strcmp(mode,'pair j1-j2') || strcmp(mode,'series(Dj)') || strcmp(mode,'series(Di)')) |
---|
2590 | for ifile=1:nbfield |
---|
2591 | for j=1:nbslice |
---|
2592 | filename=name_generator(filebase_A, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
2593 | idetect(j)=exist(filename,'file')==2; |
---|
2594 | filecell.imaA1.civ1(ifile,j)={filename} ;%first image |
---|
2595 | filename=name_generator(filebase_A, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
2596 | idetect_1(j)=exist(filename,'file')==2; |
---|
2597 | filecell.imaA2.civ1(ifile,j)={filename};%second image |
---|
2598 | end |
---|
2599 | [idetectmin,indexj]=min(idetect); |
---|
2600 | if idetectmin==0, |
---|
2601 | msgbox_uvmat('ERROR',[filecell.imaA1.civ1{ifile,indexj} ' not found']) |
---|
2602 | filecell={}; |
---|
2603 | cd(currentdir) |
---|
2604 | return |
---|
2605 | end |
---|
2606 | [idetectmin,indexj]=min(idetect_1); |
---|
2607 | if idetectmin==0, |
---|
2608 | msgbox_uvmat('ERROR',[filecell.imaA2.civ1{ifile,indexj} ' not found']) |
---|
2609 | filecell={}; |
---|
2610 | cd(currentdir) |
---|
2611 | return |
---|
2612 | end |
---|
2613 | end |
---|
2614 | end |
---|
2615 | |
---|
2616 | %%%%%%%%%%%%% fix1 or patch1 activated but no civ1 %%%%%%%%%%%%% |
---|
2617 | elseif (box_test(2)==1 || box_test(3)==1); |
---|
2618 | for ifile=1:nbfield |
---|
2619 | for j=1:nbslice |
---|
2620 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
2621 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
2622 | detect=exist(filename,'file')==2; |
---|
2623 | if detect==0 |
---|
2624 | msgbox_uvmat('ERROR',[filename ' not found']) |
---|
2625 | filecell={}; |
---|
2626 | cd(currentdir) |
---|
2627 | return |
---|
2628 | end |
---|
2629 | filecell.nc.civ1(ifile,j)={filename}; |
---|
2630 | end |
---|
2631 | end |
---|
2632 | if strcmp(compare,'stereo PIV') |
---|
2633 | for ifile=1:nbfield |
---|
2634 | for j=1:nbslice |
---|
2635 | filename=name_generator(filebase_A,num1_civ1(ifile),num_a_civ1(j),'.nc',nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
2636 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
2637 | if ~exist(filename,'file') |
---|
2638 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
2639 | set(handles.RUN, 'Enable','On') |
---|
2640 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
2641 | filecell={}; |
---|
2642 | cd(currentdir) |
---|
2643 | return |
---|
2644 | end |
---|
2645 | end |
---|
2646 | end |
---|
2647 | end |
---|
2648 | end |
---|
2649 | |
---|
2650 | %%%%%%%%%%%%% if civ2 performed with pairs different than civ1 %%%%%%%%%%%%% |
---|
2651 | testdiff=0; |
---|
2652 | if (box_test(4)==1)&&... |
---|
2653 | ((get(handles.list_pair_civ1,'Value')~=get(handles.list_pair_civ2,'Value'))||~strcmp(subdir_civ2,subdir_civ1)) |
---|
2654 | testdiff=1; |
---|
2655 | detect=1; |
---|
2656 | vers=0; |
---|
2657 | subdir_civ2_new=subdir_civ2; |
---|
2658 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
2659 | for ifile=1:nbfield |
---|
2660 | for j=1:nbslice |
---|
2661 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2_new);% |
---|
2662 | detect=exist(filename,'file')==2; |
---|
2663 | if detect% if a netcdf file already exists |
---|
2664 | indstr=regexp(subdir_civ2,'\D'); |
---|
2665 | if indstr(end)<length(subdir_civ2) %subdir_civ1 ends by a number |
---|
2666 | vers=str2double(subdir_civ2(indstr(end)+1:end))+1; |
---|
2667 | subdir_civ2_new=[subdir_civ2(1:indstr(end)) num2str(vers)]; |
---|
2668 | else |
---|
2669 | vers=vers+1; |
---|
2670 | subdir_civ2_new=[subdir_civ1 '_' num2str(vers)]; |
---|
2671 | end |
---|
2672 | break |
---|
2673 | end |
---|
2674 | filecell.nc.civ2(ifile,j)={filename}; |
---|
2675 | end |
---|
2676 | if detect% if a netcdf file already exists |
---|
2677 | break |
---|
2678 | end |
---|
2679 | end |
---|
2680 | %create the new subdir_civ2_new |
---|
2681 | if ~exist(fullfile(Path_ima,subdir_civ2_new),'dir') |
---|
2682 | [xx,m2]=mkdir(fullfile(Path_ima,subdir_civ2_new)); |
---|
2683 | [xx,msg2] = fileattrib(subdir_civ2_new,'+w','g'); %yield writing access (+w) to user group (g) |
---|
2684 | if ~isequal(m2,'') |
---|
2685 | msgbox_uvmat('ERROR',['cannot create ' subdir_civ2_new ': ' m2]) |
---|
2686 | filecell={}; |
---|
2687 | cd(currentdir) |
---|
2688 | return |
---|
2689 | end |
---|
2690 | end |
---|
2691 | if strcmp(compare,'stereo PIV')%check second nc series |
---|
2692 | for ifile=1:nbfield |
---|
2693 | for j=1:nbslice |
---|
2694 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
2695 | nom_type_nc,1,num2_civ2(ifile),num_b_civ1(j),subdir_civ2_new);% |
---|
2696 | detect=exist(filename,'file')==2; |
---|
2697 | if detect% if a netcdf file already exists |
---|
2698 | indstr=regexp(subdir_civ2,'\D'); |
---|
2699 | if indstr(end)<length(subdir_civ2) %subdir_civ1 ends by a number |
---|
2700 | vers=str2double(subdir_civ2(indstr(end)+1:end))+1; |
---|
2701 | subdir_civ2_new=[subdir_civ2(1:indstr(end)) num2str(vers)]; |
---|
2702 | else |
---|
2703 | vers=vers+1; |
---|
2704 | subdir_civ2_new=[subdir_civ1 '_' num2str(vers)]; |
---|
2705 | end |
---|
2706 | break |
---|
2707 | end |
---|
2708 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
2709 | end |
---|
2710 | if detect% if a netcdf file already exists |
---|
2711 | break |
---|
2712 | end |
---|
2713 | end |
---|
2714 | subdir_civ2=subdir_civ2_new; |
---|
2715 | %create the new subdir_civ1 |
---|
2716 | if ~exist(fullfile(Path_ima,subdir_civ2_new),'dir') |
---|
2717 | [xx,m2]=mkdir(subdir_civ2_new); |
---|
2718 | [xx,msg2] = fileattrib(subdir_civ2_new,'+w','g'); %yield writing access (+w) to user group (g) |
---|
2719 | if ~isequal(m2,'') |
---|
2720 | msgbox_uvmat('ERROR', ['cannot create ' subdir_civ2_new ': ' m2])%error message for directory creation |
---|
2721 | cd(currentdir) |
---|
2722 | filecell={}; |
---|
2723 | return |
---|
2724 | end |
---|
2725 | end |
---|
2726 | end |
---|
2727 | end |
---|
2728 | subdir_civ2=subdir_civ2_new; |
---|
2729 | end |
---|
2730 | cd(currentdir);%come back to the current working directory |
---|
2731 | |
---|
2732 | %%%%%%%%%%%%% if civ2 results are obtained or used %%%%%%%%%%%%% |
---|
2733 | if box_test(4)==1 || box_test(5)==1 || box_test(6)==1 %civ2 |
---|
2734 | %check source netcdf file of civ1 estimates |
---|
2735 | if box_test(1)==0; %no civ1 performed |
---|
2736 | for ifile=1:nbfield |
---|
2737 | for j=1:nbslice |
---|
2738 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
2739 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
2740 | filecell.nc.civ1(ifile,j)={filename};% name of the civ1 file |
---|
2741 | if ~exist(filename,'file') |
---|
2742 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
2743 | filecell={}; |
---|
2744 | return |
---|
2745 | end |
---|
2746 | if ~testdiff % civ2 or patch2 are written in the same file as civ1 |
---|
2747 | if box_test(4)==0 ; %check the existence of civ2 if it is not calculated |
---|
2748 | Data=nc2struct(filename,'ListGlobalAttribute','CivStage','civ2'); |
---|
2749 | if ~isempty(Data.CivStage) && Data.CivStage<4 %test for civ files |
---|
2750 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
2751 | filecell=[]; |
---|
2752 | return |
---|
2753 | elseif isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
2754 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
2755 | filecell=[]; |
---|
2756 | return |
---|
2757 | end |
---|
2758 | elseif box_test(3)==0; %check the existence of patch if it is not calculated |
---|
2759 | Data=nc2struct(filename,'ListGlobalAttribute','CivStage','patch') |
---|
2760 | if ~isempty(Data.CivStage) |
---|
2761 | if Data.CivStage<3 %test for civ files |
---|
2762 | msgbox_uvmat('ERROR',['no patch data in ' filename]) |
---|
2763 | filecell=[]; |
---|
2764 | return |
---|
2765 | end |
---|
2766 | elseif isempty(Data.patch)||isequal(Data.patch,0) |
---|
2767 | msgbox_uvmat('ERROR',['no patch data in ' filename]) |
---|
2768 | filecell=[]; |
---|
2769 | return |
---|
2770 | end |
---|
2771 | end |
---|
2772 | end |
---|
2773 | end |
---|
2774 | end |
---|
2775 | if strcmp(compare,'stereo PIV') |
---|
2776 | for ifile=1:nbfield |
---|
2777 | for j=1:nbslice |
---|
2778 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
2779 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
2780 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
2781 | if ~exist(filename,'file') |
---|
2782 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
2783 | set(handles.RUN, 'Enable','On') |
---|
2784 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
2785 | return |
---|
2786 | end |
---|
2787 | end |
---|
2788 | end |
---|
2789 | end |
---|
2790 | end |
---|
2791 | |
---|
2792 | detect=1; |
---|
2793 | % while detect==1%creates a new subdir if the netcdf files already contain civ2 data |
---|
2794 | for ifile=1:nbfield |
---|
2795 | for j=1:nbslice |
---|
2796 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
2797 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2); |
---|
2798 | detect=exist(filename,'file')==2; |
---|
2799 | filecell.nc.civ2(ifile,j)={filename}; |
---|
2800 | end |
---|
2801 | end |
---|
2802 | %get first image names for civ2 |
---|
2803 | if box_test(1)==1 & isequal(num1_civ1,num1_civ2) & isequal(num_a_civ1,num_a_civ2) |
---|
2804 | filecell.ima1.civ2=filecell.ima1.civ1; |
---|
2805 | elseif box_test(4)==1 |
---|
2806 | for ifile=1:nbfield |
---|
2807 | for j=1:nbslice |
---|
2808 | filename=name_generator(filebase_ima1, num1_civ2(ifile),num_a_civ2(j),ext_ima,nom_type_ima1); |
---|
2809 | idetect_2(j)=exist(filename,'file')==2; |
---|
2810 | filecell.ima1.civ2(ifile,j)={filename};%first image |
---|
2811 | end |
---|
2812 | [idetectmin,indexj]=min(idetect_2); |
---|
2813 | if idetectmin==0, |
---|
2814 | msgbox_uvmat('ERROR',['input image ' filecell.ima1.civ2{ifile,indexj} ' not found']) |
---|
2815 | filecell=[]; |
---|
2816 | return |
---|
2817 | end |
---|
2818 | end |
---|
2819 | end |
---|
2820 | |
---|
2821 | %get second image names for civ2 |
---|
2822 | if box_test(1)==1 & isequal(num2_civ1,num2_civ2) & isequal(num_b_civ1,num_b_civ2) |
---|
2823 | filecell.ima2.civ2=filecell.ima2.civ1; |
---|
2824 | elseif box_test(4)==1 |
---|
2825 | for ifile=1:nbfield |
---|
2826 | for j=1:nbslice |
---|
2827 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),ext_ima,nom_type_ima2); |
---|
2828 | idetect_3(j)=exist(filename,'file')==2; |
---|
2829 | filecell.ima2.civ2(ifile,j)={filename};%first image |
---|
2830 | end |
---|
2831 | [idetectmin,indexj]=min(idetect_3); |
---|
2832 | if idetectmin==0, |
---|
2833 | msgbox_uvmat('ERROR',['input image ' filecell.ima2.civ2{ifile,indexj} ' not found']) |
---|
2834 | filecell=[]; |
---|
2835 | return |
---|
2836 | end |
---|
2837 | end |
---|
2838 | end |
---|
2839 | end |
---|
2840 | if (box_test(5)==1 || box_test(6)==1 ) && box_test(4)==0 % need to read an existing netcdf civ2 file |
---|
2841 | if ~testdiff |
---|
2842 | filecell.nc.civ2=filecell.nc.civ1;% file already checked |
---|
2843 | else % check the civ2 files |
---|
2844 | for ifile=1:nbfield |
---|
2845 | for j=1:nbslice |
---|
2846 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
2847 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
2848 | filecell.nc.civ2(ifile,j)={filename}; |
---|
2849 | if ~exist(filename,'file') |
---|
2850 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
2851 | filecell=[]; |
---|
2852 | return |
---|
2853 | else |
---|
2854 | Data=nc2struct(filename,'ListGlobalAttribute','CivStage','civ2'); |
---|
2855 | if ~isempty(Data.CivStage) && Data.CivStage<4 %test for civ files |
---|
2856 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
2857 | filecell=[]; |
---|
2858 | return |
---|
2859 | elseif isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
2860 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
2861 | filecell=[]; |
---|
2862 | return |
---|
2863 | end |
---|
2864 | end |
---|
2865 | end |
---|
2866 | end |
---|
2867 | end |
---|
2868 | end |
---|
2869 | |
---|
2870 | %%%%%%%%%%%%% if stereo fields are calculated by PATCH %%%%%%%%%%%%% |
---|
2871 | if strcmp(compare,'stereo PIV') |
---|
2872 | if box_test(3)==1 && isequal(get(handles.test_stereo1,'Value'),1) |
---|
2873 | for ifile=1:nbfield |
---|
2874 | for j=1:nbslice |
---|
2875 | filename=name_generator(filebase_AB,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
2876 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
2877 | filecell.st(ifile,j)={filename}; |
---|
2878 | end |
---|
2879 | end |
---|
2880 | end |
---|
2881 | if box_test(6)==1 && isequal(get(handles.test_stereo2,'Value'),1) |
---|
2882 | for ifile=1:nbfield |
---|
2883 | for j=1:nbslice |
---|
2884 | filename=name_generator(filebase_AB,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
2885 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
2886 | filecell.st(ifile,j)={filename}; |
---|
2887 | end |
---|
2888 | end |
---|
2889 | end |
---|
2890 | end |
---|
2891 | set(handles.subdir_civ1,'String',subdir_civ1);%update the edit box |
---|
2892 | set(handles.subdir_civ2,'String',subdir_civ2);%update the edit box |
---|
2893 | browse.nom_type_nc=nom_type_nc; |
---|
2894 | set(handles.browse_root,'UserData',browse); %update the nomenclature type for uvmat |
---|
2895 | |
---|
2896 | |
---|
2897 | %COPY IMAGES TO THE FORMAT .png IF NEEDED |
---|
2898 | if isequal(nom_type_ima1,'*')%case of movie files |
---|
2899 | nom_type_imanew1='_i'; |
---|
2900 | else |
---|
2901 | nom_type_imanew1=nom_type_ima1; |
---|
2902 | end |
---|
2903 | if isequal(nom_type_ima2,'*')%case of movie files |
---|
2904 | nom_type_imanew2='_i'; |
---|
2905 | else |
---|
2906 | nom_type_imanew2=nom_type_ima2; |
---|
2907 | end |
---|
2908 | if ~isequal(ext_ima,'.png') |
---|
2909 | %%type of image file |
---|
2910 | type_ima1='none';%default |
---|
2911 | movieobject1=[];%default |
---|
2912 | if strcmpi(ext_ima,'.avi') |
---|
2913 | hhh=which('mmreader'); |
---|
2914 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
---|
2915 | type_ima1='movie'; |
---|
2916 | movieobject1=mmreader([filebase_ima2 ext_ima]); |
---|
2917 | else |
---|
2918 | type_ima1='avi'; |
---|
2919 | end |
---|
2920 | elseif ischar(ext_ima) && ~isempty(ext_ima(2:end)) |
---|
2921 | form=imformats(ext_ima(2:end)); |
---|
2922 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
2923 | if isequal(nom_type_ima1,'*'); |
---|
2924 | type_ima1='multimage';%image series in a single image file |
---|
2925 | else |
---|
2926 | type_ima1='image'; |
---|
2927 | end |
---|
2928 | end |
---|
2929 | end |
---|
2930 | type_ima2='none';%default |
---|
2931 | movieobject2=[]; |
---|
2932 | if strcmpi(ext_ima,'.avi') |
---|
2933 | hhh=which('mmreader'); |
---|
2934 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
---|
2935 | type_ima2='movie'; |
---|
2936 | movieobject2=mmreader([filebase_ima2 ext_ima]); |
---|
2937 | else |
---|
2938 | type_ima2='avi'; |
---|
2939 | end |
---|
2940 | elseif ischar(ext_ima) && ~isempty(ext_ima(2:end)) |
---|
2941 | form=imformats(ext_ima(2:end)); |
---|
2942 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
2943 | if isequal(nom_type_ima1,'*'); |
---|
2944 | type_ima2='multimage';%image series in a single image file |
---|
2945 | else |
---|
2946 | type_ima2='image'; |
---|
2947 | end |
---|
2948 | end |
---|
2949 | end |
---|
2950 | %npxy=get(handles.ImaExt,'UserData'); |
---|
2951 | % % if numel(npxy)<2 |
---|
2952 | % |
---|
2953 | % filename=name_generator(filebase_ima1,num1_civ1(1),num_a_civ1(1),ImaExt,nom_type_ima1); |
---|
2954 | % A=imread(filename); |
---|
2955 | % npxy=size(A); |
---|
2956 | % % end |
---|
2957 | % npy=npxy(1); |
---|
2958 | % npx=npxy(2); |
---|
2959 | if box_test(1)==1 %if civ1 is performed |
---|
2960 | h = waitbar(0,'copy images to the .png format for civ1');% display a wait bar |
---|
2961 | for ifile=1:nbfield |
---|
2962 | waitbar(ifile/nbfield); |
---|
2963 | for j=1:nbslice |
---|
2964 | filename=name_generator(filebase_ima1,num1_civ1(ifile),num_a_civ1(j),'.png',nom_type_imanew1); |
---|
2965 | if ~exist(filename,'file') |
---|
2966 | A=read_image(filecell.ima1.civ1{ifile,j},type_ima1,num1_civ1(ifile),movieobject1); |
---|
2967 | imwrite(A,filename,'BitDepth',16); |
---|
2968 | end |
---|
2969 | filecell.ima1.civ1(ifile,j)={filename}; |
---|
2970 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),'.png',nom_type_imanew2); |
---|
2971 | if ~exist(filename,'file') |
---|
2972 | A=read_image(filecell.ima2.civ1{ifile,j},type_ima2,num2_civ1(ifile),movieobject2); |
---|
2973 | imwrite(A,filename,'BitDepth',16); |
---|
2974 | end |
---|
2975 | filecell.ima2.civ1(ifile,j)={filename}; |
---|
2976 | end |
---|
2977 | end |
---|
2978 | close(h) |
---|
2979 | end |
---|
2980 | if box_test(4)==1 %if civ2 is performed |
---|
2981 | h = waitbar(0,'copy images to the .png format for civ2');% display a wait bar |
---|
2982 | for ifile=1:nbfield |
---|
2983 | waitbar(ifile/nbfield); |
---|
2984 | for j=1:nbslice |
---|
2985 | filename=name_generator(filebase_ima1,num1_civ2(ifile),num_a_civ2(j),'.png',nom_type_imanew1); |
---|
2986 | if ~exist(filename,'file') |
---|
2987 | A=read_image(cell2mat(filecell.ima1.civ2(ifile,j)),type_ima2,num1_civ2(ifile)); |
---|
2988 | imwrite(A,filename,'BitDepth',16); |
---|
2989 | end |
---|
2990 | filecell.ima1.civ2(ifile,j)={filename}; |
---|
2991 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),'.png',nom_type_imanew2); |
---|
2992 | if ~exist(filename,'file') |
---|
2993 | A=read_image(cell2mat(filecell.ima2.civ2(ifile,j)),type_ima2,num2_civ2(ifile)); |
---|
2994 | imwrite(A,filename,'BitDepth',16); |
---|
2995 | end |
---|
2996 | filecell.ima2.civ2(ifile,j)={filename}; |
---|
2997 | end |
---|
2998 | end |
---|
2999 | close(h); |
---|
3000 | end |
---|
3001 | end |
---|
3002 | |
---|
3003 | %------------------------------------------------------------------------ |
---|
3004 | % --- determine the list of index pairs of processing file |
---|
3005 | function [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
3006 | find_pair_indices(handles,ref_i,ref_j,mode) |
---|
3007 | %------------------------------------------------------------------------ |
---|
3008 | |
---|
3009 | list_civ1=get(handles.list_pair_civ1,'String'); |
---|
3010 | index_civ1=get(handles.list_pair_civ1,'Value'); |
---|
3011 | str_civ1=list_civ1{index_civ1};%string defining the image pairs for civ1 |
---|
3012 | if isempty(str_civ1)||isequal(str_civ1,'') |
---|
3013 | msgbox_uvmat('ERROR','no image pair selected for civ1') |
---|
3014 | return |
---|
3015 | end |
---|
3016 | list_civ2=get(handles.list_pair_civ2,'String'); |
---|
3017 | index_civ2=get(handles.list_pair_civ2,'Value'); |
---|
3018 | if index_civ2>length(list_civ2) |
---|
3019 | list_civ2=list_civ1; |
---|
3020 | index_civ2=index_civ1; |
---|
3021 | end |
---|
3022 | str_civ2=list_civ2{index_civ2};%string defining the image pairs for civ2 |
---|
3023 | |
---|
3024 | if isequal (mode,'series(Di)') |
---|
3025 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
3026 | num1_civ1=ref_i-floor(index_civ1/2)*ones(size(ref_i));% set of first image numbers |
---|
3027 | num2_civ1=ref_i+ceil(index_civ1/2)*ones(size(ref_i)); |
---|
3028 | num_a_civ1=ref_j; |
---|
3029 | num_b_civ1=ref_j; |
---|
3030 | num1_civ2=ref_i-floor(index_civ2/2)*ones(size(ref_i)); |
---|
3031 | num2_civ2=ref_i+ceil(index_civ2/2)*ones(size(ref_i)); |
---|
3032 | num_a_civ2=ref_j; |
---|
3033 | num_b_civ2=ref_j; |
---|
3034 | |
---|
3035 | % adjust the first and last field number |
---|
3036 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
3037 | if isnan(lastfield) |
---|
3038 | indsel=find((num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
3039 | else |
---|
3040 | indsel=find((num2_civ1 <= lastfield)&(num2_civ2 <= lastfield)&(num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
3041 | end |
---|
3042 | if length(indsel)>=1 |
---|
3043 | firstind=indsel(1); |
---|
3044 | lastind=indsel(end); |
---|
3045 | set(handles.first_i,'String',num2str(ref_i(firstind)))%update the display of first and last fields |
---|
3046 | set(handles.last_i,'String',num2str(ref_i(lastind))) |
---|
3047 | ref_i=ref_i(indsel); |
---|
3048 | num1_civ1=num1_civ1(indsel); |
---|
3049 | num1_civ2=num1_civ2(indsel); |
---|
3050 | num2_civ1=num2_civ1(indsel); |
---|
3051 | num2_civ2=num2_civ2(indsel); |
---|
3052 | end |
---|
3053 | elseif isequal (mode,'series(Dj)') |
---|
3054 | lastfield_j=str2double(get(handles.nb_field2,'String')); |
---|
3055 | num1_civ1=ref_i;% set of first image numbers |
---|
3056 | num2_civ1=ref_i; |
---|
3057 | num_a_civ1=ref_j-floor(index_civ1/2)*ones(size(ref_j)); |
---|
3058 | num_b_civ1=ref_j+ceil(index_civ1/2)*ones(size(ref_j)); |
---|
3059 | num1_civ2=ref_i; |
---|
3060 | num2_civ2=ref_i; |
---|
3061 | num_a_civ2=ref_j-floor(index_civ2/2)*ones(size(ref_j)); |
---|
3062 | num_b_civ2=ref_j+ceil(index_civ2/2)*ones(size(ref_j)); |
---|
3063 | % adjust the first and last field number |
---|
3064 | if isnan(lastfield_j) |
---|
3065 | indsel=find((num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
3066 | else |
---|
3067 | indsel=find((num_b_civ1 <= lastfield_j)&(num_b_civ2 <= lastfield_j)&(num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
3068 | end |
---|
3069 | if length(indsel)>=1 |
---|
3070 | firstind=indsel(1); |
---|
3071 | lastind=indsel(end); |
---|
3072 | set(handles.first_j,'String',num2str(ref_j(firstind)))%update the display of first and last fields |
---|
3073 | set(handles.last_j,'String',num2str(ref_j(lastind))) |
---|
3074 | ref_j=ref_j(indsel); |
---|
3075 | num_a_civ1=num_a_civ1(indsel); |
---|
3076 | num_b_civ1=num_b_civ1(indsel); |
---|
3077 | num_a_civ2=num_a_civ2(indsel); |
---|
3078 | num_b_civ2=num_b_civ2(indsel); |
---|
3079 | end |
---|
3080 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
3081 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
3082 | num1_civ1=ref_i; |
---|
3083 | num2_civ1=ref_i; |
---|
3084 | num_a_civ1=displ_num(1,index_civ1); |
---|
3085 | num_b_civ1=displ_num(2,index_civ1); |
---|
3086 | num1_civ2=ref_i; |
---|
3087 | num2_civ2=ref_i; |
---|
3088 | num_a_civ2=displ_num(1,index_civ2); |
---|
3089 | num_b_civ2=displ_num(2,index_civ2); |
---|
3090 | elseif isequal(mode,'displacement') |
---|
3091 | num1_civ1=ref_i; |
---|
3092 | num2_civ1=ref_i; |
---|
3093 | num_a_civ1=ref_j; |
---|
3094 | num_b_civ1=ref_j; |
---|
3095 | num1_civ2=ref_i; |
---|
3096 | num2_civ2=ref_i; |
---|
3097 | num_a_civ2=ref_j; |
---|
3098 | num_b_civ2=ref_j; |
---|
3099 | end |
---|
3100 | |
---|
3101 | |
---|
3102 | %------------------------------------------------------------------------ |
---|
3103 | % --- PATCH |
---|
3104 | function cmd_PATCH=PATCH_CMD(filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,test_interp,PatchBin) |
---|
3105 | %------------------------------------------------------------------------ |
---|
3106 | namelog=[filename_nc(1:end-3) '_patch.log']; |
---|
3107 | if test_interp==0 |
---|
3108 | if isunix |
---|
3109 | cmd_PATCH=[PatchBin ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ... |
---|
3110 | ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
3111 | else |
---|
3112 | cmd_PATCH=['"' PatchBin '" -f "' filename_nc '" -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ... |
---|
3113 | ' > "' namelog '" 2>&1']; % redirect standard output to the log file |
---|
3114 | end |
---|
3115 | else %nouveau programme patch |
---|
3116 | cmd_PATCH=[PatchBin ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ... |
---|
3117 | ' -max ' thresh_value ' -nopt ' subdomain_patch ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
3118 | end |
---|
3119 | cmd_PATCH=regexprep(cmd_PATCH,'\\','\\\\'); |
---|
3120 | %------------------------------------------------------------------------ |
---|
3121 | % --- STEREO Interp |
---|
3122 | function cmd=RUN_STINTERP(stinterpBin,filename_A_nc,filename_B_nc,filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,xmlA,xmlB) |
---|
3123 | %------------------------------------------------------------------------ |
---|
3124 | namelog=[filename_nc(1:end-3) '_stinterp.log']; |
---|
3125 | cmd=[stinterpBin ' -f1 ' filename_A_nc ' -f2 ' filename_B_nc ' -f ' filename_nc ... |
---|
3126 | ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ' -c1 ' xmlA ' -c2 ' xmlB ' -xy x -Nfy 1024 > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
3127 | |
---|
3128 | %------------------------------------------------------------------------ |
---|
3129 | % --- Executes on button press in CIV1. |
---|
3130 | function CIV1_Callback(hObject, eventdata, handles) |
---|
3131 | %------------------------------------------------------------------------ |
---|
3132 | val=get(handles.CIV1,'Value'); |
---|
3133 | if isequal(val,1) |
---|
3134 | enable_civ1(handles,'on') |
---|
3135 | enable_pair1(handles,'on') |
---|
3136 | else |
---|
3137 | enable_civ1(handles,'off') |
---|
3138 | end |
---|
3139 | find_netcpair_civ1(hObject, eventdata, handles); |
---|
3140 | |
---|
3141 | %------------------------------------------------------------------------ |
---|
3142 | % --- Executes on button press in FIX1. |
---|
3143 | function FIX1_Callback(hObject, eventdata, handles) |
---|
3144 | %------------------------------------------------------------------------ |
---|
3145 | enable_fix1(handles,get(handles.FIX1,'Value')) |
---|
3146 | |
---|
3147 | %------------------------------------------------------------------------ |
---|
3148 | % --- Executes on button press in PATCH1. |
---|
3149 | function PATCH1_Callback(hObject, eventdata, handles) |
---|
3150 | %------------------------------------------------------------------------ |
---|
3151 | if get(handles.PATCH1,'Value')==1 |
---|
3152 | enable_patch1(handles) |
---|
3153 | else |
---|
3154 | desable_patch1(handles) |
---|
3155 | end |
---|
3156 | |
---|
3157 | %------------------------------------------------------------------------ |
---|
3158 | % --- Executes on button press in CIV2. |
---|
3159 | function CIV2_Callback(hObject, eventdata, handles) |
---|
3160 | %------------------------------------------------------------------------ |
---|
3161 | state=get(handles.CIV2,'Value'); |
---|
3162 | enable_civ2(handles,state) |
---|
3163 | if state |
---|
3164 | find_netcpair_civ2(hObject, eventdata, handles) |
---|
3165 | enable_pair1(handles,'on') |
---|
3166 | end |
---|
3167 | |
---|
3168 | %------------------------------------------------------------------------ |
---|
3169 | % --- Executes on button press in FIX2. |
---|
3170 | function FIX2_Callback(hObject, eventdata, handles) |
---|
3171 | %------------------------------------------------------------------------ |
---|
3172 | if get(handles.FIX2,'Value')==1 |
---|
3173 | enable_fix2(handles) |
---|
3174 | if get(handles.CIV2,'Value')==0 |
---|
3175 | find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files |
---|
3176 | end |
---|
3177 | else |
---|
3178 | desable_fix2(handles) |
---|
3179 | end |
---|
3180 | |
---|
3181 | %------------------------------------------------------------------------ |
---|
3182 | % --- Executes on button press in PATCH2. |
---|
3183 | function PATCH2_Callback(hObject, eventdata, handles) |
---|
3184 | %------------------------------------------------------------------------ |
---|
3185 | if get(handles.PATCH2,'Value')==1 |
---|
3186 | enable_patch2(handles) |
---|
3187 | if get(handles.CIV2,'Value')==0 |
---|
3188 | find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files |
---|
3189 | end |
---|
3190 | else |
---|
3191 | desable_patch2(handles) |
---|
3192 | end |
---|
3193 | |
---|
3194 | %------------------------------------------------------------------------ |
---|
3195 | function first_i_Callback(hObject, eventdata, handles) |
---|
3196 | %------------------------------------------------------------------------ |
---|
3197 | % last_i_Callback(hObject, eventdata, handles) |
---|
3198 | first_i=str2double(get(handles.first_i,'String')); |
---|
3199 | % last_i=str2num(get(handles.last_i,'String')); |
---|
3200 | % ref_i=ceil((first_i+last_i)/2); |
---|
3201 | set(handles.ref_i,'String', num2str(first_i))% reference index for pair dt = first index |
---|
3202 | set(handles.ref_i_civ2,'String', num2str(first_i))% reference index for pair dt = first index |
---|
3203 | ref_i_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
3204 | |
---|
3205 | %------------------------------------------------------------------------ |
---|
3206 | function first_j_Callback(hObject, eventdata, handles) |
---|
3207 | %------------------------------------------------------------------------ |
---|
3208 | first_j=str2num(get(handles.first_j,'String')); |
---|
3209 | set(handles.ref_j,'String', num2str(first_j))% reference index for pair dt = first index |
---|
3210 | ref_j_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
3211 | |
---|
3212 | %------------------------------------------------------------------------ |
---|
3213 | % --- Executes on button press in calcul_search: determine the search range isx,isy |
---|
3214 | function calcul_search_Callback(hObject, eventdata, handles) |
---|
3215 | %------------------------------------------------------------------------ |
---|
3216 | %determine pair numbers |
---|
3217 | list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs |
---|
3218 | index=get(handles.list_pair_civ1,'Value'); |
---|
3219 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
3220 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
3221 | pxcm_xy=get(handles.calcul_search,'UserData'); |
---|
3222 | pxcmx=pxcm_xy(1); |
---|
3223 | pxcmy=pxcm_xy(2); |
---|
3224 | mode_list=get(handles.mode,'String'); |
---|
3225 | mode_value=get(handles.mode,'Value'); |
---|
3226 | mode=mode_list{mode_value}; |
---|
3227 | if isequal (mode, 'series(Di)' ) |
---|
3228 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
3229 | num1=ref_i-floor(index/2);% first image numbers |
---|
3230 | num2=ref_i+ceil(index/2); |
---|
3231 | num_a=1; |
---|
3232 | num_b=1; |
---|
3233 | elseif isequal (mode, 'series(Dj)') |
---|
3234 | num1=1; |
---|
3235 | num2=1; |
---|
3236 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
3237 | num_a=ref_j-floor(index/2);% first image numbers |
---|
3238 | num_b=ref_j+ceil(index/2); |
---|
3239 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
3240 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
3241 | num1=ref_i; |
---|
3242 | num2=ref_i; |
---|
3243 | num_a=displ_num(1,index); |
---|
3244 | num_b=displ_num(2,index); |
---|
3245 | end |
---|
3246 | dt=time(num2,num_b)-time(num1,num_a); |
---|
3247 | ibx=str2double(get(handles.ibx,'String')); |
---|
3248 | iby=str2double(get(handles.iby,'String')); |
---|
3249 | umin=dt*pxcmx*str2double(get(handles.umin,'String')); |
---|
3250 | umax=dt*pxcmx*str2double(get(handles.umax,'String')); |
---|
3251 | vmin=dt*pxcmy*str2double(get(handles.vmin,'String')); |
---|
3252 | vmax=dt*pxcmy*str2double(get(handles.vmax,'String')); |
---|
3253 | shiftx=round((umin+umax)/2); |
---|
3254 | shifty=round((vmin+vmax)/2); |
---|
3255 | isx=(umax+2-shiftx)*2+ibx; |
---|
3256 | isx=2*ceil(isx/2)+1; |
---|
3257 | isy=(vmax+2-shifty)*2+iby; |
---|
3258 | isy=2*ceil(isy/2)+1; |
---|
3259 | set(handles.shiftx,'String',num2str(shiftx)); |
---|
3260 | set(handles.shifty,'String',num2str(shifty)); |
---|
3261 | set(handles.isx,'String',num2str(isx)); |
---|
3262 | set(handles.isy,'String',num2str(isy)); |
---|
3263 | |
---|
3264 | %------------------------------------------------------------------------ |
---|
3265 | % --- Executes on carriage return on the subdir civ1 edit window |
---|
3266 | function subdir_civ1_Callback(hObject, eventdata, handles) |
---|
3267 | %------------------------------------------------------------------------ |
---|
3268 | subdir=get(handles.subdir_civ1,'String'); |
---|
3269 | set(handles.subdir_civ2,'String',subdir); |
---|
3270 | if get(handles.CIV1,'Value')==0 |
---|
3271 | find_netcpair_civ1(hObject, eventdata, handles); %update the list of available pairs from netcdf files in the new directory |
---|
3272 | end |
---|
3273 | |
---|
3274 | %------------------------------------------------------------------------ |
---|
3275 | % --- Executes on carriage return on the subdir civ1 edit window |
---|
3276 | function subdir_civ2_Callback(hObject, eventdata, handles) |
---|
3277 | %------------------------------------------------------------------------ |
---|
3278 | %update the list of available pairs from netcdf files in the new directory |
---|
3279 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0 |
---|
3280 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
3281 | end |
---|
3282 | |
---|
3283 | %------------------------------------------------------------------------ |
---|
3284 | % --- Executes on button press in get_mask_civ1: select box for mask option |
---|
3285 | function get_mask_civ1_Callback(hObject, eventdata, handles) |
---|
3286 | %------------------------------------------------------------------------ |
---|
3287 | maskval=get(handles.get_mask_civ1,'Value') |
---|
3288 | if isequal(maskval,0) |
---|
3289 | set(handles.mask_civ1,'String','') |
---|
3290 | else |
---|
3291 | mask_displ='no mask'; %default |
---|
3292 | filebase=get(handles.RootName,'String'); |
---|
3293 | [ nbslice_mask, flag_mask]=get_mask(filebase,handles); |
---|
3294 | if isequal(flag_mask,1) |
---|
3295 | mask_displ=[num2str(nbslice_mask) 'mask']; |
---|
3296 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
3297 | common_path=fileparts(filebase); |
---|
3298 | filebase_a=fullfile(common_path,get(handles.RootName_1,'String')); |
---|
3299 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
3300 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice_mask) |
---|
3301 | mask_displ='no mask'; |
---|
3302 | end |
---|
3303 | end |
---|
3304 | if isequal(mask_displ,'no mask') |
---|
3305 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
3306 | {'*.png', ' (*.png)'; |
---|
3307 | '*.png', '.png files '; ... |
---|
3308 | '*.*', 'All Files (*.*)'}, ... |
---|
3309 | 'Pick a mask file *.png',filebase); |
---|
3310 | mask_displ=fullfile(PathName,FileName); |
---|
3311 | if ~exist(mask_displ,'file') |
---|
3312 | mask_displ='no mask'; |
---|
3313 | end |
---|
3314 | end |
---|
3315 | if isequal(mask_displ,'no mask') |
---|
3316 | set(handles.get_mask_civ1,'Value',0) |
---|
3317 | set(handles.get_mask_fix1,'Value',0) |
---|
3318 | set(handles.get_mask_civ2,'Value',0) |
---|
3319 | set(handles.get_mask_fix2,'Value',0) |
---|
3320 | else |
---|
3321 | set(handles.get_mask_fix1,'Value',1) |
---|
3322 | set(handles.get_mask_fix2,'Value',1) |
---|
3323 | end |
---|
3324 | set(handles.mask_civ1,'String',mask_displ) |
---|
3325 | set(handles.mask_fix1,'String',mask_displ) |
---|
3326 | set(handles.mask_civ2,'String',mask_displ) |
---|
3327 | set(handles.mask_fix2,'String',mask_displ) |
---|
3328 | end |
---|
3329 | set(handles.get_mask_civ2,'Value',maskval)%update the civ2 mask with the same option as civ1 |
---|
3330 | |
---|
3331 | %------------------------------------------------------------------------ |
---|
3332 | % --- Executes on button press in get_mask_fix1. |
---|
3333 | function get_mask_fix1_Callback(hObject, eventdata, handles) |
---|
3334 | %------------------------------------------------------------------------ |
---|
3335 | maskval=get(handles.get_mask_fix1,'Value'); |
---|
3336 | if isequal(maskval,0) |
---|
3337 | set(handles.mask_fix1,'String','') |
---|
3338 | else |
---|
3339 | mask_displ='no mask'; %default |
---|
3340 | filebase=get(handles.RootName,'String'); |
---|
3341 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
3342 | if isequal(flag_mask,1) |
---|
3343 | mask_displ=[num2str(nbslice) 'mask']; |
---|
3344 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
3345 | filebase_a=get(handles.RootName_1,'String'); |
---|
3346 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
3347 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
3348 | mask_displ='no mask'; |
---|
3349 | end |
---|
3350 | end |
---|
3351 | if isequal(mask_displ,'no mask') |
---|
3352 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
3353 | {'*.png', ' (*.png)'; |
---|
3354 | '*.png', '.png files '; ... |
---|
3355 | '*.*', 'All Files (*.*)'}, ... |
---|
3356 | 'Pick a mask file *.png',filebase); |
---|
3357 | mask_displ=fullfile(PathName,FileName); |
---|
3358 | if ~exist(mask_displ,'file') |
---|
3359 | mask_displ='no mask'; |
---|
3360 | end |
---|
3361 | end |
---|
3362 | if isequal(mask_displ,'no mask') |
---|
3363 | set(handles.get_mask_fix1,'Value',0) |
---|
3364 | set(handles.get_mask_civ2,'Value',0) |
---|
3365 | set(handles.get_mask_fix2,'Value',0) |
---|
3366 | else |
---|
3367 | %set(handles.get_mask_civ2,'Value',1) |
---|
3368 | set(handles.get_mask_fix2,'Value',1) |
---|
3369 | end |
---|
3370 | set(handles.mask_fix1,'String',mask_displ) |
---|
3371 | set(handles.mask_civ2,'String',mask_displ) |
---|
3372 | set(handles.mask_fix2,'String',mask_displ) |
---|
3373 | end |
---|
3374 | |
---|
3375 | %------------------------------------------------------------------------ |
---|
3376 | % --- Executes on button press in get_mask_civ2: select box for mask option |
---|
3377 | function get_mask_civ2_Callback(hObject, eventdata, handles) |
---|
3378 | %------------------------------------------------------------------------ |
---|
3379 | maskval=get(handles.get_mask_civ2,'Value'); |
---|
3380 | if isequal(maskval,0) |
---|
3381 | set(handles.mask_civ2,'String','') |
---|
3382 | else |
---|
3383 | mask_displ='no mask'; %default |
---|
3384 | filebase=get(handles.RootName,'String'); |
---|
3385 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
3386 | if isequal(flag_mask,1) |
---|
3387 | mask_displ=[num2str(nbslice) 'mask']; |
---|
3388 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
3389 | filebase_a=get(handles.RootName_1,'String'); |
---|
3390 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
3391 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
3392 | mask_displ='no mask'; |
---|
3393 | end |
---|
3394 | end |
---|
3395 | if isequal(mask_displ,'no mask') |
---|
3396 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
3397 | {'*.png', ' (*.png)'; |
---|
3398 | '*.png', '.png files '; ... |
---|
3399 | '*.*', 'All Files (*.*)'}, ... |
---|
3400 | 'Pick a mask file *.png',filebase); |
---|
3401 | mask_displ=fullfile(PathName,FileName); |
---|
3402 | if ~exist(mask_displ,'file') |
---|
3403 | mask_displ='no mask'; |
---|
3404 | end |
---|
3405 | end |
---|
3406 | if isequal(mask_displ,'no mask') |
---|
3407 | set(handles.get_mask_civ2,'Value',0) |
---|
3408 | set(handles.get_mask_fix2,'Value',0) |
---|
3409 | else |
---|
3410 | set(handles.get_mask_fix2,'Value',1) |
---|
3411 | end |
---|
3412 | set(handles.mask_civ2,'String',mask_displ) |
---|
3413 | set(handles.mask_fix2,'String',mask_displ) |
---|
3414 | end |
---|
3415 | |
---|
3416 | %------------------------------------------------------------------------ |
---|
3417 | % --- Executes on button press in get_mask_fix2. |
---|
3418 | function get_mask_fix2_Callback(hObject, eventdata, handles) |
---|
3419 | %------------------------------------------------------------------------ |
---|
3420 | maskval=get(handles.get_mask_fix2,'Value'); |
---|
3421 | if isequal(maskval,0) |
---|
3422 | set(handles.mask_fix2,'String','') |
---|
3423 | else |
---|
3424 | mask_displ='no mask'; %default |
---|
3425 | filebase=get(handles.RootName,'String'); |
---|
3426 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
3427 | if isequal(flag_mask,1) |
---|
3428 | mask_displ=[num2str(nbslice) 'mask']; |
---|
3429 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
3430 | filebase_a=get(handles.RootName_1,'String'); |
---|
3431 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
3432 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
3433 | mask_displ='no mask'; |
---|
3434 | end |
---|
3435 | end |
---|
3436 | if isequal(mask_displ,'no mask') |
---|
3437 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
3438 | {'*.png', ' (*.png)'; |
---|
3439 | '*.png', '.png files '; ... |
---|
3440 | '*.*', 'All Files (*.*)'}, ... |
---|
3441 | 'Pick a mask file *.png',filebase); |
---|
3442 | mask_displ=fullfile(PathName,FileName); |
---|
3443 | if ~exist(mask_displ,'file') |
---|
3444 | mask_displ='no mask'; |
---|
3445 | end |
---|
3446 | end |
---|
3447 | if isequal(mask_displ,'no mask') |
---|
3448 | set(handles.get_mask_fix2,'Value',0) |
---|
3449 | end |
---|
3450 | set(handles.mask_fix2,'String',mask_displ) |
---|
3451 | end |
---|
3452 | |
---|
3453 | %------------------------------------------------------------------------ |
---|
3454 | % --- function called to look for mask files |
---|
3455 | function [nbslice, flag_mask]=get_mask(filebase,handles) |
---|
3456 | %------------------------------------------------------------------------ |
---|
3457 | %detect mask files, images with appropriate file base |
---|
3458 | %[filebase '_' xx 'mask'], xx=nbslice |
---|
3459 | %flag_mask=1 indicates detection |
---|
3460 | |
---|
3461 | flag_mask=0;%default |
---|
3462 | nbslice=1; |
---|
3463 | |
---|
3464 | % subdir=get(handles.subdir_civ1,'String'); |
---|
3465 | [Path,Name]=fileparts(filebase); |
---|
3466 | if ~isdir(Path) |
---|
3467 | msgbox_uvmat('ERROR','no path for input files') |
---|
3468 | return |
---|
3469 | end |
---|
3470 | currentdir=pwd; |
---|
3471 | cd(Path);%move in the dir of the root name filebase |
---|
3472 | maskfiles=dir([Name '_*mask_*.png']);%look for mask files |
---|
3473 | cd(currentdir);%come back to the current working directory |
---|
3474 | if ~isempty(maskfiles) |
---|
3475 | % msgbox_uvmat('ERROR','no mask available, to create it use Tools/Make mask in the upper menu bar of uvmat') |
---|
3476 | % else |
---|
3477 | flag_mask=1; |
---|
3478 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
3479 | [Path2,Name,ext]=fileparts(maskname); |
---|
3480 | Namedouble=double(Name); |
---|
3481 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
3482 | ind_mask=findstr('mask',Name); |
---|
3483 | i=ind_mask-1; |
---|
3484 | while val(i)==0 && i>0 |
---|
3485 | i=i-1; |
---|
3486 | end |
---|
3487 | nbslice=str2double(Name(i+1:ind_mask-1)); |
---|
3488 | if ~isnan(nbslice) && Name(i)=='_' |
---|
3489 | flag_mask=1; |
---|
3490 | else |
---|
3491 | msgbox_uvmat('ERROR',['bad mask file ' Name ext ' found in ' Path2]) |
---|
3492 | return |
---|
3493 | nbslice=1; |
---|
3494 | end |
---|
3495 | end |
---|
3496 | |
---|
3497 | %------------------------------------------------------------------------ |
---|
3498 | % --- function called to look for grid files |
---|
3499 | function [nbslice, flag_mask]=get_grid(filebase,handles) |
---|
3500 | %------------------------------------------------------------------------ |
---|
3501 | flag_mask=0;%default |
---|
3502 | nbslice=1; |
---|
3503 | [Path,Name]=fileparts(filebase); |
---|
3504 | currentdir=pwd; |
---|
3505 | cd(Path);%move in the dir of the root name filebase |
---|
3506 | maskfiles=dir([Name '_*grid_*.grid']);%look for mask files |
---|
3507 | cd(currentdir);%come back to the current working directory |
---|
3508 | if ~isempty(maskfiles) |
---|
3509 | flag_mask=1; |
---|
3510 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
3511 | [Path2,Name,ext]=fileparts(maskname); |
---|
3512 | Namedouble=double(Name); |
---|
3513 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
3514 | ind_mask=findstr('grid',Name); |
---|
3515 | i=ind_mask-1; |
---|
3516 | while val(i)==0 && i>0 |
---|
3517 | i=i-1; |
---|
3518 | end |
---|
3519 | nbslice=str2double(Name(i+1:ind_mask-1)); |
---|
3520 | if ~isnan(nbslice) && Name(i)=='_' |
---|
3521 | flag_mask=1; |
---|
3522 | else |
---|
3523 | msgbox_uvmat('ERROR',['bad grid file ' Name ext ' found in ' Path2]) |
---|
3524 | return |
---|
3525 | nbslice=1; |
---|
3526 | end |
---|
3527 | end |
---|
3528 | |
---|
3529 | %------------------------------------------------------------------------ |
---|
3530 | % --- transform numbers to letters |
---|
3531 | function str=num2stra(num,nom_type) |
---|
3532 | %------------------------------------------------------------------------ |
---|
3533 | if isempty(nom_type) |
---|
3534 | str=''; |
---|
3535 | elseif strcmp(nom_type(end),'a') |
---|
3536 | str=char(96+num); |
---|
3537 | elseif strcmp(nom_type(end),'A') |
---|
3538 | str=char(96+num); |
---|
3539 | elseif isempty(nom_type(2:end))%a single index |
---|
3540 | str=''; |
---|
3541 | else |
---|
3542 | str=num2str(num); |
---|
3543 | end |
---|
3544 | |
---|
3545 | %------------------------------------------------------------------------ |
---|
3546 | % --- Executes on button press in list_subdir_civ1. |
---|
3547 | function list_subdir_civ1_Callback(hObject, eventdata, handles) |
---|
3548 | %------------------------------------------------------------------------ |
---|
3549 | list_subdir_civ1=get(handles.list_subdir_civ1,'String'); |
---|
3550 | val=get(handles.list_subdir_civ1,'Value'); |
---|
3551 | if val>1 |
---|
3552 | subdir=list_subdir_civ1{val}; |
---|
3553 | set(handles.subdir_civ1,'String',subdir); |
---|
3554 | set(handles.list_subdir_civ1,'Value',1); |
---|
3555 | end |
---|
3556 | |
---|
3557 | %------------------------------------------------------------------------ |
---|
3558 | % --- Executes on button press in list_subdir_civ2. |
---|
3559 | function list_subdir_civ2_Callback(hObject, eventdata, handles) |
---|
3560 | %------------------------------------------------------------------------ |
---|
3561 | list_subdir_civ2=get(handles.list_subdir_civ2,'String'); |
---|
3562 | val=get(handles.list_subdir_civ2,'Value'); |
---|
3563 | if val>1 |
---|
3564 | subdir=list_subdir_civ2{val}; |
---|
3565 | set(handles.subdir_civ2,'String',subdir); |
---|
3566 | set(handles.list_subdir_civ2,'Value',1); |
---|
3567 | end |
---|
3568 | |
---|
3569 | %------------------------------------------------------------------------ |
---|
3570 | % --- Executes on button press in browse_gridciv1. |
---|
3571 | function browse_gridciv1_Callback(hObject, eventdata, handles) |
---|
3572 | %------------------------------------------------------------------------ |
---|
3573 | value=get(handles.browse_gridciv1,'Value'); |
---|
3574 | testgrid=0; |
---|
3575 | if value |
---|
3576 | filebase=get(handles.RootName,'String'); |
---|
3577 | [nbslice, flag_grid]=get_grid(filebase,handles); |
---|
3578 | if isequal(flag_grid,1) |
---|
3579 | filegrid=[num2str(nbslice) 'grid']; |
---|
3580 | testgrid=1; |
---|
3581 | else |
---|
3582 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
3583 | {'*.grid', ' (*.grid)'; |
---|
3584 | '*.grid', '.grid files '; ... |
---|
3585 | '*.*', 'All Files (*.*)'}, ... |
---|
3586 | 'Pick a file',filebase); |
---|
3587 | filegrid=fullfile(PathName,FileName); |
---|
3588 | if ~(isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file')) |
---|
3589 | testgrid=1; |
---|
3590 | end |
---|
3591 | end |
---|
3592 | end |
---|
3593 | if testgrid |
---|
3594 | set(handles.browse_gridciv2,'Value',1) |
---|
3595 | set(handles.get_gridpatch1,'Value',1) |
---|
3596 | set(handles.get_gridpatch2,'Value',1) |
---|
3597 | set(handles.dx_civ1,'Visible','off'); |
---|
3598 | set(handles.dy_civ1,'Visible','off'); |
---|
3599 | set(handles.dx_civ2,'Visible','off'); |
---|
3600 | set(handles.dy_civ2,'Visible','off'); |
---|
3601 | set(handles.grid_civ1,'String',filegrid) |
---|
3602 | set(handles.grid_patch1,'String',filegrid) |
---|
3603 | set(handles.grid_civ2,'String',filegrid) |
---|
3604 | set(handles.grid_patch2,'String',filegrid) |
---|
3605 | else |
---|
3606 | set(handles.browse_gridciv1,'Value',0); |
---|
3607 | set(handles.browse_gridciv2,'Value',0); |
---|
3608 | set(handles.get_gridpatch1,'Value',0) |
---|
3609 | set(handles.get_gridpatch2,'Value',0) |
---|
3610 | set(handles.dx_civ1,'Visible','on'); |
---|
3611 | set(handles.dy_civ1,'Visible','on'); |
---|
3612 | set(handles.dx_civ2,'Visible','on'); |
---|
3613 | set(handles.dy_civ2,'Visible','on'); |
---|
3614 | set(handles.grid_civ1,'String','') |
---|
3615 | set(handles.grid_patch1,'String','') |
---|
3616 | set(handles.grid_civ2,'String','') |
---|
3617 | set(handles.grid_patch2,'String','') |
---|
3618 | end |
---|
3619 | |
---|
3620 | %------------------------------------------------------------------------ |
---|
3621 | % --- Executes on button press in browse_gridciv1. |
---|
3622 | function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
3623 | %------------------------------------------------------------------------ |
---|
3624 | value=get(handles.browse_gridciv2,'Value'); |
---|
3625 | if value |
---|
3626 | filebase=get(handles.RootName,'String'); |
---|
3627 | [nbslice, flag_grid]=get_grid(filebase,handles); |
---|
3628 | if isequal(flag_grid,1) |
---|
3629 | mask_displ=[num2str(nbslice) 'grid']; |
---|
3630 | set(handles.grid_civ2,'String',mask_displ) |
---|
3631 | set(handles.dx_civ2,'Visible','off'); |
---|
3632 | set(handles.dy_civ2,'Visible','off'); |
---|
3633 | else |
---|
3634 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
3635 | {'*.grid', ' (*.grid)'; |
---|
3636 | '*.grid', '.grid files '; ... |
---|
3637 | '*.*', 'All Files (*.*)'}, ... |
---|
3638 | 'Pick a file',filebase); |
---|
3639 | filegrid=fullfile(PathName,FileName); |
---|
3640 | if isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file') |
---|
3641 | set(handles.browse_gridciv2,'Value',0); |
---|
3642 | set(handles.grid_civ2,'string',''); |
---|
3643 | set(handles.dx_civ2,'Visible','on'); |
---|
3644 | set(handles.dy_civ2,'Visible','on'); |
---|
3645 | set(handles.grid_civ2,'string',''); |
---|
3646 | else |
---|
3647 | set(handles.grid_civ2,'string',filegrid); |
---|
3648 | set(handles.dx_civ2,'Visible','off'); |
---|
3649 | set(handles.dy_civ2,'Visible','off'); |
---|
3650 | set(handles.grid_civ2,'string',filegrid); |
---|
3651 | end |
---|
3652 | end |
---|
3653 | else |
---|
3654 | set(handles.grid_civ2,'string',''); |
---|
3655 | set(handles.dx_civ2,'Visible','on'); |
---|
3656 | set(handles.dy_civ2,'Visible','on'); |
---|
3657 | set(handles.grid_civ2,'string',''); |
---|
3658 | end |
---|
3659 | |
---|
3660 | % % --- Executes on button press in browse_gridciv2. |
---|
3661 | % function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
3662 | % |
---|
3663 | % filebase=get(handles.RootName,'String'); |
---|
3664 | % [FileName, PathName, filterindex] = uigetfile( ... |
---|
3665 | % {'*.grid', ' (*.grid)'; |
---|
3666 | % '*.grid', '.grid files '; ... |
---|
3667 | % '*.*', 'All Files (*.*)'}, ... |
---|
3668 | % 'Pick a file',filebase); |
---|
3669 | % filegrid=fullfile(PathName,FileName); |
---|
3670 | % set(handles.grid_civ2,'string',filegrid); |
---|
3671 | % set(handles.dx_civ2,'String',' '); |
---|
3672 | % set(handles.dy_civ2,'String',' '); |
---|
3673 | % % set(handles.grid_patch2,'string',filegrid); |
---|
3674 | |
---|
3675 | % --- Executes on button press in get_gridpatch1. |
---|
3676 | function get_gridpatch1_Callback(hObject, eventdata, handles) |
---|
3677 | % hObject handle to get_gridpatch1 (see GCBO) |
---|
3678 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
3679 | % handles structure with handles and user data (see GUIDATA) |
---|
3680 | |
---|
3681 | filebase=get(handles.RootName,'String'); |
---|
3682 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
3683 | {'*.grid', ' (*.grid)'; |
---|
3684 | '*.grid', '.grid files '; ... |
---|
3685 | '*.*', 'All Files (*.*)'}, ... |
---|
3686 | 'Pick a file',filebase); |
---|
3687 | filegrid=fullfile(PathName,FileName); |
---|
3688 | set(handles.grid_patch1,'string',filegrid); |
---|
3689 | % set(handles.grid_patch2,'string',filegrid |
---|
3690 | |
---|
3691 | %------------------------------------------------------------------------ |
---|
3692 | % --- Executes on button press in get_gridpatch2. |
---|
3693 | function get_gridpatch2_Callback(hObject, eventdata, handles) |
---|
3694 | %------------------------------------------------------------------------ |
---|
3695 | |
---|
3696 | %------------------------------------------------------------------------ |
---|
3697 | function enable_civ1(handles,state) |
---|
3698 | %------------------------------------------------------------------------ |
---|
3699 | if isequal(state,'on') |
---|
3700 | set(handles.frame_civ1,'BackgroundColor',[1 1 0]) |
---|
3701 | set(handles.frame_para_civ1,'BackgroundColor',[1 1 0]) |
---|
3702 | set(handles.frame_grid_civ1,'BackgroundColor',[1 1 0]) |
---|
3703 | else |
---|
3704 | set(handles.frame_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
3705 | set(handles.frame_para_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
3706 | set(handles.frame_grid_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
3707 | end |
---|
3708 | set(handles.ibx,'Visible',state) |
---|
3709 | set(handles.iby,'Visible',state) |
---|
3710 | set(handles.isx,'Visible',state) |
---|
3711 | set(handles.isy,'Visible',state) |
---|
3712 | set(handles.shiftx,'Visible',state) |
---|
3713 | set(handles.shifty,'Visible',state) |
---|
3714 | set(handles.rho,'Visible',state) |
---|
3715 | set(handles.dx_civ1,'Visible',state) |
---|
3716 | set(handles.dy_civ1,'Visible',state) |
---|
3717 | set(handles.calcul_search,'Visible',state) |
---|
3718 | set(handles.u_text,'Visible',state) |
---|
3719 | set(handles.v_text,'Visible',state) |
---|
3720 | set(handles.min,'Visible',state) |
---|
3721 | set(handles.max,'Visible',state) |
---|
3722 | set(handles.umin,'Visible',state) |
---|
3723 | set(handles.umax,'Visible',state) |
---|
3724 | set(handles.vmin,'Visible',state) |
---|
3725 | set(handles.vmax,'Visible',state) |
---|
3726 | set(handles.grid_civ1,'Visible',state) |
---|
3727 | set(handles.mask_civ1,'Visible',state) |
---|
3728 | set(handles.browse_gridciv1,'Visible',state) |
---|
3729 | set(handles.get_mask_civ1,'Visible',state) |
---|
3730 | set(handles.parameters,'Visible',state) |
---|
3731 | set(handles.grid,'Visible',state) |
---|
3732 | set(handles.dx_civ1,'Visible',state) |
---|
3733 | set(handles.dy_civ1,'Visible',state) |
---|
3734 | set(handles.ImaThreshold,'Visible',state) |
---|
3735 | if isequal(state,'off') |
---|
3736 | set(handles.MinIma,'Visible','off') |
---|
3737 | set(handles.MaxIma,'Visible','off') |
---|
3738 | set(handles.ImaThreshold,'Value',0) |
---|
3739 | end |
---|
3740 | set(handles.dx_civ1_title,'Visible',state) |
---|
3741 | set(handles.dy_civ1_title,'Visible',state) |
---|
3742 | set(handles.ImaThreshold_title,'Visible',state) |
---|
3743 | set(handles.ib_title,'Visible',state) |
---|
3744 | set(handles.is_title,'Visible',state) |
---|
3745 | set(handles.shift_title,'Visible',state) |
---|
3746 | set(handles.rho_title,'Visible',state) |
---|
3747 | set(handles.TestCiv1,'Visible',state) |
---|
3748 | %set(handles.CivAll,'Visible',state) |
---|
3749 | |
---|
3750 | %------------------------------------------------------------------------ |
---|
3751 | function enable_fix1(handles,state) |
---|
3752 | %------------------------------------------------------------------------ |
---|
3753 | if isequal(state,0) |
---|
3754 | state='off'; |
---|
3755 | end |
---|
3756 | if isequal(state,1) |
---|
3757 | state='on'; |
---|
3758 | end |
---|
3759 | if isequal(state,'on') |
---|
3760 | set(handles.frame_fix1,'BackgroundColor',[1 1 0]) |
---|
3761 | else |
---|
3762 | set(handles.frame_fix1,'BackgroundColor',[0.7 0.7 0.7]) |
---|
3763 | end |
---|
3764 | set(handles.REMOVE,'Visible',state) |
---|
3765 | set(handles.vec_Fmin2,'Visible',state) |
---|
3766 | set(handles.vec_F2,'Visible',state) |
---|
3767 | set(handles.vec_F3,'Visible',state) |
---|
3768 | set(handles.thresh_vecC,'Visible',state) |
---|
3769 | set(handles.thresh_vecC_title,'Visible',state) |
---|
3770 | set(handles.thresh_vel,'Visible',state) |
---|
3771 | set(handles.thresh_vel_text,'Visible',state) |
---|
3772 | set(handles.mask_fix1,'Visible',state) |
---|
3773 | set(handles.get_mask_fix1,'Visible',state) |
---|
3774 | set(handles.get_ref_fix1,'Visible',state) |
---|
3775 | set(handles.ref_fix1,'Visible',state) |
---|
3776 | set(handles.inf_sup1,'Visible',state) |
---|
3777 | set(handles.field_ref1,'Visible',state) |
---|
3778 | |
---|
3779 | %------------------------------------------------------------------------ |
---|
3780 | function enable_patch1(handles) |
---|
3781 | %------------------------------------------------------------------------ |
---|
3782 | set(handles.frame_patch1,'BackgroundColor',[1 1 0]) |
---|
3783 | set(handles.rho_patch1,'Visible','on') |
---|
3784 | set(handles.rho_text1,'Visible','on') |
---|
3785 | if get(handles.CivAll,'Value')==2 |
---|
3786 | set(handles.thresh_patch1,'Visible','on') |
---|
3787 | set(handles.thresh_text1,'Visible','on') |
---|
3788 | end |
---|
3789 | set(handles.subdomain_patch1,'Visible','on') |
---|
3790 | set(handles.subdomain_text1,'Visible','on') |
---|
3791 | set(handles.nx_patch1,'Visible','on') |
---|
3792 | set(handles.ny_patch1,'Visible','on') |
---|
3793 | set(handles.nx_patch1_title,'Visible','on') |
---|
3794 | set(handles.ny_patch1_title,'Visible','on') |
---|
3795 | % if ~isempty(patch_newBin) |
---|
3796 | set(handles.test_interp,'Visible','off'); |
---|
3797 | stereo_test=get(handles.compare,'Value'); |
---|
3798 | if stereo_test==3 |
---|
3799 | set(handles.test_stereo1,'Visible','on') |
---|
3800 | end |
---|
3801 | % end |
---|
3802 | %set(handles.get_gridpatch1,'Visible','on') |
---|
3803 | %set(handles.grid_patch1,'string','none'); |
---|
3804 | %set(handles.grid_patch1,'Visible','on') |
---|
3805 | |
---|
3806 | %------------------------------------------------------------------------ |
---|
3807 | function desable_patch1(handles) |
---|
3808 | %------------------------------------------------------------------------ |
---|
3809 | set(handles.frame_patch1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
3810 | set(handles.rho_patch1,'Visible','off') |
---|
3811 | set(handles.rho_text1,'Visible','off') |
---|
3812 | set(handles.thresh_patch1,'Visible','off') |
---|
3813 | set(handles.thresh_text1,'Visible','off') |
---|
3814 | set(handles.subdomain_patch1,'Visible','off') |
---|
3815 | set(handles.subdomain_text1,'Visible','off') |
---|
3816 | set(handles.nx_patch1,'Visible','off') |
---|
3817 | set(handles.ny_patch1,'Visible','off') |
---|
3818 | set(handles.nx_patch1_title,'Visible','off') |
---|
3819 | set(handles.ny_patch1_title,'Visible','off') |
---|
3820 | set(handles.test_stereo1,'Visible','off') |
---|
3821 | %set(handles.test_interp,'Visible','off') |
---|
3822 | %set(handles.get_gridpatch1,'Visible','off') |
---|
3823 | %set(handles.grid_patch1,'Visible','off') |
---|
3824 | |
---|
3825 | %------------------------------------------------------------------------ |
---|
3826 | function enable_civ2(handles,state) |
---|
3827 | %------------------------------------------------------------------------ |
---|
3828 | if isequal(state,0) |
---|
3829 | state='off'; |
---|
3830 | end |
---|
3831 | if isequal(state,1) |
---|
3832 | state='on'; |
---|
3833 | end |
---|
3834 | if isequal(state,'on') |
---|
3835 | set(handles.frame_civ2,'BackgroundColor',[1 1 0]) |
---|
3836 | set(handles.frame_para_civ2,'BackgroundColor',[1 1 0]) |
---|
3837 | set(handles.frame_grid_civ2,'BackgroundColor',[1 1 0]) |
---|
3838 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
3839 | else |
---|
3840 | set(handles.frame_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
3841 | set(handles.frame_para_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
3842 | set(handles.frame_grid_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
3843 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
3844 | end |
---|
3845 | set(handles.ibx_civ2,'Visible',state) |
---|
3846 | set(handles.iby_civ2,'Visible',state) |
---|
3847 | set(handles.decimal,'Visible',state) |
---|
3848 | set(handles.deformation,'Visible',state) |
---|
3849 | set(handles.rho_civ2,'Visible',state) |
---|
3850 | set(handles.dx_civ2,'Visible',state) |
---|
3851 | set(handles.dy_civ2,'Visible',state) |
---|
3852 | set(handles.browse_gridciv2,'Visible',state) |
---|
3853 | set(handles.get_mask_civ2,'Visible',state) |
---|
3854 | set(handles.parameters,'Visible',state) |
---|
3855 | set(handles.grid,'Visible',state) |
---|
3856 | set(handles.parameters_text,'Visible',state) |
---|
3857 | set(handles.grid_text,'Visible',state) |
---|
3858 | set(handles.grid_civ2,'Visible',state) |
---|
3859 | set(handles.mask_civ2,'Visible',state) |
---|
3860 | set(handles.dx_civ2_title,'Visible',state) |
---|
3861 | set(handles.dy_civ2_title,'Visible',state) |
---|
3862 | set(handles.ibx_civ2_text,'Visible',state) |
---|
3863 | set(handles.rho_civ2_title,'Visible',state) |
---|
3864 | set(handles.ImaThreshold2,'Visible',state) |
---|
3865 | set(handles.ImaThreshold_title2,'Visible',state) |
---|
3866 | if isequal(state,'off') |
---|
3867 | set(handles.MinIma2,'Visible','off') |
---|
3868 | set(handles.MaxIma2,'Visible','off') |
---|
3869 | set(handles.ImaThreshold2,'Value',0) |
---|
3870 | if isequal(get(handles.FIX2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) |
---|
3871 | set(handles.list_pair_civ2,'Visible','off') |
---|
3872 | set(handles.subdir_civ2,'Visible','off') |
---|
3873 | set(handles.subdir_civ2_text,'Visible','off') |
---|
3874 | set(handles.dt_unit_civ2,'Visible','off') |
---|
3875 | set(handles.ref_i_civ2,'Visible','off') |
---|
3876 | set(handles.i_ref_civ2_title,'Visible','off') |
---|
3877 | set(handles.j_ref_civ2_title,'Visible','off') |
---|
3878 | set(handles.ref_j_civ2,'Visible','off') |
---|
3879 | end |
---|
3880 | else |
---|
3881 | set(handles.list_pair_civ2,'Visible','on') |
---|
3882 | set(handles.subdir_civ2,'Visible','on') |
---|
3883 | set(handles.subdir_civ2_text,'Visible','on') |
---|
3884 | set(handles.dt_unit_civ2,'Visible','on') |
---|
3885 | set(handles.ref_i_civ2,'Visible','on') |
---|
3886 | set(handles.i_ref_civ2_title,'Visible','on') |
---|
3887 | set(handles.j_ref_civ2_title,'Visible','on') |
---|
3888 | set(handles.ref_j_civ2,'Visible','on') |
---|
3889 | end |
---|
3890 | set(handles.rho_civ2_title,'Visible',state) |
---|
3891 | |
---|
3892 | %------------------------------------------------------------------------ |
---|
3893 | function enable_fix2(handles) |
---|
3894 | %------------------------------------------------------------------------ |
---|
3895 | set(handles.frame_fix2,'BackgroundColor',[1 1 0]) |
---|
3896 | set(handles.REMOVE2,'Visible','on') |
---|
3897 | set(handles.vec_Fmin2_2,'Visible','on') |
---|
3898 | set(handles.vec_F4,'Visible','on') |
---|
3899 | set(handles.vec_F3_2,'Visible','on') |
---|
3900 | set(handles.thresh_vec2C,'Visible','on') |
---|
3901 | set(handles.thresh_vec2C_text,'Visible','on') |
---|
3902 | set(handles.thresh_vel2,'Visible','on') |
---|
3903 | set(handles.thresh_vel2_text,'Visible','on') |
---|
3904 | set(handles.mask_fix2,'Visible','on') |
---|
3905 | set(handles.get_mask_fix2,'Visible','on') |
---|
3906 | set(handles.list_pair_civ2,'Visible','on') |
---|
3907 | set(handles.subdir_civ2,'Visible','on') |
---|
3908 | set(handles.subdir_civ2_text,'Visible','on') |
---|
3909 | set(handles.get_ref_fix2,'Visible','on') |
---|
3910 | set(handles.ref_fix2,'Visible','on') |
---|
3911 | set(handles.inf_sup2,'Visible','on') |
---|
3912 | set(handles.field_ref2,'Visible','on') |
---|
3913 | |
---|
3914 | %------------------------------------------------------------------------ |
---|
3915 | function desable_fix2(handles) |
---|
3916 | %------------------------------------------------------------------------ |
---|
3917 | set(handles.frame_fix2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
3918 | set(handles.REMOVE2,'Visible','off') |
---|
3919 | set(handles.vec_Fmin2_2,'Visible','off') |
---|
3920 | set(handles.vec_F4,'Visible','off') |
---|
3921 | set(handles.vec_F3_2,'Visible','off') |
---|
3922 | set(handles.thresh_vec2C,'Visible','off') |
---|
3923 | set(handles.thresh_vec2C_text,'Visible','off') |
---|
3924 | set(handles.thresh_vel2,'Visible','off') |
---|
3925 | set(handles.thresh_vel2_text,'Visible','off') |
---|
3926 | set(handles.mask_fix2,'Visible','off') |
---|
3927 | set(handles.get_mask_fix2,'Visible','off') |
---|
3928 | set(handles.get_ref_fix2,'Visible','off') |
---|
3929 | set(handles.ref_fix2,'Visible','off') |
---|
3930 | set(handles.inf_sup2,'Visible','off') |
---|
3931 | set(handles.field_ref2,'Visible','off') |
---|
3932 | if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) |
---|
3933 | set(handles.list_pair_civ2,'Visible','off') |
---|
3934 | set(handles.subdir_civ2,'Visible','off') |
---|
3935 | set(handles.subdir_civ2_text,'Visible','off') |
---|
3936 | end |
---|
3937 | |
---|
3938 | %------------------------------------------------------------------------ |
---|
3939 | function enable_patch2(handles) |
---|
3940 | %------------------------------------------------------------------------ |
---|
3941 | set(handles.frame_patch2,'BackgroundColor',[1 1 0]) |
---|
3942 | set(handles.rho_patch2,'Visible','on') |
---|
3943 | set(handles.rho_text2,'Visible','on') |
---|
3944 | set(handles.thresh_patch2,'Visible','on') |
---|
3945 | set(handles.thresh_text2,'Visible','on') |
---|
3946 | set(handles.subdomain_patch2,'Visible','on') |
---|
3947 | set(handles.subdomain_text2,'Visible','on') |
---|
3948 | set(handles.nx_patch2,'Visible','on') |
---|
3949 | set(handles.ny_patch2,'Visible','on') |
---|
3950 | set(handles.nx_patch2_title,'Visible','on') |
---|
3951 | set(handles.ny_patch2_title,'Visible','on') |
---|
3952 | % set(handles.get_gridpatch2,'Visible','on') |
---|
3953 | % set(handles.grid_patch2,'Visible','on') |
---|
3954 | set(handles.list_pair_civ2,'Visible','on') |
---|
3955 | set(handles.subdir_civ2,'Visible','on') |
---|
3956 | set(handles.subdir_civ2_text,'Visible','on') |
---|
3957 | stereo_test=get(handles.compare,'Value'); |
---|
3958 | if stereo_test==3 |
---|
3959 | set(handles.test_stereo2,'Visible','on') |
---|
3960 | end |
---|
3961 | |
---|
3962 | %------------------------------------------------------------------------ |
---|
3963 | function desable_patch2(handles) |
---|
3964 | %------------------------------------------------------------------------ |
---|
3965 | set(handles.frame_patch2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
3966 | set(handles.rho_patch2,'Visible','off') |
---|
3967 | set(handles.rho_text2,'Visible','off') |
---|
3968 | set(handles.thresh_patch2,'Visible','off') |
---|
3969 | set(handles.thresh_text2,'Visible','off') |
---|
3970 | set(handles.subdomain_patch2,'Visible','off') |
---|
3971 | set(handles.subdomain_text2,'Visible','off') |
---|
3972 | set(handles.nx_patch2,'Visible','off') |
---|
3973 | set(handles.ny_patch2,'Visible','off') |
---|
3974 | set(handles.nx_patch2_title,'Visible','off') |
---|
3975 | set(handles.ny_patch2_title,'Visible','off') |
---|
3976 | % set(handles.get_gridpatch2,'Visible','off') |
---|
3977 | % set(handles.grid_patch2,'Visible','off') |
---|
3978 | if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.FIX2,'Value'),0) |
---|
3979 | set(handles.list_pair_civ2,'Visible','off') |
---|
3980 | set(handles.subdir_civ2,'Visible','off') |
---|
3981 | set(handles.subdir_civ2_text,'Visible','off') |
---|
3982 | end |
---|
3983 | set(handles.test_stereo2,'Visible','off') |
---|
3984 | %------------------------------------------------------------------------ |
---|
3985 | function enable_pair1(handles,state) |
---|
3986 | %------------------------------------------------------------------------ |
---|
3987 | set(handles.subdir_civ1,'Visible',state) |
---|
3988 | set(handles.list_subdir_civ1,'Visible',state) |
---|
3989 | set(handles.SUBDIR_CIV1_txt,'Visible',state) |
---|
3990 | set(handles.frame_subdirciv1,'Visible',state) |
---|
3991 | set(handles.list_pair_civ1,'Visible',state) |
---|
3992 | set(handles.PAIR_txt,'Visible',state) |
---|
3993 | %set(handles.dt_unit,'Visible',state) |
---|
3994 | set(handles.PAIR_frame,'Visible',state) |
---|
3995 | |
---|
3996 | %------------------------------------------------------------------------ |
---|
3997 | % --- Read the parameters for civ1 on the interface |
---|
3998 | function par=read_param_civ1(handles,file_ima) |
---|
3999 | %------------------------------------------------------------------------ |
---|
4000 | ibx_val=str2double(get(handles.ibx,'String')); |
---|
4001 | par.ibx=num2str(ibx_val); |
---|
4002 | iby_val=str2double(get(handles.iby,'String')); |
---|
4003 | par.iby=num2str(iby_val); |
---|
4004 | isx=get(handles.isx,'String'); |
---|
4005 | if isnan(str2double(isx)), isx='41'; set(handles.isx,'String','41'), end; %default |
---|
4006 | if str2double(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.isx,'String',num2str(ibx_val+8)); end |
---|
4007 | isy=get(handles.isy,'String'); |
---|
4008 | if isnan(str2double(isy)), isy='41'; set(handles.isy,'String','41'), end;%default |
---|
4009 | if str2double(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.isy,'String',num2str(iby_val+8)); end |
---|
4010 | par.isx=get(handles.isx,'String'); |
---|
4011 | par.isy=get(handles.isy,'String'); |
---|
4012 | par.shiftx=get(handles.shiftx,'String'); |
---|
4013 | par.shifty=get(handles.shifty,'String'); |
---|
4014 | if isnan(str2double(par.isx)) |
---|
4015 | par.isx='41';%default |
---|
4016 | set(handles.isx,'String','41'); |
---|
4017 | end |
---|
4018 | if isnan(str2double(par.isy)) |
---|
4019 | par.isy='41'; %default |
---|
4020 | set(handles.isy,'String','41'); |
---|
4021 | end |
---|
4022 | if isnan(str2double(par.shiftx)) |
---|
4023 | par.shiftx='0';%default |
---|
4024 | set(handles.shiftx,'String','0'); |
---|
4025 | end |
---|
4026 | if isnan(str2double(par.shifty)) |
---|
4027 | par.shifty='0'; %default |
---|
4028 | set(handles.shifty,'String','0'); |
---|
4029 | end |
---|
4030 | par.rho=get(handles.rho,'String'); |
---|
4031 | if isequal(get(handles.rho,'Style'),'popupmenu') |
---|
4032 | index=get(handles.rho,'Value'); |
---|
4033 | par.rho=par.rho{index}; |
---|
4034 | end |
---|
4035 | par.dx=get(handles.dx_civ1,'String'); |
---|
4036 | par.dy=get(handles.dy_civ1,'String'); |
---|
4037 | if isnan(str2double(par.dx)) |
---|
4038 | if isempty(get(handles.grid_civ1,'String')); |
---|
4039 | par.dx='0'; %just read by civ program, not used |
---|
4040 | else |
---|
4041 | par.dx='20';%default |
---|
4042 | set(handles.dx_civ1,'String','20'); |
---|
4043 | end |
---|
4044 | end |
---|
4045 | if isnan(str2double(par.dy)) |
---|
4046 | if isempty(get(handles.grid_civ1,'String')); |
---|
4047 | par.dy='0';%just read by civ program, not used |
---|
4048 | else |
---|
4049 | par.dy='20';%default |
---|
4050 | set(handles.dy_civ1_title,'String','20'); |
---|
4051 | end |
---|
4052 | end |
---|
4053 | par.pxcmx='1'; %velocities are expressed in pixel dispalcement |
---|
4054 | par.pxcmy='1'; |
---|
4055 | if exist('file_ima','var') |
---|
4056 | A=imread(file_ima);%read the first image to get the size |
---|
4057 | sizim=size(A); |
---|
4058 | par.npx=num2str(sizim(2)); |
---|
4059 | par.npy=num2str(sizim(1)); |
---|
4060 | end |
---|
4061 | %time=get(handles.RootName,'UserData'); %get the set of times |
---|
4062 | par.gridname=get(handles.grid_civ1,'String'); |
---|
4063 | par.gridflag='y'; |
---|
4064 | if strcmp(par.gridname,'')|| isempty(par.gridname) |
---|
4065 | par.gridname='nogrid'; |
---|
4066 | par.gridflag='n'; |
---|
4067 | end |
---|
4068 | |
---|
4069 | %------------------------------------------------------------------------ |
---|
4070 | function par=read_param_civ2(handles,file_ima) |
---|
4071 | %------------------------------------------------------------------------ |
---|
4072 | par.ibx=get(handles.ibx_civ2,'String'); |
---|
4073 | par.iby=get(handles.iby_civ2,'String'); |
---|
4074 | par.rho=get(handles.rho_civ2,'String'); |
---|
4075 | par.decimal=int2str(get(handles.decimal,'Value')); |
---|
4076 | par.deformation=int2str(get(handles.deformation,'Value')); |
---|
4077 | par.dx=get(handles.dx_civ2,'String'); |
---|
4078 | par.dy=get(handles.dy_civ2,'String'); |
---|
4079 | if isnan(str2double(par.dx)) |
---|
4080 | if isempty(get(handles.grid_civ2,'String')); |
---|
4081 | par.dx='0'; %just read by civ program, not used |
---|
4082 | else |
---|
4083 | par.dx='20';%default |
---|
4084 | set(handles.dx_civ2,'String','20'); |
---|
4085 | end |
---|
4086 | end |
---|
4087 | if isnan(str2double(par.dy)) |
---|
4088 | if isempty(get(handles.grid_civ2,'String')); |
---|
4089 | par.dy='0';%just read by civ program, not used |
---|
4090 | else |
---|
4091 | par.dy='20';%default |
---|
4092 | set(handles.dy_civ2,'String','20'); |
---|
4093 | end |
---|
4094 | end |
---|
4095 | par.pxcmx='1'; |
---|
4096 | par.pxcmy='1'; |
---|
4097 | A=imread(file_ima);%read the first image to get the size |
---|
4098 | sizim=size(A); |
---|
4099 | par.npx=num2str(sizim(2)); |
---|
4100 | par.npy=num2str(sizim(1)); |
---|
4101 | %time=get(handles.RootName,'UserData'); %get the set of times |
---|
4102 | par.gridname=get(handles.grid_civ2,'String'); |
---|
4103 | par.gridflag='y'; |
---|
4104 | if strcmp(par.gridname,'')|| isempty(par.gridname) |
---|
4105 | par.gridname='nogrid'; |
---|
4106 | par.gridflag='n'; |
---|
4107 | end |
---|
4108 | |
---|
4109 | %------------------------------------------------------------------------ |
---|
4110 | % --- CIV1 CIV1 CIV1 CIV1 |
---|
4111 | function cmd_CIV1=CIV1_CMD(filename,namelog,par,handles,sparam) |
---|
4112 | %------------------------------------------------------------------------ |
---|
4113 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
4114 | |
---|
4115 | %changes : filename_cmx -> filename ( no extension ) |
---|
4116 | % input namelog not used |
---|
4117 | if isequal(par.Dt,'0') |
---|
4118 | par.Dt='1' ;%case of 'displacement' mode |
---|
4119 | end |
---|
4120 | par.filename_ima_a=regexprep(par.filename_ima_a,'.png',''); |
---|
4121 | par.filename_ima_b=regexprep(par.filename_ima_b,'.png',''); |
---|
4122 | fid=fopen([filename '.civ1.cmx'],'w'); |
---|
4123 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
4124 | fprintf(fid, ['FirstImage ' regexprep(par.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
4125 | fprintf(fid, ['LastImage ' regexprep(par.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
4126 | fprintf(fid, ['XX' '\n' ]); |
---|
4127 | fprintf(fid, ['Mask ' par.maskflag '\n' ]); |
---|
4128 | fprintf(fid, ['MaskName ' regexprep(par.maskname,'\\','\\\\') '\n' ]); |
---|
4129 | fprintf(fid, ['ImageSize ' par.npx ' ' par.npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
4130 | fprintf(fid, ['CorrelationBoxesSize ' par.ibx ' ' par.iby '\n' ]); |
---|
4131 | fprintf(fid, ['SearchBoxeSize ' par.isx ' ' par.isy '\n' ]); |
---|
4132 | fprintf(fid, ['RO ' par.rho '\n' ]); |
---|
4133 | fprintf(fid, ['GridSpacing ' par.dx ' ' par.dy '\n' ]); |
---|
4134 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
4135 | fprintf(fid, ['Dt_TO ' par.Dt ' ' par.T0 '\n' ]); |
---|
4136 | fprintf(fid, ['PixCmXY ' par.pxcmx ' ' par.pxcmy '\n' ]); |
---|
4137 | fprintf(fid, ['XX 1' '\n' ]); |
---|
4138 | fprintf(fid, ['ShiftXY ' par.shiftx ' ' par.shifty '\n' ]); |
---|
4139 | fprintf(fid, ['Grid ' par.gridflag '\n' ]); |
---|
4140 | fprintf(fid, ['GridName ' regexprep(par.gridname,'\\','\\\\') '\n' ]); |
---|
4141 | fprintf(fid, ['XX 85' '\n' ]); |
---|
4142 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
4143 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
4144 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
4145 | fprintf(fid, [ 'DecimalShift 0' '\n' ]); |
---|
4146 | fprintf(fid, ['Deformation 0' '\n' ]); |
---|
4147 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
4148 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
4149 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
4150 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
4151 | fprintf(fid, ['ImageToUse ' par.term_a ' ' par.term_b '\n' ]); % VERIFIER ? |
---|
4152 | fprintf(fid, ['ImageUsedBefore null null' '\n' ]); |
---|
4153 | fclose(fid); |
---|
4154 | |
---|
4155 | % cmd_CIV1=[sparam.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file |
---|
4156 | % cmd_CIV1=regexprep(cmd_CIV1,'\\','\\\\'); |
---|
4157 | % namelog=regexprep(namelog,'\\','\\\\'); |
---|
4158 | if(isunix) |
---|
4159 | cmd_CIV1=['cp -f ' filename '.civ1.cmx ' filename '.cmx\n']; |
---|
4160 | cmd_CIV1=[cmd_CIV1 sparam.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx |
---|
4161 | cmd_CIV1=[cmd_CIV1 '\n' 'mv ' filename '.log' ' ' filename '.civ1.log' '\n' 'chmod g+w ' filename '.civ1.log' '\n' 'chmod g+w ' filename '.nc'];%rename .log as .civ1.log and set the netcdf result file for group user writting |
---|
4162 | % cmd_CIV1=[cmd_CIV1 '\n' 'mv ' filename '.cmx' ' ' filename '.civ1.cmx' '\n'];%rename .cmx as .civ1.cmx |
---|
4163 | else %Windows system |
---|
4164 | flname=regexprep(flname,'\\','\\\\'); |
---|
4165 | % cmd=[cmd 'copy /Y "' flname '.civ1.cmx" "' flname '.cmx"\n']; |
---|
4166 | filename=regexprep(filename,'\\','\\\\'); |
---|
4167 | cmd_CIV1=['copy /Y "' filename '.civ1.cmx" "' filename '.cmx"\n'];% copy the .civ1.cmx parameter file to .cmx |
---|
4168 | cmd_CIV1=['"' sparam.Civ1Bin '" -f "' filename '.cmx" >"' filename '.log"' ]; % redirect standard output to the log file |
---|
4169 | cmd_CIV1=regexprep(cmd_CIV1,'\\','\\\\'); |
---|
4170 | namelog=regexprep(namelog,'\\','\\\\'); |
---|
4171 | cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y "' filename '.log' '" "' filename '.civ1.log"']; %preserve the log file as .civ1.log |
---|
4172 | % cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y "' filename '.cmx' '" "' filename '.civ1.cmx"']; |
---|
4173 | end |
---|
4174 | |
---|
4175 | %------------------------------------------------------------------------ |
---|
4176 | % --- CIV1 Unified |
---|
4177 | function xml_civ1_parameters=CIV1_CMD_Unified(filename,namelog,par) |
---|
4178 | %------------------------------------------------------------------------ |
---|
4179 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
4180 | %global CivBin%name of the executable for civ1 calculation |
---|
4181 | |
---|
4182 | civ1.image1=par.filename_ima_a; |
---|
4183 | civ1.image2=par.filename_ima_b; |
---|
4184 | civ1.imageSize_X=par.npx; |
---|
4185 | civ1.imageSize_Y=par.npy; |
---|
4186 | civ1.outputFileName=[filename '.nc']; |
---|
4187 | civ1.correlationBoxesSize_X=par.ibx; |
---|
4188 | civ1.correlationBoxesSize_Y=par.iby; |
---|
4189 | civ1.searchBoxesSize_X=par.isx; |
---|
4190 | civ1.searchBoxesSize_Y=par.isy; |
---|
4191 | civ1.globalShift_X=par.shiftx; |
---|
4192 | civ1.globalShift_Y=par.shifty; |
---|
4193 | civ1.ro=par.rho; |
---|
4194 | civ1.hart='y'; |
---|
4195 | if isequal(par.gridflag,'y') |
---|
4196 | civ1.grid=par.gridname; |
---|
4197 | else |
---|
4198 | civ1.grid='n'; |
---|
4199 | civ1.gridSpacing_X=par.dx; |
---|
4200 | civ1.gridSpacing_Y=par.dy; |
---|
4201 | end |
---|
4202 | if isequal(par.maskflag,'y') |
---|
4203 | civ1.mask=par.maskname; |
---|
4204 | end |
---|
4205 | civ1.dt=par.Dt; |
---|
4206 | civ1.unit='pixel'; |
---|
4207 | civ1.absolut_time_T0=par.T0; |
---|
4208 | civ1.pixcmx=par.pxcmx; |
---|
4209 | civ1.pixcmy=par.pxcmy; |
---|
4210 | civ1.convectFlow='n'; |
---|
4211 | |
---|
4212 | xml_civ1_parameters=civ1; |
---|
4213 | |
---|
4214 | %------------------------------------------------------------------------ |
---|
4215 | % --- CIV2 Unified |
---|
4216 | function civ2=CIV2_CMD_Unified(filename,namelog,par) |
---|
4217 | %------------------------------------------------------------------------ |
---|
4218 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
4219 | %global CivBin%name of the executable for civ1 calculation |
---|
4220 | |
---|
4221 | civ2.image1=par.filename_ima_a; |
---|
4222 | civ2.image2=par.filename_ima_b; |
---|
4223 | civ2.imageSize_X=par.npx; |
---|
4224 | civ2.imageSize_Y=par.npy; |
---|
4225 | civ2.inputFileName=[par.filename_nc1 '.nc']; |
---|
4226 | civ2.outputFileName=[filename '.nc']; |
---|
4227 | civ2.correlationBoxesSize_X=par.ibx; |
---|
4228 | civ2.correlationBoxesSize_Y=par.iby; |
---|
4229 | civ2.ro=par.rho; |
---|
4230 | %civ2.decimalShift=par.decimal; |
---|
4231 | %civ2.deformation=par.deformation; |
---|
4232 | if isequal(par.decimal,'1') |
---|
4233 | civ2.decimalShift='y'; |
---|
4234 | else |
---|
4235 | civ2.decimalShift='n'; |
---|
4236 | end |
---|
4237 | if isequal(par.deformation,'1') |
---|
4238 | civ2.deformation='y'; |
---|
4239 | else |
---|
4240 | civ2.deformation='n'; |
---|
4241 | end |
---|
4242 | if isequal(par.gridflag,'y') |
---|
4243 | civ2.grid=par.gridname; |
---|
4244 | else |
---|
4245 | civ2.grid='n'; |
---|
4246 | civ2.gridSpacing_X=par.dx; |
---|
4247 | civ2.gridSpacing_Y=par.dy; |
---|
4248 | end |
---|
4249 | civ2.gridSpacing_X='10'; |
---|
4250 | civ2.gridSpacing_Y='10';%NOTE: faut mettre gridSpacing pourque ca tourne, meme si c'est la grille qui est utilisee |
---|
4251 | if isequal(par.maskflag,'y') |
---|
4252 | civ2.mask=par.maskname; |
---|
4253 | else |
---|
4254 | civ2.mask='n'; |
---|
4255 | end |
---|
4256 | civ2.dt=par.Dt; |
---|
4257 | civ2.unit='pixel'; |
---|
4258 | civ2.absolut_time_T0=par.T0; |
---|
4259 | civ2.pixcmx=par.pxcmx; |
---|
4260 | civ2.pixcmy=par.pxcmy; |
---|
4261 | civ2.convectFlow='n'; |
---|
4262 | civ2.pixcmx=par.pxcmx; |
---|
4263 | civ2.pixcmy=par.pxcmy; |
---|
4264 | civ2.convectFlow='n'; |
---|
4265 | |
---|
4266 | %------------------------------------------------------------------------ |
---|
4267 | % --- CIV2 CIV2 CIV2 CIV2 |
---|
4268 | function cmd_CIV2=CIV2_CMD(filename,namelog,par,sparam) |
---|
4269 | %------------------------------------------------------------------------ |
---|
4270 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
4271 | % global civ2Bin sge%name of the executable for civ1 calculation |
---|
4272 | if isequal(par.Dt,'0') |
---|
4273 | par.Dt='1' ;%case of 'displacement' mode |
---|
4274 | end |
---|
4275 | par.filename_ima_a=regexprep(par.filename_ima_a,'.png',''); |
---|
4276 | par.filename_ima_b=regexprep(par.filename_ima_b,'.png','');% bug : .png appears two times ? |
---|
4277 | [fid,errormsg]=fopen([filename '.civ2.cmx'],'w'); |
---|
4278 | if isequal(fid,-1) |
---|
4279 | msgbox_uvmat('ERROR',errormsg) |
---|
4280 | cmd_CIV2=''; |
---|
4281 | return |
---|
4282 | end |
---|
4283 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
4284 | fprintf(fid, ['FirstImage ' regexprep(par.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
4285 | fprintf(fid, ['LastImage ' regexprep(par.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
4286 | fprintf(fid, ['XX' '\n' ]); |
---|
4287 | fprintf(fid, ['Mask ' par.maskflag '\n' ]); |
---|
4288 | fprintf(fid, ['MaskName ' regexprep(par.maskname,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
4289 | fprintf(fid, ['ImageSize ' par.npx ' ' par.npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
4290 | fprintf(fid, ['CorrelationBoxesSize ' par.ibx ' ' par.iby '\n' ]); |
---|
4291 | fprintf(fid, ['SearchBoxeSize ' par.ibx ' ' par.iby '\n']); |
---|
4292 | fprintf(fid, ['RO ' par.rho '\n']); |
---|
4293 | fprintf(fid, ['GridSpacing ' par.dx ' ' par.dy '\n']); |
---|
4294 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
4295 | fprintf(fid, ['Dt_TO ' par.Dt ' ' par.T0 '\n' ]); |
---|
4296 | fprintf(fid, ['PixCmXY ' par.pxcmx ' ' par.pxcmy '\n' ]); |
---|
4297 | fprintf(fid, ['XX 1' '\n' ]); |
---|
4298 | fprintf(fid, 'ShiftXY 0 0\n'); |
---|
4299 | fprintf(fid, ['Grid ' par.gridflag '\n' ]); |
---|
4300 | fprintf(fid, ['GridName ' regexprep(par.gridname,'\\','\\\\') '\n']); |
---|
4301 | fprintf(fid, ['XX 85' '\n' ]); |
---|
4302 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
4303 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
4304 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
4305 | fprintf(fid, ['DecimalShift ' par.decimal '\n']); |
---|
4306 | fprintf(fid, ['Deformation ' par.deformation '\n']); |
---|
4307 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
4308 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
4309 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
4310 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
4311 | fprintf(fid, ['ImageToUse ' par.term_a ' ' par.term_b '\n' ]); % VERIFIER ? |
---|
4312 | fprintf(fid, ['ImageUsedBefore ' regexprep(par.filename_nc1,'\\','\\\\') '\n']); |
---|
4313 | fclose(fid); |
---|
4314 | |
---|
4315 | if(isunix) |
---|
4316 | cmd_CIV2=['cp -f ' filename '.civ2.cmx ' filename '.cmx\n']; |
---|
4317 | cmd_CIV2=[cmd_CIV2 sparam.Civ2Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx |
---|
4318 | cmd_CIV2=[cmd_CIV2 '\n' 'mv ' filename '.log' ' ' filename '.civ2.log' '\n' 'chmod g+w ' filename '.nc'];%preserve the log file as .civ2.log |
---|
4319 | % cmd_CIV2=[cmd_CIV2 '\n' 'mv ' filename '.cmx' ' ' filename '.civ2.cmx' '\n'];%rename .cmx as .civ2.cmx, the result file is named [filename '.nc'] by CIVx |
---|
4320 | |
---|
4321 | else |
---|
4322 | filename=regexprep(filename,'\\','\\\\'); |
---|
4323 | cmd_CIV2=['copy /Y "' filename '.civ2.cmx" "' filename '.cmx"\n']; |
---|
4324 | cmd_CIV2=[cmd_CIV2 '"' sparam.Civ2Bin '" -f "' filename '.cmx" >"' filename '.log"' ]; % redirect standard output to the log file |
---|
4325 | cmd_CIV2=regexprep(cmd_CIV2,'\\','\\\\'); |
---|
4326 | cmd_CIV2=[cmd_CIV2 '\n' 'copy /Y "' filename '.log' '" "' filename '.civ2.log"']; |
---|
4327 | % cmd_CIV2=[cmd_CIV2 '\n' 'copy /Y "' filename '.cmx' '" "' filename '.civ2.cmx"']; |
---|
4328 | end |
---|
4329 | |
---|
4330 | % %------------------------------------------------------------------------ |
---|
4331 | % % --- civ using pivlab |
---|
4332 | % function Data=civ_uvmat(par_civ1) |
---|
4333 | % %------------------------------------------------------------------------ |
---|
4334 | % image1=imread(par_civ1.filename_ima_a); |
---|
4335 | % image2=imread(par_civ1.filename_ima_b); |
---|
4336 | % stepx=str2num(par_civ1.dx); |
---|
4337 | % stepy=str2num(par_civ1.dy); |
---|
4338 | % ibx2=ceil(str2num(par_civ1.ibx)/2); |
---|
4339 | % iby2=ceil(str2num(par_civ1.iby)/2); |
---|
4340 | % isx2=ceil(str2num(par_civ1.isx)/2); |
---|
4341 | % isy2=ceil(str2num(par_civ1.isy)/2); |
---|
4342 | % shiftx=str2num(par_civ1.shiftx); |
---|
4343 | % shifty=str2num(par_civ1.shifty); |
---|
4344 | % miniy=max(1+isy2-shifty,1+iby2); |
---|
4345 | % minix=max(1+isx2-shiftx,1+ibx2); |
---|
4346 | % maxiy=min(size(image1,1)-isy2-shifty,size(image1,1)-iby2); |
---|
4347 | % maxix=min(size(image1,2)-isx2-shiftx,size(image1,2)-ibx2); |
---|
4348 | % [GridX,GridY]=meshgrid(minix:stepx:maxix,miniy:stepy:maxiy); |
---|
4349 | % PointCoord(:,1)=reshape(GridX,[],1); |
---|
4350 | % PointCoord(:,2)=reshape(GridY,[],1); |
---|
4351 | % % caluclate velocity data (y and v in indices, reverse to y component) |
---|
4352 | % [xtable ytable utable vtable ctable F] = pivlab (image1,image2,ibx2,iby2,isx2,isy2,shiftx,shifty,PointCoord, 1, []); |
---|
4353 | % Data.ListGlobalAttribute=[{'Conventions','Program','CivStage'} {'Time','Dt'}]; |
---|
4354 | % Data.Conventions='uvmat/civdata'; |
---|
4355 | % Data.Program='civ_uvmat'; |
---|
4356 | % Data.CivStage=1; |
---|
4357 | % % list_param=fieldnames(Param.Civ1); |
---|
4358 | % % for ilist=1:length(list_param) |
---|
4359 | % % eval(['Data.Civ1_' list_param{ilist} '=Param.Civ1.' list_param{ilist} ';']) |
---|
4360 | % % end |
---|
4361 | % Data.Time=str2double(par_civ1.T0); |
---|
4362 | % Data.Dt=str2double(par_civ1.Dt); |
---|
4363 | % Data.ListVarName={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_F'};% cell array containing the names of the fields to record |
---|
4364 | % Data.VarDimName={'nbvec','nbvec','nbvec','nbvec','nbvec','nbvec'}; |
---|
4365 | % Data.VarAttribute{1}.Role='coord_x'; |
---|
4366 | % Data.VarAttribute{2}.Role='coord_y'; |
---|
4367 | % Data.VarAttribute{3}.Role='vector_x'; |
---|
4368 | % Data.VarAttribute{4}.Role='vector_y'; |
---|
4369 | % Data.VarAttribute{5}.Role='warnflag'; |
---|
4370 | % Data.Civ1_X=reshape(xtable,[],1); |
---|
4371 | % Data.Civ1_Y=reshape(size(image1,1)-ytable+1,[],1); |
---|
4372 | % Data.Civ1_U=reshape(utable,[],1); |
---|
4373 | % Data.Civ1_V=reshape(-vtable,[],1); |
---|
4374 | % Data.Civ1_C=reshape(ctable,[],1); |
---|
4375 | % Data.Civ1_F=reshape(F,[],1); |
---|
4376 | |
---|
4377 | %------------------------------------------------------------------------ |
---|
4378 | % --- Executes on button press in HELP. |
---|
4379 | function HELP_Callback(hObject, eventdata, handles) |
---|
4380 | %------------------------------------------------------------------------ |
---|
4381 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
4382 | pathelp=fileparts(path_to_uvmat); |
---|
4383 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html'); |
---|
4384 | if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package') |
---|
4385 | else |
---|
4386 | addpath (fullfile(pathelp,'uvmat_doc')) |
---|
4387 | web([helpfile '#civ']) |
---|
4388 | end |
---|
4389 | |
---|
4390 | %------------------------------------------------------------------------ |
---|
4391 | %--read images and convert them to the uint16 format used for PIV |
---|
4392 | function A=read_image(filename,type_ima,num,movieobject) |
---|
4393 | %------------------------------------------------------------------------ |
---|
4394 | %num is the view number needed for an avi movie |
---|
4395 | switch type_ima |
---|
4396 | case 'movie' |
---|
4397 | A=read(movieobject,num); |
---|
4398 | case 'avi' |
---|
4399 | mov=aviread(filename,num); |
---|
4400 | A=frame2im(mov(1)); |
---|
4401 | case 'multimage' |
---|
4402 | A=imread(filename,num); |
---|
4403 | case 'image' |
---|
4404 | A=imread(filename); |
---|
4405 | end |
---|
4406 | siz=size(A); |
---|
4407 | if length(siz)==3;%color images |
---|
4408 | A=sum(double(A),3); |
---|
4409 | A=uint16(A); |
---|
4410 | end |
---|
4411 | |
---|
4412 | %------------------------------------------------------------------------ |
---|
4413 | function ref_i_Callback(hObject, eventdata, handles) |
---|
4414 | %------------------------------------------------------------------------ |
---|
4415 | mode_list=get(handles.mode,'String'); |
---|
4416 | mode_value=get(handles.mode,'Value'); |
---|
4417 | mode=mode_list{mode_value}; |
---|
4418 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
4419 | if isequal(mode,'series(Di)') || ...% we do patch2 only |
---|
4420 | (get(handles.CIV2,'Value')==0 && get(handles.CIV1,'Value')==0 && get(handles.FIX1,'Value')==0 && get(handles.PATCH1,'Value')==0) |
---|
4421 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
4422 | end |
---|
4423 | |
---|
4424 | %------------------------------------------------------------------------ |
---|
4425 | function ref_j_Callback(hObject, eventdata, handles) |
---|
4426 | %------------------------------------------------------------------------ |
---|
4427 | mode_list=get(handles.mode,'String'); |
---|
4428 | mode_value=get(handles.mode,'Value'); |
---|
4429 | mode=mode_list{mode_value}; |
---|
4430 | if isequal(get(handles.CIV1,'Value'),0)|| isequal(mode,'series(Dj)') |
---|
4431 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
4432 | end |
---|
4433 | if isequal(mode,'series(Dj)') || ... |
---|
4434 | (get(handles.CIV2,'Value')==0 && get(handles.CIV1,'Value')==0 && get(handles.FIX1,'Value')==0 && get(handles.PATCH1,'Value')==0) |
---|
4435 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
4436 | end |
---|
4437 | |
---|
4438 | %------------------------------------------------------------------------ |
---|
4439 | function ref_i_civ2_Callback(hObject, eventdata, handles) |
---|
4440 | %------------------------------------------------------------------------ |
---|
4441 | mode_list=get(handles.mode,'String'); |
---|
4442 | mode_value=get(handles.mode,'Value'); |
---|
4443 | mode=mode_list{mode_value}; |
---|
4444 | find_netcpair_civ2(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
4445 | |
---|
4446 | %------------------------------------------------------------------------ |
---|
4447 | function ref_j_civ2_Callback(hObject, eventdata, handles) |
---|
4448 | %------------------------------------------------------------------------ |
---|
4449 | mode_list=get(handles.mode,'String'); |
---|
4450 | mode_value=get(handles.mode,'Value'); |
---|
4451 | mode=mode_list{mode_value}; |
---|
4452 | if isequal(mode,'series(Dj)') |
---|
4453 | find_netcpair_civ2(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
4454 | end |
---|
4455 | |
---|
4456 | %------------------------------------------------------------------------ |
---|
4457 | % --- Executes on button press in compare. |
---|
4458 | function compare_Callback(hObject, eventdata, handles) |
---|
4459 | %------------------------------------------------------------------------ |
---|
4460 | test=get(handles.compare,'Value'); |
---|
4461 | if test==2 || test==3 |
---|
4462 | filebase=get(handles.RootName,'String'); |
---|
4463 | browse=get(handles.browse_root,'Userdata'); |
---|
4464 | browse.nom_type_ima1=browse.nom_type_ima; |
---|
4465 | set(handles.browse_root,'UserData',browse); |
---|
4466 | set(handles.sub_txt,'Visible','on') |
---|
4467 | set(handles.RootName_1,'Visible','On');%mkes the second file input window visible |
---|
4468 | mode_store=get(handles.mode,'String');%get the present 'mode' |
---|
4469 | set(handles.compare,'UserData',mode_store);%store the mode display |
---|
4470 | set(handles.mode,'Visible','off') |
---|
4471 | if test==2 |
---|
4472 | set(handles.mode,'Visible','off') |
---|
4473 | else |
---|
4474 | set(handles.mode,'Visible','on') |
---|
4475 | end |
---|
4476 | |
---|
4477 | %% open an image file with the browser |
---|
4478 | ind_opening=1;%default |
---|
4479 | browse.incr_pair=[0 0]; %default |
---|
4480 | oldfile=get(handles.RootName,'String'); |
---|
4481 | menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)'; |
---|
4482 | '*.xml', '.xml files '; ... |
---|
4483 | '*.civ', '.civ files '; ... |
---|
4484 | '*.png','.png image files'; ... |
---|
4485 | '*.jpg',' jpeg image files'; ... |
---|
4486 | '*.tif','.tif image files'; ... |
---|
4487 | '*.avi;*.AVI','.avi movie files'; ... |
---|
4488 | '*.nc','.netcdf files'; ... |
---|
4489 | '*.*', 'All Files (*.*)'}; |
---|
4490 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file of the second series',oldfile); |
---|
4491 | fileinput=[PathName FileName];%complete file name |
---|
4492 | sizf=size(fileinput); |
---|
4493 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
4494 | [path,name,ext]=fileparts(fileinput); |
---|
4495 | [path1]=fileparts(filebase); |
---|
4496 | % if isunix |
---|
4497 | % ['readlink ' path] |
---|
4498 | % [status,path]=system(['readlink ' path]) |
---|
4499 | % [status,path1]=system(['readlink ' path1])% look for the true path in case of symbolic paths |
---|
4500 | % end |
---|
4501 | if ~strcmp(path1,path) |
---|
4502 | msgbox_uvmat('ERROR','The two input image series must be in the same directory') |
---|
4503 | return |
---|
4504 | end |
---|
4505 | set(handles.RootName_1,'String',name); |
---|
4506 | [RootPath,RootFile,field_count,str2,str_a,str_b,xx,nom_type,subdir]=name2display(name); |
---|
4507 | browse=get(handles.browse_root,'UserData'); |
---|
4508 | browse.nom_type_ima_1=nom_type; |
---|
4509 | set(handles.browse_root,'UserData',browse) |
---|
4510 | |
---|
4511 | %check image extension |
---|
4512 | if ~strcmp(ext,get(handles.ImaExt,'String')) |
---|
4513 | msgbox_uvmat('ERROR','The two input image series must have the same extension name') |
---|
4514 | return |
---|
4515 | end |
---|
4516 | |
---|
4517 | %% check coincidence of image sizes |
---|
4518 | ref_i=get(handles.ref_i,'string'); |
---|
4519 | ref_j=get(handles.ref_j,'string'); |
---|
4520 | [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc]=set_civ_filenames(handles,ref_i,ref_j,[1 0 0 0 0 0]); |
---|
4521 | A=imread(filecell.ima1.civ1{1}); |
---|
4522 | A_1=imread(fileinput); |
---|
4523 | npxy=size(A); |
---|
4524 | npxy_1=size(A_1); |
---|
4525 | if ~isequal(size(A),size(A_1)) |
---|
4526 | msgbox_uvmat('ERROR','The two input image series do not have the same size') |
---|
4527 | return |
---|
4528 | end |
---|
4529 | else |
---|
4530 | set(handles.mode,'Visible','on') |
---|
4531 | set(handles.RootName_1,'Visible','Off'); |
---|
4532 | set(handles.sub_txt,'Visible','off') |
---|
4533 | set(handles.RootName_1,'String',[]); |
---|
4534 | mode_store=get(handles.compare,'UserData'); |
---|
4535 | set(handles.mode,'Value',1) |
---|
4536 | set(handles.mode,'String',mode_store) |
---|
4537 | set(handles.test_stereo1,'Value',0) |
---|
4538 | set(handles.test_stereo2,'Value',0) |
---|
4539 | end |
---|
4540 | if test==3 && get(handles.PATCH1,'Value') |
---|
4541 | set(handles.stereo1,'Visible','on') |
---|
4542 | else |
---|
4543 | set(handles.stereo1,'Visible','off') |
---|
4544 | end |
---|
4545 | if test==3 && get(handles.PATCH2,'Value') |
---|
4546 | set(handles.stereo2,'Visible','on') |
---|
4547 | else |
---|
4548 | set(handles.stereo2,'Visible','off') |
---|
4549 | end |
---|
4550 | mode_Callback(hObject, eventdata, handles) |
---|
4551 | |
---|
4552 | %------------------------------------------------------------------------ |
---|
4553 | % --- Executes on button press in get_ref_fix1. |
---|
4554 | function get_ref_fix1_Callback(hObject, eventdata, handles) |
---|
4555 | %------------------------------------------------------------------------ |
---|
4556 | filebase=get(handles.RootName,'String'); |
---|
4557 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
4558 | {'*.nc', ' (*.nc)'; |
---|
4559 | '*.nc', 'netcdf files '; ... |
---|
4560 | '*.*', 'All Files (*.*)'}, ... |
---|
4561 | 'Pick a file',filebase); |
---|
4562 | |
---|
4563 | fileinput=[PathName FileName]; |
---|
4564 | sizf=size(fileinput); |
---|
4565 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
4566 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
4567 | ref.filebase=fullfile(Path,File); |
---|
4568 | ref.num_a=stra2num(str_a); |
---|
4569 | ref.num_b=stra2num(str_b); |
---|
4570 | ref.num1=str2double(field_count); |
---|
4571 | ref.num2=str2double(str2); |
---|
4572 | browse=[];%initialisation |
---|
4573 | if ~isequal(ref.ext,'.nc') |
---|
4574 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
4575 | return |
---|
4576 | end |
---|
4577 | set(handles.ref_fix1,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
4578 | set(handles.ref_fix1,'UserData',ref) |
---|
4579 | menu_field{1}='civ1'; |
---|
4580 | Data=nc2struct(fileinput,[]); |
---|
4581 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
4582 | menu_field{2}='filter1'; |
---|
4583 | end |
---|
4584 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
4585 | menu_field{3}='civ2'; |
---|
4586 | end |
---|
4587 | if isfield(Data,'patch2') && isequal(Data.patch2,1) |
---|
4588 | menu_field{4}='filter2'; |
---|
4589 | end |
---|
4590 | set(handles.field_ref1,'String',menu_field); |
---|
4591 | set(handles.field_ref1,'Value',length(menu_field)); |
---|
4592 | set(handles.inf_sup1,'Value',2); |
---|
4593 | set(handles.thresh_vel,'String','1');%default threshold |
---|
4594 | set(handles.ref_fix1,'Enable','on') |
---|
4595 | |
---|
4596 | %------------------------------------------------------------------------ |
---|
4597 | % --- Executes on button press in get_ref_fix2. |
---|
4598 | function get_ref_fix2_Callback(hObject, eventdata, handles) |
---|
4599 | %------------------------------------------------------------------------ |
---|
4600 | if isequal(get(handles.get_ref_fix2,'Value'),1) |
---|
4601 | filebase=get(handles.RootName,'String'); |
---|
4602 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
4603 | {'*.nc', ' (*.nc)'; |
---|
4604 | '*.nc', 'netcdf files '; ... |
---|
4605 | '*.*', 'All Files (*.*)'}, ... |
---|
4606 | 'Pick a file',filebase); |
---|
4607 | fileinput=[PathName FileName]; |
---|
4608 | sizf=size(fileinput); |
---|
4609 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
4610 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
4611 | ref.filebase=fullfile(Path,File); |
---|
4612 | ref.num_a=stra2num(str_a); |
---|
4613 | ref.num_b=stra2num(str_b); |
---|
4614 | ref.num1=str2num(field_count); |
---|
4615 | ref.num2=str2num(str2); |
---|
4616 | browse=[];%initialisation |
---|
4617 | if ~isequal(ref.ext,'.nc') |
---|
4618 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
4619 | return |
---|
4620 | end |
---|
4621 | set(handles.ref_fix2,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
4622 | set(handles.ref_fix2,'UserData',ref) |
---|
4623 | menu_field{1}='civ1'; |
---|
4624 | Data=nc2struct(fileinput,[]); |
---|
4625 | if isfield(Data,'patch') & isequal(Data.patch,1) |
---|
4626 | menu_field{2}='filter1'; |
---|
4627 | end |
---|
4628 | if isfield(Data,'civ2') & isequal(Data.civ2,1) |
---|
4629 | menu_field{3}='civ2'; |
---|
4630 | end |
---|
4631 | if isfield(Data,'patch2') & isequal(Data.patch2,1) |
---|
4632 | menu_field{4}='filter2'; |
---|
4633 | end |
---|
4634 | set(handles.field_ref2,'String',menu_field); |
---|
4635 | set(handles.field_ref2,'Value',length(menu_field)); |
---|
4636 | set(handles.inf_sup2,'Value',2); |
---|
4637 | set(handles.thresh_vel2,'String','1');%default threshold |
---|
4638 | set(handles.ref_fix2,'Enable','on') |
---|
4639 | set(handles.ref_fix2,'Visible','on') |
---|
4640 | set(handles.field_ref2,'Visible','on') |
---|
4641 | else |
---|
4642 | set(handles.ref_fix2,'Visible','off') |
---|
4643 | set(handles.field_ref2,'Visible','off') |
---|
4644 | end |
---|
4645 | |
---|
4646 | %------------------------------------------------------------------------ |
---|
4647 | function ref_fix1_Callback(hObject, eventdata, handles) |
---|
4648 | %------------------------------------------------------------------------ |
---|
4649 | set(handles.inf_sup1,'Value',1); |
---|
4650 | set(handles.field_ref1,'Value',1) |
---|
4651 | set(handles.field_ref1,'String',{' '}) |
---|
4652 | set(handles.ref_fix1,'UserData',[]); |
---|
4653 | set(handles.ref_fix1,'String',''); |
---|
4654 | set(handles.thresh_vel1,'String','0'); |
---|
4655 | |
---|
4656 | %------------------------------------------------------------------------ |
---|
4657 | function ref_fix2_Callback(hObject, eventdata, handles) |
---|
4658 | %------------------------------------------------------------------------ |
---|
4659 | set(handles.inf_sup2,'Value',1); |
---|
4660 | set(handles.field_ref2,'Value',1) |
---|
4661 | set(handles.field_ref2,'String',{' '}) |
---|
4662 | set(handles.ref_fix2,'UserData',[]); |
---|
4663 | set(handles.ref_fix2,'String',''); |
---|
4664 | set(handles.thresh_vel2,'String','0'); |
---|
4665 | |
---|
4666 | %------------------------------------------------------------------------ |
---|
4667 | % --- Executes on button press in test_stereo1. |
---|
4668 | function test_stereo1_Callback(hObject, eventdata, handles) |
---|
4669 | %------------------------------------------------------------------------ |
---|
4670 | if isequal(get(handles.test_stereo1,'Value'),0) |
---|
4671 | set(handles.subdomain_patch1,'Visible','on') |
---|
4672 | set(handles.rho_patch1,'Visible','on') |
---|
4673 | else |
---|
4674 | set(handles.subdomain_patch1,'Visible','off') |
---|
4675 | set(handles.rho_patch1,'Visible','off') |
---|
4676 | end |
---|
4677 | |
---|
4678 | %------------------------------------------------------------------------ |
---|
4679 | % --- Executes on button press in test_stereo2. |
---|
4680 | function test_stereo2_Callback(hObject, eventdata, handles) |
---|
4681 | %------------------------------------------------------------------------ |
---|
4682 | if isequal(get(handles.test_stereo2,'Value'),0) |
---|
4683 | set(handles.subdomain_patch2,'Visible','on') |
---|
4684 | set(handles.rho_patch2,'Visible','on') |
---|
4685 | else |
---|
4686 | set(handles.subdomain_patch2,'Visible','off') |
---|
4687 | set(handles.rho_patch2,'Visible','off') |
---|
4688 | end |
---|
4689 | |
---|
4690 | %------------------------------------------------------------------------ |
---|
4691 | % --- Executes on button press in ImaThreshold. |
---|
4692 | function ImaThreshold_Callback(hObject, eventdata, handles) |
---|
4693 | %------------------------------------------------------------------------ |
---|
4694 | if isequal(get(handles.ImaThreshold,'Value'),1) |
---|
4695 | set(handles.MinIma,'Visible','on') |
---|
4696 | set(handles.MaxIma,'Visible','on') |
---|
4697 | else |
---|
4698 | set(handles.MinIma,'Visible','off') |
---|
4699 | set(handles.MaxIma,'Visible','off') |
---|
4700 | end |
---|
4701 | |
---|
4702 | %------------------------------------------------------------------------ |
---|
4703 | % --- Executes on button press in ImaThreshold2. |
---|
4704 | function ImaThreshold2_Callback(hObject, eventdata, handles) |
---|
4705 | %------------------------------------------------------------------------ |
---|
4706 | if isequal(get(handles.ImaThreshold2,'Value'),1) |
---|
4707 | set(handles.MinIma2,'Visible','on') |
---|
4708 | set(handles.MaxIma2,'Visible','on') |
---|
4709 | else |
---|
4710 | set(handles.MinIma2,'Visible','off') |
---|
4711 | set(handles.MaxIma2,'Visible','off') |
---|
4712 | end |
---|
4713 | |
---|
4714 | %------------------------------------------------------------------------ |
---|
4715 | % --- Executes on button press in TestCiv1: display image correlation function |
---|
4716 | function TestCiv1_Callback(hObject, eventdata, handles) |
---|
4717 | %------------------------------------------------------------------------ |
---|
4718 | set(handles.TestCiv1,'BackgroundColor',[1 1 0]) |
---|
4719 | drawnow |
---|
4720 | test_civ1=get(handles.TestCiv1,'Value'); |
---|
4721 | if test_civ1 |
---|
4722 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
4723 | if strcmp(get(handles.ref_j,'Visible'),'on') |
---|
4724 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
4725 | else |
---|
4726 | ref_j=1;%default |
---|
4727 | end |
---|
4728 | [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc,file_ref_fix1,file_ref_fix2]=... |
---|
4729 | set_civ_filenames(handles,ref_i,ref_j,[1 0 0 0 0 0]) |
---|
4730 | Data.ListVarName={'ny','nx','A'}; |
---|
4731 | Data.VarDimName={'ny','nx',{'ny','nx'}}; |
---|
4732 | Data.A=imread(filecell.ima1.civ1{1}); |
---|
4733 | Data.ny=[size(Data.A,1) 1]; |
---|
4734 | Data.nx=[1 size(Data.A,2)]; |
---|
4735 | par_civ1=read_param_civ1(handles,filecell.ima1.civ1{1}); |
---|
4736 | par_civ1.filename_ima_a=filecell.ima1.civ1{1}; |
---|
4737 | par_civ1.filename_ima_b=filecell.ima2.civ1{1}; |
---|
4738 | par_civ1.T0=0; |
---|
4739 | par_civ1.Dt=1; |
---|
4740 | Param.Civ1=par_civ1; |
---|
4741 | Data=civ_uvmat(Param); |
---|
4742 | Data.ListVarName=[Data.ListVarName {'ny','nx','A'}]; |
---|
4743 | Data.VarDimName=[Data.VarDimName {'ny','nx',{'ny','nx'}}]; |
---|
4744 | Data.A=imread(filecell.ima1.civ1{1}); |
---|
4745 | Data.ny=[size(Data.A,1) 1]; |
---|
4746 | Data.nx=[1 size(Data.A,2)]; |
---|
4747 | hview_field=view_field(Data); |
---|
4748 | set(0,'CurrentFigure',hview_field) |
---|
4749 | hhview_field=guihandles(hview_field); |
---|
4750 | set(hview_field,'CurrentAxes',hhview_field.axes3) |
---|
4751 | ViewData=get(hview_field,'UserData'); |
---|
4752 | ViewData.CivHandle=handles.civ;% indicate the handle of the civ GUI in view_field |
---|
4753 | ViewData.axes3.B=imread(filecell.ima2.civ1{1});%store the second image in the UserData of the GUI view_field |
---|
4754 | ViewData.axes3.X=Data.Civ1_X; %keep the set of points in memeory |
---|
4755 | ViewData.axes3.Y=Data.Civ1_Y; |
---|
4756 | set(hview_field,'UserData',ViewData) |
---|
4757 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
4758 | if isempty(corrfig) |
---|
4759 | corrfig=figure; |
---|
4760 | set(corrfig,'tag','corrfig') |
---|
4761 | set(corrfig,'name','image correlation') |
---|
4762 | set(corrfig,'DeleteFcn',{@closeview_field})% |
---|
4763 | end |
---|
4764 | set(handles.TestCiv1,'BackgroundColor',[1 0 0]) |
---|
4765 | else |
---|
4766 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
4767 | if ~isempty(corrfig) |
---|
4768 | delete(corrfig) |
---|
4769 | end |
---|
4770 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
4771 | if ~isempty(hview_field) |
---|
4772 | delete(hview_field) |
---|
4773 | end |
---|
4774 | end |
---|
4775 | |
---|
4776 | function closeview_field(gcbo,eventdata) |
---|
4777 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
4778 | if ~isempty(hview_field) |
---|
4779 | delete(hview_field) |
---|
4780 | end |
---|
4781 | %------------------------------------------------------------------- |
---|
4782 | % --- Executes on button press in status. |
---|
4783 | function status_Callback(hObject, eventdata, handles) |
---|
4784 | %------------------------------------------------------------------- |
---|
4785 | val=get(handles.status,'Value'); |
---|
4786 | if val==0 |
---|
4787 | set(handles.status,'BackgroundColor',[0 1 0]) |
---|
4788 | hfig=findobj(allchild(0),'name','civ_status'); |
---|
4789 | if ~isempty(hfig) |
---|
4790 | delete(hfig) |
---|
4791 | end |
---|
4792 | return |
---|
4793 | end |
---|
4794 | set(handles.status,'BackgroundColor',[1 1 0]) |
---|
4795 | drawnow |
---|
4796 | listtype={'civ1','fix1','patch1','civ2','fix2','patch2'}; |
---|
4797 | box_test(1)=get(handles.CIV1,'Value'); |
---|
4798 | box_test(2)=get(handles.FIX1,'Value'); |
---|
4799 | box_test(3)=get(handles.PATCH1,'Value'); |
---|
4800 | box_test(4)=get(handles.CIV2,'Value'); |
---|
4801 | box_test(5)=get(handles.FIX2,'Value'); |
---|
4802 | box_test(6)=get(handles.PATCH2,'Value'); |
---|
4803 | option_civ=find(box_test,1,'last');%last selected option (non-zero index of box_test) |
---|
4804 | filecell=get(handles.civ,'UserData');%retrieve the list of output files expected for PIV |
---|
4805 | test_new=0; |
---|
4806 | if ~isfield(filecell,'nc') |
---|
4807 | test_new=1; |
---|
4808 | [ref_i,ref_j,errormsg]=find_ref_indices(handles); |
---|
4809 | if ~isempty(errormsg) |
---|
4810 | msgbox_uvmat('ERROR',errormsg) |
---|
4811 | return |
---|
4812 | end |
---|
4813 | filecell=set_civ_filenames(handles,ref_i,ref_j,box_test);%determine the output file expected from the GUI status |
---|
4814 | end |
---|
4815 | if ~isequal(box_test(4:6),[0 0 0]) |
---|
4816 | civ_files=filecell.nc.civ2;%case of civ2 operations |
---|
4817 | else |
---|
4818 | civ_files=filecell.nc.civ1; |
---|
4819 | end |
---|
4820 | [root,filename,ext]=fileparts(civ_files{1}); |
---|
4821 | [rootroot,subdir,extdir]=fileparts(root); |
---|
4822 | hfig=findobj(allchild(0),'name','civ_status'); |
---|
4823 | if isempty(hfig) |
---|
4824 | hfig=figure('DeleteFcn',@stop_status); |
---|
4825 | set(hfig,'name','civ_status') |
---|
4826 | hlist=uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', @open_view_field,'tag','list'); |
---|
4827 | uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','msgbox','Max',2,'String','checking files...'); |
---|
4828 | uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]); |
---|
4829 | uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'String','OK','FontWeight','bold','FontUnits','normalized','FontSize',0.9,'Callback',@close_GUI); |
---|
4830 | BarPosition=[0.05 0.81 0.01 0.05]; |
---|
4831 | hwaitbar=uicontrol('Style','frame','Units','normalized', 'Position',BarPosition ,'BackgroundColor',[1 0 0],'tag','waitbar'); |
---|
4832 | drawnow |
---|
4833 | end |
---|
4834 | % datnum=[]; |
---|
4835 | Tabchar={}; |
---|
4836 | nbfiles=numel(civ_files); |
---|
4837 | count=0; |
---|
4838 | testrecent=0; |
---|
4839 | while count<nbfiles |
---|
4840 | count=0; |
---|
4841 | datnum=zeros(1,nbfiles); |
---|
4842 | for ifile=1:nbfiles |
---|
4843 | detect=exist(civ_files{ifile},'file'); % check the existence of the file |
---|
4844 | option=0; |
---|
4845 | if detect==0 |
---|
4846 | option_str='not created'; |
---|
4847 | else |
---|
4848 | datfile=dir(civ_files{ifile}); |
---|
4849 | if isfield(datfile,'datenum') |
---|
4850 | datnum(ifile)=datfile.datenum;%only available in recent matlab versions |
---|
4851 | testrecent=1; |
---|
4852 | end |
---|
4853 | filefound(ifile)={datfile.name}; |
---|
4854 | lastfield=''; |
---|
4855 | % check the content netcdf file |
---|
4856 | Data=nc2struct(civ_files{ifile},'ListGlobalAttribute','patch2','fix2','civ2','patch','fix'); |
---|
4857 | if ~isempty(Data.patch2) && isequal(Data.patch2,1) |
---|
4858 | option=6; |
---|
4859 | option_str='patch2'; |
---|
4860 | elseif ~isempty(Data.fix2) && isequal(Data.fix2,1) |
---|
4861 | option=5; |
---|
4862 | option_str='fix2'; |
---|
4863 | elseif ~isempty(Data.civ2) && isequal(Data.civ2,1); |
---|
4864 | option=4; |
---|
4865 | option_str='civ2'; |
---|
4866 | elseif ~isempty(Data.patch) && isequal(Data.patch,1); |
---|
4867 | option=3; |
---|
4868 | option_str='patch1'; |
---|
4869 | elseif ~isempty(Data.fix) && isequal(Data.fix,1); |
---|
4870 | option=2; |
---|
4871 | option_str='fix1'; |
---|
4872 | else |
---|
4873 | option=1; |
---|
4874 | option_str='civ1'; |
---|
4875 | end |
---|
4876 | end |
---|
4877 | if option >= option_civ |
---|
4878 | count=count+1; |
---|
4879 | end |
---|
4880 | [rr,filename,ext]=fileparts(civ_files{ifile}); |
---|
4881 | Tabchar{ifile,1}=[fullfile([subdir extdir],filename) ext '...' option_str]; |
---|
4882 | end |
---|
4883 | datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files |
---|
4884 | if isempty(datnum) |
---|
4885 | if testrecent |
---|
4886 | message='no civ result created yet'; |
---|
4887 | else |
---|
4888 | message=''; |
---|
4889 | end |
---|
4890 | else |
---|
4891 | datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files |
---|
4892 | [first,ind]=min(datnum); |
---|
4893 | [last,indlast]=max(datnum); |
---|
4894 | if test_new |
---|
4895 | message='existing file status, no processing launched yet'; |
---|
4896 | else |
---|
4897 | message={[num2str(count) ' file(s) done over ' num2str(nbfiles)] ;['oldest modification: ' cell2mat(filefound(ind)) ' : ' datestr(first)];... |
---|
4898 | ['latest modification: ' cell2mat(filefound(indlast)) ' : ' datestr(last)]}; |
---|
4899 | end |
---|
4900 | end |
---|
4901 | hfig=findobj(allchild(0),'name','civ_status'); |
---|
4902 | if isempty(hfig)% the status list has been deleted |
---|
4903 | return |
---|
4904 | else |
---|
4905 | hlist=findobj(hfig,'tag','list'); |
---|
4906 | hmsgbox=findobj(hfig,'tag','msgbox'); |
---|
4907 | hwaitbar=findobj(hfig,'tag','waitbar'); |
---|
4908 | set(hlist,'String',Tabchar) |
---|
4909 | set(hmsgbox,'String', message) |
---|
4910 | if count>0 && ~test_new |
---|
4911 | BarPosition(3)=0.9*count/nbfiles; |
---|
4912 | set(hwaitbar,'Position',BarPosition) |
---|
4913 | end |
---|
4914 | end |
---|
4915 | set(hlist,'UserData',rootroot) |
---|
4916 | pause(10)% wait 10 seconds for next check |
---|
4917 | end |
---|
4918 | |
---|
4919 | |
---|
4920 | %------------------------------------------------------------------------ |
---|
4921 | % call 'view_field.fig' to display the field selected in the list of 'status' |
---|
4922 | function open_view_field(hObject, eventdata) |
---|
4923 | %------------------------------------------------------------------------ |
---|
4924 | list=get(hObject,'String'); |
---|
4925 | index=get(hObject,'Value'); |
---|
4926 | rootroot=get(hObject,'UserData'); |
---|
4927 | filename=list{index}; |
---|
4928 | ind_dot=findstr(filename,'...'); |
---|
4929 | filename=filename(1:ind_dot-1); |
---|
4930 | filename=fullfile(rootroot,filename); |
---|
4931 | delete(get(hObject,'parent'))%delete the display figure to stop the check process |
---|
4932 | if exist(filename,'file')%visualise the vel field if it exists |
---|
4933 | uvmat(filename) |
---|
4934 | set(gcbo,'Value',1) |
---|
4935 | end |
---|
4936 | |
---|
4937 | %------------------------------------------------------------------------ |
---|
4938 | % launched by pressing OK on the status figure |
---|
4939 | function close_GUI(hObject, eventdata) |
---|
4940 | %------------------------------------------------------------------------ |
---|
4941 | delete(gcbf) |
---|
4942 | |
---|
4943 | %------------------------------------------------------------------------ |
---|
4944 | % launched by deleting the status figure |
---|
4945 | function stop_status(hObject, eventdata) |
---|
4946 | %------------------------------------------------------------------------ |
---|
4947 | hciv=findobj(allchild(0),'tag','civ'); |
---|
4948 | hhciv=guidata(hciv); |
---|
4949 | set(hhciv.status,'value',0) %reset the status uicontrol in the GUI civ |
---|
4950 | set(hhciv.status,'BackgroundColor',[0 1 0]) |
---|
4951 | |
---|
4952 | %------------------------------------------------------------------------ |
---|
4953 | % --- Executes on button press in CivAll. |
---|
4954 | function CivAll_Callback(hObject, eventdata, handles) |
---|
4955 | %------------------------------------------------------------------------ |
---|
4956 | Listprog=get(handles.CivAll,'String'); |
---|
4957 | index=get(handles.CivAll,'Value'); |
---|
4958 | prog=Listprog{index}; |
---|
4959 | switch prog |
---|
4960 | case 'CivX' |
---|
4961 | set(handles.thresh_patch1,'Visible','off') |
---|
4962 | set(handles.thresh_text1,'Visible','off') |
---|
4963 | set(handles.thresh_patch2,'Visible','off') |
---|
4964 | set(handles.thresh_text2,'Visible','off') |
---|
4965 | set(handles.rho,'Style','edit') |
---|
4966 | set(handles.rho,'String','1') |
---|
4967 | set(handles.BATCH,'Enable','on') |
---|
4968 | case 'CivAll' |
---|
4969 | if get(handles.PATCH1,'Value') |
---|
4970 | set(handles.thresh_patch1,'Visible','on') |
---|
4971 | set(handles.thresh_text1,'Visible','on') |
---|
4972 | end |
---|
4973 | set(handles.rho,'Style','edit') |
---|
4974 | set(handles.rho,'String','1') |
---|
4975 | set(handles.BATCH,'Enable','on') |
---|
4976 | case 'CivUvmat' |
---|
4977 | if get(handles.PATCH1,'Value') |
---|
4978 | set(handles.thresh_patch1,'Visible','on') |
---|
4979 | set(handles.thresh_text1,'Visible','on') |
---|
4980 | end |
---|
4981 | if get(handles.PATCH2,'Value') |
---|
4982 | set(handles.thresh_patch2,'Visible','on') |
---|
4983 | set(handles.thresh_text2,'Visible','on') |
---|
4984 | end |
---|
4985 | set(handles.rho,'Style','popupmenu') |
---|
4986 | set(handles.rho,'Value',1) |
---|
4987 | set(handles.rho,'String',{'1';'2'}) |
---|
4988 | set(handles.BATCH,'Enable','off') |
---|
4989 | end |
---|
4990 | |
---|