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