[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 | |
---|
[39] | 93 | if exist('ext','var') && length(ext)>1 && (~isempty(imformats(ext(2:end)))||... |
---|
| 94 | isequal(lower(ext),'.avi'));%if an image file has been opened by uvmat |
---|
[2] | 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 |
---|
[39] | 261 | if isempty(filebase)|| isequal(filebase,'')%loads the previously stored file name and set it as default in the file_input box |
---|
[2] | 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=[]; |
---|
[39] | 450 | % npx=[];%default |
---|
| 451 | % npy=[]; |
---|
[2] | 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')); |
---|
[39] | 480 | if isempty(first_j)|| first_j < 1 |
---|
[2] | 481 | first_j=1; %default first_j |
---|
| 482 | end |
---|
| 483 | last_j=str2num(get(handles.last_j,'String')); |
---|
[39] | 484 | if isempty(last_j)|| last_j < first_j |
---|
[2] | 485 | last_j=first_j; %default last_j |
---|
| 486 | end |
---|
| 487 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
[39] | 488 | if isempty(incr_i) || incr_i < 1; |
---|
[2] | 489 | set(handles.incr_i,'String','1') %default incr_i |
---|
| 490 | end |
---|
| 491 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
[39] | 492 | if isempty(incr_j) || incr_j < 1; |
---|
[2] | 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); |
---|
[39] | 556 | fullname=fullfile(fileparts(filebase),XmlData.Heading.ImageName); %full name (including path) of the first image defined by the xmle file, |
---|
[12] | 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 %%%%%%%%%%%%%%%%%%% |
---|
[41] | 723 | if isequal(nom_type_ima,'_i')|| isequal(nom_type_nc,'_i1-i2')||~(exist('nbfield2','var')&&(nbfield2~=1)) |
---|
[2] | 724 | set(handles.mode,'String',{'series(Di)'}) |
---|
| 725 | set(handles.mode,'Value',1) |
---|
[41] | 726 | elseif isequal(nom_type_ima,'png_old')||isequal(nom_type_nc,'netc_old') |
---|
[2] | 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 |
---|
[41] | 734 | if nbfield2 <= 5 |
---|
| 735 | set(handles.mode,'Value',1)% advice 'pair j1-j2' for small burst |
---|
[2] | 736 | end |
---|
[41] | 737 | % else |
---|
| 738 | % if isequal(mode,'volume') |
---|
| 739 | % set(handles.mode,'Value',3) |
---|
| 740 | % elseif nbfield2 <= 5 |
---|
| 741 | % set(handles.mode,'Value',1)% advice 'pair j1-j2' for small bursts |
---|
| 742 | % else |
---|
| 743 | % set(handles.mode,'Value',2)% advice series Dj for long bursts, not volume |
---|
| 744 | % end |
---|
[2] | 745 | end |
---|
| 746 | |
---|
| 747 | %update the subdir |
---|
| 748 | pathdir=fileparts(filebase);%path to the current xml file |
---|
| 749 | listot=dir(pathdir); |
---|
| 750 | idir=0; |
---|
| 751 | listdir={''};%default |
---|
| 752 | for ilist=1:length(listot) |
---|
| 753 | if listot(ilist).isdir |
---|
| 754 | name=listot(ilist).name; |
---|
| 755 | if ~isequal(name,'.') && ~isequal(name,'..') |
---|
| 756 | idir=idir+1; |
---|
| 757 | listdir{idir,1}=listot(ilist).name; |
---|
| 758 | end |
---|
| 759 | end |
---|
| 760 | end |
---|
| 761 | set(handles.list_subdir_civ1,'Value',1) |
---|
| 762 | set(handles.list_subdir_civ2,'Value',1) |
---|
| 763 | set(handles.list_subdir_civ1,'String',['browse...';listdir]) |
---|
| 764 | set(handles.list_subdir_civ2,'String',['browse...';listdir]) |
---|
| 765 | %check wether the current subdir exists: |
---|
| 766 | subdir_civ1=get(handles.subdir_civ1,'String'); |
---|
| 767 | subdir_civ2=get(handles.subdir_civ2,'String'); |
---|
| 768 | |
---|
| 769 | mode_Callback(hObject, eventdata, handles) |
---|
| 770 | |
---|
| 771 | %%%%%% initialize waitbars and RUN button |
---|
| 772 | set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001]) |
---|
| 773 | set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001]) |
---|
| 774 | set(handles.waitbar_civ2,'Position',[0.946 0.219 0.03 0.001]) |
---|
| 775 | set(handles.waitbar_patch2,'Position',[0.946 0.0 0.03 0.001]) |
---|
| 776 | set(handles.RUN, 'Enable','On') |
---|
| 777 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 778 | if isequal(test_batch,1)%if batch installation is available |
---|
| 779 | set(handles.BATCH, 'Enable','On') |
---|
| 780 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 781 | end |
---|
| 782 | |
---|
| 783 | %%%%% store the root input filename for future opening |
---|
| 784 | dir_perso=prefdir; |
---|
| 785 | profil_perso=fullfile(prefdir,'uvmat_perso.mat'); |
---|
| 786 | RootPath=fileparts(filebase); |
---|
| 787 | if exist(profil_perso,'file') |
---|
| 788 | save (profil_perso,'RootPath','-append'); %store the root name for future opening of uvmat |
---|
| 789 | else |
---|
| 790 | txt=ver; |
---|
| 791 | Release=txt(1).Release; |
---|
| 792 | relnumb=str2num(Release(3:4)); |
---|
| 793 | if relnumb >= 14 |
---|
| 794 | save (profil_perso,'RootPath','-V6'); %store the root name for future opening of uvmat |
---|
| 795 | else |
---|
| 796 | save (profil_perso,'RootPath'); %store the root name for future opening of uvmat |
---|
| 797 | end |
---|
| 798 | end |
---|
| 799 | % save(profil_perso, 'filebase'); %store the root name for future opening of uvmat |
---|
| 800 | set(gcf,'Pointer','arrow') |
---|
| 801 | |
---|
[12] | 802 | %------------------------------------------------------------------------ |
---|
[2] | 803 | % --- Executes on button press in mode. |
---|
| 804 | function mode_Callback(hObject, eventdata, handles) |
---|
[12] | 805 | %------------------------------------------------------------------------ |
---|
[2] | 806 | browse=get(handles.browse_root,'UserData'); |
---|
| 807 | compare_list=get(handles.compare,'String'); |
---|
| 808 | val=get(handles.compare,'Value'); |
---|
| 809 | compare=compare_list{val}; |
---|
| 810 | if strcmp(compare,'displacement') |
---|
| 811 | mode='displacement'; |
---|
| 812 | else |
---|
| 813 | mode_list=get(handles.mode,'String'); |
---|
| 814 | mode_value=get(handles.mode,'Value'); |
---|
| 815 | mode=mode_list{mode_value}; |
---|
| 816 | end |
---|
| 817 | displ_num=[];%default |
---|
| 818 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 819 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 820 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 821 | siztime=size(time); |
---|
| 822 | nbfield=siztime(1); |
---|
| 823 | nbfield2=siztime(2); |
---|
| 824 | indchosen=1; %%first pair selected by default |
---|
| 825 | if isequal(mode,'pair j1-j2')%| isequal(mode,'st_pair j1-j2') |
---|
| 826 | dt=1; |
---|
| 827 | displ=''; |
---|
| 828 | index=0; |
---|
| 829 | numlist_a=[]; |
---|
| 830 | numlist_B=[]; |
---|
| 831 | %get all the time intervals in bursts |
---|
| 832 | displ_dt=1;%default |
---|
| 833 | nbfield2=min(nbfield2,10);%limitate the number of pairs to 10x10 |
---|
| 834 | for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'pair j1-j2' mode |
---|
| 835 | for numod_b=(numod_a+1):nbfield2 |
---|
| 836 | index=index+1; |
---|
| 837 | numlist_a(index)=numod_a; |
---|
| 838 | numlist_b(index)=numod_b; |
---|
| 839 | if ~isempty(time) |
---|
| 840 | dt(numod_a,numod_b)=time(first_i,numod_b)-time(first_i,numod_a);%first time interval dt |
---|
| 841 | displ_dt(index)=dt(numod_a,numod_b); |
---|
| 842 | else |
---|
| 843 | displ_dt(index)=1; |
---|
| 844 | end |
---|
| 845 | end |
---|
| 846 | end |
---|
| 847 | [dtsort,indsort]=sort(displ_dt); |
---|
| 848 | if ~isempty(numlist_a) |
---|
| 849 | displ_num(1,:)=numlist_a(indsort); |
---|
| 850 | displ_num(2,:)=numlist_b(indsort); |
---|
| 851 | end |
---|
| 852 | displ_num(3,:)=0; |
---|
| 853 | displ_num(4,:)=0; |
---|
| 854 | set(handles.jtext,'Visible','Off') |
---|
| 855 | set(handles.first_j,'Visible','Off') |
---|
| 856 | set(handles.last_j,'Visible','Off') |
---|
| 857 | set(handles.incr_j,'Visible','Off') |
---|
| 858 | set(handles.nb_field2,'Visible','Off') |
---|
| 859 | set(handles.ref_j,'Visible','Off') |
---|
| 860 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') |
---|
| 861 | for index=1:min(nbfield2-1,200) |
---|
| 862 | displ_num(1,index)=-floor(index/2); |
---|
| 863 | displ_num(2,index)=ceil(index/2); |
---|
| 864 | displ_num(3,index)=0; |
---|
| 865 | displ_num(4,index)=0; |
---|
| 866 | end |
---|
| 867 | set(handles.jtext,'Visible','On') |
---|
| 868 | set(handles.first_j,'Visible','On') |
---|
| 869 | set(handles.last_j,'Visible','On') |
---|
| 870 | set(handles.incr_j,'Visible','On') |
---|
| 871 | set(handles.nb_field2,'Visible','On') |
---|
| 872 | set(handles.ref_j,'Visible','On') |
---|
| 873 | if nbfield > 1 |
---|
| 874 | set(handles.itext,'Visible','On') |
---|
| 875 | set(handles.first_i,'Visible','On') |
---|
| 876 | set(handles.last_i,'Visible','On') |
---|
| 877 | set(handles.incr_i,'Visible','On') |
---|
| 878 | set(handles.nb_field,'Visible','On') |
---|
| 879 | set(handles.ref_i,'Visible','On') |
---|
| 880 | else |
---|
| 881 | set(handles.itext,'Visible','Off') |
---|
| 882 | set(handles.first_i,'Visible','Off') |
---|
| 883 | set(handles.last_i,'Visible','Off') |
---|
| 884 | set(handles.incr_i,'Visible','Off') |
---|
| 885 | set(handles.nb_field,'Visible','Off') |
---|
| 886 | set(handles.ref_i,'Visible','Off') |
---|
| 887 | end |
---|
| 888 | elseif isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 889 | for index=1:200%min(nbfield-1,200) |
---|
| 890 | displ_num(1,index)=0; |
---|
| 891 | displ_num(2,index)=0; |
---|
| 892 | displ_num(3,index)=-floor(index/2); |
---|
| 893 | displ_num(4,index)=ceil(index/2); |
---|
| 894 | end |
---|
| 895 | set(handles.itext,'Visible','On') |
---|
| 896 | set(handles.first_i,'Visible','On') |
---|
| 897 | set(handles.last_i,'Visible','On') |
---|
| 898 | set(handles.incr_i,'Visible','On') |
---|
| 899 | set(handles.nb_field,'Visible','On') |
---|
| 900 | set(handles.ref_i,'Visible','On') |
---|
| 901 | if nbfield2 > 1 |
---|
| 902 | set(handles.jtext,'Visible','On') |
---|
| 903 | set(handles.first_j,'Visible','On') |
---|
| 904 | set(handles.last_j,'Visible','On') |
---|
| 905 | set(handles.incr_j,'Visible','On') |
---|
| 906 | set(handles.nb_field2,'Visible','On') |
---|
| 907 | set(handles.ref_j,'Visible','On') |
---|
| 908 | else |
---|
| 909 | set(handles.jtext,'Visible','Off') |
---|
| 910 | set(handles.first_j,'Visible','Off') |
---|
| 911 | set(handles.last_j,'Visible','Off') |
---|
| 912 | set(handles.incr_j,'Visible','Off') |
---|
| 913 | set(handles.nb_field2,'Visible','Off') |
---|
| 914 | set(handles.ref_j,'Visible','Off') |
---|
| 915 | end |
---|
| 916 | elseif isequal(mode,'displacement')%the pairs have the same indices |
---|
| 917 | displ_num(1,1)=0; |
---|
| 918 | displ_num(2,1)=0; |
---|
| 919 | displ_num(3,1)=0; |
---|
| 920 | displ_num(4,1)=0; |
---|
| 921 | if nbfield > 1 |
---|
| 922 | set(handles.itext,'Visible','On') |
---|
| 923 | set(handles.first_i,'Visible','On') |
---|
| 924 | set(handles.last_i,'Visible','On') |
---|
| 925 | set(handles.incr_i,'Visible','On') |
---|
| 926 | set(handles.nb_field,'Visible','On') |
---|
| 927 | set(handles.ref_i,'Visible','On') |
---|
| 928 | else |
---|
| 929 | set(handles.itext,'Visible','Off') |
---|
| 930 | set(handles.first_i,'Visible','Off') |
---|
| 931 | set(handles.last_i,'Visible','Off') |
---|
| 932 | set(handles.incr_i,'Visible','Off') |
---|
| 933 | set(handles.nb_field,'Visible','Off') |
---|
| 934 | set(handles.ref_i,'Visible','Off') |
---|
| 935 | end |
---|
| 936 | if nbfield2 > 1 |
---|
| 937 | set(handles.jtext,'Visible','On') |
---|
| 938 | set(handles.first_j,'Visible','On') |
---|
| 939 | set(handles.last_j,'Visible','On') |
---|
| 940 | set(handles.incr_j,'Visible','On') |
---|
| 941 | set(handles.nb_field2,'Visible','On') |
---|
| 942 | set(handles.ref_j,'Visible','On') |
---|
| 943 | else |
---|
| 944 | set(handles.jtext,'Visible','Off') |
---|
| 945 | set(handles.first_j,'Visible','Off') |
---|
| 946 | set(handles.last_j,'Visible','Off') |
---|
| 947 | set(handles.incr_j,'Visible','Off') |
---|
| 948 | set(handles.nb_field2,'Visible','Off') |
---|
| 949 | set(handles.ref_j,'Visible','Off') |
---|
| 950 | end |
---|
| 951 | end |
---|
| 952 | set(handles.list_pair_civ1,'UserData',displ_num); |
---|
| 953 | find_netcpair_civ1(hObject, eventdata, handles) |
---|
| 954 | find_netcpair_civ2(hObject, eventdata, handles) |
---|
| 955 | |
---|
[12] | 956 | %------------------------------------------------------------------------ |
---|
[2] | 957 | % determine the menu for civ1 pairs depending on existing netcdf file at the middle of |
---|
| 958 | % the field series set by first_i, incr, last_i |
---|
| 959 | function find_netcpair_civ1(hObject, eventdata, handles) |
---|
[12] | 960 | %------------------------------------------------------------------------ |
---|
[2] | 961 | set(gcf,'Pointer','watch') |
---|
| 962 | %nomenclature types |
---|
| 963 | filebase=get(handles.displ_filebase,'String'); |
---|
| 964 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
| 965 | browse=get(handles.browse_root,'UserData'); |
---|
| 966 | compare_list=get(handles.compare,'String'); |
---|
| 967 | val=get(handles.compare,'Value'); |
---|
| 968 | compare=compare_list{val}; |
---|
| 969 | if strcmp(compare,'displacement') |
---|
| 970 | mode='displacement'; |
---|
| 971 | else |
---|
| 972 | mode_list=get(handles.mode,'String'); |
---|
| 973 | mode_value=get(handles.mode,'Value'); |
---|
| 974 | mode=mode_list{mode_value}; |
---|
| 975 | end |
---|
| 976 | |
---|
| 977 | % nomenclature type of the .nc files |
---|
| 978 | nom_type_ima=[];%default |
---|
| 979 | if isfield(browse,'nom_type_ima') |
---|
| 980 | nom_type_ima=browse.nom_type_ima; |
---|
| 981 | end |
---|
| 982 | |
---|
| 983 | %determine nom_type_nc: |
---|
| 984 | nom_type_nc=[];%default |
---|
| 985 | if isfield(browse,'nom_type_nc') |
---|
| 986 | nom_type_nc=browse.nom_type_nc; |
---|
| 987 | end |
---|
| 988 | if isempty(nom_type_nc) |
---|
| 989 | [nom_type_nc]=nomtype2pair(nom_type_ima,isequal(mode,'series(Di)'),isequal(mode,'series(Dj)')); |
---|
| 990 | end |
---|
| 991 | browse.nom_type_nc=nom_type_nc; |
---|
| 992 | set(handles.browse_root,'UserData',browse) |
---|
| 993 | |
---|
| 994 | %reads .nc subdirectoy and image numbers from the interface |
---|
| 995 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
| 996 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 997 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 998 | incr=str2num(get(handles.incr_i,'String')); |
---|
| 999 | num1=first_i:incr:last_i; |
---|
| 1000 | if isempty(num1) |
---|
| 1001 | set(handles.list_pair_civ1,'String',{''}); |
---|
| 1002 | return |
---|
| 1003 | end |
---|
| 1004 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
| 1005 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
| 1006 | ref_j=0; |
---|
| 1007 | else |
---|
| 1008 | ref_j=str2num(get(handles.ref_j,'String')); |
---|
| 1009 | end |
---|
| 1010 | time=get(handles.displ_filebase,'UserData');%get the set of times |
---|
| 1011 | if isempty(time) |
---|
| 1012 | time=[0 1]; |
---|
| 1013 | end |
---|
| 1014 | dt_unit=str2num(get(handles.dt,'String'));% used when there is no image documentation file |
---|
| 1015 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 1016 | |
---|
| 1017 | %eliminate the first pairs inconsistent with the position |
---|
| 1018 | if isempty(displ_num) |
---|
| 1019 | nbpair=0; |
---|
| 1020 | else |
---|
| 1021 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
| 1022 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 1023 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1024 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 1025 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1026 | end |
---|
| 1027 | end |
---|
| 1028 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
| 1029 | |
---|
| 1030 | %look for existing processed pairs involving the field at the middle of the series if civ1 will not |
---|
| 1031 | % be performed, while the result is needed for next steps. |
---|
| 1032 | displ_pair={''}; |
---|
| 1033 | select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs |
---|
| 1034 | testpair=0; |
---|
| 1035 | if get(handles.CIV1,'Value')==0 % |
---|
| 1036 | dirname=fullfile(filepath,subdir_civ1,ext_dir); |
---|
| 1037 | if ~exist(fullfile(filepath,subdir_civ1,ext_dir),'dir') |
---|
| 1038 | msgbox_uvmat('ERROR',['no civ1 file available: subdirectory ' subdir_civ1 ' does not exist']); |
---|
| 1039 | set(handles.list_pair_civ1,'String',{}); |
---|
| 1040 | return |
---|
| 1041 | end |
---|
| 1042 | for ipair=1:nbpair |
---|
| 1043 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
| 1044 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
| 1045 | select(ipair)=exist(filename,'file')==2; |
---|
| 1046 | end |
---|
| 1047 | if ~exist('select','var') || isequal(select,zeros(size(1:nbpair))) |
---|
| 1048 | if isfield(browse,'incr_pair') |
---|
| 1049 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
| 1050 | num_i2=ref_i+ceil(browse.incr_pair(1)/2); |
---|
| 1051 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
| 1052 | num_j2=ref_j+ceil(browse.incr_pair(2)/2); |
---|
| 1053 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ1); |
---|
| 1054 | select(1)=exist(filename,'file')==2; |
---|
| 1055 | testpair=1; |
---|
| 1056 | else |
---|
| 1057 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 1058 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1]); |
---|
| 1059 | else |
---|
| 1060 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ1]); |
---|
| 1061 | end |
---|
| 1062 | set(handles.list_pair_civ1,'String',{''}); |
---|
| 1063 | %COMPLETER CAS STEREO |
---|
| 1064 | return |
---|
| 1065 | end |
---|
| 1066 | end |
---|
| 1067 | end |
---|
| 1068 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 1069 | if testpair |
---|
| 1070 | displ_pair{1}=['Di= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
| 1071 | elseif ~isequal(get(handles.dt_text,'String'),'dt(ms)=') |
---|
| 1072 | for ipair=1:nbpair |
---|
| 1073 | if select(ipair) |
---|
| 1074 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1075 | 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 |
---|
| 1076 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1077 | end |
---|
| 1078 | else |
---|
| 1079 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1080 | end |
---|
| 1081 | end |
---|
| 1082 | else |
---|
| 1083 | for ipair=1:nbpair |
---|
| 1084 | if select(ipair) |
---|
| 1085 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt_unit*ipair)]; |
---|
| 1086 | else |
---|
| 1087 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1088 | end |
---|
| 1089 | end |
---|
| 1090 | end |
---|
| 1091 | elseif isequal(mode,'series(Dj)')%|isequal(mode,'st_series(Dj)')% series on the j index |
---|
| 1092 | if testpair |
---|
| 1093 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
| 1094 | else |
---|
| 1095 | for ipair=1:nbpair |
---|
| 1096 | if select(ipair) |
---|
| 1097 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1098 | 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 |
---|
| 1099 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1100 | end |
---|
| 1101 | elseif testpair |
---|
| 1102 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(2)/2)) '|' num2str(ceil(browse.incr_pair(2)/2))]; |
---|
| 1103 | else |
---|
| 1104 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1105 | end |
---|
| 1106 | end |
---|
| 1107 | end |
---|
| 1108 | elseif isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2')%case of pairs |
---|
| 1109 | for ipair=1:nbpair |
---|
| 1110 | if select(ipair) |
---|
| 1111 | 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 |
---|
| 1112 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
| 1113 | ' :dt= ' num2str(dt*1000)]; |
---|
| 1114 | else |
---|
| 1115 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1116 | end |
---|
| 1117 | end |
---|
| 1118 | elseif isequal(mode,'displacement') |
---|
| 1119 | displ_pair={'Di=Dj=0'}; |
---|
| 1120 | end |
---|
| 1121 | set(handles.list_pair_civ1,'String',displ_pair'); |
---|
| 1122 | ichoice=min(find(select)); |
---|
| 1123 | if (isempty(ichoice) | ichoice < 1); ichoice=1; end; |
---|
| 1124 | initial=get(handles.list_pair_civ1,'Value'); |
---|
| 1125 | if initial>nbpair |~isequal(select(initial),1) |
---|
| 1126 | set(handles.list_pair_civ1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
| 1127 | end |
---|
| 1128 | %set(handles.list_pair_civ2,'String',displ_pair'); |
---|
| 1129 | initial=get(handles.list_pair_civ2,'Value'); |
---|
| 1130 | if initial>length(displ_pair')%|~isequal(select(initial),1) |
---|
| 1131 | if ichoice <= length(displ_pair') |
---|
| 1132 | set(handles.list_pair_civ2,'Value',ichoice);% same pair proposed by default for civ2 |
---|
| 1133 | else |
---|
| 1134 | set(handles.list_pair_civ2,'Value',1);% same pair proposed by default for civ2 |
---|
| 1135 | end |
---|
| 1136 | end |
---|
| 1137 | set(handles.list_pair_civ2,'String',displ_pair'); |
---|
| 1138 | set(gcf,'Pointer','arrow') |
---|
[12] | 1139 | |
---|
| 1140 | %------------------------------------------------------------------------ |
---|
[2] | 1141 | % determine the menu for civ2 pairs depending on the existing netcdf file at the |
---|
| 1142 | %middle of the series set by first_i, incr, last_i |
---|
| 1143 | function find_netcpair_civ2(hObject, eventdata, handles) |
---|
[12] | 1144 | %------------------------------------------------------------------------ |
---|
[2] | 1145 | set(gcf,'Pointer','watch') |
---|
| 1146 | %nomenclature types |
---|
| 1147 | filebase=get(handles.displ_filebase,'String'); |
---|
| 1148 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
| 1149 | browse=get(handles.browse_root,'UserData'); |
---|
| 1150 | compare_list=get(handles.compare,'String'); |
---|
| 1151 | val=get(handles.compare,'Value'); |
---|
| 1152 | compare=compare_list{val}; |
---|
| 1153 | if strcmp(compare,'displacement') |
---|
| 1154 | mode='displacement'; |
---|
| 1155 | else |
---|
| 1156 | mode_list=get(handles.mode,'String'); |
---|
| 1157 | mode_value=get(handles.mode,'Value'); |
---|
| 1158 | mode=mode_list{mode_value}; |
---|
| 1159 | end |
---|
| 1160 | |
---|
| 1161 | % nomenclature type of the .nc files |
---|
| 1162 | nom_type_ima='ima_num';%default |
---|
| 1163 | if isfield(browse,'nom_type_ima') |
---|
| 1164 | nom_type_ima=browse.nom_type_ima; |
---|
| 1165 | end |
---|
| 1166 | nom_type_nc='_i1-i2';%default |
---|
| 1167 | if isfield(browse,'nom_type_nc') |
---|
| 1168 | nom_type_nc=browse.nom_type_nc; |
---|
| 1169 | end |
---|
| 1170 | 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') |
---|
| 1171 | nom_type_nc='netc_old';%nom_type for the netcdf files |
---|
| 1172 | elseif isequal(nom_type_ima,'none')|isequal(nom_type_nc,'none') |
---|
| 1173 | nom_type_nc='none'; |
---|
| 1174 | elseif isequal(nom_type_ima,'avi')|isequal(nom_type_ima,'_i')|isequal(nom_type_ima,'ima_num')|isequal(nom_type_nc,'_i1-i2') |
---|
| 1175 | nom_type_nc='_i1-i2'; |
---|
| 1176 | else |
---|
| 1177 | if isequal(mode,'series(Di)')%|isequal(mode,'st_series(Di)') |
---|
| 1178 | nom_type_nc='_i1-i2_j'; % PIV in volume |
---|
| 1179 | else |
---|
| 1180 | nom_type_nc='_i_j1-j2'; |
---|
| 1181 | end |
---|
| 1182 | end |
---|
| 1183 | browse.nom_type_nc=nom_type_nc; |
---|
| 1184 | set(handles.browse_root,'UserData',browse) |
---|
| 1185 | |
---|
| 1186 | %reads .nc subdirectory and image numbers from the interface |
---|
| 1187 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
| 1188 | subdir_civ2=get(handles.subdir_civ2,'String');%subdirectory subdir_civ2 for the netcdf data |
---|
| 1189 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 1190 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 1191 | incr=str2num(get(handles.incr_i,'String')); |
---|
| 1192 | num1=first_i:incr:last_i; |
---|
| 1193 | if isempty(num1) |
---|
| 1194 | set(handles.list_pair_civ2,'Value',1); |
---|
| 1195 | set(handles.list_pair_civ2,'String',{''}); |
---|
| 1196 | return |
---|
| 1197 | end |
---|
| 1198 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
| 1199 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
| 1200 | ref_j=0; |
---|
| 1201 | else |
---|
| 1202 | ref_j=str2num(get(handles.ref_j,'String')); |
---|
| 1203 | end |
---|
| 1204 | if isequal(get(handles.dt_text,'String'),'dt(ms)=')%simple series(Di) with equal interval |
---|
| 1205 | ref_i=ceil((first_i+last_i)/2); |
---|
| 1206 | ref_j=1; |
---|
| 1207 | end |
---|
| 1208 | % ref_i=browse.num_ref;%field number initially selected by the browser |
---|
| 1209 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 1210 | if isempty(time) |
---|
| 1211 | time=[0 1];%default |
---|
| 1212 | end |
---|
| 1213 | dt_unit=str2num(get(handles.dt,'String'));% used when there is no image documentation file |
---|
| 1214 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 1215 | |
---|
| 1216 | |
---|
| 1217 | %eliminate the first pairs inconsistent with the position |
---|
| 1218 | if isempty(displ_num) |
---|
| 1219 | nbpair=0; |
---|
| 1220 | else |
---|
| 1221 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
| 1222 | if isequal(mode,'series(Di)')% | isequal(mode,'st_series(Di)') |
---|
| 1223 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1224 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 1225 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1226 | end |
---|
| 1227 | end |
---|
| 1228 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
| 1229 | |
---|
| 1230 | %look for existing processed pairs involving the field at the middle of the series if civ1 will not |
---|
| 1231 | % be performed, while the result is needed for next steps. |
---|
| 1232 | displ_pair={''}; %default |
---|
| 1233 | select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs |
---|
| 1234 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0%&... |
---|
| 1235 | if ~exist(fullfile(filepath,subdir_civ2,ext_dir),'dir') |
---|
| 1236 | errordlg(['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist']) |
---|
| 1237 | set(handles.list_pair_civ2,'Value',1); |
---|
| 1238 | set(handles.list_pair_civ2,'String',{''}); |
---|
| 1239 | return |
---|
| 1240 | end |
---|
| 1241 | for ipair=1:nbpair |
---|
| 1242 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
| 1243 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
| 1244 | select(ipair)=exist(filename,'file')==2; |
---|
| 1245 | end |
---|
| 1246 | if isequal(select,zeros(size(1:nbpair))) |
---|
| 1247 | if isfield(browse,'incr_pair') |
---|
| 1248 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
| 1249 | num_i2=ref_i+floor((browse.incr_pair(1)+1)/2); |
---|
| 1250 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
| 1251 | num_j2=ref_j+floor((browse.incr_pair(2)+1)/2); |
---|
| 1252 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ2); |
---|
| 1253 | select(1)=exist(filename,'file')==2; |
---|
| 1254 | else |
---|
| 1255 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 1256 | errordlg(['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2]) |
---|
| 1257 | else |
---|
| 1258 | errordlg(['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2]) |
---|
| 1259 | end |
---|
| 1260 | set(handles.list_pair_civ2,'Value',1); |
---|
| 1261 | set(handles.list_pair_civ2,'String',{''}); |
---|
| 1262 | return |
---|
| 1263 | end |
---|
| 1264 | end |
---|
| 1265 | end |
---|
| 1266 | if isequal(mode,'series(Di)') % | isequal(mode,'st_series(Di)') |
---|
| 1267 | % if ~isequal(get(handles.dt_text,'String'),'dt(ms)=') |
---|
| 1268 | for ipair=1:nbpair |
---|
| 1269 | if select(ipair) |
---|
| 1270 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1271 | 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 |
---|
| 1272 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1273 | end |
---|
| 1274 | else |
---|
| 1275 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1276 | end |
---|
| 1277 | end |
---|
| 1278 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') % series on the j index |
---|
| 1279 | for ipair=1:nbpair |
---|
| 1280 | if select(ipair) |
---|
| 1281 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1282 | 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 |
---|
| 1283 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1284 | end |
---|
| 1285 | else |
---|
| 1286 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1287 | end |
---|
| 1288 | end |
---|
| 1289 | elseif isequal(mode,'pair j1-j2')% | isequal(mode,'st_pair j1-j2') %case of pairs |
---|
| 1290 | for ipair=1:nbpair |
---|
| 1291 | if select(ipair) |
---|
| 1292 | 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 |
---|
| 1293 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
| 1294 | ' :dt= ' num2str(dt*1000)]; |
---|
| 1295 | else |
---|
| 1296 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1297 | end |
---|
| 1298 | end |
---|
| 1299 | elseif isequal(mode,'displacement') |
---|
| 1300 | displ_pair={'Di=Dj=0'}; |
---|
| 1301 | end |
---|
| 1302 | val=get(handles.list_pair_civ2,'Value'); |
---|
| 1303 | ichoice=min(find(select)); |
---|
| 1304 | if (isempty(ichoice) | ichoice < 1); ichoice=1; end; |
---|
| 1305 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0 |
---|
| 1306 | val=ichoice;% first valid pair proposed by default in the menu |
---|
| 1307 | end |
---|
| 1308 | if val>length(displ_pair') |
---|
| 1309 | set(handles.list_pair_civ2,'Value',1);% first valid pair proposed by default in the menu |
---|
| 1310 | else |
---|
| 1311 | set(handles.list_pair_civ2,'Value',val); |
---|
| 1312 | end |
---|
| 1313 | set(handles.list_pair_civ2,'String',displ_pair'); |
---|
[12] | 1314 | set(gcf,'Pointer','arrow') |
---|
[2] | 1315 | |
---|
[12] | 1316 | %------------------------------------------------------------------------ |
---|
[2] | 1317 | % determine the list of index pairs of processing file |
---|
| 1318 | function [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
| 1319 | find_pair_indices(handles,mode) |
---|
[12] | 1320 | %------------------------------------------------------------------------ |
---|
[36] | 1321 | first_i=str2num(get(handles.first_i,'String'));%first index i |
---|
| 1322 | last_i=str2num(get(handles.last_i,'String'));%last index i |
---|
| 1323 | incr=str2num(get(handles.incr_i,'String'));% increment |
---|
[39] | 1324 | num_i=[first_i:incr:last_i];% list of i indices (reference values for each pair) |
---|
[2] | 1325 | if isequal(get(handles.first_j,'Visible'),'on') |
---|
[36] | 1326 | first_j=str2num(get(handles.first_j,'String'));%first index j |
---|
| 1327 | last_j=str2num(get(handles.last_j,'String'));%last index j |
---|
| 1328 | incr_j=str2num(get(handles.incr_j,'String'));% increment |
---|
[2] | 1329 | else |
---|
| 1330 | first_j=1; |
---|
| 1331 | last_j=1; |
---|
| 1332 | incr_j=1; |
---|
| 1333 | end |
---|
[36] | 1334 | num_j=[first_j:incr_j:last_j];% list of j indices (reference values for each pair) |
---|
[2] | 1335 | list_civ1=get(handles.list_pair_civ1,'String'); |
---|
| 1336 | index_civ1=get(handles.list_pair_civ1,'Value'); |
---|
[36] | 1337 | str_civ1=list_civ1{index_civ1};%string defining the image pairs for civ1 |
---|
[2] | 1338 | if isempty(str_civ1)||isequal(str_civ1,'') |
---|
| 1339 | msgbox_uvmat('ERROR','no image pair selected for civ1') |
---|
| 1340 | return |
---|
| 1341 | end |
---|
| 1342 | list_civ2=get(handles.list_pair_civ2,'String'); |
---|
| 1343 | index_civ2=get(handles.list_pair_civ2,'Value'); |
---|
| 1344 | if index_civ2>length(list_civ2) |
---|
| 1345 | list_civ2=list_civ1; |
---|
| 1346 | index_civ2=index_civ1; |
---|
| 1347 | end |
---|
[36] | 1348 | str_civ2=list_civ2{index_civ2};%string defining the image pairs for civ2 |
---|
| 1349 | if isempty(first_i)||isempty(first_j), msgbox_uvmat('ERROR','first field number not defined'),... |
---|
| 1350 | return,end; |
---|
[39] | 1351 | if isequal(last_i,[])|| isequal(last_j,[]),msgbox_uvmat('ERROR','last field number not defined'),... |
---|
[36] | 1352 | return,end; |
---|
[39] | 1353 | if isequal(incr,[])|| isequal(incr_j,[]),msgbox_uvmat('ERROR','increment in field number not defined'),... |
---|
[36] | 1354 | return,end; |
---|
[39] | 1355 | if last_i < first_i || last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),... |
---|
[36] | 1356 | return,end; |
---|
| 1357 | if isequal (mode,'series(Di)') |
---|
[2] | 1358 | %recognize the pair civ1 from the display |
---|
| 1359 | indsel=find((double(str_civ1)<48)|(double(str_civ1)>57));% character indices of non numerical characters |
---|
| 1360 | str_raw=str_civ1(indsel); |
---|
| 1361 | indsepar=find(str_raw=='|'); %character index of the separator |
---|
| 1362 | d1=str2num(str_civ1([indsel(indsepar-1)+1:indsel(indsepar)-1])); |
---|
| 1363 | if indsepar==length(str_raw) |
---|
| 1364 | d2=str2num(str_civ1([indsel(indsepar)+1:end])); |
---|
| 1365 | else |
---|
| 1366 | d2=str2num(str_civ1([indsel(indsepar)+1:indsel(indsepar+1)-1])); |
---|
| 1367 | end |
---|
[39] | 1368 | num1_civ1=num_i-d1;% set of first image numbers |
---|
| 1369 | num2_civ1=num_i+d2; |
---|
[2] | 1370 | num_a_civ1=num_j; |
---|
| 1371 | num_b_civ1=num_j; |
---|
| 1372 | |
---|
| 1373 | %recognize the pair civ2 from the display |
---|
| 1374 | indsel=find((double(str_civ2)<48)|(double(str_civ2)>57));% character indices of non numerical characters |
---|
| 1375 | str_raw=str_civ2(indsel); |
---|
| 1376 | indsepar=find(str_raw=='|'); %character index of the separator |
---|
| 1377 | d1=str2num(str_civ2([indsel(indsepar-1)+1:indsel(indsepar)-1])); |
---|
| 1378 | if indsepar==length(str_raw) |
---|
| 1379 | d2=str2num(str_civ2([indsel(indsepar)+1:end])); |
---|
| 1380 | else |
---|
| 1381 | d2=str2num(str_civ2([indsel(indsepar)+1:indsel(indsepar+1)-1])); |
---|
| 1382 | end |
---|
| 1383 | if isempty(d1) |
---|
[39] | 1384 | num1_civ2=num_i; |
---|
[2] | 1385 | else |
---|
[39] | 1386 | num1_civ2=num_i-d1;% set of first image numbers |
---|
[2] | 1387 | end |
---|
| 1388 | if isempty(d2) |
---|
[39] | 1389 | num2_civ2=num_i; |
---|
[2] | 1390 | else |
---|
[39] | 1391 | num2_civ2=num_i+d2; |
---|
[2] | 1392 | end |
---|
| 1393 | num_a_civ2=num_j; |
---|
| 1394 | num_b_civ2=num_j; |
---|
| 1395 | |
---|
| 1396 | % adjust the first and last field number |
---|
| 1397 | lastfield=str2num(get(handles.nb_field,'String')); |
---|
| 1398 | if isequal(lastfield,[]) |
---|
| 1399 | indsel=find((num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
| 1400 | else |
---|
| 1401 | indsel=find((num2_civ1 <= lastfield)&(num2_civ2 <= lastfield)&(num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
| 1402 | end |
---|
| 1403 | if length(indsel)>=1 |
---|
| 1404 | firstind=indsel(1); |
---|
| 1405 | lastind=indsel(end); |
---|
[39] | 1406 | set(handles.first_i,'String',num2str(num_i(firstind)))%update the display of first and last fields |
---|
| 1407 | set(handles.last_i,'String',num2str(num_i(lastind))) |
---|
| 1408 | num_i=num_i(indsel); |
---|
[2] | 1409 | num1_civ1=num1_civ1(indsel); |
---|
| 1410 | num1_civ2=num1_civ2(indsel); |
---|
| 1411 | num2_civ1=num2_civ1(indsel); |
---|
| 1412 | num2_civ2=num2_civ2(indsel); |
---|
| 1413 | end |
---|
[36] | 1414 | elseif isequal (mode,'series(Dj)') |
---|
[2] | 1415 | lastfield_j=str2num(get(handles.nb_field2,'String')); |
---|
[39] | 1416 | num1_civ1=num_i;% set of first image numbers |
---|
| 1417 | num2_civ1=num_i; |
---|
[2] | 1418 | num_a_civ1=num_j-floor(index_civ1/2)*ones(size(num_j)); |
---|
| 1419 | num_b_civ1=num_j+ceil(index_civ1/2)*ones(size(num_j)); |
---|
[39] | 1420 | num1_civ2=num_i; |
---|
| 1421 | num2_civ2=num_i; |
---|
[2] | 1422 | num_a_civ2=num_j-floor(index_civ2/2)*ones(size(num_j)); |
---|
| 1423 | num_b_civ2=num_j+ceil(index_civ2/2)*ones(size(num_j)); |
---|
| 1424 | % adjust the first and last field number |
---|
| 1425 | if isequal(lastfield_j,[]) |
---|
| 1426 | indsel=find((num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
| 1427 | else |
---|
| 1428 | indsel=find((num_b_civ1 <= lastfield_j)&(num_b_civ2 <= lastfield_j)&(num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
| 1429 | end |
---|
| 1430 | if length(indsel)>=1 |
---|
| 1431 | firstind=indsel(1); |
---|
| 1432 | lastind=indsel(end); |
---|
| 1433 | set(handles.first_j,'String',num2str(num_j(firstind)))%update the display of first and last fields |
---|
| 1434 | set(handles.last_j,'String',num2str(num_j(lastind))) |
---|
| 1435 | num_j=num_j(indsel); |
---|
| 1436 | num_a_civ1=num_a_civ1(indsel); |
---|
| 1437 | num_a_civ2=num_a_civ2(indsel); |
---|
| 1438 | num_b_civ1=num_b_civ1(indsel); |
---|
| 1439 | num_b_civ2=num_b_civ2(indsel); |
---|
| 1440 | end |
---|
[36] | 1441 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
[39] | 1442 | num1_civ1=num_i; |
---|
| 1443 | num1_civ2=num_i; |
---|
[2] | 1444 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
[39] | 1445 | num2_civ1=num_i; |
---|
[2] | 1446 | num_a_civ1=displ_num(1,index_civ1); |
---|
| 1447 | num_b_civ1=displ_num(2,index_civ1); |
---|
[39] | 1448 | num2_civ2=num_i; |
---|
[2] | 1449 | num_a_civ2=displ_num(1,index_civ2); |
---|
| 1450 | num_b_civ2=displ_num(2,index_civ2); |
---|
| 1451 | elseif isequal(mode,'displacement') |
---|
[39] | 1452 | num1_civ1=num_i; |
---|
| 1453 | num2_civ1=num_i; |
---|
[2] | 1454 | num_a_civ1=num_j; |
---|
| 1455 | num_b_civ1=num_j; |
---|
[39] | 1456 | num1_civ2=num_i; |
---|
| 1457 | num2_civ2=num_i; |
---|
[2] | 1458 | num_a_civ2=num_j; |
---|
| 1459 | num_b_civ2=num_j; |
---|
| 1460 | end |
---|
| 1461 | |
---|
[41] | 1462 | |
---|
[12] | 1463 | %------------------------------------------------------------------------ |
---|
[2] | 1464 | % --- Executes on selection change in list_pair_civ1. |
---|
| 1465 | function list_pair_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 1466 | %------------------------------------------------------------------------ |
---|
[2] | 1467 | %reproduce by default the chosen pair in the civ2 menu |
---|
| 1468 | list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs |
---|
| 1469 | index_pair=get(handles.list_pair_civ1,'Value'); |
---|
| 1470 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 1471 | num_a=displ_num(1,index_pair); |
---|
| 1472 | num_b=displ_num(2,index_pair); |
---|
| 1473 | list_pair2=get(handles.list_pair_civ2,'String');%get the menu of image pairs |
---|
| 1474 | if index_pair<=length(list_pair2) |
---|
| 1475 | set(handles.list_pair_civ2,'Value',index_pair); |
---|
| 1476 | end |
---|
| 1477 | |
---|
| 1478 | %update first_i and last_i according to the chosen image pairs |
---|
| 1479 | mode_list=get(handles.mode,'String'); |
---|
| 1480 | mode_value=get(handles.mode,'Value'); |
---|
| 1481 | mode=mode_list{mode_value}; |
---|
| 1482 | if isequal(mode,'series(Di)') |
---|
| 1483 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 1484 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 1485 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
| 1486 | num1=first_i:incr_i:last_i; |
---|
| 1487 | lastfield=str2num(get(handles.nb_field,'String')); |
---|
| 1488 | if ~isequal(lastfield,[]) |
---|
| 1489 | ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
| 1490 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield)); |
---|
| 1491 | num1=num1(ind); |
---|
| 1492 | end |
---|
| 1493 | set(handles.first_i,'String',num2str(num1(1))); |
---|
| 1494 | set(handles.last_i,'String',num2str(num1(end))); |
---|
| 1495 | elseif isequal(mode,'series(Dj)') |
---|
| 1496 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 1497 | last_j=str2num(get(handles.last_j,'String')); |
---|
| 1498 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
| 1499 | num_j=first_j:incr_j:last_j; |
---|
| 1500 | lastfield2=str2num(get(handles.nb_field2,'String')); |
---|
| 1501 | if ~isequal(lastfield2,[]) |
---|
| 1502 | ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 1503 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2)); |
---|
| 1504 | num1=num_j(ind); |
---|
| 1505 | end |
---|
| 1506 | set(handles.first_j,'String',num2str(num1(1))); |
---|
| 1507 | set(handles.last_j,'String',num2str(num1(end))); |
---|
| 1508 | end |
---|
| 1509 | |
---|
[12] | 1510 | %------------------------------------------------------------------------ |
---|
[2] | 1511 | % --- Executes on selection change in list_pair_civ2. |
---|
| 1512 | function list_pair_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 1513 | %------------------------------------------------------------------------ |
---|
[2] | 1514 | index_pair=get(handles.list_pair_civ2,'Value');%get the selected position index in the menu |
---|
| 1515 | |
---|
| 1516 | %update first_i and last_i according to the chosen image pairs |
---|
| 1517 | mode_list=get(handles.mode,'String'); |
---|
| 1518 | mode_value=get(handles.mode,'Value'); |
---|
| 1519 | mode=mode_list{mode_value}; |
---|
| 1520 | if isequal(mode,'series(Di)') |
---|
| 1521 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 1522 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 1523 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
| 1524 | num1=first_i:incr_i:last_i; |
---|
| 1525 | lastfield=str2num(get(handles.nb_field,'String')); |
---|
| 1526 | if ~isequal(lastfield,[]) |
---|
| 1527 | ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
| 1528 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield)); |
---|
| 1529 | num1=num1(ind); |
---|
| 1530 | end |
---|
| 1531 | set(handles.first_i,'String',num2str(num1(1))); |
---|
| 1532 | set(handles.last_i,'String',num2str(num1(end))); |
---|
| 1533 | elseif isequal(mode,'series(Dj)') |
---|
| 1534 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 1535 | last_j=str2num(get(handles.last_j,'String')); |
---|
| 1536 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
| 1537 | num_j=first_j:incr_j:last_j; |
---|
| 1538 | lastfield2=str2num(get(handles.nb_field2,'String')); |
---|
| 1539 | if ~isequal(lastfield2,[]) |
---|
| 1540 | ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 1541 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2)); |
---|
| 1542 | num1=num_j(ind); |
---|
| 1543 | end |
---|
| 1544 | set(handles.first_j,'String',num2str(num1(1))); |
---|
| 1545 | set(handles.last_j,'String',num2str(num1(end))); |
---|
| 1546 | end |
---|
| 1547 | |
---|
[12] | 1548 | %------------------------------------------------------------------------ |
---|
[2] | 1549 | % --- Executes on button press in RUN. |
---|
| 1550 | function RUN_Callback(hObject, eventdata, handles) |
---|
[12] | 1551 | %------------------------------------------------------------------------ |
---|
[2] | 1552 | global civ1_exe civ2_exe patch_exe patch_new_exe sge |
---|
| 1553 | |
---|
| 1554 | compare=get(handles.compare,'Value');%test for usual PIV (compare=1) or displacement (=2) or stereo PIV (=3) |
---|
| 1555 | %check the list of operations: |
---|
| 1556 | operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'}; |
---|
| 1557 | run_flag=1; |
---|
| 1558 | box_test(1)=get(handles.CIV1,'Value'); |
---|
| 1559 | box_test(2)=get(handles.FIX1,'Value'); |
---|
| 1560 | box_test(3)=get(handles.PATCH1,'Value'); |
---|
| 1561 | box_test(4)=get(handles.CIV2,'Value'); |
---|
| 1562 | box_test(5)=get(handles.FIX2,'Value'); |
---|
| 1563 | box_test(6)=get(handles.PATCH2,'Value'); |
---|
| 1564 | index=find(box_test==1); |
---|
| 1565 | if isempty(index) |
---|
| 1566 | msgbox_uvmat('ERROR','no selected operation') |
---|
| 1567 | return |
---|
| 1568 | end |
---|
| 1569 | index_first=min(index); |
---|
| 1570 | index_last=max(index); |
---|
| 1571 | box_used=box_test([index_first : index_last]); |
---|
| 1572 | [box_missing,ind_missing]=min(box_used); |
---|
| 1573 | if isequal(box_missing,0) |
---|
| 1574 | msgbox_uvmat('ERROR',['missing' cell2mat(operations(ind_missing))]); |
---|
| 1575 | return |
---|
| 1576 | end |
---|
| 1577 | |
---|
| 1578 | %root name |
---|
| 1579 | filebase=get(handles.displ_filebase,'String'); |
---|
| 1580 | if isempty(filebase)||isequal(filebase,'') |
---|
| 1581 | msgbox_uvmat('ERROR','no input files') |
---|
| 1582 | return |
---|
| 1583 | end |
---|
| 1584 | %check mask if selecetd |
---|
| 1585 | if isequal(get(handles.get_mask_civ1,'Value'),1) |
---|
[12] | 1586 | maskname=get(handles.mask_civ1,'String'); |
---|
| 1587 | if ~exist(maskname,'file') |
---|
| 1588 | get_mask_civ1_Callback(hObject, eventdata, handles); |
---|
| 1589 | end |
---|
[2] | 1590 | end |
---|
| 1591 | if isequal(get(handles.get_mask_fix1,'Value'),1) |
---|
[12] | 1592 | maskname=get(handles.mask_fix1,'String'); |
---|
| 1593 | if ~exist(maskname,'file') |
---|
[2] | 1594 | get_mask_fix1_Callback(hObject, eventdata, handles); |
---|
[12] | 1595 | end |
---|
[2] | 1596 | end |
---|
| 1597 | if isequal(get(handles.get_mask_civ2,'Value'),1) |
---|
[12] | 1598 | maskname=get(handles.mask_civ2,'String'); |
---|
| 1599 | if ~exist(maskname,'file') |
---|
[2] | 1600 | get_mask_civ2_Callback(hObject, eventdata, handles); |
---|
[12] | 1601 | end |
---|
[2] | 1602 | end |
---|
| 1603 | if isequal(get(handles.get_mask_fix2,'Value'),1) |
---|
[12] | 1604 | maskname=get(handles.mask_fix2,'String'); |
---|
| 1605 | if ~exist(maskname,'file') |
---|
[2] | 1606 | get_mask_fix2_Callback(hObject, eventdata, handles); |
---|
[12] | 1607 | end |
---|
[2] | 1608 | end |
---|
| 1609 | |
---|
| 1610 | %read names of the .exe file |
---|
| 1611 | if box_test(1)==1 | box_test(3)==1 | box_test(4)==1 | box_test(6)==1 |
---|
| 1612 | path_uvmat=which('uvmat');% check the path detected for source file uvmat |
---|
| 1613 | path_UVMAT=fileparts(path_uvmat); %path to UVMAT |
---|
| 1614 | if isunix |
---|
| 1615 | %fid = fopen(fullfile(path_UVMAT,'PARAM_LINUX.txt'),'r');%open the file with civ binary names |
---|
| 1616 | xmlfile=fullfile(path_UVMAT,'PARAM_LINUX.xml'); |
---|
| 1617 | if exist(xmlfile,'file') |
---|
| 1618 | t=xmltree(xmlfile); |
---|
| 1619 | sparam=convert(t); |
---|
| 1620 | end |
---|
| 1621 | else |
---|
| 1622 | %fid = fopen(fullfile(path_UVMAT,'PARAM_WIN.txt'),'r');%open the file with civ binary names |
---|
| 1623 | xmlfile=fullfile(path_UVMAT,'PARAM_WIN.xml'); |
---|
| 1624 | if exist(xmlfile,'file') |
---|
| 1625 | t=xmltree(xmlfile); |
---|
| 1626 | sparam=convert(t); |
---|
| 1627 | end |
---|
| 1628 | end |
---|
| 1629 | if isfield(sparam,'Civ1_exe') |
---|
| 1630 | civ1_exe=sparam.Civ1_exe; |
---|
| 1631 | end |
---|
| 1632 | if isfield(sparam,'Civ2_exe') |
---|
| 1633 | civ2_exe=sparam.Civ2_exe; |
---|
| 1634 | end |
---|
| 1635 | if isfield(sparam,'Patch_exe') |
---|
| 1636 | patch_exe=sparam.Patch_exe; |
---|
| 1637 | end |
---|
| 1638 | if isfield(sparam,'Stinterp_exe') |
---|
| 1639 | stinterp_exe=sparam.Stinterp_exe; |
---|
| 1640 | end |
---|
| 1641 | if isfield(sparam,'SGE') |
---|
| 1642 | sge=str2num(sparam.SGE); |
---|
| 1643 | end |
---|
| 1644 | if ~isunix % for windows system, check whether the Matlab working dir is a UBC name |
---|
| 1645 | dircur=pwd; |
---|
| 1646 | if ~isequal(dircur([2 3]),':\') |
---|
| 1647 | msgbox_uvmat('ERROR','move to a Matlab current working directory with a Windows name, e.g. m:/...') |
---|
| 1648 | return; |
---|
| 1649 | end |
---|
| 1650 | end |
---|
| 1651 | end |
---|
| 1652 | |
---|
| 1653 | %initialize the waitbars |
---|
| 1654 | set(handles.waitbar_1,'Position',[0.946 0.877 0.03 0.001]) |
---|
| 1655 | set(handles.waitbar_patch1,'Position',[0.946 0.626 0.03 0.001]) |
---|
| 1656 | set(handles.waitbar_civ2,'Position',[0.946 0.406 0.03 0.001]) |
---|
| 1657 | set(handles.waitbar_patch2,'Position',[0.946 0.187 0.03 0.001]) |
---|
| 1658 | set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 1659 | set(handles.RUN, 'Enable','Off') |
---|
| 1660 | drawnow |
---|
| 1661 | |
---|
| 1662 | % get the list of file names and check the files |
---|
| 1663 | display('checking the files...') |
---|
| 1664 | [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]=... |
---|
| 1665 | set_civ_filenames(handles,compare,box_test); |
---|
[41] | 1666 | nbfield=numel(num1_civ1); |
---|
| 1667 | nbslice=size(num_a_civ1); |
---|
[36] | 1668 | |
---|
[12] | 1669 | if isempty(filecell) |
---|
| 1670 | set(handles.RUN, 'Enable','On') |
---|
| 1671 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 1672 | set(handles.BATCH, 'Enable','On') |
---|
| 1673 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 1674 | return |
---|
| 1675 | end |
---|
[2] | 1676 | display('files OK, processing...') |
---|
| 1677 | nbfield=size(num1_civ1,2); |
---|
| 1678 | nbslice=size(num1_civ1,1); |
---|
| 1679 | |
---|
| 1680 | %RUN CIV1 |
---|
| 1681 | if box_test(1)==1 |
---|
| 1682 | 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) |
---|
| 1683 | if compare==3 |
---|
| 1684 | 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) |
---|
| 1685 | end |
---|
| 1686 | end |
---|
| 1687 | |
---|
| 1688 | %RUN FIX1 |
---|
| 1689 | if box_test(2)==1 |
---|
| 1690 | filebase=get(handles.displ_filebase,'String'); |
---|
| 1691 | %names of the civ1 fields |
---|
| 1692 | field1.vel_type='civ1'; |
---|
| 1693 | field1.nb='nb_vectors'; |
---|
| 1694 | field1.X='vec_X'; |
---|
| 1695 | field1.Y='vec_Y'; |
---|
| 1696 | field1.U='vec_U'; |
---|
| 1697 | field1.V='vec_V'; |
---|
| 1698 | field1.fixflag='vec_FixFlag'; |
---|
| 1699 | flagindex(1)=get(handles.vec_Fmin2, 'Value'); |
---|
| 1700 | flagindex(2)=get(handles.vec_F3, 'Value'); |
---|
| 1701 | flagindex(3)=get(handles.vec_F2, 'Value'); |
---|
| 1702 | thresh_vecC=str2num(get(handles.thresh_vecC,'String'));%threshold on image correlation vec_C |
---|
| 1703 | thresh_vel=str2num(get(handles.thresh_vel,'String'));%threshold on velocity modulus |
---|
| 1704 | inf_sup=get(handles.inf_sup1,'Value'); |
---|
| 1705 | menu=get(handles.field_ref1,'String'); |
---|
| 1706 | index=get(handles.field_ref1,'Value'); |
---|
| 1707 | if isempty(menu) |
---|
| 1708 | fieldchoice=''; |
---|
| 1709 | else |
---|
| 1710 | fieldchoice=menu{index}; |
---|
| 1711 | end |
---|
| 1712 | h = waitbar(0,['removing velocity vectors, fix1']);% display a wait bar |
---|
[12] | 1713 | test_mask=get(handles.get_mask_fix1,'Value'); |
---|
| 1714 | if test_mask |
---|
| 1715 | maskdispl=get(handles.mask_fix1,'String'); |
---|
| 1716 | if exist(maskdispl,'file') |
---|
| 1717 | test_mask=2; |
---|
| 1718 | maskname=maskdispl; |
---|
| 1719 | else |
---|
| 1720 | maskbase=[get(handles.displ_filebase,'String') '_' maskdispl]; % mask root name |
---|
| 1721 | end |
---|
| 1722 | end |
---|
[2] | 1723 | for ifile=1:nbfield |
---|
| 1724 | waitbar(ifile/nbfield); %update the waitbar |
---|
| 1725 | for j=1:nbslice |
---|
| 1726 | if test_mask==0 |
---|
| 1727 | maskname='noFile use default'; |
---|
| 1728 | maskflag=0; |
---|
[12] | 1729 | elseif test_mask==1 |
---|
[2] | 1730 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 1731 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
| 1732 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i');% mask corresponding to the first image of the pair |
---|
| 1733 | maskflag= exist(maskname,'file')==2; |
---|
| 1734 | if ~maskflag; |
---|
| 1735 | maskname='noFile use default'; |
---|
| 1736 | end |
---|
| 1737 | end |
---|
| 1738 | if ~isempty(file_ref_fix1) |
---|
| 1739 | file_ref=file_ref_fix1{ifile,j}; |
---|
| 1740 | else |
---|
| 1741 | file_ref=''; |
---|
| 1742 | end |
---|
| 1743 | error=RUN_FIX(filecell.nc.civ1{ifile,j},field1,flagindex,1,thresh_vecC,maskflag,maskname,... |
---|
| 1744 | thresh_vel,inf_sup,file_ref,fieldchoice); |
---|
| 1745 | |
---|
| 1746 | if compare==3 &&(isequal(mode,'pair j1-j2') || isequal(mode,'series(Dj)') || isequal(mode,'series(Di)')) |
---|
| 1747 | if test_mask==0 |
---|
| 1748 | maskname='noFile use default'; |
---|
| 1749 | maskflag=0; |
---|
| 1750 | else |
---|
| 1751 | maskbase=[get(handles.displ_filebase2,'String') '_' maskdispl]; % mask root name |
---|
| 1752 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 1753 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
| 1754 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 1755 | maskflag= exist(maskname,'file')==2; |
---|
| 1756 | if ~maskflag; |
---|
| 1757 | maskname='noFile use default'; |
---|
| 1758 | end |
---|
| 1759 | end |
---|
| 1760 | error=RUN_FIX(filecell.ncA.civ1{ifile,j},field1,flagindex,1,thresh_vecC,maskflag,maskname,... |
---|
| 1761 | thresh_vel,inf_sup,file_ref,fieldchoice); |
---|
| 1762 | if ~isempty(error) |
---|
| 1763 | msgbox_uvmat('ERROR',error) |
---|
| 1764 | return |
---|
| 1765 | end |
---|
| 1766 | end |
---|
| 1767 | end |
---|
| 1768 | end |
---|
| 1769 | close(h) |
---|
| 1770 | end |
---|
| 1771 | |
---|
| 1772 | % RUN PATCH1 |
---|
| 1773 | if box_test(3)==1 |
---|
| 1774 | rho_patch1=str2num(get(handles.rho_patch1,'String')); |
---|
| 1775 | if isempty(rho_patch1) |
---|
| 1776 | rho_patch1='1000'; |
---|
| 1777 | set(handles.rho_patch1,'String','1') |
---|
| 1778 | else |
---|
| 1779 | rho_patch1=num2str(1000*rho_patch1); |
---|
| 1780 | end |
---|
| 1781 | nx_patch1=get(handles.nx_patch1,'String'); |
---|
| 1782 | if isequal(str2num(nx_patch1),[]) |
---|
| 1783 | nx_patch1='50' ;%default |
---|
| 1784 | set(handles.nx_patch1,'String','50'); |
---|
| 1785 | end |
---|
| 1786 | ny_patch1=get(handles.ny_patch1,'String'); |
---|
| 1787 | if isequal(str2num(ny_patch1),[]) |
---|
| 1788 | ny_patch1='50' ;%default |
---|
| 1789 | set(handles.ny_patch1,'String','50'); |
---|
| 1790 | end |
---|
| 1791 | subdomain_patch1=get(handles.subdomain_patch1,'String'); |
---|
| 1792 | thresh_patch1=get(handles.thresh_patch1,'String'); |
---|
| 1793 | test_interp=get(handles.test_interp,'Value'); |
---|
| 1794 | icount=0; |
---|
| 1795 | for ifile=1:nbfield |
---|
| 1796 | for j=1:nbslice |
---|
| 1797 | icount=icount+1; |
---|
| 1798 | barlength=0.188*icount/(nbfield*nbslice); |
---|
| 1799 | set(handles.waitbar_patch1,'Position',[0.946 0.627-barlength 0.03 barlength]) |
---|
| 1800 | drawnow |
---|
| 1801 | if isequal(get(handles.test_stereo1,'Value'),0) |
---|
| 1802 | cmd=RUN_PATCH(filecell.nc.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp); |
---|
| 1803 | s=-1; |
---|
| 1804 | if sge |
---|
| 1805 | [s,w]=unix(['qrsh -q -fast.q ' cmd]); |
---|
| 1806 | end |
---|
| 1807 | if s~=0 |
---|
| 1808 | display(['!' cmd]) |
---|
| 1809 | eval(['!' cmd]); |
---|
| 1810 | end |
---|
| 1811 | |
---|
| 1812 | %stereo case: |
---|
| 1813 | elseif isequal(get(handles.test_stereo1,'Value'),1) |
---|
| 1814 | if exist('stinterp_exe','var')%Prog Gauthier |
---|
| 1815 | cmd=RUN_STINTERP(stinterp_exe,filecell.ncA.civ1{ifile,j},filecell.nc.civ1{ifile,j},filecell.st{ifile,j},... |
---|
| 1816 | nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,[filebase_A '.xml'],[filebase_B '.xml']); |
---|
| 1817 | display(['!' cmd]) |
---|
| 1818 | eval(['!' cmd]); |
---|
| 1819 | else |
---|
| 1820 | RUN_STLIN(filecell.ncA.civ1{ifile,j},filecell.nc.civ1{ifile,j},'civ1',filecell.st{ifile,j},... |
---|
| 1821 | str2num(nx_patch1),str2num(ny_patch1),str2num(thresh_patch1),[filebase_A '.xml'],[filebase_B '.xml']); |
---|
| 1822 | end |
---|
| 1823 | end |
---|
| 1824 | if compare==3 && isequal(get(handles.test_stereo1,'Value'),0) |
---|
| 1825 | cmd=RUN_PATCH(filecell.ncA.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp); |
---|
| 1826 | s=-1; |
---|
| 1827 | if sge |
---|
| 1828 | [s,w]=unix(['qrsh -q -fast.q ' cmd]); |
---|
| 1829 | end |
---|
| 1830 | if s~=0 |
---|
| 1831 | display(['!' cmd]) |
---|
| 1832 | eval(['!' cmd]); |
---|
| 1833 | end |
---|
| 1834 | end |
---|
| 1835 | end |
---|
| 1836 | end |
---|
| 1837 | end |
---|
| 1838 | |
---|
| 1839 | % CIV2 |
---|
| 1840 | if box_test(4)==1 |
---|
| 1841 | RUN_CIV2(handles,filecell.ima1.civ2,filecell.ima2.civ2,filecell.nc.civ1,filecell.nc.civ2,num1_civ2,num2_civ2,... |
---|
| 1842 | num_a_civ2,num_b_civ2,nom_type_nc) |
---|
| 1843 | end |
---|
| 1844 | |
---|
| 1845 | % FIX2 |
---|
| 1846 | if box_test(5)==1 |
---|
| 1847 | %names of the civ2 fields |
---|
| 1848 | field2.vel_type='civ2'; |
---|
| 1849 | field2.nb='nb_vectors2'; |
---|
| 1850 | field2.X='vec2_X'; |
---|
| 1851 | field2.Y='vec2_Y'; |
---|
| 1852 | field2.U='vec2_U'; |
---|
| 1853 | field2.V='vec2_V'; |
---|
| 1854 | field2.fixflag='vec2_FixFlag'; |
---|
| 1855 | flagindex(1)=get(handles.vec_Fmin2_2, 'Value'); |
---|
| 1856 | flagindex(2)=get(handles.vec_F3_2, 'Value'); |
---|
| 1857 | flagindex(3)=get(handles.vec_F4, 'Value'); |
---|
| 1858 | thresh_vec2C=str2num(get(handles.thresh_vec2C,'String'));%threshold on image correlation vec_C |
---|
| 1859 | thresh_vel2=str2num(get(handles.thresh_vel2,'String'));%threshold on velocity modulus |
---|
| 1860 | inf_sup=get(handles.inf_sup2,'Value'); |
---|
| 1861 | menu=get(handles.field_ref2,'String'); |
---|
| 1862 | index=get(handles.field_ref2,'Value'); |
---|
| 1863 | if isempty(menu) |
---|
| 1864 | fieldchoice=''; |
---|
| 1865 | else |
---|
| 1866 | fieldchoice=menu{index}; |
---|
| 1867 | end |
---|
| 1868 | h = waitbar(0,['removing velocity vectors, fix2']);% display a wait bar |
---|
| 1869 | test_mask=get(handles.get_mask_fix2,'Value'); |
---|
[12] | 1870 | if test_mask |
---|
| 1871 | maskdispl=get(handles.mask_fix2,'String'); |
---|
| 1872 | if exist(maskdispl,'file') |
---|
| 1873 | test_mask=2; |
---|
| 1874 | maskname=maskdispl; |
---|
| 1875 | else |
---|
| 1876 | maskbase=[get(handles.displ_filebase,'String') '_' maskdispl]; % mask root name |
---|
| 1877 | end |
---|
| 1878 | end |
---|
[2] | 1879 | for ifile=1:nbfield |
---|
| 1880 | waitbar(ifile/nbfield); %update the waitbar |
---|
| 1881 | for j=1:nbslice |
---|
| 1882 | if test_mask==0 |
---|
| 1883 | maskname='noFile use default'; |
---|
| 1884 | maskflag=0; |
---|
[12] | 1885 | elseif test_mask==1 |
---|
[2] | 1886 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 1887 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
| 1888 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 1889 | maskflag= exist(maskname,'file')==2; |
---|
| 1890 | if ~maskflag; |
---|
| 1891 | maskname='noFile use default'; |
---|
| 1892 | end |
---|
| 1893 | end |
---|
| 1894 | if ~isempty(file_ref_fix2) |
---|
| 1895 | file_ref=file_ref_fix2{ifile,j}; |
---|
| 1896 | else |
---|
| 1897 | file_ref=''; |
---|
| 1898 | end |
---|
| 1899 | error=RUN_FIX(filecell.nc.civ2{ifile,j},field2,flagindex,2,thresh_vec2C,maskflag,maskname,... |
---|
| 1900 | thresh_vel2,inf_sup,file_ref,fieldchoice); |
---|
| 1901 | if ~isempty(error) |
---|
| 1902 | msgbox_uvmat('ERROR',error) |
---|
| 1903 | return |
---|
| 1904 | end |
---|
| 1905 | if compare==3 |
---|
| 1906 | if test_mask==0 |
---|
| 1907 | maskname='noFile use default'; |
---|
| 1908 | maskflag=0; |
---|
| 1909 | else |
---|
| 1910 | maskbase=[get(handles.displ_filebase2,'String') '_' maskdispl]; % mask root name |
---|
| 1911 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 1912 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
| 1913 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 1914 | maskflag= exist(maskname,'file')==2; |
---|
| 1915 | if ~maskflag; |
---|
| 1916 | maskname='noFile use default'; |
---|
| 1917 | end |
---|
| 1918 | end |
---|
| 1919 | error=RUN_FIX(filecell.ncA.civ2{ifile,j},field2,flagindex,1,thresh_vec2C,maskflag,maskname,... |
---|
| 1920 | thresh_vel2,inf_sup,file_ref,fieldchoice); |
---|
| 1921 | if ~isempty(error) |
---|
| 1922 | msgbox_uvmat('ERROR',error) |
---|
| 1923 | return |
---|
| 1924 | end |
---|
| 1925 | end |
---|
| 1926 | end |
---|
| 1927 | end |
---|
| 1928 | close(h) |
---|
| 1929 | end |
---|
| 1930 | |
---|
| 1931 | %PATCH 2 |
---|
| 1932 | if box_test(6)==1 |
---|
| 1933 | rho_patch2=str2num(get(handles.rho_patch2,'String')); |
---|
| 1934 | if isempty(rho_patch2) |
---|
| 1935 | rho_patch2='1000'; |
---|
| 1936 | set(handles.rho_patch2,'String','1') |
---|
| 1937 | else |
---|
| 1938 | rho_patch2=num2str(1000*rho_patch2); |
---|
| 1939 | end |
---|
| 1940 | nx_patch2=get(handles.nx_patch2,'String'); |
---|
| 1941 | ny_patch2=get(handles.ny_patch2,'String'); |
---|
| 1942 | thresh_patch2=get(handles.thresh_patch2,'String'); |
---|
| 1943 | if isequal(str2num(nx_patch2),[]) |
---|
| 1944 | nx_patch2='50' ;%default |
---|
| 1945 | set(handles.nx_patch2,'String','50'); |
---|
| 1946 | end |
---|
| 1947 | if isequal(str2num(ny_patch2),[]) |
---|
| 1948 | ny_patch2='50' ;%default |
---|
| 1949 | set(handles.ny_patch2,'String','50'); |
---|
| 1950 | end |
---|
| 1951 | subdomain_patch2=get(handles.subdomain_patch2,'String'); |
---|
| 1952 | icount=0; |
---|
| 1953 | for ifile=1:nbfield |
---|
| 1954 | for j=1:nbslice |
---|
| 1955 | icount=icount+1; |
---|
| 1956 | barlength=0.188*icount/(nbfield*nbslice); |
---|
| 1957 | set(handles.waitbar_patch2,'Position',[0.946 0.188-barlength 0.03 barlength]) |
---|
| 1958 | drawnow |
---|
| 1959 | if compare~=3 | isequal(get(handles.test_stereo2,'Value'),0) |
---|
| 1960 | cmd=RUN_PATCH(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,1,0); |
---|
| 1961 | s=-1; |
---|
| 1962 | if sge |
---|
| 1963 | [s,w]=unix(['qrsh -q -fast.q ' cmd]); |
---|
| 1964 | end |
---|
| 1965 | if s~=0 |
---|
| 1966 | display(['!' cmd]) |
---|
| 1967 | eval(['!' cmd]); |
---|
| 1968 | end |
---|
| 1969 | elseif compare==3 && isequal(get(handles.test_stereo2,'Value'),1) |
---|
| 1970 | if exist('stinterp_exe','var')%Prog Gauthier |
---|
| 1971 | cmd=RUN_STINTERP(stinterp_exe,filecell.ncA.civ2{ifile,j},filecell.nc.civ2{ifile,j},filecell.st{ifile,j},... |
---|
| 1972 | nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,[filebase_A '.xml'],[filebase_B '.xml']); |
---|
| 1973 | display(['!' cmd]) |
---|
| 1974 | eval(['!' cmd]) |
---|
| 1975 | else |
---|
| 1976 | RUN_STLIN(filecell.ncA.civ2{ifile,j},filecell.nc.civ2{ifile,j},'civ2',filecell.st{ifile,j},... |
---|
| 1977 | str2num(nx_patch2),str2num(ny_patch2),str2num(thresh_patch2),[filebase_A '.xml'],[filebase_B '.xml']) |
---|
| 1978 | end |
---|
| 1979 | end |
---|
| 1980 | if compare==3 && isequal(get(handles.test_stereo2,'Value'),0) |
---|
| 1981 | cmd=RUN_PATCH(filecell.ncA.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,1,0); |
---|
| 1982 | s=-1; |
---|
| 1983 | if sge |
---|
| 1984 | [s,w]=unix(['qrsh -q -fast.q ' cmd]); |
---|
| 1985 | end |
---|
| 1986 | if s~=0 |
---|
| 1987 | display(['!' cmd]) |
---|
| 1988 | eval(['!' cmd]); |
---|
| 1989 | end |
---|
| 1990 | end |
---|
| 1991 | end |
---|
| 1992 | end |
---|
| 1993 | end |
---|
| 1994 | |
---|
| 1995 | set(handles.RUN, 'Enable','On') |
---|
| 1996 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 1997 | |
---|
| 1998 | %save the current interface setting as figure namefig, append .0 to the name if it already exists |
---|
| 1999 | if isfield(filecell,'st') |
---|
| 2000 | fileresu=filecell.st{1,1}; |
---|
| 2001 | elseif isfield(filecell,'nc') |
---|
| 2002 | if isfield(filecell.nc,'civ2') |
---|
| 2003 | fileresu=filecell.nc.civ2{1,1}; |
---|
| 2004 | else |
---|
| 2005 | fileresu=filecell.nc.civ1{1,1}; |
---|
| 2006 | end |
---|
| 2007 | end |
---|
| 2008 | [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileresu); |
---|
| 2009 | namedoc=fullfile(RootPath,subdir,RootFile); |
---|
| 2010 | detect=1; |
---|
| 2011 | while detect==1 |
---|
| 2012 | namefigfull=[namedoc '.fig']; |
---|
| 2013 | hh=dir(namefigfull); |
---|
| 2014 | if ~isempty(hh) |
---|
| 2015 | detect=1; |
---|
| 2016 | namedoc=[namedoc '.0']; |
---|
| 2017 | else |
---|
| 2018 | detect=0; |
---|
| 2019 | end |
---|
| 2020 | end |
---|
| 2021 | saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) |
---|
| 2022 | |
---|
[12] | 2023 | %------------------------------------------------------------------------ |
---|
[2] | 2024 | % --- Executes on button press in BATCH: remote processing |
---|
| 2025 | function BATCH_Callback(hObject, eventdata, handles) |
---|
[12] | 2026 | %------------------------------------------------------------------------ |
---|
[2] | 2027 | global civ1_exe civ2_exe patch_exe patch_new_exe fix_exe todo_path sge Civ_exe |
---|
| 2028 | compare=get(handles.compare,'Value');%test for usual PIV (compare=1) or displacement (=2) or stereo PIV (=3) |
---|
| 2029 | |
---|
| 2030 | %check the list of operations: |
---|
| 2031 | operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'}; |
---|
| 2032 | run_flag=1; |
---|
| 2033 | box_test(1)=get(handles.CIV1,'Value'); |
---|
| 2034 | box_test(2)=get(handles.FIX1,'Value'); |
---|
| 2035 | box_test(3)=get(handles.PATCH1,'Value'); |
---|
| 2036 | box_test(4)=get(handles.CIV2,'Value'); |
---|
| 2037 | box_test(5)=get(handles.FIX2,'Value'); |
---|
| 2038 | box_test(6)=get(handles.PATCH2,'Value'); |
---|
| 2039 | index=find(box_test==1); |
---|
| 2040 | if isempty(index) |
---|
| 2041 | msgbox_uvmat('ERROR','no selected operation') |
---|
| 2042 | return |
---|
| 2043 | end |
---|
| 2044 | index_first=min(index); |
---|
| 2045 | index_last=max(index); |
---|
| 2046 | box_used=box_test([index_first : index_last]); |
---|
| 2047 | [box_missing,ind_missing]=min(box_used); |
---|
| 2048 | if isequal(box_missing,0) |
---|
| 2049 | msgbox_uvmat('ERROR',['missing' cell2mat(operations(ind_missing))]); |
---|
| 2050 | return |
---|
| 2051 | end |
---|
| 2052 | |
---|
| 2053 | %root name |
---|
| 2054 | filebase=get(handles.displ_filebase,'String'); |
---|
| 2055 | if isempty(filebase)||isequal(filebase,'') |
---|
| 2056 | msgbox_uvmat('ERROR','no input files') |
---|
| 2057 | return |
---|
| 2058 | end |
---|
| 2059 | |
---|
| 2060 | %check mask if selecetd |
---|
| 2061 | if isequal(get(handles.get_mask_civ1,'Value'),1) |
---|
[12] | 2062 | maskname=get(handles.mask_civ1,'String'); |
---|
| 2063 | if ~exist(maskname,'file') |
---|
| 2064 | get_mask_civ1_Callback(hObject, eventdata, handles); |
---|
| 2065 | end |
---|
[2] | 2066 | end |
---|
| 2067 | if isequal(get(handles.get_mask_fix1,'Value'),1) |
---|
[12] | 2068 | maskname=get(handles.mask_fix1,'String'); |
---|
| 2069 | if ~exist(maskname,'file') |
---|
| 2070 | get_mask_fix1_Callback(hObject, eventdata, handles); |
---|
| 2071 | end |
---|
[2] | 2072 | end |
---|
| 2073 | if isequal(get(handles.get_mask_civ2,'Value'),1) |
---|
[12] | 2074 | maskname=get(handles.mask_civ2,'String'); |
---|
| 2075 | if ~exist(maskname,'file') |
---|
[2] | 2076 | get_mask_civ2_Callback(hObject, eventdata, handles); |
---|
[12] | 2077 | end |
---|
[2] | 2078 | end |
---|
| 2079 | if isequal(get(handles.get_mask_fix2,'Value'),1) |
---|
[12] | 2080 | maskname=get(handles.mask_fix2,'String'); |
---|
| 2081 | if ~exist(maskname,'file') |
---|
[2] | 2082 | get_mask_fix2_Callback(hObject, eventdata, handles); |
---|
[12] | 2083 | end |
---|
[2] | 2084 | end |
---|
| 2085 | |
---|
| 2086 | %read names of the .exe file |
---|
| 2087 | path_uvmat=which('uvmat');% check the path detected for source file uvmat |
---|
| 2088 | path_UVMAT=fileparts(path_uvmat); %path to UVMAT |
---|
| 2089 | if isunix |
---|
| 2090 | xmlfile=fullfile(path_UVMAT,'PARAM_LINUX.xml'); |
---|
| 2091 | if exist(xmlfile,'file') |
---|
| 2092 | t=xmltree(xmlfile); |
---|
| 2093 | sparam=convert(t); |
---|
| 2094 | end |
---|
| 2095 | else |
---|
| 2096 | xmlfile=fullfile(path_UVMAT,'PARAM_WIN.xml'); |
---|
| 2097 | if exist(xmlfile,'file') |
---|
| 2098 | t=xmltree(xmlfile); |
---|
| 2099 | sparam=convert(t); |
---|
| 2100 | end |
---|
| 2101 | end |
---|
| 2102 | sge=0; |
---|
| 2103 | if isfield(sparam,'Civ_exe') |
---|
| 2104 | Civ_exe=sparam.Civ_exe; |
---|
| 2105 | end |
---|
| 2106 | if isfield(sparam,'Civ1_exe') |
---|
| 2107 | civ1_exe=sparam.Civ1_exe; |
---|
| 2108 | end |
---|
| 2109 | if isfield(sparam,'Civ2_exe') |
---|
| 2110 | civ2_exe=sparam.Civ2_exe; |
---|
| 2111 | end |
---|
| 2112 | if isfield(sparam,'Patch_exe') |
---|
| 2113 | patch_exe=sparam.Patch_exe; |
---|
| 2114 | end |
---|
| 2115 | if isfield(sparam,'PatchNew_exe') |
---|
| 2116 | patch_new_exe=sparam.PatchNew_exe; |
---|
| 2117 | end |
---|
| 2118 | if isfield(sparam,'Fix_exe') |
---|
| 2119 | fix_exe=sparam.Fix_exe; |
---|
| 2120 | end |
---|
| 2121 | if isfield(sparam,'Todo_path') |
---|
| 2122 | todo_path=sparam.Todo_path; |
---|
| 2123 | end |
---|
| 2124 | if isfield(sparam,'SGE') |
---|
| 2125 | sge=str2num(sparam.SGE); |
---|
| 2126 | end |
---|
| 2127 | |
---|
| 2128 | %choice of batch priority |
---|
| 2129 | ind_answer=2; |
---|
| 2130 | if sge |
---|
| 2131 | [s,w]=unix('qstat -q civ.q|grep job_| wc -l'); %check the waiting list (command unix) |
---|
| 2132 | if isequal(s,0) |
---|
| 2133 | w(end)=[]; |
---|
| 2134 | str_displ={[w ' jobs in the waiting list'];'Select a priority:'}; |
---|
| 2135 | str={'urgent';'normal';'low'}; |
---|
| 2136 | [ind_answer,v] = listdlg('PromptString',str_displ,... |
---|
| 2137 | 'SelectionMode','single',... |
---|
| 2138 | 'ListString',str,'ListSize',[200 200],'Name','job priority','InitialValue',3); |
---|
| 2139 | if isequal(v,0) % to handle Cancel button and figure close, |
---|
| 2140 | return % a better way should be create |
---|
| 2141 | end |
---|
| 2142 | else |
---|
| 2143 | msgbox_uvmat('ERROR','batch system not available') |
---|
| 2144 | return |
---|
| 2145 | end |
---|
| 2146 | end |
---|
| 2147 | |
---|
| 2148 | %initialize the waitbars |
---|
| 2149 | set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001]) |
---|
| 2150 | set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001]) |
---|
| 2151 | set(handles.waitbar_civ2,'Position',[0.946 0.219 0.03 0.001]) |
---|
| 2152 | set(handles.waitbar_patch2,'Position',[0.946 0.0 0.03 0.001]) |
---|
| 2153 | set(handles.BATCH, 'Enable','Off') |
---|
| 2154 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 2155 | drawnow |
---|
| 2156 | %get the filename root, nomenclature and numbers |
---|
| 2157 | |
---|
| 2158 | % for Windows system find the UBC path name if needed |
---|
| 2159 | if ~isunix & isequal(todo_path(1:2),'\\') & isequal(filebase(2:3),':\') |
---|
| 2160 | cur_dir=pwd; |
---|
| 2161 | if ~isequal(cur_dir(2:3),':\') |
---|
| 2162 | cd(matlabroot); %move to the Matlab root directory if the current Matlab dir does not allow the dos command or is M: |
---|
| 2163 | end |
---|
| 2164 | [ss,ww]=dos(['net use ' filebase(1:2)]); |
---|
| 2165 | if isequal(ss,0) |
---|
| 2166 | rankpath=findstr(ww,'\\'); |
---|
| 2167 | if ~isempty(rankpath) |
---|
| 2168 | wwrest=ww(rankpath:end); |
---|
| 2169 | rankend=min(find(double(wwrest)==10))-1; |
---|
| 2170 | filebase=[wwrest(1:rankend) filebase(3:end)]; |
---|
| 2171 | set(handles.displ_filebase,'String',filebase); |
---|
| 2172 | end |
---|
| 2173 | else |
---|
| 2174 | msgbox_uvmat('ERROR','for BATCH option, UBC file names, beginning by \\, are needed'); |
---|
| 2175 | set(handles.BATCH, 'Enable','On') |
---|
| 2176 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 2177 | return |
---|
| 2178 | end |
---|
| 2179 | end |
---|
| 2180 | |
---|
| 2181 | % set the list of files and check them |
---|
| 2182 | display('checking the files...') |
---|
| 2183 | [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]=... |
---|
| 2184 | set_civ_filenames(handles,compare,box_test); |
---|
[41] | 2185 | |
---|
[2] | 2186 | display('files OK, processing...') |
---|
[41] | 2187 | nbfield=numel(num1_civ1); |
---|
| 2188 | nbslice=numel(num_a_civ1); |
---|
[2] | 2189 | |
---|
| 2190 | %GET PARAMETERS: |
---|
| 2191 | %get civ parameters |
---|
| 2192 | if box_test(1)==1 |
---|
| 2193 | par_civ1=read_param_civ1(handles,filecell.ima1.civ1{1,1}); |
---|
| 2194 | end |
---|
| 2195 | |
---|
| 2196 | %get fix1 parameters |
---|
| 2197 | if box_test(2)==1 |
---|
| 2198 | flagindex1(1)=get(handles.vec_Fmin2, 'Value'); |
---|
| 2199 | flagindex1(2)=get(handles.vec_F3, 'Value'); |
---|
| 2200 | flagindex1(3)=get(handles.vec_F2, 'Value'); |
---|
| 2201 | thresh_vecC1=str2num(get(handles.thresh_vecC,'String'));%threshold on image correlation vec_C |
---|
| 2202 | thresh_vel1=str2num(get(handles.thresh_vel,'String'));%threshold on velocity modulus |
---|
| 2203 | test_mask=get(handles.get_mask_fix1,'Value'); |
---|
| 2204 | nbslice_mask=get(handles.mask_fix1,'UserData'); % get the number of slices (= number of masks) |
---|
| 2205 | %%%%%%%%%%%%%COMPLETER LE PROGRAMME FIX |
---|
| 2206 | % inf_sup=get(handles.inf_sup1,'Value'); |
---|
| 2207 | % fileref=get(handles.ref_fix1,'String'); |
---|
| 2208 | % refpath=get(handles.ref_fix1,'UserData'); |
---|
| 2209 | % fileref=fullfile(refpath,fileref); |
---|
| 2210 | menu=get(handles.field_ref1,'String'); |
---|
| 2211 | index=get(handles.field_ref1,'Value'); |
---|
| 2212 | if isempty(menu) |
---|
| 2213 | fieldchoice=''; |
---|
| 2214 | else |
---|
| 2215 | fieldchoice=menu{index}; |
---|
| 2216 | msgbox_uvmat('WARNING','reference field is not used presently with batch, use RUN option') |
---|
| 2217 | end |
---|
| 2218 | end |
---|
| 2219 | |
---|
| 2220 | %get patch1 parameters |
---|
| 2221 | if box_test(3)==1 |
---|
| 2222 | rho_patch1=str2num(get(handles.rho_patch1,'String')); |
---|
| 2223 | if isempty(rho_patch1) |
---|
| 2224 | rho_patch1='1000'; |
---|
| 2225 | set(handles.rho_patch1,'String','1') |
---|
| 2226 | else |
---|
| 2227 | rho_patch1=num2str(1000*rho_patch1); |
---|
| 2228 | end |
---|
| 2229 | nx_patch1=get(handles.nx_patch1,'String'); |
---|
| 2230 | ny_patch1=get(handles.ny_patch1,'String'); |
---|
| 2231 | if isequal(str2num(nx_patch1),[]) |
---|
| 2232 | nx_patch1='50' ;%default |
---|
| 2233 | set(handles.nx_patch1,'String','50'); |
---|
| 2234 | end |
---|
| 2235 | if isequal(str2num(ny_patch1),[]) |
---|
| 2236 | ny_patch1='50' ;%default |
---|
| 2237 | set(handles.ny_patch1,'String','50'); |
---|
| 2238 | end |
---|
| 2239 | subdomain_patch1=get(handles.subdomain_patch1,'String'); |
---|
| 2240 | thresh_patch1=get(handles.thresh_patch1,'String'); |
---|
| 2241 | test_interp=get(handles.test_interp,'Value'); |
---|
| 2242 | end |
---|
| 2243 | |
---|
| 2244 | %get civ2 parameters |
---|
| 2245 | if box_test(4)==1 |
---|
| 2246 | par_civ2=read_param_civ2(handles,cell2mat(filecell.ima1.civ2(1,1))); |
---|
| 2247 | end |
---|
| 2248 | |
---|
| 2249 | %get fix2 parameters |
---|
| 2250 | if box_test(5)==1 |
---|
| 2251 | flagindex2(1)=get(handles.vec_Fmin2_2, 'Value'); |
---|
| 2252 | flagindex2(2)=get(handles.vec_F3_2, 'Value'); |
---|
| 2253 | flagindex2(3)=get(handles.vec_F4, 'Value'); |
---|
| 2254 | thresh_vec2C=str2num(get(handles.thresh_vec2C,'String'));%threshold on image correlation vec_C |
---|
| 2255 | thresh_vel2=str2num(get(handles.thresh_vel2,'String'));%threshold on velocity modulus |
---|
| 2256 | test_mask=get(handles.get_mask_fix2,'Value'); |
---|
| 2257 | nbslice_mask=get(handles.mask_fix2,'UserData'); % get the number of slices (= number of masks) |
---|
| 2258 | %%%%%%%%%%%%%COMPLETER LE PROGRAMME FIX AVEC REF FILE ET OPTION inf_sup=2 |
---|
| 2259 | % inf_sup=get(handles.inf_sup2,'Value'); |
---|
| 2260 | % ref=get(handles.ref_fix2,'UserData'); |
---|
| 2261 | |
---|
| 2262 | %%%%%%%%%%%%%%%%%%% |
---|
| 2263 | end |
---|
| 2264 | |
---|
| 2265 | |
---|
| 2266 | %get patch2 parameters |
---|
| 2267 | if box_test(6)==1 |
---|
| 2268 | rho_patch2=str2num(get(handles.rho_patch2,'String')); |
---|
| 2269 | if isempty(rho_patch2) |
---|
| 2270 | rho_patch2='1000'; |
---|
| 2271 | set(handles.rho_patch2,'String','1') |
---|
| 2272 | else |
---|
| 2273 | rho_patch2=num2str(1000*rho_patch2); |
---|
| 2274 | end |
---|
| 2275 | nx_patch2=get(handles.nx_patch2,'String'); |
---|
| 2276 | ny_patch2=get(handles.ny_patch2,'String'); |
---|
| 2277 | if isequal(str2num(nx_patch2),[]) |
---|
| 2278 | nx_patch2='50' ;%default |
---|
| 2279 | set(handles.nx_patch2,'String','50'); |
---|
| 2280 | end |
---|
| 2281 | if isequal(str2num(ny_patch2),[]) |
---|
| 2282 | ny_patch2='50' ;%default |
---|
| 2283 | set(handles.ny_patch2,'String','50'); |
---|
| 2284 | end |
---|
| 2285 | subdomain_patch2=get(handles.subdomain_patch2,'String'); |
---|
| 2286 | thresh_patch2=get(handles.thresh_patch2,'String'); |
---|
| 2287 | test_interp=get(handles.test_interp,'Value'); |
---|
| 2288 | end |
---|
| 2289 | |
---|
| 2290 | if ~sge |
---|
| 2291 | |
---|
| 2292 | %OPEN THE WAIT LIST FOR BATCH PROCESSES |
---|
| 2293 | name_lock=fullfile(todo_path,'lock'); %lock file |
---|
| 2294 | iwait=0; |
---|
| 2295 | while(exist(name_lock) & iwait<15) |
---|
| 2296 | pause(1); %wait 1 second |
---|
| 2297 | iwait=iwait+1; |
---|
| 2298 | end |
---|
| 2299 | if iwait==15 |
---|
| 2300 | msgbox_uvmat('ERROR',['I''m tired to wait for the lock file, please delete it then click again on BATCH' name_lock ]) |
---|
| 2301 | set(handles.BATCH, 'Enable','On') |
---|
| 2302 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 2303 | return |
---|
| 2304 | end |
---|
| 2305 | p0=fopen(name_lock,'w'); %create the file name_lock: prevents other users to interfere |
---|
| 2306 | name_todo=fullfile(todo_path,'TODO.txt'); |
---|
| 2307 | p1=fopen(name_todo,'a'); |
---|
| 2308 | if (p1<0) |
---|
| 2309 | msgbox_uvmat('ERROR',['error in opening ' name_todo]) |
---|
| 2310 | set(handles.BATCH, 'Enable','On') |
---|
| 2311 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 2312 | return; |
---|
| 2313 | end |
---|
| 2314 | end |
---|
| 2315 | |
---|
| 2316 | %MAIN LOOP |
---|
| 2317 | % for ifile=1:nbfield |
---|
| 2318 | p1text=[];%initiate command text |
---|
| 2319 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 2320 | civAll=get(handles.Experimental,'Value'); % Boolean for new civ excution method |
---|
[41] | 2321 | 'TESTbatch' |
---|
| 2322 | size(filecell.nc.civ1) |
---|
| 2323 | nbslice |
---|
| 2324 | nbfield |
---|
[2] | 2325 | for ifile=1:nbfield |
---|
| 2326 | for j=1:nbslice |
---|
| 2327 | i_cmd=0; |
---|
| 2328 | cmd=''; |
---|
| 2329 | if sge |
---|
[12] | 2330 | %fid=fopen([filename '.cmx'],'w') |
---|
[2] | 2331 | cmd='#!/bin/bash'; |
---|
[12] | 2332 | cmd=[cmd '\n' '#$ -cwd']; |
---|
| 2333 | cmd=[cmd '\n' 'hostname && date']; |
---|
[2] | 2334 | end |
---|
| 2335 | if civAll |
---|
| 2336 | civAllxml=xmltree;% xml contents, all parameters |
---|
| 2337 | civAllCmd=[]; |
---|
| 2338 | civAllxml=set(civAllxml,1,'name','CivDoc'); |
---|
| 2339 | end |
---|
| 2340 | % filecell.nc.civ1 |
---|
[41] | 2341 | filename_cmx=filecell.nc.civ1{ifile,j}%output netcdf file |
---|
| 2342 | filename_cmx(end-1:end)='cm';%name of cmx file |
---|
[2] | 2343 | filename_cmx=[filename_cmx 'x']; |
---|
| 2344 | |
---|
| 2345 | %CIV1 |
---|
| 2346 | if box_test(1)==1 |
---|
[41] | 2347 | par_civ1.filename_ima_a=filecell.ima1.civ1{ifile,j}; |
---|
[2] | 2348 | % par_civ1.filename_ima_a([end-3:end])=[];%remove .png extension |
---|
[41] | 2349 | par_civ1.filename_ima_b=filecell.ima2.civ1{ifile,j}; |
---|
[2] | 2350 | % par_civ1.filename_ima_b([end-3:end])=[];%remove .png extension |
---|
| 2351 | |
---|
| 2352 | namelog=[filename_cmx([1:end-3]) 'log']; |
---|
| 2353 | par_civ1.Dt=num2str(time(num2_civ1(ifile),num_b_civ1(j))-time(num1_civ1(ifile),num_a_civ1(j))); |
---|
| 2354 | par_civ1.T0=num2str((time(num2_civ1(ifile),num_b_civ1(j))+time(num1_civ1(ifile),num_a_civ1(j)))/2); |
---|
| 2355 | par_civ1.term_a=num2stra(num_a_civ1(j),nom_type_nc);%UTILITE? |
---|
| 2356 | par_civ1.term_b=num2stra(num_b_civ1(j),nom_type_nc);% |
---|
| 2357 | test_mask=get(handles.get_mask_civ1,'Value'); |
---|
| 2358 | if test_mask==0 |
---|
| 2359 | par_civ1.maskname='noFile use default'; |
---|
| 2360 | par_civ1.maskflag='n'; |
---|
| 2361 | else |
---|
| 2362 | maskdispl=get(handles.mask_civ1,'String'); |
---|
[12] | 2363 | if exist(maskdispl,'file') |
---|
| 2364 | par_civ1.maskname=maskdispl; |
---|
| 2365 | par_civ1.maskflag='y'; |
---|
[2] | 2366 | else |
---|
[12] | 2367 | maskbase=[filebase '_' maskdispl]; % |
---|
| 2368 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 2369 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
| 2370 | par_civ1.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 2371 | if exist(par_civ1.maskname,'file') |
---|
| 2372 | par_civ1.maskflag='y'; |
---|
| 2373 | else |
---|
| 2374 | par_civ1.maskname='noFile use default'; |
---|
| 2375 | par_civ1.maskflag='n'; |
---|
| 2376 | end |
---|
[2] | 2377 | end |
---|
| 2378 | end |
---|
| 2379 | |
---|
| 2380 | %TESTgrid |
---|
| 2381 | test_grid=get(handles.browse_gridciv1,'Value'); |
---|
| 2382 | if test_grid |
---|
| 2383 | par_civ1.gridflag='y'; |
---|
| 2384 | gridname=get(handles.grid_civ1,'String'); |
---|
| 2385 | if isequal(gridname(end-3:end),'grid') |
---|
| 2386 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
| 2387 | if ~isempty(nbslice_grid) |
---|
| 2388 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
| 2389 | par_civ1.gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 2390 | if ~exist(par_civ1.gridname,'file') |
---|
| 2391 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
| 2392 | end |
---|
| 2393 | elseif exist(gridname,'file') |
---|
| 2394 | par_civ1.gridname=gridname; |
---|
| 2395 | else |
---|
| 2396 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
| 2397 | end |
---|
| 2398 | end |
---|
| 2399 | else |
---|
| 2400 | par_civ1.gridname='noFile use default'; |
---|
| 2401 | par_civ1.gridflag='n'; |
---|
| 2402 | end |
---|
| 2403 | %endTESTgrid |
---|
| 2404 | |
---|
| 2405 | i_cmd=i_cmd+1; |
---|
| 2406 | if isequal(civAll,0) |
---|
[12] | 2407 | cmd=[cmd '\n' BATCH_CIV1(filename_cmx(1:end-4),namelog,par_civ1,handles)]; |
---|
[2] | 2408 | else |
---|
| 2409 | civAllCmd=[civAllCmd ' civ1 ']; |
---|
| 2410 | str=BATCH_CIV1_Unified(filename_cmx([1:end-4]),namelog,par_civ1); |
---|
| 2411 | fieldnames=fields(str); |
---|
| 2412 | [civAllxml,uid_civ1]=add(civAllxml,1,'element','civ1'); |
---|
| 2413 | for ilist=1:length(fieldnames) |
---|
| 2414 | val=eval(['str.' fieldnames{ilist}]); |
---|
| 2415 | if ischar(val) |
---|
| 2416 | [civAllxml,uid_t]=add(civAllxml,uid_civ1,'element',fieldnames{ilist}); |
---|
| 2417 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2418 | end |
---|
| 2419 | end |
---|
| 2420 | end |
---|
| 2421 | end |
---|
| 2422 | |
---|
| 2423 | % FIX1 |
---|
| 2424 | if box_test(2)==1 |
---|
| 2425 | test_mask=get(handles.get_mask_fix1,'Value'); |
---|
| 2426 | if test_mask==0 |
---|
| 2427 | maskname=''; |
---|
| 2428 | else |
---|
| 2429 | maskdispl=get(handles.mask_fix1,'String'); |
---|
| 2430 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 2431 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
| 2432 | maskbase=[filebase '_' maskdispl]; |
---|
| 2433 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 2434 | end |
---|
| 2435 | if isequal(civAll,0) |
---|
| 2436 | cmd_FIX=[fix_exe ' -f ' filecell.nc.civ1{ifile,j} ' -fi1 ' num2str(flagindex1(1)) ... |
---|
| 2437 | ' -fi2 ' num2str(flagindex1(2)) ' -fi3 ' num2str(flagindex1(3)) ... |
---|
| 2438 | ' -threshC ' num2str(thresh_vecC1) ' -threshV ' num2str(thresh_vel1) ' -maskName ' maskname]; |
---|
[12] | 2439 | cmd=[cmd '\n' cmd_FIX]; |
---|
[2] | 2440 | else |
---|
| 2441 | fix1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 2442 | fix1.fi1=num2str(flagindex1(1)); |
---|
| 2443 | fix1.fi2=num2str(flagindex1(2)); |
---|
| 2444 | fix1.fi3=num2str(flagindex1(3)); |
---|
| 2445 | fix1.threshC=num2str(thresh_vecC1); |
---|
| 2446 | fix1.threshV=num2str(thresh_vel1); |
---|
| 2447 | fieldnames=fields(fix1); |
---|
| 2448 | [civAllxml,uid_fix1]=add(civAllxml,1,'element','fix1'); |
---|
| 2449 | for ilist=1:length(fieldnames) |
---|
| 2450 | val=eval(['fix1.' fieldnames{ilist}]); |
---|
| 2451 | if ischar(val) |
---|
| 2452 | [civAllxml,uid_t]=add(civAllxml,uid_fix1,'element',fieldnames{ilist}); |
---|
| 2453 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2454 | end |
---|
| 2455 | end |
---|
| 2456 | civAllCmd=[civAllCmd ' fix1 ']; |
---|
| 2457 | end |
---|
| 2458 | end |
---|
| 2459 | |
---|
| 2460 | %PATCH1 |
---|
| 2461 | if box_test(3)==1 |
---|
| 2462 | if isequal(civAll,0) |
---|
| 2463 | cmd_PATCH=RUN_PATCH(filecell.nc.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp); |
---|
[12] | 2464 | cmd=[cmd '\n' cmd_PATCH]; |
---|
[2] | 2465 | else |
---|
| 2466 | patch1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 2467 | patch1.nopt=subdomain_patch1; |
---|
| 2468 | patch1.maxdiff=thresh_patch1; |
---|
| 2469 | patch1.ro=rho_patch1; |
---|
| 2470 | test_grid=get(handles.get_gridpatch1,'Value'); |
---|
| 2471 | if test_grid |
---|
| 2472 | patch1.gridflag='y'; |
---|
| 2473 | gridname=get(handles.grid_patch1,'String'); |
---|
| 2474 | if isequal(gridname(end-3:end),'grid') |
---|
| 2475 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
| 2476 | if ~isempty(nbslice_grid) |
---|
| 2477 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
| 2478 | patch1.gridPatch=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 2479 | if ~exist(patch1.gridPatch,'file') |
---|
| 2480 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
| 2481 | end |
---|
| 2482 | elseif exist(gridname,'file') |
---|
| 2483 | patch1.gridPatch=gridname; |
---|
| 2484 | else |
---|
| 2485 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
| 2486 | end |
---|
| 2487 | end |
---|
| 2488 | else |
---|
| 2489 | patch1.gridPatch='n'; |
---|
| 2490 | patch1.gridflag='n'; |
---|
| 2491 | patch1.m=nx_patch1; |
---|
| 2492 | patch1.n=ny_patch1; |
---|
| 2493 | end |
---|
| 2494 | patch1.convectFlow='n'; |
---|
| 2495 | fieldnames=fields(patch1); |
---|
| 2496 | [civAllxml,uid_patch1]=add(civAllxml,1,'element','patch1'); |
---|
| 2497 | for ilist=1:length(fieldnames) |
---|
| 2498 | val=eval(['patch1.' fieldnames{ilist}]); |
---|
| 2499 | if ischar(val) |
---|
| 2500 | [civAllxml,uid_t]=add(civAllxml,uid_patch1,'element',fieldnames{ilist}); |
---|
| 2501 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2502 | end |
---|
| 2503 | end |
---|
| 2504 | civAllCmd=[civAllCmd ' patch1 ']; |
---|
| 2505 | end |
---|
| 2506 | end |
---|
| 2507 | |
---|
| 2508 | if box_test(4)==1 | box_test(5)==1 | box_test(6)==1 |
---|
| 2509 | filename_cmx=filecell.nc.civ2{ifile,j};%output netcdf file |
---|
| 2510 | filename_cmx([end-1:end])=[ 'cm'];%name of cmx file |
---|
| 2511 | filename_cmx=[filename_cmx 'x']; |
---|
| 2512 | end |
---|
| 2513 | |
---|
| 2514 | if box_test(4)==1 |
---|
| 2515 | par_civ2.filename_ima_a=filecell.ima1.civ2{ifile,j}; |
---|
| 2516 | %par_civ2.filename_ima_a([end-3:end])=[];%remove .png extension |
---|
| 2517 | par_civ2.filename_ima_b=filecell.ima2.civ2{ifile,j}; |
---|
| 2518 | %par_civ2.filename_ima_b([end-3:end])=[];%remove .png extension |
---|
| 2519 | namelog=[filename_cmx([1:end-3]) 'log']; |
---|
| 2520 | par_civ2.Dt=num2str(time(num2_civ2(ifile),num_b_civ2(j))-time(num1_civ2(ifile),num_a_civ2(j))); |
---|
| 2521 | par_civ2.T0=num2str((time(num2_civ1(ifile),num_b_civ2(j))+time(num1_civ2(ifile),num_a_civ2(j)))/2); |
---|
| 2522 | par_civ2.term_a=num2stra(num_a_civ2(j),nom_type_nc); |
---|
| 2523 | par_civ2.term_b=num2stra(num_b_civ2(j),nom_type_nc); |
---|
| 2524 | par_civ2.filename_nc1=filecell.nc.civ1{ifile,j}; |
---|
| 2525 | par_civ2.filename_nc1([end-2:end])=[]; % remove '.nc' |
---|
| 2526 | test_mask=get(handles.get_mask_civ2,'Value'); |
---|
| 2527 | if test_mask==0 |
---|
| 2528 | par_civ2.maskname='noFile use default'; |
---|
| 2529 | par_civ2.maskflag='n'; |
---|
| 2530 | else |
---|
| 2531 | maskdispl=get(handles.mask_civ2,'String'); |
---|
[12] | 2532 | if exist(maskdispl,'file') |
---|
| 2533 | par_civ2.maskname=maskdispl; |
---|
| 2534 | par_civ2.maskflag='y'; |
---|
[2] | 2535 | else |
---|
[12] | 2536 | maskbase=[filebase '_' maskdispl]; % |
---|
| 2537 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 2538 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
| 2539 | par_civ2.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 2540 | if exist(par_civ2.maskname,'file') |
---|
| 2541 | par_civ2.maskflag='y'; |
---|
| 2542 | else |
---|
| 2543 | par_civ2.maskname='noFile use default'; |
---|
| 2544 | par_civ2.maskflag='n'; |
---|
| 2545 | end |
---|
[2] | 2546 | end |
---|
| 2547 | end |
---|
| 2548 | %TESTgrid |
---|
| 2549 | test_grid=get(handles.browse_gridciv2,'Value'); |
---|
| 2550 | gridname=get(handles.grid_civ2,'String'); |
---|
| 2551 | gridflag='y'; |
---|
| 2552 | if numel(gridname)>=4 && isequal(gridname(end-3:end),'grid') |
---|
| 2553 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
| 2554 | if ~isempty(nbslice_grid) |
---|
| 2555 | par_civ2.gridflag='y'; |
---|
| 2556 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
| 2557 | par_civ2.gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 2558 | if exist(par_civ2.gridname,'file') |
---|
| 2559 | par_civ2.gridflag='y'; |
---|
| 2560 | else |
---|
| 2561 | par_civ2.gridname='noFile use default'; |
---|
| 2562 | par_civ2.gridflag='n'; |
---|
| 2563 | end |
---|
| 2564 | elseif exist(gridname,'file') |
---|
| 2565 | par_civ2.gridflag='y'; |
---|
| 2566 | else |
---|
| 2567 | par_civ2.gridname='noFile use default'; |
---|
| 2568 | par_civ2.gridflag='n'; |
---|
| 2569 | end |
---|
| 2570 | end |
---|
| 2571 | %endTESTgrid |
---|
| 2572 | i_cmd=i_cmd+1; |
---|
| 2573 | cmd_CIV2=BATCH_CIV2(filename_cmx,namelog,par_civ2); |
---|
| 2574 | if isequal(civAll,0) |
---|
| 2575 | if(isunix) |
---|
[12] | 2576 | cmd=[cmd '\n' 'cp -f ' filename_cmx '2 ' filename_cmx '\n' cmd_CIV2]; |
---|
[2] | 2577 | else |
---|
[12] | 2578 | cmd=[cmd '\n' 'copy /Y ' filename_cmx '2 ' filename_cmx '\n' cmd_CIV2]; |
---|
[2] | 2579 | end |
---|
| 2580 | else |
---|
| 2581 | civAllCmd=[civAllCmd ' civ2 ']; |
---|
| 2582 | str=BATCH_CIV2_Unified(filename_cmx([1:end-4]),namelog,par_civ2); |
---|
| 2583 | fieldnames=fields(str); |
---|
| 2584 | [civAllxml,uid_civ2]=add(civAllxml,1,'element','civ2'); |
---|
| 2585 | for ilist=1:length(fieldnames) |
---|
| 2586 | val=eval(['str.' fieldnames{ilist}]); |
---|
| 2587 | if ischar(val) |
---|
| 2588 | [civAllxml,uid_t]=add(civAllxml,uid_civ2,'element',fieldnames{ilist}); |
---|
| 2589 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2590 | end |
---|
| 2591 | end |
---|
| 2592 | end |
---|
| 2593 | end |
---|
| 2594 | |
---|
| 2595 | % FIX2 |
---|
[12] | 2596 | if box_test(5)==1 |
---|
[2] | 2597 | test_mask=get(handles.get_mask_fix2,'Value'); |
---|
| 2598 | if test_mask==0 |
---|
| 2599 | maskname=''; %no mask used |
---|
| 2600 | else |
---|
| 2601 | maskdispl=get(handles.mask_fix2,'String'); |
---|
| 2602 | maskbase=[filebase '_' maskdispl]; % |
---|
| 2603 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 2604 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
| 2605 | maskname =name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 2606 | end |
---|
| 2607 | if isequal(civAll,0) |
---|
| 2608 | cmd_FIX=[fix_exe ' -f ' filecell.nc.civ2{ifile,j} ' -fi1 ' num2str(flagindex2(1)) ... |
---|
| 2609 | ' -fi2 ' num2str(flagindex2(2)) ' -fi3 ' num2str(flagindex2(3)) ... |
---|
| 2610 | ' -threshC ' num2str(thresh_vec2C) ' -threshV ' num2str(thresh_vel2) ' -maskName ' maskname]; |
---|
[12] | 2611 | cmd=[cmd '\n' cmd_FIX]; |
---|
[2] | 2612 | else |
---|
| 2613 | fix2.inputFileName=filecell.nc.civ2{ifile,j} ; |
---|
| 2614 | fix2.fi1=num2str(flagindex2(1)); |
---|
| 2615 | fix2.fi2=num2str(flagindex2(2)); |
---|
| 2616 | fix2.fi3=num2str(flagindex2(3)); |
---|
| 2617 | fix2.threshC=num2str(thresh_vec2C); |
---|
| 2618 | fix2.threshV=num2str(thresh_vel2); |
---|
| 2619 | fieldnames=fields(fix2); |
---|
| 2620 | [civAllxml,uid_fix2]=add(civAllxml,1,'element','fix2'); |
---|
| 2621 | for ilist=1:length(fieldnames) |
---|
| 2622 | val=eval(['fix2.' fieldnames{ilist}]); |
---|
| 2623 | if ischar(val) |
---|
| 2624 | [civAllxml,uid_t]=add(civAllxml,uid_fix2,'element',fieldnames{ilist}); |
---|
| 2625 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2626 | end |
---|
| 2627 | end |
---|
| 2628 | civAllCmd=[civAllCmd ' fix2 ']; |
---|
| 2629 | end |
---|
| 2630 | end |
---|
| 2631 | |
---|
| 2632 | %PATCH2 |
---|
[12] | 2633 | if box_test(6)==1 |
---|
| 2634 | if isequal(civAll,0) |
---|
| 2635 | cmd_PATCH=RUN_PATCH(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,test_interp); |
---|
| 2636 | cmd=[cmd '\n' cmd_PATCH]; |
---|
| 2637 | else |
---|
| 2638 | patch2.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 2639 | patch2.nopt=subdomain_patch1; |
---|
| 2640 | patch2.maxdiff=thresh_patch1; |
---|
| 2641 | patch2.ro=rho_patch1; |
---|
| 2642 | test_grid=get(handles.get_gridpatch2,'Value'); |
---|
| 2643 | if test_grid |
---|
| 2644 | patch2.gridflag='y'; |
---|
| 2645 | gridname=get(handles.grid_patch2,'String'); |
---|
| 2646 | if isequal(gridname(end-3:end),'grid') |
---|
| 2647 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
| 2648 | if ~isempty(nbslice_grid) |
---|
| 2649 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
| 2650 | patch2.gridPatch=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 2651 | if ~exist(patch2.gridPatch,'file') |
---|
| 2652 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
| 2653 | end |
---|
| 2654 | elseif exist(gridname,'file') |
---|
| 2655 | patch2.gridPatch=gridname; |
---|
| 2656 | else |
---|
| 2657 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
[2] | 2658 | end |
---|
| 2659 | end |
---|
[12] | 2660 | else |
---|
| 2661 | patch2.gridPatch='n'; |
---|
| 2662 | patch2.gridflag='n'; |
---|
| 2663 | patch2.m=nx_patch2; |
---|
| 2664 | patch2.n=ny_patch2; |
---|
[2] | 2665 | end |
---|
[12] | 2666 | patch2.convectFlow='n'; |
---|
| 2667 | fieldnames=fields(patch2); |
---|
| 2668 | [civAllxml,uid_patch2]=add(civAllxml,1,'element','patch2'); |
---|
| 2669 | for ilist=1:length(fieldnames) |
---|
| 2670 | val=eval(['patch2.' fieldnames{ilist}]); |
---|
| 2671 | if ischar(val) |
---|
| 2672 | [civAllxml,uid_t]=add(civAllxml,uid_patch2,'element',fieldnames{ilist}); |
---|
| 2673 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2674 | end |
---|
| 2675 | end |
---|
| 2676 | civAllCmd=[civAllCmd ' patch2 ']; |
---|
| 2677 | end |
---|
| 2678 | end |
---|
| 2679 | if isequal(civAll,1) |
---|
| 2680 | save(civAllxml,[filename_cmx([1:end-4]) '.xml']); |
---|
| 2681 | cmd=char({cmd;[Civ_exe ' -f ' [filename_cmx([1:end-4]) '.xml'] ' ' civAllCmd]}); |
---|
| 2682 | end |
---|
| 2683 | % create the .bat file: |
---|
| 2684 | if sge |
---|
| 2685 | [Rootbat,Filebat,extbat]=fileparts(filename_cmx); |
---|
| 2686 | filename_bat=fullfile(Rootbat,['job_' Filebat extbat]); |
---|
| 2687 | else |
---|
| 2688 | filename_bat=filename_cmx; |
---|
| 2689 | end |
---|
| 2690 | filename_bat(end-2:end)='bat'; |
---|
| 2691 | fid=fopen(filename_bat,'w'); |
---|
[39] | 2692 | fprintf(fid,cmd); |
---|
| 2693 | fclose(fid); |
---|
[12] | 2694 | %dlmwrite(filename_bat,cmd,'');%write commands in filename_bat |
---|
| 2695 | if sge |
---|
| 2696 | pvalue=num2str((1-ind_answer)*500); |
---|
| 2697 | namelog=[filename_bat '.patch.log']; |
---|
| 2698 | ['!qsub -p ' pvalue ' -q civ.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat]; |
---|
| 2699 | eval( ['!qsub -p ' pvalue ' -q civ.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat]); |
---|
| 2700 | else |
---|
| 2701 | if(isunix) |
---|
| 2702 | cmdtodo=['. ' filename_bat ];%removed for Mathieu tests %' && rm -f ' filename_bat] ; |
---|
[2] | 2703 | else |
---|
[12] | 2704 | cmdtodo=[filename_bat];%removed for Mathieu tests %' && del /F /Q ' filename_bat' ; |
---|
[2] | 2705 | end |
---|
[12] | 2706 | count= fprintf(p1,'%s\n', cmdtodo); |
---|
| 2707 | end |
---|
[2] | 2708 | end |
---|
| 2709 | end |
---|
| 2710 | if ~sge |
---|
| 2711 | fclose(p1); |
---|
| 2712 | fclose(p0); |
---|
| 2713 | delete(name_lock); |
---|
| 2714 | end |
---|
| 2715 | |
---|
| 2716 | set(handles.BATCH, 'Enable','On') |
---|
| 2717 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 2718 | |
---|
| 2719 | %save interface state |
---|
| 2720 | if isfield(filecell,'nc') |
---|
| 2721 | if isfield(filecell.nc,'civ2') |
---|
| 2722 | fileresu=filecell.nc.civ2{1,1}; |
---|
| 2723 | else |
---|
| 2724 | fileresu=filecell.nc.civ1{1,1}; |
---|
| 2725 | end |
---|
| 2726 | end |
---|
| 2727 | [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileresu); |
---|
| 2728 | namedoc=fullfile(RootPath,subdir,RootFile); |
---|
| 2729 | detect=1; |
---|
| 2730 | while detect==1 |
---|
| 2731 | namefigfull=[namedoc '.fig']; |
---|
| 2732 | hh=dir(namefigfull); |
---|
| 2733 | if ~isempty(hh) |
---|
| 2734 | detect=1; |
---|
| 2735 | namedoc=[namedoc '.0']; |
---|
| 2736 | else |
---|
| 2737 | detect=0; |
---|
| 2738 | end |
---|
| 2739 | end |
---|
| 2740 | saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) |
---|
| 2741 | |
---|
[12] | 2742 | %------------------------------------------------------------------------ |
---|
[2] | 2743 | %OUTPUT: |
---|
| 2744 | % filecell: structure of input and output files |
---|
| 2745 | % .ima1.civ1{i,j}, .ima1.civ2{i,j}; set of first image names for correlations, for civ1 and civ2 |
---|
| 2746 | % .ima2.civ1{i,j}, .ima2.civ2{i,j} ; set of second image names for correlations |
---|
| 2747 | % .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) |
---|
| 2748 | % .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) |
---|
| 2749 | % .nc.civ1{i,j}, .nc.civ2{i,j}; set of nc files for PIV results |
---|
| 2750 | % .ncA.civ1{i,j}, .ncA.civ2{i,j}; set of nc files for PIV results with camA (then .nc corresponds to camB) |
---|
| 2751 | % .st{i,j}; set of nc files for the combined stereo fields |
---|
[41] | 2752 | % num1_civ1(i),num2_civ1(i): lists of first and last i indices for civ1 |
---|
| 2753 | % num_a_civ1(j),num_b_civ1(j): lists of first and last j indices for civ1 |
---|
| 2754 | % num1_civ2(i),num2_civ2(i): lists of first and last i indices for civ2 |
---|
| 2755 | % num_a_civ2(j),num_b_civ2(j): lists of first and last j indices for civ2 |
---|
| 2756 | % nom_type_nc: nomenclature type for velocity files |
---|
| 2757 | % file_ref_fix1,file_ref_fix2: reference files possibly used by Fix1 and 2 |
---|
[2] | 2758 | 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]=... |
---|
| 2759 | set_civ_filenames(handles,compare,box_test) |
---|
[12] | 2760 | %------------------------------------------------------------------------ |
---|
[2] | 2761 | %get the filename root, nomenclature and numbers |
---|
| 2762 | filebase=get(handles.displ_filebase,'String'); |
---|
| 2763 | browse=get(handles.browse_root,'UserData'); |
---|
| 2764 | compare_list=get(handles.compare,'String'); |
---|
| 2765 | val=get(handles.compare,'Value'); |
---|
| 2766 | compare=compare_list{val}; |
---|
| 2767 | if strcmp(compare,'displacement') |
---|
| 2768 | mode='displacement'; |
---|
| 2769 | else |
---|
| 2770 | mode_list=get(handles.mode,'String'); |
---|
| 2771 | mode_value=get(handles.mode,'Value'); |
---|
| 2772 | mode=mode_list{mode_value}; |
---|
| 2773 | end |
---|
| 2774 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 2775 | ext_ima=get(handles.ext_ima,'String'); |
---|
| 2776 | nom_type_nc=browse.nom_type_nc; |
---|
| 2777 | nom_type_ima2=browse.nom_type_ima; |
---|
| 2778 | if isequal(nom_type_ima2,[]),nom_type_ima2='ima_num';end; %default |
---|
| 2779 | if isequal(nom_type_nc,[]),nom_type_nc='_i1-i2';end; %default |
---|
| 2780 | [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
| 2781 | find_pair_indices(handles,mode); |
---|
| 2782 | %determine the new filebase for 'displacement' mode (comparison of two series) |
---|
| 2783 | filebase_B=filebase;% root name of the second field series for stereo |
---|
| 2784 | if strcmp(compare,'displacement') || strcmp(compare,'stereo PIV') |
---|
| 2785 | test_disp=1; |
---|
| 2786 | nom_type_ima1=browse.nom_type_ima_1; %nomenclature type of the second file series |
---|
| 2787 | [Path2,Name2]=fileparts(filebase_B); |
---|
| 2788 | Path1=Path2; |
---|
| 2789 | Name1=get(handles.displ_filebase2,'String');% root name of the first field series for stereo |
---|
| 2790 | filebase_A=fullfile(Path1,Name1); |
---|
| 2791 | if length(Name1)>6 |
---|
| 2792 | Name1=Name1(end-5:end); |
---|
| 2793 | end |
---|
| 2794 | if length(Name2)>6 |
---|
| 2795 | Name2=Name2(end-5:end); |
---|
| 2796 | end |
---|
| 2797 | filebase_AB=fullfile(Path2,[Name2 '-' Name1]); |
---|
| 2798 | else |
---|
| 2799 | test_disp=0; |
---|
| 2800 | filebase_A=filebase; |
---|
| 2801 | nom_type_ima1=nom_type_ima2; |
---|
| 2802 | filebase_AB=filebase; |
---|
| 2803 | end |
---|
| 2804 | if strcmp(compare,'displacement') |
---|
| 2805 | filebase_ima1=filebase_A; |
---|
| 2806 | filebase_ima2=filebase_B; |
---|
| 2807 | filebase_nc=filebase_AB; %root name for the result of civ2 |
---|
| 2808 | else |
---|
| 2809 | filebase_ima1=filebase_B; |
---|
| 2810 | filebase_ima2=filebase_B; |
---|
| 2811 | filebase_nc=filebase_B; |
---|
| 2812 | end |
---|
| 2813 | |
---|
| 2814 | %determine reference files for fix: |
---|
| 2815 | file_ref_fix1={};%default |
---|
| 2816 | file_ref_fix2={}; |
---|
| 2817 | nbfield=length(num1_civ1); |
---|
| 2818 | nbslice=length(num_a_civ1); |
---|
| 2819 | if box_test(2)==1% fix1 performed |
---|
| 2820 | ref=get(handles.ref_fix1,'UserData');%read data on the ref file stored by get_ref_fix1_Callback |
---|
| 2821 | if ~isempty(ref) |
---|
| 2822 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 2823 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 2824 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
| 2825 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 2826 | last_j=str2num(get(handles.last_j,'String')); |
---|
| 2827 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
| 2828 | num_i_ref=[first_i:incr_i:last_i]; |
---|
| 2829 | num_j_ref=[first_j:incr_j:last_j]; |
---|
| 2830 | if isequal(mode,'displacement') |
---|
| 2831 | num_i1=num_i_ref; |
---|
| 2832 | num_i2=num_i_ref; |
---|
| 2833 | num_j1=num_j_ref; |
---|
| 2834 | num_j2=num_j_ref; |
---|
| 2835 | elseif isequal(mode,'pair j1-j2')% isequal(mode,'st_pair j1-j2') |
---|
| 2836 | num_i1=num_i_ref; |
---|
| 2837 | num_i2=num_i1; |
---|
| 2838 | num_j1=ref.num_a*ones(size(num_i_ref)); |
---|
| 2839 | num_j2=ref.num_b*ones(size(num_i_ref)); |
---|
| 2840 | elseif isequal(mode,'series(Di)') % isequal(mode,'st_series(Di)') |
---|
| 2841 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 2842 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 2843 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 2844 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 2845 | if isempty(ref.num_a) |
---|
| 2846 | ref.num_a=1; |
---|
| 2847 | end |
---|
| 2848 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 2849 | num_j2=num_j1; |
---|
| 2850 | elseif isequal(mode,'series(Dj)')%| isequal(mode,'st_series(Dj)') |
---|
| 2851 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 2852 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 2853 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 2854 | num_i2=num_i1; |
---|
| 2855 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 2856 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 2857 | end |
---|
| 2858 | for ifile=1:nbfield |
---|
| 2859 | for j=1:nbslice |
---|
| 2860 | 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);% |
---|
| 2861 | file_ref_fix1(ifile,j)={file_ref}; |
---|
| 2862 | if ~exist(file_ref,'file') |
---|
| 2863 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix1']) |
---|
[12] | 2864 | filecell=[]; |
---|
[2] | 2865 | return |
---|
| 2866 | end |
---|
| 2867 | end |
---|
| 2868 | end |
---|
| 2869 | end |
---|
| 2870 | end |
---|
| 2871 | |
---|
| 2872 | %determine reference files for fix2: |
---|
| 2873 | if box_test(5)==1% fix2 performed |
---|
| 2874 | ref=get(handles.ref_fix2,'UserData'); |
---|
| 2875 | if ~isempty(ref) |
---|
| 2876 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 2877 | last_i=str2num(get(handles.last_i,'String')); |
---|
| 2878 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
| 2879 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 2880 | last_j=str2num(get(handles.last_j,'String')); |
---|
| 2881 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
| 2882 | num_i_ref=[first_i:incr_i:last_i]; |
---|
| 2883 | num_j_ref=[first_j:incr_j:last_j]; |
---|
| 2884 | if isequal(mode,'displacement') |
---|
| 2885 | num_i1=num_i_ref; |
---|
| 2886 | num_i2=num_i_ref; |
---|
| 2887 | num_j1=num_j_ref; |
---|
| 2888 | num_j2=num_j_ref; |
---|
| 2889 | elseif isequal(mode,'pair j1-j2') |
---|
| 2890 | num_i1=num_i_ref; |
---|
| 2891 | num_i2=num_i1; |
---|
| 2892 | num_j1=ref.num_a; |
---|
| 2893 | num_j2=ref.num_b; |
---|
| 2894 | elseif isequal(mode,'series(Di)') |
---|
| 2895 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 2896 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 2897 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 2898 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 2899 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 2900 | num_j2=num_j1; |
---|
| 2901 | elseif isequal(mode,'series(Dj)') |
---|
| 2902 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 2903 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 2904 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 2905 | num_i2=num_i1; |
---|
| 2906 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 2907 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 2908 | end |
---|
| 2909 | for ifile=1:nbfield |
---|
| 2910 | for j=1:nbslice |
---|
| 2911 | 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);% |
---|
| 2912 | file_ref_fix2(ifile,j)={file_ref}; |
---|
| 2913 | if ~exist(file_ref,'file') |
---|
| 2914 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix2']) |
---|
[12] | 2915 | filecell=[]; |
---|
[2] | 2916 | return |
---|
| 2917 | end |
---|
| 2918 | end |
---|
| 2919 | end |
---|
| 2920 | end |
---|
| 2921 | end |
---|
| 2922 | |
---|
| 2923 | %check dir |
---|
| 2924 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf output data |
---|
| 2925 | subdir_civ2=get(handles.subdir_civ2,'String'); |
---|
| 2926 | if isequal(subdir_civ1,''),subdir_civ1='A'; end% put default subdir |
---|
| 2927 | if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end% put default subdir |
---|
| 2928 | currentdir=pwd;%store the current working directory |
---|
| 2929 | [Path_ima,Name]=fileparts(filebase);%Path of the image files (.civ) |
---|
| 2930 | if ~exist(Path_ima,'dir') |
---|
[12] | 2931 | msgbox_uvmat('ERROR',['path to images ' Path_ima ' not found']) |
---|
| 2932 | filecell=[]; |
---|
[2] | 2933 | return |
---|
| 2934 | end |
---|
| 2935 | cd(Path_ima);%move to the directory of the images: needed to create the result dir by 'mkdir' |
---|
| 2936 | dircur=pwd; %current working directory |
---|
| 2937 | m2=''; |
---|
| 2938 | [erread,message]=fileattrib(Path_ima); |
---|
| 2939 | if ~isempty(message) & ~isequal(message.UserWrite,1) |
---|
| 2940 | msgbox_uvmat('ERROR',['No writting access to ' Path_ima]) |
---|
[12] | 2941 | filecell=[]; |
---|
[2] | 2942 | cd(currentdir); |
---|
| 2943 | return |
---|
| 2944 | end |
---|
| 2945 | |
---|
| 2946 | %check the existence of the netcdf and image files involved |
---|
| 2947 | % %%%%%%%%%%%% case CIV1 activated %%%%%%%%%%%%% |
---|
| 2948 | if box_test(1)==1; |
---|
| 2949 | detect=1; |
---|
| 2950 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
| 2951 | for ifile=1:nbfield; |
---|
| 2952 | for j=1:nbslice |
---|
| 2953 | 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); |
---|
| 2954 | detect=exist(filename,'file')==2; |
---|
| 2955 | if detect% if a netcdf file already exists |
---|
| 2956 | subdir_civ1=[subdir_civ1 '.0']; |
---|
| 2957 | subdir_civ2=subdir_civ1; |
---|
| 2958 | break |
---|
| 2959 | end |
---|
| 2960 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 2961 | end |
---|
| 2962 | if detect% if a netcdf file already exists |
---|
| 2963 | break |
---|
| 2964 | end |
---|
| 2965 | end |
---|
| 2966 | %create the new subdir_civ1 |
---|
| 2967 | if ~exist(fullfile(Path_ima,subdir_civ1),'dir') |
---|
| 2968 | [m1,m2,m3]=mkdir(subdir_civ1); |
---|
| 2969 | if ~isequal(m2,'') |
---|
| 2970 | msgbox_uvmat('ERROR', m2) |
---|
| 2971 | %msgbox(m2);%error message for directory creation |
---|
| 2972 | end |
---|
| 2973 | end |
---|
| 2974 | if strcmp(compare,'stereo PIV')&&(strcmp(mode,'pair j1-j2')||strcmp(mode,'series(Dj)')||strcmp(mode,'series(Di)'))%check second nc series |
---|
| 2975 | for ifile=1:nbfield |
---|
| 2976 | for j=1:nbslice |
---|
| 2977 | 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);% |
---|
| 2978 | detect=exist(filename,'file')==2; |
---|
| 2979 | if detect% if a netcdf file already exists |
---|
| 2980 | subdir_civ1=[subdir_civ1 '.0']; |
---|
| 2981 | subdir_civ2=subdir_civ1; |
---|
| 2982 | break |
---|
| 2983 | end |
---|
| 2984 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
| 2985 | end |
---|
| 2986 | if detect% if a netcdf file already exists |
---|
| 2987 | break |
---|
| 2988 | end |
---|
| 2989 | end |
---|
| 2990 | %create the new subdir_civ1 |
---|
| 2991 | if ~exist(fullfile(Path_ima,subdir_civ1),'dir') |
---|
| 2992 | [m1,m2,m3]=mkdir(subdir_civ1); |
---|
| 2993 | if ~isequal(m2,'') |
---|
| 2994 | msgbox_uvmat('ERROR', m2) |
---|
| 2995 | end |
---|
| 2996 | end |
---|
| 2997 | end |
---|
| 2998 | end |
---|
| 2999 | % get image names |
---|
| 3000 | for ifile=1:nbfield |
---|
| 3001 | for j=1:nbslice |
---|
| 3002 | filename=name_generator(filebase_ima1, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
| 3003 | idetect(j)=exist(filename,'file')==2; |
---|
| 3004 | filecell.ima1.civ1(ifile,j)={filename}; %first image |
---|
| 3005 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
| 3006 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 3007 | filecell.ima2.civ1(ifile,j)={filename};%second image |
---|
| 3008 | end |
---|
| 3009 | [idetectmin,indexj]=min(idetect); |
---|
| 3010 | if idetectmin==0, |
---|
| 3011 | msgbox_uvmat('ERROR',[filecell.ima1.civ1{ifile,indexj} ' not found']) |
---|
[12] | 3012 | filecell=[]; |
---|
[2] | 3013 | return |
---|
| 3014 | end |
---|
| 3015 | [idetectmin,indexj]=min(idetect_1); |
---|
| 3016 | if idetectmin==0, |
---|
| 3017 | msgbox_uvmat('ERROR',[filecell.ima2.civ1{ifile,indexj} ' not found']) |
---|
[12] | 3018 | filecell=[]; |
---|
[2] | 3019 | cd(currentdir) |
---|
| 3020 | return |
---|
| 3021 | end |
---|
| 3022 | end |
---|
| 3023 | if strcmp(compare,'stereo PIV') && (strcmp(mode,'pair j1-j2') || strcmp(mode,'series(Dj)') || strcmp(mode,'series(Di)')) |
---|
| 3024 | for ifile=1:nbfield |
---|
| 3025 | for j=1:nbslice |
---|
| 3026 | filename=name_generator(filebase_A, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
| 3027 | idetect(j)=exist(filename,'file')==2; |
---|
| 3028 | filecell.imaA1.civ1(ifile,j)={filename} ;%first image |
---|
| 3029 | filename=name_generator(filebase_A, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
| 3030 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 3031 | filecell.imaA2.civ1(ifile,j)={filename};%second image |
---|
| 3032 | end |
---|
| 3033 | [idetectmin,indexj]=min(idetect); |
---|
| 3034 | if idetectmin==0, |
---|
| 3035 | msgbox_uvmat('ERROR',[filecell.imaA1.civ1{ifile,indexj} ' not found']) |
---|
[12] | 3036 | filecell=[]; |
---|
| 3037 | cd(currentdir) |
---|
| 3038 | return |
---|
[2] | 3039 | end |
---|
| 3040 | [idetectmin,indexj]=min(idetect_1); |
---|
| 3041 | if idetectmin==0, |
---|
[12] | 3042 | msgbox_uvmat('ERROR',[filecell.imaA2.civ1{ifile,indexj} ' not found']) |
---|
| 3043 | filecell=[]; |
---|
| 3044 | cd(currentdir) |
---|
| 3045 | return |
---|
[2] | 3046 | end |
---|
| 3047 | end |
---|
| 3048 | end |
---|
| 3049 | |
---|
| 3050 | %%%%%%%%%%%%% fix1 or patch1 activated but no civ1 %%%%%%%%%%%%% |
---|
| 3051 | elseif (box_test(2)==1 || box_test(3)==1); |
---|
| 3052 | for ifile=1:nbfield |
---|
| 3053 | for j=1:nbslice |
---|
| 3054 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 3055 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 3056 | detect=exist(filename,'file')==2; |
---|
| 3057 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 3058 | end |
---|
| 3059 | end |
---|
| 3060 | if strcmp(compare,'stereo PIV') |
---|
| 3061 | for ifile=1:nbfield |
---|
| 3062 | for j=1:nbslice |
---|
| 3063 | 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);% |
---|
| 3064 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
| 3065 | if ~exist(filename,'file') |
---|
| 3066 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
| 3067 | set(handles.RUN, 'Enable','On') |
---|
| 3068 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 3069 | set(handles.BATCH, 'Enable','On') |
---|
| 3070 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
[12] | 3071 | filecell=[]; |
---|
[2] | 3072 | cd(currentdir) |
---|
| 3073 | return |
---|
| 3074 | end |
---|
| 3075 | end |
---|
| 3076 | end |
---|
| 3077 | end |
---|
| 3078 | end |
---|
| 3079 | |
---|
| 3080 | %%%%%%%%%%%%% if civ2 performed with pairs different than civ1 %%%%%%%%%%%%% |
---|
| 3081 | testdiff=0; |
---|
| 3082 | if (box_test(4)==1)&&... |
---|
| 3083 | ((get(handles.list_pair_civ1,'Value')~=get(handles.list_pair_civ2,'Value'))||~isequal(subdir_civ2,subdir_civ1)) |
---|
| 3084 | testdiff=1; |
---|
| 3085 | detect=1; |
---|
| 3086 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
| 3087 | for ifile=1:nbfield |
---|
| 3088 | for j=1:nbslice |
---|
| 3089 | 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);% |
---|
| 3090 | detect=exist(filename,'file')==2; |
---|
| 3091 | if detect% if a netcdf file already exists |
---|
| 3092 | subdir_civ2=[subdir_civ2 '.0']; |
---|
| 3093 | break |
---|
| 3094 | end |
---|
| 3095 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 3096 | end |
---|
| 3097 | if detect% if a netcdf file already exists |
---|
| 3098 | break |
---|
| 3099 | end |
---|
| 3100 | end |
---|
| 3101 | %create the new subdir_civ2 |
---|
| 3102 | if ~exist(fullfile(Path_ima,subdir_civ2),'dir') |
---|
| 3103 | [m1,m2,m3]=mkdir(subdir_civ2); |
---|
| 3104 | if ~isequal(m2,'') |
---|
| 3105 | msgbox_uvmat('ERROR', m2) |
---|
| 3106 | end |
---|
| 3107 | end |
---|
| 3108 | if strcmp(compare,'stereo PIV')%check second nc series |
---|
| 3109 | for ifile=1:nbfield |
---|
| 3110 | for j=1:nbslice |
---|
| 3111 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 3112 | nom_type_nc,1,num2_civ2(ifile),num_b_civ1(j),subdir_civ2);% |
---|
| 3113 | detect=exist(filename,'file')==2; |
---|
| 3114 | if detect% if a netcdf file already exists |
---|
| 3115 | subdir_civ2=[subdir_civ2 '.0']; |
---|
| 3116 | break |
---|
| 3117 | end |
---|
| 3118 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 3119 | end |
---|
| 3120 | if detect% if a netcdf file already exists |
---|
| 3121 | break |
---|
| 3122 | end |
---|
| 3123 | end |
---|
| 3124 | %create the new subdir_civ1 |
---|
| 3125 | if ~exist(fullfile(Path_ima,subdir_civ2),'dir') |
---|
| 3126 | [m1,m2,m3]=mkdir(subdir_civ2); |
---|
| 3127 | if ~isequal(m2,'') |
---|
| 3128 | msgbox_uvmat('ERROR', m2) |
---|
| 3129 | %msgbox(m2);%error message for directory creation |
---|
| 3130 | end |
---|
| 3131 | end |
---|
| 3132 | end |
---|
| 3133 | end |
---|
| 3134 | end |
---|
| 3135 | cd(currentdir);%come back to the current working directory |
---|
| 3136 | |
---|
| 3137 | |
---|
| 3138 | %%%%%%%%%%%%% if civ2 results are obtained or used %%%%%%%%%%%%% |
---|
| 3139 | if box_test(4)==1 || box_test(5)==1 || box_test(6)==1 %civ2 |
---|
| 3140 | %check source netcdf file of civ1 estimates |
---|
| 3141 | if box_test(1)==0; %no civ1 performed |
---|
| 3142 | for ifile=1:nbfield |
---|
| 3143 | for j=1:nbslice |
---|
| 3144 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 3145 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 3146 | filecell.nc.civ1(ifile,j)={filename};% name of the civ1 file |
---|
| 3147 | if ~exist(filename,'file') |
---|
| 3148 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
[12] | 3149 | filecell=[]; |
---|
[2] | 3150 | return |
---|
| 3151 | end |
---|
| 3152 | if ~testdiff % civ2 or patch2 are written in the same file as civ1 |
---|
| 3153 | if box_test(4)==0 ; %check the existence of civ2 if it is not calculated |
---|
| 3154 | Data=nc2struct(filename,'ListGlobalAttribute','civ2'); |
---|
| 3155 | if isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
| 3156 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
[12] | 3157 | filecell=[]; |
---|
[2] | 3158 | return |
---|
| 3159 | end |
---|
| 3160 | elseif box_test(3)==0; %check the existence of patch if it is not calculated |
---|
| 3161 | Data=nc2struct(filename,'ListGlobalAttribute','patch'); |
---|
| 3162 | if isempty(Data.patch)||isequal(Data.patch,0) |
---|
| 3163 | msgbox_uvmat('ERROR',['no patch data in ' filename]) |
---|
[12] | 3164 | filecell=[]; |
---|
[2] | 3165 | return |
---|
| 3166 | end |
---|
| 3167 | end |
---|
| 3168 | end |
---|
| 3169 | end |
---|
| 3170 | end |
---|
| 3171 | if strcmp(compare,'stereo PIV') |
---|
| 3172 | for ifile=1:nbfield |
---|
| 3173 | for j=1:nbslice |
---|
| 3174 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 3175 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 3176 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 3177 | if ~exist(filename,'file') |
---|
| 3178 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
| 3179 | set(handles.RUN, 'Enable','On') |
---|
| 3180 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 3181 | set(handles.BATCH, 'Enable','On') |
---|
| 3182 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
| 3183 | cd(currentdir) |
---|
| 3184 | return |
---|
| 3185 | end |
---|
| 3186 | end |
---|
| 3187 | end |
---|
| 3188 | end |
---|
| 3189 | end |
---|
| 3190 | |
---|
| 3191 | detect=1; |
---|
| 3192 | % while detect==1%creates a new subdir if the netcdf files already contain civ2 data |
---|
| 3193 | for ifile=1:nbfield |
---|
| 3194 | for j=1:nbslice |
---|
| 3195 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 3196 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2); |
---|
| 3197 | detect=exist(filename,'file')==2; |
---|
| 3198 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 3199 | end |
---|
| 3200 | end |
---|
| 3201 | %get first image names for civ2 |
---|
| 3202 | if box_test(1)==1 & isequal(num1_civ1,num1_civ2) & isequal(num_a_civ1,num_a_civ2) |
---|
| 3203 | filecell.ima1.civ2=filecell.ima1.civ1; |
---|
| 3204 | elseif box_test(4)==1 |
---|
| 3205 | for ifile=1:nbfield |
---|
| 3206 | for j=1:nbslice |
---|
| 3207 | filename=name_generator(filebase_ima1, num1_civ2(ifile),num_a_civ2(j),ext_ima,nom_type_ima1); |
---|
| 3208 | idetect_2(j)=exist(filename,'file')==2; |
---|
| 3209 | filecell.ima1.civ2(ifile,j)={filename};%first image |
---|
| 3210 | end |
---|
| 3211 | [idetectmin,indexj]=min(idetect_2); |
---|
| 3212 | if idetectmin==0, |
---|
| 3213 | msgbox_uvmat('ERROR',['input image ' filecell.ima1.civ2{ifile,indexj} ' not found']) |
---|
[12] | 3214 | filecell=[]; |
---|
[2] | 3215 | return |
---|
| 3216 | end |
---|
| 3217 | end |
---|
| 3218 | end |
---|
| 3219 | |
---|
| 3220 | %get second image names for civ2 |
---|
| 3221 | if box_test(1)==1 & isequal(num2_civ1,num2_civ2) & isequal(num_b_civ1,num_b_civ2) |
---|
| 3222 | filecell.ima2.civ2=filecell.ima2.civ1; |
---|
| 3223 | elseif box_test(4)==1 |
---|
| 3224 | for ifile=1:nbfield |
---|
| 3225 | for j=1:nbslice |
---|
| 3226 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),ext_ima,nom_type_ima2); |
---|
| 3227 | idetect_3(j)=exist(filename,'file')==2; |
---|
| 3228 | filecell.ima2.civ2(ifile,j)={filename};%first image |
---|
| 3229 | end |
---|
| 3230 | [idetectmin,indexj]=min(idetect_3); |
---|
| 3231 | if idetectmin==0, |
---|
| 3232 | msgbox_uvmat('ERROR',['input image ' filecell.ima2.civ2{ifile,indexj} ' not found']) |
---|
[12] | 3233 | filecell=[]; |
---|
[2] | 3234 | return |
---|
| 3235 | end |
---|
| 3236 | end |
---|
| 3237 | end |
---|
| 3238 | end |
---|
| 3239 | if (box_test(5)==1 || box_test(6)==1 ) && box_test(4)==0 % need to read an existing netcdf civ2 file |
---|
| 3240 | if ~testdiff |
---|
| 3241 | filecell.nc.civ2=filecell.nc.civ1;% file already checked |
---|
| 3242 | else % check the civ2 files |
---|
| 3243 | for ifile=1:nbfield |
---|
| 3244 | for j=1:nbslice |
---|
| 3245 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 3246 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 3247 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 3248 | if ~exist(filename,'file') |
---|
| 3249 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
[12] | 3250 | filecell=[]; |
---|
[2] | 3251 | return |
---|
| 3252 | else |
---|
| 3253 | Data=nc2struct(filename,'ListGlobalAttribute','civ2'); |
---|
| 3254 | if isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
| 3255 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
[12] | 3256 | filecell=[]; |
---|
[2] | 3257 | return |
---|
| 3258 | end |
---|
| 3259 | end |
---|
| 3260 | end |
---|
| 3261 | end |
---|
| 3262 | end |
---|
| 3263 | end |
---|
| 3264 | |
---|
| 3265 | %%%%%%%%%%%%% if stereo fields are calculated by PATCH %%%%%%%%%%%%% |
---|
| 3266 | if strcmp(compare,'stereo PIV') |
---|
| 3267 | if box_test(3)==1 & isequal(get(handles.test_stereo1,'Value'),1) |
---|
| 3268 | for ifile=1:nbfield |
---|
| 3269 | for j=1:nbslice |
---|
| 3270 | filename=name_generator(filebase_AB,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 3271 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 3272 | filecell.st(ifile,j)={filename}; |
---|
| 3273 | end |
---|
| 3274 | end |
---|
| 3275 | end |
---|
| 3276 | if box_test(6)==1 & isequal(get(handles.test_stereo2,'Value'),1) |
---|
| 3277 | for ifile=1:nbfield |
---|
| 3278 | for j=1:nbslice |
---|
| 3279 | filename=name_generator(filebase_AB,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 3280 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 3281 | filecell.st(ifile,j)={filename}; |
---|
| 3282 | end |
---|
| 3283 | end |
---|
| 3284 | end |
---|
| 3285 | end |
---|
| 3286 | set(handles.subdir_civ1,'String',subdir_civ1);%update the edit box |
---|
| 3287 | set(handles.subdir_civ2,'String',subdir_civ2);%update the edit box |
---|
| 3288 | browse.nom_type_nc=nom_type_nc; |
---|
| 3289 | set(handles.browse_root,'UserData',browse); %update the nomenclature type for uvmat |
---|
| 3290 | |
---|
| 3291 | |
---|
| 3292 | %COPY IMAGES TO THE FORMAT .png IF NEEDED |
---|
| 3293 | if isequal(nom_type_ima1,'*') |
---|
| 3294 | nom_type_imanew='_i'; |
---|
| 3295 | else |
---|
| 3296 | nom_type_imanew1=nom_type_ima1; |
---|
| 3297 | end |
---|
| 3298 | if isequal(nom_type_ima2,'*') |
---|
| 3299 | nom_type_imanew='_i'; |
---|
| 3300 | else |
---|
| 3301 | nom_type_imanew2=nom_type_ima2; |
---|
| 3302 | end |
---|
| 3303 | if ~isequal(ext_ima,'.png') |
---|
| 3304 | %npxy=get(handles.ext_ima,'UserData'); |
---|
| 3305 | % % if numel(npxy)<2 |
---|
| 3306 | % |
---|
| 3307 | % filename=name_generator(filebase_ima1,num1_civ1(1),num_a_civ1(1),ext_ima,nom_type_ima1); |
---|
| 3308 | % A=imread(filename); |
---|
| 3309 | % npxy=size(A); |
---|
| 3310 | % % end |
---|
| 3311 | % npy=npxy(1); |
---|
| 3312 | % npx=npxy(2); |
---|
| 3313 | if box_test(1)==1 %if civ1 is performed |
---|
| 3314 | h = waitbar(0,['copy images to the .png format for civ1']);% display a wait bar |
---|
| 3315 | for ifile=1:nbfield |
---|
| 3316 | waitbar(ifile/nbfield); |
---|
| 3317 | for j=1:nbslice |
---|
| 3318 | filename=name_generator(filebase_ima1,num1_civ1(ifile),num_a_civ1(j),'.png',nom_type_imanew1); |
---|
| 3319 | if ~exist(filename,'file') |
---|
| 3320 | A=read_image(filecell.ima1.civ1{ifile,j},nom_type_ima2,num1_civ1(ifile)); |
---|
| 3321 | imwrite(A,filename,'BitDepth',16); |
---|
| 3322 | end |
---|
| 3323 | filecell.ima1.civ1(ifile,j)={filename}; |
---|
| 3324 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),'.png',nom_type_imanew2); |
---|
| 3325 | if ~exist(filename,'file') |
---|
| 3326 | A=read_image(filecell.ima2.civ1{ifile,j},nom_type_ima2,num2_civ1(ifile)); |
---|
| 3327 | imwrite(A,filename,'BitDepth',16); |
---|
| 3328 | end |
---|
| 3329 | filecell.ima2.civ1(ifile,j)={filename}; |
---|
| 3330 | end |
---|
| 3331 | end |
---|
| 3332 | close(h) |
---|
| 3333 | end |
---|
| 3334 | if box_test(4)==1 %if civ2 is performed |
---|
| 3335 | h = waitbar(0,['copy images to the .png format for civ2']);% display a wait bar |
---|
| 3336 | for ifile=1:nbfield |
---|
| 3337 | waitbar(ifile/nbfield); |
---|
| 3338 | for j=1:nbslice |
---|
| 3339 | filename=name_generator(filebase_ima1,num1_civ2(ifile),num_a_civ2(j),'.png',nom_type_imanew1); |
---|
| 3340 | if ~exist(filename,'file') |
---|
| 3341 | A=read_image(cell2mat(filecell.ima1.civ2(ifile,j)),nom_type_ima2,num1_civ2(ifile)); |
---|
| 3342 | imwrite(A,filename,'BitDepth',16); |
---|
| 3343 | end |
---|
| 3344 | filecell.ima1.civ2(ifile,j)={filename}; |
---|
| 3345 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),'.png',nom_type_imanew2); |
---|
| 3346 | if ~exist(filename,'file') |
---|
| 3347 | A=read_image(cell2mat(filecell.ima2.civ2(ifile,j)),nom_type_ima2,num2.civ1(ifile)); |
---|
| 3348 | imwrite(A,filename,'BitDepth',16); |
---|
| 3349 | end |
---|
| 3350 | filecell.ima2.civ2(ifile,j)={filename}; |
---|
| 3351 | end |
---|
| 3352 | end |
---|
| 3353 | close(h); |
---|
| 3354 | end |
---|
| 3355 | end |
---|
| 3356 | |
---|
[12] | 3357 | %------------------------------------------------------------------------ |
---|
[2] | 3358 | %CIV1 CIV1 CIV1 CIV1 |
---|
| 3359 | function RUN_CIV1(handles,filecell,filecell_1,filecell_nc1,num1,num2,num_a,num_b,nom_type_nc) |
---|
[12] | 3360 | %------------------------------------------------------------------------ |
---|
[2] | 3361 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 3362 | global civ1_exe sge%name of the executable for civ1 calculation |
---|
| 3363 | |
---|
| 3364 | %get civ parameters |
---|
| 3365 | ibx_val=str2num(get(handles.ibx,'String')); |
---|
| 3366 | if isempty(ibx_val) |
---|
| 3367 | ibx='21'; set(handles.ibx,'String','21') |
---|
| 3368 | else |
---|
| 3369 | ibx=num2str(ibx_val); |
---|
| 3370 | end |
---|
| 3371 | iby_val=str2num(get(handles.iby,'String')); |
---|
| 3372 | if isempty(iby_val) |
---|
| 3373 | iby='21'; set(handles.iby,'String','21') |
---|
| 3374 | else |
---|
| 3375 | iby=num2str(iby_val); |
---|
| 3376 | end |
---|
| 3377 | isx=get(handles.isx,'String'); |
---|
| 3378 | if isempty(str2num(isx)), isx='41'; set(handles.isx,'String','41'), end; %default |
---|
| 3379 | if str2num(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.isx,'String',num2str(ibx_val+8)); end |
---|
| 3380 | isy=get(handles.isy,'String'); |
---|
| 3381 | if isempty(str2num(isy)), isy='41'; set(handles.isy,'String','41'), end;%default |
---|
| 3382 | if str2num(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.isy,'String',num2str(iby_val+8)); end |
---|
| 3383 | shiftx=get(handles.shiftx,'String'); |
---|
| 3384 | if isempty(str2num(shiftx)), shiftx='0'; set(handles.shiftx,'String','0'), end;%default |
---|
| 3385 | shifty=get(handles.shifty,'String'); |
---|
| 3386 | if isempty(str2num(shifty)), shifty='0'; set(handles.shifty,'String','0'), end;%default |
---|
| 3387 | rho=get(handles.rho,'String'); |
---|
| 3388 | dx=get(handles.dx_civ1,'String'); |
---|
| 3389 | if isequal(str2num(dx),[]), dx='20'; set(handles.dx_civ1,'String','20'); end%default |
---|
| 3390 | dy=get(handles.dy_civ1,'String'); |
---|
| 3391 | if isequal(str2num(dy),[]), dy='20'; set(handles.dy_civ1,'String','20');end %default |
---|
| 3392 | if isequal(str2num(dy),[]), dy='20'; end%default |
---|
| 3393 | pxcmx='1'; %velocity fields are expressed in pixel displacement |
---|
| 3394 | pxcmy='1'; |
---|
| 3395 | image_first=cell2mat(filecell(1,1)); |
---|
| 3396 | if ~exist(image_first,'file') |
---|
| 3397 | msgbox_uvmat('ERROR',['image ' image_first 'not found']) |
---|
| 3398 | set(handles.RUN, 'Enable','On') |
---|
| 3399 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 3400 | return |
---|
| 3401 | end |
---|
| 3402 | A=imread(cell2mat(filecell(1,1)));%read the first image to get the size |
---|
| 3403 | sizim=size(A); |
---|
| 3404 | npx=num2str(sizim(2)); |
---|
| 3405 | npy=num2str(sizim(1)); |
---|
| 3406 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 3407 | gridname='';%default ='noFile use default' |
---|
| 3408 | gridflag='n';%default |
---|
| 3409 | test_grid=get(handles.browse_gridciv1,'Value'); |
---|
| 3410 | nbslice_grid=[]; |
---|
| 3411 | if test_grid |
---|
| 3412 | gridname=get(handles.grid_civ1,'String'); |
---|
| 3413 | if numel(gridname)>4 && isequal(gridname(end-3:end),'grid') |
---|
| 3414 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
| 3415 | if ~isempty(nbslice_grid) |
---|
| 3416 | gridflag='y'; |
---|
| 3417 | end |
---|
| 3418 | elseif exist(gridname,'file') |
---|
| 3419 | gridflag='y'; |
---|
| 3420 | else |
---|
| 3421 | msgbox_uvmat('ERROR',['input grid file ' gridname ' not found']) |
---|
| 3422 | return |
---|
| 3423 | end |
---|
| 3424 | end |
---|
| 3425 | if isequal(get(handles.ImaThreshold,'Value'),1) |
---|
| 3426 | threshflag='y'; |
---|
| 3427 | min_ima=get(handles.MinIma,'String'); |
---|
| 3428 | max_ima=get(handles.MaxIma,'String'); |
---|
| 3429 | else |
---|
| 3430 | threshflag='n'; |
---|
| 3431 | min_ima='0'; |
---|
| 3432 | max_ima='4096'; |
---|
| 3433 | end |
---|
| 3434 | %main loop |
---|
| 3435 | filebase=get(handles.displ_filebase,'String'); |
---|
| 3436 | sizcell=size(filecell); |
---|
| 3437 | nbfield=sizcell(1); |
---|
| 3438 | nbslice=sizcell(2); |
---|
| 3439 | icount=0; |
---|
| 3440 | for ifile=1:nbfield |
---|
| 3441 | for j=1:nbslice |
---|
| 3442 | icount=icount+1; |
---|
| 3443 | barlength=0.188*icount/(nbfield*nbslice); |
---|
| 3444 | set(handles.waitbar_1,'Position',[0.946 0.877-barlength 0.03 barlength]) |
---|
| 3445 | drawnow |
---|
| 3446 | filename_ima=cell2mat(filecell(ifile,j)); |
---|
| 3447 | filename_ima([end-3:end])=[];%remove .png extension |
---|
| 3448 | filename_ima_1=cell2mat(filecell_1(ifile,j)); |
---|
| 3449 | filename_ima_1([end-3:end])=[];%remove .png extension |
---|
| 3450 | filename_cmx=cell2mat(filecell_nc1(ifile,j));%output netcdf file |
---|
| 3451 | filename_cmx([end-1:end])=[ 'cm'];%name of cmx file |
---|
| 3452 | filename_cmx=[filename_cmx 'x']; |
---|
| 3453 | namelog=[filename_cmx([1:end-3]) 'log']; |
---|
| 3454 | if size(time,1)>=num2(ifile) & size(time,2)>=num_b(j) |
---|
| 3455 | Dt=num2str(time(num2(ifile),num_b(j))-time(num1(ifile),num_a(j))); |
---|
| 3456 | if isequal(Dt,'0') |
---|
| 3457 | Dt='1' ;%case of 'displacement' mode |
---|
| 3458 | end |
---|
| 3459 | T0=num2str((time(num2(ifile),num_b(j))+time(num1(ifile),num_a(j)))/2); |
---|
| 3460 | else |
---|
| 3461 | Dt='1'; |
---|
| 3462 | T0='0'; |
---|
| 3463 | end |
---|
| 3464 | term_a=num2stra(num_a(j),nom_type_nc);%UTILITE? |
---|
| 3465 | term_b=num2stra(num_b(j),nom_type_nc);% |
---|
| 3466 | if test_grid && ~isempty(nbslice_grid) |
---|
[39] | 3467 | num1_grid=mod(num1(ifile)-1,nbslice_grid)+1; |
---|
[2] | 3468 | gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 3469 | if ~exist(gridname,'file') |
---|
| 3470 | msgbox_uvmat('ERROR',['missing grid file ' gridname]) |
---|
| 3471 | return |
---|
| 3472 | end |
---|
| 3473 | end |
---|
| 3474 | test_mask=get(handles.get_mask_civ1,'Value'); |
---|
| 3475 | if test_mask==0 |
---|
| 3476 | maskname='noFile use default'; |
---|
| 3477 | maskflag='n'; |
---|
| 3478 | else |
---|
| 3479 | maskdispl=get(handles.mask_civ1,'String');%look for mask name in edit box |
---|
| 3480 | maskbase=[filebase '_' maskdispl];% |
---|
| 3481 | nbslice=str2num(maskdispl(1:end-4)); % |
---|
| 3482 | num1_mask=mod(num1(ifile)-1,nbslice)+1; |
---|
| 3483 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 3484 | if exist(maskname,'file') |
---|
| 3485 | maskflag='y'; |
---|
| 3486 | else |
---|
| 3487 | maskname='noFile use default'; |
---|
| 3488 | maskflag='n'; |
---|
| 3489 | end |
---|
| 3490 | end |
---|
| 3491 | textcmx={'############## CMX file';... |
---|
| 3492 | ['FirstImage ' filename_ima];... |
---|
| 3493 | ['LastImage ' filename_ima_1];... |
---|
| 3494 | 'XX' ;... |
---|
| 3495 | ['Mask ' maskflag] ;... |
---|
| 3496 | ['MaskName ' maskname];... |
---|
| 3497 | ['ImageSize ' npx ' ' npy];... %VERIFIER CAS GENERAL ? |
---|
| 3498 | ['CorrelationBoxesSize ' ibx ' ' iby];... |
---|
| 3499 | ['SearchBoxeSize ' isx ' ' isy];... |
---|
| 3500 | ['RO ' rho];... |
---|
| 3501 | ['GridSpacing ' dx ' ' dy];... |
---|
| 3502 | 'XX 1.0';... |
---|
| 3503 | ['Dt_TO ' Dt ' ' T0];... |
---|
| 3504 | ['PixCmXY ' pxcmx ' ' pxcmy];... |
---|
| 3505 | 'XX 1';... |
---|
| 3506 | ['ShiftXY ' shiftx ' ' shifty];... |
---|
| 3507 | ['Grid ' gridflag];... |
---|
| 3508 | ['GridName ' gridname] ;... |
---|
| 3509 | 'XX 85';... |
---|
| 3510 | 'XX 1.0';... |
---|
| 3511 | 'XX 1.0';... |
---|
| 3512 | 'Hart 1';... |
---|
| 3513 | 'DecimalShift 0';... |
---|
| 3514 | 'Deformation 0';... |
---|
| 3515 | 'CorrelationMin 0';... |
---|
| 3516 | 'IntensityMin 0';... |
---|
| 3517 | ['SeuilImage ' threshflag];... |
---|
| 3518 | ['SeuilImageValues ' min_ima ' ' max_ima];... |
---|
| 3519 | ['ImageToUse ' term_a ' ' term_b];... % VERIFIER ? |
---|
| 3520 | 'ImageUsedBefore null null'}; |
---|
| 3521 | textout=char(textcmx); |
---|
[12] | 3522 | % dlmwrite(filename_cmx,textout,''); |
---|
| 3523 | fid=fopen([filename_cmx],'w'); |
---|
| 3524 | fprintf(fid, ['############## CMX file' '\n']); |
---|
[16] | 3525 | fprintf(fid, ['FirstImage ' regexprep(filename_ima,'\\','\\\\') '\n' ]); |
---|
| 3526 | fprintf(fid, ['LastImage ' regexprep(filename_ima_1,'\\','\\\\') '\n' ]); |
---|
[12] | 3527 | fprintf(fid, ['XX' '\n' ]); |
---|
| 3528 | fprintf(fid, ['Mask ' maskflag '\n' ]); |
---|
| 3529 | fprintf(fid, ['MaskName ' maskname '\n' ]); |
---|
| 3530 | fprintf(fid, ['ImageSize ' npx ' ' npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 3531 | fprintf(fid, ['CorrelationBoxesSize ' ibx ' ' iby '\n' ]); |
---|
| 3532 | fprintf(fid, ['SearchBoxeSize ' isx ' ' isy '\n' ]); |
---|
| 3533 | fprintf(fid, ['RO ' rho '\n' ]); |
---|
| 3534 | fprintf(fid, ['GridSpacing ' dx ' ' dy '\n' ]); |
---|
| 3535 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 3536 | fprintf(fid, ['Dt_TO ' Dt ' ' T0 '\n' ]); |
---|
| 3537 | fprintf(fid, ['PixCmXY ' pxcmx ' ' pxcmy '\n' ]); |
---|
| 3538 | fprintf(fid, ['XX 1' '\n' ]); |
---|
| 3539 | fprintf(fid, ['ShiftXY ' shiftx ' ' shifty '\n' ]); |
---|
| 3540 | fprintf(fid, ['Grid ' gridflag '\n' ]); |
---|
| 3541 | fprintf(fid, ['GridName ' gridname '\n' ]); |
---|
| 3542 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 3543 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 3544 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 3545 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
| 3546 | fprintf(fid, [ 'DecimalShift 0' '\n' ]); |
---|
| 3547 | fprintf(fid, ['Deformation 0' '\n' ]); |
---|
| 3548 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 3549 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 3550 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 3551 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
| 3552 | fprintf(fid, ['ImageToUse ' term_a ' ' term_b '\n' ]); % VERIFIER ? |
---|
| 3553 | fprintf(fid, ['ImageUsedBefore null null' '\n' ]); |
---|
| 3554 | fclose(fid); |
---|
| 3555 | |
---|
[2] | 3556 | s=-1; |
---|
| 3557 | display(['!' civ1_exe ' -f ' filename_cmx ' > ' namelog]) |
---|
| 3558 | eval(['!' civ1_exe ' -f ' filename_cmx ' > ' namelog]); |
---|
| 3559 | % if sge%dispatch computation on the cluster using interactive queue |
---|
| 3560 | % % [s,w] = unix(['qrsh -q fast.q ' civ1_exe ' -f ' filename_cmx ' > ' namelog ' 2>&1' ]); |
---|
| 3561 | % end |
---|
| 3562 | % if s~=0 |
---|
| 3563 | % % ['!' civ1_exe ' -f ' filename_cmx ' > ' namelog] |
---|
| 3564 | % % eval(['!' civ1_exe ' -f ' filename_cmx ' > ' namelog]); |
---|
| 3565 | % end |
---|
| 3566 | end |
---|
| 3567 | end |
---|
| 3568 | |
---|
[12] | 3569 | %------------------------------------------------------------------------ |
---|
[2] | 3570 | % RUN CIV2 CIV2 CIV2 CIV2 |
---|
| 3571 | function RUN_CIV2(handles,filecell_2,filecell_3,filecell_nc1,filecell_nc2,num1,num2,num_a,num_b,nom_type_nc) |
---|
[12] | 3572 | %------------------------------------------------------------------------ |
---|
[2] | 3573 | %filecell_2: names of first image |
---|
| 3574 | %filecell_3: names of second images |
---|
| 3575 | global civ2_exe sge |
---|
| 3576 | |
---|
| 3577 | %names of the civ2 fields |
---|
| 3578 | field.vel_type='civ2'; |
---|
| 3579 | field.nb='nb_vectors2'; |
---|
| 3580 | field.X='vec2_X'; |
---|
| 3581 | field.Y='vec2_Y'; |
---|
| 3582 | field.U='vec2_U'; |
---|
| 3583 | field.V='vec2_V'; |
---|
| 3584 | |
---|
| 3585 | %get civ parameters |
---|
| 3586 | ibx=get(handles.ibx_civ2,'String'); |
---|
| 3587 | iby=get(handles.iby_civ2,'String'); |
---|
| 3588 | rho=get(handles.rho_civ2,'String'); |
---|
| 3589 | decimal=int2str(get(handles.decimal,'Value')); |
---|
| 3590 | deformation=int2str(get(handles.deformation,'Value')); |
---|
| 3591 | dx=get(handles.dx_civ2,'String'); |
---|
| 3592 | dy=get(handles.dy_civ2,'String'); |
---|
| 3593 | if isequal(str2num(dx),[]) |
---|
| 3594 | dx='20';%default |
---|
| 3595 | end |
---|
| 3596 | if isequal(str2num(dy),[]) |
---|
| 3597 | dy='20';%default |
---|
| 3598 | end |
---|
| 3599 | pxcmx='1';%velocity fields are expressed in pixel displacement |
---|
| 3600 | pxcmy='1'; |
---|
| 3601 | A=imread(cell2mat(filecell_2(1,1)));%read the first image to get the size |
---|
| 3602 | sizim=size(A); |
---|
| 3603 | npx=num2str(sizim(2)); |
---|
| 3604 | npy=num2str(sizim(1)); |
---|
| 3605 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 3606 | filebase=get(handles.displ_filebase,'String'); |
---|
| 3607 | %grid |
---|
| 3608 | gridname='';%default ='noFile use default' |
---|
| 3609 | gridflag='n';%default |
---|
| 3610 | test_grid=get(handles.browse_gridciv2,'Value'); |
---|
| 3611 | nbslice_grid=[]; |
---|
| 3612 | if test_grid |
---|
| 3613 | gridname=get(handles.grid_civ2,'String'); |
---|
| 3614 | if numel(gridname)>4 && isequal(gridname(end-3:end),'grid') |
---|
| 3615 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
| 3616 | if ~isempty(nbslice_grid) |
---|
| 3617 | gridflag='y'; |
---|
| 3618 | end |
---|
| 3619 | elseif exist(gridname,'file') |
---|
| 3620 | gridflag='y'; |
---|
| 3621 | else |
---|
| 3622 | msgbox_uvmat('ERROR',['input grid file ' gridname ' not found']) |
---|
| 3623 | return |
---|
| 3624 | end |
---|
| 3625 | end |
---|
| 3626 | sizcell=size(filecell_2); |
---|
| 3627 | nbfield=sizcell(1); |
---|
| 3628 | nbslice=sizcell(2); |
---|
| 3629 | |
---|
| 3630 | %main loop |
---|
| 3631 | icount=0; |
---|
| 3632 | for ifile=1:nbfield |
---|
| 3633 | for j=1:nbslice |
---|
| 3634 | icount=icount+1; |
---|
| 3635 | barlength=0.188*icount/(nbfield*nbslice); |
---|
| 3636 | set(handles.waitbar_civ2,'Position',[0.946 0.407-barlength 0.03 barlength]) |
---|
| 3637 | drawnow |
---|
| 3638 | filename_ima_2=cell2mat(filecell_2(ifile,j)); |
---|
| 3639 | filename_ima_2([end-3:end])=[];%remove .png extension |
---|
| 3640 | filename_ima_3=cell2mat(filecell_3(ifile,j)); |
---|
| 3641 | filename_ima_3([end-3:end])=[];%remove .png extension |
---|
| 3642 | filename_cmx=cell2mat(filecell_nc2(ifile,j));%output netcdf file |
---|
| 3643 | filename_cmx([end-1:end])=[ 'cm'];%name of cmx file |
---|
| 3644 | filename_cmx=[filename_cmx 'x']; |
---|
| 3645 | namelog=[filename_cmx([1:end-3]) 'log']; |
---|
| 3646 | if size(time,1)>=num2(ifile) & size(time,2)>=num_b(j) |
---|
| 3647 | Dt=num2str(time(num2(ifile),num_b(j))-time(num1(ifile),num_a(j))); |
---|
| 3648 | if isequal(Dt,'0') |
---|
| 3649 | Dt='1' ;%case of 'displacement' mode |
---|
| 3650 | end |
---|
| 3651 | T0=num2str((time(num2(ifile),num_b(j))+time(num1(ifile),num_a(j)))/2); |
---|
| 3652 | else |
---|
| 3653 | Dt='1'; |
---|
| 3654 | T0='0'; |
---|
| 3655 | end |
---|
| 3656 | term_a=num2stra(num_a(j),nom_type_nc); |
---|
| 3657 | term_b=num2stra(num_b(j),nom_type_nc); |
---|
| 3658 | filename_nc1=cell2mat(filecell_nc1(ifile,j)); |
---|
| 3659 | filename_nc1([end-2:end])=[]; % remove '.nc' |
---|
| 3660 | if test_grid && ~isempty(nbslice_grid) |
---|
[39] | 3661 | num1_grid=mod(num1(ifile)-1,nbslice_grid)+1; |
---|
[2] | 3662 | gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 3663 | if ~exist(gridname,'file') |
---|
| 3664 | msgbox_uvmat('ERROR',['missing grid file ' gridname]) |
---|
| 3665 | return |
---|
| 3666 | end |
---|
| 3667 | end |
---|
| 3668 | test_mask=get(handles.get_mask_civ2,'Value'); |
---|
| 3669 | if test_mask==0 |
---|
| 3670 | maskname='noFile use default'; |
---|
| 3671 | maskflag='n'; |
---|
| 3672 | else |
---|
| 3673 | maskdispl=get(handles.mask_civ2,'String'); |
---|
| 3674 | maskbase=[filebase '_' maskdispl]; % |
---|
| 3675 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
| 3676 | num1_mask=mod(num1(ifile)-1,nbslice_mask)+1; |
---|
| 3677 | maskname =name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 3678 | if ~exist(maskname,'file') |
---|
| 3679 | maskflag='y'; |
---|
| 3680 | else |
---|
| 3681 | maskname='noFile use default'; |
---|
| 3682 | maskflag='n'; |
---|
| 3683 | end |
---|
| 3684 | end |
---|
| 3685 | |
---|
| 3686 | textcmx={'############## CMX file';... |
---|
| 3687 | ['FirstImage ' filename_ima_2];... |
---|
| 3688 | ['LastImage ' filename_ima_3];... |
---|
| 3689 | 'XX' ;... |
---|
| 3690 | ['Mask ' maskflag];... |
---|
| 3691 | ['MaskName ' maskname];... |
---|
| 3692 | ['ImageSize ' npx ' ' npy];... |
---|
| 3693 | ['CorrelationBoxesSize ' ibx ' ' iby];... |
---|
| 3694 | ['SearchBoxeSize ' ibx ' ' iby];... |
---|
| 3695 | ['RO ' rho];... |
---|
| 3696 | ['GridSpacing ' dx ' ' dy];... |
---|
| 3697 | 'XX 1.0';... |
---|
| 3698 | ['Dt_TO ' Dt ' ' T0];... |
---|
| 3699 | ['PixCmXY ' pxcmx ' ' pxcmy];... |
---|
| 3700 | 'XX 1';... |
---|
| 3701 | ['ShiftXY 0 0'];... |
---|
| 3702 | ['Grid ' gridflag];... |
---|
| 3703 | ['GridName ' gridname];... |
---|
| 3704 | 'XX 85';... |
---|
| 3705 | 'XX 1.0';... |
---|
| 3706 | 'XX 1.0';... |
---|
| 3707 | 'Hart 1';... |
---|
| 3708 | ['DecimalShift ' decimal];... |
---|
| 3709 | ['Deformation ' deformation];... |
---|
| 3710 | 'CorrelationMin 0';... |
---|
| 3711 | 'IntensityMin 0';... |
---|
| 3712 | 'SeuilImage n';... |
---|
| 3713 | 'SeuilImageValues 0 4096';... |
---|
| 3714 | ['ImageToUse ' term_a ' ' term_b];... % VERIFIER ? |
---|
| 3715 | ['ImageUsedBefore ' filename_nc1]}; |
---|
| 3716 | textout=char(textcmx); |
---|
[12] | 3717 | dlmwrite(filename_cmx,textout,''); |
---|
[2] | 3718 | s=-1; |
---|
| 3719 | display(['!' civ2_exe ' -f ' filename_cmx ' > ' namelog]) |
---|
| 3720 | eval(['!' civ2_exe ' -f ' filename_cmx ' > ' namelog]); |
---|
| 3721 | |
---|
| 3722 | % if sge%dispatch computation on the cluster using interactive queue |
---|
| 3723 | % [s,w] = unix(['qrsh -q fast.q ' civ2_exe ' -f ' filename_cmx ' > ' namelog ' 2>&1']); |
---|
| 3724 | % end |
---|
| 3725 | % if s~=0 |
---|
| 3726 | % eval(['!' civ2_exe ' -f ' filename_cmx ' > ' namelog]); |
---|
| 3727 | % ['!' civ2_exe ' -f ' filename_cmx ' > ' namelog] |
---|
| 3728 | % end |
---|
| 3729 | end |
---|
| 3730 | end |
---|
| 3731 | % close(h) |
---|
| 3732 | |
---|
[12] | 3733 | %------------------------------------------------------------------------ |
---|
| 3734 | % --- PATCH |
---|
[2] | 3735 | function cmd_PATCH=RUN_PATCH(filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,test_interp) |
---|
[12] | 3736 | %------------------------------------------------------------------------ |
---|
[2] | 3737 | global patch_exe patch_new_exe |
---|
| 3738 | namelog=[filename_nc([1:end-3]) '_patch.log']; |
---|
| 3739 | if test_interp==0 |
---|
| 3740 | cmd_PATCH=[patch_exe ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ... |
---|
| 3741 | ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
| 3742 | else %nouveau programme patch |
---|
| 3743 | cmd_PATCH=[patch_new_exe ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ... |
---|
| 3744 | ' -max ' thresh_value ' -nopt ' subdomain_patch ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
| 3745 | end |
---|
[12] | 3746 | |
---|
| 3747 | %------------------------------------------------------------------------ |
---|
| 3748 | % --- STEREO Interp |
---|
[2] | 3749 | 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] | 3750 | %------------------------------------------------------------------------ |
---|
[2] | 3751 | namelog=[filename_nc([1:end-3]) '_stinterp.log']; |
---|
| 3752 | cmd=[stinterp_exe ' -f1 ' filename_A_nc ' -f2 ' filename_B_nc ' -f ' filename_nc ... |
---|
| 3753 | ' -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 |
---|
| 3754 | |
---|
[12] | 3755 | %------------------------------------------------------------------------ |
---|
[2] | 3756 | % --- Executes on button press in CIV1. |
---|
| 3757 | function CIV1_Callback(hObject, eventdata, handles) |
---|
[12] | 3758 | %------------------------------------------------------------------------ |
---|
[2] | 3759 | val=get(handles.CIV1,'Value'); |
---|
| 3760 | if isequal(val,1) |
---|
| 3761 | enable_civ1(handles,'on') |
---|
| 3762 | enable_pair1(handles,'on') |
---|
| 3763 | else |
---|
| 3764 | enable_civ1(handles,'off') |
---|
| 3765 | end |
---|
| 3766 | find_netcpair_civ1(hObject, eventdata, handles); |
---|
| 3767 | |
---|
[12] | 3768 | %------------------------------------------------------------------------ |
---|
[2] | 3769 | % --- Executes on button press in FIX1. |
---|
| 3770 | function FIX1_Callback(hObject, eventdata, handles) |
---|
[12] | 3771 | %------------------------------------------------------------------------ |
---|
[2] | 3772 | enable_fix1(handles,get(handles.FIX1,'Value')) |
---|
| 3773 | |
---|
[12] | 3774 | %------------------------------------------------------------------------ |
---|
[2] | 3775 | % --- Executes on button press in PATCH1. |
---|
| 3776 | function PATCH1_Callback(hObject, eventdata, handles) |
---|
[12] | 3777 | %------------------------------------------------------------------------ |
---|
[2] | 3778 | if get(handles.PATCH1,'Value')==1 |
---|
[12] | 3779 | enable_patch1(handles) |
---|
[2] | 3780 | else |
---|
[12] | 3781 | desable_patch1(handles) |
---|
[2] | 3782 | end |
---|
| 3783 | |
---|
[12] | 3784 | %------------------------------------------------------------------------ |
---|
[2] | 3785 | % --- Executes on button press in CIV2. |
---|
| 3786 | function CIV2_Callback(hObject, eventdata, handles) |
---|
[12] | 3787 | %------------------------------------------------------------------------ |
---|
[2] | 3788 | state=get(handles.CIV2,'Value'); |
---|
| 3789 | enable_civ2(handles,state) |
---|
| 3790 | if state |
---|
| 3791 | find_netcpair_civ2(hObject, eventdata, handles) |
---|
| 3792 | enable_pair1(handles,'on') |
---|
| 3793 | end |
---|
| 3794 | |
---|
[12] | 3795 | %------------------------------------------------------------------------ |
---|
[2] | 3796 | % --- Executes on button press in FIX2. |
---|
| 3797 | function FIX2_Callback(hObject, eventdata, handles) |
---|
[12] | 3798 | %------------------------------------------------------------------------ |
---|
[2] | 3799 | if get(handles.FIX2,'Value')==1 |
---|
| 3800 | enable_fix2(handles) |
---|
| 3801 | if get(handles.CIV2,'Value')==0 |
---|
| 3802 | find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files |
---|
| 3803 | end |
---|
| 3804 | else |
---|
| 3805 | desable_fix2(handles) |
---|
| 3806 | end |
---|
| 3807 | |
---|
[12] | 3808 | %------------------------------------------------------------------------ |
---|
[2] | 3809 | % --- Executes on button press in PATCH2. |
---|
| 3810 | function PATCH2_Callback(hObject, eventdata, handles) |
---|
[12] | 3811 | %------------------------------------------------------------------------ |
---|
[2] | 3812 | if get(handles.PATCH2,'Value')==1 |
---|
| 3813 | enable_patch2(handles) |
---|
| 3814 | if get(handles.CIV2,'Value')==0 |
---|
| 3815 | find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files |
---|
| 3816 | end |
---|
| 3817 | else |
---|
| 3818 | desable_patch2(handles) |
---|
| 3819 | end |
---|
| 3820 | |
---|
[12] | 3821 | %------------------------------------------------------------------------ |
---|
| 3822 | function first_i_Callback(hObject, eventdata, handles) |
---|
| 3823 | %------------------------------------------------------------------------ |
---|
| 3824 | % last_i_Callback(hObject, eventdata, handles) |
---|
| 3825 | first_i=str2num(get(handles.first_i,'String')); |
---|
| 3826 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 3827 | % ref_i=ceil((first_i+last_i)/2); |
---|
| 3828 | set(handles.ref_i,'String', num2str(first_i))% reference index for pair dt = first index |
---|
| 3829 | ref_i_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3830 | |
---|
[12] | 3831 | %------------------------------------------------------------------------ |
---|
| 3832 | function first_j_Callback(hObject, eventdata, handles) |
---|
| 3833 | %------------------------------------------------------------------------ |
---|
| 3834 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 3835 | set(handles.ref_j,'String', num2str(first_j))% reference index for pair dt = first index |
---|
| 3836 | ref_j_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3837 | |
---|
[12] | 3838 | %------------------------------------------------------------------------ |
---|
[2] | 3839 | % --- Executes on button press in calcul_search: determine the search range isx,isy |
---|
| 3840 | function calcul_search_Callback(hObject, eventdata, handles) |
---|
[12] | 3841 | %------------------------------------------------------------------------ |
---|
[2] | 3842 | %determine pair numbers |
---|
| 3843 | list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs |
---|
| 3844 | index=get(handles.list_pair_civ1,'Value'); |
---|
| 3845 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 3846 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 3847 | pxcm_xy=get(handles.calcul_search,'UserData'); |
---|
| 3848 | pxcmx=pxcm_xy(1); |
---|
| 3849 | pxcmy=pxcm_xy(2); |
---|
| 3850 | mode_list=get(handles.mode,'String'); |
---|
| 3851 | mode_value=get(handles.mode,'Value'); |
---|
| 3852 | mode=mode_list{mode_value}; |
---|
| 3853 | if isequal (mode, 'series(Di)' ) |
---|
| 3854 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
| 3855 | num1=ref_i-floor(index/2);% first image numbers |
---|
| 3856 | num2=ref_i+ceil(index/2); |
---|
| 3857 | num_a=1; |
---|
| 3858 | num_b=1; |
---|
| 3859 | elseif isequal (mode, 'series(Dj)') |
---|
| 3860 | num1=1; |
---|
| 3861 | num2=1; |
---|
| 3862 | ref_j=str2num(get(handles.ref_j,'String')); |
---|
| 3863 | num_a=ref_j-floor(index/2);% first image numbers |
---|
| 3864 | num_b=ref_j+ceil(index/2); |
---|
| 3865 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
| 3866 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
| 3867 | num1=ref_i; |
---|
| 3868 | num2=ref_i; |
---|
| 3869 | num_a=displ_num(1,index); |
---|
| 3870 | num_b=displ_num(2,index); |
---|
| 3871 | end |
---|
| 3872 | dt=time(num2,num_b)-time(num1,num_a); |
---|
| 3873 | ibx=str2num(get(handles.ibx,'String')); |
---|
| 3874 | iby=str2num(get(handles.iby,'String')); |
---|
| 3875 | umin=dt*pxcmx*str2num(get(handles.umin,'String')); |
---|
| 3876 | umax=dt*pxcmx*str2num(get(handles.umax,'String')); |
---|
| 3877 | vmin=dt*pxcmy*str2num(get(handles.vmin,'String')); |
---|
| 3878 | vmax=dt*pxcmy*str2num(get(handles.vmax,'String')); |
---|
| 3879 | shiftx=round((umin+umax)/2); |
---|
| 3880 | shifty=round((vmin+vmax)/2); |
---|
| 3881 | isx=(umax+2-shiftx)*2+ibx; |
---|
| 3882 | isx=2*ceil(isx/2)+1; |
---|
| 3883 | isy=(vmax+2-shifty)*2+iby; |
---|
| 3884 | isy=2*ceil(isy/2)+1; |
---|
| 3885 | set(handles.shiftx,'String',num2str(shiftx)); |
---|
| 3886 | set(handles.shifty,'String',num2str(shifty)); |
---|
| 3887 | set(handles.isx,'String',num2str(isx)); |
---|
| 3888 | set(handles.isy,'String',num2str(isy)); |
---|
| 3889 | |
---|
[12] | 3890 | %------------------------------------------------------------------------ |
---|
| 3891 | % --- Executes on carriage return on the subdir civ1 edit window |
---|
[2] | 3892 | function subdir_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 3893 | %------------------------------------------------------------------------ |
---|
[2] | 3894 | subdir=get(handles.subdir_civ1,'String'); |
---|
| 3895 | set(handles.subdir_civ2,'String',subdir); |
---|
| 3896 | if get(handles.CIV1,'Value')==0 |
---|
| 3897 | find_netcpair_civ1(hObject, eventdata, handles); %update the list of available pairs from netcdf files in the new directory |
---|
| 3898 | end |
---|
| 3899 | |
---|
[12] | 3900 | %------------------------------------------------------------------------ |
---|
| 3901 | % --- Executes on carriage return on the subdir civ1 edit window |
---|
[2] | 3902 | function subdir_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 3903 | %------------------------------------------------------------------------ |
---|
[2] | 3904 | %update the list of available pairs from netcdf files in the new directory |
---|
| 3905 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0 |
---|
| 3906 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 3907 | end |
---|
| 3908 | |
---|
[12] | 3909 | %------------------------------------------------------------------------ |
---|
[2] | 3910 | % --- Executes on button press in get_mask_civ1. |
---|
| 3911 | function get_mask_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 3912 | %------------------------------------------------------------------------ |
---|
[2] | 3913 | maskval=get(handles.get_mask_civ1,'Value'); |
---|
| 3914 | if isequal(maskval,0) |
---|
| 3915 | set(handles.mask_civ1,'String','') |
---|
| 3916 | else |
---|
| 3917 | mask_displ='no mask'; %default |
---|
| 3918 | filebase=get(handles.displ_filebase,'String'); |
---|
| 3919 | [ nbslice_mask, flag_mask]=get_mask(filebase,handles); |
---|
| 3920 | if isequal(flag_mask,1) |
---|
| 3921 | mask_displ=[num2str(nbslice_mask) 'mask']; |
---|
| 3922 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
| 3923 | common_path=fileparts(filebase); |
---|
| 3924 | filebase_a=fullfile(common_path,get(handles.displ_filebase2,'String')); |
---|
| 3925 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[12] | 3926 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice_mask) |
---|
[2] | 3927 | mask_displ='no mask'; |
---|
| 3928 | end |
---|
| 3929 | end |
---|
| 3930 | if isequal(mask_displ,'no mask') |
---|
[12] | 3931 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3932 | {'*.png', ' (*.png)'; |
---|
| 3933 | '*.png', '.png files '; ... |
---|
| 3934 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3935 | 'Pick a mask file *.png',filebase); |
---|
| 3936 | mask_displ=fullfile(PathName,FileName); |
---|
| 3937 | if ~exist(mask_displ,'file') |
---|
| 3938 | mask_displ='no mask'; |
---|
| 3939 | end |
---|
| 3940 | end |
---|
| 3941 | if isequal(mask_displ,'no mask') |
---|
[2] | 3942 | set(handles.get_mask_civ1,'Value',0) |
---|
| 3943 | set(handles.get_mask_fix1,'Value',0) |
---|
| 3944 | set(handles.get_mask_civ2,'Value',0) |
---|
| 3945 | set(handles.get_mask_fix2,'Value',0) |
---|
| 3946 | else |
---|
| 3947 | set(handles.get_mask_fix1,'Value',1) |
---|
| 3948 | set(handles.get_mask_fix2,'Value',1) |
---|
| 3949 | end |
---|
| 3950 | set(handles.mask_civ1,'String',mask_displ) |
---|
| 3951 | set(handles.mask_fix1,'String',mask_displ) |
---|
| 3952 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 3953 | set(handles.mask_fix2,'String',mask_displ) |
---|
| 3954 | end |
---|
| 3955 | |
---|
[12] | 3956 | %------------------------------------------------------------------------ |
---|
[2] | 3957 | % --- Executes on button press in get_mask_fix1. |
---|
| 3958 | function get_mask_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 3959 | %------------------------------------------------------------------------ |
---|
[2] | 3960 | maskval=get(handles.get_mask_fix1,'Value'); |
---|
| 3961 | if isequal(maskval,0) |
---|
| 3962 | set(handles.mask_fix1,'String','') |
---|
| 3963 | else |
---|
| 3964 | mask_displ='no mask'; %default |
---|
| 3965 | filebase=get(handles.displ_filebase,'String'); |
---|
| 3966 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3967 | if isequal(flag_mask,1) |
---|
| 3968 | mask_displ=[num2str(nbslice) 'mask']; |
---|
| 3969 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
| 3970 | filebase_a=get(handles.displ_filebase2,'String'); |
---|
| 3971 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
| 3972 | if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice) |
---|
| 3973 | mask_displ='no mask'; |
---|
| 3974 | end |
---|
| 3975 | end |
---|
| 3976 | if isequal(mask_displ,'no mask') |
---|
[12] | 3977 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3978 | {'*.png', ' (*.png)'; |
---|
| 3979 | '*.png', '.png files '; ... |
---|
| 3980 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3981 | 'Pick a mask file *.png',filebase); |
---|
| 3982 | mask_displ=fullfile(PathName,FileName); |
---|
| 3983 | if ~exist(mask_displ,'file') |
---|
| 3984 | mask_displ='no mask'; |
---|
| 3985 | end |
---|
| 3986 | end |
---|
| 3987 | if isequal(mask_displ,'no mask') |
---|
[2] | 3988 | set(handles.get_mask_fix1,'Value',0) |
---|
| 3989 | set(handles.get_mask_civ2,'Value',0) |
---|
| 3990 | set(handles.get_mask_fix2,'Value',0) |
---|
| 3991 | else |
---|
| 3992 | %set(handles.get_mask_civ2,'Value',1) |
---|
| 3993 | set(handles.get_mask_fix2,'Value',1) |
---|
| 3994 | end |
---|
| 3995 | set(handles.mask_fix1,'String',mask_displ) |
---|
| 3996 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 3997 | set(handles.mask_fix2,'String',mask_displ) |
---|
| 3998 | end |
---|
[12] | 3999 | |
---|
| 4000 | %------------------------------------------------------------------------ |
---|
[2] | 4001 | % --- Executes on button press in get_mask_civ2. |
---|
| 4002 | function get_mask_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 4003 | %------------------------------------------------------------------------ |
---|
[2] | 4004 | maskval=get(handles.get_mask_civ2,'Value'); |
---|
| 4005 | if isequal(maskval,0) |
---|
| 4006 | set(handles.mask_civ2,'String','') |
---|
| 4007 | else |
---|
| 4008 | mask_displ='no mask'; %default |
---|
| 4009 | filebase=get(handles.displ_filebase,'String'); |
---|
| 4010 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 4011 | if isequal(flag_mask,1) |
---|
| 4012 | mask_displ=[num2str(nbslice) 'mask']; |
---|
| 4013 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
| 4014 | filebase_a=get(handles.displ_filebase2,'String'); |
---|
| 4015 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
| 4016 | if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice) |
---|
| 4017 | mask_displ='no mask'; |
---|
| 4018 | end |
---|
| 4019 | end |
---|
| 4020 | if isequal(mask_displ,'no mask') |
---|
[12] | 4021 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4022 | {'*.png', ' (*.png)'; |
---|
| 4023 | '*.png', '.png files '; ... |
---|
| 4024 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4025 | 'Pick a mask file *.png',filebase); |
---|
| 4026 | mask_displ=fullfile(PathName,FileName); |
---|
| 4027 | if ~exist(mask_displ,'file') |
---|
| 4028 | mask_displ='no mask'; |
---|
| 4029 | end |
---|
| 4030 | end |
---|
| 4031 | if isequal(mask_displ,'no mask') |
---|
[2] | 4032 | set(handles.get_mask_civ2,'Value',0) |
---|
| 4033 | set(handles.get_mask_fix2,'Value',0) |
---|
| 4034 | else |
---|
| 4035 | set(handles.get_mask_fix2,'Value',1) |
---|
| 4036 | end |
---|
| 4037 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 4038 | set(handles.mask_fix2,'String',mask_displ) |
---|
| 4039 | end |
---|
[12] | 4040 | |
---|
| 4041 | %------------------------------------------------------------------------ |
---|
[2] | 4042 | % --- Executes on button press in get_mask_fix2. |
---|
| 4043 | function get_mask_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 4044 | %------------------------------------------------------------------------ |
---|
[2] | 4045 | maskval=get(handles.get_mask_fix2,'Value'); |
---|
| 4046 | if isequal(maskval,0) |
---|
| 4047 | set(handles.mask_fix2,'String','') |
---|
| 4048 | else |
---|
[12] | 4049 | mask_displ='no mask'; %default |
---|
| 4050 | filebase=get(handles.displ_filebase,'String'); |
---|
| 4051 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 4052 | if isequal(flag_mask,1) |
---|
| 4053 | mask_displ=[num2str(nbslice) 'mask']; |
---|
| 4054 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
| 4055 | filebase_a=get(handles.displ_filebase2,'String'); |
---|
| 4056 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
| 4057 | if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice) |
---|
| 4058 | mask_displ='no mask'; |
---|
| 4059 | end |
---|
| 4060 | end |
---|
| 4061 | if isequal(mask_displ,'no mask') |
---|
| 4062 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4063 | {'*.png', ' (*.png)'; |
---|
| 4064 | '*.png', '.png files '; ... |
---|
| 4065 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4066 | 'Pick a mask file *.png',filebase); |
---|
| 4067 | mask_displ=fullfile(PathName,FileName); |
---|
| 4068 | if ~exist(mask_displ,'file') |
---|
[2] | 4069 | mask_displ='no mask'; |
---|
| 4070 | end |
---|
[12] | 4071 | end |
---|
| 4072 | if isequal(mask_displ,'no mask') |
---|
| 4073 | set(handles.get_mask_fix2,'Value',0) |
---|
| 4074 | end |
---|
| 4075 | set(handles.mask_fix2,'String',mask_displ) |
---|
[2] | 4076 | end |
---|
| 4077 | |
---|
[12] | 4078 | %------------------------------------------------------------------------ |
---|
| 4079 | % --- function called to look for mask files |
---|
[2] | 4080 | function [nbslice, flag_mask]=get_mask(filebase,handles) |
---|
[12] | 4081 | %------------------------------------------------------------------------ |
---|
[2] | 4082 | %detect mask files, images with appropriate file base |
---|
| 4083 | %[filebase '_' xx 'mask'], xx=nbslice |
---|
| 4084 | %flag_mask=1 indicates detection |
---|
| 4085 | |
---|
| 4086 | flag_mask=0;%default |
---|
| 4087 | nbslice=1; |
---|
| 4088 | |
---|
| 4089 | % subdir=get(handles.subdir_civ1,'String'); |
---|
| 4090 | [Path,Name]=fileparts(filebase); |
---|
[12] | 4091 | if ~isdir(Path) |
---|
| 4092 | msgbox_uvmat('ERROR','no path for input files') |
---|
| 4093 | return |
---|
| 4094 | end |
---|
[2] | 4095 | currentdir=pwd; |
---|
| 4096 | cd(Path);%move in the dir of the root name filebase |
---|
| 4097 | maskfiles=dir([Name '_*mask_*.png']);%look for mask files |
---|
| 4098 | cd(currentdir);%come back to the current working directory |
---|
[12] | 4099 | if ~isempty(maskfiles) |
---|
| 4100 | % msgbox_uvmat('ERROR','no mask available, to create it use Tools/Make mask in the upper menu bar of uvmat') |
---|
| 4101 | % else |
---|
[2] | 4102 | flag_mask=1; |
---|
| 4103 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 4104 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 4105 | Namedouble=double(Name); |
---|
| 4106 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 4107 | ind_mask=findstr('mask',Name); |
---|
| 4108 | i=ind_mask-1; |
---|
| 4109 | while val(i)==0 & i>0 |
---|
| 4110 | i=i-1; |
---|
| 4111 | end |
---|
| 4112 | nbslice=str2num(Name(i+1:ind_mask-1)); |
---|
| 4113 | if ~isequal(nbslice,[]) & Name(i)=='_' |
---|
| 4114 | flag_mask=1; |
---|
| 4115 | else |
---|
| 4116 | msgbox_uvmat('ERROR',['bad mask file ' Name ext ' found in ' Path2]) |
---|
| 4117 | return |
---|
| 4118 | nbslice=1; |
---|
| 4119 | end |
---|
| 4120 | end |
---|
| 4121 | |
---|
[12] | 4122 | %------------------------------------------------------------------------ |
---|
| 4123 | % --- function called to look for grid files |
---|
[2] | 4124 | function [nbslice, flag_mask]=get_grid(filebase,handles) |
---|
[12] | 4125 | %------------------------------------------------------------------------ |
---|
[2] | 4126 | flag_mask=0;%default |
---|
| 4127 | nbslice=1; |
---|
| 4128 | [Path,Name]=fileparts(filebase); |
---|
| 4129 | currentdir=pwd; |
---|
| 4130 | cd(Path);%move in the dir of the root name filebase |
---|
| 4131 | maskfiles=dir([Name '_*grid_*.grid']);%look for mask files |
---|
| 4132 | cd(currentdir);%come back to the current working directory |
---|
| 4133 | if ~isempty(maskfiles) |
---|
| 4134 | flag_mask=1; |
---|
| 4135 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 4136 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 4137 | Namedouble=double(Name); |
---|
| 4138 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 4139 | ind_mask=findstr('grid',Name); |
---|
| 4140 | i=ind_mask-1; |
---|
| 4141 | while val(i)==0 & i>0 |
---|
| 4142 | i=i-1; |
---|
| 4143 | end |
---|
| 4144 | nbslice=str2num(Name(i+1:ind_mask-1)); |
---|
| 4145 | if ~isequal(nbslice,[]) & Name(i)=='_' |
---|
| 4146 | flag_mask=1; |
---|
| 4147 | else |
---|
| 4148 | msgbox_uvmat('ERROR',['bad grid file ' Name ext ' found in ' Path2]) |
---|
| 4149 | return |
---|
| 4150 | nbslice=1; |
---|
| 4151 | end |
---|
[12] | 4152 | end |
---|
[2] | 4153 | |
---|
[12] | 4154 | %------------------------------------------------------------------------ |
---|
| 4155 | % --- transform numbers to letters |
---|
[2] | 4156 | function str=num2stra(num,nom_type); |
---|
[12] | 4157 | %------------------------------------------------------------------------ |
---|
[2] | 4158 | if isequal(nom_type,'png_old') | isequal(nom_type,'netc_old') |isequal(nom_type,'raw_SMD') |
---|
| 4159 | str=char(96+num); |
---|
| 4160 | elseif isequal(nom_type,'_i')|isequal(nom_type,'_i1-i2')... |
---|
| 4161 | |isequal(nom_type,'ima_num')| isequal(nom_type,'avi')| isequal(nom_type,'none') |
---|
| 4162 | str=''; |
---|
| 4163 | else |
---|
| 4164 | str=num2str(num); |
---|
| 4165 | end |
---|
[12] | 4166 | |
---|
| 4167 | %------------------------------------------------------------------------ |
---|
[2] | 4168 | function mask_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 4169 | %------------------------------------------------------------------------ |
---|
[2] | 4170 | set(handles.mask_civ1,'UserData',[]) |
---|
| 4171 | set(handles.mask_civ1,'String','') |
---|
[12] | 4172 | |
---|
| 4173 | %------------------------------------------------------------------------ |
---|
[2] | 4174 | function mask_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 4175 | %------------------------------------------------------------------------ |
---|
[2] | 4176 | set(handles.mask_civ2,'UserData',[]) |
---|
| 4177 | set(handles.mask_civ2,'String','') |
---|
[12] | 4178 | |
---|
| 4179 | %------------------------------------------------------------------------ |
---|
[2] | 4180 | function mask_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 4181 | %------------------------------------------------------------------------ |
---|
[2] | 4182 | set(handles.mask_fix1,'UserData',[]) |
---|
| 4183 | set(handles.mask_fix1,'String','') |
---|
[12] | 4184 | |
---|
| 4185 | %------------------------------------------------------------------------ |
---|
[2] | 4186 | function mask_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 4187 | %------------------------------------------------------------------------ |
---|
[2] | 4188 | set(handles.mask_fix2,'UserData',[]) |
---|
| 4189 | set(handles.mask_fix2,'String','') |
---|
| 4190 | |
---|
[12] | 4191 | %------------------------------------------------------------------------ |
---|
[2] | 4192 | % --- Executes on button press in list_subdir_civ1. |
---|
| 4193 | function list_subdir_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 4194 | %------------------------------------------------------------------------ |
---|
[2] | 4195 | list_subdir_civ1=get(handles.list_subdir_civ1,'String'); |
---|
| 4196 | val=get(handles.list_subdir_civ1,'Value'); |
---|
| 4197 | if val>1 |
---|
| 4198 | subdir=list_subdir_civ1{val}; |
---|
| 4199 | set(handles.subdir_civ1,'String',subdir); |
---|
| 4200 | set(handles.list_subdir_civ1,'Value',1); |
---|
| 4201 | end |
---|
| 4202 | |
---|
[12] | 4203 | %------------------------------------------------------------------------ |
---|
[2] | 4204 | % --- Executes on button press in list_subdir_civ2. |
---|
| 4205 | function list_subdir_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 4206 | %------------------------------------------------------------------------ |
---|
[2] | 4207 | list_subdir_civ2=get(handles.list_subdir_civ2,'String'); |
---|
| 4208 | val=get(handles.list_subdir_civ2,'Value'); |
---|
| 4209 | if val>1 |
---|
| 4210 | subdir=list_subdir_civ2{val}; |
---|
| 4211 | set(handles.subdir_civ2,'String',subdir); |
---|
| 4212 | set(handles.list_subdir_civ2,'Value',1); |
---|
| 4213 | end |
---|
| 4214 | |
---|
[12] | 4215 | %------------------------------------------------------------------------ |
---|
[2] | 4216 | % --- Executes on button press in browse_gridciv1. |
---|
| 4217 | function browse_gridciv1_Callback(hObject, eventdata, handles) |
---|
[12] | 4218 | %------------------------------------------------------------------------ |
---|
[2] | 4219 | value=get(handles.browse_gridciv1,'Value'); |
---|
| 4220 | testgrid=0; |
---|
| 4221 | if value |
---|
| 4222 | filebase=get(handles.displ_filebase,'String'); |
---|
[39] | 4223 | [nbslice, flag_grid]=get_grid(filebase,handles); |
---|
[2] | 4224 | if isequal(flag_grid,1) |
---|
| 4225 | filegrid=[num2str(nbslice) 'grid']; |
---|
| 4226 | testgrid=1; |
---|
| 4227 | else |
---|
| 4228 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4229 | {'*.grid', ' (*.grid)'; |
---|
| 4230 | '*.grid', '.grid files '; ... |
---|
| 4231 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4232 | 'Pick a file',filebase); |
---|
| 4233 | filegrid=fullfile(PathName,FileName); |
---|
| 4234 | if ~(isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file')) |
---|
| 4235 | testgrid=1; |
---|
| 4236 | end |
---|
| 4237 | end |
---|
| 4238 | end |
---|
| 4239 | if testgrid |
---|
| 4240 | set(handles.browse_gridciv2,'Value',1) |
---|
| 4241 | set(handles.get_gridpatch1,'Value',1) |
---|
| 4242 | set(handles.get_gridpatch2,'Value',1) |
---|
| 4243 | set(handles.dx_civ1,'Visible','off'); |
---|
| 4244 | set(handles.dy_civ1,'Visible','off'); |
---|
| 4245 | set(handles.dx_civ2,'Visible','off'); |
---|
| 4246 | set(handles.dy_civ2,'Visible','off'); |
---|
| 4247 | set(handles.grid_civ1,'String',filegrid) |
---|
| 4248 | set(handles.grid_patch1,'String',filegrid) |
---|
| 4249 | set(handles.grid_civ2,'String',filegrid) |
---|
| 4250 | set(handles.grid_patch2,'String',filegrid) |
---|
| 4251 | else |
---|
| 4252 | set(handles.browse_gridciv1,'Value',0); |
---|
| 4253 | set(handles.browse_gridciv2,'Value',0); |
---|
| 4254 | set(handles.get_gridpatch1,'Value',0) |
---|
| 4255 | set(handles.get_gridpatch2,'Value',0) |
---|
| 4256 | set(handles.dx_civ1,'Visible','on'); |
---|
| 4257 | set(handles.dy_civ1,'Visible','on'); |
---|
| 4258 | set(handles.dx_civ2,'Visible','on'); |
---|
| 4259 | set(handles.dy_civ2,'Visible','on'); |
---|
| 4260 | set(handles.grid_civ1,'String','') |
---|
| 4261 | set(handles.grid_patch1,'String','') |
---|
| 4262 | set(handles.grid_civ2,'String','') |
---|
| 4263 | set(handles.grid_patch2,'String','') |
---|
| 4264 | end |
---|
| 4265 | |
---|
[12] | 4266 | %------------------------------------------------------------------------ |
---|
[2] | 4267 | % --- Executes on button press in browse_gridciv1. |
---|
| 4268 | function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
[12] | 4269 | %------------------------------------------------------------------------ |
---|
[2] | 4270 | value=get(handles.browse_gridciv2,'Value'); |
---|
| 4271 | if value |
---|
| 4272 | filebase=get(handles.displ_filebase,'String'); |
---|
[39] | 4273 | [nbslice, flag_grid]=get_grid(filebase,handles); |
---|
[2] | 4274 | if isequal(flag_grid,1) |
---|
| 4275 | mask_displ=[num2str(nbslice) 'grid']; |
---|
| 4276 | set(handles.grid_civ2,'String',mask_displ) |
---|
| 4277 | set(handles.dx_civ2,'Visible','off'); |
---|
| 4278 | set(handles.dy_civ2,'Visible','off'); |
---|
| 4279 | else |
---|
| 4280 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4281 | {'*.grid', ' (*.grid)'; |
---|
| 4282 | '*.grid', '.grid files '; ... |
---|
| 4283 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4284 | 'Pick a file',filebase); |
---|
| 4285 | filegrid=fullfile(PathName,FileName); |
---|
| 4286 | if isempty(FileName)|isempty(PathName)|isequal(FileName,0)|~exist(filegrid,'file') |
---|
| 4287 | set(handles.browse_gridciv2,'Value',0); |
---|
| 4288 | set(handles.grid_civ2,'string',''); |
---|
| 4289 | set(handles.dx_civ2,'Visible','on'); |
---|
| 4290 | set(handles.dy_civ2,'Visible','on'); |
---|
| 4291 | set(handles.grid_civ2,'string',''); |
---|
| 4292 | else |
---|
| 4293 | set(handles.grid_civ2,'string',filegrid); |
---|
| 4294 | set(handles.dx_civ2,'Visible','off'); |
---|
| 4295 | set(handles.dy_civ2,'Visible','off'); |
---|
| 4296 | set(handles.grid_civ2,'string',filegrid); |
---|
| 4297 | end |
---|
| 4298 | end |
---|
| 4299 | else |
---|
| 4300 | set(handles.grid_civ2,'string',''); |
---|
| 4301 | set(handles.dx_civ2,'Visible','on'); |
---|
| 4302 | set(handles.dy_civ2,'Visible','on'); |
---|
| 4303 | set(handles.grid_civ2,'string',''); |
---|
| 4304 | end |
---|
| 4305 | |
---|
| 4306 | % % --- Executes on button press in browse_gridciv2. |
---|
| 4307 | % function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
| 4308 | % |
---|
| 4309 | % filebase=get(handles.displ_filebase,'String'); |
---|
| 4310 | % [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4311 | % {'*.grid', ' (*.grid)'; |
---|
| 4312 | % '*.grid', '.grid files '; ... |
---|
| 4313 | % '*.*', 'All Files (*.*)'}, ... |
---|
| 4314 | % 'Pick a file',filebase); |
---|
| 4315 | % filegrid=fullfile(PathName,FileName); |
---|
| 4316 | % set(handles.grid_civ2,'string',filegrid); |
---|
| 4317 | % set(handles.dx_civ2,'String',' '); |
---|
| 4318 | % set(handles.dy_civ2,'String',' '); |
---|
| 4319 | % % set(handles.grid_patch2,'string',filegrid); |
---|
| 4320 | |
---|
| 4321 | % --- Executes on button press in get_gridpatch1. |
---|
| 4322 | function get_gridpatch1_Callback(hObject, eventdata, handles) |
---|
| 4323 | % hObject handle to get_gridpatch1 (see GCBO) |
---|
| 4324 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 4325 | % handles structure with handles and user data (see GUIDATA) |
---|
| 4326 | |
---|
| 4327 | filebase=get(handles.displ_filebase,'String'); |
---|
| 4328 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4329 | {'*.grid', ' (*.grid)'; |
---|
| 4330 | '*.grid', '.grid files '; ... |
---|
| 4331 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4332 | 'Pick a file',filebase); |
---|
| 4333 | filegrid=fullfile(PathName,FileName); |
---|
| 4334 | set(handles.grid_patch1,'string',filegrid); |
---|
| 4335 | % set(handles.grid_patch2,'string',filegrid |
---|
| 4336 | |
---|
[12] | 4337 | %------------------------------------------------------------------------ |
---|
[2] | 4338 | % --- Executes on button press in get_gridpatch2. |
---|
| 4339 | function get_gridpatch2_Callback(hObject, eventdata, handles) |
---|
[12] | 4340 | %------------------------------------------------------------------------ |
---|
[2] | 4341 | |
---|
[12] | 4342 | %------------------------------------------------------------------------ |
---|
[2] | 4343 | function enable_civ1(handles,state) |
---|
[12] | 4344 | %------------------------------------------------------------------------ |
---|
[2] | 4345 | if isequal(state,0) |
---|
| 4346 | state='off'; |
---|
| 4347 | end |
---|
| 4348 | if isequal(state,1) |
---|
| 4349 | state='on'; |
---|
| 4350 | end |
---|
| 4351 | if isequal(state,'on') |
---|
| 4352 | set(handles.frame_civ1,'BackgroundColor',[1 1 0]) |
---|
| 4353 | set(handles.frame_para_civ1,'BackgroundColor',[1 1 0]) |
---|
| 4354 | set(handles.frame_grid_civ1,'BackgroundColor',[1 1 0]) |
---|
| 4355 | else |
---|
| 4356 | set(handles.frame_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4357 | set(handles.frame_para_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4358 | set(handles.frame_grid_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4359 | end |
---|
| 4360 | set(handles.ibx,'Visible',state) |
---|
| 4361 | set(handles.iby,'Visible',state) |
---|
| 4362 | set(handles.isx,'Visible',state) |
---|
| 4363 | set(handles.isy,'Visible',state) |
---|
| 4364 | set(handles.shiftx,'Visible',state) |
---|
| 4365 | set(handles.shifty,'Visible',state) |
---|
| 4366 | set(handles.rho,'Visible',state) |
---|
| 4367 | set(handles.dx_civ1,'Visible',state) |
---|
| 4368 | set(handles.dy_civ1,'Visible',state) |
---|
| 4369 | set(handles.calcul_search,'Visible',state) |
---|
| 4370 | set(handles.u_text,'Visible',state) |
---|
| 4371 | set(handles.v_text,'Visible',state) |
---|
| 4372 | set(handles.min,'Visible',state) |
---|
| 4373 | set(handles.max,'Visible',state) |
---|
| 4374 | set(handles.umin,'Visible',state) |
---|
| 4375 | set(handles.umax,'Visible',state) |
---|
| 4376 | set(handles.vmin,'Visible',state) |
---|
| 4377 | set(handles.vmax,'Visible',state) |
---|
| 4378 | set(handles.grid_civ1,'Visible',state) |
---|
| 4379 | set(handles.mask_civ1,'Visible',state) |
---|
| 4380 | set(handles.browse_gridciv1,'Visible',state) |
---|
| 4381 | set(handles.get_mask_civ1,'Visible',state) |
---|
| 4382 | set(handles.parameters,'Visible',state) |
---|
| 4383 | set(handles.grid,'Visible',state) |
---|
| 4384 | set(handles.dx_civ1,'Visible',state) |
---|
| 4385 | set(handles.dy_civ1,'Visible',state) |
---|
| 4386 | set(handles.ImaThreshold,'Visible',state) |
---|
| 4387 | if isequal(state,'off') |
---|
| 4388 | set(handles.MinIma,'Visible','off') |
---|
| 4389 | set(handles.MaxIma,'Visible','off') |
---|
| 4390 | set(handles.ImaThreshold,'Value',0) |
---|
| 4391 | end |
---|
| 4392 | set(handles.dx_civ1_title,'Visible',state) |
---|
| 4393 | set(handles.dy_civ1_title,'Visible',state) |
---|
| 4394 | set(handles.ImaThreshold_title,'Visible',state) |
---|
| 4395 | set(handles.ib_title,'Visible',state) |
---|
| 4396 | set(handles.is_title,'Visible',state) |
---|
| 4397 | set(handles.shift_title,'Visible',state) |
---|
| 4398 | set(handles.rho_title,'Visible',state) |
---|
| 4399 | |
---|
[12] | 4400 | %------------------------------------------------------------------------ |
---|
[2] | 4401 | function enable_fix1(handles,state) |
---|
[12] | 4402 | %------------------------------------------------------------------------ |
---|
[2] | 4403 | if isequal(state,0) |
---|
| 4404 | state='off'; |
---|
| 4405 | end |
---|
| 4406 | if isequal(state,1) |
---|
| 4407 | state='on'; |
---|
| 4408 | end |
---|
| 4409 | if isequal(state,'on') |
---|
| 4410 | set(handles.frame_fix1,'BackgroundColor',[1 1 0]) |
---|
| 4411 | else |
---|
| 4412 | set(handles.frame_fix1,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 4413 | end |
---|
| 4414 | set(handles.REMOVE,'Visible',state) |
---|
| 4415 | set(handles.vec_Fmin2,'Visible',state) |
---|
| 4416 | set(handles.vec_F2,'Visible',state) |
---|
| 4417 | set(handles.vec_F3,'Visible',state) |
---|
| 4418 | set(handles.thresh_vecC,'Visible',state) |
---|
| 4419 | set(handles.thresh_vecC_title,'Visible',state) |
---|
| 4420 | set(handles.thresh_vel,'Visible',state) |
---|
| 4421 | set(handles.thresh_vel_text,'Visible',state) |
---|
| 4422 | set(handles.mask_fix1,'Visible',state) |
---|
| 4423 | set(handles.get_mask_fix1,'Visible',state) |
---|
| 4424 | set(handles.get_ref_fix1,'Visible',state) |
---|
| 4425 | set(handles.ref_fix1,'Visible',state) |
---|
| 4426 | set(handles.inf_sup1,'Visible',state) |
---|
| 4427 | set(handles.field_ref1,'Visible',state) |
---|
| 4428 | |
---|
[12] | 4429 | %------------------------------------------------------------------------ |
---|
[2] | 4430 | function enable_patch1(handles) |
---|
[12] | 4431 | %------------------------------------------------------------------------ |
---|
[2] | 4432 | global patch_new_exe |
---|
| 4433 | set(handles.frame_patch1,'BackgroundColor',[1 1 0]) |
---|
| 4434 | set(handles.rho_patch1,'Visible','on') |
---|
| 4435 | set(handles.rho_text1,'Visible','on') |
---|
| 4436 | set(handles.thresh_patch1,'Visible','on') |
---|
| 4437 | set(handles.thresh_text1,'Visible','on') |
---|
| 4438 | set(handles.subdomain_patch1,'Visible','on') |
---|
| 4439 | set(handles.subdomain_text1,'Visible','on') |
---|
| 4440 | set(handles.nx_patch1,'Visible','on') |
---|
| 4441 | set(handles.ny_patch1,'Visible','on') |
---|
| 4442 | set(handles.nx_patch1_title,'Visible','on') |
---|
| 4443 | set(handles.ny_patch1_title,'Visible','on') |
---|
| 4444 | if (~isequal(patch_new_exe,[]) & ~isequal(patch_new_exe,[])) |
---|
| 4445 | set(handles.test_interp,'Visible','on'); |
---|
| 4446 | end |
---|
| 4447 | set(handles.get_gridpatch1,'Visible','on') |
---|
| 4448 | set(handles.grid_patch1,'string','none'); |
---|
| 4449 | set(handles.grid_patch1,'Visible','on') |
---|
| 4450 | |
---|
[12] | 4451 | %------------------------------------------------------------------------ |
---|
[2] | 4452 | function desable_patch1(handles) |
---|
[12] | 4453 | %------------------------------------------------------------------------ |
---|
[2] | 4454 | set(handles.frame_patch1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4455 | set(handles.rho_patch1,'Visible','off') |
---|
| 4456 | set(handles.rho_text1,'Visible','off') |
---|
| 4457 | set(handles.thresh_patch1,'Visible','off') |
---|
| 4458 | set(handles.thresh_text1,'Visible','off') |
---|
| 4459 | set(handles.subdomain_patch1,'Visible','off') |
---|
| 4460 | set(handles.subdomain_text1,'Visible','off') |
---|
| 4461 | set(handles.nx_patch1,'Visible','off') |
---|
| 4462 | set(handles.ny_patch1,'Visible','off') |
---|
| 4463 | set(handles.nx_patch1_title,'Visible','off') |
---|
| 4464 | set(handles.ny_patch1_title,'Visible','off') |
---|
| 4465 | set(handles.test_interp,'Visible','off') |
---|
| 4466 | set(handles.get_gridpatch1,'Visible','off') |
---|
| 4467 | set(handles.grid_patch1,'Visible','off') |
---|
| 4468 | |
---|
[12] | 4469 | %------------------------------------------------------------------------ |
---|
[2] | 4470 | function enable_civ2(handles,state) |
---|
[12] | 4471 | %------------------------------------------------------------------------ |
---|
[2] | 4472 | if isequal(state,0) |
---|
| 4473 | state='off'; |
---|
| 4474 | end |
---|
| 4475 | if isequal(state,1) |
---|
| 4476 | state='on'; |
---|
| 4477 | end |
---|
| 4478 | if isequal(state,'on') |
---|
| 4479 | set(handles.frame_civ2,'BackgroundColor',[1 1 0]) |
---|
| 4480 | set(handles.frame_para_civ2,'BackgroundColor',[1 1 0]) |
---|
| 4481 | set(handles.frame_grid_civ2,'BackgroundColor',[1 1 0]) |
---|
| 4482 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 4483 | else |
---|
| 4484 | set(handles.frame_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4485 | set(handles.frame_para_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4486 | set(handles.frame_grid_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4487 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4488 | end |
---|
| 4489 | set(handles.ibx_civ2,'Visible',state) |
---|
| 4490 | set(handles.iby_civ2,'Visible',state) |
---|
| 4491 | set(handles.decimal,'Visible',state) |
---|
| 4492 | set(handles.deformation,'Visible',state) |
---|
| 4493 | set(handles.rho_civ2,'Visible',state) |
---|
| 4494 | set(handles.dx_civ2,'Visible',state) |
---|
| 4495 | set(handles.dy_civ2,'Visible',state) |
---|
| 4496 | set(handles.browse_gridciv2,'Visible',state) |
---|
| 4497 | set(handles.get_mask_civ2,'Visible',state) |
---|
| 4498 | set(handles.parameters,'Visible',state) |
---|
| 4499 | set(handles.grid,'Visible',state) |
---|
| 4500 | set(handles.parameters_text,'Visible',state) |
---|
| 4501 | set(handles.grid_text,'Visible',state) |
---|
| 4502 | set(handles.grid_civ2,'Visible',state) |
---|
| 4503 | set(handles.mask_civ2,'Visible',state) |
---|
| 4504 | set(handles.dx_civ2_title,'Visible',state) |
---|
| 4505 | set(handles.dy_civ2_title,'Visible',state) |
---|
| 4506 | set(handles.ibx_civ2_text,'Visible',state) |
---|
| 4507 | set(handles.rho_civ2_title,'Visible',state) |
---|
| 4508 | set(handles.ImaThreshold2,'Visible',state) |
---|
| 4509 | set(handles.ImaThreshold_title2,'Visible',state) |
---|
| 4510 | if isequal(state,'off') |
---|
| 4511 | set(handles.MinIma2,'Visible','off') |
---|
| 4512 | set(handles.MaxIma2,'Visible','off') |
---|
| 4513 | set(handles.ImaThreshold2,'Value',0) |
---|
| 4514 | if isequal(get(handles.FIX2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) |
---|
| 4515 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 4516 | set(handles.subdir_civ2,'Visible','off') |
---|
| 4517 | set(handles.subdir_civ2_text,'Visible','off') |
---|
| 4518 | end |
---|
| 4519 | else |
---|
| 4520 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 4521 | set(handles.subdir_civ2,'Visible','on') |
---|
| 4522 | set(handles.subdir_civ2_text,'Visible','on') |
---|
| 4523 | end |
---|
| 4524 | |
---|
[12] | 4525 | %------------------------------------------------------------------------ |
---|
[2] | 4526 | function enable_fix2(handles) |
---|
[12] | 4527 | %------------------------------------------------------------------------ |
---|
[2] | 4528 | set(handles.frame_fix2,'BackgroundColor',[1 1 0]) |
---|
| 4529 | set(handles.REMOVE2,'Visible','on') |
---|
| 4530 | set(handles.vec_Fmin2_2,'Visible','on') |
---|
| 4531 | set(handles.vec_F4,'Visible','on') |
---|
| 4532 | set(handles.vec_F3_2,'Visible','on') |
---|
| 4533 | set(handles.thresh_vec2C,'Visible','on') |
---|
| 4534 | set(handles.thresh_vec2C_text,'Visible','on') |
---|
| 4535 | set(handles.thresh_vel2,'Visible','on') |
---|
| 4536 | set(handles.thresh_vel2_text,'Visible','on') |
---|
| 4537 | set(handles.mask_fix2,'Visible','on') |
---|
| 4538 | set(handles.get_mask_fix2,'Visible','on') |
---|
| 4539 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 4540 | set(handles.subdir_civ2,'Visible','on') |
---|
| 4541 | set(handles.subdir_civ2_text,'Visible','on') |
---|
| 4542 | set(handles.get_ref_fix2,'Visible','on') |
---|
| 4543 | set(handles.ref_fix2,'Visible','on') |
---|
| 4544 | set(handles.inf_sup2,'Visible','on') |
---|
| 4545 | set(handles.field_ref2,'Visible','on') |
---|
| 4546 | |
---|
[12] | 4547 | %------------------------------------------------------------------------ |
---|
[2] | 4548 | function desable_fix2(handles) |
---|
[12] | 4549 | %------------------------------------------------------------------------ |
---|
[2] | 4550 | set(handles.frame_fix2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4551 | set(handles.REMOVE2,'Visible','off') |
---|
| 4552 | set(handles.vec_Fmin2_2,'Visible','off') |
---|
| 4553 | set(handles.vec_F4,'Visible','off') |
---|
| 4554 | set(handles.vec_F3_2,'Visible','off') |
---|
| 4555 | set(handles.thresh_vec2C,'Visible','off') |
---|
| 4556 | set(handles.thresh_vec2C_text,'Visible','off') |
---|
| 4557 | set(handles.thresh_vel2,'Visible','off') |
---|
| 4558 | set(handles.thresh_vel2_text,'Visible','off') |
---|
| 4559 | set(handles.mask_fix2,'Visible','off') |
---|
| 4560 | set(handles.get_mask_fix2,'Visible','off') |
---|
| 4561 | set(handles.get_ref_fix2,'Visible','off') |
---|
| 4562 | set(handles.ref_fix2,'Visible','off') |
---|
| 4563 | set(handles.inf_sup2,'Visible','off') |
---|
| 4564 | set(handles.field_ref2,'Visible','off') |
---|
| 4565 | if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) |
---|
| 4566 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 4567 | set(handles.subdir_civ2,'Visible','off') |
---|
| 4568 | set(handles.subdir_civ2_text,'Visible','off') |
---|
| 4569 | end |
---|
| 4570 | |
---|
[12] | 4571 | %------------------------------------------------------------------------ |
---|
[2] | 4572 | function enable_patch2(handles) |
---|
[12] | 4573 | %------------------------------------------------------------------------ |
---|
[2] | 4574 | set(handles.frame_patch2,'BackgroundColor',[1 1 0]) |
---|
| 4575 | %set(handles.rho_patch2,'Visible','on') |
---|
| 4576 | set(handles.rho_text2,'Visible','on') |
---|
| 4577 | set(handles.thresh_patch2,'Visible','on') |
---|
| 4578 | set(handles.thresh_text2,'Visible','on') |
---|
| 4579 | set(handles.subdomain_patch2,'Visible','on') |
---|
| 4580 | set(handles.subdomain_text2,'Visible','on') |
---|
| 4581 | set(handles.nx_patch2,'Visible','on') |
---|
| 4582 | set(handles.ny_patch2,'Visible','on') |
---|
| 4583 | set(handles.nx_patch2_title,'Visible','on') |
---|
| 4584 | set(handles.ny_patch2_title,'Visible','on') |
---|
| 4585 | set(handles.get_gridpatch2,'Visible','on') |
---|
| 4586 | set(handles.grid_patch2,'Visible','on') |
---|
| 4587 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 4588 | set(handles.subdir_civ2,'Visible','on') |
---|
| 4589 | set(handles.subdir_civ2_text,'Visible','on') |
---|
| 4590 | |
---|
[12] | 4591 | %------------------------------------------------------------------------ |
---|
[2] | 4592 | function desable_patch2(handles) |
---|
[12] | 4593 | %------------------------------------------------------------------------ |
---|
[2] | 4594 | set(handles.frame_patch2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4595 | set(handles.rho_patch2,'Visible','off') |
---|
| 4596 | set(handles.rho_text2,'Visible','off') |
---|
| 4597 | set(handles.thresh_patch2,'Visible','off') |
---|
| 4598 | set(handles.thresh_text2,'Visible','off') |
---|
| 4599 | set(handles.subdomain_patch2,'Visible','off') |
---|
| 4600 | set(handles.subdomain_text2,'Visible','off') |
---|
| 4601 | set(handles.nx_patch2,'Visible','off') |
---|
| 4602 | set(handles.ny_patch2,'Visible','off') |
---|
| 4603 | set(handles.nx_patch2_title,'Visible','off') |
---|
| 4604 | set(handles.ny_patch2_title,'Visible','off') |
---|
| 4605 | set(handles.get_gridpatch2,'Visible','off') |
---|
| 4606 | set(handles.grid_patch2,'Visible','off') |
---|
| 4607 | if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.FIX2,'Value'),0) |
---|
| 4608 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 4609 | set(handles.subdir_civ2,'Visible','off') |
---|
| 4610 | set(handles.subdir_civ2_text,'Visible','off') |
---|
| 4611 | end |
---|
| 4612 | |
---|
[12] | 4613 | %------------------------------------------------------------------------ |
---|
[2] | 4614 | function enable_pair1(handles,state) |
---|
[12] | 4615 | %------------------------------------------------------------------------ |
---|
[2] | 4616 | set(handles.subdir_civ1,'Visible',state) |
---|
| 4617 | set(handles.list_subdir_civ1,'Visible',state) |
---|
| 4618 | set(handles.SUBDIR_CIV1_txt,'Visible',state) |
---|
| 4619 | set(handles.frame_subdirciv1,'Visible',state) |
---|
| 4620 | set(handles.list_pair_civ1,'Visible',state) |
---|
| 4621 | set(handles.PAIR_txt,'Visible',state) |
---|
[12] | 4622 | %set(handles.dt_display_txt,'Visible',state) |
---|
[2] | 4623 | set(handles.dt_unit,'Visible',state) |
---|
| 4624 | set(handles.PAIR_frame,'Visible',state) |
---|
| 4625 | |
---|
[12] | 4626 | %------------------------------------------------------------------------ |
---|
| 4627 | % --- Read the parameters for civ1 on the interface |
---|
[2] | 4628 | function par=read_param_civ1(handles,file_ima) |
---|
[12] | 4629 | %------------------------------------------------------------------------ |
---|
[2] | 4630 | ibx_val=str2num(get(handles.ibx,'String')); |
---|
| 4631 | par.ibx=num2str(ibx_val); |
---|
| 4632 | iby_val=str2num(get(handles.iby,'String')); |
---|
| 4633 | par.iby=num2str(iby_val); |
---|
| 4634 | isx=get(handles.isx,'String'); |
---|
| 4635 | if isempty(str2num(isx)), isx='41'; set(handles.isx,'String','41'), end; %default |
---|
| 4636 | if str2num(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.isx,'String',num2str(ibx_val+8)); end |
---|
| 4637 | isy=get(handles.isy,'String'); |
---|
| 4638 | if isempty(str2num(isy)), isy='41'; set(handles.isy,'String','41'), end;%default |
---|
| 4639 | if str2num(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.isy,'String',num2str(iby_val+8)); end |
---|
| 4640 | par.isx=get(handles.isx,'String'); |
---|
| 4641 | par.isy=get(handles.isy,'String'); |
---|
| 4642 | par.shiftx=get(handles.shiftx,'String'); |
---|
| 4643 | par.shifty=get(handles.shifty,'String'); |
---|
| 4644 | if isempty(str2num(par.isx)) |
---|
| 4645 | par.isx='41';%default |
---|
| 4646 | set(handles.isx,'String','41'); |
---|
| 4647 | end |
---|
| 4648 | if isempty(str2num(par.isy)) |
---|
| 4649 | par.isy='41'; %default |
---|
| 4650 | set(handles.isy,'String','41'); |
---|
[12] | 4651 | end |
---|
[2] | 4652 | if isempty(str2num(par.shiftx)) |
---|
| 4653 | par.shiftx='0';%default |
---|
| 4654 | set(handles.shiftx,'String','0'); |
---|
[12] | 4655 | end |
---|
[2] | 4656 | if isempty(str2num(par.shifty)) |
---|
| 4657 | par.shifty='0'; %default |
---|
| 4658 | set(handles.shifty,'String','0'); |
---|
[12] | 4659 | end |
---|
| 4660 | par.rho=get(handles.rho,'String'); |
---|
| 4661 | par.dx=get(handles.dx_civ1,'String'); |
---|
| 4662 | par.dy=get(handles.dy_civ1,'String'); |
---|
| 4663 | if isequal(str2num(par.dx),[]) |
---|
| 4664 | if isempty(get(handles.grid_civ1,'String')); |
---|
| 4665 | par.dx='0'; %just read by civ program, not used |
---|
| 4666 | else |
---|
| 4667 | par.dx='20';%default |
---|
| 4668 | set(handles.dx_civ1,'String','20'); |
---|
[2] | 4669 | end |
---|
[12] | 4670 | end |
---|
| 4671 | if isequal(str2num(par.dy),[]) |
---|
| 4672 | if isempty(get(handles.grid_civ1,'String')); |
---|
| 4673 | par.dy='0';%just read by civ program, not used |
---|
| 4674 | else |
---|
| 4675 | par.dy='20';%default |
---|
| 4676 | set(handles.dy_civ1_title,'String','20'); |
---|
[2] | 4677 | end |
---|
[12] | 4678 | end |
---|
| 4679 | par.pxcmx='1'; %velocities are expressed in pixel dispalcement |
---|
| 4680 | par.pxcmy='1'; |
---|
[2] | 4681 | % end |
---|
[12] | 4682 | A=imread(file_ima);%read the first image to get the size |
---|
| 4683 | sizim=size(A); |
---|
| 4684 | par.npx=num2str(sizim(2)); |
---|
| 4685 | par.npy=num2str(sizim(1)); |
---|
| 4686 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 4687 | par.gridname=get(handles.grid_civ1,'String'); |
---|
| 4688 | par.gridflag='y'; |
---|
| 4689 | if isequal(par.gridname,'')| isempty(par.gridname) |
---|
| 4690 | par.gridname='nogrid'; |
---|
| 4691 | par.gridflag='n'; |
---|
| 4692 | end |
---|
| 4693 | |
---|
| 4694 | %------------------------------------------------------------------------ |
---|
[2] | 4695 | function par=read_param_civ2(handles,file_ima) |
---|
[12] | 4696 | %------------------------------------------------------------------------ |
---|
| 4697 | par.ibx=get(handles.ibx_civ2,'String'); |
---|
| 4698 | par.iby=get(handles.iby_civ2,'String'); |
---|
| 4699 | par.rho=get(handles.rho_civ2,'String'); |
---|
| 4700 | par.decimal=int2str(get(handles.decimal,'Value')); |
---|
| 4701 | par.deformation=int2str(get(handles.deformation,'Value')); |
---|
| 4702 | par.dx=get(handles.dx_civ2,'String'); |
---|
| 4703 | par.dy=get(handles.dy_civ2,'String'); |
---|
| 4704 | if isequal(str2num(par.dx),[]) |
---|
| 4705 | if isempty(get(handles.grid_civ2,'String')); |
---|
| 4706 | par.dx='0'; %just read by civ program, not used |
---|
| 4707 | else |
---|
| 4708 | par.dx='20';%default |
---|
| 4709 | set(handles.dx_civ2,'String','20'); |
---|
[2] | 4710 | end |
---|
[12] | 4711 | end |
---|
| 4712 | if isequal(str2num(par.dy),[]) |
---|
| 4713 | if isempty(get(handles.grid_civ2,'String')); |
---|
| 4714 | par.dy='0';%just read by civ program, not used |
---|
| 4715 | else |
---|
| 4716 | par.dy='20';%default |
---|
| 4717 | set(handles.dy_civ2,'String','20'); |
---|
[2] | 4718 | end |
---|
[12] | 4719 | end |
---|
| 4720 | par.pxcmx='1'; |
---|
| 4721 | par.pxcmy='1'; |
---|
| 4722 | A=imread(file_ima);%read the first image to get the size |
---|
| 4723 | sizim=size(A); |
---|
| 4724 | par.npx=num2str(sizim(2)); |
---|
| 4725 | par.npy=num2str(sizim(1)); |
---|
| 4726 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
| 4727 | par.gridname=get(handles.grid_civ2,'String'); |
---|
| 4728 | par.gridflag='y'; |
---|
| 4729 | if isequal(par.gridname,'')| isempty(par.gridname) |
---|
| 4730 | par.gridname='nogrid'; |
---|
| 4731 | par.gridflag='n'; |
---|
| 4732 | end |
---|
[2] | 4733 | |
---|
[12] | 4734 | %------------------------------------------------------------------------ |
---|
| 4735 | % --- CIV1 CIV1 CIV1 CIV1 |
---|
[2] | 4736 | function cmd_CIV1=BATCH_CIV1(filename,namelog,par,handles) |
---|
[12] | 4737 | %------------------------------------------------------------------------ |
---|
[2] | 4738 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 4739 | global civ1_exe Civ_exe sge%name of the executable for civ1 calculation |
---|
| 4740 | |
---|
| 4741 | %changes : filename_cmx -> filename ( no extension ) |
---|
| 4742 | |
---|
| 4743 | if isequal(par.Dt,'0') |
---|
| 4744 | par.Dt='1' ;%case of 'displacement' mode |
---|
| 4745 | end |
---|
[12] | 4746 | % |
---|
| 4747 | % textcmx={'############## CMX file';... |
---|
| 4748 | % ['FirstImage ' par.filename_ima_a];... |
---|
| 4749 | % ['LastImage ' par.filename_ima_b];... |
---|
| 4750 | % 'XX' ;... |
---|
| 4751 | % ['Mask ' par.maskflag] ;... |
---|
| 4752 | % ['MaskName ' par.maskname];... |
---|
| 4753 | % ['ImageSize ' par.npx ' ' par.npy];... %VERIFIER CAS GENERAL ? |
---|
| 4754 | % ['CorrelationBoxesSize ' par.ibx ' ' par.iby];... |
---|
| 4755 | % ['SearchBoxeSize ' par.isx ' ' par.isy];... |
---|
| 4756 | % ['RO ' par.rho];... |
---|
| 4757 | % ['GridSpacing ' par.dx ' ' par.dy];... |
---|
| 4758 | % 'XX 1.0';... |
---|
| 4759 | % ['Dt_TO ' par.Dt ' ' par.T0];... |
---|
| 4760 | % ['PixCmXY ' par.pxcmx ' ' par.pxcmy];... |
---|
| 4761 | % 'XX 1';... |
---|
| 4762 | % ['ShiftXY ' par.shiftx ' ' par.shifty];... |
---|
| 4763 | % ['Grid ' par.gridflag];... |
---|
| 4764 | % ['GridName ' par.gridname] ;... |
---|
| 4765 | % 'XX 85';... |
---|
| 4766 | % 'XX 1.0';... |
---|
| 4767 | % 'XX 1.0';... |
---|
| 4768 | % 'Hart 1';... |
---|
| 4769 | % 'DecimalShift 0';... |
---|
| 4770 | % 'Deformation 0';... |
---|
| 4771 | % 'CorrelationMin 0';... |
---|
| 4772 | % 'IntensityMin 0';... |
---|
| 4773 | % 'SeuilImage n';... |
---|
| 4774 | % 'SeuilImageValues 0 4096';... |
---|
| 4775 | % ['ImageToUse ' par.term_a ' ' par.term_b];... % VERIFIER ? |
---|
| 4776 | % 'ImageUsedBefore null null'}; |
---|
| 4777 | % |
---|
| 4778 | % textout=char(textcmx); |
---|
[2] | 4779 | |
---|
[12] | 4780 | fid=fopen([filename '.cmx'],'w'); |
---|
| 4781 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
| 4782 | fprintf(fid, ['FirstImage ' par.filename_ima_a '\n' ]); |
---|
| 4783 | fprintf(fid, ['LastImage ' par.filename_ima_b '\n' ]); |
---|
| 4784 | fprintf(fid, ['XX' '\n' ]); |
---|
| 4785 | fprintf(fid, ['Mask ' par.maskflag '\n' ]); |
---|
| 4786 | fprintf(fid, ['MaskName ' par.maskname '\n' ]); |
---|
| 4787 | fprintf(fid, ['ImageSize ' par.npx ' ' par.npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 4788 | fprintf(fid, ['CorrelationBoxesSize ' par.ibx ' ' par.iby '\n' ]); |
---|
| 4789 | fprintf(fid, ['SearchBoxeSize ' par.isx ' ' par.isy '\n' ]); |
---|
| 4790 | fprintf(fid, ['RO ' par.rho '\n' ]); |
---|
| 4791 | fprintf(fid, ['GridSpacing ' par.dx ' ' par.dy '\n' ]); |
---|
| 4792 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4793 | fprintf(fid, ['Dt_TO ' par.Dt ' ' par.T0 '\n' ]); |
---|
| 4794 | fprintf(fid, ['PixCmXY ' par.pxcmx ' ' par.pxcmy '\n' ]); |
---|
| 4795 | fprintf(fid, ['XX 1' '\n' ]); |
---|
| 4796 | fprintf(fid, ['ShiftXY ' par.shiftx ' ' par.shifty '\n' ]); |
---|
| 4797 | fprintf(fid, ['Grid ' par.gridflag '\n' ]); |
---|
| 4798 | fprintf(fid, ['GridName ' par.gridname '\n' ]); |
---|
| 4799 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 4800 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4801 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4802 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
| 4803 | fprintf(fid, [ 'DecimalShift 0' '\n' ]); |
---|
| 4804 | fprintf(fid, ['Deformation 0' '\n' ]); |
---|
| 4805 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 4806 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 4807 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 4808 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
| 4809 | fprintf(fid, ['ImageToUse ' par.term_a ' ' par.term_b '\n' ]); % VERIFIER ? |
---|
| 4810 | fprintf(fid, ['ImageUsedBefore null null' '\n' ]); |
---|
| 4811 | fclose(fid); |
---|
| 4812 | |
---|
| 4813 | if sge |
---|
| 4814 | cmd_CIV1=[civ1_exe ' -f ' filename '.cmx' ]; % redirect standard output to the log file |
---|
| 4815 | else |
---|
| 4816 | cmd_CIV1=[civ1_exe ' -f ' filename_cmx ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
| 4817 | end |
---|
| 4818 | if(isunix) |
---|
| 4819 | [Rootbat,Filebat,extbat]=fileparts(namelog); |
---|
| 4820 | ncName=fullfile(Rootbat,[ Filebat '.nc']); |
---|
| 4821 | cmd_CIV1=[cmd_CIV1 '\n' 'mv ' namelog ' ' namelog '.civ1.log' '\n' 'chmod g+w ' ncName]; |
---|
| 4822 | else |
---|
| 4823 | cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y ' namelog ' ' namelog '.civ1.log']; |
---|
| 4824 | end |
---|
[2] | 4825 | |
---|
[12] | 4826 | %------------------------------------------------------------------------ |
---|
| 4827 | % --- CIV1 Unified |
---|
[2] | 4828 | function xml_civ1_parameters=BATCH_CIV1_Unified(filename,namelog,par) |
---|
[12] | 4829 | %------------------------------------------------------------------------ |
---|
[2] | 4830 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 4831 | global civ1_exe Civ_exe%name of the executable for civ1 calculation |
---|
| 4832 | |
---|
| 4833 | civ1.image1=par.filename_ima_a; |
---|
| 4834 | civ1.image2=par.filename_ima_b; |
---|
| 4835 | civ1.imageSize_X=par.npx; |
---|
| 4836 | civ1.imageSize_Y=par.npy; |
---|
| 4837 | civ1.outputFileName=[filename '.nc']; |
---|
| 4838 | civ1.correlationBoxesSize_X=par.ibx; |
---|
| 4839 | civ1.correlationBoxesSize_Y=par.iby; |
---|
| 4840 | civ1.searchBoxesSize_X=par.isx; |
---|
| 4841 | civ1.searchBoxesSize_Y=par.isy; |
---|
| 4842 | civ1.globalShift_X=par.shiftx; |
---|
| 4843 | civ1.globalShift_Y=par.shifty; |
---|
| 4844 | civ1.ro=par.rho; |
---|
| 4845 | civ1.hart='y'; |
---|
| 4846 | if isequal(par.gridflag,'y') |
---|
| 4847 | civ1.grid=par.gridname; |
---|
| 4848 | else |
---|
| 4849 | civ1.grid='n'; |
---|
| 4850 | civ1.gridSpacing_X=par.dx; |
---|
| 4851 | civ1.gridSpacing_Y=par.dy; |
---|
| 4852 | end |
---|
| 4853 | if isequal(par.maskflag,'y') |
---|
| 4854 | civ1.mask=par.maskname; |
---|
| 4855 | end |
---|
| 4856 | civ1.dt=par.Dt; |
---|
| 4857 | civ1.unit='pixel'; |
---|
| 4858 | civ1.absolut_time_T0=par.T0; |
---|
| 4859 | civ1.pixcmx=par.pxcmx; |
---|
| 4860 | civ1.pixcmy=par.pxcmy; |
---|
| 4861 | civ1.convectFlow='n'; |
---|
| 4862 | |
---|
| 4863 | xml_civ1_parameters=civ1; |
---|
[12] | 4864 | |
---|
| 4865 | %------------------------------------------------------------------------ |
---|
| 4866 | % --- CIV2 Unified |
---|
[2] | 4867 | function civ2=BATCH_CIV2_Unified(filename,namelog,par) |
---|
[12] | 4868 | %------------------------------------------------------------------------ |
---|
[2] | 4869 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 4870 | global civ2_exe Civ_exe%name of the executable for civ1 calculation |
---|
| 4871 | |
---|
| 4872 | civ2.image1=par.filename_ima_a; |
---|
| 4873 | civ2.image2=par.filename_ima_b; |
---|
| 4874 | civ2.imageSize_X=par.npx; |
---|
| 4875 | civ2.imageSize_Y=par.npy; |
---|
| 4876 | civ2.inputFileName=[par.filename_nc1 '.nc']; |
---|
| 4877 | civ2.outputFileName=[filename '.nc']; |
---|
| 4878 | civ2.correlationBoxesSize_X=par.ibx; |
---|
| 4879 | civ2.correlationBoxesSize_Y=par.iby; |
---|
| 4880 | civ2.ro=par.rho; |
---|
| 4881 | %civ2.decimalShift=par.decimal; |
---|
| 4882 | %civ2.deformation=par.deformation; |
---|
| 4883 | if isequal(par.decimal,'1') |
---|
| 4884 | civ2.decimalShift='y'; |
---|
| 4885 | else |
---|
| 4886 | civ2.decimalShift='n'; |
---|
| 4887 | end |
---|
| 4888 | if isequal(par.deformation,'1') |
---|
| 4889 | civ2.deformation='y'; |
---|
| 4890 | else |
---|
| 4891 | civ2.deformation='n'; |
---|
| 4892 | end |
---|
| 4893 | if isequal(par.gridflag,'y') |
---|
| 4894 | civ2.grid=par.gridname; |
---|
| 4895 | else |
---|
| 4896 | civ2.grid='n'; |
---|
| 4897 | civ2.gridSpacing_X=par.dx; |
---|
| 4898 | civ2.gridSpacing_Y=par.dy; |
---|
| 4899 | end |
---|
| 4900 | civ2.gridSpacing_X='10'; |
---|
| 4901 | civ2.gridSpacing_Y='10';%NOTE: faut mettre gridSpacing pourque ca tourne, meme si c'est la grille qui est utilisee |
---|
| 4902 | if isequal(par.maskflag,'y') |
---|
| 4903 | civ2.mask=par.maskname; |
---|
| 4904 | else |
---|
| 4905 | civ2.mask='n'; |
---|
| 4906 | end |
---|
| 4907 | civ2.dt=par.Dt; |
---|
| 4908 | civ2.unit='pixel'; |
---|
| 4909 | civ2.absolut_time_T0=par.T0; |
---|
| 4910 | civ2.pixcmx=par.pxcmx; |
---|
| 4911 | civ2.pixcmy=par.pxcmy; |
---|
| 4912 | civ2.convectFlow='n'; |
---|
| 4913 | civ2.pixcmx=par.pxcmx; |
---|
| 4914 | civ2.pixcmy=par.pxcmy; |
---|
| 4915 | civ2.convectFlow='n'; |
---|
| 4916 | |
---|
[12] | 4917 | %------------------------------------------------------------------------ |
---|
| 4918 | % --- CIV2 CIV2 CIV2 CIV2 |
---|
[2] | 4919 | function cmd_CIV2=BATCH_CIV2(filename_cmx,namelog,par) |
---|
[12] | 4920 | %------------------------------------------------------------------------ |
---|
[2] | 4921 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 4922 | global civ2_exe sge%name of the executable for civ1 calculation |
---|
| 4923 | if isequal(par.Dt,'0') |
---|
| 4924 | par.Dt='1' ;%case of 'displacement' mode |
---|
| 4925 | end |
---|
[12] | 4926 | textcmx=['############## CMX file' '\n'... |
---|
| 4927 | ['FirstImage ' par.filename_ima_a] '\n'... |
---|
| 4928 | ['LastImage ' par.filename_ima_b] '\n'... |
---|
| 4929 | 'XX' '\n'... |
---|
| 4930 | ['Mask ' par.maskflag] '\n'... |
---|
| 4931 | ['MaskName ' par.maskname] '\n'... |
---|
| 4932 | ['ImageSize ' par.npx ' ' par.npy] '\n'... |
---|
| 4933 | ['CorrelationBoxesSize ' par.ibx ' ' par.iby] '\n'... |
---|
| 4934 | ['SearchBoxeSize ' par.ibx ' ' par.iby] '\n'... |
---|
| 4935 | ['RO ' par.rho] '\n'... |
---|
| 4936 | ['GridSpacing ' par.dx ' ' par.dy] '\n'... |
---|
| 4937 | 'XX 1.0' '\n'... |
---|
| 4938 | ['Dt_TO ' par.Dt ' ' par.T0] '\n'... |
---|
| 4939 | ['PixCmXY ' par.pxcmx ' ' par.pxcmy] '\n'... |
---|
| 4940 | 'XX 1' '\n'... |
---|
| 4941 | ['ShiftXY 0 0'] '\n'... |
---|
| 4942 | ['Grid ' par.gridflag] '\n'... |
---|
| 4943 | ['GridName ' par.gridname] '\n'... |
---|
| 4944 | 'XX 85' '\n'... |
---|
| 4945 | 'XX 1.0' '\n'... |
---|
| 4946 | 'XX 1.0' '\n'... |
---|
| 4947 | 'Hart 1' '\n'... |
---|
| 4948 | ['DecimalShift ' par.decimal] '\n'... |
---|
| 4949 | ['Deformation ' par.deformation] '\n'... |
---|
| 4950 | 'CorrelationMin 0' '\n'... |
---|
| 4951 | 'IntensityMin 0' '\n'... |
---|
| 4952 | 'SeuilImage n' '\n'... |
---|
| 4953 | 'SeuilImageValues 0 4096' '\n'... |
---|
| 4954 | ['ImageToUse ' par.term_a ' ' par.term_b] '\n'... % VERIFIER ? |
---|
| 4955 | ['ImageUsedBefore ' par.filename_nc1]]; |
---|
| 4956 | textout=char(textcmx); |
---|
| 4957 | fid=fopen([filename_cmx '2'],'w'); |
---|
| 4958 | fprintf(fid,textout); |
---|
| 4959 | fclose(fid) |
---|
| 4960 | if sge |
---|
| 4961 | cmd_CIV2=[civ2_exe ' -f ' filename_cmx ]; % redirect standard output to the log file |
---|
| 4962 | else |
---|
| 4963 | cmd_CIV2=[civ2_exe ' -f ' filename_cmx ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
| 4964 | end |
---|
[2] | 4965 | |
---|
[12] | 4966 | %------------------------------------------------------------------------ |
---|
[2] | 4967 | % --- Executes on button press in HELP. |
---|
| 4968 | function HELP_Callback(hObject, eventdata, handles) |
---|
[12] | 4969 | %------------------------------------------------------------------------ |
---|
[2] | 4970 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
| 4971 | pathelp=fileparts(path_to_uvmat); |
---|
[36] | 4972 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html'); |
---|
| 4973 | if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package') |
---|
[2] | 4974 | else |
---|
[36] | 4975 | addpath (fullfile(pathelp,'uvmat_doc')) |
---|
| 4976 | web([helpfile '#civ']) |
---|
[2] | 4977 | end |
---|
| 4978 | |
---|
[12] | 4979 | %------------------------------------------------------------------------ |
---|
[2] | 4980 | %--read images and convert them to the uint16 format used for PIV |
---|
| 4981 | function A=read_image(filename,nom_type,npx,npy,num); |
---|
[12] | 4982 | %------------------------------------------------------------------------ |
---|
[2] | 4983 | %npx, npy are the dimensions needed for the raw SMD images |
---|
| 4984 | %num is the view number needed for an avi movie |
---|
| 4985 | if isequal(nom_type,'avi') |
---|
| 4986 | mov=aviread(filename,num); |
---|
| 4987 | A=frame2im(mov(1)); |
---|
| 4988 | A=sum(double(A),3); |
---|
| 4989 | A=uint16(A); |
---|
| 4990 | elseif isequal(nom_type,'raw_SMD') |
---|
| 4991 | [fid,message]=fopen(filename,'r'); |
---|
| 4992 | B=fread(fid,Inf,'int16',0,'ieee-le');%read 16 bit binary file |
---|
| 4993 | A=(reshape(B,npx,npy))'; %remplissage ligne par ligne avec une matrice colonne ? transposer(uB) pour avoir une matrice ligne |
---|
| 4994 | A=uint16(A); |
---|
| 4995 | fclose(fid); |
---|
| 4996 | else |
---|
| 4997 | A=imread(filename); |
---|
| 4998 | siz=size(A); |
---|
| 4999 | if length(siz)==3;%color images |
---|
| 5000 | A=sum(double(A),3); |
---|
| 5001 | end |
---|
| 5002 | A=uint16(A); |
---|
| 5003 | end |
---|
| 5004 | |
---|
[12] | 5005 | % %---------------------------------------------------------------- |
---|
| 5006 | % %Executes on carriage return on the time interval dt |
---|
| 5007 | % %---------------------------------------------------------------- |
---|
| 5008 | % function dt_Callback(hObject, eventdata, handles) |
---|
| 5009 | % %determine the set of times and possible intervals for CIV |
---|
| 5010 | % % answer=inputdlg('time interval between images?'); |
---|
| 5011 | % dt=(1/1000)*str2num(get(handles.dt,'String')); |
---|
| 5012 | % nbfield=str2num(get(handles.nb_field,'String')); %last image number selected in the processing series |
---|
| 5013 | % time=(dt*[0:nbfield-1])'; |
---|
| 5014 | % % set(handles.incr_i,'UserData',dt);%store the time interval between successive images |
---|
| 5015 | % set(handles.displ_filebase,'UserData',time); %store the set of times |
---|
| 5016 | % for index=1:min(nbfield-1,200) |
---|
| 5017 | % displ_num(1,index)=1; |
---|
| 5018 | % displ_num(2,index)=1; |
---|
| 5019 | % displ_num(3,index)=-floor(index/2); |
---|
| 5020 | % displ_num(4,index)=ceil(index/2); |
---|
| 5021 | % end |
---|
| 5022 | % set(handles.list_pair_civ1,'Value',1); |
---|
| 5023 | % set(handles.list_pair_civ1,'UserData',displ_num); |
---|
| 5024 | % set(handles.list_pair_civ2,'Value',1); |
---|
| 5025 | % %update the list of time intervals |
---|
| 5026 | % find_netcpair_civ1(hObject, eventdata, handles) |
---|
| 5027 | % find_netcpair_civ2(hObject, eventdata, handles) |
---|
| 5028 | |
---|
| 5029 | %------------------------------------------------------------------------ |
---|
[2] | 5030 | function ref_i_Callback(hObject, eventdata, handles) |
---|
[12] | 5031 | %------------------------------------------------------------------------ |
---|
[2] | 5032 | mode_list=get(handles.mode,'String'); |
---|
| 5033 | mode_value=get(handles.mode,'Value'); |
---|
| 5034 | mode=mode_list{mode_value}; |
---|
[12] | 5035 | %if isequal(get(handles.CIV1,'Value'),0)|| isequal(mode,'series(Di)') |
---|
[2] | 5036 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
[12] | 5037 | %end |
---|
| 5038 | if isequal(mode,'series(Di)') || ...% we do patch2 only |
---|
[2] | 5039 | (get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0) |
---|
| 5040 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 5041 | end |
---|
| 5042 | |
---|
[12] | 5043 | %------------------------------------------------------------------------ |
---|
[2] | 5044 | function ref_j_Callback(hObject, eventdata, handles) |
---|
[12] | 5045 | %------------------------------------------------------------------------ |
---|
[2] | 5046 | mode_list=get(handles.mode,'String'); |
---|
| 5047 | mode_value=get(handles.mode,'Value'); |
---|
| 5048 | mode=mode_list{mode_value}; |
---|
| 5049 | if isequal(get(handles.CIV1,'Value'),0)| isequal(mode,'series(Dj)') |
---|
| 5050 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
| 5051 | end |
---|
| 5052 | if isequal(mode,'series(Dj)') | ... |
---|
| 5053 | (get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0) |
---|
| 5054 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 5055 | end |
---|
[12] | 5056 | |
---|
| 5057 | %------------------------------------------------------------------------ |
---|
[2] | 5058 | % --- Executes on button press in compare. |
---|
| 5059 | function compare_Callback(hObject, eventdata, handles) |
---|
[12] | 5060 | %------------------------------------------------------------------------ |
---|
[2] | 5061 | test=get(handles.compare,'Value'); |
---|
| 5062 | if test==2 || test==3 |
---|
| 5063 | filebase=get(handles.displ_filebase,'String'); |
---|
| 5064 | browse=get(handles.browse_root,'Userdata'); |
---|
| 5065 | browse.nom_type_ima1=browse.nom_type_ima; |
---|
| 5066 | set(handles.browse_root,'UserData',browse); |
---|
| 5067 | set(handles.sub_txt,'Visible','on') |
---|
| 5068 | set(handles.displ_filebase2,'Visible','On');%mkes the second file input window visible |
---|
| 5069 | mode_store=get(handles.mode,'String');%get the present 'mode' |
---|
| 5070 | set(handles.compare,'UserData',mode_store);%store the mode display |
---|
| 5071 | set(handles.mode,'Visible','off') |
---|
| 5072 | if test==2 |
---|
| 5073 | set(handles.mode,'Visible','off') |
---|
| 5074 | else |
---|
| 5075 | set(handles.mode,'Visible','on') |
---|
| 5076 | end |
---|
| 5077 | |
---|
| 5078 | % open an image file with the browser |
---|
| 5079 | ind_opening=1;%default |
---|
| 5080 | browse.incr_pair=[0 0]; %default |
---|
| 5081 | oldfile=get(handles.displ_filebase,'String'); |
---|
| 5082 | menu={'*.xml;*.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ... |
---|
| 5083 | '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc', '.nc files';... |
---|
| 5084 | '*.*', 'All Files (*.*)'}; |
---|
| 5085 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile); |
---|
| 5086 | fileinput=[PathName FileName];%complete file name |
---|
| 5087 | sizf=size(fileinput); |
---|
| 5088 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
| 5089 | [path,name,ext]=fileparts(fileinput); |
---|
| 5090 | [path1]=fileparts(filebase); |
---|
| 5091 | if ~strcmp(path1,path) |
---|
| 5092 | msgbox_uvmat('ERROR','The two input image series must be in the same directory') |
---|
| 5093 | return |
---|
| 5094 | end |
---|
| 5095 | set(handles.displ_filebase2,'String',name); |
---|
| 5096 | [RootPath,RootFile,field_count,str2,str_a,str_b,xx,nom_type,subdir]=name2display(name); |
---|
| 5097 | browse=get(handles.browse_root,'UserData'); |
---|
| 5098 | browse.nom_type_ima_1=nom_type; |
---|
| 5099 | set(handles.browse_root,'UserData',browse) |
---|
| 5100 | |
---|
| 5101 | %check image extension |
---|
| 5102 | if ~strcmp(ext,get(handles.ext_ima,'String')) |
---|
| 5103 | msgbox_uvmat('ERROR','The two input image series must have the same extenion name') |
---|
| 5104 | return |
---|
| 5105 | end |
---|
| 5106 | |
---|
| 5107 | %check image size |
---|
| 5108 | A=imread(fileinput); |
---|
| 5109 | npxy=get(handles.ext_ima,'UserData'); |
---|
| 5110 | if ~isequal(npxy(1),size(A,1))|| ~isequal(npxy(2),size(A,2)) |
---|
| 5111 | msgbox_uvmat('ERROR','The two input image series must have the same size') |
---|
| 5112 | return |
---|
| 5113 | end |
---|
| 5114 | else |
---|
| 5115 | set(handles.mode,'Visible','on') |
---|
| 5116 | set(handles.displ_filebase2,'Visible','Off'); |
---|
| 5117 | set(handles.sub_txt,'Visible','off') |
---|
| 5118 | set(handles.displ_filebase2,'String',[]); |
---|
| 5119 | mode_store=get(handles.compare,'UserData'); |
---|
| 5120 | set(handles.mode,'String',mode_store) |
---|
| 5121 | set(handles.test_stereo1,'Value',0) |
---|
| 5122 | set(handles.test_stereo2,'Value',0) |
---|
| 5123 | end |
---|
| 5124 | mode_Callback(hObject, eventdata, handles) |
---|
| 5125 | |
---|
[12] | 5126 | %------------------------------------------------------------------------ |
---|
[2] | 5127 | % --- Executes on button press in get_ref_fix1. |
---|
| 5128 | function get_ref_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 5129 | %------------------------------------------------------------------------ |
---|
[2] | 5130 | filebase=get(handles.displ_filebase,'String'); |
---|
| 5131 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 5132 | {'*.nc', ' (*.nc)'; |
---|
| 5133 | '*.nc', 'netcdf files '; ... |
---|
| 5134 | '*.*', 'All Files (*.*)'}, ... |
---|
| 5135 | 'Pick a file',filebase); |
---|
| 5136 | |
---|
| 5137 | fileinput=[PathName FileName]; |
---|
| 5138 | sizf=size(fileinput); |
---|
| 5139 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
| 5140 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 5141 | ref.filebase=fullfile(Path,File); |
---|
| 5142 | ref.num_a=stra2num(str_a); |
---|
| 5143 | ref.num_b=stra2num(str_b); |
---|
| 5144 | ref.num1=str2num(field_count); |
---|
| 5145 | ref.num2=str2num(str2); |
---|
| 5146 | browse=[];%initialisation |
---|
| 5147 | if ~isequal(ref.ext,'.nc') |
---|
| 5148 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
| 5149 | return |
---|
| 5150 | end |
---|
| 5151 | set(handles.ref_fix1,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
| 5152 | set(handles.ref_fix1,'UserData',ref) |
---|
| 5153 | menu_field{1}='civ1'; |
---|
| 5154 | Data=nc2struct(fileinput,[]); |
---|
| 5155 | if isfield(Data,'patch') & isequal(Data.patch,1) |
---|
| 5156 | menu_field{2}='filter1'; |
---|
| 5157 | end |
---|
| 5158 | if isfield(Data,'civ2') & isequal(Data.civ2,1) |
---|
| 5159 | menu_field{3}='civ2'; |
---|
| 5160 | end |
---|
| 5161 | if isfield(Data,'patch2') & isequal(Data.patch2,1) |
---|
| 5162 | menu_field{4}='filter2'; |
---|
| 5163 | end |
---|
| 5164 | set(handles.field_ref1,'String',menu_field); |
---|
| 5165 | set(handles.field_ref1,'Value',length(menu_field)); |
---|
| 5166 | set(handles.inf_sup1,'Value',2); |
---|
| 5167 | set(handles.thresh_vel,'String','1');%default threshold |
---|
| 5168 | set(handles.ref_fix1,'Enable','on') |
---|
[12] | 5169 | |
---|
| 5170 | %------------------------------------------------------------------------ |
---|
[2] | 5171 | % --- Executes on button press in get_ref_fix2. |
---|
| 5172 | function get_ref_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 5173 | %------------------------------------------------------------------------ |
---|
[2] | 5174 | if isequal(get(handles.get_ref_fix2,'Value'),1) |
---|
| 5175 | filebase=get(handles.displ_filebase,'String'); |
---|
| 5176 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 5177 | {'*.nc', ' (*.nc)'; |
---|
| 5178 | '*.nc', 'netcdf files '; ... |
---|
| 5179 | '*.*', 'All Files (*.*)'}, ... |
---|
| 5180 | 'Pick a file',filebase); |
---|
| 5181 | fileinput=[PathName FileName]; |
---|
| 5182 | sizf=size(fileinput); |
---|
| 5183 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
| 5184 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 5185 | ref.filebase=fullfile(Path,File); |
---|
| 5186 | ref.num_a=stra2num(str_a); |
---|
| 5187 | ref.num_b=stra2num(str_b); |
---|
| 5188 | ref.num1=str2num(field_count); |
---|
| 5189 | ref.num2=str2num(str2); |
---|
| 5190 | browse=[];%initialisation |
---|
| 5191 | if ~isequal(ref.ext,'.nc') |
---|
| 5192 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
| 5193 | return |
---|
| 5194 | end |
---|
| 5195 | set(handles.ref_fix2,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
| 5196 | set(handles.ref_fix2,'UserData',ref) |
---|
| 5197 | menu_field{1}='civ1'; |
---|
| 5198 | Data=nc2struct(fileinput,[]); |
---|
| 5199 | if isfield(Data,'patch') & isequal(Data.patch,1) |
---|
| 5200 | menu_field{2}='filter1'; |
---|
| 5201 | end |
---|
| 5202 | if isfield(Data,'civ2') & isequal(Data.civ2,1) |
---|
| 5203 | menu_field{3}='civ2'; |
---|
| 5204 | end |
---|
| 5205 | if isfield(Data,'patch2') & isequal(Data.patch2,1) |
---|
| 5206 | menu_field{4}='filter2'; |
---|
| 5207 | end |
---|
| 5208 | set(handles.field_ref2,'String',menu_field); |
---|
| 5209 | set(handles.field_ref2,'Value',length(menu_field)); |
---|
| 5210 | set(handles.inf_sup2,'Value',2); |
---|
| 5211 | set(handles.thresh_vel2,'String','1');%default threshold |
---|
| 5212 | set(handles.ref_fix2,'Enable','on') |
---|
| 5213 | set(handles.ref_fix2,'Visible','on') |
---|
| 5214 | set(handles.field_ref2,'Visible','on') |
---|
| 5215 | else |
---|
| 5216 | set(handles.ref_fix2,'Visible','off') |
---|
| 5217 | set(handles.field_ref2,'Visible','off') |
---|
| 5218 | end |
---|
| 5219 | |
---|
[12] | 5220 | %------------------------------------------------------------------------ |
---|
[2] | 5221 | function ref_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 5222 | %------------------------------------------------------------------------ |
---|
| 5223 | set(handles.inf_sup1,'Value',1); |
---|
| 5224 | set(handles.field_ref1,'Value',1) |
---|
| 5225 | set(handles.field_ref1,'String',{' '}) |
---|
| 5226 | set(handles.ref_fix1,'UserData',[]); |
---|
| 5227 | set(handles.ref_fix1,'String',''); |
---|
| 5228 | set(handles.thresh_vel1,'String','0'); |
---|
[2] | 5229 | |
---|
[12] | 5230 | %------------------------------------------------------------------------ |
---|
[2] | 5231 | function ref_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 5232 | %------------------------------------------------------------------------ |
---|
| 5233 | set(handles.inf_sup2,'Value',1); |
---|
| 5234 | set(handles.field_ref2,'Value',1) |
---|
| 5235 | set(handles.field_ref2,'String',{' '}) |
---|
| 5236 | set(handles.ref_fix2,'UserData',[]); |
---|
| 5237 | set(handles.ref_fix2,'String',''); |
---|
| 5238 | set(handles.thresh_vel2,'String','0'); |
---|
[2] | 5239 | |
---|
[12] | 5240 | %------------------------------------------------------------------------ |
---|
[2] | 5241 | % transform letters to numbers |
---|
| 5242 | function numres=stra2num(str) |
---|
[12] | 5243 | %------------------------------------------------------------------------ |
---|
[2] | 5244 | numres=double(str)-96; |
---|
| 5245 | if double(str) >= 48 & double(str) <= 57 % = 1 for numbers |
---|
| 5246 | numres=str2num(str); |
---|
| 5247 | end |
---|
| 5248 | |
---|
[12] | 5249 | %------------------------------------------------------------------------ |
---|
[2] | 5250 | % --- Executes on button press in test_stereo1. |
---|
| 5251 | function test_stereo1_Callback(hObject, eventdata, handles) |
---|
[12] | 5252 | %------------------------------------------------------------------------ |
---|
[2] | 5253 | if isequal(get(handles.test_stereo1,'Value'),0) |
---|
| 5254 | set(handles.subdomain_patch1,'Visible','on') |
---|
| 5255 | set(handles.rho_patch1,'Visible','on') |
---|
| 5256 | else |
---|
| 5257 | set(handles.subdomain_patch1,'Visible','off') |
---|
| 5258 | set(handles.rho_patch1,'Visible','off') |
---|
| 5259 | end |
---|
| 5260 | |
---|
[12] | 5261 | %------------------------------------------------------------------------ |
---|
[2] | 5262 | % --- Executes on button press in test_stereo2. |
---|
| 5263 | function test_stereo2_Callback(hObject, eventdata, handles) |
---|
[12] | 5264 | %------------------------------------------------------------------------ |
---|
[2] | 5265 | if isequal(get(handles.test_stereo2,'Value'),0) |
---|
| 5266 | set(handles.subdomain_patch2,'Visible','on') |
---|
| 5267 | set(handles.rho_patch2,'Visible','on') |
---|
| 5268 | else |
---|
| 5269 | set(handles.subdomain_patch2,'Visible','off') |
---|
| 5270 | set(handles.rho_patch2,'Visible','off') |
---|
| 5271 | end |
---|
| 5272 | |
---|
[12] | 5273 | %------------------------------------------------------------------------ |
---|
[2] | 5274 | % --- Executes on button press in ImaThreshold. |
---|
| 5275 | function ImaThreshold_Callback(hObject, eventdata, handles) |
---|
[12] | 5276 | %------------------------------------------------------------------------ |
---|
[2] | 5277 | if isequal(get(handles.ImaThreshold,'Value'),1) |
---|
| 5278 | set(handles.MinIma,'Visible','on') |
---|
| 5279 | set(handles.MaxIma,'Visible','on') |
---|
| 5280 | else |
---|
| 5281 | set(handles.MinIma,'Visible','off') |
---|
| 5282 | set(handles.MaxIma,'Visible','off') |
---|
| 5283 | end |
---|
| 5284 | |
---|
[12] | 5285 | %------------------------------------------------------------------------ |
---|
[2] | 5286 | % --- Executes on button press in ImaThreshold2. |
---|
| 5287 | function ImaThreshold2_Callback(hObject, eventdata, handles) |
---|
[12] | 5288 | %------------------------------------------------------------------------ |
---|
[2] | 5289 | if isequal(get(handles.ImaThreshold2,'Value'),1) |
---|
| 5290 | set(handles.MinIma2,'Visible','on') |
---|
| 5291 | set(handles.MaxIma2,'Visible','on') |
---|
| 5292 | else |
---|
| 5293 | set(handles.MinIma2,'Visible','off') |
---|
| 5294 | set(handles.MaxIma2,'Visible','off') |
---|
| 5295 | end |
---|
| 5296 | |
---|