[2] | 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 | |
---|
[12] | 24 | % Last Modified by GUIDE v2.5 10-Jan-2010 22:04:45 |
---|
[2] | 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 | |
---|
[12] | 44 | %------------------------------------------------------------------------ |
---|
[2] | 45 | % --- Executes just before civ is made visible. |
---|
| 46 | function civ_OpeningFcn(hObject, eventdata, handles, varargin) |
---|
[12] | 47 | %------------------------------------------------------------------------ |
---|
[2] | 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 test_batch patch_new_exe%=1 if 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 | nom_type=[]; % nomenclature type |
---|
| 68 | ext=[]; |
---|
| 69 | testall=0; |
---|
| 70 | browse=[]; |
---|
| 71 | |
---|
| 72 | %load the initial parameters if the interface is started from uvmat |
---|
| 73 | if ~isempty(varargin)% the interface is opened from uvmat |
---|
| 74 | varcell=varargin{1}; |
---|
| 75 | filebase=varcell{1}; |
---|
| 76 | nom_type_read=varcell{2}; |
---|
| 77 | num1=varcell{3}; |
---|
| 78 | num2=varcell{4}; |
---|
| 79 | num_a=varcell{5}; |
---|
| 80 | num_b=varcell{6}; |
---|
| 81 | subdir=varcell{7}; |
---|
| 82 | ind_opening=varcell{8}; |
---|
| 83 | ext=varcell{11}; |
---|
| 84 | else |
---|
| 85 | num1=1; % set of field i numbers |
---|
| 86 | num2=2; % set of field i numbers |
---|
| 87 | num_a=1; % set of field j numbers (fields a) |
---|
| 88 | num_b=1; % second set of field j numbers (fields b) |
---|
| 89 | subdir='A'; % subdir for the netcdf result files |
---|
| 90 | ind_opening=1; % proposed operation number (1=civ1,2=fix1,3=patch1,4=civ2,5=fix2,6=patch2) |
---|
| 91 | end |
---|
| 92 | |
---|
| 93 | if exist('ext','var') && length(ext)>1 && (~isempty(imformats(ext([2:end])))|... |
---|
| 94 | isequal(ext,'.avi')||isequal(ext,'.AVI'));%if an image file has been opened by uvmat |
---|
| 95 | set(handles.ext_ima,'String',ext) |
---|
| 96 | if exist('nom_type_read','var') |
---|
| 97 | browse.nom_type_ima=nom_type_read; % the image nomenclature is stored |
---|
| 98 | end |
---|
| 99 | elseif isequal(ext,'.nc') |
---|
| 100 | if exist('nom_type_read','var') |
---|
| 101 | browse.nom_type_nc=nom_type_read;% the netcdf nomenclature is stored |
---|
| 102 | end |
---|
| 103 | end |
---|
| 104 | set(handles.displ_filebase,'String',filebase); |
---|
| 105 | set(handles.ImaDoc,'UserData',testall); |
---|
| 106 | set(handles.ImaDoc,'String',ext) |
---|
| 107 | |
---|
| 108 | %read names of the .exe file to adjust the interface according to |
---|
| 109 | %available prog |
---|
| 110 | %read names of the .exe file |
---|
| 111 | path_uvmat=which('uvmat');% check the path detected for source file uvmat |
---|
| 112 | path_UVMAT=fileparts(path_uvmat); %path to UVMAT |
---|
| 113 | if isunix |
---|
| 114 | syst='LINUX'; |
---|
| 115 | %fid = fopen(fullfile(path_UVMAT,'PARAM_LINUX.txt'),'r');%open the file with civ binary names |
---|
| 116 | xmlfile=fullfile(path_UVMAT,'PARAM_LINUX.xml'); |
---|
| 117 | display(xmlfile) |
---|
| 118 | if exist(xmlfile,'file') |
---|
| 119 | t=xmltree(xmlfile); |
---|
| 120 | sparam=convert(t); |
---|
| 121 | end |
---|
| 122 | else |
---|
| 123 | syst='WIN'; |
---|
| 124 | xmlfile=fullfile(path_UVMAT,'PARAM_WIN.xml'); |
---|
| 125 | if exist(xmlfile,'file') |
---|
| 126 | t=xmltree(xmlfile); |
---|
| 127 | sparam=convert(t); |
---|
| 128 | end |
---|
| 129 | end |
---|
| 130 | display(syst) |
---|
| 131 | patch_new_exe=''; |
---|
| 132 | % todo_patch=''; |
---|
| 133 | sge=0; |
---|
| 134 | |
---|
| 135 | if isfield(sparam,'PatchNew_exe') |
---|
| 136 | patch_new_exe=sparam.PatchNew_exe; |
---|
| 137 | end |
---|
| 138 | if isfield(sparam,'Todo_path') |
---|
| 139 | todo_path=sparam.Todo_path; |
---|
| 140 | end |
---|
| 141 | if isfield(sparam,'SGE') |
---|
| 142 | sge=str2num(sparam.SGE); |
---|
| 143 | end |
---|
| 144 | name_todo=fullfile(todo_path,'TODO.txt'); |
---|
| 145 | display(name_todo) |
---|
| 146 | test_batch=1; |
---|
| 147 | if ~sge |
---|
[12] | 148 | if isequal(todo_path,'') || isequal(todo_path,[]) |
---|
| 149 | display(['no batch distributed processing available:file path TODO.txt not defined in UVMAT/PARAM_' syst]) |
---|
| 150 | test_batch=0; |
---|
| 151 | end |
---|
| 152 | if exist(name_todo,'file')~=2 |
---|
| 153 | msgbox_uvmat('WARNING',['no batch distributed processing available, queue file ' name_todo ' absent']); |
---|
| 154 | % test_batch=0; % Problems to detect file on linux/nfs filesystems |
---|
| 155 | end |
---|
[2] | 156 | end |
---|
| 157 | if test_batch==0 |
---|
| 158 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784])% put the BATCH button in grey (unactivated) |
---|
| 159 | end |
---|
| 160 | set(handles.subdir_civ1,'String',subdir)%default subdir on which uvmat was working |
---|
| 161 | set(handles.subdir_civ2,'String',subdir)%default subdir on which uvmat was working |
---|
| 162 | |
---|
| 163 | %initiate advised operations |
---|
| 164 | if isequal(ind_opening,[]) |
---|
| 165 | ind_opening=1; % default |
---|
| 166 | end |
---|
| 167 | % set default operation options |
---|
| 168 | enable_civ1(handles,'off') |
---|
| 169 | enable_civ2(handles,'off') |
---|
| 170 | enable_pair1(handles,'on') |
---|
| 171 | enable_fix1(handles,'off') |
---|
| 172 | desable_patch1(handles) |
---|
| 173 | desable_fix2(handles) |
---|
| 174 | desable_patch2(handles) |
---|
| 175 | set(handles.CIV1,'Value',0) |
---|
| 176 | set(handles.FIX1,'Value',0) |
---|
| 177 | set(handles.PATCH1,'Value',0) |
---|
| 178 | set(handles.CIV2,'Value',0) |
---|
| 179 | set(handles.FIX2,'Value',0) |
---|
| 180 | set(handles.PATCH2,'Value',0) |
---|
| 181 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 182 | if isequal(ind_opening,1) |
---|
| 183 | set(handles.CIV1,'Value',1) |
---|
| 184 | enable_civ1(handles,'on') |
---|
| 185 | elseif isequal(ind_opening,2) |
---|
| 186 | set(handles.FIX1,'Value',1) |
---|
| 187 | enable_fix1(handles,'on') |
---|
| 188 | elseif isequal(ind_opening,3) |
---|
| 189 | set(handles.PATCH1,'Value',1) |
---|
| 190 | enable_patch1(handles) |
---|
| 191 | elseif isequal(ind_opening,4) |
---|
| 192 | set(handles.CIV2,'Value',1) |
---|
| 193 | enable_civ2(handles,1) |
---|
| 194 | elseif isequal(ind_opening,5) |
---|
| 195 | set(handles.FIX2,'Value',1) |
---|
| 196 | enable_fix2(handles) |
---|
| 197 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 198 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 199 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 200 | enable_pair1(handles,'off') |
---|
| 201 | elseif isequal(ind_opening,6) |
---|
| 202 | set(handles.PATCH2,'Value',1) |
---|
| 203 | enable_patch2(handles) |
---|
| 204 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 205 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 206 | enable_pair1(handles,'off') |
---|
| 207 | end |
---|
| 208 | |
---|
| 209 | % set the range of fields (1:1 by default) and selected pair |
---|
[12] | 210 | if isempty(num2)||isequal(num2,num1) |
---|
[2] | 211 | num_ref_i=num1; |
---|
| 212 | else |
---|
| 213 | num_ref_i=floor((num1+num2)/2); |
---|
| 214 | browse.incr_pair(1)=num2-num1; |
---|
| 215 | browse.incr_pair(2)=0; |
---|
| 216 | end |
---|
[12] | 217 | if isempty(num_b)||isequal(num_a,num_b) |
---|
[2] | 218 | if isempty(num_a) |
---|
| 219 | num_ref_j=1; |
---|
| 220 | else |
---|
| 221 | num_ref_j=num_a; |
---|
| 222 | end |
---|
| 223 | else |
---|
| 224 | num_ref_j=floor((num_a+num_b)/2); |
---|
| 225 | browse.incr_pair(2)=num_b-num_a; |
---|
| 226 | end |
---|
| 227 | set(handles.first_i,'String',num2str(num_ref_i)); |
---|
| 228 | set(handles.last_i,'String',num2str(num_ref_i)); |
---|
| 229 | set(handles.first_j,'String',num2str(num_ref_j)); |
---|
| 230 | set(handles.last_j,'String',num2str(num_ref_j)); |
---|
| 231 | set(handles.ref_i,'String',num2str(num_ref_i)); |
---|
| 232 | set(handles.ref_j,'String',num2str(num_ref_j)); |
---|
| 233 | set(handles.browse_root,'UserData',browse); |
---|
| 234 | if ~isempty(varargin)% the interface is opened from uvmat |
---|
| 235 | displ_filebase_Callback(hObject, eventdata, handles); |
---|
| 236 | end |
---|
| 237 | |
---|
| 238 | set(handles.waitbar_1,'Position',[0.946 0.877 0.03 0.001]) |
---|
| 239 | set(handles.waitbar_patch1,'Position',[0.946 0.626 0.03 0.001]) |
---|
| 240 | set(handles.waitbar_civ2,'Position',[0.946 0.406 0.03 0.001]) |
---|
| 241 | set(handles.waitbar_patch2,'Position',[0.946 0.187 0.03 0.001]) |
---|
| 242 | |
---|
[12] | 243 | %------------------------------------------------------------------------ |
---|
[2] | 244 | % --- Outputs from this function are returned to the command line. |
---|
| 245 | function varargout = civ_OutputFcn(hObject, eventdata, handles) |
---|
[12] | 246 | %------------------------------------------------------------------------ |
---|
[2] | 247 | % varargout cell array for returning output args (see VARARGOUT); |
---|
| 248 | % hObject handle to figure |
---|
| 249 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 250 | % handles structure with handles and user data (see GUIDATA) |
---|
| 251 | % Get default command line output from handles structure |
---|
| 252 | varargout{1} = handles.output; |
---|
| 253 | |
---|
[12] | 254 | %------------------------------------------------------------------------ |
---|
[2] | 255 | % --- Executes on button press in browse_root. |
---|
| 256 | function browse_root_Callback(hObject, eventdata, handles) |
---|
[12] | 257 | %------------------------------------------------------------------------ |
---|
[2] | 258 | %get the input file properties |
---|
| 259 | filebase=get(handles.displ_filebase,'String'); |
---|
| 260 | oldfile=''; %default |
---|
| 261 | if isempty(filebase)|isequal(filebase,'')%loads the previously stored file name and set it as default in the file_input box |
---|
| 262 | dir_perso=prefdir; |
---|
| 263 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 264 | display(profil_perso) |
---|
| 265 | if exist(profil_perso,'file') |
---|
| 266 | h=load (profil_perso); |
---|
| 267 | if isfield(h,'filebase')&& ischar(h.filebase) |
---|
| 268 | oldfile=h.filebase; |
---|
| 269 | end |
---|
| 270 | if isfield(h,'RootPath') && ischar(h.RootPath) |
---|
| 271 | oldfile=h.RootPath; |
---|
| 272 | end |
---|
| 273 | end |
---|
| 274 | else |
---|
| 275 | oldfile=filebase; |
---|
| 276 | end |
---|
| 277 | testall=get(handles.ImaDoc,'UserData'); |
---|
| 278 | ind_opening=1;%default |
---|
| 279 | browse.incr_pair=[0 0]; %default |
---|
| 280 | if testall |
---|
| 281 | menu={'*.*', 'All Files (*.*)'; '*.xml; *.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ... |
---|
| 282 | '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc','.nc files'}; |
---|
| 283 | else % menu selecting only .civ or .avi files |
---|
| 284 | menu={'*.xml;*.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ... |
---|
| 285 | '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc', '.nc files';... |
---|
| 286 | '*.*', 'All Files (*.*)'}; |
---|
| 287 | end |
---|
| 288 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile); |
---|
| 289 | fileinput=[PathName FileName];%complete file name |
---|
| 290 | sizf=size(fileinput); |
---|
| 291 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
| 292 | [path,name,ext]=fileparts(fileinput); |
---|
| 293 | testeditxml=0; |
---|
| 294 | if isequal(ext,'.xml') |
---|
| 295 | testeditxml=1; |
---|
| 296 | t_browse=xmltree(fileinput); |
---|
| 297 | head_element=get(t_browse,1); |
---|
| 298 | if isfield(head_element,'name')& isequal(head_element.name,'ImaDoc') |
---|
| 299 | testeditxml=0; |
---|
| 300 | end |
---|
| 301 | end |
---|
| 302 | if testeditxml==1 | isequal(ext,'.xls') |
---|
| 303 | heditxml=editxml({fileinput}); |
---|
| 304 | set(heditxml,'Tag','browser') |
---|
| 305 | waitfor(heditxml,'Tag','idle') |
---|
| 306 | if ~ishandle(heditxml) |
---|
| 307 | return |
---|
| 308 | end |
---|
| 309 | attr=findobj(get(heditxml,'children'),'Tag','CurrentAttributes'); |
---|
| 310 | set(handles.browse,'UserData',fileinput)% store for future opening with browser |
---|
| 311 | fileinput=get(attr,'UserData'); |
---|
| 312 | if ~exist(fileinput,'file') |
---|
| 313 | return |
---|
| 314 | end |
---|
| 315 | end |
---|
| 316 | [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput); |
---|
| 317 | filebase=fullfile(RootPath,RootFile); |
---|
| 318 | if isequal(get(handles.compare,'Value'),1) |
---|
| 319 | browse=[];%initialisation |
---|
| 320 | else |
---|
| 321 | browse=get(handles.browse_root,'UserData'); |
---|
| 322 | end |
---|
| 323 | if length(ext)>1 & (~isempty(imformats(ext([2:end])))|... |
---|
| 324 | isequal(ext,'.avi')|isequal(ext,'.AVI'));%if an image file has been opened by uvmat |
---|
| 325 | set(handles.ext_ima,'String',ext) |
---|
| 326 | browse.nom_type_ima=nom_type; |
---|
| 327 | browse.field_count=str2num(field_count); |
---|
| 328 | A=imread(fileinput); |
---|
| 329 | npxy=size(A); |
---|
| 330 | set(handles.ext_ima,'UserData',npxy) |
---|
| 331 | end |
---|
| 332 | set(handles.ImaDoc,'String',ext); |
---|
| 333 | |
---|
| 334 | %%%%% read the state of the selected netcdf file to advise default operation |
---|
| 335 | if isequal(ext,'.nc') |
---|
| 336 | browse.nom_type_nc=nom_type; |
---|
| 337 | ind_opening=2;% propose 'fix' as the default option |
---|
| 338 | Data=nc2struct(fileinput,[]); |
---|
| 339 | if isfield(Data,'absolut_time_T0')%test for civx files |
---|
| 340 | if isfield(Data,'fix') && isequal(Data.fix,1) |
---|
| 341 | ind_opening=3; |
---|
| 342 | end |
---|
| 343 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
| 344 | ind_opening=4; |
---|
| 345 | end |
---|
| 346 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
| 347 | ind_opening=5; |
---|
| 348 | end |
---|
| 349 | if isfield(Data,'fix2') && isequal(Data.fix2,1) |
---|
| 350 | ind_opening=6; |
---|
| 351 | end |
---|
| 352 | testciv=1; %TO SUPPRESS WITH NEW VERSION OF CIVX |
---|
| 353 | else |
---|
| 354 | ind_opening=3; %GUI used only for patch |
---|
| 355 | testciv=0; |
---|
| 356 | end |
---|
| 357 | set(handles.subdir_civ1,'String',subdir);%set the default subdir directories for installing the .nc results |
---|
| 358 | set(handles.subdir_civ2,'String',subdir); |
---|
| 359 | browse.testciv=testciv; |
---|
| 360 | browse.ind_opening=ind_opening; |
---|
| 361 | end |
---|
| 362 | set(handles.displ_filebase,'String',filebase); |
---|
| 363 | set(handles.ImaDoc,'String',ext); |
---|
| 364 | if ~isempty(str2num(field_count)) |
---|
| 365 | ref_i=str2num(field_count); |
---|
| 366 | if ~isempty(str2num(str2)) |
---|
| 367 | ref_i=floor((ref_i+str2num(str2))/2);% reference image number corresponding to the file |
---|
| 368 | browse.incr_pair(1)=str2num(str2)-str2num(field_count); |
---|
| 369 | browse.incr_pair(2)=0; |
---|
| 370 | end |
---|
| 371 | set(handles.first_i,'String',num2str(ref_i)); |
---|
| 372 | set(handles.last_i,'String',num2str(ref_i)); |
---|
| 373 | set(handles.ref_i,'String',num2str(ref_i)); |
---|
| 374 | end |
---|
| 375 | if isempty(str2num(str_a)) |
---|
| 376 | set(handles.ref_j,'String','1'); |
---|
| 377 | else |
---|
| 378 | ref_j=str2num(str_a); |
---|
| 379 | if ~isempty(str2num(str_b)) |
---|
| 380 | ref_j=floor((str2num(str_a)+str2num(str_b))/2); |
---|
| 381 | browse.incr_pair(2)=str2num(str_b)-str2num(str_a); |
---|
| 382 | end |
---|
| 383 | set(handles.first_j,'String',num2str(ref_j)); |
---|
| 384 | set(handles.last_j,'String',num2str(ref_j)); |
---|
| 385 | set(handles.ref_j,'String',num2str(ref_j)); |
---|
| 386 | end |
---|
| 387 | |
---|
| 388 | % set default operation options |
---|
| 389 | enable_civ1(handles,'off') |
---|
| 390 | enable_civ2(handles,'off') |
---|
| 391 | enable_pair1(handles,'on') |
---|
| 392 | enable_fix1(handles,'off') |
---|
| 393 | desable_patch1(handles) |
---|
| 394 | desable_fix2(handles) |
---|
| 395 | desable_patch2(handles) |
---|
| 396 | set(handles.CIV1,'Value',0) |
---|
| 397 | set(handles.FIX1,'Value',0) |
---|
| 398 | set(handles.PATCH1,'Value',0) |
---|
| 399 | set(handles.CIV2,'Value',0) |
---|
| 400 | set(handles.FIX2,'Value',0) |
---|
| 401 | set(handles.PATCH2,'Value',0) |
---|
| 402 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 403 | if isequal(ind_opening,1) |
---|
| 404 | set(handles.CIV1,'Value',1) |
---|
| 405 | enable_civ1(handles,'on') |
---|
| 406 | elseif isequal(ind_opening,2) |
---|
| 407 | set(handles.FIX1,'Value',1) |
---|
| 408 | enable_fix1(handles,'on') |
---|
| 409 | elseif isequal(ind_opening,3) |
---|
| 410 | set(handles.PATCH1,'Value',1) |
---|
| 411 | enable_patch1(handles) |
---|
| 412 | elseif isequal(ind_opening,4) |
---|
| 413 | set(handles.CIV2,'Value',1) |
---|
| 414 | enable_civ2(handles,1) |
---|
| 415 | elseif isequal(ind_opening,5) |
---|
| 416 | enable_pair1(handles,'off') |
---|
| 417 | set(handles.FIX2,'Value',1) |
---|
| 418 | enable_fix2(handles) |
---|
| 419 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 420 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 421 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 422 | elseif isequal(ind_opening,6) |
---|
| 423 | enable_pair1(handles,'off') |
---|
| 424 | set(handles.PATCH2,'Value',1) |
---|
| 425 | enable_patch2(handles) |
---|
| 426 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 427 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 428 | end |
---|
| 429 | set(handles.browse_root,'UserData',browse);% store information from browser |
---|
| 430 | testall=isequal(menu(filtindex,1),{'*.*'}); |
---|
| 431 | set(handles.ImaDoc,'UserData',testall); |
---|
| 432 | |
---|
| 433 | displ_filebase_Callback(hObject, eventdata, handles); |
---|
| 434 | |
---|
[12] | 435 | %------------------------------------------------------------------------ |
---|
[2] | 436 | function ImaDoc_Callback(hObject, eventdata, handles) |
---|
[12] | 437 | %------------------------------------------------------------------------ |
---|
[2] | 438 | displ_filebase_Callback(hObject, eventdata, handles) |
---|
| 439 | |
---|
[12] | 440 | %------------------------------------------------------------------------ |
---|
[2] | 441 | %function activated when a new filebase (image series) is introduced |
---|
| 442 | function displ_filebase_Callback(hObject, eventdata, handles) |
---|
[12] | 443 | %------------------------------------------------------------------------ |
---|
[2] | 444 | global test_batch |
---|
| 445 | set(handles.compare,'Visible','on') |
---|
| 446 | ext_ima=get(handles.ext_ima,'String'); |
---|
| 447 | nom_type_ima=[];%default |
---|
| 448 | field_count=1;%default |
---|
| 449 | nom_type_nc=[]; |
---|
| 450 | npx=[];%default |
---|
| 451 | npy=[]; |
---|
| 452 | time=[]; |
---|
| 453 | TimeUnit=[]; %default |
---|
| 454 | CoordUnit=[];%default |
---|
| 455 | pxcmx_search=[];%default |
---|
| 456 | pxcmy_search=[];%default |
---|
| 457 | filebase=get(handles.displ_filebase,'String'); |
---|
| 458 | |
---|
| 459 | ext=get(handles.ImaDoc,'String'); |
---|
| 460 | browse=get(handles.browse_root,'UserData');%default |
---|
| 461 | if ~isempty(browse) |
---|
| 462 | if isfield(browse,'nom_type_ima') |
---|
[12] | 463 | nom_type_ima=browse.nom_type_ima;% get an image nomenclature type already determined by an input image name |
---|
[2] | 464 | end |
---|
| 465 | if isfield(browse,'field_count') |
---|
[12] | 466 | field_count=browse.field_count;% get an image index type already determined by an input file |
---|
[2] | 467 | end |
---|
| 468 | end |
---|
| 469 | |
---|
| 470 | %default first_i and j and increments |
---|
| 471 | first_i=str2num(get(handles.first_i,'String'));%value possibly set by uvmat_Opening |
---|
[12] | 472 | if isempty(first_i)|| first_i < 1 |
---|
[2] | 473 | first_i=1; %default first_i |
---|
| 474 | end |
---|
| 475 | last_i=str2num(get(handles.last_i,'String')); |
---|
[12] | 476 | if isempty(last_i)|| last_i < first_i |
---|
[2] | 477 | last_i=first_i; %default last_i |
---|
| 478 | end |
---|
| 479 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 480 | if isempty(first_j)| first_j < 1 |
---|
| 481 | first_j=1; %default first_j |
---|
| 482 | end |
---|
| 483 | last_j=str2num(get(handles.last_j,'String')); |
---|
| 484 | if isempty(last_j)| last_j < first_j |
---|
| 485 | last_j=first_j; %default last_j |
---|
| 486 | end |
---|
| 487 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
| 488 | if isempty(incr_i) | incr_i < 1; |
---|
| 489 | set(handles.incr_i,'String','1') %default incr_i |
---|
| 490 | end |
---|
| 491 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
| 492 | if isempty(incr_j) | incr_j < 1; |
---|
| 493 | set(handles.incr_j,'String','1') %default incr_j |
---|
| 494 | end |
---|
| 495 | dt=[];%default |
---|
| 496 | testmode=0;%default |
---|
| 497 | nbfield=[]; %default |
---|
| 498 | nburst=[];%default |
---|
| 499 | pxcmx=1; |
---|
| 500 | pxcmy=1; |
---|
| 501 | |
---|
| 502 | %look for an image documentation file |
---|
| 503 | if ~isequal(ext,'.xml') && ~isequal(ext,'.civ')&& ~isequal(ext,'.avi')&& ~isequal(ext,'.AVI') |
---|
| 504 | if exist([filebase '.xml'],'file') |
---|
| 505 | ext='.xml'; |
---|
| 506 | elseif exist([filebase '.civxml'],'file') |
---|
| 507 | ext='.civxml'; |
---|
| 508 | elseif exist([filebase '.civ'],'file') |
---|
| 509 | ext='.civ'; |
---|
| 510 | elseif exist([filebase '.avi'],'file') |
---|
| 511 | ext='.avi'; |
---|
| 512 | elseif exist([filebase '.AVI'],'file') |
---|
| 513 | ext='.AVI'; |
---|
| 514 | end |
---|
| 515 | set(handles.ImaDoc,'String',ext) |
---|
| 516 | end |
---|
| 517 | |
---|
| 518 | %%%%%%%% read image documentation file %%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 519 | mode=''; %default |
---|
| 520 | set(handles.ImaDoc,'BackgroundColor',[1 1 0]) |
---|
| 521 | drawnow |
---|
| 522 | %read the image documentation file if found |
---|
[12] | 523 | if isequal(ext,'.civxml') || isequal(ext,'.xml')|| isequal(ext,'.civ') |
---|
[2] | 524 | set(handles.ref_i,'Visible','On')%use a reference index |
---|
| 525 | set(handles.ref_j,'Visible','On') |
---|
| 526 | set(handles.dt,'Visible','Off') |
---|
[12] | 527 | set(handles.dt_text,'String','') |
---|
| 528 | elseif isequal(ext,'.avi') || isequal(ext,'.AVI') |
---|
[2] | 529 | set(handles.ref_j,'Visible','Off') |
---|
| 530 | set(handles.dt,'Visible','Off') |
---|
| 531 | set(handles.dt_text,'String','ref. ind.') |
---|
| 532 | else |
---|
| 533 | set(handles.ref_i,'Visible','Off') |
---|
| 534 | set(handles.ref_j,'Visible','Off') |
---|
| 535 | set(handles.dt,'Visible','On') |
---|
| 536 | set(handles.dt_text,'String','dt(ms)=') |
---|
| 537 | end |
---|
[12] | 538 | testima_xml=0; |
---|
[2] | 539 | if isequal(ext,'.civxml')%TO ABANDON |
---|
| 540 | [nbfield,nburst,time]=read_civxml([filebase '.civxml']); |
---|
| 541 | mode='pair j1-j2'; |
---|
| 542 | if isempty(nom_type_ima)% dtermine types by default if not already selected by browser or uvmat |
---|
| 543 | nom_type_ima='_i_j'; |
---|
| 544 | end |
---|
| 545 | elseif isequal(ext,'.xml') |
---|
| 546 | [XmlData,warntext]=imadoc2struct([filebase '.xml']); |
---|
| 547 | if isfield(XmlData,'Time') |
---|
| 548 | time=XmlData.Time; |
---|
| 549 | nbfield=size(XmlData.Time,1); |
---|
| 550 | nburst=size(XmlData.Time,2); |
---|
| 551 | end |
---|
| 552 | ext_ima_read=[]; |
---|
| 553 | nom_type_read=[]; |
---|
[12] | 554 | if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')&&ischar(XmlData.Heading.ImageName)% get image nom type and extension from the xml file |
---|
[2] | 555 | [PP,FF,fc,str2,str_a,str_b,ext_ima_read,nom_type_read]=name2display(XmlData.Heading.ImageName); |
---|
[12] | 556 | fullname=fullfile(fileparts(filebase),XmlData.Heading.ImageName) %full name (including path) of the first image defined by the xmle file, |
---|
| 557 | if exist(fullname,'file') |
---|
| 558 | testima_xml=1; |
---|
| 559 | else |
---|
| 560 | msgbox_uvmat('WARNING',['FirstImage ' fullname ' defined in the xml file does not exist']) |
---|
| 561 | end |
---|
[2] | 562 | end |
---|
| 563 | if isfield(XmlData,'Camera') |
---|
| 564 | if isfield(XmlData.Camera,'TimeUnit') |
---|
| 565 | TimeUnit=XmlData.Camera.TimeUnit; |
---|
| 566 | end |
---|
| 567 | if isfield(XmlData.Camera,'ImageSize') |
---|
| 568 | ImageSize=XmlData.Camera.ImageSize; |
---|
| 569 | if ~isempty(ImageSize)&& ~isempty(ImageSize) |
---|
| 570 | xindex=findstr(ImageSize,'x'); |
---|
| 571 | if length(xindex)>=2 |
---|
| 572 | npx=str2num(ImageSize(1:xindex(1)-1)); |
---|
| 573 | npy=str2num(ImageSize(xindex(1)+1:xindex(2)-1)); |
---|
| 574 | end |
---|
| 575 | end |
---|
| 576 | end |
---|
| 577 | end |
---|
| 578 | pxcmx_search=1; |
---|
| 579 | pxcmy_search=1; |
---|
| 580 | if isfield(XmlData,'GeometryCalib') |
---|
| 581 | tsai=XmlData.GeometryCalib; |
---|
| 582 | if isfield(tsai,'f') & isfield(tsai,'Tz') & isfield(tsai,'dpx') & isfield(tsai,'dpy')& isfield(tsai,'R') |
---|
| 583 | rot2D=tsai.R([1:2],[1,2]); |
---|
| 584 | pxcmx_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpx); |
---|
| 585 | pxcmy_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpy); |
---|
| 586 | end |
---|
| 587 | if isfield(tsai,'CoordUnit') |
---|
| 588 | CoordUnit=tsai.CoordUnit; |
---|
| 589 | end |
---|
| 590 | end |
---|
| 591 | if ~isempty(ext_ima_read) && ~isempty(nom_type_read) |
---|
| 592 | if isempty(ext_ima) |
---|
| 593 | ext_ima=ext_ima_read;% define image extension from the xml file if an image has not been opened previously |
---|
| 594 | else %keep the image extension |
---|
| 595 | if ~strcmp(ext_ima_read,ext_ima) |
---|
| 596 | msgbox_uvmat('WARNING',['FirtsImage extension ' ext_ima_read ' announced in the xml file inconsistent with the selected image']) |
---|
| 597 | end |
---|
| 598 | end |
---|
| 599 | nom_type_ima=nom_type_read; |
---|
| 600 | end |
---|
| 601 | elseif isequal(ext,'.civ')% case of .civ image documentation file |
---|
| 602 | [error,time,TimeUnit,mode,npx,npy]=read_imatext([filebase '.civ']); |
---|
[12] | 603 | if error==2, msgbox_uvmat('WARNING',['no file ' filebase '.civ']); |
---|
| 604 | elseif error==1, msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file'); |
---|
[2] | 605 | end |
---|
| 606 | % ext_ima='.png'; |
---|
| 607 | nom_type_ima='png_old'; |
---|
| 608 | elseif isequal(lower(ext),'.avi') |
---|
| 609 | nom_type_ima='*'; |
---|
| 610 | ext_ima=ext; |
---|
| 611 | set(handles.mode,'String',{'series(Di)'}) |
---|
| 612 | dt=0.04;%default |
---|
| 613 | if exist([filebase ext],'file')==2 |
---|
| 614 | info=aviinfo([filebase ext]);%read infos on the avi movie |
---|
| 615 | dt=1/info.FramesPerSecond;%time interval between successive frames |
---|
| 616 | nbfield=info.NumFrames;%number of frames |
---|
| 617 | end |
---|
| 618 | time=(dt*[0:nbfield-1])';%list of image times |
---|
| 619 | set(handles.dt,'String',num2str(dt*1000));%store the time interval between successive images |
---|
| 620 | end |
---|
| 621 | if isempty(time) |
---|
| 622 | set(handles.ImaDoc,'String',''); %xml file not used for timing |
---|
| 623 | end |
---|
| 624 | set(handles.ImaDoc,'BackgroundColor',[1 1 1]) |
---|
| 625 | |
---|
[12] | 626 | %get the imabe nomenclature type if not defiend by the input file nor by the xml file |
---|
| 627 | if isempty(nom_type_ima) |
---|
| 628 | %look for double image series '_i_j' |
---|
| 629 | dirima=dir([filebase '_' num2str(first_i) '_' num2str(first_j) '.*']); |
---|
| 630 | if isempty(dirima) |
---|
| 631 | % look for images series with sub marker '_' |
---|
| 632 | dirima=dir([filebase '_*' num2str(first_i) '.*']); |
---|
| 633 | if isempty(dirima) |
---|
| 634 | % look for other images series |
---|
| 635 | dirima=dir([filebase '*' num2str(first_i) '.*']); |
---|
| 636 | if ~isempty(dirima) |
---|
| 637 | [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name); |
---|
| 638 | end |
---|
| 639 | else |
---|
| 640 | [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name); |
---|
| 641 | end |
---|
| 642 | else |
---|
| 643 | [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name); |
---|
| 644 | end |
---|
| 645 | end |
---|
| 646 | |
---|
[2] | 647 | % no image documentation file found: look for a series of existing images or .nc files |
---|
| 648 | if isempty(time) && ~isequal(ext,'.nc') |
---|
[12] | 649 | subdir=get(handles.subdir_civ1,'String'); |
---|
| 650 | incr_pair=[0 0];%default |
---|
| 651 | if isfield(browse,'incr_pair') |
---|
| 652 | incr_pair=browse.incr_pair; |
---|
| 653 | end |
---|
| 654 | nbdetect=0;%test of detected images |
---|
| 655 | field_i=field_count; |
---|
| 656 | idetect=1; |
---|
| 657 | while idetect==1 %look for the maximum file number in the series |
---|
| 658 | field_i=field_i+1; |
---|
| 659 | imagename=name_generator(filebase,field_i,1,ext_ima,nom_type_ima); |
---|
| 660 | if strcmp(nom_type_ima,'none')||strcmp(nom_type_ima,'') |
---|
| 661 | idetect=0; %stop if the same image is repeated (if nom_type='none') |
---|
| 662 | nbdetect=1; |
---|
| 663 | else |
---|
| 664 | idetect=(exist(imagename,'file')==2); |
---|
| 665 | end |
---|
| 666 | %SEE CASE OF NETCDF FILES |
---|
| 667 | nbdetect=nbdetect+(exist(imagename,'file')==2); |
---|
| 668 | end |
---|
| 669 | nb_field=field_i;% last detected field number |
---|
| 670 | field_i=field_count;%look for the minimum file number in the series |
---|
| 671 | idetect=1; |
---|
| 672 | while idetect==1 |
---|
| 673 | field_i=field_i-1; |
---|
[2] | 674 | imagename=name_generator(filebase,field_i,1,ext_ima,nom_type_ima); |
---|
[12] | 675 | if isequal(nom_type_ima,'none')||strcmp(nom_type_ima,'') |
---|
| 676 | idetect=0; %stop if the same image is repeated (if nom_type='none') |
---|
| 677 | nbdetect=1; |
---|
[2] | 678 | else |
---|
| 679 | idetect=(exist(imagename,'file')==2); |
---|
| 680 | end |
---|
[12] | 681 | nbdetect=nbdetect+idetect; |
---|
| 682 | end |
---|
| 683 | first_i=max(field_i+1,1); |
---|
| 684 | %determine the set of times and possible intervals for CIV |
---|
| 685 | dt=(1/1000)*str2num(get(handles.dt,'String')); |
---|
| 686 | time=(dt*[0:nb_field-1])'; |
---|
| 687 | set(handles.mode,'String',{'series(Di)'}) |
---|
[2] | 688 | end |
---|
| 689 | if isequal(nom_type_ima,'none')% no file numbering used |
---|
| 690 | first_i=1; |
---|
| 691 | last_i=1; |
---|
| 692 | first_j=1; |
---|
| 693 | last_j=1; |
---|
| 694 | end |
---|
| 695 | if exist('time','var') |
---|
| 696 | if size(time,1)+size(time,2)>=3 % if there are at least two time values to define dt |
---|
| 697 | nbfield=size(time,1); |
---|
| 698 | nbfield2=size(time,2); |
---|
| 699 | set(handles.displ_filebase,'UserData',time); %store the set of times |
---|
| 700 | if isempty(TimeUnit) |
---|
[12] | 701 | set(handles.dt_unit,'String','dt in e-03'); |
---|
[2] | 702 | set(handles.TimeUnit,'String',''); |
---|
| 703 | else |
---|
[12] | 704 | set(handles.dt_unit,'String',['dt in m' TimeUnit]); |
---|
[2] | 705 | set(handles.TimeUnit,'String',TimeUnit); |
---|
| 706 | end |
---|
| 707 | set(handles.nb_field,'String',num2str(nbfield)); |
---|
| 708 | set(handles.nb_field2,'String',num2str(nbfield2)); |
---|
| 709 | end |
---|
| 710 | end |
---|
| 711 | set(handles.CoordUnit,'String',[CoordUnit '/']) |
---|
| 712 | set(handles.calcul_search,'UserData',[pxcmx_search pxcmy_search]); |
---|
| 713 | % npxy=[npy npx]; |
---|
| 714 | set(handles.ext_ima,'String',ext_ima) |
---|
| 715 | set(handles.first_i,'String',num2str(first_i)); |
---|
| 716 | set(handles.last_i,'String',num2str(last_i));% |
---|
| 717 | set(handles.first_j,'String',num2str(first_j)); |
---|
| 718 | set(handles.last_j,'String',num2str(last_j));% |
---|
| 719 | browse.nom_type_ima=nom_type_ima; |
---|
| 720 | set(handles.browse_root,'UserData',browse)% store the nomenclature type |
---|
| 721 | |
---|
| 722 | %%%%%%%%%%% set the menus of image pairs and default selection for civ %%%%%%%%%%%%%%%%%%% |
---|
| 723 | if isequal(nom_type_ima,'_i')| isequal(nom_type_nc,'_i1-i2')|~exist('nbfield2','var')|(nbfield2==1) |
---|
| 724 | set(handles.mode,'String',{'series(Di)'}) |
---|
| 725 | set(handles.mode,'Value',1) |
---|
| 726 | elseif isequal(nom_type_ima,'png_old')|isequal(nom_type_nc,'netc_old') |
---|
| 727 | set(handles.mode,'String',{'pair j1-j2'}) |
---|
| 728 | set(handles.mode,'Value',1) |
---|
| 729 | elseif (nbfield==1)% simple series in j |
---|
| 730 | set(handles.mode,'String',{'series(Dj)'}) |
---|
| 731 | set(handles.mode,'Value',1) |
---|
| 732 | else |
---|
| 733 | set(handles.mode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice |
---|
| 734 | if isequal(mode,'volume') |
---|
| 735 | set(handles.mode,'Value',3) |
---|
| 736 | elseif nbfield2 <= 5 |
---|
| 737 | set(handles.mode,'Value',1)% advice 'pair j1-j2' for small bursts |
---|
| 738 | else |
---|
| 739 | set(handles.mode,'Value',2)% advice series Dj for long bursts, not volume |
---|
| 740 | end |
---|
| 741 | end |
---|
| 742 | |
---|
| 743 | %update the subdir |
---|
| 744 | pathdir=fileparts(filebase);%path to the current xml file |
---|
| 745 | listot=dir(pathdir); |
---|
| 746 | idir=0; |
---|
| 747 | listdir={''};%default |
---|
| 748 | for ilist=1:length(listot) |
---|
| 749 | if listot(ilist).isdir |
---|
| 750 | name=listot(ilist).name; |
---|
| 751 | if ~isequal(name,'.') && ~isequal(name,'..') |
---|
| 752 | idir=idir+1; |
---|
| 753 | listdir{idir,1}=listot(ilist).name; |
---|
| 754 | end |
---|
| 755 | end |
---|
| 756 | end |
---|
| 757 | set(handles.list_subdir_civ1,'Value',1) |
---|
| 758 | set(handles.list_subdir_civ2,'Value',1) |
---|
| 759 | set(handles.list_subdir_civ1,'String',['browse...';listdir]) |
---|
| 760 | set(handles.list_subdir_civ2,'String',['browse...';listdir]) |
---|
| 761 | %check wether the current subdir exists: |
---|
| 762 | subdir_civ1=get(handles.subdir_civ1,'String'); |
---|
| 763 | subdir_civ2=get(handles.subdir_civ2,'String'); |
---|
| 764 | |
---|
| 765 | mode_Callback(hObject, eventdata, handles) |
---|
| 766 | |
---|
| 767 | %%%%%% initialize waitbars and RUN button |
---|
| 768 | set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001]) |
---|
| 769 | set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001]) |
---|
| 770 | set(handles.waitbar_civ2,'Position',[0.946 0.219 0.03 0.001]) |
---|
| 771 | set(handles.waitbar_patch2,'Position',[0.946 0.0 0.03 0.001]) |
---|
| 772 | set(handles.RUN, 'Enable','On') |
---|
| 773 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 774 | if isequal(test_batch,1)%if batch installation is available |
---|
| 775 | set(handles.BATCH, 'Enable','On') |
---|
| 776 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 777 | end |
---|
| 778 | |
---|
| 779 | %%%%% store the root input filename for future opening |
---|
| 780 | dir_perso=prefdir; |
---|
| 781 | profil_perso=fullfile(prefdir,'uvmat_perso.mat'); |
---|
| 782 | RootPath=fileparts(filebase); |
---|
| 783 | if exist(profil_perso,'file') |
---|
| 784 | save (profil_perso,'RootPath','-append'); %store the root name for future opening of uvmat |
---|
| 785 | else |
---|
| 786 | txt=ver; |
---|
| 787 | Release=txt(1).Release; |
---|
| 788 | relnumb=str2num(Release(3:4)); |
---|
| 789 | if relnumb >= 14 |
---|
| 790 | save (profil_perso,'RootPath','-V6'); %store the root name for future opening of uvmat |
---|
| 791 | else |
---|
| 792 | save (profil_perso,'RootPath'); %store the root name for future opening of uvmat |
---|
| 793 | end |
---|
| 794 | end |
---|
| 795 | % save(profil_perso, 'filebase'); %store the root name for future opening of uvmat |
---|
| 796 | set(gcf,'Pointer','arrow') |
---|
| 797 | |
---|
[12] | 798 | %------------------------------------------------------------------------ |
---|
[2] | 799 | % --- Executes on button press in mode. |
---|
| 800 | function mode_Callback(hObject, eventdata, handles) |
---|
[12] | 801 | %------------------------------------------------------------------------ |
---|
[2] | 802 | browse=get(handles.browse_root,'UserData'); |
---|
| 803 | compare_list=get(handles.compare,'String'); |
---|
| 804 | val=get(handles.compare,'Value'); |
---|
| 805 | compare=compare_list{val}; |
---|
| 806 | if strcmp(compare,'displacement') |
---|
| 807 | mode='displacement'; |
---|
| 808 | else |
---|
| 809 | mode_list=get(handles.mode,'String'); |
---|
| 810 | mode_value=get(handles.mode,'Value'); |
---|
| 811 | mode=mode_list{mode_value}; |
---|
| 812 | end |
---|
| 813 | displ_num=[];%default |
---|
| 814 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 815 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 816 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 817 | siztime=size(time); |
---|
| 818 | nbfield=siztime(1); |
---|
| 819 | nbfield2=siztime(2); |
---|
| 820 | indchosen=1; %%first pair selected by default |
---|
| 821 | if isequal(mode,'pair j1-j2')%| isequal(mode,'st_pair j1-j2') |
---|
| 822 | dt=1; |
---|
| 823 | displ=''; |
---|
| 824 | index=0; |
---|
| 825 | numlist_a=[]; |
---|
| 826 | numlist_B=[]; |
---|
| 827 | %get all the time intervals in bursts |
---|
| 828 | displ_dt=1;%default |
---|
| 829 | nbfield2=min(nbfield2,10);%limitate the number of pairs to 10x10 |
---|
| 830 | for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'pair j1-j2' mode |
---|
| 831 | for numod_b=(numod_a+1):nbfield2 |
---|
| 832 | index=index+1; |
---|
| 833 | numlist_a(index)=numod_a; |
---|
| 834 | numlist_b(index)=numod_b; |
---|
| 835 | if ~isempty(time) |
---|
| 836 | dt(numod_a,numod_b)=time(first_i,numod_b)-time(first_i,numod_a);%first time interval dt |
---|
| 837 | displ_dt(index)=dt(numod_a,numod_b); |
---|
| 838 | else |
---|
| 839 | displ_dt(index)=1; |
---|
| 840 | end |
---|
| 841 | end |
---|
| 842 | end |
---|
| 843 | [dtsort,indsort]=sort(displ_dt); |
---|
| 844 | if ~isempty(numlist_a) |
---|
| 845 | displ_num(1,:)=numlist_a(indsort); |
---|
| 846 | displ_num(2,:)=numlist_b(indsort); |
---|
| 847 | end |
---|
| 848 | displ_num(3,:)=0; |
---|
| 849 | displ_num(4,:)=0; |
---|
| 850 | set(handles.jtext,'Visible','Off') |
---|
| 851 | set(handles.first_j,'Visible','Off') |
---|
| 852 | set(handles.last_j,'Visible','Off') |
---|
| 853 | set(handles.incr_j,'Visible','Off') |
---|
| 854 | set(handles.nb_field2,'Visible','Off') |
---|
| 855 | set(handles.ref_j,'Visible','Off') |
---|
| 856 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') |
---|
| 857 | for index=1:min(nbfield2-1,200) |
---|
| 858 | displ_num(1,index)=-floor(index/2); |
---|
| 859 | displ_num(2,index)=ceil(index/2); |
---|
| 860 | displ_num(3,index)=0; |
---|
| 861 | displ_num(4,index)=0; |
---|
| 862 | end |
---|
| 863 | set(handles.jtext,'Visible','On') |
---|
| 864 | set(handles.first_j,'Visible','On') |
---|
| 865 | set(handles.last_j,'Visible','On') |
---|
| 866 | set(handles.incr_j,'Visible','On') |
---|
| 867 | set(handles.nb_field2,'Visible','On') |
---|
| 868 | set(handles.ref_j,'Visible','On') |
---|
| 869 | if nbfield > 1 |
---|
| 870 | set(handles.itext,'Visible','On') |
---|
| 871 | set(handles.first_i,'Visible','On') |
---|
| 872 | set(handles.last_i,'Visible','On') |
---|
| 873 | set(handles.incr_i,'Visible','On') |
---|
| 874 | set(handles.nb_field,'Visible','On') |
---|
| 875 | set(handles.ref_i,'Visible','On') |
---|
| 876 | else |
---|
| 877 | set(handles.itext,'Visible','Off') |
---|
| 878 | set(handles.first_i,'Visible','Off') |
---|
| 879 | set(handles.last_i,'Visible','Off') |
---|
| 880 | set(handles.incr_i,'Visible','Off') |
---|
| 881 | set(handles.nb_field,'Visible','Off') |
---|
| 882 | set(handles.ref_i,'Visible','Off') |
---|
| 883 | end |
---|
| 884 | elseif isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 885 | for index=1:200%min(nbfield-1,200) |
---|
| 886 | displ_num(1,index)=0; |
---|
| 887 | displ_num(2,index)=0; |
---|
| 888 | displ_num(3,index)=-floor(index/2); |
---|
| 889 | displ_num(4,index)=ceil(index/2); |
---|
| 890 | end |
---|
| 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 | if nbfield2 > 1 |
---|
| 898 | set(handles.jtext,'Visible','On') |
---|
| 899 | set(handles.first_j,'Visible','On') |
---|
| 900 | set(handles.last_j,'Visible','On') |
---|
| 901 | set(handles.incr_j,'Visible','On') |
---|
| 902 | set(handles.nb_field2,'Visible','On') |
---|
| 903 | set(handles.ref_j,'Visible','On') |
---|
| 904 | else |
---|
| 905 | set(handles.jtext,'Visible','Off') |
---|
| 906 | set(handles.first_j,'Visible','Off') |
---|
| 907 | set(handles.last_j,'Visible','Off') |
---|
| 908 | set(handles.incr_j,'Visible','Off') |
---|
| 909 | set(handles.nb_field2,'Visible','Off') |
---|
| 910 | set(handles.ref_j,'Visible','Off') |
---|
| 911 | end |
---|
| 912 | elseif isequal(mode,'displacement')%the pairs have the same indices |
---|
| 913 | displ_num(1,1)=0; |
---|
| 914 | displ_num(2,1)=0; |
---|
| 915 | displ_num(3,1)=0; |
---|
| 916 | displ_num(4,1)=0; |
---|
| 917 | if nbfield > 1 |
---|
| 918 | set(handles.itext,'Visible','On') |
---|
| 919 | set(handles.first_i,'Visible','On') |
---|
| 920 | set(handles.last_i,'Visible','On') |
---|
| 921 | set(handles.incr_i,'Visible','On') |
---|
| 922 | set(handles.nb_field,'Visible','On') |
---|
| 923 | set(handles.ref_i,'Visible','On') |
---|
| 924 | else |
---|
| 925 | set(handles.itext,'Visible','Off') |
---|
| 926 | set(handles.first_i,'Visible','Off') |
---|
| 927 | set(handles.last_i,'Visible','Off') |
---|
| 928 | set(handles.incr_i,'Visible','Off') |
---|
| 929 | set(handles.nb_field,'Visible','Off') |
---|
| 930 | set(handles.ref_i,'Visible','Off') |
---|
| 931 | end |
---|
| 932 | if nbfield2 > 1 |
---|
| 933 | set(handles.jtext,'Visible','On') |
---|
| 934 | set(handles.first_j,'Visible','On') |
---|
| 935 | set(handles.last_j,'Visible','On') |
---|
| 936 | set(handles.incr_j,'Visible','On') |
---|
| 937 | set(handles.nb_field2,'Visible','On') |
---|
| 938 | set(handles.ref_j,'Visible','On') |
---|
| 939 | else |
---|
| 940 | set(handles.jtext,'Visible','Off') |
---|
| 941 | set(handles.first_j,'Visible','Off') |
---|
| 942 | set(handles.last_j,'Visible','Off') |
---|
| 943 | set(handles.incr_j,'Visible','Off') |
---|
| 944 | set(handles.nb_field2,'Visible','Off') |
---|
| 945 | set(handles.ref_j,'Visible','Off') |
---|
| 946 | end |
---|
| 947 | end |
---|
| 948 | set(handles.list_pair_civ1,'UserData',displ_num); |
---|
| 949 | find_netcpair_civ1(hObject, eventdata, handles) |
---|
| 950 | find_netcpair_civ2(hObject, eventdata, handles) |
---|
| 951 | |
---|
[12] | 952 | %------------------------------------------------------------------------ |
---|
[2] | 953 | % determine the menu for civ1 pairs depending on existing netcdf file at the middle of |
---|
| 954 | % the field series set by first_i, incr, last_i |
---|
| 955 | function find_netcpair_civ1(hObject, eventdata, handles) |
---|
[12] | 956 | %------------------------------------------------------------------------ |
---|
[2] | 957 | set(gcf,'Pointer','watch') |
---|
| 958 | %nomenclature types |
---|
| 959 | filebase=get(handles.displ_filebase,'String'); |
---|
| 960 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
| 961 | browse=get(handles.browse_root,'UserData'); |
---|
| 962 | compare_list=get(handles.compare,'String'); |
---|
| 963 | val=get(handles.compare,'Value'); |
---|
| 964 | compare=compare_list{val}; |
---|
| 965 | if strcmp(compare,'displacement') |
---|
| 966 | mode='displacement'; |
---|
| 967 | else |
---|
| 968 | mode_list=get(handles.mode,'String'); |
---|
| 969 | mode_value=get(handles.mode,'Value'); |
---|
| 970 | mode=mode_list{mode_value}; |
---|
| 971 | end |
---|
| 972 | |
---|
| 973 | % nomenclature type of the .nc files |
---|
| 974 | nom_type_ima=[];%default |
---|
| 975 | if isfield(browse,'nom_type_ima') |
---|
| 976 | nom_type_ima=browse.nom_type_ima; |
---|
| 977 | end |
---|
| 978 | |
---|
| 979 | %determine nom_type_nc: |
---|
| 980 | nom_type_nc=[];%default |
---|
| 981 | if isfield(browse,'nom_type_nc') |
---|
| 982 | nom_type_nc=browse.nom_type_nc; |
---|
| 983 | end |
---|
| 984 | if isempty(nom_type_nc) |
---|
| 985 | [nom_type_nc]=nomtype2pair(nom_type_ima,isequal(mode,'series(Di)'),isequal(mode,'series(Dj)')); |
---|
| 986 | end |
---|
| 987 | browse.nom_type_nc=nom_type_nc; |
---|
| 988 | set(handles.browse_root,'UserData',browse) |
---|
| 989 | |
---|
| 990 | %reads .nc subdirectoy and image numbers from the interface |
---|
| 991 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
| 992 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 993 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 994 | incr=str2num(get(handles.incr_i,'String')); |
---|
| 995 | num1=first_i:incr:last_i; |
---|
| 996 | if isempty(num1) |
---|
| 997 | set(handles.list_pair_civ1,'String',{''}); |
---|
| 998 | return |
---|
| 999 | end |
---|
| 1000 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
| 1001 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
| 1002 | ref_j=0; |
---|
| 1003 | else |
---|
| 1004 | ref_j=str2num(get(handles.ref_j,'String')); |
---|
| 1005 | end |
---|
| 1006 | time=get(handles.displ_filebase,'UserData');%get the set of times |
---|
| 1007 | if isempty(time) |
---|
| 1008 | time=[0 1]; |
---|
| 1009 | end |
---|
| 1010 | dt_unit=str2num(get(handles.dt,'String'));% used when there is no image documentation file |
---|
| 1011 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 1012 | |
---|
| 1013 | %eliminate the first pairs inconsistent with the position |
---|
| 1014 | if isempty(displ_num) |
---|
| 1015 | nbpair=0; |
---|
| 1016 | else |
---|
| 1017 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
| 1018 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 1019 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1020 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 1021 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1022 | end |
---|
| 1023 | end |
---|
| 1024 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
| 1025 | |
---|
| 1026 | %look for existing processed pairs involving the field at the middle of the series if civ1 will not |
---|
| 1027 | % be performed, while the result is needed for next steps. |
---|
| 1028 | displ_pair={''}; |
---|
| 1029 | select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs |
---|
| 1030 | testpair=0; |
---|
| 1031 | if get(handles.CIV1,'Value')==0 % |
---|
| 1032 | dirname=fullfile(filepath,subdir_civ1,ext_dir); |
---|
| 1033 | if ~exist(fullfile(filepath,subdir_civ1,ext_dir),'dir') |
---|
| 1034 | msgbox_uvmat('ERROR',['no civ1 file available: subdirectory ' subdir_civ1 ' does not exist']); |
---|
| 1035 | set(handles.list_pair_civ1,'String',{}); |
---|
| 1036 | return |
---|
| 1037 | end |
---|
| 1038 | for ipair=1:nbpair |
---|
| 1039 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
| 1040 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
| 1041 | select(ipair)=exist(filename,'file')==2; |
---|
| 1042 | end |
---|
| 1043 | if ~exist('select','var') || isequal(select,zeros(size(1:nbpair))) |
---|
| 1044 | if isfield(browse,'incr_pair') |
---|
| 1045 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
| 1046 | num_i2=ref_i+ceil(browse.incr_pair(1)/2); |
---|
| 1047 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
| 1048 | num_j2=ref_j+ceil(browse.incr_pair(2)/2); |
---|
| 1049 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ1); |
---|
| 1050 | select(1)=exist(filename,'file')==2; |
---|
| 1051 | testpair=1; |
---|
| 1052 | else |
---|
| 1053 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 1054 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1]); |
---|
| 1055 | else |
---|
| 1056 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ1]); |
---|
| 1057 | end |
---|
| 1058 | set(handles.list_pair_civ1,'String',{''}); |
---|
| 1059 | %COMPLETER CAS STEREO |
---|
| 1060 | return |
---|
| 1061 | end |
---|
| 1062 | end |
---|
| 1063 | end |
---|
| 1064 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 1065 | if testpair |
---|
| 1066 | displ_pair{1}=['Di= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
| 1067 | elseif ~isequal(get(handles.dt_text,'String'),'dt(ms)=') |
---|
| 1068 | for ipair=1:nbpair |
---|
| 1069 | if select(ipair) |
---|
| 1070 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1071 | 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 |
---|
| 1072 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1073 | end |
---|
| 1074 | else |
---|
| 1075 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1076 | end |
---|
| 1077 | end |
---|
| 1078 | else |
---|
| 1079 | for ipair=1:nbpair |
---|
| 1080 | if select(ipair) |
---|
| 1081 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt_unit*ipair)]; |
---|
| 1082 | else |
---|
| 1083 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1084 | end |
---|
| 1085 | end |
---|
| 1086 | end |
---|
| 1087 | elseif isequal(mode,'series(Dj)')%|isequal(mode,'st_series(Dj)')% series on the j index |
---|
| 1088 | if testpair |
---|
| 1089 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
| 1090 | else |
---|
| 1091 | for ipair=1:nbpair |
---|
| 1092 | if select(ipair) |
---|
| 1093 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1094 | 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 |
---|
| 1095 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1096 | end |
---|
| 1097 | elseif testpair |
---|
| 1098 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(2)/2)) '|' num2str(ceil(browse.incr_pair(2)/2))]; |
---|
| 1099 | else |
---|
| 1100 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1101 | end |
---|
| 1102 | end |
---|
| 1103 | end |
---|
| 1104 | elseif isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2')%case of pairs |
---|
| 1105 | for ipair=1:nbpair |
---|
| 1106 | if select(ipair) |
---|
| 1107 | 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 |
---|
| 1108 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
| 1109 | ' :dt= ' num2str(dt*1000)]; |
---|
| 1110 | else |
---|
| 1111 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1112 | end |
---|
| 1113 | end |
---|
| 1114 | elseif isequal(mode,'displacement') |
---|
| 1115 | displ_pair={'Di=Dj=0'}; |
---|
| 1116 | end |
---|
| 1117 | set(handles.list_pair_civ1,'String',displ_pair'); |
---|
| 1118 | ichoice=min(find(select)); |
---|
| 1119 | if (isempty(ichoice) | ichoice < 1); ichoice=1; end; |
---|
| 1120 | initial=get(handles.list_pair_civ1,'Value'); |
---|
| 1121 | if initial>nbpair |~isequal(select(initial),1) |
---|
| 1122 | set(handles.list_pair_civ1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
| 1123 | end |
---|
| 1124 | %set(handles.list_pair_civ2,'String',displ_pair'); |
---|
| 1125 | initial=get(handles.list_pair_civ2,'Value'); |
---|
| 1126 | if initial>length(displ_pair')%|~isequal(select(initial),1) |
---|
| 1127 | if ichoice <= length(displ_pair') |
---|
| 1128 | set(handles.list_pair_civ2,'Value',ichoice);% same pair proposed by default for civ2 |
---|
| 1129 | else |
---|
| 1130 | set(handles.list_pair_civ2,'Value',1);% same pair proposed by default for civ2 |
---|
| 1131 | end |
---|
| 1132 | end |
---|
| 1133 | set(handles.list_pair_civ2,'String',displ_pair'); |
---|
| 1134 | set(gcf,'Pointer','arrow') |
---|
[12] | 1135 | |
---|
| 1136 | %------------------------------------------------------------------------ |
---|
[2] | 1137 | % determine the menu for civ2 pairs depending on the existing netcdf file at the |
---|
| 1138 | %middle of the series set by first_i, incr, last_i |
---|
| 1139 | function find_netcpair_civ2(hObject, eventdata, handles) |
---|
[12] | 1140 | %------------------------------------------------------------------------ |
---|
[2] | 1141 | set(gcf,'Pointer','watch') |
---|
| 1142 | %nomenclature types |
---|
| 1143 | filebase=get(handles.displ_filebase,'String'); |
---|
| 1144 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
| 1145 | browse=get(handles.browse_root,'UserData'); |
---|
| 1146 | compare_list=get(handles.compare,'String'); |
---|
| 1147 | val=get(handles.compare,'Value'); |
---|
| 1148 | compare=compare_list{val}; |
---|
| 1149 | if strcmp(compare,'displacement') |
---|
| 1150 | mode='displacement'; |
---|
| 1151 | else |
---|
| 1152 | mode_list=get(handles.mode,'String'); |
---|
| 1153 | mode_value=get(handles.mode,'Value'); |
---|
| 1154 | mode=mode_list{mode_value}; |
---|
| 1155 | end |
---|
| 1156 | |
---|
| 1157 | % nomenclature type of the .nc files |
---|
| 1158 | nom_type_ima='ima_num';%default |
---|
| 1159 | if isfield(browse,'nom_type_ima') |
---|
| 1160 | nom_type_ima=browse.nom_type_ima; |
---|
| 1161 | end |
---|
| 1162 | nom_type_nc='_i1-i2';%default |
---|
| 1163 | if isfield(browse,'nom_type_nc') |
---|
| 1164 | nom_type_nc=browse.nom_type_nc; |
---|
| 1165 | end |
---|
| 1166 | 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') |
---|
| 1167 | nom_type_nc='netc_old';%nom_type for the netcdf files |
---|
| 1168 | elseif isequal(nom_type_ima,'none')|isequal(nom_type_nc,'none') |
---|
| 1169 | nom_type_nc='none'; |
---|
| 1170 | elseif isequal(nom_type_ima,'avi')|isequal(nom_type_ima,'_i')|isequal(nom_type_ima,'ima_num')|isequal(nom_type_nc,'_i1-i2') |
---|
| 1171 | nom_type_nc='_i1-i2'; |
---|
| 1172 | else |
---|
| 1173 | if isequal(mode,'series(Di)')%|isequal(mode,'st_series(Di)') |
---|
| 1174 | nom_type_nc='_i1-i2_j'; % PIV in volume |
---|
| 1175 | else |
---|
| 1176 | nom_type_nc='_i_j1-j2'; |
---|
| 1177 | end |
---|
| 1178 | end |
---|
| 1179 | browse.nom_type_nc=nom_type_nc; |
---|
| 1180 | set(handles.browse_root,'UserData',browse) |
---|
| 1181 | |
---|
| 1182 | %reads .nc subdirectory and image numbers from the interface |
---|
| 1183 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
| 1184 | subdir_civ2=get(handles.subdir_civ2,'String');%subdirectory subdir_civ2 for the netcdf data |
---|
| 1185 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 1186 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 1187 | incr=str2num(get(handles.incr_i,'String')); |
---|
| 1188 | num1=first_i:incr:last_i; |
---|
| 1189 | if isempty(num1) |
---|
| 1190 | set(handles.list_pair_civ2,'Value',1); |
---|
| 1191 | set(handles.list_pair_civ2,'String',{''}); |
---|
| 1192 | return |
---|
| 1193 | end |
---|
| 1194 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
| 1195 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
| 1196 | ref_j=0; |
---|
| 1197 | else |
---|
| 1198 | ref_j=str2num(get(handles.ref_j,'String')); |
---|
| 1199 | end |
---|
| 1200 | if isequal(get(handles.dt_text,'String'),'dt(ms)=')%simple series(Di) with equal interval |
---|
| 1201 | ref_i=ceil((first_i+last_i)/2); |
---|
| 1202 | ref_j=1; |
---|
| 1203 | end |
---|
| 1204 | % ref_i=browse.num_ref;%field number initially selected by the browser |
---|
| 1205 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 1206 | if isempty(time) |
---|
| 1207 | time=[0 1];%default |
---|
| 1208 | end |
---|
| 1209 | dt_unit=str2num(get(handles.dt,'String'));% used when there is no image documentation file |
---|
| 1210 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 1211 | |
---|
| 1212 | |
---|
| 1213 | %eliminate the first pairs inconsistent with the position |
---|
| 1214 | if isempty(displ_num) |
---|
| 1215 | nbpair=0; |
---|
| 1216 | else |
---|
| 1217 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
| 1218 | if isequal(mode,'series(Di)')% | isequal(mode,'st_series(Di)') |
---|
| 1219 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1220 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 1221 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1222 | end |
---|
| 1223 | end |
---|
| 1224 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
| 1225 | |
---|
| 1226 | %look for existing processed pairs involving the field at the middle of the series if civ1 will not |
---|
| 1227 | % be performed, while the result is needed for next steps. |
---|
| 1228 | displ_pair={''}; %default |
---|
| 1229 | select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs |
---|
| 1230 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0%&... |
---|
| 1231 | if ~exist(fullfile(filepath,subdir_civ2,ext_dir),'dir') |
---|
| 1232 | errordlg(['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist']) |
---|
| 1233 | set(handles.list_pair_civ2,'Value',1); |
---|
| 1234 | set(handles.list_pair_civ2,'String',{''}); |
---|
| 1235 | return |
---|
| 1236 | end |
---|
| 1237 | for ipair=1:nbpair |
---|
| 1238 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
| 1239 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
| 1240 | select(ipair)=exist(filename,'file')==2; |
---|
| 1241 | end |
---|
| 1242 | if isequal(select,zeros(size(1:nbpair))) |
---|
| 1243 | if isfield(browse,'incr_pair') |
---|
| 1244 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
| 1245 | num_i2=ref_i+floor((browse.incr_pair(1)+1)/2); |
---|
| 1246 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
| 1247 | num_j2=ref_j+floor((browse.incr_pair(2)+1)/2); |
---|
| 1248 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ2); |
---|
| 1249 | select(1)=exist(filename,'file')==2; |
---|
| 1250 | else |
---|
| 1251 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 1252 | errordlg(['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2]) |
---|
| 1253 | else |
---|
| 1254 | errordlg(['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2]) |
---|
| 1255 | end |
---|
| 1256 | set(handles.list_pair_civ2,'Value',1); |
---|
| 1257 | set(handles.list_pair_civ2,'String',{''}); |
---|
| 1258 | return |
---|
| 1259 | end |
---|
| 1260 | end |
---|
| 1261 | end |
---|
| 1262 | if isequal(mode,'series(Di)') % | isequal(mode,'st_series(Di)') |
---|
| 1263 | % if ~isequal(get(handles.dt_text,'String'),'dt(ms)=') |
---|
| 1264 | for ipair=1:nbpair |
---|
| 1265 | if select(ipair) |
---|
| 1266 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1267 | 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 |
---|
| 1268 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1269 | end |
---|
| 1270 | else |
---|
| 1271 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1272 | end |
---|
| 1273 | end |
---|
| 1274 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') % series on the j index |
---|
| 1275 | for ipair=1:nbpair |
---|
| 1276 | if select(ipair) |
---|
| 1277 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1278 | 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 |
---|
| 1279 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1280 | end |
---|
| 1281 | else |
---|
| 1282 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1283 | end |
---|
| 1284 | end |
---|
| 1285 | elseif isequal(mode,'pair j1-j2')% | isequal(mode,'st_pair j1-j2') %case of pairs |
---|
| 1286 | for ipair=1:nbpair |
---|
| 1287 | if select(ipair) |
---|
| 1288 | 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 |
---|
| 1289 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
| 1290 | ' :dt= ' num2str(dt*1000)]; |
---|
| 1291 | else |
---|
| 1292 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1293 | end |
---|
| 1294 | end |
---|
| 1295 | elseif isequal(mode,'displacement') |
---|
| 1296 | displ_pair={'Di=Dj=0'}; |
---|
| 1297 | end |
---|
| 1298 | val=get(handles.list_pair_civ2,'Value'); |
---|
| 1299 | ichoice=min(find(select)); |
---|
| 1300 | if (isempty(ichoice) | ichoice < 1); ichoice=1; end; |
---|
| 1301 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0 |
---|
| 1302 | val=ichoice;% first valid pair proposed by default in the menu |
---|
| 1303 | end |
---|
| 1304 | if val>length(displ_pair') |
---|
| 1305 | set(handles.list_pair_civ2,'Value',1);% first valid pair proposed by default in the menu |
---|
| 1306 | else |
---|
| 1307 | set(handles.list_pair_civ2,'Value',val); |
---|
| 1308 | end |
---|
| 1309 | set(handles.list_pair_civ2,'String',displ_pair'); |
---|
[12] | 1310 | set(gcf,'Pointer','arrow') |
---|
[2] | 1311 | |
---|
[12] | 1312 | %------------------------------------------------------------------------ |
---|
[2] | 1313 | % determine the list of index pairs of processing file |
---|
| 1314 | function [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
| 1315 | find_pair_indices(handles,mode) |
---|
[12] | 1316 | %------------------------------------------------------------------------ |
---|
[2] | 1317 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 1318 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 1319 | incr=str2num(get(handles.incr_i,'String')); |
---|
| 1320 | num1=[first_i:incr:last_i]; |
---|
| 1321 | if isequal(get(handles.first_j,'Visible'),'on') |
---|
| 1322 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 1323 | last_j=str2num(get(handles.last_j,'String')); |
---|
| 1324 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
| 1325 | else |
---|
| 1326 | first_j=1; |
---|
| 1327 | last_j=1; |
---|
| 1328 | incr_j=1; |
---|
| 1329 | end |
---|
| 1330 | num_j=[first_j:incr_j:last_j]; |
---|
| 1331 | list_civ1=get(handles.list_pair_civ1,'String'); |
---|
| 1332 | index_civ1=get(handles.list_pair_civ1,'Value'); |
---|
| 1333 | str_civ1=list_civ1{index_civ1}; |
---|
| 1334 | if isempty(str_civ1)||isequal(str_civ1,'') |
---|
| 1335 | msgbox_uvmat('ERROR','no image pair selected for civ1') |
---|
| 1336 | return |
---|
| 1337 | end |
---|
| 1338 | list_civ2=get(handles.list_pair_civ2,'String'); |
---|
| 1339 | index_civ2=get(handles.list_pair_civ2,'Value'); |
---|
| 1340 | if index_civ2>length(list_civ2) |
---|
| 1341 | list_civ2=list_civ1; |
---|
| 1342 | index_civ2=index_civ1; |
---|
| 1343 | end |
---|
| 1344 | str_civ2=list_civ2{index_civ2}; |
---|
| 1345 | if isequal(first_i,[])|isequal(first_j,[]), errordlg('first field number not defined'),... |
---|
| 1346 | set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end; |
---|
| 1347 | if isequal(last_i,[])| isequal(last_j,[]),errordlg('last field number not defined'),... |
---|
| 1348 | set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end; |
---|
| 1349 | if isequal(incr,[])| isequal(incr_j,[]),errordlg('increment in field number not defined'),... |
---|
| 1350 | set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end; |
---|
| 1351 | if last_i < first_i | last_j < first_j , errordlg('last field number must be larger than the first one'),... |
---|
| 1352 | set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end; |
---|
| 1353 | if isequal (mode,'series(Di)')% |isequal(mode,'st_series(Di)') |
---|
| 1354 | %recognize the pair civ1 from the display |
---|
| 1355 | indsel=find((double(str_civ1)<48)|(double(str_civ1)>57));% character indices of non numerical characters |
---|
| 1356 | str_raw=str_civ1(indsel); |
---|
| 1357 | indsepar=find(str_raw=='|'); %character index of the separator |
---|
| 1358 | d1=str2num(str_civ1([indsel(indsepar-1)+1:indsel(indsepar)-1])); |
---|
| 1359 | if indsepar==length(str_raw) |
---|
| 1360 | d2=str2num(str_civ1([indsel(indsepar)+1:end])); |
---|
| 1361 | else |
---|
| 1362 | d2=str2num(str_civ1([indsel(indsepar)+1:indsel(indsepar+1)-1])); |
---|
| 1363 | end |
---|
| 1364 | num1_civ1=num1-d1;% set of first image numbers |
---|
| 1365 | num2_civ1=num1+d2; |
---|
| 1366 | num_a_civ1=num_j; |
---|
| 1367 | num_b_civ1=num_j; |
---|
| 1368 | |
---|
| 1369 | %recognize the pair civ2 from the display |
---|
| 1370 | indsel=find((double(str_civ2)<48)|(double(str_civ2)>57));% character indices of non numerical characters |
---|
| 1371 | str_raw=str_civ2(indsel); |
---|
| 1372 | indsepar=find(str_raw=='|'); %character index of the separator |
---|
| 1373 | d1=str2num(str_civ2([indsel(indsepar-1)+1:indsel(indsepar)-1])); |
---|
| 1374 | if indsepar==length(str_raw) |
---|
| 1375 | d2=str2num(str_civ2([indsel(indsepar)+1:end])); |
---|
| 1376 | else |
---|
| 1377 | d2=str2num(str_civ2([indsel(indsepar)+1:indsel(indsepar+1)-1])); |
---|
| 1378 | end |
---|
| 1379 | if isempty(d1) |
---|
| 1380 | num1_civ2=num1; |
---|
| 1381 | else |
---|
| 1382 | num1_civ2=num1-d1;% set of first image numbers |
---|
| 1383 | end |
---|
| 1384 | if isempty(d2) |
---|
| 1385 | num2_civ2=num1; |
---|
| 1386 | else |
---|
| 1387 | num2_civ2=num1+d2; |
---|
| 1388 | end |
---|
| 1389 | num_a_civ2=num_j; |
---|
| 1390 | num_b_civ2=num_j; |
---|
| 1391 | |
---|
| 1392 | % adjust the first and last field number |
---|
| 1393 | lastfield=str2num(get(handles.nb_field,'String')); |
---|
| 1394 | if isequal(lastfield,[]) |
---|
| 1395 | indsel=find((num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
| 1396 | else |
---|
| 1397 | indsel=find((num2_civ1 <= lastfield)&(num2_civ2 <= lastfield)&(num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
| 1398 | end |
---|
| 1399 | if length(indsel)>=1 |
---|
| 1400 | firstind=indsel(1); |
---|
| 1401 | lastind=indsel(end); |
---|
| 1402 | set(handles.first_i,'String',num2str(num1(firstind)))%update the display of first and last fields |
---|
| 1403 | set(handles.last_i,'String',num2str(num1(lastind))) |
---|
| 1404 | num1=num1(indsel); |
---|
| 1405 | num1_civ1=num1_civ1(indsel); |
---|
| 1406 | num1_civ2=num1_civ2(indsel); |
---|
| 1407 | num2_civ1=num2_civ1(indsel); |
---|
| 1408 | num2_civ2=num2_civ2(indsel); |
---|
| 1409 | end |
---|
| 1410 | elseif isequal (mode,'series(Dj)')%|isequal (mode,'st_series(Dj)') |
---|
| 1411 | lastfield_j=str2num(get(handles.nb_field2,'String')); |
---|
| 1412 | num1_civ1=num1;% set of first image numbers |
---|
| 1413 | num2_civ1=num1; |
---|
| 1414 | num_a_civ1=num_j-floor(index_civ1/2)*ones(size(num_j)); |
---|
| 1415 | num_b_civ1=num_j+ceil(index_civ1/2)*ones(size(num_j)); |
---|
| 1416 | num1_civ2=num1; |
---|
| 1417 | num2_civ2=num1; |
---|
| 1418 | num_a_civ2=num_j-floor(index_civ2/2)*ones(size(num_j)); |
---|
| 1419 | num_b_civ2=num_j+ceil(index_civ2/2)*ones(size(num_j)); |
---|
| 1420 | % adjust the first and last field number |
---|
| 1421 | if isequal(lastfield_j,[]) |
---|
| 1422 | indsel=find((num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
| 1423 | else |
---|
| 1424 | indsel=find((num_b_civ1 <= lastfield_j)&(num_b_civ2 <= lastfield_j)&(num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
| 1425 | end |
---|
| 1426 | if length(indsel)>=1 |
---|
| 1427 | firstind=indsel(1); |
---|
| 1428 | lastind=indsel(end); |
---|
| 1429 | set(handles.first_j,'String',num2str(num_j(firstind)))%update the display of first and last fields |
---|
| 1430 | set(handles.last_j,'String',num2str(num_j(lastind))) |
---|
| 1431 | num_j=num_j(indsel); |
---|
| 1432 | num_a_civ1=num_a_civ1(indsel); |
---|
| 1433 | num_a_civ2=num_a_civ2(indsel); |
---|
| 1434 | num_b_civ1=num_b_civ1(indsel); |
---|
| 1435 | num_b_civ2=num_b_civ2(indsel); |
---|
| 1436 | end |
---|
| 1437 | elseif isequal(mode,'pair j1-j2')% | isequal(mode,'st_pair j1-j2') %case of bursts (png_old or png_2D) |
---|
| 1438 | num1_civ1=num1; |
---|
| 1439 | num1_civ2=num1; |
---|
| 1440 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 1441 | num2_civ1=num1; |
---|
| 1442 | num_a_civ1=displ_num(1,index_civ1); |
---|
| 1443 | num_b_civ1=displ_num(2,index_civ1); |
---|
| 1444 | num2_civ2=num1; |
---|
| 1445 | num_a_civ2=displ_num(1,index_civ2); |
---|
| 1446 | num_b_civ2=displ_num(2,index_civ2); |
---|
| 1447 | elseif isequal(mode,'displacement') |
---|
| 1448 | num1_civ1=num1; |
---|
| 1449 | num2_civ1=num1; |
---|
| 1450 | num_a_civ1=num_j; |
---|
| 1451 | num_b_civ1=num_j; |
---|
| 1452 | num1_civ2=num1; |
---|
| 1453 | num2_civ2=num1; |
---|
| 1454 | num_a_civ2=num_j; |
---|
| 1455 | num_b_civ2=num_j; |
---|
| 1456 | end |
---|
| 1457 | |
---|
[12] | 1458 | %------------------------------------------------------------------------ |
---|
[2] | 1459 | % --- Executes on selection change in list_pair_civ1. |
---|
| 1460 | function list_pair_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 1461 | %------------------------------------------------------------------------ |
---|
[2] | 1462 | %reproduce by default the chosen pair in the civ2 menu |
---|
| 1463 | list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs |
---|
| 1464 | index_pair=get(handles.list_pair_civ1,'Value'); |
---|
| 1465 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 1466 | num_a=displ_num(1,index_pair); |
---|
| 1467 | num_b=displ_num(2,index_pair); |
---|
| 1468 | list_pair2=get(handles.list_pair_civ2,'String');%get the menu of image pairs |
---|
| 1469 | if index_pair<=length(list_pair2) |
---|
| 1470 | set(handles.list_pair_civ2,'Value',index_pair); |
---|
| 1471 | end |
---|
| 1472 | |
---|
| 1473 | %update first_i and last_i according to the chosen image pairs |
---|
| 1474 | mode_list=get(handles.mode,'String'); |
---|
| 1475 | mode_value=get(handles.mode,'Value'); |
---|
| 1476 | mode=mode_list{mode_value}; |
---|
| 1477 | if isequal(mode,'series(Di)') |
---|
| 1478 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 1479 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 1480 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
| 1481 | num1=first_i:incr_i:last_i; |
---|
| 1482 | lastfield=str2num(get(handles.nb_field,'String')); |
---|
| 1483 | if ~isequal(lastfield,[]) |
---|
| 1484 | ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
| 1485 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield)); |
---|
| 1486 | num1=num1(ind); |
---|
| 1487 | end |
---|
| 1488 | set(handles.first_i,'String',num2str(num1(1))); |
---|
| 1489 | set(handles.last_i,'String',num2str(num1(end))); |
---|
| 1490 | elseif isequal(mode,'series(Dj)') |
---|
| 1491 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 1492 | last_j=str2num(get(handles.last_j,'String')); |
---|
| 1493 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
| 1494 | num_j=first_j:incr_j:last_j; |
---|
| 1495 | lastfield2=str2num(get(handles.nb_field2,'String')); |
---|
| 1496 | if ~isequal(lastfield2,[]) |
---|
| 1497 | ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 1498 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2)); |
---|
| 1499 | num1=num_j(ind); |
---|
| 1500 | end |
---|
| 1501 | set(handles.first_j,'String',num2str(num1(1))); |
---|
| 1502 | set(handles.last_j,'String',num2str(num1(end))); |
---|
| 1503 | end |
---|
| 1504 | |
---|
[12] | 1505 | %------------------------------------------------------------------------ |
---|
[2] | 1506 | % --- Executes on selection change in list_pair_civ2. |
---|
| 1507 | function list_pair_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 1508 | %------------------------------------------------------------------------ |
---|
[2] | 1509 | index_pair=get(handles.list_pair_civ2,'Value');%get the selected position index in the menu |
---|
| 1510 | |
---|
| 1511 | %update first_i and last_i according to the chosen image pairs |
---|
| 1512 | mode_list=get(handles.mode,'String'); |
---|
| 1513 | mode_value=get(handles.mode,'Value'); |
---|
| 1514 | mode=mode_list{mode_value}; |
---|
| 1515 | if isequal(mode,'series(Di)') |
---|
| 1516 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 1517 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 1518 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
| 1519 | num1=first_i:incr_i:last_i; |
---|
| 1520 | lastfield=str2num(get(handles.nb_field,'String')); |
---|
| 1521 | if ~isequal(lastfield,[]) |
---|
| 1522 | ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
| 1523 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield)); |
---|
| 1524 | num1=num1(ind); |
---|
| 1525 | end |
---|
| 1526 | set(handles.first_i,'String',num2str(num1(1))); |
---|
| 1527 | set(handles.last_i,'String',num2str(num1(end))); |
---|
| 1528 | elseif isequal(mode,'series(Dj)') |
---|
| 1529 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 1530 | last_j=str2num(get(handles.last_j,'String')); |
---|
| 1531 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
| 1532 | num_j=first_j:incr_j:last_j; |
---|
| 1533 | lastfield2=str2num(get(handles.nb_field2,'String')); |
---|
| 1534 | if ~isequal(lastfield2,[]) |
---|
| 1535 | ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 1536 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2)); |
---|
| 1537 | num1=num_j(ind); |
---|
| 1538 | end |
---|
| 1539 | set(handles.first_j,'String',num2str(num1(1))); |
---|
| 1540 | set(handles.last_j,'String',num2str(num1(end))); |
---|
| 1541 | end |
---|
| 1542 | |
---|
[12] | 1543 | %------------------------------------------------------------------------ |
---|
[2] | 1544 | % --- Executes on button press in RUN. |
---|
| 1545 | function RUN_Callback(hObject, eventdata, handles) |
---|
[12] | 1546 | %------------------------------------------------------------------------ |
---|
[2] | 1547 | global civ1_exe civ2_exe patch_exe patch_new_exe sge |
---|
| 1548 | |
---|
| 1549 | compare=get(handles.compare,'Value');%test for usual PIV (compare=1) or displacement (=2) or stereo PIV (=3) |
---|
| 1550 | %check the list of operations: |
---|
| 1551 | operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'}; |
---|
| 1552 | run_flag=1; |
---|
| 1553 | box_test(1)=get(handles.CIV1,'Value'); |
---|
| 1554 | box_test(2)=get(handles.FIX1,'Value'); |
---|
| 1555 | box_test(3)=get(handles.PATCH1,'Value'); |
---|
| 1556 | box_test(4)=get(handles.CIV2,'Value'); |
---|
| 1557 | box_test(5)=get(handles.FIX2,'Value'); |
---|
| 1558 | box_test(6)=get(handles.PATCH2,'Value'); |
---|
| 1559 | index=find(box_test==1); |
---|
| 1560 | if isempty(index) |
---|
| 1561 | msgbox_uvmat('ERROR','no selected operation') |
---|
| 1562 | return |
---|
| 1563 | end |
---|
| 1564 | index_first=min(index); |
---|
| 1565 | index_last=max(index); |
---|
| 1566 | box_used=box_test([index_first : index_last]); |
---|
| 1567 | [box_missing,ind_missing]=min(box_used); |
---|
| 1568 | if isequal(box_missing,0) |
---|
| 1569 | msgbox_uvmat('ERROR',['missing' cell2mat(operations(ind_missing))]); |
---|
| 1570 | return |
---|
| 1571 | end |
---|
| 1572 | |
---|
| 1573 | %root name |
---|
| 1574 | filebase=get(handles.displ_filebase,'String'); |
---|
| 1575 | if isempty(filebase)||isequal(filebase,'') |
---|
| 1576 | msgbox_uvmat('ERROR','no input files') |
---|
| 1577 | return |
---|
| 1578 | end |
---|
| 1579 | %check mask if selecetd |
---|
| 1580 | if isequal(get(handles.get_mask_civ1,'Value'),1) |
---|
[12] | 1581 | maskname=get(handles.mask_civ1,'String'); |
---|
| 1582 | if ~exist(maskname,'file') |
---|
| 1583 | get_mask_civ1_Callback(hObject, eventdata, handles); |
---|
| 1584 | end |
---|
[2] | 1585 | end |
---|
| 1586 | if isequal(get(handles.get_mask_fix1,'Value'),1) |
---|
[12] | 1587 | maskname=get(handles.mask_fix1,'String'); |
---|
| 1588 | if ~exist(maskname,'file') |
---|
[2] | 1589 | get_mask_fix1_Callback(hObject, eventdata, handles); |
---|
[12] | 1590 | end |
---|
[2] | 1591 | end |
---|
| 1592 | if isequal(get(handles.get_mask_civ2,'Value'),1) |
---|
[12] | 1593 | maskname=get(handles.mask_civ2,'String'); |
---|
| 1594 | if ~exist(maskname,'file') |
---|
[2] | 1595 | get_mask_civ2_Callback(hObject, eventdata, handles); |
---|
[12] | 1596 | end |
---|
[2] | 1597 | end |
---|
| 1598 | if isequal(get(handles.get_mask_fix2,'Value'),1) |
---|
[12] | 1599 | maskname=get(handles.mask_fix2,'String'); |
---|
| 1600 | if ~exist(maskname,'file') |
---|
[2] | 1601 | get_mask_fix2_Callback(hObject, eventdata, handles); |
---|
[12] | 1602 | end |
---|
[2] | 1603 | end |
---|
| 1604 | |
---|
| 1605 | %read names of the .exe file |
---|
| 1606 | if box_test(1)==1 | box_test(3)==1 | box_test(4)==1 | box_test(6)==1 |
---|
| 1607 | path_uvmat=which('uvmat');% check the path detected for source file uvmat |
---|
| 1608 | path_UVMAT=fileparts(path_uvmat); %path to UVMAT |
---|
| 1609 | if isunix |
---|
| 1610 | %fid = fopen(fullfile(path_UVMAT,'PARAM_LINUX.txt'),'r');%open the file with civ binary names |
---|
| 1611 | xmlfile=fullfile(path_UVMAT,'PARAM_LINUX.xml'); |
---|
| 1612 | if exist(xmlfile,'file') |
---|
| 1613 | t=xmltree(xmlfile); |
---|
| 1614 | sparam=convert(t); |
---|
| 1615 | end |
---|
| 1616 | else |
---|
| 1617 | %fid = fopen(fullfile(path_UVMAT,'PARAM_WIN.txt'),'r');%open the file with civ binary names |
---|
| 1618 | xmlfile=fullfile(path_UVMAT,'PARAM_WIN.xml'); |
---|
| 1619 | if exist(xmlfile,'file') |
---|
| 1620 | t=xmltree(xmlfile); |
---|
| 1621 | sparam=convert(t); |
---|
| 1622 | end |
---|
| 1623 | end |
---|
| 1624 | if isfield(sparam,'Civ1_exe') |
---|
| 1625 | civ1_exe=sparam.Civ1_exe; |
---|
| 1626 | end |
---|
| 1627 | if isfield(sparam,'Civ2_exe') |
---|
| 1628 | civ2_exe=sparam.Civ2_exe; |
---|
| 1629 | end |
---|
| 1630 | if isfield(sparam,'Patch_exe') |
---|
| 1631 | patch_exe=sparam.Patch_exe; |
---|
| 1632 | end |
---|
| 1633 | if isfield(sparam,'Stinterp_exe') |
---|
| 1634 | stinterp_exe=sparam.Stinterp_exe; |
---|
| 1635 | end |
---|
| 1636 | if isfield(sparam,'SGE') |
---|
| 1637 | sge=str2num(sparam.SGE); |
---|
| 1638 | end |
---|
| 1639 | if ~isunix % for windows system, check whether the Matlab working dir is a UBC name |
---|
| 1640 | dircur=pwd; |
---|
| 1641 | if ~isequal(dircur([2 3]),':\') |
---|
| 1642 | msgbox_uvmat('ERROR','move to a Matlab current working directory with a Windows name, e.g. m:/...') |
---|
| 1643 | return; |
---|
| 1644 | end |
---|
| 1645 | end |
---|
| 1646 | end |
---|
| 1647 | |
---|
| 1648 | %initialize the waitbars |
---|
| 1649 | set(handles.waitbar_1,'Position',[0.946 0.877 0.03 0.001]) |
---|
| 1650 | set(handles.waitbar_patch1,'Position',[0.946 0.626 0.03 0.001]) |
---|
| 1651 | set(handles.waitbar_civ2,'Position',[0.946 0.406 0.03 0.001]) |
---|
| 1652 | set(handles.waitbar_patch2,'Position',[0.946 0.187 0.03 0.001]) |
---|
| 1653 | set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 1654 | set(handles.RUN, 'Enable','Off') |
---|
| 1655 | drawnow |
---|
| 1656 | |
---|
| 1657 | % get the list of file names and check the files |
---|
| 1658 | display('checking the files...') |
---|
| 1659 | [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]=... |
---|
| 1660 | set_civ_filenames(handles,compare,box_test); |
---|
[12] | 1661 | if isempty(filecell) |
---|
| 1662 | set(handles.RUN, 'Enable','On') |
---|
| 1663 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 1664 | set(handles.BATCH, 'Enable','On') |
---|
| 1665 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 1666 | return |
---|
| 1667 | end |
---|
[2] | 1668 | display('files OK, processing...') |
---|
| 1669 | nbfield=size(num1_civ1,2); |
---|
| 1670 | nbslice=size(num1_civ1,1); |
---|
| 1671 | |
---|
| 1672 | %RUN CIV1 |
---|
| 1673 | if box_test(1)==1 |
---|
| 1674 | RUN_CIV1(handles,filecell.ima1.civ1,filecell.ima2.civ1,filecell.nc.civ1,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,nom_type_nc) |
---|
| 1675 | if compare==3 |
---|
| 1676 | RUN_CIV1(handles,filecell.imaA1.civ1,filecell.imaA2.civ1,filecell.ncA.civ1,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,nom_type_nc) |
---|
| 1677 | end |
---|
| 1678 | end |
---|
| 1679 | |
---|
| 1680 | %RUN FIX1 |
---|
| 1681 | if box_test(2)==1 |
---|
| 1682 | filebase=get(handles.displ_filebase,'String'); |
---|
| 1683 | %names of the civ1 fields |
---|
| 1684 | field1.vel_type='civ1'; |
---|
| 1685 | field1.nb='nb_vectors'; |
---|
| 1686 | field1.X='vec_X'; |
---|
| 1687 | field1.Y='vec_Y'; |
---|
| 1688 | field1.U='vec_U'; |
---|
| 1689 | field1.V='vec_V'; |
---|
| 1690 | field1.fixflag='vec_FixFlag'; |
---|
| 1691 | flagindex(1)=get(handles.vec_Fmin2, 'Value'); |
---|
| 1692 | flagindex(2)=get(handles.vec_F3, 'Value'); |
---|
| 1693 | flagindex(3)=get(handles.vec_F2, 'Value'); |
---|
| 1694 | thresh_vecC=str2num(get(handles.thresh_vecC,'String'));%threshold on image correlation vec_C |
---|
| 1695 | thresh_vel=str2num(get(handles.thresh_vel,'String'));%threshold on velocity modulus |
---|
| 1696 | inf_sup=get(handles.inf_sup1,'Value'); |
---|
| 1697 | menu=get(handles.field_ref1,'String'); |
---|
| 1698 | index=get(handles.field_ref1,'Value'); |
---|
| 1699 | if isempty(menu) |
---|
| 1700 | fieldchoice=''; |
---|
| 1701 | else |
---|
| 1702 | fieldchoice=menu{index}; |
---|
| 1703 | end |
---|
| 1704 | h = waitbar(0,['removing velocity vectors, fix1']);% display a wait bar |
---|
[12] | 1705 | test_mask=get(handles.get_mask_fix1,'Value'); |
---|
| 1706 | if test_mask |
---|
| 1707 | maskdispl=get(handles.mask_fix1,'String'); |
---|
| 1708 | if exist(maskdispl,'file') |
---|
| 1709 | test_mask=2; |
---|
| 1710 | maskname=maskdispl; |
---|
| 1711 | else |
---|
| 1712 | maskbase=[get(handles.displ_filebase,'String') '_' maskdispl]; % mask root name |
---|
| 1713 | end |
---|
| 1714 | end |
---|
[2] | 1715 | for ifile=1:nbfield |
---|
| 1716 | waitbar(ifile/nbfield); %update the waitbar |
---|
| 1717 | for j=1:nbslice |
---|
| 1718 | if test_mask==0 |
---|
| 1719 | maskname='noFile use default'; |
---|
| 1720 | maskflag=0; |
---|
[12] | 1721 | elseif test_mask==1 |
---|
[2] | 1722 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 1723 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
| 1724 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i');% mask corresponding to the first image of the pair |
---|
| 1725 | maskflag= exist(maskname,'file')==2; |
---|
| 1726 | if ~maskflag; |
---|
| 1727 | maskname='noFile use default'; |
---|
| 1728 | end |
---|
| 1729 | end |
---|
| 1730 | if ~isempty(file_ref_fix1) |
---|
| 1731 | file_ref=file_ref_fix1{ifile,j}; |
---|
| 1732 | else |
---|
| 1733 | file_ref=''; |
---|
| 1734 | end |
---|
| 1735 | error=RUN_FIX(filecell.nc.civ1{ifile,j},field1,flagindex,1,thresh_vecC,maskflag,maskname,... |
---|
| 1736 | thresh_vel,inf_sup,file_ref,fieldchoice); |
---|
| 1737 | |
---|
| 1738 | if compare==3 &&(isequal(mode,'pair j1-j2') || isequal(mode,'series(Dj)') || isequal(mode,'series(Di)')) |
---|
| 1739 | if test_mask==0 |
---|
| 1740 | maskname='noFile use default'; |
---|
| 1741 | maskflag=0; |
---|
| 1742 | else |
---|
| 1743 | maskbase=[get(handles.displ_filebase2,'String') '_' maskdispl]; % mask root name |
---|
| 1744 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 1745 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
| 1746 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 1747 | maskflag= exist(maskname,'file')==2; |
---|
| 1748 | if ~maskflag; |
---|
| 1749 | maskname='noFile use default'; |
---|
| 1750 | end |
---|
| 1751 | end |
---|
| 1752 | error=RUN_FIX(filecell.ncA.civ1{ifile,j},field1,flagindex,1,thresh_vecC,maskflag,maskname,... |
---|
| 1753 | thresh_vel,inf_sup,file_ref,fieldchoice); |
---|
| 1754 | if ~isempty(error) |
---|
| 1755 | msgbox_uvmat('ERROR',error) |
---|
| 1756 | return |
---|
| 1757 | end |
---|
| 1758 | end |
---|
| 1759 | end |
---|
| 1760 | end |
---|
| 1761 | close(h) |
---|
| 1762 | end |
---|
| 1763 | |
---|
| 1764 | % RUN PATCH1 |
---|
| 1765 | if box_test(3)==1 |
---|
| 1766 | rho_patch1=str2num(get(handles.rho_patch1,'String')); |
---|
| 1767 | if isempty(rho_patch1) |
---|
| 1768 | rho_patch1='1000'; |
---|
| 1769 | set(handles.rho_patch1,'String','1') |
---|
| 1770 | else |
---|
| 1771 | rho_patch1=num2str(1000*rho_patch1); |
---|
| 1772 | end |
---|
| 1773 | nx_patch1=get(handles.nx_patch1,'String'); |
---|
| 1774 | if isequal(str2num(nx_patch1),[]) |
---|
| 1775 | nx_patch1='50' ;%default |
---|
| 1776 | set(handles.nx_patch1,'String','50'); |
---|
| 1777 | end |
---|
| 1778 | ny_patch1=get(handles.ny_patch1,'String'); |
---|
| 1779 | if isequal(str2num(ny_patch1),[]) |
---|
| 1780 | ny_patch1='50' ;%default |
---|
| 1781 | set(handles.ny_patch1,'String','50'); |
---|
| 1782 | end |
---|
| 1783 | subdomain_patch1=get(handles.subdomain_patch1,'String'); |
---|
| 1784 | thresh_patch1=get(handles.thresh_patch1,'String'); |
---|
| 1785 | test_interp=get(handles.test_interp,'Value'); |
---|
| 1786 | icount=0; |
---|
| 1787 | for ifile=1:nbfield |
---|
| 1788 | for j=1:nbslice |
---|
| 1789 | icount=icount+1; |
---|
| 1790 | barlength=0.188*icount/(nbfield*nbslice); |
---|
| 1791 | set(handles.waitbar_patch1,'Position',[0.946 0.627-barlength 0.03 barlength]) |
---|
| 1792 | drawnow |
---|
| 1793 | if isequal(get(handles.test_stereo1,'Value'),0) |
---|
| 1794 | cmd=RUN_PATCH(filecell.nc.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp); |
---|
| 1795 | s=-1; |
---|
| 1796 | if sge |
---|
| 1797 | [s,w]=unix(['qrsh -q -fast.q ' cmd]); |
---|
| 1798 | end |
---|
| 1799 | if s~=0 |
---|
| 1800 | display(['!' cmd]) |
---|
| 1801 | eval(['!' cmd]); |
---|
| 1802 | end |
---|
| 1803 | |
---|
| 1804 | %stereo case: |
---|
| 1805 | elseif isequal(get(handles.test_stereo1,'Value'),1) |
---|
| 1806 | if exist('stinterp_exe','var')%Prog Gauthier |
---|
| 1807 | cmd=RUN_STINTERP(stinterp_exe,filecell.ncA.civ1{ifile,j},filecell.nc.civ1{ifile,j},filecell.st{ifile,j},... |
---|
| 1808 | nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,[filebase_A '.xml'],[filebase_B '.xml']); |
---|
| 1809 | display(['!' cmd]) |
---|
| 1810 | eval(['!' cmd]); |
---|
| 1811 | else |
---|
| 1812 | RUN_STLIN(filecell.ncA.civ1{ifile,j},filecell.nc.civ1{ifile,j},'civ1',filecell.st{ifile,j},... |
---|
| 1813 | str2num(nx_patch1),str2num(ny_patch1),str2num(thresh_patch1),[filebase_A '.xml'],[filebase_B '.xml']); |
---|
| 1814 | end |
---|
| 1815 | end |
---|
| 1816 | if compare==3 && isequal(get(handles.test_stereo1,'Value'),0) |
---|
| 1817 | cmd=RUN_PATCH(filecell.ncA.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp); |
---|
| 1818 | s=-1; |
---|
| 1819 | if sge |
---|
| 1820 | [s,w]=unix(['qrsh -q -fast.q ' cmd]); |
---|
| 1821 | end |
---|
| 1822 | if s~=0 |
---|
| 1823 | display(['!' cmd]) |
---|
| 1824 | eval(['!' cmd]); |
---|
| 1825 | end |
---|
| 1826 | end |
---|
| 1827 | end |
---|
| 1828 | end |
---|
| 1829 | end |
---|
| 1830 | |
---|
| 1831 | % CIV2 |
---|
| 1832 | if box_test(4)==1 |
---|
| 1833 | RUN_CIV2(handles,filecell.ima1.civ2,filecell.ima2.civ2,filecell.nc.civ1,filecell.nc.civ2,num1_civ2,num2_civ2,... |
---|
| 1834 | num_a_civ2,num_b_civ2,nom_type_nc) |
---|
| 1835 | end |
---|
| 1836 | |
---|
| 1837 | % FIX2 |
---|
| 1838 | if box_test(5)==1 |
---|
| 1839 | %names of the civ2 fields |
---|
| 1840 | field2.vel_type='civ2'; |
---|
| 1841 | field2.nb='nb_vectors2'; |
---|
| 1842 | field2.X='vec2_X'; |
---|
| 1843 | field2.Y='vec2_Y'; |
---|
| 1844 | field2.U='vec2_U'; |
---|
| 1845 | field2.V='vec2_V'; |
---|
| 1846 | field2.fixflag='vec2_FixFlag'; |
---|
| 1847 | flagindex(1)=get(handles.vec_Fmin2_2, 'Value'); |
---|
| 1848 | flagindex(2)=get(handles.vec_F3_2, 'Value'); |
---|
| 1849 | flagindex(3)=get(handles.vec_F4, 'Value'); |
---|
| 1850 | thresh_vec2C=str2num(get(handles.thresh_vec2C,'String'));%threshold on image correlation vec_C |
---|
| 1851 | thresh_vel2=str2num(get(handles.thresh_vel2,'String'));%threshold on velocity modulus |
---|
| 1852 | inf_sup=get(handles.inf_sup2,'Value'); |
---|
| 1853 | menu=get(handles.field_ref2,'String'); |
---|
| 1854 | index=get(handles.field_ref2,'Value'); |
---|
| 1855 | if isempty(menu) |
---|
| 1856 | fieldchoice=''; |
---|
| 1857 | else |
---|
| 1858 | fieldchoice=menu{index}; |
---|
| 1859 | end |
---|
| 1860 | h = waitbar(0,['removing velocity vectors, fix2']);% display a wait bar |
---|
| 1861 | test_mask=get(handles.get_mask_fix2,'Value'); |
---|
[12] | 1862 | if test_mask |
---|
| 1863 | maskdispl=get(handles.mask_fix2,'String'); |
---|
| 1864 | if exist(maskdispl,'file') |
---|
| 1865 | test_mask=2; |
---|
| 1866 | maskname=maskdispl; |
---|
| 1867 | else |
---|
| 1868 | maskbase=[get(handles.displ_filebase,'String') '_' maskdispl]; % mask root name |
---|
| 1869 | end |
---|
| 1870 | end |
---|
[2] | 1871 | for ifile=1:nbfield |
---|
| 1872 | waitbar(ifile/nbfield); %update the waitbar |
---|
| 1873 | for j=1:nbslice |
---|
| 1874 | if test_mask==0 |
---|
| 1875 | maskname='noFile use default'; |
---|
| 1876 | maskflag=0; |
---|
[12] | 1877 | elseif test_mask==1 |
---|
[2] | 1878 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 1879 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
| 1880 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 1881 | maskflag= exist(maskname,'file')==2; |
---|
| 1882 | if ~maskflag; |
---|
| 1883 | maskname='noFile use default'; |
---|
| 1884 | end |
---|
| 1885 | end |
---|
| 1886 | if ~isempty(file_ref_fix2) |
---|
| 1887 | file_ref=file_ref_fix2{ifile,j}; |
---|
| 1888 | else |
---|
| 1889 | file_ref=''; |
---|
| 1890 | end |
---|
| 1891 | error=RUN_FIX(filecell.nc.civ2{ifile,j},field2,flagindex,2,thresh_vec2C,maskflag,maskname,... |
---|
| 1892 | thresh_vel2,inf_sup,file_ref,fieldchoice); |
---|
| 1893 | if ~isempty(error) |
---|
| 1894 | msgbox_uvmat('ERROR',error) |
---|
| 1895 | return |
---|
| 1896 | end |
---|
| 1897 | if compare==3 |
---|
| 1898 | if test_mask==0 |
---|
| 1899 | maskname='noFile use default'; |
---|
| 1900 | maskflag=0; |
---|
| 1901 | else |
---|
| 1902 | maskbase=[get(handles.displ_filebase2,'String') '_' maskdispl]; % mask root name |
---|
| 1903 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 1904 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
| 1905 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 1906 | maskflag= exist(maskname,'file')==2; |
---|
| 1907 | if ~maskflag; |
---|
| 1908 | maskname='noFile use default'; |
---|
| 1909 | end |
---|
| 1910 | end |
---|
| 1911 | error=RUN_FIX(filecell.ncA.civ2{ifile,j},field2,flagindex,1,thresh_vec2C,maskflag,maskname,... |
---|
| 1912 | thresh_vel2,inf_sup,file_ref,fieldchoice); |
---|
| 1913 | if ~isempty(error) |
---|
| 1914 | msgbox_uvmat('ERROR',error) |
---|
| 1915 | return |
---|
| 1916 | end |
---|
| 1917 | end |
---|
| 1918 | end |
---|
| 1919 | end |
---|
| 1920 | close(h) |
---|
| 1921 | end |
---|
| 1922 | |
---|
| 1923 | %PATCH 2 |
---|
| 1924 | if box_test(6)==1 |
---|
| 1925 | rho_patch2=str2num(get(handles.rho_patch2,'String')); |
---|
| 1926 | if isempty(rho_patch2) |
---|
| 1927 | rho_patch2='1000'; |
---|
| 1928 | set(handles.rho_patch2,'String','1') |
---|
| 1929 | else |
---|
| 1930 | rho_patch2=num2str(1000*rho_patch2); |
---|
| 1931 | end |
---|
| 1932 | nx_patch2=get(handles.nx_patch2,'String'); |
---|
| 1933 | ny_patch2=get(handles.ny_patch2,'String'); |
---|
| 1934 | thresh_patch2=get(handles.thresh_patch2,'String'); |
---|
| 1935 | if isequal(str2num(nx_patch2),[]) |
---|
| 1936 | nx_patch2='50' ;%default |
---|
| 1937 | set(handles.nx_patch2,'String','50'); |
---|
| 1938 | end |
---|
| 1939 | if isequal(str2num(ny_patch2),[]) |
---|
| 1940 | ny_patch2='50' ;%default |
---|
| 1941 | set(handles.ny_patch2,'String','50'); |
---|
| 1942 | end |
---|
| 1943 | subdomain_patch2=get(handles.subdomain_patch2,'String'); |
---|
| 1944 | icount=0; |
---|
| 1945 | for ifile=1:nbfield |
---|
| 1946 | for j=1:nbslice |
---|
| 1947 | icount=icount+1; |
---|
| 1948 | barlength=0.188*icount/(nbfield*nbslice); |
---|
| 1949 | set(handles.waitbar_patch2,'Position',[0.946 0.188-barlength 0.03 barlength]) |
---|
| 1950 | drawnow |
---|
| 1951 | if compare~=3 | isequal(get(handles.test_stereo2,'Value'),0) |
---|
| 1952 | cmd=RUN_PATCH(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,1,0); |
---|
| 1953 | s=-1; |
---|
| 1954 | if sge |
---|
| 1955 | [s,w]=unix(['qrsh -q -fast.q ' cmd]); |
---|
| 1956 | end |
---|
| 1957 | if s~=0 |
---|
| 1958 | display(['!' cmd]) |
---|
| 1959 | eval(['!' cmd]); |
---|
| 1960 | end |
---|
| 1961 | elseif compare==3 && isequal(get(handles.test_stereo2,'Value'),1) |
---|
| 1962 | if exist('stinterp_exe','var')%Prog Gauthier |
---|
| 1963 | cmd=RUN_STINTERP(stinterp_exe,filecell.ncA.civ2{ifile,j},filecell.nc.civ2{ifile,j},filecell.st{ifile,j},... |
---|
| 1964 | nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,[filebase_A '.xml'],[filebase_B '.xml']); |
---|
| 1965 | display(['!' cmd]) |
---|
| 1966 | eval(['!' cmd]) |
---|
| 1967 | else |
---|
| 1968 | RUN_STLIN(filecell.ncA.civ2{ifile,j},filecell.nc.civ2{ifile,j},'civ2',filecell.st{ifile,j},... |
---|
| 1969 | str2num(nx_patch2),str2num(ny_patch2),str2num(thresh_patch2),[filebase_A '.xml'],[filebase_B '.xml']) |
---|
| 1970 | end |
---|
| 1971 | end |
---|
| 1972 | if compare==3 && isequal(get(handles.test_stereo2,'Value'),0) |
---|
| 1973 | cmd=RUN_PATCH(filecell.ncA.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,1,0); |
---|
| 1974 | s=-1; |
---|
| 1975 | if sge |
---|
| 1976 | [s,w]=unix(['qrsh -q -fast.q ' cmd]); |
---|
| 1977 | end |
---|
| 1978 | if s~=0 |
---|
| 1979 | display(['!' cmd]) |
---|
| 1980 | eval(['!' cmd]); |
---|
| 1981 | end |
---|
| 1982 | end |
---|
| 1983 | end |
---|
| 1984 | end |
---|
| 1985 | end |
---|
| 1986 | |
---|
| 1987 | set(handles.RUN, 'Enable','On') |
---|
| 1988 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 1989 | |
---|
| 1990 | %save the current interface setting as figure namefig, append .0 to the name if it already exists |
---|
| 1991 | if isfield(filecell,'st') |
---|
| 1992 | fileresu=filecell.st{1,1}; |
---|
| 1993 | elseif isfield(filecell,'nc') |
---|
| 1994 | if isfield(filecell.nc,'civ2') |
---|
| 1995 | fileresu=filecell.nc.civ2{1,1}; |
---|
| 1996 | else |
---|
| 1997 | fileresu=filecell.nc.civ1{1,1}; |
---|
| 1998 | end |
---|
| 1999 | end |
---|
| 2000 | [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileresu); |
---|
| 2001 | namedoc=fullfile(RootPath,subdir,RootFile); |
---|
| 2002 | detect=1; |
---|
| 2003 | while detect==1 |
---|
| 2004 | namefigfull=[namedoc '.fig']; |
---|
| 2005 | hh=dir(namefigfull); |
---|
| 2006 | if ~isempty(hh) |
---|
| 2007 | detect=1; |
---|
| 2008 | namedoc=[namedoc '.0']; |
---|
| 2009 | else |
---|
| 2010 | detect=0; |
---|
| 2011 | end |
---|
| 2012 | end |
---|
| 2013 | saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) |
---|
| 2014 | |
---|
[12] | 2015 | %------------------------------------------------------------------------ |
---|
[2] | 2016 | % --- Executes on button press in BATCH: remote processing |
---|
| 2017 | function BATCH_Callback(hObject, eventdata, handles) |
---|
[12] | 2018 | %------------------------------------------------------------------------ |
---|
[2] | 2019 | global civ1_exe civ2_exe patch_exe patch_new_exe fix_exe todo_path sge Civ_exe |
---|
| 2020 | compare=get(handles.compare,'Value');%test for usual PIV (compare=1) or displacement (=2) or stereo PIV (=3) |
---|
| 2021 | |
---|
| 2022 | %check the list of operations: |
---|
| 2023 | operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'}; |
---|
| 2024 | run_flag=1; |
---|
| 2025 | box_test(1)=get(handles.CIV1,'Value'); |
---|
| 2026 | box_test(2)=get(handles.FIX1,'Value'); |
---|
| 2027 | box_test(3)=get(handles.PATCH1,'Value'); |
---|
| 2028 | box_test(4)=get(handles.CIV2,'Value'); |
---|
| 2029 | box_test(5)=get(handles.FIX2,'Value'); |
---|
| 2030 | box_test(6)=get(handles.PATCH2,'Value'); |
---|
| 2031 | index=find(box_test==1); |
---|
| 2032 | if isempty(index) |
---|
| 2033 | msgbox_uvmat('ERROR','no selected operation') |
---|
| 2034 | return |
---|
| 2035 | end |
---|
| 2036 | index_first=min(index); |
---|
| 2037 | index_last=max(index); |
---|
| 2038 | box_used=box_test([index_first : index_last]); |
---|
| 2039 | [box_missing,ind_missing]=min(box_used); |
---|
| 2040 | if isequal(box_missing,0) |
---|
| 2041 | msgbox_uvmat('ERROR',['missing' cell2mat(operations(ind_missing))]); |
---|
| 2042 | return |
---|
| 2043 | end |
---|
| 2044 | |
---|
| 2045 | %root name |
---|
| 2046 | filebase=get(handles.displ_filebase,'String'); |
---|
| 2047 | if isempty(filebase)||isequal(filebase,'') |
---|
| 2048 | msgbox_uvmat('ERROR','no input files') |
---|
| 2049 | return |
---|
| 2050 | end |
---|
| 2051 | |
---|
| 2052 | %check mask if selecetd |
---|
| 2053 | if isequal(get(handles.get_mask_civ1,'Value'),1) |
---|
[12] | 2054 | maskname=get(handles.mask_civ1,'String'); |
---|
| 2055 | if ~exist(maskname,'file') |
---|
| 2056 | get_mask_civ1_Callback(hObject, eventdata, handles); |
---|
| 2057 | end |
---|
[2] | 2058 | end |
---|
| 2059 | if isequal(get(handles.get_mask_fix1,'Value'),1) |
---|
[12] | 2060 | maskname=get(handles.mask_fix1,'String'); |
---|
| 2061 | if ~exist(maskname,'file') |
---|
| 2062 | get_mask_fix1_Callback(hObject, eventdata, handles); |
---|
| 2063 | end |
---|
[2] | 2064 | end |
---|
| 2065 | if isequal(get(handles.get_mask_civ2,'Value'),1) |
---|
[12] | 2066 | maskname=get(handles.mask_civ2,'String'); |
---|
| 2067 | if ~exist(maskname,'file') |
---|
[2] | 2068 | get_mask_civ2_Callback(hObject, eventdata, handles); |
---|
[12] | 2069 | end |
---|
[2] | 2070 | end |
---|
| 2071 | if isequal(get(handles.get_mask_fix2,'Value'),1) |
---|
[12] | 2072 | maskname=get(handles.mask_fix2,'String'); |
---|
| 2073 | if ~exist(maskname,'file') |
---|
[2] | 2074 | get_mask_fix2_Callback(hObject, eventdata, handles); |
---|
[12] | 2075 | end |
---|
[2] | 2076 | end |
---|
| 2077 | |
---|
| 2078 | %read names of the .exe file |
---|
| 2079 | path_uvmat=which('uvmat');% check the path detected for source file uvmat |
---|
| 2080 | path_UVMAT=fileparts(path_uvmat); %path to UVMAT |
---|
| 2081 | if isunix |
---|
| 2082 | xmlfile=fullfile(path_UVMAT,'PARAM_LINUX.xml'); |
---|
| 2083 | if exist(xmlfile,'file') |
---|
| 2084 | t=xmltree(xmlfile); |
---|
| 2085 | sparam=convert(t); |
---|
| 2086 | end |
---|
| 2087 | else |
---|
| 2088 | xmlfile=fullfile(path_UVMAT,'PARAM_WIN.xml'); |
---|
| 2089 | if exist(xmlfile,'file') |
---|
| 2090 | t=xmltree(xmlfile); |
---|
| 2091 | sparam=convert(t); |
---|
| 2092 | end |
---|
| 2093 | end |
---|
| 2094 | sge=0; |
---|
| 2095 | if isfield(sparam,'Civ_exe') |
---|
| 2096 | Civ_exe=sparam.Civ_exe; |
---|
| 2097 | end |
---|
| 2098 | if isfield(sparam,'Civ1_exe') |
---|
| 2099 | civ1_exe=sparam.Civ1_exe; |
---|
| 2100 | end |
---|
| 2101 | if isfield(sparam,'Civ2_exe') |
---|
| 2102 | civ2_exe=sparam.Civ2_exe; |
---|
| 2103 | end |
---|
| 2104 | if isfield(sparam,'Patch_exe') |
---|
| 2105 | patch_exe=sparam.Patch_exe; |
---|
| 2106 | end |
---|
| 2107 | if isfield(sparam,'PatchNew_exe') |
---|
| 2108 | patch_new_exe=sparam.PatchNew_exe; |
---|
| 2109 | end |
---|
| 2110 | if isfield(sparam,'Fix_exe') |
---|
| 2111 | fix_exe=sparam.Fix_exe; |
---|
| 2112 | end |
---|
| 2113 | if isfield(sparam,'Todo_path') |
---|
| 2114 | todo_path=sparam.Todo_path; |
---|
| 2115 | end |
---|
| 2116 | if isfield(sparam,'SGE') |
---|
| 2117 | sge=str2num(sparam.SGE); |
---|
| 2118 | end |
---|
| 2119 | |
---|
| 2120 | %choice of batch priority |
---|
| 2121 | ind_answer=2; |
---|
| 2122 | if sge |
---|
| 2123 | [s,w]=unix('qstat -q civ.q|grep job_| wc -l'); %check the waiting list (command unix) |
---|
| 2124 | if isequal(s,0) |
---|
| 2125 | w(end)=[]; |
---|
| 2126 | str_displ={[w ' jobs in the waiting list'];'Select a priority:'}; |
---|
| 2127 | str={'urgent';'normal';'low'}; |
---|
| 2128 | [ind_answer,v] = listdlg('PromptString',str_displ,... |
---|
| 2129 | 'SelectionMode','single',... |
---|
| 2130 | 'ListString',str,'ListSize',[200 200],'Name','job priority','InitialValue',3); |
---|
| 2131 | if isequal(v,0) % to handle Cancel button and figure close, |
---|
| 2132 | return % a better way should be create |
---|
| 2133 | end |
---|
| 2134 | else |
---|
| 2135 | msgbox_uvmat('ERROR','batch system not available') |
---|
| 2136 | return |
---|
| 2137 | end |
---|
| 2138 | end |
---|
| 2139 | |
---|
| 2140 | %initialize the waitbars |
---|
| 2141 | set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001]) |
---|
| 2142 | set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001]) |
---|
| 2143 | set(handles.waitbar_civ2,'Position',[0.946 0.219 0.03 0.001]) |
---|
| 2144 | set(handles.waitbar_patch2,'Position',[0.946 0.0 0.03 0.001]) |
---|
| 2145 | set(handles.BATCH, 'Enable','Off') |
---|
| 2146 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 2147 | drawnow |
---|
| 2148 | %get the filename root, nomenclature and numbers |
---|
| 2149 | |
---|
| 2150 | % for Windows system find the UBC path name if needed |
---|
| 2151 | if ~isunix & isequal(todo_path(1:2),'\\') & isequal(filebase(2:3),':\') |
---|
| 2152 | cur_dir=pwd; |
---|
| 2153 | if ~isequal(cur_dir(2:3),':\') |
---|
| 2154 | cd(matlabroot); %move to the Matlab root directory if the current Matlab dir does not allow the dos command or is M: |
---|
| 2155 | end |
---|
| 2156 | [ss,ww]=dos(['net use ' filebase(1:2)]); |
---|
| 2157 | if isequal(ss,0) |
---|
| 2158 | rankpath=findstr(ww,'\\'); |
---|
| 2159 | if ~isempty(rankpath) |
---|
| 2160 | wwrest=ww(rankpath:end); |
---|
| 2161 | rankend=min(find(double(wwrest)==10))-1; |
---|
| 2162 | filebase=[wwrest(1:rankend) filebase(3:end)]; |
---|
| 2163 | set(handles.displ_filebase,'String',filebase); |
---|
| 2164 | end |
---|
| 2165 | else |
---|
| 2166 | msgbox_uvmat('ERROR','for BATCH option, UBC file names, beginning by \\, are needed'); |
---|
| 2167 | set(handles.BATCH, 'Enable','On') |
---|
| 2168 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 2169 | return |
---|
| 2170 | end |
---|
| 2171 | end |
---|
| 2172 | |
---|
| 2173 | % set the list of files and check them |
---|
| 2174 | display('checking the files...') |
---|
| 2175 | [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]=... |
---|
| 2176 | set_civ_filenames(handles,compare,box_test); |
---|
| 2177 | display('files OK, processing...') |
---|
| 2178 | nbfield=size(num1_civ1,2); |
---|
| 2179 | nbslice=size(num1_civ1,1); |
---|
| 2180 | |
---|
| 2181 | %GET PARAMETERS: |
---|
| 2182 | %get civ parameters |
---|
| 2183 | if box_test(1)==1 |
---|
| 2184 | par_civ1=read_param_civ1(handles,filecell.ima1.civ1{1,1}); |
---|
| 2185 | end |
---|
| 2186 | |
---|
| 2187 | %get fix1 parameters |
---|
| 2188 | if box_test(2)==1 |
---|
| 2189 | flagindex1(1)=get(handles.vec_Fmin2, 'Value'); |
---|
| 2190 | flagindex1(2)=get(handles.vec_F3, 'Value'); |
---|
| 2191 | flagindex1(3)=get(handles.vec_F2, 'Value'); |
---|
| 2192 | thresh_vecC1=str2num(get(handles.thresh_vecC,'String'));%threshold on image correlation vec_C |
---|
| 2193 | thresh_vel1=str2num(get(handles.thresh_vel,'String'));%threshold on velocity modulus |
---|
| 2194 | test_mask=get(handles.get_mask_fix1,'Value'); |
---|
| 2195 | nbslice_mask=get(handles.mask_fix1,'UserData'); % get the number of slices (= number of masks) |
---|
| 2196 | %%%%%%%%%%%%%COMPLETER LE PROGRAMME FIX |
---|
| 2197 | % inf_sup=get(handles.inf_sup1,'Value'); |
---|
| 2198 | % fileref=get(handles.ref_fix1,'String'); |
---|
| 2199 | % refpath=get(handles.ref_fix1,'UserData'); |
---|
| 2200 | % fileref=fullfile(refpath,fileref); |
---|
| 2201 | menu=get(handles.field_ref1,'String'); |
---|
| 2202 | index=get(handles.field_ref1,'Value'); |
---|
| 2203 | if isempty(menu) |
---|
| 2204 | fieldchoice=''; |
---|
| 2205 | else |
---|
| 2206 | fieldchoice=menu{index}; |
---|
| 2207 | msgbox_uvmat('WARNING','reference field is not used presently with batch, use RUN option') |
---|
| 2208 | end |
---|
| 2209 | end |
---|
| 2210 | |
---|
| 2211 | %get patch1 parameters |
---|
| 2212 | if box_test(3)==1 |
---|
| 2213 | rho_patch1=str2num(get(handles.rho_patch1,'String')); |
---|
| 2214 | if isempty(rho_patch1) |
---|
| 2215 | rho_patch1='1000'; |
---|
| 2216 | set(handles.rho_patch1,'String','1') |
---|
| 2217 | else |
---|
| 2218 | rho_patch1=num2str(1000*rho_patch1); |
---|
| 2219 | end |
---|
| 2220 | nx_patch1=get(handles.nx_patch1,'String'); |
---|
| 2221 | ny_patch1=get(handles.ny_patch1,'String'); |
---|
| 2222 | if isequal(str2num(nx_patch1),[]) |
---|
| 2223 | nx_patch1='50' ;%default |
---|
| 2224 | set(handles.nx_patch1,'String','50'); |
---|
| 2225 | end |
---|
| 2226 | if isequal(str2num(ny_patch1),[]) |
---|
| 2227 | ny_patch1='50' ;%default |
---|
| 2228 | set(handles.ny_patch1,'String','50'); |
---|
| 2229 | end |
---|
| 2230 | subdomain_patch1=get(handles.subdomain_patch1,'String'); |
---|
| 2231 | thresh_patch1=get(handles.thresh_patch1,'String'); |
---|
| 2232 | test_interp=get(handles.test_interp,'Value'); |
---|
| 2233 | end |
---|
| 2234 | |
---|
| 2235 | %get civ2 parameters |
---|
| 2236 | if box_test(4)==1 |
---|
| 2237 | par_civ2=read_param_civ2(handles,cell2mat(filecell.ima1.civ2(1,1))); |
---|
| 2238 | end |
---|
| 2239 | |
---|
| 2240 | %get fix2 parameters |
---|
| 2241 | if box_test(5)==1 |
---|
| 2242 | flagindex2(1)=get(handles.vec_Fmin2_2, 'Value'); |
---|
| 2243 | flagindex2(2)=get(handles.vec_F3_2, 'Value'); |
---|
| 2244 | flagindex2(3)=get(handles.vec_F4, 'Value'); |
---|
| 2245 | thresh_vec2C=str2num(get(handles.thresh_vec2C,'String'));%threshold on image correlation vec_C |
---|
| 2246 | thresh_vel2=str2num(get(handles.thresh_vel2,'String'));%threshold on velocity modulus |
---|
| 2247 | test_mask=get(handles.get_mask_fix2,'Value'); |
---|
| 2248 | nbslice_mask=get(handles.mask_fix2,'UserData'); % get the number of slices (= number of masks) |
---|
| 2249 | %%%%%%%%%%%%%COMPLETER LE PROGRAMME FIX AVEC REF FILE ET OPTION inf_sup=2 |
---|
| 2250 | % inf_sup=get(handles.inf_sup2,'Value'); |
---|
| 2251 | % ref=get(handles.ref_fix2,'UserData'); |
---|
| 2252 | |
---|
| 2253 | %%%%%%%%%%%%%%%%%%% |
---|
| 2254 | end |
---|
| 2255 | |
---|
| 2256 | |
---|
| 2257 | %get patch2 parameters |
---|
| 2258 | if box_test(6)==1 |
---|
| 2259 | rho_patch2=str2num(get(handles.rho_patch2,'String')); |
---|
| 2260 | if isempty(rho_patch2) |
---|
| 2261 | rho_patch2='1000'; |
---|
| 2262 | set(handles.rho_patch2,'String','1') |
---|
| 2263 | else |
---|
| 2264 | rho_patch2=num2str(1000*rho_patch2); |
---|
| 2265 | end |
---|
| 2266 | nx_patch2=get(handles.nx_patch2,'String'); |
---|
| 2267 | ny_patch2=get(handles.ny_patch2,'String'); |
---|
| 2268 | if isequal(str2num(nx_patch2),[]) |
---|
| 2269 | nx_patch2='50' ;%default |
---|
| 2270 | set(handles.nx_patch2,'String','50'); |
---|
| 2271 | end |
---|
| 2272 | if isequal(str2num(ny_patch2),[]) |
---|
| 2273 | ny_patch2='50' ;%default |
---|
| 2274 | set(handles.ny_patch2,'String','50'); |
---|
| 2275 | end |
---|
| 2276 | subdomain_patch2=get(handles.subdomain_patch2,'String'); |
---|
| 2277 | thresh_patch2=get(handles.thresh_patch2,'String'); |
---|
| 2278 | test_interp=get(handles.test_interp,'Value'); |
---|
| 2279 | end |
---|
| 2280 | |
---|
| 2281 | if ~sge |
---|
| 2282 | |
---|
| 2283 | %OPEN THE WAIT LIST FOR BATCH PROCESSES |
---|
| 2284 | name_lock=fullfile(todo_path,'lock'); %lock file |
---|
| 2285 | iwait=0; |
---|
| 2286 | while(exist(name_lock) & iwait<15) |
---|
| 2287 | pause(1); %wait 1 second |
---|
| 2288 | iwait=iwait+1; |
---|
| 2289 | end |
---|
| 2290 | if iwait==15 |
---|
| 2291 | msgbox_uvmat('ERROR',['I''m tired to wait for the lock file, please delete it then click again on BATCH' name_lock ]) |
---|
| 2292 | set(handles.BATCH, 'Enable','On') |
---|
| 2293 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 2294 | return |
---|
| 2295 | end |
---|
| 2296 | p0=fopen(name_lock,'w'); %create the file name_lock: prevents other users to interfere |
---|
| 2297 | name_todo=fullfile(todo_path,'TODO.txt'); |
---|
| 2298 | p1=fopen(name_todo,'a'); |
---|
| 2299 | if (p1<0) |
---|
| 2300 | msgbox_uvmat('ERROR',['error in opening ' name_todo]) |
---|
| 2301 | set(handles.BATCH, 'Enable','On') |
---|
| 2302 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 2303 | return; |
---|
| 2304 | end |
---|
| 2305 | end |
---|
| 2306 | |
---|
| 2307 | %MAIN LOOP |
---|
| 2308 | % for ifile=1:nbfield |
---|
| 2309 | p1text=[];%initiate command text |
---|
| 2310 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 2311 | civAll=get(handles.Experimental,'Value'); % Boolean for new civ excution method |
---|
| 2312 | for ifile=1:nbfield |
---|
| 2313 | for j=1:nbslice |
---|
| 2314 | i_cmd=0; |
---|
| 2315 | cmd=''; |
---|
| 2316 | if sge |
---|
[12] | 2317 | %fid=fopen([filename '.cmx'],'w') |
---|
[2] | 2318 | cmd='#!/bin/bash'; |
---|
[12] | 2319 | cmd=[cmd '\n' '#$ -cwd']; |
---|
| 2320 | cmd=[cmd '\n' 'hostname && date']; |
---|
[2] | 2321 | end |
---|
| 2322 | if civAll |
---|
| 2323 | civAllxml=xmltree;% xml contents, all parameters |
---|
| 2324 | civAllCmd=[]; |
---|
| 2325 | civAllxml=set(civAllxml,1,'name','CivDoc'); |
---|
| 2326 | end |
---|
| 2327 | % filecell.nc.civ1 |
---|
| 2328 | filename_cmx=cell2mat(filecell.nc.civ1(ifile,j));%output netcdf file |
---|
| 2329 | filename_cmx([end-1:end])='cm';%name of cmx file |
---|
| 2330 | filename_cmx=[filename_cmx 'x']; |
---|
| 2331 | |
---|
| 2332 | %CIV1 |
---|
| 2333 | if box_test(1)==1 |
---|
| 2334 | par_civ1.filename_ima_a=cell2mat(filecell.ima1.civ1(ifile,j)); |
---|
| 2335 | % par_civ1.filename_ima_a([end-3:end])=[];%remove .png extension |
---|
| 2336 | par_civ1.filename_ima_b=cell2mat(filecell.ima2.civ1(ifile,j)); |
---|
| 2337 | % par_civ1.filename_ima_b([end-3:end])=[];%remove .png extension |
---|
| 2338 | |
---|
| 2339 | namelog=[filename_cmx([1:end-3]) 'log']; |
---|
| 2340 | par_civ1.Dt=num2str(time(num2_civ1(ifile),num_b_civ1(j))-time(num1_civ1(ifile),num_a_civ1(j))); |
---|
| 2341 | par_civ1.T0=num2str((time(num2_civ1(ifile),num_b_civ1(j))+time(num1_civ1(ifile),num_a_civ1(j)))/2); |
---|
| 2342 | par_civ1.term_a=num2stra(num_a_civ1(j),nom_type_nc);%UTILITE? |
---|
| 2343 | par_civ1.term_b=num2stra(num_b_civ1(j),nom_type_nc);% |
---|
| 2344 | test_mask=get(handles.get_mask_civ1,'Value'); |
---|
| 2345 | if test_mask==0 |
---|
| 2346 | par_civ1.maskname='noFile use default'; |
---|
| 2347 | par_civ1.maskflag='n'; |
---|
| 2348 | else |
---|
| 2349 | maskdispl=get(handles.mask_civ1,'String'); |
---|
[12] | 2350 | if exist(maskdispl,'file') |
---|
| 2351 | par_civ1.maskname=maskdispl; |
---|
| 2352 | par_civ1.maskflag='y'; |
---|
[2] | 2353 | else |
---|
[12] | 2354 | maskbase=[filebase '_' maskdispl]; % |
---|
| 2355 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 2356 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
| 2357 | par_civ1.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 2358 | if exist(par_civ1.maskname,'file') |
---|
| 2359 | par_civ1.maskflag='y'; |
---|
| 2360 | else |
---|
| 2361 | par_civ1.maskname='noFile use default'; |
---|
| 2362 | par_civ1.maskflag='n'; |
---|
| 2363 | end |
---|
[2] | 2364 | end |
---|
| 2365 | end |
---|
| 2366 | |
---|
| 2367 | %TESTgrid |
---|
| 2368 | test_grid=get(handles.browse_gridciv1,'Value'); |
---|
| 2369 | if test_grid |
---|
| 2370 | par_civ1.gridflag='y'; |
---|
| 2371 | gridname=get(handles.grid_civ1,'String'); |
---|
| 2372 | if isequal(gridname(end-3:end),'grid') |
---|
| 2373 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
| 2374 | if ~isempty(nbslice_grid) |
---|
| 2375 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
| 2376 | par_civ1.gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 2377 | if ~exist(par_civ1.gridname,'file') |
---|
| 2378 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
| 2379 | end |
---|
| 2380 | elseif exist(gridname,'file') |
---|
| 2381 | par_civ1.gridname=gridname; |
---|
| 2382 | else |
---|
| 2383 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
| 2384 | end |
---|
| 2385 | end |
---|
| 2386 | else |
---|
| 2387 | par_civ1.gridname='noFile use default'; |
---|
| 2388 | par_civ1.gridflag='n'; |
---|
| 2389 | end |
---|
| 2390 | %endTESTgrid |
---|
| 2391 | |
---|
| 2392 | i_cmd=i_cmd+1; |
---|
| 2393 | if isequal(civAll,0) |
---|
[12] | 2394 | cmd=[cmd '\n' BATCH_CIV1(filename_cmx(1:end-4),namelog,par_civ1,handles)]; |
---|
[2] | 2395 | else |
---|
| 2396 | civAllCmd=[civAllCmd ' civ1 ']; |
---|
| 2397 | str=BATCH_CIV1_Unified(filename_cmx([1:end-4]),namelog,par_civ1); |
---|
| 2398 | fieldnames=fields(str); |
---|
| 2399 | [civAllxml,uid_civ1]=add(civAllxml,1,'element','civ1'); |
---|
| 2400 | for ilist=1:length(fieldnames) |
---|
| 2401 | val=eval(['str.' fieldnames{ilist}]); |
---|
| 2402 | if ischar(val) |
---|
| 2403 | [civAllxml,uid_t]=add(civAllxml,uid_civ1,'element',fieldnames{ilist}); |
---|
| 2404 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2405 | end |
---|
| 2406 | end |
---|
| 2407 | end |
---|
| 2408 | end |
---|
| 2409 | |
---|
| 2410 | % FIX1 |
---|
| 2411 | if box_test(2)==1 |
---|
| 2412 | test_mask=get(handles.get_mask_fix1,'Value'); |
---|
| 2413 | if test_mask==0 |
---|
| 2414 | maskname=''; |
---|
| 2415 | else |
---|
| 2416 | maskdispl=get(handles.mask_fix1,'String'); |
---|
| 2417 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 2418 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
| 2419 | maskbase=[filebase '_' maskdispl]; |
---|
| 2420 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 2421 | end |
---|
| 2422 | if isequal(civAll,0) |
---|
| 2423 | cmd_FIX=[fix_exe ' -f ' filecell.nc.civ1{ifile,j} ' -fi1 ' num2str(flagindex1(1)) ... |
---|
| 2424 | ' -fi2 ' num2str(flagindex1(2)) ' -fi3 ' num2str(flagindex1(3)) ... |
---|
| 2425 | ' -threshC ' num2str(thresh_vecC1) ' -threshV ' num2str(thresh_vel1) ' -maskName ' maskname]; |
---|
[12] | 2426 | cmd=[cmd '\n' cmd_FIX]; |
---|
[2] | 2427 | else |
---|
| 2428 | fix1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 2429 | fix1.fi1=num2str(flagindex1(1)); |
---|
| 2430 | fix1.fi2=num2str(flagindex1(2)); |
---|
| 2431 | fix1.fi3=num2str(flagindex1(3)); |
---|
| 2432 | fix1.threshC=num2str(thresh_vecC1); |
---|
| 2433 | fix1.threshV=num2str(thresh_vel1); |
---|
| 2434 | fieldnames=fields(fix1); |
---|
| 2435 | [civAllxml,uid_fix1]=add(civAllxml,1,'element','fix1'); |
---|
| 2436 | for ilist=1:length(fieldnames) |
---|
| 2437 | val=eval(['fix1.' fieldnames{ilist}]); |
---|
| 2438 | if ischar(val) |
---|
| 2439 | [civAllxml,uid_t]=add(civAllxml,uid_fix1,'element',fieldnames{ilist}); |
---|
| 2440 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2441 | end |
---|
| 2442 | end |
---|
| 2443 | civAllCmd=[civAllCmd ' fix1 ']; |
---|
| 2444 | end |
---|
| 2445 | end |
---|
| 2446 | |
---|
| 2447 | %PATCH1 |
---|
| 2448 | if box_test(3)==1 |
---|
| 2449 | if isequal(civAll,0) |
---|
| 2450 | cmd_PATCH=RUN_PATCH(filecell.nc.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp); |
---|
[12] | 2451 | cmd=[cmd '\n' cmd_PATCH]; |
---|
[2] | 2452 | else |
---|
| 2453 | patch1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 2454 | patch1.nopt=subdomain_patch1; |
---|
| 2455 | patch1.maxdiff=thresh_patch1; |
---|
| 2456 | patch1.ro=rho_patch1; |
---|
| 2457 | test_grid=get(handles.get_gridpatch1,'Value'); |
---|
| 2458 | if test_grid |
---|
| 2459 | patch1.gridflag='y'; |
---|
| 2460 | gridname=get(handles.grid_patch1,'String'); |
---|
| 2461 | if isequal(gridname(end-3:end),'grid') |
---|
| 2462 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
| 2463 | if ~isempty(nbslice_grid) |
---|
| 2464 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
| 2465 | patch1.gridPatch=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 2466 | if ~exist(patch1.gridPatch,'file') |
---|
| 2467 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
| 2468 | end |
---|
| 2469 | elseif exist(gridname,'file') |
---|
| 2470 | patch1.gridPatch=gridname; |
---|
| 2471 | else |
---|
| 2472 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
| 2473 | end |
---|
| 2474 | end |
---|
| 2475 | else |
---|
| 2476 | patch1.gridPatch='n'; |
---|
| 2477 | patch1.gridflag='n'; |
---|
| 2478 | patch1.m=nx_patch1; |
---|
| 2479 | patch1.n=ny_patch1; |
---|
| 2480 | end |
---|
| 2481 | patch1.convectFlow='n'; |
---|
| 2482 | fieldnames=fields(patch1); |
---|
| 2483 | [civAllxml,uid_patch1]=add(civAllxml,1,'element','patch1'); |
---|
| 2484 | for ilist=1:length(fieldnames) |
---|
| 2485 | val=eval(['patch1.' fieldnames{ilist}]); |
---|
| 2486 | if ischar(val) |
---|
| 2487 | [civAllxml,uid_t]=add(civAllxml,uid_patch1,'element',fieldnames{ilist}); |
---|
| 2488 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2489 | end |
---|
| 2490 | end |
---|
| 2491 | civAllCmd=[civAllCmd ' patch1 ']; |
---|
| 2492 | end |
---|
| 2493 | end |
---|
| 2494 | |
---|
| 2495 | if box_test(4)==1 | box_test(5)==1 | box_test(6)==1 |
---|
| 2496 | filename_cmx=filecell.nc.civ2{ifile,j};%output netcdf file |
---|
| 2497 | filename_cmx([end-1:end])=[ 'cm'];%name of cmx file |
---|
| 2498 | filename_cmx=[filename_cmx 'x']; |
---|
| 2499 | end |
---|
| 2500 | |
---|
| 2501 | if box_test(4)==1 |
---|
| 2502 | par_civ2.filename_ima_a=filecell.ima1.civ2{ifile,j}; |
---|
| 2503 | %par_civ2.filename_ima_a([end-3:end])=[];%remove .png extension |
---|
| 2504 | par_civ2.filename_ima_b=filecell.ima2.civ2{ifile,j}; |
---|
| 2505 | %par_civ2.filename_ima_b([end-3:end])=[];%remove .png extension |
---|
| 2506 | namelog=[filename_cmx([1:end-3]) 'log']; |
---|
| 2507 | par_civ2.Dt=num2str(time(num2_civ2(ifile),num_b_civ2(j))-time(num1_civ2(ifile),num_a_civ2(j))); |
---|
| 2508 | par_civ2.T0=num2str((time(num2_civ1(ifile),num_b_civ2(j))+time(num1_civ2(ifile),num_a_civ2(j)))/2); |
---|
| 2509 | par_civ2.term_a=num2stra(num_a_civ2(j),nom_type_nc); |
---|
| 2510 | par_civ2.term_b=num2stra(num_b_civ2(j),nom_type_nc); |
---|
| 2511 | par_civ2.filename_nc1=filecell.nc.civ1{ifile,j}; |
---|
| 2512 | par_civ2.filename_nc1([end-2:end])=[]; % remove '.nc' |
---|
| 2513 | test_mask=get(handles.get_mask_civ2,'Value'); |
---|
| 2514 | if test_mask==0 |
---|
| 2515 | par_civ2.maskname='noFile use default'; |
---|
| 2516 | par_civ2.maskflag='n'; |
---|
| 2517 | else |
---|
| 2518 | maskdispl=get(handles.mask_civ2,'String'); |
---|
[12] | 2519 | if exist(maskdispl,'file') |
---|
| 2520 | par_civ2.maskname=maskdispl; |
---|
| 2521 | par_civ2.maskflag='y'; |
---|
[2] | 2522 | else |
---|
[12] | 2523 | maskbase=[filebase '_' maskdispl]; % |
---|
| 2524 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 2525 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
| 2526 | par_civ2.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 2527 | if exist(par_civ2.maskname,'file') |
---|
| 2528 | par_civ2.maskflag='y'; |
---|
| 2529 | else |
---|
| 2530 | par_civ2.maskname='noFile use default'; |
---|
| 2531 | par_civ2.maskflag='n'; |
---|
| 2532 | end |
---|
[2] | 2533 | end |
---|
| 2534 | end |
---|
| 2535 | %TESTgrid |
---|
| 2536 | test_grid=get(handles.browse_gridciv2,'Value'); |
---|
| 2537 | gridname=get(handles.grid_civ2,'String'); |
---|
| 2538 | gridflag='y'; |
---|
| 2539 | if numel(gridname)>=4 && isequal(gridname(end-3:end),'grid') |
---|
| 2540 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
| 2541 | if ~isempty(nbslice_grid) |
---|
| 2542 | par_civ2.gridflag='y'; |
---|
| 2543 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
| 2544 | par_civ2.gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 2545 | if exist(par_civ2.gridname,'file') |
---|
| 2546 | par_civ2.gridflag='y'; |
---|
| 2547 | else |
---|
| 2548 | par_civ2.gridname='noFile use default'; |
---|
| 2549 | par_civ2.gridflag='n'; |
---|
| 2550 | end |
---|
| 2551 | elseif exist(gridname,'file') |
---|
| 2552 | par_civ2.gridflag='y'; |
---|
| 2553 | else |
---|
| 2554 | par_civ2.gridname='noFile use default'; |
---|
| 2555 | par_civ2.gridflag='n'; |
---|
| 2556 | end |
---|
| 2557 | end |
---|
| 2558 | %endTESTgrid |
---|
| 2559 | i_cmd=i_cmd+1; |
---|
| 2560 | cmd_CIV2=BATCH_CIV2(filename_cmx,namelog,par_civ2); |
---|
| 2561 | if isequal(civAll,0) |
---|
| 2562 | if(isunix) |
---|
[12] | 2563 | cmd=[cmd '\n' 'cp -f ' filename_cmx '2 ' filename_cmx '\n' cmd_CIV2]; |
---|
[2] | 2564 | else |
---|
[12] | 2565 | cmd=[cmd '\n' 'copy /Y ' filename_cmx '2 ' filename_cmx '\n' cmd_CIV2]; |
---|
[2] | 2566 | end |
---|
| 2567 | else |
---|
| 2568 | civAllCmd=[civAllCmd ' civ2 ']; |
---|
| 2569 | str=BATCH_CIV2_Unified(filename_cmx([1:end-4]),namelog,par_civ2); |
---|
| 2570 | fieldnames=fields(str); |
---|
| 2571 | [civAllxml,uid_civ2]=add(civAllxml,1,'element','civ2'); |
---|
| 2572 | for ilist=1:length(fieldnames) |
---|
| 2573 | val=eval(['str.' fieldnames{ilist}]); |
---|
| 2574 | if ischar(val) |
---|
| 2575 | [civAllxml,uid_t]=add(civAllxml,uid_civ2,'element',fieldnames{ilist}); |
---|
| 2576 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2577 | end |
---|
| 2578 | end |
---|
| 2579 | end |
---|
| 2580 | end |
---|
| 2581 | |
---|
| 2582 | % FIX2 |
---|
[12] | 2583 | if box_test(5)==1 |
---|
[2] | 2584 | test_mask=get(handles.get_mask_fix2,'Value'); |
---|
| 2585 | if test_mask==0 |
---|
| 2586 | maskname=''; %no mask used |
---|
| 2587 | else |
---|
| 2588 | maskdispl=get(handles.mask_fix2,'String'); |
---|
| 2589 | maskbase=[filebase '_' maskdispl]; % |
---|
| 2590 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 2591 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
| 2592 | maskname =name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 2593 | end |
---|
| 2594 | if isequal(civAll,0) |
---|
| 2595 | cmd_FIX=[fix_exe ' -f ' filecell.nc.civ2{ifile,j} ' -fi1 ' num2str(flagindex2(1)) ... |
---|
| 2596 | ' -fi2 ' num2str(flagindex2(2)) ' -fi3 ' num2str(flagindex2(3)) ... |
---|
| 2597 | ' -threshC ' num2str(thresh_vec2C) ' -threshV ' num2str(thresh_vel2) ' -maskName ' maskname]; |
---|
[12] | 2598 | cmd=[cmd '\n' cmd_FIX]; |
---|
[2] | 2599 | else |
---|
| 2600 | fix2.inputFileName=filecell.nc.civ2{ifile,j} ; |
---|
| 2601 | fix2.fi1=num2str(flagindex2(1)); |
---|
| 2602 | fix2.fi2=num2str(flagindex2(2)); |
---|
| 2603 | fix2.fi3=num2str(flagindex2(3)); |
---|
| 2604 | fix2.threshC=num2str(thresh_vec2C); |
---|
| 2605 | fix2.threshV=num2str(thresh_vel2); |
---|
| 2606 | fieldnames=fields(fix2); |
---|
| 2607 | [civAllxml,uid_fix2]=add(civAllxml,1,'element','fix2'); |
---|
| 2608 | for ilist=1:length(fieldnames) |
---|
| 2609 | val=eval(['fix2.' fieldnames{ilist}]); |
---|
| 2610 | if ischar(val) |
---|
| 2611 | [civAllxml,uid_t]=add(civAllxml,uid_fix2,'element',fieldnames{ilist}); |
---|
| 2612 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2613 | end |
---|
| 2614 | end |
---|
| 2615 | civAllCmd=[civAllCmd ' fix2 ']; |
---|
| 2616 | end |
---|
| 2617 | end |
---|
| 2618 | |
---|
| 2619 | %PATCH2 |
---|
[12] | 2620 | if box_test(6)==1 |
---|
| 2621 | if isequal(civAll,0) |
---|
| 2622 | cmd_PATCH=RUN_PATCH(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,test_interp); |
---|
| 2623 | cmd=[cmd '\n' cmd_PATCH]; |
---|
| 2624 | else |
---|
| 2625 | patch2.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 2626 | patch2.nopt=subdomain_patch1; |
---|
| 2627 | patch2.maxdiff=thresh_patch1; |
---|
| 2628 | patch2.ro=rho_patch1; |
---|
| 2629 | test_grid=get(handles.get_gridpatch2,'Value'); |
---|
| 2630 | if test_grid |
---|
| 2631 | patch2.gridflag='y'; |
---|
| 2632 | gridname=get(handles.grid_patch2,'String'); |
---|
| 2633 | if isequal(gridname(end-3:end),'grid') |
---|
| 2634 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
| 2635 | if ~isempty(nbslice_grid) |
---|
| 2636 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
| 2637 | patch2.gridPatch=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 2638 | if ~exist(patch2.gridPatch,'file') |
---|
| 2639 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
| 2640 | end |
---|
| 2641 | elseif exist(gridname,'file') |
---|
| 2642 | patch2.gridPatch=gridname; |
---|
| 2643 | else |
---|
| 2644 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
[2] | 2645 | end |
---|
| 2646 | end |
---|
[12] | 2647 | else |
---|
| 2648 | patch2.gridPatch='n'; |
---|
| 2649 | patch2.gridflag='n'; |
---|
| 2650 | patch2.m=nx_patch2; |
---|
| 2651 | patch2.n=ny_patch2; |
---|
[2] | 2652 | end |
---|
[12] | 2653 | patch2.convectFlow='n'; |
---|
| 2654 | fieldnames=fields(patch2); |
---|
| 2655 | [civAllxml,uid_patch2]=add(civAllxml,1,'element','patch2'); |
---|
| 2656 | for ilist=1:length(fieldnames) |
---|
| 2657 | val=eval(['patch2.' fieldnames{ilist}]); |
---|
| 2658 | if ischar(val) |
---|
| 2659 | [civAllxml,uid_t]=add(civAllxml,uid_patch2,'element',fieldnames{ilist}); |
---|
| 2660 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2661 | end |
---|
| 2662 | end |
---|
| 2663 | civAllCmd=[civAllCmd ' patch2 ']; |
---|
| 2664 | end |
---|
| 2665 | end |
---|
| 2666 | if isequal(civAll,1) |
---|
| 2667 | save(civAllxml,[filename_cmx([1:end-4]) '.xml']); |
---|
| 2668 | cmd=char({cmd;[Civ_exe ' -f ' [filename_cmx([1:end-4]) '.xml'] ' ' civAllCmd]}); |
---|
| 2669 | end |
---|
| 2670 | |
---|
| 2671 | % create the .bat file: |
---|
| 2672 | if sge |
---|
| 2673 | [Rootbat,Filebat,extbat]=fileparts(filename_cmx); |
---|
| 2674 | filename_bat=fullfile(Rootbat,['job_' Filebat extbat]); |
---|
| 2675 | else |
---|
| 2676 | filename_bat=filename_cmx; |
---|
| 2677 | end |
---|
| 2678 | filename_bat(end-2:end)='bat'; |
---|
| 2679 | fid=fopen(filename_bat,'w'); |
---|
| 2680 | fprintf(fid,cmd) |
---|
| 2681 | fclose(fid) |
---|
| 2682 | %dlmwrite(filename_bat,cmd,'');%write commands in filename_bat |
---|
| 2683 | if sge |
---|
| 2684 | pvalue=num2str((1-ind_answer)*500); |
---|
| 2685 | namelog=[filename_bat '.patch.log']; |
---|
| 2686 | ['!qsub -p ' pvalue ' -q civ.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat]; |
---|
| 2687 | eval( ['!qsub -p ' pvalue ' -q civ.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat]); |
---|
| 2688 | else |
---|
| 2689 | if(isunix) |
---|
| 2690 | cmdtodo=['. ' filename_bat ];%removed for Mathieu tests %' && rm -f ' filename_bat] ; |
---|
[2] | 2691 | else |
---|
[12] | 2692 | cmdtodo=[filename_bat];%removed for Mathieu tests %' && del /F /Q ' filename_bat' ; |
---|
[2] | 2693 | end |
---|
[12] | 2694 | count= fprintf(p1,'%s\n', cmdtodo); |
---|
| 2695 | end |
---|
[2] | 2696 | end |
---|
| 2697 | end |
---|
| 2698 | if ~sge |
---|
| 2699 | fclose(p1); |
---|
| 2700 | fclose(p0); |
---|
| 2701 | delete(name_lock); |
---|
| 2702 | end |
---|
| 2703 | |
---|
| 2704 | set(handles.BATCH, 'Enable','On') |
---|
| 2705 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 2706 | |
---|
| 2707 | %save interface state |
---|
| 2708 | if isfield(filecell,'nc') |
---|
| 2709 | if isfield(filecell.nc,'civ2') |
---|
| 2710 | fileresu=filecell.nc.civ2{1,1}; |
---|
| 2711 | else |
---|
| 2712 | fileresu=filecell.nc.civ1{1,1}; |
---|
| 2713 | end |
---|
| 2714 | end |
---|
| 2715 | [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileresu); |
---|
| 2716 | namedoc=fullfile(RootPath,subdir,RootFile); |
---|
| 2717 | detect=1; |
---|
| 2718 | while detect==1 |
---|
| 2719 | namefigfull=[namedoc '.fig']; |
---|
| 2720 | hh=dir(namefigfull); |
---|
| 2721 | if ~isempty(hh) |
---|
| 2722 | detect=1; |
---|
| 2723 | namedoc=[namedoc '.0']; |
---|
| 2724 | else |
---|
| 2725 | detect=0; |
---|
| 2726 | end |
---|
| 2727 | end |
---|
| 2728 | saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) |
---|
| 2729 | |
---|
[12] | 2730 | %------------------------------------------------------------------------ |
---|
[2] | 2731 | %OUTPUT: |
---|
| 2732 | % filecell: structure of input and output files |
---|
| 2733 | % .ima1.civ1{i,j}, .ima1.civ2{i,j}; set of first image names for correlations, for civ1 and civ2 |
---|
| 2734 | % .ima2.civ1{i,j}, .ima2.civ2{i,j} ; set of second image names for correlations |
---|
| 2735 | % .imaA1.civ1{i,j}, .ima1.civ2{i,j}; set of first image names for correlations, for civ1 and civ2, with camA in stereo case (then .ima1 corresponds to camB) |
---|
| 2736 | % .imaA2.civ1{i,j}, .ima2.civ2{i,j} ; set of second image names for correlations, with camA in stereo case (then .ima1 corresponds to camB) |
---|
| 2737 | % .nc.civ1{i,j}, .nc.civ2{i,j}; set of nc files for PIV results |
---|
| 2738 | % .ncA.civ1{i,j}, .ncA.civ2{i,j}; set of nc files for PIV results with camA (then .nc corresponds to camB) |
---|
| 2739 | % .st{i,j}; set of nc files for the combined stereo fields |
---|
| 2740 | 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]=... |
---|
| 2741 | set_civ_filenames(handles,compare,box_test) |
---|
[12] | 2742 | %------------------------------------------------------------------------ |
---|
[2] | 2743 | %get the filename root, nomenclature and numbers |
---|
| 2744 | filebase=get(handles.displ_filebase,'String'); |
---|
| 2745 | browse=get(handles.browse_root,'UserData'); |
---|
| 2746 | compare_list=get(handles.compare,'String'); |
---|
| 2747 | val=get(handles.compare,'Value'); |
---|
| 2748 | compare=compare_list{val}; |
---|
| 2749 | if strcmp(compare,'displacement') |
---|
| 2750 | mode='displacement'; |
---|
| 2751 | else |
---|
| 2752 | mode_list=get(handles.mode,'String'); |
---|
| 2753 | mode_value=get(handles.mode,'Value'); |
---|
| 2754 | mode=mode_list{mode_value}; |
---|
| 2755 | end |
---|
| 2756 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 2757 | ext_ima=get(handles.ext_ima,'String'); |
---|
| 2758 | nom_type_nc=browse.nom_type_nc; |
---|
| 2759 | nom_type_ima2=browse.nom_type_ima; |
---|
| 2760 | if isequal(nom_type_ima2,[]),nom_type_ima2='ima_num';end; %default |
---|
| 2761 | if isequal(nom_type_nc,[]),nom_type_nc='_i1-i2';end; %default |
---|
| 2762 | [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
| 2763 | find_pair_indices(handles,mode); |
---|
| 2764 | |
---|
| 2765 | %determine the new filebase for 'displacement' mode (comparison of two series) |
---|
| 2766 | filebase_B=filebase;% root name of the second field series for stereo |
---|
| 2767 | if strcmp(compare,'displacement') || strcmp(compare,'stereo PIV') |
---|
| 2768 | test_disp=1; |
---|
| 2769 | nom_type_ima1=browse.nom_type_ima_1; %nomenclature type of the second file series |
---|
| 2770 | [Path2,Name2]=fileparts(filebase_B); |
---|
| 2771 | Path1=Path2; |
---|
| 2772 | Name1=get(handles.displ_filebase2,'String');% root name of the first field series for stereo |
---|
| 2773 | filebase_A=fullfile(Path1,Name1); |
---|
| 2774 | if length(Name1)>6 |
---|
| 2775 | Name1=Name1(end-5:end); |
---|
| 2776 | end |
---|
| 2777 | if length(Name2)>6 |
---|
| 2778 | Name2=Name2(end-5:end); |
---|
| 2779 | end |
---|
| 2780 | filebase_AB=fullfile(Path2,[Name2 '-' Name1]); |
---|
| 2781 | else |
---|
| 2782 | test_disp=0; |
---|
| 2783 | filebase_A=filebase; |
---|
| 2784 | nom_type_ima1=nom_type_ima2; |
---|
| 2785 | filebase_AB=filebase; |
---|
| 2786 | end |
---|
| 2787 | if strcmp(compare,'displacement') |
---|
| 2788 | filebase_ima1=filebase_A; |
---|
| 2789 | filebase_ima2=filebase_B; |
---|
| 2790 | filebase_nc=filebase_AB; %root name for the result of civ2 |
---|
| 2791 | else |
---|
| 2792 | filebase_ima1=filebase_B; |
---|
| 2793 | filebase_ima2=filebase_B; |
---|
| 2794 | filebase_nc=filebase_B; |
---|
| 2795 | end |
---|
| 2796 | |
---|
| 2797 | %determine reference files for fix: |
---|
| 2798 | file_ref_fix1={};%default |
---|
| 2799 | file_ref_fix2={}; |
---|
| 2800 | nbfield=length(num1_civ1); |
---|
| 2801 | nbslice=length(num_a_civ1); |
---|
| 2802 | if box_test(2)==1% fix1 performed |
---|
| 2803 | ref=get(handles.ref_fix1,'UserData');%read data on the ref file stored by get_ref_fix1_Callback |
---|
| 2804 | if ~isempty(ref) |
---|
| 2805 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 2806 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 2807 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
| 2808 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 2809 | last_j=str2num(get(handles.last_j,'String')); |
---|
| 2810 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
| 2811 | num_i_ref=[first_i:incr_i:last_i]; |
---|
| 2812 | num_j_ref=[first_j:incr_j:last_j]; |
---|
| 2813 | if isequal(mode,'displacement') |
---|
| 2814 | num_i1=num_i_ref; |
---|
| 2815 | num_i2=num_i_ref; |
---|
| 2816 | num_j1=num_j_ref; |
---|
| 2817 | num_j2=num_j_ref; |
---|
| 2818 | elseif isequal(mode,'pair j1-j2')% isequal(mode,'st_pair j1-j2') |
---|
| 2819 | num_i1=num_i_ref; |
---|
| 2820 | num_i2=num_i1; |
---|
| 2821 | num_j1=ref.num_a*ones(size(num_i_ref)); |
---|
| 2822 | num_j2=ref.num_b*ones(size(num_i_ref)); |
---|
| 2823 | elseif isequal(mode,'series(Di)') % isequal(mode,'st_series(Di)') |
---|
| 2824 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 2825 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 2826 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 2827 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 2828 | if isempty(ref.num_a) |
---|
| 2829 | ref.num_a=1; |
---|
| 2830 | end |
---|
| 2831 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 2832 | num_j2=num_j1; |
---|
| 2833 | elseif isequal(mode,'series(Dj)')%| isequal(mode,'st_series(Dj)') |
---|
| 2834 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 2835 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 2836 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 2837 | num_i2=num_i1; |
---|
| 2838 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 2839 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 2840 | end |
---|
| 2841 | for ifile=1:nbfield |
---|
| 2842 | for j=1:nbslice |
---|
| 2843 | 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);% |
---|
| 2844 | file_ref_fix1(ifile,j)={file_ref}; |
---|
| 2845 | if ~exist(file_ref,'file') |
---|
| 2846 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix1']) |
---|
[12] | 2847 | filecell=[]; |
---|
[2] | 2848 | return |
---|
| 2849 | end |
---|
| 2850 | end |
---|
| 2851 | end |
---|
| 2852 | end |
---|
| 2853 | end |
---|
| 2854 | |
---|
| 2855 | %determine reference files for fix2: |
---|
| 2856 | if box_test(5)==1% fix2 performed |
---|
| 2857 | ref=get(handles.ref_fix2,'UserData'); |
---|
| 2858 | if ~isempty(ref) |
---|
| 2859 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 2860 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 2861 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
| 2862 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 2863 | last_j=str2num(get(handles.last_j,'String')); |
---|
| 2864 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
| 2865 | num_i_ref=[first_i:incr_i:last_i]; |
---|
| 2866 | num_j_ref=[first_j:incr_j:last_j]; |
---|
| 2867 | if isequal(mode,'displacement') |
---|
| 2868 | num_i1=num_i_ref; |
---|
| 2869 | num_i2=num_i_ref; |
---|
| 2870 | num_j1=num_j_ref; |
---|
| 2871 | num_j2=num_j_ref; |
---|
| 2872 | elseif isequal(mode,'pair j1-j2') |
---|
| 2873 | num_i1=num_i_ref; |
---|
| 2874 | num_i2=num_i1; |
---|
| 2875 | num_j1=ref.num_a; |
---|
| 2876 | num_j2=ref.num_b; |
---|
| 2877 | elseif isequal(mode,'series(Di)') |
---|
| 2878 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 2879 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 2880 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 2881 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 2882 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 2883 | num_j2=num_j1; |
---|
| 2884 | elseif isequal(mode,'series(Dj)') |
---|
| 2885 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 2886 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 2887 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 2888 | num_i2=num_i1; |
---|
| 2889 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 2890 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 2891 | end |
---|
| 2892 | for ifile=1:nbfield |
---|
| 2893 | for j=1:nbslice |
---|
| 2894 | 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);% |
---|
| 2895 | file_ref_fix2(ifile,j)={file_ref}; |
---|
| 2896 | if ~exist(file_ref,'file') |
---|
| 2897 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix2']) |
---|
[12] | 2898 | filecell=[]; |
---|
[2] | 2899 | return |
---|
| 2900 | end |
---|
| 2901 | end |
---|
| 2902 | end |
---|
| 2903 | end |
---|
| 2904 | end |
---|
| 2905 | |
---|
| 2906 | %check dir |
---|
| 2907 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf output data |
---|
| 2908 | subdir_civ2=get(handles.subdir_civ2,'String'); |
---|
| 2909 | if isequal(subdir_civ1,''),subdir_civ1='A'; end% put default subdir |
---|
| 2910 | if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end% put default subdir |
---|
| 2911 | currentdir=pwd;%store the current working directory |
---|
| 2912 | [Path_ima,Name]=fileparts(filebase);%Path of the image files (.civ) |
---|
| 2913 | if ~exist(Path_ima,'dir') |
---|
[12] | 2914 | msgbox_uvmat('ERROR',['path to images ' Path_ima ' not found']) |
---|
| 2915 | filecell=[]; |
---|
[2] | 2916 | return |
---|
| 2917 | end |
---|
| 2918 | cd(Path_ima);%move to the directory of the images: needed to create the result dir by 'mkdir' |
---|
| 2919 | dircur=pwd; %current working directory |
---|
| 2920 | m2=''; |
---|
| 2921 | [erread,message]=fileattrib(Path_ima); |
---|
| 2922 | if ~isempty(message) & ~isequal(message.UserWrite,1) |
---|
| 2923 | msgbox_uvmat('ERROR',['No writting access to ' Path_ima]) |
---|
[12] | 2924 | filecell=[]; |
---|
[2] | 2925 | cd(currentdir); |
---|
| 2926 | return |
---|
| 2927 | end |
---|
| 2928 | |
---|
| 2929 | %check the existence of the netcdf and image files involved |
---|
| 2930 | % %%%%%%%%%%%% case CIV1 activated %%%%%%%%%%%%% |
---|
| 2931 | if box_test(1)==1; |
---|
| 2932 | detect=1; |
---|
| 2933 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
| 2934 | for ifile=1:nbfield; |
---|
| 2935 | for j=1:nbslice |
---|
| 2936 | 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); |
---|
| 2937 | detect=exist(filename,'file')==2; |
---|
| 2938 | if detect% if a netcdf file already exists |
---|
| 2939 | subdir_civ1=[subdir_civ1 '.0']; |
---|
| 2940 | subdir_civ2=subdir_civ1; |
---|
| 2941 | break |
---|
| 2942 | end |
---|
| 2943 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 2944 | end |
---|
| 2945 | if detect% if a netcdf file already exists |
---|
| 2946 | break |
---|
| 2947 | end |
---|
| 2948 | end |
---|
| 2949 | %create the new subdir_civ1 |
---|
| 2950 | if ~exist(fullfile(Path_ima,subdir_civ1),'dir') |
---|
| 2951 | [m1,m2,m3]=mkdir(subdir_civ1); |
---|
| 2952 | if ~isequal(m2,'') |
---|
| 2953 | msgbox_uvmat('ERROR', m2) |
---|
| 2954 | %msgbox(m2);%error message for directory creation |
---|
| 2955 | end |
---|
| 2956 | end |
---|
| 2957 | if strcmp(compare,'stereo PIV')&&(strcmp(mode,'pair j1-j2')||strcmp(mode,'series(Dj)')||strcmp(mode,'series(Di)'))%check second nc series |
---|
| 2958 | for ifile=1:nbfield |
---|
| 2959 | for j=1:nbslice |
---|
| 2960 | 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);% |
---|
| 2961 | detect=exist(filename,'file')==2; |
---|
| 2962 | if detect% if a netcdf file already exists |
---|
| 2963 | subdir_civ1=[subdir_civ1 '.0']; |
---|
| 2964 | subdir_civ2=subdir_civ1; |
---|
| 2965 | break |
---|
| 2966 | end |
---|
| 2967 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
| 2968 | end |
---|
| 2969 | if detect% if a netcdf file already exists |
---|
| 2970 | break |
---|
| 2971 | end |
---|
| 2972 | end |
---|
| 2973 | %create the new subdir_civ1 |
---|
| 2974 | if ~exist(fullfile(Path_ima,subdir_civ1),'dir') |
---|
| 2975 | [m1,m2,m3]=mkdir(subdir_civ1); |
---|
| 2976 | if ~isequal(m2,'') |
---|
| 2977 | msgbox_uvmat('ERROR', m2) |
---|
| 2978 | end |
---|
| 2979 | end |
---|
| 2980 | end |
---|
| 2981 | end |
---|
| 2982 | % get image names |
---|
| 2983 | for ifile=1:nbfield |
---|
| 2984 | for j=1:nbslice |
---|
| 2985 | filename=name_generator(filebase_ima1, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
| 2986 | idetect(j)=exist(filename,'file')==2; |
---|
| 2987 | filecell.ima1.civ1(ifile,j)={filename}; %first image |
---|
| 2988 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
| 2989 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 2990 | filecell.ima2.civ1(ifile,j)={filename};%second image |
---|
| 2991 | end |
---|
| 2992 | [idetectmin,indexj]=min(idetect); |
---|
| 2993 | if idetectmin==0, |
---|
| 2994 | msgbox_uvmat('ERROR',[filecell.ima1.civ1{ifile,indexj} ' not found']) |
---|
[12] | 2995 | filecell=[]; |
---|
[2] | 2996 | return |
---|
| 2997 | end |
---|
| 2998 | [idetectmin,indexj]=min(idetect_1); |
---|
| 2999 | if idetectmin==0, |
---|
| 3000 | msgbox_uvmat('ERROR',[filecell.ima2.civ1{ifile,indexj} ' not found']) |
---|
[12] | 3001 | filecell=[]; |
---|
[2] | 3002 | cd(currentdir) |
---|
| 3003 | return |
---|
| 3004 | end |
---|
| 3005 | end |
---|
| 3006 | if strcmp(compare,'stereo PIV') && (strcmp(mode,'pair j1-j2') || strcmp(mode,'series(Dj)') || strcmp(mode,'series(Di)')) |
---|
| 3007 | for ifile=1:nbfield |
---|
| 3008 | for j=1:nbslice |
---|
| 3009 | filename=name_generator(filebase_A, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
| 3010 | idetect(j)=exist(filename,'file')==2; |
---|
| 3011 | filecell.imaA1.civ1(ifile,j)={filename} ;%first image |
---|
| 3012 | filename=name_generator(filebase_A, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
| 3013 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 3014 | filecell.imaA2.civ1(ifile,j)={filename};%second image |
---|
| 3015 | end |
---|
| 3016 | [idetectmin,indexj]=min(idetect); |
---|
| 3017 | if idetectmin==0, |
---|
| 3018 | msgbox_uvmat('ERROR',[filecell.imaA1.civ1{ifile,indexj} ' not found']) |
---|
[12] | 3019 | filecell=[]; |
---|
| 3020 | cd(currentdir) |
---|
| 3021 | return |
---|
[2] | 3022 | end |
---|
| 3023 | [idetectmin,indexj]=min(idetect_1); |
---|
| 3024 | if idetectmin==0, |
---|
[12] | 3025 | msgbox_uvmat('ERROR',[filecell.imaA2.civ1{ifile,indexj} ' not found']) |
---|
| 3026 | filecell=[]; |
---|
| 3027 | cd(currentdir) |
---|
| 3028 | return |
---|
[2] | 3029 | end |
---|
| 3030 | end |
---|
| 3031 | end |
---|
| 3032 | |
---|
| 3033 | %%%%%%%%%%%%% fix1 or patch1 activated but no civ1 %%%%%%%%%%%%% |
---|
| 3034 | elseif (box_test(2)==1 || box_test(3)==1); |
---|
| 3035 | for ifile=1:nbfield |
---|
| 3036 | for j=1:nbslice |
---|
| 3037 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 3038 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 3039 | detect=exist(filename,'file')==2; |
---|
| 3040 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 3041 | end |
---|
| 3042 | end |
---|
| 3043 | if strcmp(compare,'stereo PIV') |
---|
| 3044 | for ifile=1:nbfield |
---|
| 3045 | for j=1:nbslice |
---|
| 3046 | 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);% |
---|
| 3047 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
| 3048 | if ~exist(filename,'file') |
---|
| 3049 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
| 3050 | set(handles.RUN, 'Enable','On') |
---|
| 3051 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 3052 | set(handles.BATCH, 'Enable','On') |
---|
| 3053 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
[12] | 3054 | filecell=[]; |
---|
[2] | 3055 | cd(currentdir) |
---|
| 3056 | return |
---|
| 3057 | end |
---|
| 3058 | end |
---|
| 3059 | end |
---|
| 3060 | end |
---|
| 3061 | end |
---|
| 3062 | |
---|
| 3063 | %%%%%%%%%%%%% if civ2 performed with pairs different than civ1 %%%%%%%%%%%%% |
---|
| 3064 | testdiff=0; |
---|
| 3065 | if (box_test(4)==1)&&... |
---|
| 3066 | ((get(handles.list_pair_civ1,'Value')~=get(handles.list_pair_civ2,'Value'))||~isequal(subdir_civ2,subdir_civ1)) |
---|
| 3067 | testdiff=1; |
---|
| 3068 | detect=1; |
---|
| 3069 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
| 3070 | for ifile=1:nbfield |
---|
| 3071 | for j=1:nbslice |
---|
| 3072 | 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);% |
---|
| 3073 | detect=exist(filename,'file')==2; |
---|
| 3074 | if detect% if a netcdf file already exists |
---|
| 3075 | subdir_civ2=[subdir_civ2 '.0']; |
---|
| 3076 | break |
---|
| 3077 | end |
---|
| 3078 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 3079 | end |
---|
| 3080 | if detect% if a netcdf file already exists |
---|
| 3081 | break |
---|
| 3082 | end |
---|
| 3083 | end |
---|
| 3084 | %create the new subdir_civ2 |
---|
| 3085 | if ~exist(fullfile(Path_ima,subdir_civ2),'dir') |
---|
| 3086 | [m1,m2,m3]=mkdir(subdir_civ2); |
---|
| 3087 | if ~isequal(m2,'') |
---|
| 3088 | msgbox_uvmat('ERROR', m2) |
---|
| 3089 | end |
---|
| 3090 | end |
---|
| 3091 | if strcmp(compare,'stereo PIV')%check second nc series |
---|
| 3092 | for ifile=1:nbfield |
---|
| 3093 | for j=1:nbslice |
---|
| 3094 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 3095 | nom_type_nc,1,num2_civ2(ifile),num_b_civ1(j),subdir_civ2);% |
---|
| 3096 | detect=exist(filename,'file')==2; |
---|
| 3097 | if detect% if a netcdf file already exists |
---|
| 3098 | subdir_civ2=[subdir_civ2 '.0']; |
---|
| 3099 | break |
---|
| 3100 | end |
---|
| 3101 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 3102 | end |
---|
| 3103 | if detect% if a netcdf file already exists |
---|
| 3104 | break |
---|
| 3105 | end |
---|
| 3106 | end |
---|
| 3107 | %create the new subdir_civ1 |
---|
| 3108 | if ~exist(fullfile(Path_ima,subdir_civ2),'dir') |
---|
| 3109 | [m1,m2,m3]=mkdir(subdir_civ2); |
---|
| 3110 | if ~isequal(m2,'') |
---|
| 3111 | msgbox_uvmat('ERROR', m2) |
---|
| 3112 | %msgbox(m2);%error message for directory creation |
---|
| 3113 | end |
---|
| 3114 | end |
---|
| 3115 | end |
---|
| 3116 | end |
---|
| 3117 | end |
---|
| 3118 | cd(currentdir);%come back to the current working directory |
---|
| 3119 | |
---|
| 3120 | |
---|
| 3121 | %%%%%%%%%%%%% if civ2 results are obtained or used %%%%%%%%%%%%% |
---|
| 3122 | if box_test(4)==1 || box_test(5)==1 || box_test(6)==1 %civ2 |
---|
| 3123 | %check source netcdf file of civ1 estimates |
---|
| 3124 | if box_test(1)==0; %no civ1 performed |
---|
| 3125 | for ifile=1:nbfield |
---|
| 3126 | for j=1:nbslice |
---|
| 3127 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 3128 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 3129 | filecell.nc.civ1(ifile,j)={filename};% name of the civ1 file |
---|
| 3130 | if ~exist(filename,'file') |
---|
| 3131 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
[12] | 3132 | filecell=[]; |
---|
[2] | 3133 | return |
---|
| 3134 | end |
---|
| 3135 | if ~testdiff % civ2 or patch2 are written in the same file as civ1 |
---|
| 3136 | if box_test(4)==0 ; %check the existence of civ2 if it is not calculated |
---|
| 3137 | Data=nc2struct(filename,'ListGlobalAttribute','civ2'); |
---|
| 3138 | if isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
| 3139 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
[12] | 3140 | filecell=[]; |
---|
[2] | 3141 | return |
---|
| 3142 | end |
---|
| 3143 | elseif box_test(3)==0; %check the existence of patch if it is not calculated |
---|
| 3144 | Data=nc2struct(filename,'ListGlobalAttribute','patch'); |
---|
| 3145 | if isempty(Data.patch)||isequal(Data.patch,0) |
---|
| 3146 | msgbox_uvmat('ERROR',['no patch data in ' filename]) |
---|
[12] | 3147 | filecell=[]; |
---|
[2] | 3148 | return |
---|
| 3149 | end |
---|
| 3150 | end |
---|
| 3151 | end |
---|
| 3152 | end |
---|
| 3153 | end |
---|
| 3154 | if strcmp(compare,'stereo PIV') |
---|
| 3155 | for ifile=1:nbfield |
---|
| 3156 | for j=1:nbslice |
---|
| 3157 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 3158 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 3159 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 3160 | if ~exist(filename,'file') |
---|
| 3161 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
| 3162 | set(handles.RUN, 'Enable','On') |
---|
| 3163 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 3164 | set(handles.BATCH, 'Enable','On') |
---|
| 3165 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 3166 | cd(currentdir) |
---|
| 3167 | return |
---|
| 3168 | end |
---|
| 3169 | end |
---|
| 3170 | end |
---|
| 3171 | end |
---|
| 3172 | end |
---|
| 3173 | |
---|
| 3174 | detect=1; |
---|
| 3175 | % while detect==1%creates a new subdir if the netcdf files already contain civ2 data |
---|
| 3176 | for ifile=1:nbfield |
---|
| 3177 | for j=1:nbslice |
---|
| 3178 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 3179 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2); |
---|
| 3180 | detect=exist(filename,'file')==2; |
---|
| 3181 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 3182 | end |
---|
| 3183 | end |
---|
| 3184 | %get first image names for civ2 |
---|
| 3185 | if box_test(1)==1 & isequal(num1_civ1,num1_civ2) & isequal(num_a_civ1,num_a_civ2) |
---|
| 3186 | filecell.ima1.civ2=filecell.ima1.civ1; |
---|
| 3187 | elseif box_test(4)==1 |
---|
| 3188 | for ifile=1:nbfield |
---|
| 3189 | for j=1:nbslice |
---|
| 3190 | filename=name_generator(filebase_ima1, num1_civ2(ifile),num_a_civ2(j),ext_ima,nom_type_ima1); |
---|
| 3191 | idetect_2(j)=exist(filename,'file')==2; |
---|
| 3192 | filecell.ima1.civ2(ifile,j)={filename};%first image |
---|
| 3193 | end |
---|
| 3194 | [idetectmin,indexj]=min(idetect_2); |
---|
| 3195 | if idetectmin==0, |
---|
| 3196 | msgbox_uvmat('ERROR',['input image ' filecell.ima1.civ2{ifile,indexj} ' not found']) |
---|
[12] | 3197 | filecell=[]; |
---|
[2] | 3198 | return |
---|
| 3199 | end |
---|
| 3200 | end |
---|
| 3201 | end |
---|
| 3202 | |
---|
| 3203 | %get second image names for civ2 |
---|
| 3204 | if box_test(1)==1 & isequal(num2_civ1,num2_civ2) & isequal(num_b_civ1,num_b_civ2) |
---|
| 3205 | filecell.ima2.civ2=filecell.ima2.civ1; |
---|
| 3206 | elseif box_test(4)==1 |
---|
| 3207 | for ifile=1:nbfield |
---|
| 3208 | for j=1:nbslice |
---|
| 3209 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),ext_ima,nom_type_ima2); |
---|
| 3210 | idetect_3(j)=exist(filename,'file')==2; |
---|
| 3211 | filecell.ima2.civ2(ifile,j)={filename};%first image |
---|
| 3212 | end |
---|
| 3213 | [idetectmin,indexj]=min(idetect_3); |
---|
| 3214 | if idetectmin==0, |
---|
| 3215 | msgbox_uvmat('ERROR',['input image ' filecell.ima2.civ2{ifile,indexj} ' not found']) |
---|
[12] | 3216 | filecell=[]; |
---|
[2] | 3217 | return |
---|
| 3218 | end |
---|
| 3219 | end |
---|
| 3220 | end |
---|
| 3221 | end |
---|
| 3222 | if (box_test(5)==1 || box_test(6)==1 ) && box_test(4)==0 % need to read an existing netcdf civ2 file |
---|
| 3223 | if ~testdiff |
---|
| 3224 | filecell.nc.civ2=filecell.nc.civ1;% file already checked |
---|
| 3225 | else % check the civ2 files |
---|
| 3226 | for ifile=1:nbfield |
---|
| 3227 | for j=1:nbslice |
---|
| 3228 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 3229 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 3230 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 3231 | if ~exist(filename,'file') |
---|
| 3232 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
[12] | 3233 | filecell=[]; |
---|
[2] | 3234 | return |
---|
| 3235 | else |
---|
| 3236 | Data=nc2struct(filename,'ListGlobalAttribute','civ2'); |
---|
| 3237 | if isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
| 3238 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
[12] | 3239 | filecell=[]; |
---|
[2] | 3240 | return |
---|
| 3241 | end |
---|
| 3242 | end |
---|
| 3243 | end |
---|
| 3244 | end |
---|
| 3245 | end |
---|
| 3246 | end |
---|
| 3247 | |
---|
| 3248 | %%%%%%%%%%%%% if stereo fields are calculated by PATCH %%%%%%%%%%%%% |
---|
| 3249 | if strcmp(compare,'stereo PIV') |
---|
| 3250 | if box_test(3)==1 & isequal(get(handles.test_stereo1,'Value'),1) |
---|
| 3251 | for ifile=1:nbfield |
---|
| 3252 | for j=1:nbslice |
---|
| 3253 | filename=name_generator(filebase_AB,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 3254 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 3255 | filecell.st(ifile,j)={filename}; |
---|
| 3256 | end |
---|
| 3257 | end |
---|
| 3258 | end |
---|
| 3259 | if box_test(6)==1 & isequal(get(handles.test_stereo2,'Value'),1) |
---|
| 3260 | for ifile=1:nbfield |
---|
| 3261 | for j=1:nbslice |
---|
| 3262 | filename=name_generator(filebase_AB,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 3263 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 3264 | filecell.st(ifile,j)={filename}; |
---|
| 3265 | end |
---|
| 3266 | end |
---|
| 3267 | end |
---|
| 3268 | end |
---|
| 3269 | set(handles.subdir_civ1,'String',subdir_civ1);%update the edit box |
---|
| 3270 | set(handles.subdir_civ2,'String',subdir_civ2);%update the edit box |
---|
| 3271 | browse.nom_type_nc=nom_type_nc; |
---|
| 3272 | set(handles.browse_root,'UserData',browse); %update the nomenclature type for uvmat |
---|
| 3273 | |
---|
| 3274 | |
---|
| 3275 | %COPY IMAGES TO THE FORMAT .png IF NEEDED |
---|
| 3276 | if isequal(nom_type_ima1,'*') |
---|
| 3277 | nom_type_imanew='_i'; |
---|
| 3278 | else |
---|
| 3279 | nom_type_imanew1=nom_type_ima1; |
---|
| 3280 | end |
---|
| 3281 | if isequal(nom_type_ima2,'*') |
---|
| 3282 | nom_type_imanew='_i'; |
---|
| 3283 | else |
---|
| 3284 | nom_type_imanew2=nom_type_ima2; |
---|
| 3285 | end |
---|
| 3286 | if ~isequal(ext_ima,'.png') |
---|
| 3287 | %npxy=get(handles.ext_ima,'UserData'); |
---|
| 3288 | % % if numel(npxy)<2 |
---|
| 3289 | % |
---|
| 3290 | % filename=name_generator(filebase_ima1,num1_civ1(1),num_a_civ1(1),ext_ima,nom_type_ima1); |
---|
| 3291 | % A=imread(filename); |
---|
| 3292 | % npxy=size(A); |
---|
| 3293 | % % end |
---|
| 3294 | % npy=npxy(1); |
---|
| 3295 | % npx=npxy(2); |
---|
| 3296 | if box_test(1)==1 %if civ1 is performed |
---|
| 3297 | h = waitbar(0,['copy images to the .png format for civ1']);% display a wait bar |
---|
| 3298 | for ifile=1:nbfield |
---|
| 3299 | waitbar(ifile/nbfield); |
---|
| 3300 | for j=1:nbslice |
---|
| 3301 | filename=name_generator(filebase_ima1,num1_civ1(ifile),num_a_civ1(j),'.png',nom_type_imanew1); |
---|
| 3302 | if ~exist(filename,'file') |
---|
| 3303 | A=read_image(filecell.ima1.civ1{ifile,j},nom_type_ima2,num1_civ1(ifile)); |
---|
| 3304 | imwrite(A,filename,'BitDepth',16); |
---|
| 3305 | end |
---|
| 3306 | filecell.ima1.civ1(ifile,j)={filename}; |
---|
| 3307 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),'.png',nom_type_imanew2); |
---|
| 3308 | if ~exist(filename,'file') |
---|
| 3309 | A=read_image(filecell.ima2.civ1{ifile,j},nom_type_ima2,num2_civ1(ifile)); |
---|
| 3310 | imwrite(A,filename,'BitDepth',16); |
---|
| 3311 | end |
---|
| 3312 | filecell.ima2.civ1(ifile,j)={filename}; |
---|
| 3313 | end |
---|
| 3314 | end |
---|
| 3315 | close(h) |
---|
| 3316 | end |
---|
| 3317 | if box_test(4)==1 %if civ2 is performed |
---|
| 3318 | h = waitbar(0,['copy images to the .png format for civ2']);% display a wait bar |
---|
| 3319 | for ifile=1:nbfield |
---|
| 3320 | waitbar(ifile/nbfield); |
---|
| 3321 | for j=1:nbslice |
---|
| 3322 | filename=name_generator(filebase_ima1,num1_civ2(ifile),num_a_civ2(j),'.png',nom_type_imanew1); |
---|
| 3323 | if ~exist(filename,'file') |
---|
| 3324 | A=read_image(cell2mat(filecell.ima1.civ2(ifile,j)),nom_type_ima2,num1_civ2(ifile)); |
---|
| 3325 | imwrite(A,filename,'BitDepth',16); |
---|
| 3326 | end |
---|
| 3327 | filecell.ima1.civ2(ifile,j)={filename}; |
---|
| 3328 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),'.png',nom_type_imanew2); |
---|
| 3329 | if ~exist(filename,'file') |
---|
| 3330 | A=read_image(cell2mat(filecell.ima2.civ2(ifile,j)),nom_type_ima2,num2.civ1(ifile)); |
---|
| 3331 | imwrite(A,filename,'BitDepth',16); |
---|
| 3332 | end |
---|
| 3333 | filecell.ima2.civ2(ifile,j)={filename}; |
---|
| 3334 | end |
---|
| 3335 | end |
---|
| 3336 | close(h); |
---|
| 3337 | end |
---|
| 3338 | end |
---|
| 3339 | |
---|
[12] | 3340 | %------------------------------------------------------------------------ |
---|
[2] | 3341 | %CIV1 CIV1 CIV1 CIV1 |
---|
| 3342 | function RUN_CIV1(handles,filecell,filecell_1,filecell_nc1,num1,num2,num_a,num_b,nom_type_nc) |
---|
[12] | 3343 | %------------------------------------------------------------------------ |
---|
[2] | 3344 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 3345 | global civ1_exe sge%name of the executable for civ1 calculation |
---|
| 3346 | |
---|
| 3347 | %get civ parameters |
---|
| 3348 | ibx_val=str2num(get(handles.ibx,'String')); |
---|
| 3349 | if isempty(ibx_val) |
---|
| 3350 | ibx='21'; set(handles.ibx,'String','21') |
---|
| 3351 | else |
---|
| 3352 | ibx=num2str(ibx_val); |
---|
| 3353 | end |
---|
| 3354 | iby_val=str2num(get(handles.iby,'String')); |
---|
| 3355 | if isempty(iby_val) |
---|
| 3356 | iby='21'; set(handles.iby,'String','21') |
---|
| 3357 | else |
---|
| 3358 | iby=num2str(iby_val); |
---|
| 3359 | end |
---|
| 3360 | isx=get(handles.isx,'String'); |
---|
| 3361 | if isempty(str2num(isx)), isx='41'; set(handles.isx,'String','41'), end; %default |
---|
| 3362 | if str2num(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.isx,'String',num2str(ibx_val+8)); end |
---|
| 3363 | isy=get(handles.isy,'String'); |
---|
| 3364 | if isempty(str2num(isy)), isy='41'; set(handles.isy,'String','41'), end;%default |
---|
| 3365 | if str2num(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.isy,'String',num2str(iby_val+8)); end |
---|
| 3366 | shiftx=get(handles.shiftx,'String'); |
---|
| 3367 | if isempty(str2num(shiftx)), shiftx='0'; set(handles.shiftx,'String','0'), end;%default |
---|
| 3368 | shifty=get(handles.shifty,'String'); |
---|
| 3369 | if isempty(str2num(shifty)), shifty='0'; set(handles.shifty,'String','0'), end;%default |
---|
| 3370 | rho=get(handles.rho,'String'); |
---|
| 3371 | dx=get(handles.dx_civ1,'String'); |
---|
| 3372 | if isequal(str2num(dx),[]), dx='20'; set(handles.dx_civ1,'String','20'); end%default |
---|
| 3373 | dy=get(handles.dy_civ1,'String'); |
---|
| 3374 | if isequal(str2num(dy),[]), dy='20'; set(handles.dy_civ1,'String','20');end %default |
---|
| 3375 | if isequal(str2num(dy),[]), dy='20'; end%default |
---|
| 3376 | pxcmx='1'; %velocity fields are expressed in pixel displacement |
---|
| 3377 | pxcmy='1'; |
---|
| 3378 | image_first=cell2mat(filecell(1,1)); |
---|
| 3379 | if ~exist(image_first,'file') |
---|
| 3380 | msgbox_uvmat('ERROR',['image ' image_first 'not found']) |
---|
| 3381 | set(handles.RUN, 'Enable','On') |
---|
| 3382 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 3383 | return |
---|
| 3384 | end |
---|
| 3385 | A=imread(cell2mat(filecell(1,1)));%read the first image to get the size |
---|
| 3386 | sizim=size(A); |
---|
| 3387 | npx=num2str(sizim(2)); |
---|
| 3388 | npy=num2str(sizim(1)); |
---|
| 3389 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 3390 | gridname='';%default ='noFile use default' |
---|
| 3391 | gridflag='n';%default |
---|
| 3392 | test_grid=get(handles.browse_gridciv1,'Value'); |
---|
| 3393 | nbslice_grid=[]; |
---|
| 3394 | if test_grid |
---|
| 3395 | gridname=get(handles.grid_civ1,'String'); |
---|
| 3396 | if numel(gridname)>4 && isequal(gridname(end-3:end),'grid') |
---|
| 3397 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
| 3398 | if ~isempty(nbslice_grid) |
---|
| 3399 | gridflag='y'; |
---|
| 3400 | end |
---|
| 3401 | elseif exist(gridname,'file') |
---|
| 3402 | gridflag='y'; |
---|
| 3403 | else |
---|
| 3404 | msgbox_uvmat('ERROR',['input grid file ' gridname ' not found']) |
---|
| 3405 | return |
---|
| 3406 | end |
---|
| 3407 | end |
---|
| 3408 | if isequal(get(handles.ImaThreshold,'Value'),1) |
---|
| 3409 | threshflag='y'; |
---|
| 3410 | min_ima=get(handles.MinIma,'String'); |
---|
| 3411 | max_ima=get(handles.MaxIma,'String'); |
---|
| 3412 | else |
---|
| 3413 | threshflag='n'; |
---|
| 3414 | min_ima='0'; |
---|
| 3415 | max_ima='4096'; |
---|
| 3416 | end |
---|
| 3417 | %main loop |
---|
| 3418 | filebase=get(handles.displ_filebase,'String'); |
---|
| 3419 | sizcell=size(filecell); |
---|
| 3420 | nbfield=sizcell(1); |
---|
| 3421 | nbslice=sizcell(2); |
---|
| 3422 | icount=0; |
---|
| 3423 | for ifile=1:nbfield |
---|
| 3424 | for j=1:nbslice |
---|
| 3425 | icount=icount+1; |
---|
| 3426 | barlength=0.188*icount/(nbfield*nbslice); |
---|
| 3427 | set(handles.waitbar_1,'Position',[0.946 0.877-barlength 0.03 barlength]) |
---|
| 3428 | drawnow |
---|
| 3429 | filename_ima=cell2mat(filecell(ifile,j)); |
---|
| 3430 | filename_ima([end-3:end])=[];%remove .png extension |
---|
| 3431 | filename_ima_1=cell2mat(filecell_1(ifile,j)); |
---|
| 3432 | filename_ima_1([end-3:end])=[];%remove .png extension |
---|
| 3433 | filename_cmx=cell2mat(filecell_nc1(ifile,j));%output netcdf file |
---|
| 3434 | filename_cmx([end-1:end])=[ 'cm'];%name of cmx file |
---|
| 3435 | filename_cmx=[filename_cmx 'x']; |
---|
| 3436 | namelog=[filename_cmx([1:end-3]) 'log']; |
---|
| 3437 | if size(time,1)>=num2(ifile) & size(time,2)>=num_b(j) |
---|
| 3438 | Dt=num2str(time(num2(ifile),num_b(j))-time(num1(ifile),num_a(j))); |
---|
| 3439 | if isequal(Dt,'0') |
---|
| 3440 | Dt='1' ;%case of 'displacement' mode |
---|
| 3441 | end |
---|
| 3442 | T0=num2str((time(num2(ifile),num_b(j))+time(num1(ifile),num_a(j)))/2); |
---|
| 3443 | else |
---|
| 3444 | Dt='1'; |
---|
| 3445 | T0='0'; |
---|
| 3446 | end |
---|
| 3447 | term_a=num2stra(num_a(j),nom_type_nc);%UTILITE? |
---|
| 3448 | term_b=num2stra(num_b(j),nom_type_nc);% |
---|
| 3449 | if test_grid && ~isempty(nbslice_grid) |
---|
| 3450 | num1_grid=mod(num1(ifile)-1,nbslice_grid)+1 |
---|
| 3451 | gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 3452 | if ~exist(gridname,'file') |
---|
| 3453 | msgbox_uvmat('ERROR',['missing grid file ' gridname]) |
---|
| 3454 | return |
---|
| 3455 | end |
---|
| 3456 | end |
---|
| 3457 | test_mask=get(handles.get_mask_civ1,'Value'); |
---|
| 3458 | if test_mask==0 |
---|
| 3459 | maskname='noFile use default'; |
---|
| 3460 | maskflag='n'; |
---|
| 3461 | else |
---|
| 3462 | maskdispl=get(handles.mask_civ1,'String');%look for mask name in edit box |
---|
| 3463 | maskbase=[filebase '_' maskdispl];% |
---|
| 3464 | nbslice=str2num(maskdispl(1:end-4)); % |
---|
| 3465 | num1_mask=mod(num1(ifile)-1,nbslice)+1; |
---|
| 3466 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 3467 | if exist(maskname,'file') |
---|
| 3468 | maskflag='y'; |
---|
| 3469 | else |
---|
| 3470 | maskname='noFile use default'; |
---|
| 3471 | maskflag='n'; |
---|
| 3472 | end |
---|
| 3473 | end |
---|
| 3474 | textcmx={'############## CMX file';... |
---|
| 3475 | ['FirstImage ' filename_ima];... |
---|
| 3476 | ['LastImage ' filename_ima_1];... |
---|
| 3477 | 'XX' ;... |
---|
| 3478 | ['Mask ' maskflag] ;... |
---|
| 3479 | ['MaskName ' maskname];... |
---|
| 3480 | ['ImageSize ' npx ' ' npy];... %VERIFIER CAS GENERAL ? |
---|
| 3481 | ['CorrelationBoxesSize ' ibx ' ' iby];... |
---|
| 3482 | ['SearchBoxeSize ' isx ' ' isy];... |
---|
| 3483 | ['RO ' rho];... |
---|
| 3484 | ['GridSpacing ' dx ' ' dy];... |
---|
| 3485 | 'XX 1.0';... |
---|
| 3486 | ['Dt_TO ' Dt ' ' T0];... |
---|
| 3487 | ['PixCmXY ' pxcmx ' ' pxcmy];... |
---|
| 3488 | 'XX 1';... |
---|
| 3489 | ['ShiftXY ' shiftx ' ' shifty];... |
---|
| 3490 | ['Grid ' gridflag];... |
---|
| 3491 | ['GridName ' gridname] ;... |
---|
| 3492 | 'XX 85';... |
---|
| 3493 | 'XX 1.0';... |
---|
| 3494 | 'XX 1.0';... |
---|
| 3495 | 'Hart 1';... |
---|
| 3496 | 'DecimalShift 0';... |
---|
| 3497 | 'Deformation 0';... |
---|
| 3498 | 'CorrelationMin 0';... |
---|
| 3499 | 'IntensityMin 0';... |
---|
| 3500 | ['SeuilImage ' threshflag];... |
---|
| 3501 | ['SeuilImageValues ' min_ima ' ' max_ima];... |
---|
| 3502 | ['ImageToUse ' term_a ' ' term_b];... % VERIFIER ? |
---|
| 3503 | 'ImageUsedBefore null null'}; |
---|
| 3504 | textout=char(textcmx); |
---|
[12] | 3505 | % dlmwrite(filename_cmx,textout,''); |
---|
| 3506 | |
---|
[16] | 3507 | filename_ima |
---|
| 3508 | filename_ima_1 |
---|
[12] | 3509 | fid=fopen([filename_cmx],'w'); |
---|
| 3510 | fprintf(fid, ['############## CMX file' '\n']); |
---|
[16] | 3511 | fprintf(fid, ['FirstImage ' regexprep(filename_ima,'\\','\\\\') '\n' ]); |
---|
| 3512 | fprintf(fid, ['LastImage ' regexprep(filename_ima_1,'\\','\\\\') '\n' ]); |
---|
[12] | 3513 | fprintf(fid, ['XX' '\n' ]); |
---|
| 3514 | fprintf(fid, ['Mask ' maskflag '\n' ]); |
---|
| 3515 | fprintf(fid, ['MaskName ' maskname '\n' ]); |
---|
| 3516 | fprintf(fid, ['ImageSize ' npx ' ' npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 3517 | fprintf(fid, ['CorrelationBoxesSize ' ibx ' ' iby '\n' ]); |
---|
| 3518 | fprintf(fid, ['SearchBoxeSize ' isx ' ' isy '\n' ]); |
---|
| 3519 | fprintf(fid, ['RO ' rho '\n' ]); |
---|
| 3520 | fprintf(fid, ['GridSpacing ' dx ' ' dy '\n' ]); |
---|
| 3521 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 3522 | fprintf(fid, ['Dt_TO ' Dt ' ' T0 '\n' ]); |
---|
| 3523 | fprintf(fid, ['PixCmXY ' pxcmx ' ' pxcmy '\n' ]); |
---|
| 3524 | fprintf(fid, ['XX 1' '\n' ]); |
---|
| 3525 | fprintf(fid, ['ShiftXY ' shiftx ' ' shifty '\n' ]); |
---|
| 3526 | fprintf(fid, ['Grid ' gridflag '\n' ]); |
---|
| 3527 | fprintf(fid, ['GridName ' gridname '\n' ]); |
---|
| 3528 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 3529 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 3530 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 3531 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
| 3532 | fprintf(fid, [ 'DecimalShift 0' '\n' ]); |
---|
| 3533 | fprintf(fid, ['Deformation 0' '\n' ]); |
---|
| 3534 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 3535 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 3536 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 3537 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
| 3538 | fprintf(fid, ['ImageToUse ' term_a ' ' term_b '\n' ]); % VERIFIER ? |
---|
| 3539 | fprintf(fid, ['ImageUsedBefore null null' '\n' ]); |
---|
| 3540 | fclose(fid); |
---|
| 3541 | |
---|
[2] | 3542 | s=-1; |
---|
| 3543 | display(['!' civ1_exe ' -f ' filename_cmx ' > ' namelog]) |
---|
| 3544 | eval(['!' civ1_exe ' -f ' filename_cmx ' > ' namelog]); |
---|
| 3545 | % if sge%dispatch computation on the cluster using interactive queue |
---|
| 3546 | % % [s,w] = unix(['qrsh -q fast.q ' civ1_exe ' -f ' filename_cmx ' > ' namelog ' 2>&1' ]); |
---|
| 3547 | % end |
---|
| 3548 | % if s~=0 |
---|
| 3549 | % % ['!' civ1_exe ' -f ' filename_cmx ' > ' namelog] |
---|
| 3550 | % % eval(['!' civ1_exe ' -f ' filename_cmx ' > ' namelog]); |
---|
| 3551 | % end |
---|
| 3552 | end |
---|
| 3553 | end |
---|
| 3554 | |
---|
[12] | 3555 | %------------------------------------------------------------------------ |
---|
[2] | 3556 | % RUN CIV2 CIV2 CIV2 CIV2 |
---|
| 3557 | function RUN_CIV2(handles,filecell_2,filecell_3,filecell_nc1,filecell_nc2,num1,num2,num_a,num_b,nom_type_nc) |
---|
[12] | 3558 | %------------------------------------------------------------------------ |
---|
[2] | 3559 | %filecell_2: names of first image |
---|
| 3560 | %filecell_3: names of second images |
---|
| 3561 | global civ2_exe sge |
---|
| 3562 | |
---|
| 3563 | %names of the civ2 fields |
---|
| 3564 | field.vel_type='civ2'; |
---|
| 3565 | field.nb='nb_vectors2'; |
---|
| 3566 | field.X='vec2_X'; |
---|
| 3567 | field.Y='vec2_Y'; |
---|
| 3568 | field.U='vec2_U'; |
---|
| 3569 | field.V='vec2_V'; |
---|
| 3570 | |
---|
| 3571 | %get civ parameters |
---|
| 3572 | ibx=get(handles.ibx_civ2,'String'); |
---|
| 3573 | iby=get(handles.iby_civ2,'String'); |
---|
| 3574 | rho=get(handles.rho_civ2,'String'); |
---|
| 3575 | decimal=int2str(get(handles.decimal,'Value')); |
---|
| 3576 | deformation=int2str(get(handles.deformation,'Value')); |
---|
| 3577 | dx=get(handles.dx_civ2,'String'); |
---|
| 3578 | dy=get(handles.dy_civ2,'String'); |
---|
| 3579 | if isequal(str2num(dx),[]) |
---|
| 3580 | dx='20';%default |
---|
| 3581 | end |
---|
| 3582 | if isequal(str2num(dy),[]) |
---|
| 3583 | dy='20';%default |
---|
| 3584 | end |
---|
| 3585 | pxcmx='1';%velocity fields are expressed in pixel displacement |
---|
| 3586 | pxcmy='1'; |
---|
| 3587 | A=imread(cell2mat(filecell_2(1,1)));%read the first image to get the size |
---|
| 3588 | sizim=size(A); |
---|
| 3589 | npx=num2str(sizim(2)); |
---|
| 3590 | npy=num2str(sizim(1)); |
---|
| 3591 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 3592 | filebase=get(handles.displ_filebase,'String'); |
---|
| 3593 | %grid |
---|
| 3594 | gridname='';%default ='noFile use default' |
---|
| 3595 | gridflag='n';%default |
---|
| 3596 | test_grid=get(handles.browse_gridciv2,'Value'); |
---|
| 3597 | nbslice_grid=[]; |
---|
| 3598 | if test_grid |
---|
| 3599 | gridname=get(handles.grid_civ2,'String'); |
---|
| 3600 | if numel(gridname)>4 && isequal(gridname(end-3:end),'grid') |
---|
| 3601 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
| 3602 | if ~isempty(nbslice_grid) |
---|
| 3603 | gridflag='y'; |
---|
| 3604 | end |
---|
| 3605 | elseif exist(gridname,'file') |
---|
| 3606 | gridflag='y'; |
---|
| 3607 | else |
---|
| 3608 | msgbox_uvmat('ERROR',['input grid file ' gridname ' not found']) |
---|
| 3609 | return |
---|
| 3610 | end |
---|
| 3611 | end |
---|
| 3612 | sizcell=size(filecell_2); |
---|
| 3613 | nbfield=sizcell(1); |
---|
| 3614 | nbslice=sizcell(2); |
---|
| 3615 | |
---|
| 3616 | %main loop |
---|
| 3617 | icount=0; |
---|
| 3618 | for ifile=1:nbfield |
---|
| 3619 | for j=1:nbslice |
---|
| 3620 | icount=icount+1; |
---|
| 3621 | barlength=0.188*icount/(nbfield*nbslice); |
---|
| 3622 | set(handles.waitbar_civ2,'Position',[0.946 0.407-barlength 0.03 barlength]) |
---|
| 3623 | drawnow |
---|
| 3624 | filename_ima_2=cell2mat(filecell_2(ifile,j)); |
---|
| 3625 | filename_ima_2([end-3:end])=[];%remove .png extension |
---|
| 3626 | filename_ima_3=cell2mat(filecell_3(ifile,j)); |
---|
| 3627 | filename_ima_3([end-3:end])=[];%remove .png extension |
---|
| 3628 | filename_cmx=cell2mat(filecell_nc2(ifile,j));%output netcdf file |
---|
| 3629 | filename_cmx([end-1:end])=[ 'cm'];%name of cmx file |
---|
| 3630 | filename_cmx=[filename_cmx 'x']; |
---|
| 3631 | namelog=[filename_cmx([1:end-3]) 'log']; |
---|
| 3632 | if size(time,1)>=num2(ifile) & size(time,2)>=num_b(j) |
---|
| 3633 | Dt=num2str(time(num2(ifile),num_b(j))-time(num1(ifile),num_a(j))); |
---|
| 3634 | if isequal(Dt,'0') |
---|
| 3635 | Dt='1' ;%case of 'displacement' mode |
---|
| 3636 | end |
---|
| 3637 | T0=num2str((time(num2(ifile),num_b(j))+time(num1(ifile),num_a(j)))/2); |
---|
| 3638 | else |
---|
| 3639 | Dt='1'; |
---|
| 3640 | T0='0'; |
---|
| 3641 | end |
---|
| 3642 | term_a=num2stra(num_a(j),nom_type_nc); |
---|
| 3643 | term_b=num2stra(num_b(j),nom_type_nc); |
---|
| 3644 | filename_nc1=cell2mat(filecell_nc1(ifile,j)); |
---|
| 3645 | filename_nc1([end-2:end])=[]; % remove '.nc' |
---|
| 3646 | if test_grid && ~isempty(nbslice_grid) |
---|
| 3647 | num1_grid=mod(num1(ifile)-1,nbslice_grid)+1 |
---|
| 3648 | gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 3649 | if ~exist(gridname,'file') |
---|
| 3650 | msgbox_uvmat('ERROR',['missing grid file ' gridname]) |
---|
| 3651 | return |
---|
| 3652 | end |
---|
| 3653 | end |
---|
| 3654 | test_mask=get(handles.get_mask_civ2,'Value'); |
---|
| 3655 | if test_mask==0 |
---|
| 3656 | maskname='noFile use default'; |
---|
| 3657 | maskflag='n'; |
---|
| 3658 | else |
---|
| 3659 | maskdispl=get(handles.mask_civ2,'String'); |
---|
| 3660 | maskbase=[filebase '_' maskdispl]; % |
---|
| 3661 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 3662 | num1_mask=mod(num1(ifile)-1,nbslice_mask)+1; |
---|
| 3663 | maskname =name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 3664 | if ~exist(maskname,'file') |
---|
| 3665 | maskflag='y'; |
---|
| 3666 | else |
---|
| 3667 | maskname='noFile use default'; |
---|
| 3668 | maskflag='n'; |
---|
| 3669 | end |
---|
| 3670 | end |
---|
| 3671 | |
---|
| 3672 | textcmx={'############## CMX file';... |
---|
| 3673 | ['FirstImage ' filename_ima_2];... |
---|
| 3674 | ['LastImage ' filename_ima_3];... |
---|
| 3675 | 'XX' ;... |
---|
| 3676 | ['Mask ' maskflag];... |
---|
| 3677 | ['MaskName ' maskname];... |
---|
| 3678 | ['ImageSize ' npx ' ' npy];... |
---|
| 3679 | ['CorrelationBoxesSize ' ibx ' ' iby];... |
---|
| 3680 | ['SearchBoxeSize ' ibx ' ' iby];... |
---|
| 3681 | ['RO ' rho];... |
---|
| 3682 | ['GridSpacing ' dx ' ' dy];... |
---|
| 3683 | 'XX 1.0';... |
---|
| 3684 | ['Dt_TO ' Dt ' ' T0];... |
---|
| 3685 | ['PixCmXY ' pxcmx ' ' pxcmy];... |
---|
| 3686 | 'XX 1';... |
---|
| 3687 | ['ShiftXY 0 0'];... |
---|
| 3688 | ['Grid ' gridflag];... |
---|
| 3689 | ['GridName ' gridname];... |
---|
| 3690 | 'XX 85';... |
---|
| 3691 | 'XX 1.0';... |
---|
| 3692 | 'XX 1.0';... |
---|
| 3693 | 'Hart 1';... |
---|
| 3694 | ['DecimalShift ' decimal];... |
---|
| 3695 | ['Deformation ' deformation];... |
---|
| 3696 | 'CorrelationMin 0';... |
---|
| 3697 | 'IntensityMin 0';... |
---|
| 3698 | 'SeuilImage n';... |
---|
| 3699 | 'SeuilImageValues 0 4096';... |
---|
| 3700 | ['ImageToUse ' term_a ' ' term_b];... % VERIFIER ? |
---|
| 3701 | ['ImageUsedBefore ' filename_nc1]}; |
---|
| 3702 | textout=char(textcmx); |
---|
[12] | 3703 | dlmwrite(filename_cmx,textout,''); |
---|
[2] | 3704 | s=-1; |
---|
| 3705 | display(['!' civ2_exe ' -f ' filename_cmx ' > ' namelog]) |
---|
| 3706 | eval(['!' civ2_exe ' -f ' filename_cmx ' > ' namelog]); |
---|
| 3707 | |
---|
| 3708 | % if sge%dispatch computation on the cluster using interactive queue |
---|
| 3709 | % [s,w] = unix(['qrsh -q fast.q ' civ2_exe ' -f ' filename_cmx ' > ' namelog ' 2>&1']); |
---|
| 3710 | % end |
---|
| 3711 | % if s~=0 |
---|
| 3712 | % eval(['!' civ2_exe ' -f ' filename_cmx ' > ' namelog]); |
---|
| 3713 | % ['!' civ2_exe ' -f ' filename_cmx ' > ' namelog] |
---|
| 3714 | % end |
---|
| 3715 | end |
---|
| 3716 | end |
---|
| 3717 | % close(h) |
---|
| 3718 | |
---|
[12] | 3719 | %------------------------------------------------------------------------ |
---|
| 3720 | % --- PATCH |
---|
[2] | 3721 | function cmd_PATCH=RUN_PATCH(filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,test_interp) |
---|
[12] | 3722 | %------------------------------------------------------------------------ |
---|
[2] | 3723 | global patch_exe patch_new_exe |
---|
| 3724 | namelog=[filename_nc([1:end-3]) '_patch.log']; |
---|
| 3725 | if test_interp==0 |
---|
| 3726 | cmd_PATCH=[patch_exe ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ... |
---|
| 3727 | ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
| 3728 | else %nouveau programme patch |
---|
| 3729 | cmd_PATCH=[patch_new_exe ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ... |
---|
| 3730 | ' -max ' thresh_value ' -nopt ' subdomain_patch ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
| 3731 | end |
---|
[12] | 3732 | |
---|
| 3733 | %------------------------------------------------------------------------ |
---|
| 3734 | % --- STEREO Interp |
---|
[2] | 3735 | function cmd=RUN_STINTERP(stinterp_exe,filename_A_nc,filename_B_nc,filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,xmlA,xmlB) |
---|
[12] | 3736 | %------------------------------------------------------------------------ |
---|
[2] | 3737 | namelog=[filename_nc([1:end-3]) '_stinterp.log']; |
---|
| 3738 | cmd=[stinterp_exe ' -f1 ' filename_A_nc ' -f2 ' filename_B_nc ' -f ' filename_nc ... |
---|
| 3739 | ' -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 |
---|
| 3740 | |
---|
[12] | 3741 | %------------------------------------------------------------------------ |
---|
[2] | 3742 | % --- Executes on button press in CIV1. |
---|
| 3743 | function CIV1_Callback(hObject, eventdata, handles) |
---|
[12] | 3744 | %------------------------------------------------------------------------ |
---|
[2] | 3745 | val=get(handles.CIV1,'Value'); |
---|
| 3746 | if isequal(val,1) |
---|
| 3747 | enable_civ1(handles,'on') |
---|
| 3748 | enable_pair1(handles,'on') |
---|
| 3749 | else |
---|
| 3750 | enable_civ1(handles,'off') |
---|
| 3751 | end |
---|
| 3752 | find_netcpair_civ1(hObject, eventdata, handles); |
---|
| 3753 | |
---|
[12] | 3754 | %------------------------------------------------------------------------ |
---|
[2] | 3755 | % --- Executes on button press in FIX1. |
---|
| 3756 | function FIX1_Callback(hObject, eventdata, handles) |
---|
[12] | 3757 | %------------------------------------------------------------------------ |
---|
[2] | 3758 | enable_fix1(handles,get(handles.FIX1,'Value')) |
---|
| 3759 | |
---|
[12] | 3760 | %------------------------------------------------------------------------ |
---|
[2] | 3761 | % --- Executes on button press in PATCH1. |
---|
| 3762 | function PATCH1_Callback(hObject, eventdata, handles) |
---|
[12] | 3763 | %------------------------------------------------------------------------ |
---|
[2] | 3764 | if get(handles.PATCH1,'Value')==1 |
---|
[12] | 3765 | enable_patch1(handles) |
---|
[2] | 3766 | else |
---|
[12] | 3767 | desable_patch1(handles) |
---|
[2] | 3768 | end |
---|
| 3769 | |
---|
[12] | 3770 | %------------------------------------------------------------------------ |
---|
[2] | 3771 | % --- Executes on button press in CIV2. |
---|
| 3772 | function CIV2_Callback(hObject, eventdata, handles) |
---|
[12] | 3773 | %------------------------------------------------------------------------ |
---|
[2] | 3774 | state=get(handles.CIV2,'Value'); |
---|
| 3775 | enable_civ2(handles,state) |
---|
| 3776 | if state |
---|
| 3777 | find_netcpair_civ2(hObject, eventdata, handles) |
---|
| 3778 | enable_pair1(handles,'on') |
---|
| 3779 | end |
---|
| 3780 | |
---|
[12] | 3781 | %------------------------------------------------------------------------ |
---|
[2] | 3782 | % --- Executes on button press in FIX2. |
---|
| 3783 | function FIX2_Callback(hObject, eventdata, handles) |
---|
[12] | 3784 | %------------------------------------------------------------------------ |
---|
[2] | 3785 | if get(handles.FIX2,'Value')==1 |
---|
| 3786 | enable_fix2(handles) |
---|
| 3787 | if get(handles.CIV2,'Value')==0 |
---|
| 3788 | find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files |
---|
| 3789 | end |
---|
| 3790 | else |
---|
| 3791 | desable_fix2(handles) |
---|
| 3792 | end |
---|
| 3793 | |
---|
[12] | 3794 | %------------------------------------------------------------------------ |
---|
[2] | 3795 | % --- Executes on button press in PATCH2. |
---|
| 3796 | function PATCH2_Callback(hObject, eventdata, handles) |
---|
[12] | 3797 | %------------------------------------------------------------------------ |
---|
[2] | 3798 | if get(handles.PATCH2,'Value')==1 |
---|
| 3799 | enable_patch2(handles) |
---|
| 3800 | if get(handles.CIV2,'Value')==0 |
---|
| 3801 | find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files |
---|
| 3802 | end |
---|
| 3803 | else |
---|
| 3804 | desable_patch2(handles) |
---|
| 3805 | end |
---|
| 3806 | |
---|
[12] | 3807 | %------------------------------------------------------------------------ |
---|
| 3808 | function first_i_Callback(hObject, eventdata, handles) |
---|
| 3809 | %------------------------------------------------------------------------ |
---|
| 3810 | % last_i_Callback(hObject, eventdata, handles) |
---|
| 3811 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 3812 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 3813 | % ref_i=ceil((first_i+last_i)/2); |
---|
| 3814 | set(handles.ref_i,'String', num2str(first_i))% reference index for pair dt = first index |
---|
| 3815 | ref_i_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3816 | |
---|
[12] | 3817 | %------------------------------------------------------------------------ |
---|
| 3818 | function first_j_Callback(hObject, eventdata, handles) |
---|
| 3819 | %------------------------------------------------------------------------ |
---|
| 3820 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 3821 | set(handles.ref_j,'String', num2str(first_j))% reference index for pair dt = first index |
---|
| 3822 | ref_j_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3823 | |
---|
[12] | 3824 | %------------------------------------------------------------------------ |
---|
[2] | 3825 | % --- Executes on button press in calcul_search: determine the search range isx,isy |
---|
| 3826 | function calcul_search_Callback(hObject, eventdata, handles) |
---|
[12] | 3827 | %------------------------------------------------------------------------ |
---|
[2] | 3828 | %determine pair numbers |
---|
| 3829 | list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs |
---|
| 3830 | index=get(handles.list_pair_civ1,'Value'); |
---|
| 3831 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 3832 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 3833 | pxcm_xy=get(handles.calcul_search,'UserData'); |
---|
| 3834 | pxcmx=pxcm_xy(1); |
---|
| 3835 | pxcmy=pxcm_xy(2); |
---|
| 3836 | mode_list=get(handles.mode,'String'); |
---|
| 3837 | mode_value=get(handles.mode,'Value'); |
---|
| 3838 | mode=mode_list{mode_value}; |
---|
| 3839 | if isequal (mode, 'series(Di)' ) |
---|
| 3840 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
| 3841 | num1=ref_i-floor(index/2);% first image numbers |
---|
| 3842 | num2=ref_i+ceil(index/2); |
---|
| 3843 | num_a=1; |
---|
| 3844 | num_b=1; |
---|
| 3845 | elseif isequal (mode, 'series(Dj)') |
---|
| 3846 | num1=1; |
---|
| 3847 | num2=1; |
---|
| 3848 | ref_j=str2num(get(handles.ref_j,'String')); |
---|
| 3849 | num_a=ref_j-floor(index/2);% first image numbers |
---|
| 3850 | num_b=ref_j+ceil(index/2); |
---|
| 3851 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
| 3852 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
| 3853 | num1=ref_i; |
---|
| 3854 | num2=ref_i; |
---|
| 3855 | num_a=displ_num(1,index); |
---|
| 3856 | num_b=displ_num(2,index); |
---|
| 3857 | end |
---|
| 3858 | dt=time(num2,num_b)-time(num1,num_a); |
---|
| 3859 | ibx=str2num(get(handles.ibx,'String')); |
---|
| 3860 | iby=str2num(get(handles.iby,'String')); |
---|
| 3861 | umin=dt*pxcmx*str2num(get(handles.umin,'String')); |
---|
| 3862 | umax=dt*pxcmx*str2num(get(handles.umax,'String')); |
---|
| 3863 | vmin=dt*pxcmy*str2num(get(handles.vmin,'String')); |
---|
| 3864 | vmax=dt*pxcmy*str2num(get(handles.vmax,'String')); |
---|
| 3865 | shiftx=round((umin+umax)/2); |
---|
| 3866 | shifty=round((vmin+vmax)/2); |
---|
| 3867 | isx=(umax+2-shiftx)*2+ibx; |
---|
| 3868 | isx=2*ceil(isx/2)+1; |
---|
| 3869 | isy=(vmax+2-shifty)*2+iby; |
---|
| 3870 | isy=2*ceil(isy/2)+1; |
---|
| 3871 | set(handles.shiftx,'String',num2str(shiftx)); |
---|
| 3872 | set(handles.shifty,'String',num2str(shifty)); |
---|
| 3873 | set(handles.isx,'String',num2str(isx)); |
---|
| 3874 | set(handles.isy,'String',num2str(isy)); |
---|
| 3875 | |
---|
[12] | 3876 | %------------------------------------------------------------------------ |
---|
| 3877 | % --- Executes on carriage return on the subdir civ1 edit window |
---|
[2] | 3878 | function subdir_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 3879 | %------------------------------------------------------------------------ |
---|
[2] | 3880 | subdir=get(handles.subdir_civ1,'String'); |
---|
| 3881 | set(handles.subdir_civ2,'String',subdir); |
---|
| 3882 | if get(handles.CIV1,'Value')==0 |
---|
| 3883 | find_netcpair_civ1(hObject, eventdata, handles); %update the list of available pairs from netcdf files in the new directory |
---|
| 3884 | end |
---|
| 3885 | |
---|
[12] | 3886 | %------------------------------------------------------------------------ |
---|
| 3887 | % --- Executes on carriage return on the subdir civ1 edit window |
---|
[2] | 3888 | function subdir_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 3889 | %------------------------------------------------------------------------ |
---|
[2] | 3890 | %update the list of available pairs from netcdf files in the new directory |
---|
| 3891 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0 |
---|
| 3892 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 3893 | end |
---|
| 3894 | |
---|
[12] | 3895 | %------------------------------------------------------------------------ |
---|
[2] | 3896 | % --- Executes on button press in get_mask_civ1. |
---|
| 3897 | function get_mask_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 3898 | %------------------------------------------------------------------------ |
---|
[2] | 3899 | maskval=get(handles.get_mask_civ1,'Value'); |
---|
| 3900 | if isequal(maskval,0) |
---|
| 3901 | set(handles.mask_civ1,'String','') |
---|
| 3902 | else |
---|
| 3903 | mask_displ='no mask'; %default |
---|
| 3904 | filebase=get(handles.displ_filebase,'String'); |
---|
| 3905 | [ nbslice_mask, flag_mask]=get_mask(filebase,handles); |
---|
| 3906 | if isequal(flag_mask,1) |
---|
| 3907 | mask_displ=[num2str(nbslice_mask) 'mask']; |
---|
| 3908 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
| 3909 | common_path=fileparts(filebase); |
---|
| 3910 | filebase_a=fullfile(common_path,get(handles.displ_filebase2,'String')); |
---|
| 3911 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[12] | 3912 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice_mask) |
---|
[2] | 3913 | mask_displ='no mask'; |
---|
| 3914 | end |
---|
| 3915 | end |
---|
| 3916 | if isequal(mask_displ,'no mask') |
---|
[12] | 3917 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3918 | {'*.png', ' (*.png)'; |
---|
| 3919 | '*.png', '.png files '; ... |
---|
| 3920 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3921 | 'Pick a mask file *.png',filebase); |
---|
| 3922 | mask_displ=fullfile(PathName,FileName); |
---|
| 3923 | if ~exist(mask_displ,'file') |
---|
| 3924 | mask_displ='no mask'; |
---|
| 3925 | end |
---|
| 3926 | end |
---|
| 3927 | if isequal(mask_displ,'no mask') |
---|
[2] | 3928 | set(handles.get_mask_civ1,'Value',0) |
---|
| 3929 | set(handles.get_mask_fix1,'Value',0) |
---|
| 3930 | set(handles.get_mask_civ2,'Value',0) |
---|
| 3931 | set(handles.get_mask_fix2,'Value',0) |
---|
| 3932 | else |
---|
| 3933 | set(handles.get_mask_fix1,'Value',1) |
---|
| 3934 | set(handles.get_mask_fix2,'Value',1) |
---|
| 3935 | end |
---|
| 3936 | set(handles.mask_civ1,'String',mask_displ) |
---|
| 3937 | set(handles.mask_fix1,'String',mask_displ) |
---|
| 3938 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 3939 | set(handles.mask_fix2,'String',mask_displ) |
---|
| 3940 | end |
---|
| 3941 | |
---|
[12] | 3942 | %------------------------------------------------------------------------ |
---|
[2] | 3943 | % --- Executes on button press in get_mask_fix1. |
---|
| 3944 | function get_mask_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 3945 | %------------------------------------------------------------------------ |
---|
[2] | 3946 | maskval=get(handles.get_mask_fix1,'Value'); |
---|
| 3947 | if isequal(maskval,0) |
---|
| 3948 | set(handles.mask_fix1,'String','') |
---|
| 3949 | else |
---|
| 3950 | mask_displ='no mask'; %default |
---|
| 3951 | filebase=get(handles.displ_filebase,'String'); |
---|
| 3952 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3953 | if isequal(flag_mask,1) |
---|
| 3954 | mask_displ=[num2str(nbslice) 'mask']; |
---|
| 3955 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
| 3956 | filebase_a=get(handles.displ_filebase2,'String'); |
---|
| 3957 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
| 3958 | if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice) |
---|
| 3959 | mask_displ='no mask'; |
---|
| 3960 | end |
---|
| 3961 | end |
---|
| 3962 | if isequal(mask_displ,'no mask') |
---|
[12] | 3963 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3964 | {'*.png', ' (*.png)'; |
---|
| 3965 | '*.png', '.png files '; ... |
---|
| 3966 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3967 | 'Pick a mask file *.png',filebase); |
---|
| 3968 | mask_displ=fullfile(PathName,FileName); |
---|
| 3969 | if ~exist(mask_displ,'file') |
---|
| 3970 | mask_displ='no mask'; |
---|
| 3971 | end |
---|
| 3972 | end |
---|
| 3973 | if isequal(mask_displ,'no mask') |
---|
[2] | 3974 | set(handles.get_mask_fix1,'Value',0) |
---|
| 3975 | set(handles.get_mask_civ2,'Value',0) |
---|
| 3976 | set(handles.get_mask_fix2,'Value',0) |
---|
| 3977 | else |
---|
| 3978 | %set(handles.get_mask_civ2,'Value',1) |
---|
| 3979 | set(handles.get_mask_fix2,'Value',1) |
---|
| 3980 | end |
---|
| 3981 | set(handles.mask_fix1,'String',mask_displ) |
---|
| 3982 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 3983 | set(handles.mask_fix2,'String',mask_displ) |
---|
| 3984 | end |
---|
[12] | 3985 | |
---|
| 3986 | %------------------------------------------------------------------------ |
---|
[2] | 3987 | % --- Executes on button press in get_mask_civ2. |
---|
| 3988 | function get_mask_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 3989 | %------------------------------------------------------------------------ |
---|
[2] | 3990 | maskval=get(handles.get_mask_civ2,'Value'); |
---|
| 3991 | if isequal(maskval,0) |
---|
| 3992 | set(handles.mask_civ2,'String','') |
---|
| 3993 | else |
---|
| 3994 | mask_displ='no mask'; %default |
---|
| 3995 | filebase=get(handles.displ_filebase,'String'); |
---|
| 3996 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3997 | if isequal(flag_mask,1) |
---|
| 3998 | mask_displ=[num2str(nbslice) 'mask']; |
---|
| 3999 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
| 4000 | filebase_a=get(handles.displ_filebase2,'String'); |
---|
| 4001 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
| 4002 | if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice) |
---|
| 4003 | mask_displ='no mask'; |
---|
| 4004 | end |
---|
| 4005 | end |
---|
| 4006 | if isequal(mask_displ,'no mask') |
---|
[12] | 4007 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4008 | {'*.png', ' (*.png)'; |
---|
| 4009 | '*.png', '.png files '; ... |
---|
| 4010 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4011 | 'Pick a mask file *.png',filebase); |
---|
| 4012 | mask_displ=fullfile(PathName,FileName); |
---|
| 4013 | if ~exist(mask_displ,'file') |
---|
| 4014 | mask_displ='no mask'; |
---|
| 4015 | end |
---|
| 4016 | end |
---|
| 4017 | if isequal(mask_displ,'no mask') |
---|
[2] | 4018 | set(handles.get_mask_civ2,'Value',0) |
---|
| 4019 | set(handles.get_mask_fix2,'Value',0) |
---|
| 4020 | else |
---|
| 4021 | set(handles.get_mask_fix2,'Value',1) |
---|
| 4022 | end |
---|
| 4023 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 4024 | set(handles.mask_fix2,'String',mask_displ) |
---|
| 4025 | end |
---|
[12] | 4026 | |
---|
| 4027 | %------------------------------------------------------------------------ |
---|
[2] | 4028 | % --- Executes on button press in get_mask_fix2. |
---|
| 4029 | function get_mask_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 4030 | %------------------------------------------------------------------------ |
---|
[2] | 4031 | maskval=get(handles.get_mask_fix2,'Value'); |
---|
| 4032 | if isequal(maskval,0) |
---|
| 4033 | set(handles.mask_fix2,'String','') |
---|
| 4034 | else |
---|
[12] | 4035 | mask_displ='no mask'; %default |
---|
| 4036 | filebase=get(handles.displ_filebase,'String'); |
---|
| 4037 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 4038 | if isequal(flag_mask,1) |
---|
| 4039 | mask_displ=[num2str(nbslice) 'mask']; |
---|
| 4040 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
| 4041 | filebase_a=get(handles.displ_filebase2,'String'); |
---|
| 4042 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
| 4043 | if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice) |
---|
| 4044 | mask_displ='no mask'; |
---|
| 4045 | end |
---|
| 4046 | end |
---|
| 4047 | if isequal(mask_displ,'no mask') |
---|
| 4048 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4049 | {'*.png', ' (*.png)'; |
---|
| 4050 | '*.png', '.png files '; ... |
---|
| 4051 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4052 | 'Pick a mask file *.png',filebase); |
---|
| 4053 | mask_displ=fullfile(PathName,FileName); |
---|
| 4054 | if ~exist(mask_displ,'file') |
---|
[2] | 4055 | mask_displ='no mask'; |
---|
| 4056 | end |
---|
[12] | 4057 | end |
---|
| 4058 | if isequal(mask_displ,'no mask') |
---|
| 4059 | set(handles.get_mask_fix2,'Value',0) |
---|
| 4060 | end |
---|
| 4061 | set(handles.mask_fix2,'String',mask_displ) |
---|
[2] | 4062 | end |
---|
| 4063 | |
---|
[12] | 4064 | %------------------------------------------------------------------------ |
---|
| 4065 | % --- function called to look for mask files |
---|
[2] | 4066 | function [nbslice, flag_mask]=get_mask(filebase,handles) |
---|
[12] | 4067 | %------------------------------------------------------------------------ |
---|
[2] | 4068 | %detect mask files, images with appropriate file base |
---|
| 4069 | %[filebase '_' xx 'mask'], xx=nbslice |
---|
| 4070 | %flag_mask=1 indicates detection |
---|
| 4071 | |
---|
| 4072 | flag_mask=0;%default |
---|
| 4073 | nbslice=1; |
---|
| 4074 | |
---|
| 4075 | % subdir=get(handles.subdir_civ1,'String'); |
---|
| 4076 | [Path,Name]=fileparts(filebase); |
---|
[12] | 4077 | if ~isdir(Path) |
---|
| 4078 | msgbox_uvmat('ERROR','no path for input files') |
---|
| 4079 | return |
---|
| 4080 | end |
---|
[2] | 4081 | currentdir=pwd; |
---|
| 4082 | cd(Path);%move in the dir of the root name filebase |
---|
| 4083 | maskfiles=dir([Name '_*mask_*.png']);%look for mask files |
---|
| 4084 | cd(currentdir);%come back to the current working directory |
---|
[12] | 4085 | if ~isempty(maskfiles) |
---|
| 4086 | % msgbox_uvmat('ERROR','no mask available, to create it use Tools/Make mask in the upper menu bar of uvmat') |
---|
| 4087 | % else |
---|
[2] | 4088 | flag_mask=1; |
---|
| 4089 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 4090 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 4091 | Namedouble=double(Name); |
---|
| 4092 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 4093 | ind_mask=findstr('mask',Name); |
---|
| 4094 | i=ind_mask-1; |
---|
| 4095 | while val(i)==0 & i>0 |
---|
| 4096 | i=i-1; |
---|
| 4097 | end |
---|
| 4098 | nbslice=str2num(Name(i+1:ind_mask-1)); |
---|
| 4099 | if ~isequal(nbslice,[]) & Name(i)=='_' |
---|
| 4100 | flag_mask=1; |
---|
| 4101 | else |
---|
| 4102 | msgbox_uvmat('ERROR',['bad mask file ' Name ext ' found in ' Path2]) |
---|
| 4103 | return |
---|
| 4104 | nbslice=1; |
---|
| 4105 | end |
---|
| 4106 | end |
---|
| 4107 | |
---|
[12] | 4108 | %------------------------------------------------------------------------ |
---|
| 4109 | % --- function called to look for grid files |
---|
[2] | 4110 | function [nbslice, flag_mask]=get_grid(filebase,handles) |
---|
[12] | 4111 | %------------------------------------------------------------------------ |
---|
[2] | 4112 | flag_mask=0;%default |
---|
| 4113 | nbslice=1; |
---|
| 4114 | [Path,Name]=fileparts(filebase); |
---|
| 4115 | currentdir=pwd; |
---|
| 4116 | cd(Path);%move in the dir of the root name filebase |
---|
| 4117 | maskfiles=dir([Name '_*grid_*.grid']);%look for mask files |
---|
| 4118 | cd(currentdir);%come back to the current working directory |
---|
| 4119 | if ~isempty(maskfiles) |
---|
| 4120 | flag_mask=1; |
---|
| 4121 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 4122 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 4123 | Namedouble=double(Name); |
---|
| 4124 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 4125 | ind_mask=findstr('grid',Name); |
---|
| 4126 | i=ind_mask-1; |
---|
| 4127 | while val(i)==0 & i>0 |
---|
| 4128 | i=i-1; |
---|
| 4129 | end |
---|
| 4130 | nbslice=str2num(Name(i+1:ind_mask-1)); |
---|
| 4131 | if ~isequal(nbslice,[]) & Name(i)=='_' |
---|
| 4132 | flag_mask=1; |
---|
| 4133 | else |
---|
| 4134 | msgbox_uvmat('ERROR',['bad grid file ' Name ext ' found in ' Path2]) |
---|
| 4135 | return |
---|
| 4136 | nbslice=1; |
---|
| 4137 | end |
---|
[12] | 4138 | end |
---|
[2] | 4139 | |
---|
[12] | 4140 | %------------------------------------------------------------------------ |
---|
| 4141 | % --- transform numbers to letters |
---|
[2] | 4142 | function str=num2stra(num,nom_type); |
---|
[12] | 4143 | %------------------------------------------------------------------------ |
---|
[2] | 4144 | if isequal(nom_type,'png_old') | isequal(nom_type,'netc_old') |isequal(nom_type,'raw_SMD') |
---|
| 4145 | str=char(96+num); |
---|
| 4146 | elseif isequal(nom_type,'_i')|isequal(nom_type,'_i1-i2')... |
---|
| 4147 | |isequal(nom_type,'ima_num')| isequal(nom_type,'avi')| isequal(nom_type,'none') |
---|
| 4148 | str=''; |
---|
| 4149 | else |
---|
| 4150 | str=num2str(num); |
---|
| 4151 | end |
---|
[12] | 4152 | |
---|
| 4153 | %------------------------------------------------------------------------ |
---|
[2] | 4154 | function mask_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 4155 | %------------------------------------------------------------------------ |
---|
[2] | 4156 | set(handles.mask_civ1,'UserData',[]) |
---|
| 4157 | set(handles.mask_civ1,'String','') |
---|
[12] | 4158 | |
---|
| 4159 | %------------------------------------------------------------------------ |
---|
[2] | 4160 | function mask_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 4161 | %------------------------------------------------------------------------ |
---|
[2] | 4162 | set(handles.mask_civ2,'UserData',[]) |
---|
| 4163 | set(handles.mask_civ2,'String','') |
---|
[12] | 4164 | |
---|
| 4165 | %------------------------------------------------------------------------ |
---|
[2] | 4166 | function mask_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 4167 | %------------------------------------------------------------------------ |
---|
[2] | 4168 | set(handles.mask_fix1,'UserData',[]) |
---|
| 4169 | set(handles.mask_fix1,'String','') |
---|
[12] | 4170 | |
---|
| 4171 | %------------------------------------------------------------------------ |
---|
[2] | 4172 | function mask_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 4173 | %------------------------------------------------------------------------ |
---|
[2] | 4174 | set(handles.mask_fix2,'UserData',[]) |
---|
| 4175 | set(handles.mask_fix2,'String','') |
---|
| 4176 | |
---|
[12] | 4177 | %------------------------------------------------------------------------ |
---|
[2] | 4178 | % --- Executes on button press in list_subdir_civ1. |
---|
| 4179 | function list_subdir_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 4180 | %------------------------------------------------------------------------ |
---|
[2] | 4181 | list_subdir_civ1=get(handles.list_subdir_civ1,'String'); |
---|
| 4182 | val=get(handles.list_subdir_civ1,'Value'); |
---|
| 4183 | if val>1 |
---|
| 4184 | subdir=list_subdir_civ1{val}; |
---|
| 4185 | set(handles.subdir_civ1,'String',subdir); |
---|
| 4186 | set(handles.list_subdir_civ1,'Value',1); |
---|
| 4187 | end |
---|
| 4188 | |
---|
[12] | 4189 | %------------------------------------------------------------------------ |
---|
[2] | 4190 | % --- Executes on button press in list_subdir_civ2. |
---|
| 4191 | function list_subdir_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 4192 | %------------------------------------------------------------------------ |
---|
[2] | 4193 | list_subdir_civ2=get(handles.list_subdir_civ2,'String'); |
---|
| 4194 | val=get(handles.list_subdir_civ2,'Value'); |
---|
| 4195 | if val>1 |
---|
| 4196 | subdir=list_subdir_civ2{val}; |
---|
| 4197 | set(handles.subdir_civ2,'String',subdir); |
---|
| 4198 | set(handles.list_subdir_civ2,'Value',1); |
---|
| 4199 | end |
---|
| 4200 | |
---|
[12] | 4201 | %------------------------------------------------------------------------ |
---|
[2] | 4202 | % --- Executes on button press in browse_gridciv1. |
---|
| 4203 | function browse_gridciv1_Callback(hObject, eventdata, handles) |
---|
[12] | 4204 | %------------------------------------------------------------------------ |
---|
[2] | 4205 | value=get(handles.browse_gridciv1,'Value'); |
---|
| 4206 | testgrid=0; |
---|
| 4207 | if value |
---|
| 4208 | filebase=get(handles.displ_filebase,'String'); |
---|
| 4209 | [nbslice, flag_grid]=get_grid(filebase,handles) |
---|
| 4210 | if isequal(flag_grid,1) |
---|
| 4211 | filegrid=[num2str(nbslice) 'grid']; |
---|
| 4212 | testgrid=1; |
---|
| 4213 | else |
---|
| 4214 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4215 | {'*.grid', ' (*.grid)'; |
---|
| 4216 | '*.grid', '.grid files '; ... |
---|
| 4217 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4218 | 'Pick a file',filebase); |
---|
| 4219 | filegrid=fullfile(PathName,FileName); |
---|
| 4220 | if ~(isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file')) |
---|
| 4221 | testgrid=1; |
---|
| 4222 | end |
---|
| 4223 | end |
---|
| 4224 | end |
---|
| 4225 | if testgrid |
---|
| 4226 | set(handles.browse_gridciv2,'Value',1) |
---|
| 4227 | set(handles.get_gridpatch1,'Value',1) |
---|
| 4228 | set(handles.get_gridpatch2,'Value',1) |
---|
| 4229 | set(handles.dx_civ1,'Visible','off'); |
---|
| 4230 | set(handles.dy_civ1,'Visible','off'); |
---|
| 4231 | set(handles.dx_civ2,'Visible','off'); |
---|
| 4232 | set(handles.dy_civ2,'Visible','off'); |
---|
| 4233 | set(handles.grid_civ1,'String',filegrid) |
---|
| 4234 | set(handles.grid_patch1,'String',filegrid) |
---|
| 4235 | set(handles.grid_civ2,'String',filegrid) |
---|
| 4236 | set(handles.grid_patch2,'String',filegrid) |
---|
| 4237 | else |
---|
| 4238 | set(handles.browse_gridciv1,'Value',0); |
---|
| 4239 | set(handles.browse_gridciv2,'Value',0); |
---|
| 4240 | set(handles.get_gridpatch1,'Value',0) |
---|
| 4241 | set(handles.get_gridpatch2,'Value',0) |
---|
| 4242 | set(handles.dx_civ1,'Visible','on'); |
---|
| 4243 | set(handles.dy_civ1,'Visible','on'); |
---|
| 4244 | set(handles.dx_civ2,'Visible','on'); |
---|
| 4245 | set(handles.dy_civ2,'Visible','on'); |
---|
| 4246 | set(handles.grid_civ1,'String','') |
---|
| 4247 | set(handles.grid_patch1,'String','') |
---|
| 4248 | set(handles.grid_civ2,'String','') |
---|
| 4249 | set(handles.grid_patch2,'String','') |
---|
| 4250 | end |
---|
| 4251 | |
---|
[12] | 4252 | %------------------------------------------------------------------------ |
---|
[2] | 4253 | % --- Executes on button press in browse_gridciv1. |
---|
| 4254 | function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
[12] | 4255 | %------------------------------------------------------------------------ |
---|
[2] | 4256 | value=get(handles.browse_gridciv2,'Value'); |
---|
| 4257 | if value |
---|
| 4258 | filebase=get(handles.displ_filebase,'String'); |
---|
| 4259 | [nbslice, flag_grid]=get_grid(filebase,handles) |
---|
| 4260 | if isequal(flag_grid,1) |
---|
| 4261 | mask_displ=[num2str(nbslice) 'grid']; |
---|
| 4262 | set(handles.grid_civ2,'String',mask_displ) |
---|
| 4263 | set(handles.dx_civ2,'Visible','off'); |
---|
| 4264 | set(handles.dy_civ2,'Visible','off'); |
---|
| 4265 | else |
---|
| 4266 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4267 | {'*.grid', ' (*.grid)'; |
---|
| 4268 | '*.grid', '.grid files '; ... |
---|
| 4269 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4270 | 'Pick a file',filebase); |
---|
| 4271 | filegrid=fullfile(PathName,FileName); |
---|
| 4272 | if isempty(FileName)|isempty(PathName)|isequal(FileName,0)|~exist(filegrid,'file') |
---|
| 4273 | set(handles.browse_gridciv2,'Value',0); |
---|
| 4274 | set(handles.grid_civ2,'string',''); |
---|
| 4275 | set(handles.dx_civ2,'Visible','on'); |
---|
| 4276 | set(handles.dy_civ2,'Visible','on'); |
---|
| 4277 | set(handles.grid_civ2,'string',''); |
---|
| 4278 | else |
---|
| 4279 | set(handles.grid_civ2,'string',filegrid); |
---|
| 4280 | set(handles.dx_civ2,'Visible','off'); |
---|
| 4281 | set(handles.dy_civ2,'Visible','off'); |
---|
| 4282 | set(handles.grid_civ2,'string',filegrid); |
---|
| 4283 | end |
---|
| 4284 | end |
---|
| 4285 | else |
---|
| 4286 | set(handles.grid_civ2,'string',''); |
---|
| 4287 | set(handles.dx_civ2,'Visible','on'); |
---|
| 4288 | set(handles.dy_civ2,'Visible','on'); |
---|
| 4289 | set(handles.grid_civ2,'string',''); |
---|
| 4290 | end |
---|
| 4291 | |
---|
| 4292 | % % --- Executes on button press in browse_gridciv2. |
---|
| 4293 | % function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
| 4294 | % |
---|
| 4295 | % filebase=get(handles.displ_filebase,'String'); |
---|
| 4296 | % [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4297 | % {'*.grid', ' (*.grid)'; |
---|
| 4298 | % '*.grid', '.grid files '; ... |
---|
| 4299 | % '*.*', 'All Files (*.*)'}, ... |
---|
| 4300 | % 'Pick a file',filebase); |
---|
| 4301 | % filegrid=fullfile(PathName,FileName); |
---|
| 4302 | % set(handles.grid_civ2,'string',filegrid); |
---|
| 4303 | % set(handles.dx_civ2,'String',' '); |
---|
| 4304 | % set(handles.dy_civ2,'String',' '); |
---|
| 4305 | % % set(handles.grid_patch2,'string',filegrid); |
---|
| 4306 | |
---|
| 4307 | % --- Executes on button press in get_gridpatch1. |
---|
| 4308 | function get_gridpatch1_Callback(hObject, eventdata, handles) |
---|
| 4309 | % hObject handle to get_gridpatch1 (see GCBO) |
---|
| 4310 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 4311 | % handles structure with handles and user data (see GUIDATA) |
---|
| 4312 | |
---|
| 4313 | filebase=get(handles.displ_filebase,'String'); |
---|
| 4314 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4315 | {'*.grid', ' (*.grid)'; |
---|
| 4316 | '*.grid', '.grid files '; ... |
---|
| 4317 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4318 | 'Pick a file',filebase); |
---|
| 4319 | filegrid=fullfile(PathName,FileName); |
---|
| 4320 | set(handles.grid_patch1,'string',filegrid); |
---|
| 4321 | % set(handles.grid_patch2,'string',filegrid |
---|
| 4322 | |
---|
[12] | 4323 | %------------------------------------------------------------------------ |
---|
[2] | 4324 | % --- Executes on button press in get_gridpatch2. |
---|
| 4325 | function get_gridpatch2_Callback(hObject, eventdata, handles) |
---|
[12] | 4326 | %------------------------------------------------------------------------ |
---|
[2] | 4327 | |
---|
[12] | 4328 | %------------------------------------------------------------------------ |
---|
[2] | 4329 | function enable_civ1(handles,state) |
---|
[12] | 4330 | %------------------------------------------------------------------------ |
---|
[2] | 4331 | if isequal(state,0) |
---|
| 4332 | state='off'; |
---|
| 4333 | end |
---|
| 4334 | if isequal(state,1) |
---|
| 4335 | state='on'; |
---|
| 4336 | end |
---|
| 4337 | if isequal(state,'on') |
---|
| 4338 | set(handles.frame_civ1,'BackgroundColor',[1 1 0]) |
---|
| 4339 | set(handles.frame_para_civ1,'BackgroundColor',[1 1 0]) |
---|
| 4340 | set(handles.frame_grid_civ1,'BackgroundColor',[1 1 0]) |
---|
| 4341 | else |
---|
| 4342 | set(handles.frame_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4343 | set(handles.frame_para_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4344 | set(handles.frame_grid_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4345 | end |
---|
| 4346 | set(handles.ibx,'Visible',state) |
---|
| 4347 | set(handles.iby,'Visible',state) |
---|
| 4348 | set(handles.isx,'Visible',state) |
---|
| 4349 | set(handles.isy,'Visible',state) |
---|
| 4350 | set(handles.shiftx,'Visible',state) |
---|
| 4351 | set(handles.shifty,'Visible',state) |
---|
| 4352 | set(handles.rho,'Visible',state) |
---|
| 4353 | set(handles.dx_civ1,'Visible',state) |
---|
| 4354 | set(handles.dy_civ1,'Visible',state) |
---|
| 4355 | set(handles.calcul_search,'Visible',state) |
---|
| 4356 | set(handles.u_text,'Visible',state) |
---|
| 4357 | set(handles.v_text,'Visible',state) |
---|
| 4358 | set(handles.min,'Visible',state) |
---|
| 4359 | set(handles.max,'Visible',state) |
---|
| 4360 | set(handles.umin,'Visible',state) |
---|
| 4361 | set(handles.umax,'Visible',state) |
---|
| 4362 | set(handles.vmin,'Visible',state) |
---|
| 4363 | set(handles.vmax,'Visible',state) |
---|
| 4364 | set(handles.grid_civ1,'Visible',state) |
---|
| 4365 | set(handles.mask_civ1,'Visible',state) |
---|
| 4366 | set(handles.browse_gridciv1,'Visible',state) |
---|
| 4367 | set(handles.get_mask_civ1,'Visible',state) |
---|
| 4368 | set(handles.parameters,'Visible',state) |
---|
| 4369 | set(handles.grid,'Visible',state) |
---|
| 4370 | set(handles.dx_civ1,'Visible',state) |
---|
| 4371 | set(handles.dy_civ1,'Visible',state) |
---|
| 4372 | set(handles.ImaThreshold,'Visible',state) |
---|
| 4373 | if isequal(state,'off') |
---|
| 4374 | set(handles.MinIma,'Visible','off') |
---|
| 4375 | set(handles.MaxIma,'Visible','off') |
---|
| 4376 | set(handles.ImaThreshold,'Value',0) |
---|
| 4377 | end |
---|
| 4378 | set(handles.dx_civ1_title,'Visible',state) |
---|
| 4379 | set(handles.dy_civ1_title,'Visible',state) |
---|
| 4380 | set(handles.ImaThreshold_title,'Visible',state) |
---|
| 4381 | set(handles.ib_title,'Visible',state) |
---|
| 4382 | set(handles.is_title,'Visible',state) |
---|
| 4383 | set(handles.shift_title,'Visible',state) |
---|
| 4384 | set(handles.rho_title,'Visible',state) |
---|
| 4385 | |
---|
[12] | 4386 | %------------------------------------------------------------------------ |
---|
[2] | 4387 | function enable_fix1(handles,state) |
---|
[12] | 4388 | %------------------------------------------------------------------------ |
---|
[2] | 4389 | if isequal(state,0) |
---|
| 4390 | state='off'; |
---|
| 4391 | end |
---|
| 4392 | if isequal(state,1) |
---|
| 4393 | state='on'; |
---|
| 4394 | end |
---|
| 4395 | if isequal(state,'on') |
---|
| 4396 | set(handles.frame_fix1,'BackgroundColor',[1 1 0]) |
---|
| 4397 | else |
---|
| 4398 | set(handles.frame_fix1,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 4399 | end |
---|
| 4400 | set(handles.REMOVE,'Visible',state) |
---|
| 4401 | set(handles.vec_Fmin2,'Visible',state) |
---|
| 4402 | set(handles.vec_F2,'Visible',state) |
---|
| 4403 | set(handles.vec_F3,'Visible',state) |
---|
| 4404 | set(handles.thresh_vecC,'Visible',state) |
---|
| 4405 | set(handles.thresh_vecC_title,'Visible',state) |
---|
| 4406 | set(handles.thresh_vel,'Visible',state) |
---|
| 4407 | set(handles.thresh_vel_text,'Visible',state) |
---|
| 4408 | set(handles.mask_fix1,'Visible',state) |
---|
| 4409 | set(handles.get_mask_fix1,'Visible',state) |
---|
| 4410 | set(handles.get_ref_fix1,'Visible',state) |
---|
| 4411 | set(handles.ref_fix1,'Visible',state) |
---|
| 4412 | set(handles.inf_sup1,'Visible',state) |
---|
| 4413 | set(handles.field_ref1,'Visible',state) |
---|
| 4414 | |
---|
[12] | 4415 | %------------------------------------------------------------------------ |
---|
[2] | 4416 | function enable_patch1(handles) |
---|
[12] | 4417 | %------------------------------------------------------------------------ |
---|
[2] | 4418 | global patch_new_exe |
---|
| 4419 | set(handles.frame_patch1,'BackgroundColor',[1 1 0]) |
---|
| 4420 | set(handles.rho_patch1,'Visible','on') |
---|
| 4421 | set(handles.rho_text1,'Visible','on') |
---|
| 4422 | set(handles.thresh_patch1,'Visible','on') |
---|
| 4423 | set(handles.thresh_text1,'Visible','on') |
---|
| 4424 | set(handles.subdomain_patch1,'Visible','on') |
---|
| 4425 | set(handles.subdomain_text1,'Visible','on') |
---|
| 4426 | set(handles.nx_patch1,'Visible','on') |
---|
| 4427 | set(handles.ny_patch1,'Visible','on') |
---|
| 4428 | set(handles.nx_patch1_title,'Visible','on') |
---|
| 4429 | set(handles.ny_patch1_title,'Visible','on') |
---|
| 4430 | if (~isequal(patch_new_exe,[]) & ~isequal(patch_new_exe,[])) |
---|
| 4431 | set(handles.test_interp,'Visible','on'); |
---|
| 4432 | end |
---|
| 4433 | set(handles.get_gridpatch1,'Visible','on') |
---|
| 4434 | set(handles.grid_patch1,'string','none'); |
---|
| 4435 | set(handles.grid_patch1,'Visible','on') |
---|
| 4436 | |
---|
[12] | 4437 | %------------------------------------------------------------------------ |
---|
[2] | 4438 | function desable_patch1(handles) |
---|
[12] | 4439 | %------------------------------------------------------------------------ |
---|
[2] | 4440 | set(handles.frame_patch1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4441 | set(handles.rho_patch1,'Visible','off') |
---|
| 4442 | set(handles.rho_text1,'Visible','off') |
---|
| 4443 | set(handles.thresh_patch1,'Visible','off') |
---|
| 4444 | set(handles.thresh_text1,'Visible','off') |
---|
| 4445 | set(handles.subdomain_patch1,'Visible','off') |
---|
| 4446 | set(handles.subdomain_text1,'Visible','off') |
---|
| 4447 | set(handles.nx_patch1,'Visible','off') |
---|
| 4448 | set(handles.ny_patch1,'Visible','off') |
---|
| 4449 | set(handles.nx_patch1_title,'Visible','off') |
---|
| 4450 | set(handles.ny_patch1_title,'Visible','off') |
---|
| 4451 | set(handles.test_interp,'Visible','off') |
---|
| 4452 | set(handles.get_gridpatch1,'Visible','off') |
---|
| 4453 | set(handles.grid_patch1,'Visible','off') |
---|
| 4454 | |
---|
[12] | 4455 | %------------------------------------------------------------------------ |
---|
[2] | 4456 | function enable_civ2(handles,state) |
---|
[12] | 4457 | %------------------------------------------------------------------------ |
---|
[2] | 4458 | if isequal(state,0) |
---|
| 4459 | state='off'; |
---|
| 4460 | end |
---|
| 4461 | if isequal(state,1) |
---|
| 4462 | state='on'; |
---|
| 4463 | end |
---|
| 4464 | if isequal(state,'on') |
---|
| 4465 | set(handles.frame_civ2,'BackgroundColor',[1 1 0]) |
---|
| 4466 | set(handles.frame_para_civ2,'BackgroundColor',[1 1 0]) |
---|
| 4467 | set(handles.frame_grid_civ2,'BackgroundColor',[1 1 0]) |
---|
| 4468 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 4469 | else |
---|
| 4470 | set(handles.frame_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4471 | set(handles.frame_para_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4472 | set(handles.frame_grid_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4473 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4474 | end |
---|
| 4475 | set(handles.ibx_civ2,'Visible',state) |
---|
| 4476 | set(handles.iby_civ2,'Visible',state) |
---|
| 4477 | set(handles.decimal,'Visible',state) |
---|
| 4478 | set(handles.deformation,'Visible',state) |
---|
| 4479 | set(handles.rho_civ2,'Visible',state) |
---|
| 4480 | set(handles.dx_civ2,'Visible',state) |
---|
| 4481 | set(handles.dy_civ2,'Visible',state) |
---|
| 4482 | set(handles.browse_gridciv2,'Visible',state) |
---|
| 4483 | set(handles.get_mask_civ2,'Visible',state) |
---|
| 4484 | set(handles.parameters,'Visible',state) |
---|
| 4485 | set(handles.grid,'Visible',state) |
---|
| 4486 | set(handles.parameters_text,'Visible',state) |
---|
| 4487 | set(handles.grid_text,'Visible',state) |
---|
| 4488 | set(handles.grid_civ2,'Visible',state) |
---|
| 4489 | set(handles.mask_civ2,'Visible',state) |
---|
| 4490 | set(handles.dx_civ2_title,'Visible',state) |
---|
| 4491 | set(handles.dy_civ2_title,'Visible',state) |
---|
| 4492 | set(handles.ibx_civ2_text,'Visible',state) |
---|
| 4493 | set(handles.rho_civ2_title,'Visible',state) |
---|
| 4494 | set(handles.ImaThreshold2,'Visible',state) |
---|
| 4495 | set(handles.ImaThreshold_title2,'Visible',state) |
---|
| 4496 | if isequal(state,'off') |
---|
| 4497 | set(handles.MinIma2,'Visible','off') |
---|
| 4498 | set(handles.MaxIma2,'Visible','off') |
---|
| 4499 | set(handles.ImaThreshold2,'Value',0) |
---|
| 4500 | if isequal(get(handles.FIX2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) |
---|
| 4501 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 4502 | set(handles.subdir_civ2,'Visible','off') |
---|
| 4503 | set(handles.subdir_civ2_text,'Visible','off') |
---|
| 4504 | end |
---|
| 4505 | else |
---|
| 4506 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 4507 | set(handles.subdir_civ2,'Visible','on') |
---|
| 4508 | set(handles.subdir_civ2_text,'Visible','on') |
---|
| 4509 | end |
---|
| 4510 | |
---|
[12] | 4511 | %------------------------------------------------------------------------ |
---|
[2] | 4512 | function enable_fix2(handles) |
---|
[12] | 4513 | %------------------------------------------------------------------------ |
---|
[2] | 4514 | set(handles.frame_fix2,'BackgroundColor',[1 1 0]) |
---|
| 4515 | set(handles.REMOVE2,'Visible','on') |
---|
| 4516 | set(handles.vec_Fmin2_2,'Visible','on') |
---|
| 4517 | set(handles.vec_F4,'Visible','on') |
---|
| 4518 | set(handles.vec_F3_2,'Visible','on') |
---|
| 4519 | set(handles.thresh_vec2C,'Visible','on') |
---|
| 4520 | set(handles.thresh_vec2C_text,'Visible','on') |
---|
| 4521 | set(handles.thresh_vel2,'Visible','on') |
---|
| 4522 | set(handles.thresh_vel2_text,'Visible','on') |
---|
| 4523 | set(handles.mask_fix2,'Visible','on') |
---|
| 4524 | set(handles.get_mask_fix2,'Visible','on') |
---|
| 4525 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 4526 | set(handles.subdir_civ2,'Visible','on') |
---|
| 4527 | set(handles.subdir_civ2_text,'Visible','on') |
---|
| 4528 | set(handles.get_ref_fix2,'Visible','on') |
---|
| 4529 | set(handles.ref_fix2,'Visible','on') |
---|
| 4530 | set(handles.inf_sup2,'Visible','on') |
---|
| 4531 | set(handles.field_ref2,'Visible','on') |
---|
| 4532 | |
---|
[12] | 4533 | %------------------------------------------------------------------------ |
---|
[2] | 4534 | function desable_fix2(handles) |
---|
[12] | 4535 | %------------------------------------------------------------------------ |
---|
[2] | 4536 | set(handles.frame_fix2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4537 | set(handles.REMOVE2,'Visible','off') |
---|
| 4538 | set(handles.vec_Fmin2_2,'Visible','off') |
---|
| 4539 | set(handles.vec_F4,'Visible','off') |
---|
| 4540 | set(handles.vec_F3_2,'Visible','off') |
---|
| 4541 | set(handles.thresh_vec2C,'Visible','off') |
---|
| 4542 | set(handles.thresh_vec2C_text,'Visible','off') |
---|
| 4543 | set(handles.thresh_vel2,'Visible','off') |
---|
| 4544 | set(handles.thresh_vel2_text,'Visible','off') |
---|
| 4545 | set(handles.mask_fix2,'Visible','off') |
---|
| 4546 | set(handles.get_mask_fix2,'Visible','off') |
---|
| 4547 | set(handles.get_ref_fix2,'Visible','off') |
---|
| 4548 | set(handles.ref_fix2,'Visible','off') |
---|
| 4549 | set(handles.inf_sup2,'Visible','off') |
---|
| 4550 | set(handles.field_ref2,'Visible','off') |
---|
| 4551 | if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) |
---|
| 4552 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 4553 | set(handles.subdir_civ2,'Visible','off') |
---|
| 4554 | set(handles.subdir_civ2_text,'Visible','off') |
---|
| 4555 | end |
---|
| 4556 | |
---|
[12] | 4557 | %------------------------------------------------------------------------ |
---|
[2] | 4558 | function enable_patch2(handles) |
---|
[12] | 4559 | %------------------------------------------------------------------------ |
---|
[2] | 4560 | set(handles.frame_patch2,'BackgroundColor',[1 1 0]) |
---|
| 4561 | %set(handles.rho_patch2,'Visible','on') |
---|
| 4562 | set(handles.rho_text2,'Visible','on') |
---|
| 4563 | set(handles.thresh_patch2,'Visible','on') |
---|
| 4564 | set(handles.thresh_text2,'Visible','on') |
---|
| 4565 | set(handles.subdomain_patch2,'Visible','on') |
---|
| 4566 | set(handles.subdomain_text2,'Visible','on') |
---|
| 4567 | set(handles.nx_patch2,'Visible','on') |
---|
| 4568 | set(handles.ny_patch2,'Visible','on') |
---|
| 4569 | set(handles.nx_patch2_title,'Visible','on') |
---|
| 4570 | set(handles.ny_patch2_title,'Visible','on') |
---|
| 4571 | set(handles.get_gridpatch2,'Visible','on') |
---|
| 4572 | set(handles.grid_patch2,'Visible','on') |
---|
| 4573 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 4574 | set(handles.subdir_civ2,'Visible','on') |
---|
| 4575 | set(handles.subdir_civ2_text,'Visible','on') |
---|
| 4576 | |
---|
[12] | 4577 | %------------------------------------------------------------------------ |
---|
[2] | 4578 | function desable_patch2(handles) |
---|
[12] | 4579 | %------------------------------------------------------------------------ |
---|
[2] | 4580 | set(handles.frame_patch2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4581 | set(handles.rho_patch2,'Visible','off') |
---|
| 4582 | set(handles.rho_text2,'Visible','off') |
---|
| 4583 | set(handles.thresh_patch2,'Visible','off') |
---|
| 4584 | set(handles.thresh_text2,'Visible','off') |
---|
| 4585 | set(handles.subdomain_patch2,'Visible','off') |
---|
| 4586 | set(handles.subdomain_text2,'Visible','off') |
---|
| 4587 | set(handles.nx_patch2,'Visible','off') |
---|
| 4588 | set(handles.ny_patch2,'Visible','off') |
---|
| 4589 | set(handles.nx_patch2_title,'Visible','off') |
---|
| 4590 | set(handles.ny_patch2_title,'Visible','off') |
---|
| 4591 | set(handles.get_gridpatch2,'Visible','off') |
---|
| 4592 | set(handles.grid_patch2,'Visible','off') |
---|
| 4593 | if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.FIX2,'Value'),0) |
---|
| 4594 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 4595 | set(handles.subdir_civ2,'Visible','off') |
---|
| 4596 | set(handles.subdir_civ2_text,'Visible','off') |
---|
| 4597 | end |
---|
| 4598 | |
---|
[12] | 4599 | %------------------------------------------------------------------------ |
---|
[2] | 4600 | function enable_pair1(handles,state) |
---|
[12] | 4601 | %------------------------------------------------------------------------ |
---|
[2] | 4602 | set(handles.subdir_civ1,'Visible',state) |
---|
| 4603 | set(handles.list_subdir_civ1,'Visible',state) |
---|
| 4604 | set(handles.SUBDIR_CIV1_txt,'Visible',state) |
---|
| 4605 | set(handles.frame_subdirciv1,'Visible',state) |
---|
| 4606 | set(handles.list_pair_civ1,'Visible',state) |
---|
| 4607 | set(handles.PAIR_txt,'Visible',state) |
---|
[12] | 4608 | %set(handles.dt_display_txt,'Visible',state) |
---|
[2] | 4609 | set(handles.dt_unit,'Visible',state) |
---|
| 4610 | set(handles.PAIR_frame,'Visible',state) |
---|
| 4611 | |
---|
[12] | 4612 | %------------------------------------------------------------------------ |
---|
| 4613 | % --- Read the parameters for civ1 on the interface |
---|
[2] | 4614 | function par=read_param_civ1(handles,file_ima) |
---|
[12] | 4615 | %------------------------------------------------------------------------ |
---|
[2] | 4616 | ibx_val=str2num(get(handles.ibx,'String')); |
---|
| 4617 | par.ibx=num2str(ibx_val); |
---|
| 4618 | iby_val=str2num(get(handles.iby,'String')); |
---|
| 4619 | par.iby=num2str(iby_val); |
---|
| 4620 | isx=get(handles.isx,'String'); |
---|
| 4621 | if isempty(str2num(isx)), isx='41'; set(handles.isx,'String','41'), end; %default |
---|
| 4622 | if str2num(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.isx,'String',num2str(ibx_val+8)); end |
---|
| 4623 | isy=get(handles.isy,'String'); |
---|
| 4624 | if isempty(str2num(isy)), isy='41'; set(handles.isy,'String','41'), end;%default |
---|
| 4625 | if str2num(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.isy,'String',num2str(iby_val+8)); end |
---|
| 4626 | par.isx=get(handles.isx,'String'); |
---|
| 4627 | par.isy=get(handles.isy,'String'); |
---|
| 4628 | par.shiftx=get(handles.shiftx,'String'); |
---|
| 4629 | par.shifty=get(handles.shifty,'String'); |
---|
| 4630 | if isempty(str2num(par.isx)) |
---|
| 4631 | par.isx='41';%default |
---|
| 4632 | set(handles.isx,'String','41'); |
---|
| 4633 | end |
---|
| 4634 | if isempty(str2num(par.isy)) |
---|
| 4635 | par.isy='41'; %default |
---|
| 4636 | set(handles.isy,'String','41'); |
---|
[12] | 4637 | end |
---|
[2] | 4638 | if isempty(str2num(par.shiftx)) |
---|
| 4639 | par.shiftx='0';%default |
---|
| 4640 | set(handles.shiftx,'String','0'); |
---|
[12] | 4641 | end |
---|
[2] | 4642 | if isempty(str2num(par.shifty)) |
---|
| 4643 | par.shifty='0'; %default |
---|
| 4644 | set(handles.shifty,'String','0'); |
---|
[12] | 4645 | end |
---|
| 4646 | par.rho=get(handles.rho,'String'); |
---|
| 4647 | par.dx=get(handles.dx_civ1,'String'); |
---|
| 4648 | par.dy=get(handles.dy_civ1,'String'); |
---|
| 4649 | if isequal(str2num(par.dx),[]) |
---|
| 4650 | if isempty(get(handles.grid_civ1,'String')); |
---|
| 4651 | par.dx='0'; %just read by civ program, not used |
---|
| 4652 | else |
---|
| 4653 | par.dx='20';%default |
---|
| 4654 | set(handles.dx_civ1,'String','20'); |
---|
[2] | 4655 | end |
---|
[12] | 4656 | end |
---|
| 4657 | if isequal(str2num(par.dy),[]) |
---|
| 4658 | if isempty(get(handles.grid_civ1,'String')); |
---|
| 4659 | par.dy='0';%just read by civ program, not used |
---|
| 4660 | else |
---|
| 4661 | par.dy='20';%default |
---|
| 4662 | set(handles.dy_civ1_title,'String','20'); |
---|
[2] | 4663 | end |
---|
[12] | 4664 | end |
---|
| 4665 | par.pxcmx='1'; %velocities are expressed in pixel dispalcement |
---|
| 4666 | par.pxcmy='1'; |
---|
[2] | 4667 | % end |
---|
[12] | 4668 | A=imread(file_ima);%read the first image to get the size |
---|
| 4669 | sizim=size(A); |
---|
| 4670 | par.npx=num2str(sizim(2)); |
---|
| 4671 | par.npy=num2str(sizim(1)); |
---|
| 4672 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 4673 | par.gridname=get(handles.grid_civ1,'String'); |
---|
| 4674 | par.gridflag='y'; |
---|
| 4675 | if isequal(par.gridname,'')| isempty(par.gridname) |
---|
| 4676 | par.gridname='nogrid'; |
---|
| 4677 | par.gridflag='n'; |
---|
| 4678 | end |
---|
| 4679 | |
---|
| 4680 | %------------------------------------------------------------------------ |
---|
[2] | 4681 | function par=read_param_civ2(handles,file_ima) |
---|
[12] | 4682 | %------------------------------------------------------------------------ |
---|
| 4683 | par.ibx=get(handles.ibx_civ2,'String'); |
---|
| 4684 | par.iby=get(handles.iby_civ2,'String'); |
---|
| 4685 | par.rho=get(handles.rho_civ2,'String'); |
---|
| 4686 | par.decimal=int2str(get(handles.decimal,'Value')); |
---|
| 4687 | par.deformation=int2str(get(handles.deformation,'Value')); |
---|
| 4688 | par.dx=get(handles.dx_civ2,'String'); |
---|
| 4689 | par.dy=get(handles.dy_civ2,'String'); |
---|
| 4690 | if isequal(str2num(par.dx),[]) |
---|
| 4691 | if isempty(get(handles.grid_civ2,'String')); |
---|
| 4692 | par.dx='0'; %just read by civ program, not used |
---|
| 4693 | else |
---|
| 4694 | par.dx='20';%default |
---|
| 4695 | set(handles.dx_civ2,'String','20'); |
---|
[2] | 4696 | end |
---|
[12] | 4697 | end |
---|
| 4698 | if isequal(str2num(par.dy),[]) |
---|
| 4699 | if isempty(get(handles.grid_civ2,'String')); |
---|
| 4700 | par.dy='0';%just read by civ program, not used |
---|
| 4701 | else |
---|
| 4702 | par.dy='20';%default |
---|
| 4703 | set(handles.dy_civ2,'String','20'); |
---|
[2] | 4704 | end |
---|
[12] | 4705 | end |
---|
| 4706 | par.pxcmx='1'; |
---|
| 4707 | par.pxcmy='1'; |
---|
| 4708 | A=imread(file_ima);%read the first image to get the size |
---|
| 4709 | sizim=size(A); |
---|
| 4710 | par.npx=num2str(sizim(2)); |
---|
| 4711 | par.npy=num2str(sizim(1)); |
---|
| 4712 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 4713 | par.gridname=get(handles.grid_civ2,'String'); |
---|
| 4714 | par.gridflag='y'; |
---|
| 4715 | if isequal(par.gridname,'')| isempty(par.gridname) |
---|
| 4716 | par.gridname='nogrid'; |
---|
| 4717 | par.gridflag='n'; |
---|
| 4718 | end |
---|
[2] | 4719 | |
---|
[12] | 4720 | %------------------------------------------------------------------------ |
---|
| 4721 | % --- CIV1 CIV1 CIV1 CIV1 |
---|
[2] | 4722 | function cmd_CIV1=BATCH_CIV1(filename,namelog,par,handles) |
---|
[12] | 4723 | %------------------------------------------------------------------------ |
---|
[2] | 4724 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 4725 | global civ1_exe Civ_exe sge%name of the executable for civ1 calculation |
---|
| 4726 | |
---|
| 4727 | %changes : filename_cmx -> filename ( no extension ) |
---|
| 4728 | |
---|
| 4729 | if isequal(par.Dt,'0') |
---|
| 4730 | par.Dt='1' ;%case of 'displacement' mode |
---|
| 4731 | end |
---|
[12] | 4732 | % |
---|
| 4733 | % textcmx={'############## CMX file';... |
---|
| 4734 | % ['FirstImage ' par.filename_ima_a];... |
---|
| 4735 | % ['LastImage ' par.filename_ima_b];... |
---|
| 4736 | % 'XX' ;... |
---|
| 4737 | % ['Mask ' par.maskflag] ;... |
---|
| 4738 | % ['MaskName ' par.maskname];... |
---|
| 4739 | % ['ImageSize ' par.npx ' ' par.npy];... %VERIFIER CAS GENERAL ? |
---|
| 4740 | % ['CorrelationBoxesSize ' par.ibx ' ' par.iby];... |
---|
| 4741 | % ['SearchBoxeSize ' par.isx ' ' par.isy];... |
---|
| 4742 | % ['RO ' par.rho];... |
---|
| 4743 | % ['GridSpacing ' par.dx ' ' par.dy];... |
---|
| 4744 | % 'XX 1.0';... |
---|
| 4745 | % ['Dt_TO ' par.Dt ' ' par.T0];... |
---|
| 4746 | % ['PixCmXY ' par.pxcmx ' ' par.pxcmy];... |
---|
| 4747 | % 'XX 1';... |
---|
| 4748 | % ['ShiftXY ' par.shiftx ' ' par.shifty];... |
---|
| 4749 | % ['Grid ' par.gridflag];... |
---|
| 4750 | % ['GridName ' par.gridname] ;... |
---|
| 4751 | % 'XX 85';... |
---|
| 4752 | % 'XX 1.0';... |
---|
| 4753 | % 'XX 1.0';... |
---|
| 4754 | % 'Hart 1';... |
---|
| 4755 | % 'DecimalShift 0';... |
---|
| 4756 | % 'Deformation 0';... |
---|
| 4757 | % 'CorrelationMin 0';... |
---|
| 4758 | % 'IntensityMin 0';... |
---|
| 4759 | % 'SeuilImage n';... |
---|
| 4760 | % 'SeuilImageValues 0 4096';... |
---|
| 4761 | % ['ImageToUse ' par.term_a ' ' par.term_b];... % VERIFIER ? |
---|
| 4762 | % 'ImageUsedBefore null null'}; |
---|
| 4763 | % |
---|
| 4764 | % textout=char(textcmx); |
---|
[2] | 4765 | |
---|
[12] | 4766 | fid=fopen([filename '.cmx'],'w'); |
---|
| 4767 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
| 4768 | fprintf(fid, ['FirstImage ' par.filename_ima_a '\n' ]); |
---|
| 4769 | fprintf(fid, ['LastImage ' par.filename_ima_b '\n' ]); |
---|
| 4770 | fprintf(fid, ['XX' '\n' ]); |
---|
| 4771 | fprintf(fid, ['Mask ' par.maskflag '\n' ]); |
---|
| 4772 | fprintf(fid, ['MaskName ' par.maskname '\n' ]); |
---|
| 4773 | fprintf(fid, ['ImageSize ' par.npx ' ' par.npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 4774 | fprintf(fid, ['CorrelationBoxesSize ' par.ibx ' ' par.iby '\n' ]); |
---|
| 4775 | fprintf(fid, ['SearchBoxeSize ' par.isx ' ' par.isy '\n' ]); |
---|
| 4776 | fprintf(fid, ['RO ' par.rho '\n' ]); |
---|
| 4777 | fprintf(fid, ['GridSpacing ' par.dx ' ' par.dy '\n' ]); |
---|
| 4778 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4779 | fprintf(fid, ['Dt_TO ' par.Dt ' ' par.T0 '\n' ]); |
---|
| 4780 | fprintf(fid, ['PixCmXY ' par.pxcmx ' ' par.pxcmy '\n' ]); |
---|
| 4781 | fprintf(fid, ['XX 1' '\n' ]); |
---|
| 4782 | fprintf(fid, ['ShiftXY ' par.shiftx ' ' par.shifty '\n' ]); |
---|
| 4783 | fprintf(fid, ['Grid ' par.gridflag '\n' ]); |
---|
| 4784 | fprintf(fid, ['GridName ' par.gridname '\n' ]); |
---|
| 4785 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 4786 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4787 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4788 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
| 4789 | fprintf(fid, [ 'DecimalShift 0' '\n' ]); |
---|
| 4790 | fprintf(fid, ['Deformation 0' '\n' ]); |
---|
| 4791 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 4792 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 4793 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 4794 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
| 4795 | fprintf(fid, ['ImageToUse ' par.term_a ' ' par.term_b '\n' ]); % VERIFIER ? |
---|
| 4796 | fprintf(fid, ['ImageUsedBefore null null' '\n' ]); |
---|
| 4797 | fclose(fid); |
---|
| 4798 | |
---|
| 4799 | if sge |
---|
| 4800 | cmd_CIV1=[civ1_exe ' -f ' filename '.cmx' ]; % redirect standard output to the log file |
---|
| 4801 | else |
---|
| 4802 | cmd_CIV1=[civ1_exe ' -f ' filename_cmx ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
| 4803 | end |
---|
| 4804 | if(isunix) |
---|
| 4805 | [Rootbat,Filebat,extbat]=fileparts(namelog); |
---|
| 4806 | ncName=fullfile(Rootbat,[ Filebat '.nc']); |
---|
| 4807 | cmd_CIV1=[cmd_CIV1 '\n' 'mv ' namelog ' ' namelog '.civ1.log' '\n' 'chmod g+w ' ncName]; |
---|
| 4808 | else |
---|
| 4809 | cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y ' namelog ' ' namelog '.civ1.log']; |
---|
| 4810 | end |
---|
[2] | 4811 | |
---|
[12] | 4812 | %------------------------------------------------------------------------ |
---|
| 4813 | % --- CIV1 Unified |
---|
[2] | 4814 | function xml_civ1_parameters=BATCH_CIV1_Unified(filename,namelog,par) |
---|
[12] | 4815 | %------------------------------------------------------------------------ |
---|
[2] | 4816 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 4817 | global civ1_exe Civ_exe%name of the executable for civ1 calculation |
---|
| 4818 | |
---|
| 4819 | civ1.image1=par.filename_ima_a; |
---|
| 4820 | civ1.image2=par.filename_ima_b; |
---|
| 4821 | civ1.imageSize_X=par.npx; |
---|
| 4822 | civ1.imageSize_Y=par.npy; |
---|
| 4823 | civ1.outputFileName=[filename '.nc']; |
---|
| 4824 | civ1.correlationBoxesSize_X=par.ibx; |
---|
| 4825 | civ1.correlationBoxesSize_Y=par.iby; |
---|
| 4826 | civ1.searchBoxesSize_X=par.isx; |
---|
| 4827 | civ1.searchBoxesSize_Y=par.isy; |
---|
| 4828 | civ1.globalShift_X=par.shiftx; |
---|
| 4829 | civ1.globalShift_Y=par.shifty; |
---|
| 4830 | civ1.ro=par.rho; |
---|
| 4831 | civ1.hart='y'; |
---|
| 4832 | if isequal(par.gridflag,'y') |
---|
| 4833 | civ1.grid=par.gridname; |
---|
| 4834 | else |
---|
| 4835 | civ1.grid='n'; |
---|
| 4836 | civ1.gridSpacing_X=par.dx; |
---|
| 4837 | civ1.gridSpacing_Y=par.dy; |
---|
| 4838 | end |
---|
| 4839 | if isequal(par.maskflag,'y') |
---|
| 4840 | civ1.mask=par.maskname; |
---|
| 4841 | end |
---|
| 4842 | civ1.dt=par.Dt; |
---|
| 4843 | civ1.unit='pixel'; |
---|
| 4844 | civ1.absolut_time_T0=par.T0; |
---|
| 4845 | civ1.pixcmx=par.pxcmx; |
---|
| 4846 | civ1.pixcmy=par.pxcmy; |
---|
| 4847 | civ1.convectFlow='n'; |
---|
| 4848 | |
---|
| 4849 | xml_civ1_parameters=civ1; |
---|
[12] | 4850 | |
---|
| 4851 | %------------------------------------------------------------------------ |
---|
| 4852 | % --- CIV2 Unified |
---|
[2] | 4853 | function civ2=BATCH_CIV2_Unified(filename,namelog,par) |
---|
[12] | 4854 | %------------------------------------------------------------------------ |
---|
[2] | 4855 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 4856 | global civ2_exe Civ_exe%name of the executable for civ1 calculation |
---|
| 4857 | |
---|
| 4858 | civ2.image1=par.filename_ima_a; |
---|
| 4859 | civ2.image2=par.filename_ima_b; |
---|
| 4860 | civ2.imageSize_X=par.npx; |
---|
| 4861 | civ2.imageSize_Y=par.npy; |
---|
| 4862 | civ2.inputFileName=[par.filename_nc1 '.nc']; |
---|
| 4863 | civ2.outputFileName=[filename '.nc']; |
---|
| 4864 | civ2.correlationBoxesSize_X=par.ibx; |
---|
| 4865 | civ2.correlationBoxesSize_Y=par.iby; |
---|
| 4866 | civ2.ro=par.rho; |
---|
| 4867 | %civ2.decimalShift=par.decimal; |
---|
| 4868 | %civ2.deformation=par.deformation; |
---|
| 4869 | if isequal(par.decimal,'1') |
---|
| 4870 | civ2.decimalShift='y'; |
---|
| 4871 | else |
---|
| 4872 | civ2.decimalShift='n'; |
---|
| 4873 | end |
---|
| 4874 | if isequal(par.deformation,'1') |
---|
| 4875 | civ2.deformation='y'; |
---|
| 4876 | else |
---|
| 4877 | civ2.deformation='n'; |
---|
| 4878 | end |
---|
| 4879 | if isequal(par.gridflag,'y') |
---|
| 4880 | civ2.grid=par.gridname; |
---|
| 4881 | else |
---|
| 4882 | civ2.grid='n'; |
---|
| 4883 | civ2.gridSpacing_X=par.dx; |
---|
| 4884 | civ2.gridSpacing_Y=par.dy; |
---|
| 4885 | end |
---|
| 4886 | civ2.gridSpacing_X='10'; |
---|
| 4887 | civ2.gridSpacing_Y='10';%NOTE: faut mettre gridSpacing pourque ca tourne, meme si c'est la grille qui est utilisee |
---|
| 4888 | if isequal(par.maskflag,'y') |
---|
| 4889 | civ2.mask=par.maskname; |
---|
| 4890 | else |
---|
| 4891 | civ2.mask='n'; |
---|
| 4892 | end |
---|
| 4893 | civ2.dt=par.Dt; |
---|
| 4894 | civ2.unit='pixel'; |
---|
| 4895 | civ2.absolut_time_T0=par.T0; |
---|
| 4896 | civ2.pixcmx=par.pxcmx; |
---|
| 4897 | civ2.pixcmy=par.pxcmy; |
---|
| 4898 | civ2.convectFlow='n'; |
---|
| 4899 | civ2.pixcmx=par.pxcmx; |
---|
| 4900 | civ2.pixcmy=par.pxcmy; |
---|
| 4901 | civ2.convectFlow='n'; |
---|
| 4902 | |
---|
[12] | 4903 | %------------------------------------------------------------------------ |
---|
| 4904 | % --- CIV2 CIV2 CIV2 CIV2 |
---|
[2] | 4905 | function cmd_CIV2=BATCH_CIV2(filename_cmx,namelog,par) |
---|
[12] | 4906 | %------------------------------------------------------------------------ |
---|
[2] | 4907 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 4908 | global civ2_exe sge%name of the executable for civ1 calculation |
---|
| 4909 | if isequal(par.Dt,'0') |
---|
| 4910 | par.Dt='1' ;%case of 'displacement' mode |
---|
| 4911 | end |
---|
[12] | 4912 | textcmx=['############## CMX file' '\n'... |
---|
| 4913 | ['FirstImage ' par.filename_ima_a] '\n'... |
---|
| 4914 | ['LastImage ' par.filename_ima_b] '\n'... |
---|
| 4915 | 'XX' '\n'... |
---|
| 4916 | ['Mask ' par.maskflag] '\n'... |
---|
| 4917 | ['MaskName ' par.maskname] '\n'... |
---|
| 4918 | ['ImageSize ' par.npx ' ' par.npy] '\n'... |
---|
| 4919 | ['CorrelationBoxesSize ' par.ibx ' ' par.iby] '\n'... |
---|
| 4920 | ['SearchBoxeSize ' par.ibx ' ' par.iby] '\n'... |
---|
| 4921 | ['RO ' par.rho] '\n'... |
---|
| 4922 | ['GridSpacing ' par.dx ' ' par.dy] '\n'... |
---|
| 4923 | 'XX 1.0' '\n'... |
---|
| 4924 | ['Dt_TO ' par.Dt ' ' par.T0] '\n'... |
---|
| 4925 | ['PixCmXY ' par.pxcmx ' ' par.pxcmy] '\n'... |
---|
| 4926 | 'XX 1' '\n'... |
---|
| 4927 | ['ShiftXY 0 0'] '\n'... |
---|
| 4928 | ['Grid ' par.gridflag] '\n'... |
---|
| 4929 | ['GridName ' par.gridname] '\n'... |
---|
| 4930 | 'XX 85' '\n'... |
---|
| 4931 | 'XX 1.0' '\n'... |
---|
| 4932 | 'XX 1.0' '\n'... |
---|
| 4933 | 'Hart 1' '\n'... |
---|
| 4934 | ['DecimalShift ' par.decimal] '\n'... |
---|
| 4935 | ['Deformation ' par.deformation] '\n'... |
---|
| 4936 | 'CorrelationMin 0' '\n'... |
---|
| 4937 | 'IntensityMin 0' '\n'... |
---|
| 4938 | 'SeuilImage n' '\n'... |
---|
| 4939 | 'SeuilImageValues 0 4096' '\n'... |
---|
| 4940 | ['ImageToUse ' par.term_a ' ' par.term_b] '\n'... % VERIFIER ? |
---|
| 4941 | ['ImageUsedBefore ' par.filename_nc1]]; |
---|
| 4942 | textout=char(textcmx); |
---|
| 4943 | fid=fopen([filename_cmx '2'],'w'); |
---|
| 4944 | fprintf(fid,textout); |
---|
| 4945 | fclose(fid) |
---|
| 4946 | if sge |
---|
| 4947 | cmd_CIV2=[civ2_exe ' -f ' filename_cmx ]; % redirect standard output to the log file |
---|
| 4948 | else |
---|
| 4949 | cmd_CIV2=[civ2_exe ' -f ' filename_cmx ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
| 4950 | end |
---|
[2] | 4951 | |
---|
[12] | 4952 | %------------------------------------------------------------------------ |
---|
[2] | 4953 | % --- Executes on button press in HELP. |
---|
| 4954 | function HELP_Callback(hObject, eventdata, handles) |
---|
[12] | 4955 | %------------------------------------------------------------------------ |
---|
[2] | 4956 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
| 4957 | pathelp=fileparts(path_to_uvmat); |
---|
| 4958 | helpfile=fullfile(pathelp,'UVMAT_DOC','uvmat_doc.html'); |
---|
| 4959 | if isempty(dir(helpfile)), errordlg('Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC') |
---|
| 4960 | else |
---|
| 4961 | web([helpfile '#civ']) |
---|
| 4962 | end |
---|
| 4963 | |
---|
[12] | 4964 | %------------------------------------------------------------------------ |
---|
[2] | 4965 | %--read images and convert them to the uint16 format used for PIV |
---|
| 4966 | function A=read_image(filename,nom_type,npx,npy,num); |
---|
[12] | 4967 | %------------------------------------------------------------------------ |
---|
[2] | 4968 | %npx, npy are the dimensions needed for the raw SMD images |
---|
| 4969 | %num is the view number needed for an avi movie |
---|
| 4970 | if isequal(nom_type,'avi') |
---|
| 4971 | mov=aviread(filename,num); |
---|
| 4972 | A=frame2im(mov(1)); |
---|
| 4973 | A=sum(double(A),3); |
---|
| 4974 | A=uint16(A); |
---|
| 4975 | elseif isequal(nom_type,'raw_SMD') |
---|
| 4976 | [fid,message]=fopen(filename,'r'); |
---|
| 4977 | B=fread(fid,Inf,'int16',0,'ieee-le');%read 16 bit binary file |
---|
| 4978 | A=(reshape(B,npx,npy))'; %remplissage ligne par ligne avec une matrice colonne ? transposer(uB) pour avoir une matrice ligne |
---|
| 4979 | A=uint16(A); |
---|
| 4980 | fclose(fid); |
---|
| 4981 | else |
---|
| 4982 | A=imread(filename); |
---|
| 4983 | siz=size(A); |
---|
| 4984 | if length(siz)==3;%color images |
---|
| 4985 | A=sum(double(A),3); |
---|
| 4986 | end |
---|
| 4987 | A=uint16(A); |
---|
| 4988 | end |
---|
| 4989 | |
---|
[12] | 4990 | % %---------------------------------------------------------------- |
---|
| 4991 | % %Executes on carriage return on the time interval dt |
---|
| 4992 | % %---------------------------------------------------------------- |
---|
| 4993 | % function dt_Callback(hObject, eventdata, handles) |
---|
| 4994 | % %determine the set of times and possible intervals for CIV |
---|
| 4995 | % % answer=inputdlg('time interval between images?'); |
---|
| 4996 | % dt=(1/1000)*str2num(get(handles.dt,'String')); |
---|
| 4997 | % nbfield=str2num(get(handles.nb_field,'String')); %last image number selected in the processing series |
---|
| 4998 | % time=(dt*[0:nbfield-1])'; |
---|
| 4999 | % % set(handles.incr_i,'UserData',dt);%store the time interval between successive images |
---|
| 5000 | % set(handles.displ_filebase,'UserData',time); %store the set of times |
---|
| 5001 | % for index=1:min(nbfield-1,200) |
---|
| 5002 | % displ_num(1,index)=1; |
---|
| 5003 | % displ_num(2,index)=1; |
---|
| 5004 | % displ_num(3,index)=-floor(index/2); |
---|
| 5005 | % displ_num(4,index)=ceil(index/2); |
---|
| 5006 | % end |
---|
| 5007 | % set(handles.list_pair_civ1,'Value',1); |
---|
| 5008 | % set(handles.list_pair_civ1,'UserData',displ_num); |
---|
| 5009 | % set(handles.list_pair_civ2,'Value',1); |
---|
| 5010 | % %update the list of time intervals |
---|
| 5011 | % find_netcpair_civ1(hObject, eventdata, handles) |
---|
| 5012 | % find_netcpair_civ2(hObject, eventdata, handles) |
---|
| 5013 | |
---|
| 5014 | %------------------------------------------------------------------------ |
---|
[2] | 5015 | function ref_i_Callback(hObject, eventdata, handles) |
---|
[12] | 5016 | %------------------------------------------------------------------------ |
---|
[2] | 5017 | mode_list=get(handles.mode,'String'); |
---|
| 5018 | mode_value=get(handles.mode,'Value'); |
---|
| 5019 | mode=mode_list{mode_value}; |
---|
[12] | 5020 | %if isequal(get(handles.CIV1,'Value'),0)|| isequal(mode,'series(Di)') |
---|
[2] | 5021 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
[12] | 5022 | %end |
---|
| 5023 | if isequal(mode,'series(Di)') || ...% we do patch2 only |
---|
[2] | 5024 | (get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0) |
---|
| 5025 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 5026 | end |
---|
| 5027 | |
---|
[12] | 5028 | %------------------------------------------------------------------------ |
---|
[2] | 5029 | function ref_j_Callback(hObject, eventdata, handles) |
---|
[12] | 5030 | %------------------------------------------------------------------------ |
---|
[2] | 5031 | mode_list=get(handles.mode,'String'); |
---|
| 5032 | mode_value=get(handles.mode,'Value'); |
---|
| 5033 | mode=mode_list{mode_value}; |
---|
| 5034 | if isequal(get(handles.CIV1,'Value'),0)| isequal(mode,'series(Dj)') |
---|
| 5035 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
| 5036 | end |
---|
| 5037 | if isequal(mode,'series(Dj)') | ... |
---|
| 5038 | (get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0) |
---|
| 5039 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 5040 | end |
---|
[12] | 5041 | |
---|
| 5042 | %------------------------------------------------------------------------ |
---|
[2] | 5043 | % --- Executes on button press in compare. |
---|
| 5044 | function compare_Callback(hObject, eventdata, handles) |
---|
[12] | 5045 | %------------------------------------------------------------------------ |
---|
[2] | 5046 | test=get(handles.compare,'Value'); |
---|
| 5047 | if test==2 || test==3 |
---|
| 5048 | filebase=get(handles.displ_filebase,'String'); |
---|
| 5049 | browse=get(handles.browse_root,'Userdata'); |
---|
| 5050 | browse.nom_type_ima1=browse.nom_type_ima; |
---|
| 5051 | set(handles.browse_root,'UserData',browse); |
---|
| 5052 | set(handles.sub_txt,'Visible','on') |
---|
| 5053 | set(handles.displ_filebase2,'Visible','On');%mkes the second file input window visible |
---|
| 5054 | mode_store=get(handles.mode,'String');%get the present 'mode' |
---|
| 5055 | set(handles.compare,'UserData',mode_store);%store the mode display |
---|
| 5056 | set(handles.mode,'Visible','off') |
---|
| 5057 | if test==2 |
---|
| 5058 | set(handles.mode,'Visible','off') |
---|
| 5059 | else |
---|
| 5060 | set(handles.mode,'Visible','on') |
---|
| 5061 | end |
---|
| 5062 | |
---|
| 5063 | % open an image file with the browser |
---|
| 5064 | ind_opening=1;%default |
---|
| 5065 | browse.incr_pair=[0 0]; %default |
---|
| 5066 | oldfile=get(handles.displ_filebase,'String'); |
---|
| 5067 | menu={'*.xml;*.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ... |
---|
| 5068 | '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc', '.nc files';... |
---|
| 5069 | '*.*', 'All Files (*.*)'}; |
---|
| 5070 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile); |
---|
| 5071 | fileinput=[PathName FileName];%complete file name |
---|
| 5072 | sizf=size(fileinput); |
---|
| 5073 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
| 5074 | [path,name,ext]=fileparts(fileinput); |
---|
| 5075 | [path1]=fileparts(filebase); |
---|
| 5076 | if ~strcmp(path1,path) |
---|
| 5077 | msgbox_uvmat('ERROR','The two input image series must be in the same directory') |
---|
| 5078 | return |
---|
| 5079 | end |
---|
| 5080 | set(handles.displ_filebase2,'String',name); |
---|
| 5081 | [RootPath,RootFile,field_count,str2,str_a,str_b,xx,nom_type,subdir]=name2display(name); |
---|
| 5082 | browse=get(handles.browse_root,'UserData'); |
---|
| 5083 | browse.nom_type_ima_1=nom_type; |
---|
| 5084 | set(handles.browse_root,'UserData',browse) |
---|
| 5085 | |
---|
| 5086 | %check image extension |
---|
| 5087 | if ~strcmp(ext,get(handles.ext_ima,'String')) |
---|
| 5088 | msgbox_uvmat('ERROR','The two input image series must have the same extenion name') |
---|
| 5089 | return |
---|
| 5090 | end |
---|
| 5091 | |
---|
| 5092 | %check image size |
---|
| 5093 | A=imread(fileinput); |
---|
| 5094 | npxy=get(handles.ext_ima,'UserData'); |
---|
| 5095 | if ~isequal(npxy(1),size(A,1))|| ~isequal(npxy(2),size(A,2)) |
---|
| 5096 | msgbox_uvmat('ERROR','The two input image series must have the same size') |
---|
| 5097 | return |
---|
| 5098 | end |
---|
| 5099 | else |
---|
| 5100 | set(handles.mode,'Visible','on') |
---|
| 5101 | set(handles.displ_filebase2,'Visible','Off'); |
---|
| 5102 | set(handles.sub_txt,'Visible','off') |
---|
| 5103 | set(handles.displ_filebase2,'String',[]); |
---|
| 5104 | mode_store=get(handles.compare,'UserData'); |
---|
| 5105 | set(handles.mode,'String',mode_store) |
---|
| 5106 | set(handles.test_stereo1,'Value',0) |
---|
| 5107 | set(handles.test_stereo2,'Value',0) |
---|
| 5108 | end |
---|
| 5109 | mode_Callback(hObject, eventdata, handles) |
---|
| 5110 | |
---|
[12] | 5111 | %------------------------------------------------------------------------ |
---|
[2] | 5112 | % --- Executes on button press in get_ref_fix1. |
---|
| 5113 | function get_ref_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 5114 | %------------------------------------------------------------------------ |
---|
[2] | 5115 | filebase=get(handles.displ_filebase,'String'); |
---|
| 5116 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 5117 | {'*.nc', ' (*.nc)'; |
---|
| 5118 | '*.nc', 'netcdf files '; ... |
---|
| 5119 | '*.*', 'All Files (*.*)'}, ... |
---|
| 5120 | 'Pick a file',filebase); |
---|
| 5121 | |
---|
| 5122 | fileinput=[PathName FileName]; |
---|
| 5123 | sizf=size(fileinput); |
---|
| 5124 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
| 5125 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 5126 | ref.filebase=fullfile(Path,File); |
---|
| 5127 | ref.num_a=stra2num(str_a); |
---|
| 5128 | ref.num_b=stra2num(str_b); |
---|
| 5129 | ref.num1=str2num(field_count); |
---|
| 5130 | ref.num2=str2num(str2); |
---|
| 5131 | browse=[];%initialisation |
---|
| 5132 | if ~isequal(ref.ext,'.nc') |
---|
| 5133 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
| 5134 | return |
---|
| 5135 | end |
---|
| 5136 | set(handles.ref_fix1,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
| 5137 | set(handles.ref_fix1,'UserData',ref) |
---|
| 5138 | menu_field{1}='civ1'; |
---|
| 5139 | Data=nc2struct(fileinput,[]); |
---|
| 5140 | if isfield(Data,'patch') & isequal(Data.patch,1) |
---|
| 5141 | menu_field{2}='filter1'; |
---|
| 5142 | end |
---|
| 5143 | if isfield(Data,'civ2') & isequal(Data.civ2,1) |
---|
| 5144 | menu_field{3}='civ2'; |
---|
| 5145 | end |
---|
| 5146 | if isfield(Data,'patch2') & isequal(Data.patch2,1) |
---|
| 5147 | menu_field{4}='filter2'; |
---|
| 5148 | end |
---|
| 5149 | set(handles.field_ref1,'String',menu_field); |
---|
| 5150 | set(handles.field_ref1,'Value',length(menu_field)); |
---|
| 5151 | set(handles.inf_sup1,'Value',2); |
---|
| 5152 | set(handles.thresh_vel,'String','1');%default threshold |
---|
| 5153 | set(handles.ref_fix1,'Enable','on') |
---|
[12] | 5154 | |
---|
| 5155 | %------------------------------------------------------------------------ |
---|
[2] | 5156 | % --- Executes on button press in get_ref_fix2. |
---|
| 5157 | function get_ref_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 5158 | %------------------------------------------------------------------------ |
---|
[2] | 5159 | if isequal(get(handles.get_ref_fix2,'Value'),1) |
---|
| 5160 | filebase=get(handles.displ_filebase,'String'); |
---|
| 5161 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 5162 | {'*.nc', ' (*.nc)'; |
---|
| 5163 | '*.nc', 'netcdf files '; ... |
---|
| 5164 | '*.*', 'All Files (*.*)'}, ... |
---|
| 5165 | 'Pick a file',filebase); |
---|
| 5166 | fileinput=[PathName FileName]; |
---|
| 5167 | sizf=size(fileinput); |
---|
| 5168 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
| 5169 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 5170 | ref.filebase=fullfile(Path,File); |
---|
| 5171 | ref.num_a=stra2num(str_a); |
---|
| 5172 | ref.num_b=stra2num(str_b); |
---|
| 5173 | ref.num1=str2num(field_count); |
---|
| 5174 | ref.num2=str2num(str2); |
---|
| 5175 | browse=[];%initialisation |
---|
| 5176 | if ~isequal(ref.ext,'.nc') |
---|
| 5177 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
| 5178 | return |
---|
| 5179 | end |
---|
| 5180 | set(handles.ref_fix2,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
| 5181 | set(handles.ref_fix2,'UserData',ref) |
---|
| 5182 | menu_field{1}='civ1'; |
---|
| 5183 | Data=nc2struct(fileinput,[]); |
---|
| 5184 | if isfield(Data,'patch') & isequal(Data.patch,1) |
---|
| 5185 | menu_field{2}='filter1'; |
---|
| 5186 | end |
---|
| 5187 | if isfield(Data,'civ2') & isequal(Data.civ2,1) |
---|
| 5188 | menu_field{3}='civ2'; |
---|
| 5189 | end |
---|
| 5190 | if isfield(Data,'patch2') & isequal(Data.patch2,1) |
---|
| 5191 | menu_field{4}='filter2'; |
---|
| 5192 | end |
---|
| 5193 | set(handles.field_ref2,'String',menu_field); |
---|
| 5194 | set(handles.field_ref2,'Value',length(menu_field)); |
---|
| 5195 | set(handles.inf_sup2,'Value',2); |
---|
| 5196 | set(handles.thresh_vel2,'String','1');%default threshold |
---|
| 5197 | set(handles.ref_fix2,'Enable','on') |
---|
| 5198 | set(handles.ref_fix2,'Visible','on') |
---|
| 5199 | set(handles.field_ref2,'Visible','on') |
---|
| 5200 | else |
---|
| 5201 | set(handles.ref_fix2,'Visible','off') |
---|
| 5202 | set(handles.field_ref2,'Visible','off') |
---|
| 5203 | end |
---|
| 5204 | |
---|
[12] | 5205 | %------------------------------------------------------------------------ |
---|
[2] | 5206 | function ref_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 5207 | %------------------------------------------------------------------------ |
---|
| 5208 | set(handles.inf_sup1,'Value',1); |
---|
| 5209 | set(handles.field_ref1,'Value',1) |
---|
| 5210 | set(handles.field_ref1,'String',{' '}) |
---|
| 5211 | set(handles.ref_fix1,'UserData',[]); |
---|
| 5212 | set(handles.ref_fix1,'String',''); |
---|
| 5213 | set(handles.thresh_vel1,'String','0'); |
---|
[2] | 5214 | |
---|
[12] | 5215 | %------------------------------------------------------------------------ |
---|
[2] | 5216 | function ref_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 5217 | %------------------------------------------------------------------------ |
---|
| 5218 | set(handles.inf_sup2,'Value',1); |
---|
| 5219 | set(handles.field_ref2,'Value',1) |
---|
| 5220 | set(handles.field_ref2,'String',{' '}) |
---|
| 5221 | set(handles.ref_fix2,'UserData',[]); |
---|
| 5222 | set(handles.ref_fix2,'String',''); |
---|
| 5223 | set(handles.thresh_vel2,'String','0'); |
---|
[2] | 5224 | |
---|
[12] | 5225 | %------------------------------------------------------------------------ |
---|
[2] | 5226 | % transform letters to numbers |
---|
| 5227 | function numres=stra2num(str) |
---|
[12] | 5228 | %------------------------------------------------------------------------ |
---|
[2] | 5229 | numres=double(str)-96; |
---|
| 5230 | if double(str) >= 48 & double(str) <= 57 % = 1 for numbers |
---|
| 5231 | numres=str2num(str); |
---|
| 5232 | end |
---|
| 5233 | |
---|
[12] | 5234 | %------------------------------------------------------------------------ |
---|
[2] | 5235 | % --- Executes on button press in test_stereo1. |
---|
| 5236 | function test_stereo1_Callback(hObject, eventdata, handles) |
---|
[12] | 5237 | %------------------------------------------------------------------------ |
---|
[2] | 5238 | if isequal(get(handles.test_stereo1,'Value'),0) |
---|
| 5239 | set(handles.subdomain_patch1,'Visible','on') |
---|
| 5240 | set(handles.rho_patch1,'Visible','on') |
---|
| 5241 | else |
---|
| 5242 | set(handles.subdomain_patch1,'Visible','off') |
---|
| 5243 | set(handles.rho_patch1,'Visible','off') |
---|
| 5244 | end |
---|
| 5245 | |
---|
[12] | 5246 | %------------------------------------------------------------------------ |
---|
[2] | 5247 | % --- Executes on button press in test_stereo2. |
---|
| 5248 | function test_stereo2_Callback(hObject, eventdata, handles) |
---|
[12] | 5249 | %------------------------------------------------------------------------ |
---|
[2] | 5250 | if isequal(get(handles.test_stereo2,'Value'),0) |
---|
| 5251 | set(handles.subdomain_patch2,'Visible','on') |
---|
| 5252 | set(handles.rho_patch2,'Visible','on') |
---|
| 5253 | else |
---|
| 5254 | set(handles.subdomain_patch2,'Visible','off') |
---|
| 5255 | set(handles.rho_patch2,'Visible','off') |
---|
| 5256 | end |
---|
| 5257 | |
---|
[12] | 5258 | %------------------------------------------------------------------------ |
---|
[2] | 5259 | % --- Executes on button press in ImaThreshold. |
---|
| 5260 | function ImaThreshold_Callback(hObject, eventdata, handles) |
---|
[12] | 5261 | %------------------------------------------------------------------------ |
---|
[2] | 5262 | if isequal(get(handles.ImaThreshold,'Value'),1) |
---|
| 5263 | set(handles.MinIma,'Visible','on') |
---|
| 5264 | set(handles.MaxIma,'Visible','on') |
---|
| 5265 | else |
---|
| 5266 | set(handles.MinIma,'Visible','off') |
---|
| 5267 | set(handles.MaxIma,'Visible','off') |
---|
| 5268 | end |
---|
| 5269 | |
---|
[12] | 5270 | %------------------------------------------------------------------------ |
---|
[2] | 5271 | % --- Executes on button press in ImaThreshold2. |
---|
| 5272 | function ImaThreshold2_Callback(hObject, eventdata, handles) |
---|
[12] | 5273 | %------------------------------------------------------------------------ |
---|
[2] | 5274 | if isequal(get(handles.ImaThreshold2,'Value'),1) |
---|
| 5275 | set(handles.MinIma2,'Visible','on') |
---|
| 5276 | set(handles.MaxIma2,'Visible','on') |
---|
| 5277 | else |
---|
| 5278 | set(handles.MinIma2,'Visible','off') |
---|
| 5279 | set(handles.MaxIma2,'Visible','off') |
---|
| 5280 | end |
---|
| 5281 | |
---|