[112] | 1 | %'civ': function associated with the interface 'civ.fig' for PIV, spline interpolation and stereo PIV (patch) |
---|
[2] | 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 |
---|
[112] | 10 | % This file is part of the toolbox UVMAT. |
---|
| 11 | % |
---|
[2] | 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. |
---|
[112] | 16 | % |
---|
[2] | 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) |
---|
[273] | 23 | %TODO: search range |
---|
[2] | 24 | |
---|
[274] | 25 | % Last Modified by GUIDE v2.5 17-Nov-2011 23:05:55 |
---|
[2] | 26 | % Begin initialization code - DO NOT EDIT |
---|
| 27 | gui_Singleton = 1; |
---|
| 28 | gui_State = struct('gui_Name', mfilename, ... |
---|
[112] | 29 | 'gui_Singleton', gui_Singleton, ... |
---|
| 30 | 'gui_OpeningFcn', @civ_OpeningFcn, ... |
---|
| 31 | 'gui_OutputFcn', @civ_OutputFcn, ... |
---|
| 32 | 'gui_LayoutFcn', [] , ... |
---|
| 33 | 'gui_Callback', []); |
---|
[2] | 34 | if nargin && ischar(varargin{1}) |
---|
| 35 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
| 36 | end |
---|
| 37 | |
---|
| 38 | if nargout |
---|
| 39 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
| 40 | else |
---|
| 41 | gui_mainfcn(gui_State, varargin{:}); |
---|
| 42 | end |
---|
| 43 | % End initialization code - DO NOT EDIT |
---|
| 44 | |
---|
[12] | 45 | %------------------------------------------------------------------------ |
---|
[2] | 46 | % --- Executes just before civ is made visible. |
---|
[71] | 47 | function civ_OpeningFcn(hObject, eventdata, handles, param) |
---|
[12] | 48 | %------------------------------------------------------------------------ |
---|
[2] | 49 | % This function has no output args, see OutputFcn. |
---|
[84] | 50 | global patch_newBin %=1 if new patch processing available |
---|
[112] | 51 | %filebase: root name |
---|
[2] | 52 | %nom_type: nomencalture used ('png_old','_i_j'...) |
---|
| 53 | %list of field numbers to process |
---|
[112] | 54 | %subdir: subdirectory of the opened netcdf file |
---|
[2] | 55 | %ind_opening: operation number advised for beginning (1=civ1,2=fix1,3=patch1,4=civ2,5=fix2,6=patch2), |
---|
| 56 | %ind_a_opening ind_b_opening chosen pair from the opened netcdf file |
---|
| 57 | % Choose default command line output for civ |
---|
| 58 | handles.output = hObject; |
---|
| 59 | % Update handles structure |
---|
| 60 | guidata(hObject, handles); |
---|
[252] | 61 | set(hObject,'WindowButtonDownFcn',{'mouse_alt_gui',handles}) % allows mouse action with right button (zoom for uicontrol display) |
---|
[2] | 62 | %default initial parameters |
---|
| 63 | filebase=''; % root file name ('filebase'.civ) |
---|
| 64 | ext=[]; |
---|
[252] | 65 | |
---|
[273] | 66 | %% read names of the .exe file to adjust the interface according to available binaries |
---|
| 67 | path_uvmat=which('uvmat');% check the path detected for source file uvmat |
---|
| 68 | path_UVMAT=fileparts(path_uvmat); %path to UVMAT |
---|
| 69 | errormsg=[];%default error message |
---|
| 70 | xmlfile='PARAM.xml'; |
---|
| 71 | if exist(xmlfile,'file') |
---|
| 72 | try |
---|
| 73 | t=xmltree(xmlfile); |
---|
| 74 | sparam=convert(t); |
---|
| 75 | catch |
---|
| 76 | errormsg={' Unable to read the file PARAM.xml defining the civx binaries:'; lasterr}; |
---|
| 77 | return |
---|
| 78 | end |
---|
| 79 | else |
---|
| 80 | errormsg=[xmlfile ' not found: path to civx binaries undefined']; |
---|
| 81 | return |
---|
| 82 | end |
---|
| 83 | if ~isempty(errormsg) |
---|
| 84 | msgbox_uvmat('ERROR',errormsg); |
---|
| 85 | end |
---|
| 86 | |
---|
| 87 | test_batch=0;%default: ,no batch mode available |
---|
| 88 | if isfield(sparam,'BatchParam') && isfield(sparam.BatchParam,'BatchMode') |
---|
| 89 | test_batch=strcmp(sparam.BatchParam.BatchMode,'sge'); %sge is currently the only implemented batch mod |
---|
| 90 | end |
---|
| 91 | if test_batch==0 |
---|
| 92 | set(handles.BATCH,'Enable','off')% put the BATCH button in grey (unactivated) |
---|
| 93 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784])% put the BATCH button in grey (unactivated) |
---|
| 94 | end |
---|
| 95 | if isfield(sparam.RunParam,'CivBin') |
---|
| 96 | if ~exist(sparam.RunParam.CivBin,'file') |
---|
| 97 | sparam.RunParam.CivBin=fullfile(path_UVMAT,sparam.RunParam.CivBin); |
---|
| 98 | end |
---|
| 99 | else |
---|
| 100 | sparam.RunParam.CivBin=''; |
---|
| 101 | end |
---|
| 102 | |
---|
| 103 | %% load the list of previously browsed files in menu Open |
---|
| 104 | dir_perso=prefdir; % path to the directory .matlab for personal data |
---|
| 105 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% personal data file uvmauvmat_perso.mat' in .matlab |
---|
| 106 | if exist(profil_perso,'file') |
---|
| 107 | h=load (profil_perso); |
---|
| 108 | if isfield(h,'MenuFile') |
---|
| 109 | set(handles.MenuFile_1,'Label',h.MenuFile{1}) |
---|
| 110 | %set(handles.MenuFile_1,'Label',h.MenuFile_1); |
---|
| 111 | end |
---|
| 112 | % if isfield(h,'MenuFile_2') |
---|
| 113 | % set(handles.MenuFile_2,'Label',h.MenuFile_2); |
---|
| 114 | % end |
---|
| 115 | % if isfield(h,'MenuFile_3') |
---|
| 116 | % set(handles.MenuFile_3,'Label',h.MenuFile_3); |
---|
| 117 | % end |
---|
| 118 | % if isfield(h,'MenuFile_4') |
---|
| 119 | % set(handles.MenuFile_4,'Label',h.MenuFile_4); |
---|
| 120 | % end |
---|
| 121 | % if isfield(h,'MenuFile_5') |
---|
| 122 | % set(handles.MenuFile_5,'Label',h.MenuFile_5); |
---|
| 123 | % end |
---|
| 124 | end |
---|
| 125 | |
---|
[71] | 126 | %default input parameters: |
---|
[153] | 127 | num_i1=1; % set of field i numbers |
---|
| 128 | num_i2=1; % set of field i numbers |
---|
| 129 | num_j1=1; % set of field j numbers (fields a) |
---|
| 130 | num_j2=1; % second set of field j numbers (fields b) |
---|
[273] | 131 | %subdir='A'; % subdir for the netcdf result files |
---|
| 132 | ind_opening=0; % proposed operation number (1=civ1,2=fix1,3=patch1,4=civ2,5=fix2,6=patch2) |
---|
[112] | 133 | %load the initial parameters if the interface is started from uvmat |
---|
[71] | 134 | if exist('param','var')&&isstruct(param)% the interface is opened from uvmat |
---|
| 135 | filebase=param.RootName; |
---|
| 136 | nom_type_read=param.NomType; |
---|
[153] | 137 | num_i1=param.num1; |
---|
| 138 | if isnan(num_i1),num_i1=1;end |
---|
| 139 | num_i2=param.num2; |
---|
| 140 | if isnan(num_i2),num_i2=num_i1;end |
---|
| 141 | num_j1=param.num_a; |
---|
| 142 | if isnan(num_j1),num_j1=1;end |
---|
| 143 | num_j2=param.num_b; |
---|
| 144 | if isnan(num_j2),num_j2=num_j1;end |
---|
[71] | 145 | subdir=param.SubDir; |
---|
| 146 | ind_opening=param.IndOpening; |
---|
| 147 | ext=param.ImaExt; |
---|
[2] | 148 | end |
---|
[153] | 149 | browse.num_i1=num_i1; |
---|
| 150 | browse.num_i2=num_i2; |
---|
| 151 | browse.num_j1=num_j1; |
---|
| 152 | browse.num_j2=num_j2; |
---|
[122] | 153 | if ~isempty(ext) && (~isempty(imformats(ext(2:end)))||strcmpi(ext,'.avi'));%if an image file has been opened by uvmat |
---|
[112] | 154 | set(handles.ImaExt,'String',ext) |
---|
[128] | 155 | browse.ext_ima=ext; |
---|
[112] | 156 | if exist('nom_type_read','var') |
---|
| 157 | browse.nom_type_ima=nom_type_read; % the image nomenclature is stored |
---|
| 158 | end |
---|
[2] | 159 | elseif isequal(ext,'.nc') |
---|
| 160 | if exist('nom_type_read','var') |
---|
| 161 | browse.nom_type_nc=nom_type_read;% the netcdf nomenclature is stored |
---|
| 162 | end |
---|
| 163 | end |
---|
[71] | 164 | set(handles.RootName,'String',filebase); |
---|
[2] | 165 | set(handles.ImaDoc,'String',ext) |
---|
| 166 | |
---|
[273] | 167 | % patch_newBin=exist(sparam.RunParam.CivBin,'file'); |
---|
| 168 | % set(handles.subdir_civ1,'String',subdir)%default subdir on which uvmat was working |
---|
| 169 | % set(handles.subdir_civ2,'String',subdir)%default subdir on which uvmat was working |
---|
[71] | 170 | |
---|
[2] | 171 | %initiate advised operations |
---|
[273] | 172 | % if isemp(ind_opening,[]) |
---|
| 173 | % ind_opening=1; % default |
---|
| 174 | % end |
---|
[2] | 175 | % set default operation options |
---|
[273] | 176 | enable_civ1(handles,0) |
---|
| 177 | enable_civ2(handles,0) |
---|
| 178 | %enable_pair1(handles,'on') |
---|
| 179 | enable_fix1(handles,0) |
---|
| 180 | enable_patch1(handles,0) |
---|
| 181 | enable_fix2(handles,0) |
---|
| 182 | enable_patch2(handles,0) |
---|
[112] | 183 | set(handles.CIV1,'Value',0) |
---|
| 184 | set(handles.FIX1,'Value',0) |
---|
| 185 | set(handles.PATCH1,'Value',0) |
---|
| 186 | set(handles.CIV2,'Value',0) |
---|
| 187 | set(handles.FIX2,'Value',0) |
---|
| 188 | set(handles.PATCH2,'Value',0) |
---|
[273] | 189 | %set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[2] | 190 | if isequal(ind_opening,1) |
---|
| 191 | set(handles.CIV1,'Value',1) |
---|
[273] | 192 | enable_civ1(handles,1) |
---|
[2] | 193 | elseif isequal(ind_opening,2) |
---|
| 194 | set(handles.FIX1,'Value',1) |
---|
[273] | 195 | enable_fix1(handles,1) |
---|
[2] | 196 | elseif isequal(ind_opening,3) |
---|
| 197 | set(handles.PATCH1,'Value',1) |
---|
[273] | 198 | enable_patch1(handles,1) |
---|
[2] | 199 | elseif isequal(ind_opening,4) |
---|
| 200 | set(handles.CIV2,'Value',1) |
---|
[273] | 201 | enable_civ2(handles,1) |
---|
[2] | 202 | elseif isequal(ind_opening,5) |
---|
| 203 | set(handles.FIX2,'Value',1) |
---|
[273] | 204 | enable_fix2(handles,1) |
---|
[112] | 205 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 206 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 207 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 208 | enable_pair1(handles,'off') |
---|
[2] | 209 | elseif isequal(ind_opening,6) |
---|
| 210 | set(handles.PATCH2,'Value',1) |
---|
[273] | 211 | enable_patch2(handles,1) |
---|
[2] | 212 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 213 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 214 | enable_pair1(handles,'off') |
---|
| 215 | end |
---|
| 216 | |
---|
| 217 | % set the range of fields (1:1 by default) and selected pair |
---|
[153] | 218 | if isequal(num_i2,num_i1) |
---|
| 219 | num_ref_i=num_i1; |
---|
[2] | 220 | else |
---|
[153] | 221 | num_ref_i=floor((num_i1+num_i2)/2); |
---|
| 222 | browse.incr_pair(1)=num_i2-num_i1; |
---|
[2] | 223 | browse.incr_pair(2)=0; |
---|
| 224 | end |
---|
[153] | 225 | if isequal(num_j1,num_j2) |
---|
| 226 | if isnan(num_j1) |
---|
[2] | 227 | num_ref_j=1; |
---|
| 228 | else |
---|
[153] | 229 | num_ref_j=num_j1; |
---|
[2] | 230 | end |
---|
| 231 | else |
---|
[153] | 232 | num_ref_j=floor((num_j1+num_j2)/2); |
---|
| 233 | browse.incr_pair(2)=num_j2-num_j1; |
---|
[2] | 234 | end |
---|
| 235 | set(handles.first_i,'String',num2str(num_ref_i)); |
---|
| 236 | set(handles.last_i,'String',num2str(num_ref_i)); |
---|
| 237 | set(handles.first_j,'String',num2str(num_ref_j)); |
---|
| 238 | set(handles.last_j,'String',num2str(num_ref_j)); |
---|
| 239 | set(handles.ref_i,'String',num2str(num_ref_i)); |
---|
| 240 | set(handles.ref_j,'String',num2str(num_ref_j)); |
---|
[273] | 241 | % set(handles.ref_i_civ2,'String',num2str(num_ref_i)); |
---|
| 242 | % set(handles.ref_j_civ2,'String',num2str(num_ref_j)); |
---|
| 243 | set(handles.RootName,'UserData',browse); |
---|
[220] | 244 | if exist('param','var') && isfield(param,'RootName') && ~isempty(param.RootName)%varargin the interface is opened from uvmat |
---|
[112] | 245 | RootName_Callback(hObject, eventdata, handles); |
---|
[2] | 246 | end |
---|
| 247 | |
---|
| 248 | |
---|
[273] | 249 | %TESTS |
---|
| 250 | |
---|
| 251 | |
---|
[274] | 252 | struct=read_panel(handles.panel_Patch2) |
---|
[273] | 253 | |
---|
[12] | 254 | %------------------------------------------------------------------------ |
---|
[2] | 255 | % --- Outputs from this function are returned to the command line. |
---|
| 256 | function varargout = civ_OutputFcn(hObject, eventdata, handles) |
---|
[12] | 257 | %------------------------------------------------------------------------ |
---|
[2] | 258 | % varargout cell array for returning output args (see VARARGOUT); |
---|
| 259 | % hObject handle to figure |
---|
| 260 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 261 | % handles structure with handles and user data (see GUIDATA) |
---|
| 262 | % Get default command line output from handles structure |
---|
| 263 | varargout{1} = handles.output; |
---|
| 264 | |
---|
[273] | 265 | % -------------------------------------------------------------------- |
---|
| 266 | function MenuBrowse_Callback(hObject, eventdata, handles) |
---|
| 267 | |
---|
[2] | 268 | %get the input file properties |
---|
[71] | 269 | filebase=get(handles.RootName,'String'); |
---|
[2] | 270 | oldfile=''; %default |
---|
[39] | 271 | if isempty(filebase)|| isequal(filebase,'')%loads the previously stored file name and set it as default in the file_input box |
---|
[112] | 272 | dir_perso=prefdir; |
---|
| 273 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 274 | if exist(profil_perso,'file') |
---|
| 275 | h=load (profil_perso); |
---|
| 276 | if isfield(h,'filebase')&& ischar(h.filebase) |
---|
| 277 | oldfile=h.filebase; |
---|
| 278 | end |
---|
| 279 | if isfield(h,'RootPath') && ischar(h.RootPath) |
---|
| 280 | oldfile=h.RootPath; |
---|
| 281 | end |
---|
| 282 | end |
---|
| 283 | else |
---|
| 284 | oldfile=filebase; |
---|
| 285 | end |
---|
[2] | 286 | ind_opening=1;%default |
---|
| 287 | browse.incr_pair=[0 0]; %default |
---|
[238] | 288 | menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)'; |
---|
[174] | 289 | '*.xml', '.xml files '; ... |
---|
| 290 | '*.civ', '.civ files '; ... |
---|
| 291 | '*.png','.png image files'; ... |
---|
| 292 | '*.jpg',' jpeg image files'; ... |
---|
| 293 | '*.tif','.tif image files'; ... |
---|
| 294 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 295 | '*.nc','.netcdf files'; ... |
---|
| 296 | '*.*', 'All Files (*.*)'}; |
---|
[2] | 297 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile); |
---|
[112] | 298 | fileinput=[PathName FileName];%complete file name |
---|
[2] | 299 | sizf=size(fileinput); |
---|
| 300 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
| 301 | [path,name,ext]=fileparts(fileinput); |
---|
| 302 | testeditxml=0; |
---|
| 303 | if isequal(ext,'.xml') |
---|
| 304 | testeditxml=1; |
---|
| 305 | t_browse=xmltree(fileinput); |
---|
| 306 | head_element=get(t_browse,1); |
---|
[45] | 307 | if isfield(head_element,'name')&& isequal(head_element.name,'ImaDoc') |
---|
[2] | 308 | testeditxml=0; |
---|
| 309 | end |
---|
| 310 | end |
---|
[45] | 311 | if testeditxml==1 || isequal(ext,'.xls') |
---|
[112] | 312 | heditxml=editxml({fileinput}); |
---|
| 313 | set(heditxml,'Tag','browser') |
---|
| 314 | waitfor(heditxml,'Tag','idle') |
---|
| 315 | if ~ishandle(heditxml) |
---|
| 316 | return |
---|
| 317 | end |
---|
| 318 | attr=findobj(get(heditxml,'children'),'Tag','CurrentAttributes'); |
---|
| 319 | set(handles.browse,'UserData',fileinput)% store for future opening with browser |
---|
| 320 | fileinput=get(attr,'UserData'); |
---|
| 321 | if ~exist(fileinput,'file') |
---|
| 322 | return |
---|
| 323 | end |
---|
[2] | 324 | end |
---|
[82] | 325 | [RootPath,RootFile,str1,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput); |
---|
[2] | 326 | filebase=fullfile(RootPath,RootFile); |
---|
[89] | 327 | num_i1=str2double(str1); |
---|
| 328 | if isnan(num_i1),num_i1=1;end |
---|
| 329 | num_i2=str2double(str2); |
---|
| 330 | if isnan(num_i2),num_i2=num_i1;end |
---|
[54] | 331 | num_j1=stra2num(str_a); |
---|
[89] | 332 | if isnan(num_j1),num_j1=1;end |
---|
[54] | 333 | num_j2=stra2num(str_b); |
---|
[112] | 334 | if isnan(num_j2),num_j2=num_j1;end |
---|
[2] | 335 | if isequal(get(handles.compare,'Value'),1) |
---|
| 336 | browse=[];%initialisation |
---|
| 337 | else |
---|
[273] | 338 | browse=get(handlesRootName,'UserData'); |
---|
[2] | 339 | end |
---|
[122] | 340 | browse.num_i1=num_i1; |
---|
| 341 | browse.num_i2=num_i2; |
---|
| 342 | browse.num_j1=num_j1; |
---|
| 343 | browse.num_j2=num_j2; |
---|
| 344 | if length(ext)>1 && (~isempty(imformats(ext(2:end)))||strcmpi(ext,'.avi'));%if an image file has been opened by uvmat |
---|
[2] | 345 | browse.nom_type_ima=nom_type; |
---|
[122] | 346 | browse.ext_ima=ext; |
---|
[177] | 347 | set(handles.ImaExt,'String',ext) |
---|
[2] | 348 | end |
---|
| 349 | set(handles.ImaDoc,'String',ext); |
---|
| 350 | |
---|
| 351 | %%%%% read the state of the selected netcdf file to advise default operation |
---|
| 352 | if isequal(ext,'.nc') |
---|
| 353 | browse.nom_type_nc=nom_type; |
---|
[112] | 354 | ind_opening=2;% propose 'fix' as the default option |
---|
[246] | 355 | Data=nc2struct(fileinput,'ListGlobalAttribute','CivStage','absolut_time_T0','fix','patch','civ2','fix2'); |
---|
| 356 | if ~isempty(Data.CivStage)%test for civ files |
---|
| 357 | ind_opening=Data.CivStage; |
---|
[257] | 358 | set(handles.CivMode,'Value',3) |
---|
[246] | 359 | end |
---|
| 360 | if ~isempty(Data.absolut_time_T0)%test for civx files |
---|
[257] | 361 | set(handles.CivMode,'Value',1) |
---|
[2] | 362 | if isfield(Data,'fix') && isequal(Data.fix,1) |
---|
| 363 | ind_opening=3; |
---|
| 364 | end |
---|
[246] | 365 | if isequal(Data.patch,1) |
---|
[2] | 366 | ind_opening=4; |
---|
| 367 | end |
---|
[246] | 368 | if isequal(Data.civ2,1) |
---|
[2] | 369 | ind_opening=5; |
---|
| 370 | end |
---|
[246] | 371 | if isequal(Data.fix2,1) |
---|
[2] | 372 | ind_opening=6; |
---|
| 373 | end |
---|
| 374 | testciv=1; %TO SUPPRESS WITH NEW VERSION OF CIVX |
---|
| 375 | else |
---|
[112] | 376 | ind_opening=3; %GUI used only for patch |
---|
[2] | 377 | testciv=0; |
---|
| 378 | end |
---|
| 379 | set(handles.subdir_civ1,'String',subdir);%set the default subdir directories for installing the .nc results |
---|
| 380 | set(handles.subdir_civ2,'String',subdir); |
---|
| 381 | browse.testciv=testciv; |
---|
| 382 | browse.ind_opening=ind_opening; |
---|
| 383 | end |
---|
[71] | 384 | set(handles.RootName,'String',filebase); |
---|
[2] | 385 | set(handles.ImaDoc,'String',ext); |
---|
[45] | 386 | if ~isempty(num_i1) |
---|
[82] | 387 | ref_i=num_i1; |
---|
[45] | 388 | if ~isempty(num_i2) |
---|
| 389 | ref_i=floor((ref_i+num_i2)/2);% reference image number corresponding to the file |
---|
| 390 | browse.incr_pair(1)=num_i2-num_i1; |
---|
[2] | 391 | browse.incr_pair(2)=0; |
---|
| 392 | end |
---|
| 393 | set(handles.first_i,'String',num2str(ref_i)); |
---|
| 394 | set(handles.last_i,'String',num2str(ref_i)); |
---|
[71] | 395 | set(handles.ref_i,'String',num2str(ref_i)); |
---|
[273] | 396 | % set(handles.ref_i_civ2,'String',num2str(ref_i)) |
---|
[2] | 397 | end |
---|
[45] | 398 | if isempty(num_j1) |
---|
[2] | 399 | set(handles.ref_j,'String','1'); |
---|
[71] | 400 | set(handles.ref_j_civ2,'String','1'); |
---|
[2] | 401 | else |
---|
[45] | 402 | ref_j=num_j1; |
---|
| 403 | if ~isempty(num_j2) |
---|
| 404 | ref_j=floor((num_j1+num_j2)/2); |
---|
[112] | 405 | browse.incr_pair(2)=num_j2-num_j1; |
---|
[2] | 406 | end |
---|
| 407 | set(handles.first_j,'String',num2str(ref_j)); |
---|
| 408 | set(handles.last_j,'String',num2str(ref_j)); |
---|
[112] | 409 | set(handles.ref_j,'String',num2str(ref_j)); |
---|
[273] | 410 | % set(handles.ref_j_civ2,'String',num2str(ref_j)); |
---|
[2] | 411 | end |
---|
| 412 | |
---|
| 413 | % set default operation options |
---|
[273] | 414 | enable_civ1(handles,0) |
---|
| 415 | enable_civ2(handles,0') |
---|
[2] | 416 | enable_pair1(handles,'on') |
---|
[273] | 417 | enable_fix1(handles,0) |
---|
| 418 | enable_patch1(handles,0) |
---|
| 419 | enable_fix2(handles,0) |
---|
| 420 | enable_patch2(handles,0) |
---|
[2] | 421 | set(handles.CIV1,'Value',0) |
---|
| 422 | set(handles.FIX1,'Value',0) |
---|
| 423 | set(handles.PATCH1,'Value',0) |
---|
| 424 | set(handles.CIV2,'Value',0) |
---|
| 425 | set(handles.FIX2,'Value',0) |
---|
| 426 | set(handles.PATCH2,'Value',0) |
---|
[273] | 427 | % set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[2] | 428 | if isequal(ind_opening,1) |
---|
| 429 | set(handles.CIV1,'Value',1) |
---|
| 430 | enable_civ1(handles,'on') |
---|
| 431 | elseif isequal(ind_opening,2) |
---|
| 432 | set(handles.FIX1,'Value',1) |
---|
| 433 | enable_fix1(handles,'on') |
---|
| 434 | elseif isequal(ind_opening,3) |
---|
| 435 | set(handles.PATCH1,'Value',1) |
---|
| 436 | enable_patch1(handles) |
---|
| 437 | elseif isequal(ind_opening,4) |
---|
| 438 | set(handles.CIV2,'Value',1) |
---|
[224] | 439 | enable_civ2(handles,'on') |
---|
[2] | 440 | elseif isequal(ind_opening,5) |
---|
| 441 | enable_pair1(handles,'off') |
---|
| 442 | set(handles.FIX2,'Value',1) |
---|
| 443 | enable_fix2(handles) |
---|
[112] | 444 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 445 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 446 | set(handles.list_pair_civ2,'Enable','On') |
---|
[2] | 447 | elseif isequal(ind_opening,6) |
---|
| 448 | enable_pair1(handles,'off') |
---|
| 449 | set(handles.PATCH2,'Value',1) |
---|
| 450 | enable_patch2(handles) |
---|
| 451 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 452 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 453 | end |
---|
[273] | 454 | set(handles.RootName,'UserData',browse);% store information from browser |
---|
[71] | 455 | RootName_Callback(hObject, eventdata, handles); |
---|
[2] | 456 | |
---|
[273] | 457 | |
---|
| 458 | % ----------------------------------------------------------------------- |
---|
| 459 | % --- Open again the file whose name has been recorded in MenuFile_1 |
---|
| 460 | function MenuFile_1_Callback(hObject, eventdata, handles) |
---|
[12] | 461 | %------------------------------------------------------------------------ |
---|
[273] | 462 | fileinput=get(handles.MenuFile_1,'Label'); |
---|
| 463 | display_file_name(hObject, eventdata, handles,fileinput) |
---|
| 464 | |
---|
| 465 | % ----------------------------------------------------------------------- |
---|
| 466 | % --- Open again the file whose name has been recorded in MenuFile_2 |
---|
| 467 | function MenuFile_2_Callback(hObject, eventdata, handles) |
---|
| 468 | %------------------------------------------------------------------------ |
---|
| 469 | fileinput=get(handles.MenuFile_2,'Label'); |
---|
| 470 | display_file_name(hObject, eventdata, handles,fileinput) |
---|
| 471 | |
---|
| 472 | % ----------------------------------------------------------------------- |
---|
| 473 | % --- Open again the file whose name has been recorded in MenuFile_3 |
---|
| 474 | function MenuFile_3_Callback(hObject, eventdata, handles) |
---|
| 475 | %------------------------------------------------------------------------ |
---|
| 476 | fileinput=get(handles.MenuFile_3,'Label'); |
---|
| 477 | display_file_name(hObject, eventdata, handles,fileinput) |
---|
| 478 | |
---|
| 479 | % ----------------------------------------------------------------------- |
---|
| 480 | % --- Open again the file whose name has been recorded in MenuFile_4 |
---|
| 481 | function MenuFile_4_Callback(hObject, eventdata, handles) |
---|
| 482 | %------------------------------------------------------------------------ |
---|
| 483 | fileinput=get(handles.MenuFile_4,'Label'); |
---|
| 484 | display_file_name(hObject, eventdata, handles,fileinput) |
---|
| 485 | |
---|
| 486 | % ----------------------------------------------------------------------- |
---|
| 487 | % --- Open again the file whose name has been recorded in MenuFile_5 |
---|
| 488 | function MenuFile_5_Callback(hObject, eventdata, handles) |
---|
| 489 | %------------------------------------------------------------------------ |
---|
| 490 | fileinput=get(handles.MenuFile_5,'Label'); |
---|
| 491 | display_file_name(hObject, eventdata, handles,fileinput) |
---|
| 492 | |
---|
| 493 | %------------------------------------------------------------------------ |
---|
[2] | 494 | function ImaDoc_Callback(hObject, eventdata, handles) |
---|
[12] | 495 | %------------------------------------------------------------------------ |
---|
[71] | 496 | RootName_Callback(hObject, eventdata, handles) |
---|
[2] | 497 | |
---|
[12] | 498 | %------------------------------------------------------------------------ |
---|
[54] | 499 | % --- function activated when a new filebase (image series) is introduced |
---|
[71] | 500 | function RootName_Callback(hObject, eventdata, handles) |
---|
[12] | 501 | %------------------------------------------------------------------------ |
---|
[273] | 502 | filebase=get(handles.RootName,'String'); |
---|
| 503 | display_file_name(hObject, eventdata, handles,filebase) |
---|
| 504 | |
---|
| 505 | %------------------------------------------------------------------------ |
---|
| 506 | function display_file_name(hObject, eventdata, handles,filebase) |
---|
| 507 | %------------------------------------------------------------------------ |
---|
[2] | 508 | set(handles.compare,'Visible','on') |
---|
[122] | 509 | ext_ima='';%default |
---|
[2] | 510 | nom_type_ima=[];%default |
---|
| 511 | field_count=1;%default |
---|
| 512 | nom_type_nc=[]; |
---|
| 513 | time=[]; |
---|
[71] | 514 | TimeUnit='frame'; %default |
---|
| 515 | CoordUnit='px';%default |
---|
[2] | 516 | pxcmx_search=[];%default |
---|
| 517 | pxcmy_search=[];%default |
---|
[273] | 518 | |
---|
[128] | 519 | ext_imadoc=get(handles.ImaDoc,'String'); |
---|
[273] | 520 | browse=get(handles.RootName,'UserData');%default |
---|
[122] | 521 | if isfield(browse,'nom_type_ima') |
---|
| 522 | nom_type_ima=browse.nom_type_ima;% get an image nomenclature type already determined by an input image name |
---|
[133] | 523 | end |
---|
| 524 | if isfield(browse,'ext_ima') |
---|
[122] | 525 | ext_ima=browse.ext_ima; |
---|
[2] | 526 | end |
---|
[122] | 527 | if isfield(browse,'nom_type_nc') |
---|
| 528 | nom_type_nc=browse.nom_type_nc;% get an image nomenclature type already determined by an input image name |
---|
| 529 | end |
---|
| 530 | if isfield(browse,'num_i1') |
---|
| 531 | field_count=browse.num_i1;% get an image index type already determined by an input file |
---|
| 532 | end |
---|
[252] | 533 | set(handles.civ,'UserData',[]); %refresh list of previous civ files (for STATUS) |
---|
[2] | 534 | |
---|
| 535 | %default first_i and j and increments |
---|
[137] | 536 | first_i=str2double(get(handles.first_i,'String'));%value possibly set by uvmat_Opening |
---|
| 537 | if isnan(first_i)|| first_i < 1 |
---|
[2] | 538 | first_i=1; %default first_i |
---|
| 539 | end |
---|
[137] | 540 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 541 | if isnan(last_i)|| last_i < first_i |
---|
[2] | 542 | last_i=first_i; %default last_i |
---|
| 543 | end |
---|
[137] | 544 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 545 | if isnan(first_j)|| first_j < 1 |
---|
[2] | 546 | first_j=1; %default first_j |
---|
| 547 | end |
---|
[137] | 548 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 549 | if isnan(last_j)|| last_j < first_j |
---|
[2] | 550 | last_j=first_j; %default last_j |
---|
| 551 | end |
---|
[137] | 552 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 553 | if isnan(incr_i) || incr_i < 1; |
---|
[2] | 554 | set(handles.incr_i,'String','1') %default incr_i |
---|
| 555 | end |
---|
[137] | 556 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
| 557 | if isnan(incr_j) || incr_j < 1; |
---|
[2] | 558 | set(handles.incr_j,'String','1') %default incr_j |
---|
| 559 | end |
---|
| 560 | dt=[];%default |
---|
| 561 | testmode=0;%default |
---|
| 562 | nbfield=[]; %default |
---|
| 563 | nburst=[];%default |
---|
| 564 | pxcmx=1; |
---|
[112] | 565 | pxcmy=1; |
---|
[2] | 566 | |
---|
[112] | 567 | %look for an image documentation file |
---|
[128] | 568 | if ~strcmp(ext_imadoc,'.xml') && ~strcmp(ext_imadoc,'.civ')&& ~strcmpi(ext_imadoc,'.avi') |
---|
[2] | 569 | if exist([filebase '.xml'],'file') |
---|
[128] | 570 | ext_imadoc='.xml'; |
---|
[2] | 571 | elseif exist([filebase '.civxml'],'file') |
---|
[128] | 572 | ext_imadoc='.civxml'; |
---|
[2] | 573 | elseif exist([filebase '.civ'],'file') |
---|
[128] | 574 | ext_imadoc='.civ'; |
---|
[112] | 575 | elseif exist([filebase '.avi'],'file') |
---|
[128] | 576 | ext_imadoc='.avi'; |
---|
[2] | 577 | elseif exist([filebase '.AVI'],'file') |
---|
[128] | 578 | ext_imadoc='.AVI'; |
---|
[2] | 579 | end |
---|
[128] | 580 | set(handles.ImaDoc,'String',ext_imadoc) |
---|
[2] | 581 | end |
---|
| 582 | |
---|
| 583 | %%%%%%%% read image documentation file %%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[84] | 584 | mode=''; %default |
---|
| 585 | set(handles.ImaDoc,'BackgroundColor',[1 1 0]) |
---|
| 586 | drawnow |
---|
[128] | 587 | if isequal(ext_imadoc,'.civxml') || isequal(ext_imadoc,'.xml')|| isequal(ext_imadoc,'.civ') |
---|
[2] | 588 | set(handles.ref_i,'Visible','On')%use a reference index |
---|
| 589 | set(handles.ref_j,'Visible','On') |
---|
[128] | 590 | elseif isequal(ext_imadoc,'.avi') || isequal(ext_imadoc,'.AVI') |
---|
[2] | 591 | set(handles.ref_j,'Visible','Off') |
---|
| 592 | else |
---|
| 593 | set(handles.ref_i,'Visible','Off') |
---|
| 594 | set(handles.ref_j,'Visible','Off') |
---|
| 595 | end |
---|
[12] | 596 | testima_xml=0; |
---|
[128] | 597 | if isequal(ext_imadoc,'.civxml')%TO ABANDON |
---|
[122] | 598 | [nbfield,nbfield2,time]=read_civxml([filebase '.civxml']); |
---|
[2] | 599 | mode='pair j1-j2'; |
---|
| 600 | if isempty(nom_type_ima)% dtermine types by default if not already selected by browser or uvmat |
---|
[112] | 601 | nom_type_ima='_i_j'; |
---|
[2] | 602 | end |
---|
[128] | 603 | elseif isequal(ext_imadoc,'.xml') |
---|
[73] | 604 | [XmlData,warntext]=imadoc2struct([filebase '.xml']); |
---|
[2] | 605 | ext_ima_read=[]; |
---|
| 606 | nom_type_read=[]; |
---|
[12] | 607 | if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')&&ischar(XmlData.Heading.ImageName)% get image nom type and extension from the xml file |
---|
[2] | 608 | [PP,FF,fc,str2,str_a,str_b,ext_ima_read,nom_type_read]=name2display(XmlData.Heading.ImageName); |
---|
[112] | 609 | fullname=fullfile(fileparts(filebase),XmlData.Heading.ImageName); %full name (including path) of the first image defined by the xmle file, |
---|
[45] | 610 | if ~exist(fullname,'file') |
---|
[12] | 611 | msgbox_uvmat('WARNING',['FirstImage ' fullname ' defined in the xml file does not exist']) |
---|
| 612 | end |
---|
[2] | 613 | end |
---|
[84] | 614 | if isfield(XmlData,'Time') |
---|
[85] | 615 | time=XmlData.Time; |
---|
[84] | 616 | nbfield=size(time,1); |
---|
[122] | 617 | nbfield2=size(time,2); |
---|
[127] | 618 | %transform .Time to a column vector if it is a line vector thenomenclature uses a single index: correct possible bug in xml |
---|
[122] | 619 | if isequal(nbfield,1) && ~isequal(nbfield2,1)% .Time is a line vector |
---|
[127] | 620 | if numel(nom_type_read)>=2 && isempty(regexp(nom_type_read(2:end),'\D')) |
---|
[84] | 621 | time=time'; |
---|
[122] | 622 | nbfield=nbfield2; |
---|
| 623 | nbfield2=1; |
---|
[84] | 624 | end |
---|
| 625 | end |
---|
| 626 | end |
---|
[71] | 627 | if isfield(XmlData,'TimeUnit') |
---|
| 628 | TimeUnit=XmlData.TimeUnit; |
---|
[2] | 629 | end |
---|
[71] | 630 | if isfield(XmlData,'Npx') |
---|
| 631 | npx=XmlData.Npx; |
---|
| 632 | npy=XmlData.Npy; |
---|
| 633 | end |
---|
[2] | 634 | pxcmx_search=1; |
---|
| 635 | pxcmy_search=1; |
---|
| 636 | if isfield(XmlData,'GeometryCalib') |
---|
| 637 | tsai=XmlData.GeometryCalib; |
---|
[112] | 638 | if isfield(tsai,'f') && isfield(tsai,'Tz') && isfield(tsai,'dpx') && isfield(tsai,'dpy')&& isfield(tsai,'R') |
---|
| 639 | rot2D=tsai.R(1:2,[1,2]); |
---|
| 640 | pxcmx_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpx); |
---|
| 641 | pxcmy_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpy); |
---|
[2] | 642 | end |
---|
[112] | 643 | if isfield(tsai,'CoordUnit') |
---|
| 644 | CoordUnit=tsai.CoordUnit; |
---|
[2] | 645 | end |
---|
[112] | 646 | end |
---|
[128] | 647 | elseif strcmp(ext_imadoc,'.civ')% case of .civ image documentation file |
---|
[112] | 648 | [error,time,TimeUnit,mode,npx,npy]=read_imatext([filebase '.civ']); |
---|
| 649 | if error==2, msgbox_uvmat('WARNING',['no file ' filebase '.civ']); |
---|
| 650 | elseif error==1, msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file'); |
---|
| 651 | end |
---|
[128] | 652 | nom_type_ima='001a'; |
---|
| 653 | elseif strcmpi(ext_imadoc,'.avi') |
---|
[112] | 654 | nom_type_ima='*'; |
---|
[128] | 655 | ext_ima=ext_imadoc; |
---|
[273] | 656 | set(handles.CivMode,'Value',1); |
---|
| 657 | set(handles.CivMode,'String',{'series(Di)'}) |
---|
[112] | 658 | dt=0.04;%default |
---|
[128] | 659 | if exist([filebase ext_imadoc],'file')==2 |
---|
| 660 | info=aviinfo([filebase ext_imadoc]);%read infos on the avi movie |
---|
[112] | 661 | dt=1/info.FramesPerSecond;%time interval between successive frames |
---|
| 662 | nbfield=info.NumFrames;%number of frames |
---|
| 663 | end |
---|
| 664 | time=(dt*(0:nbfield-1))';%list of image times |
---|
[2] | 665 | end |
---|
| 666 | if isempty(time) |
---|
| 667 | set(handles.ImaDoc,'String',''); %xml file not used for timing |
---|
| 668 | end |
---|
| 669 | set(handles.ImaDoc,'BackgroundColor',[1 1 1]) |
---|
| 670 | |
---|
[122] | 671 | %get the imabe nomenclature type if not defined by the input file nor by the xml file |
---|
| 672 | dirima=[];%default |
---|
[12] | 673 | if isempty(nom_type_ima) |
---|
| 674 | %look for double image series '_i_j' |
---|
| 675 | dirima=dir([filebase '_' num2str(first_i) '_' num2str(first_j) '.*']); |
---|
| 676 | if isempty(dirima) |
---|
[112] | 677 | % look for images series with sub marker '_' |
---|
| 678 | dirima=dir([filebase '_*' num2str(first_i) '.*']); |
---|
| 679 | if isempty(dirima) |
---|
| 680 | % look for other images series |
---|
| 681 | dirima=dir([filebase '*' num2str(first_i) '.*']); |
---|
[122] | 682 | if isempty(dirima) |
---|
| 683 | % look for other images series witth letter appendix |
---|
| 684 | appendix=char(96+first_j); |
---|
| 685 | dirima=dir([filebase '*' num2str(first_i) appendix '.*']); |
---|
[112] | 686 | end |
---|
| 687 | end |
---|
[12] | 688 | end |
---|
[112] | 689 | end |
---|
[122] | 690 | for ilist=1:numel(dirima) |
---|
| 691 | [pp,ff,fc,str2,str_a,str_b,ext_list,nom_type_list]=name2display(dirima(ilist).name); |
---|
| 692 | form=imformats(ext_list(2:end)); |
---|
| 693 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 694 | ext_ima=ext_list; |
---|
| 695 | nom_type_ima=nom_type_list; |
---|
| 696 | break |
---|
| 697 | end |
---|
| 698 | end |
---|
| 699 | % no image documentation file found: look for a series of existing files,images by priority or .nc files |
---|
| 700 | if isempty(nom_type_ima) |
---|
[128] | 701 | ext_search=ext_imadoc; |
---|
[122] | 702 | nom_type_search=nom_type_nc; |
---|
| 703 | else |
---|
| 704 | ext_search=ext_ima; |
---|
| 705 | nom_type_search=nom_type_ima; |
---|
| 706 | end |
---|
| 707 | if isempty(time) && ~strcmp(nom_type_search,'none') && ~strcmp(nom_type_search,'') && ~strcmp(nom_type_search,'*') |
---|
[12] | 708 | subdir=get(handles.subdir_civ1,'String'); |
---|
| 709 | incr_pair=[0 0];%default |
---|
| 710 | if isfield(browse,'incr_pair') |
---|
[112] | 711 | incr_pair=browse.incr_pair; |
---|
[12] | 712 | end |
---|
[112] | 713 | % nbdetect=0;%test of detected images |
---|
[122] | 714 | field_i=browse.num_i2; |
---|
[153] | 715 | imagename=name_generator(filebase,field_i,1,ext_search,nom_type_search); |
---|
| 716 | imagename_plus=''; |
---|
[12] | 717 | idetect=1; |
---|
[153] | 718 | while idetect %look for the maximum file number in the series |
---|
| 719 | imagename_plus=name_generator(filebase,field_i+1,1,ext_search,nom_type_search); |
---|
| 720 | idetect=(exist(imagename_plus,'file')==2)&& ~strcmp(imagename,imagename_plus); |
---|
[81] | 721 | if idetect |
---|
[12] | 722 | field_i=field_i+1; |
---|
[81] | 723 | end |
---|
[112] | 724 | %SEE CASE OF NETCDF FILES |
---|
| 725 | % nbdetect=nbdetect+(exist(imagename,'file')==2); |
---|
[12] | 726 | end |
---|
[122] | 727 | nbfield=field_i;% last detected field number |
---|
| 728 | field_i=browse.num_i1;%look for the minimum file number in the series |
---|
[153] | 729 | imagename_min=''; |
---|
[12] | 730 | idetect=1; |
---|
[112] | 731 | while idetect==1 |
---|
[153] | 732 | imagename_min=name_generator(filebase,field_i-1,1,ext_search,nom_type_search); |
---|
| 733 | idetect=(exist(imagename_min,'file')==2)&& ~strcmp(imagename,imagename_min); |
---|
[81] | 734 | if idetect |
---|
[112] | 735 | field_i=field_i-1; |
---|
[81] | 736 | end |
---|
[12] | 737 | end |
---|
[122] | 738 | first_i=max(field_i,1); |
---|
[273] | 739 | nom_type_search |
---|
[122] | 740 | if numel(regexp(nom_type_search,'\D'))>=1%two indices i and j |
---|
| 741 | field_i=browse.num_i1; |
---|
| 742 | field_j=browse.num_j2; |
---|
[177] | 743 | imagename=name_generator(filebase,field_i,field_j,ext_search,nom_type_search); |
---|
[153] | 744 | imagename_plus=''; |
---|
[89] | 745 | jdetect=1; |
---|
| 746 | while jdetect==1 %look for the maximum file number in the series |
---|
[153] | 747 | imagename_plus=name_generator(filebase,field_i,field_j+1,ext_search,nom_type_search); |
---|
| 748 | jdetect=(exist(imagename_plus,'file')==2)&& ~strcmp(imagename,imagename_plus); |
---|
[89] | 749 | if jdetect |
---|
| 750 | field_j=field_j+1; |
---|
| 751 | end |
---|
| 752 | %SEE CASE OF NETCDF FILES |
---|
| 753 | % nbdetect=nbdetect+(exist(imagename,'file')==2); |
---|
| 754 | end |
---|
[122] | 755 | nbfield2=field_j;% last detected field number |
---|
[120] | 756 | end |
---|
[122] | 757 | |
---|
[89] | 758 | %determine the set of times and possible intervals for CIV |
---|
[137] | 759 | % dt=(1/1000)*str2double(get(handles.dt,'String')); |
---|
[122] | 760 | time=(0:nbfield-1)';% time=file index -1 by default |
---|
| 761 | if numel(regexp(nom_type_search,'\D'))>=1%two indices i and j |
---|
| 762 | [x,y]=meshgrid(0:nbfield2-1,0:nbfield-1); |
---|
[120] | 763 | time=x+y; |
---|
[89] | 764 | end |
---|
[2] | 765 | end |
---|
[120] | 766 | |
---|
[2] | 767 | if exist('time','var') |
---|
| 768 | if size(time,1)+size(time,2)>=3 % if there are at least two time values to define dt |
---|
| 769 | nbfield=size(time,1); |
---|
| 770 | nbfield2=size(time,2); |
---|
[273] | 771 | set(handles.ImaDoc,'UserData',time); %store the set of times |
---|
[71] | 772 | set(handles.dt_unit,'String',['dt in m' TimeUnit]); |
---|
[273] | 773 | % set(handles.dt_unit_civ2,'String',['dt in m' TimeUnit]); |
---|
[71] | 774 | set(handles.TimeUnit,'String',TimeUnit); |
---|
[2] | 775 | set(handles.nb_field,'String',num2str(nbfield)); |
---|
| 776 | set(handles.nb_field2,'String',num2str(nbfield2)); |
---|
| 777 | end |
---|
| 778 | end |
---|
[71] | 779 | set(handles.CoordUnit,'String',CoordUnit) |
---|
[273] | 780 | set(handles.SearchRange,'UserData',[pxcmx_search pxcmy_search]); |
---|
[2] | 781 | % npxy=[npy npx]; |
---|
[71] | 782 | set(handles.ImaExt,'String',ext_ima) |
---|
[2] | 783 | set(handles.first_i,'String',num2str(first_i)); |
---|
| 784 | set(handles.last_i,'String',num2str(last_i));% |
---|
| 785 | set(handles.first_j,'String',num2str(first_j)); |
---|
| 786 | set(handles.last_j,'String',num2str(last_j));% |
---|
| 787 | browse.nom_type_ima=nom_type_ima; |
---|
[273] | 788 | set(handles.RootName,'UserData',browse)% store the nomenclature type |
---|
[2] | 789 | |
---|
[273] | 790 | %% set the menus of image pairs and default selection for civ %%%%%%%%%%%%%%%%%%% |
---|
[177] | 791 | test_ima_i=numel(nom_type_ima)>1 && isempty(regexp(nom_type_ima(2:end),'\D','once'));%images with single indexing |
---|
[122] | 792 | if test_ima_i || isequal(nom_type_nc,'_i1-i2')||~(exist('nbfield2','var')&&(nbfield2~=1)) |
---|
[273] | 793 | set(handles.CivMode,'Value',1) |
---|
| 794 | set(handles.CivMode,'String',{'series(Di)'}) |
---|
[2] | 795 | elseif (nbfield==1)% simple series in j |
---|
[273] | 796 | set(handles.CivMode,'Value',1) |
---|
| 797 | set(handles.CivMode,'String',{'series(Dj)'}) |
---|
[2] | 798 | else |
---|
[273] | 799 | set(handles.CivMode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice |
---|
[122] | 800 | if nbfield2 <= 10 |
---|
[273] | 801 | set(handles.CivMode,'Value',1)% advice 'pair j1-j2' for small burst |
---|
[2] | 802 | end |
---|
| 803 | end |
---|
| 804 | |
---|
| 805 | |
---|
[177] | 806 | %% desable status and RUN button |
---|
[2] | 807 | set(handles.RUN, 'Enable','On') |
---|
| 808 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
[122] | 809 | set(handles.BATCH,'Enable','On') |
---|
| 810 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
[178] | 811 | if isfield(handles,'status') |
---|
[177] | 812 | set(handles.status,'Value',0);%suppress status display |
---|
| 813 | status_Callback(hObject, eventdata, handles) |
---|
[178] | 814 | end |
---|
[112] | 815 | |
---|
[177] | 816 | %% store the root input filename for future opening |
---|
[2] | 817 | dir_perso=prefdir; |
---|
| 818 | profil_perso=fullfile(prefdir,'uvmat_perso.mat'); |
---|
| 819 | RootPath=fileparts(filebase); |
---|
| 820 | if exist(profil_perso,'file') |
---|
| 821 | save (profil_perso,'RootPath','-append'); %store the root name for future opening of uvmat |
---|
| 822 | else |
---|
[147] | 823 | txt=ver('MATLAB'); |
---|
| 824 | Release=txt.Release; |
---|
[137] | 825 | relnumb=str2double(Release(3:4)); |
---|
[2] | 826 | if relnumb >= 14 |
---|
[112] | 827 | save (profil_perso,'RootPath','-V6'); %store the root name for future opening of uvmat |
---|
[2] | 828 | else |
---|
| 829 | save (profil_perso,'RootPath'); %store the root name for future opening of uvmat |
---|
| 830 | end |
---|
| 831 | end |
---|
| 832 | |
---|
[273] | 833 | %% update the subdir |
---|
| 834 | pathdir=fileparts(filebase);%path to the current xml file |
---|
| 835 | listot=dir(pathdir); |
---|
| 836 | idir=0; |
---|
| 837 | listdir={''};%default |
---|
| 838 | for ilist=1:length(listot) |
---|
| 839 | if listot(ilist).isdir |
---|
| 840 | name=listot(ilist).name; |
---|
| 841 | if ~isequal(name,'.') && ~isequal(name,'..') |
---|
| 842 | idir=idir+1; |
---|
| 843 | listdir{idir,1}=listot(ilist).name; |
---|
| 844 | end |
---|
| 845 | end |
---|
| 846 | end |
---|
| 847 | set(handles.list_subdir_civ1,'Value',1) |
---|
| 848 | set(handles.list_subdir_civ2,'Value',1) |
---|
| 849 | set(handles.list_subdir_civ1,'String',[listdir;'new...']) |
---|
| 850 | set(handles.list_subdir_civ2,'String',[listdir;'new...']) |
---|
| 851 | if isempty(listdir) |
---|
| 852 | dirname=listdir{1}; |
---|
| 853 | else |
---|
| 854 | dirname='CIV'; %default civ directory name |
---|
| 855 | end |
---|
| 856 | set(handles.subdir_civ1,'String',dirname) |
---|
| 857 | set(handles.subdir_civ2,'String',dirname) |
---|
| 858 | %check wether the current subdir exists: |
---|
| 859 | % subdir_civ1=get(handles.subdir_civ1,'String'); |
---|
| 860 | % subdir_civ2=get(handles.subdir_civ2,'String'); |
---|
| 861 | |
---|
| 862 | CivMode_Callback(hObject, eventdata, handles) |
---|
| 863 | |
---|
[12] | 864 | %------------------------------------------------------------------------ |
---|
[273] | 865 | % --- Executes on button press in CivMode. |
---|
| 866 | function CivMode_Callback(hObject, eventdata, handles) |
---|
[12] | 867 | %------------------------------------------------------------------------ |
---|
[273] | 868 | browse=get(handles.RootName,'UserData'); |
---|
[2] | 869 | compare_list=get(handles.compare,'String'); |
---|
| 870 | val=get(handles.compare,'Value'); |
---|
| 871 | compare=compare_list{val}; |
---|
| 872 | if strcmp(compare,'displacement') |
---|
| 873 | mode='displacement'; |
---|
| 874 | else |
---|
[273] | 875 | mode_list=get(handles.CivMode,'String'); |
---|
[236] | 876 | if ischar(mode_list) |
---|
| 877 | mode_list={mode_list}; |
---|
| 878 | end |
---|
[273] | 879 | mode_value=get(handles.CivMode,'Value'); |
---|
[2] | 880 | mode=mode_list{mode_value}; |
---|
| 881 | end |
---|
| 882 | displ_num=[];%default |
---|
[137] | 883 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[2] | 884 | % last_i=str2num(get(handles.last_i,'String')); |
---|
[273] | 885 | time=get(handles.ImaDoc,'UserData'); %get the set of times |
---|
[2] | 886 | siztime=size(time); |
---|
| 887 | nbfield=siztime(1); |
---|
| 888 | nbfield2=siztime(2); |
---|
| 889 | indchosen=1; %%first pair selected by default |
---|
| 890 | if isequal(mode,'pair j1-j2')%| isequal(mode,'st_pair j1-j2') |
---|
| 891 | dt=1; |
---|
| 892 | displ=''; |
---|
| 893 | index=0; |
---|
| 894 | numlist_a=[]; |
---|
| 895 | numlist_B=[]; |
---|
| 896 | %get all the time intervals in bursts |
---|
| 897 | displ_dt=1;%default |
---|
| 898 | nbfield2=min(nbfield2,10);%limitate the number of pairs to 10x10 |
---|
| 899 | for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'pair j1-j2' mode |
---|
| 900 | for numod_b=(numod_a+1):nbfield2 |
---|
[112] | 901 | index=index+1; |
---|
| 902 | numlist_a(index)=numod_a; |
---|
| 903 | numlist_b(index)=numod_b; |
---|
| 904 | if ~isempty(time) |
---|
[54] | 905 | dt(numod_a,numod_b)=time(ref_i,numod_b)-time(ref_i,numod_a);%first time interval dt |
---|
[2] | 906 | displ_dt(index)=dt(numod_a,numod_b); |
---|
[112] | 907 | else |
---|
| 908 | displ_dt(index)=1; |
---|
| 909 | end |
---|
| 910 | end |
---|
| 911 | end |
---|
| 912 | [dtsort,indsort]=sort(displ_dt); |
---|
| 913 | if ~isempty(numlist_a) |
---|
| 914 | displ_num(1,:)=numlist_a(indsort); |
---|
| 915 | displ_num(2,:)=numlist_b(indsort); |
---|
| 916 | end |
---|
| 917 | displ_num(3,:)=0; |
---|
| 918 | displ_num(4,:)=0; |
---|
| 919 | set(handles.jtext,'Visible','Off') |
---|
[2] | 920 | set(handles.first_j,'Visible','Off') |
---|
| 921 | set(handles.last_j,'Visible','Off') |
---|
| 922 | set(handles.incr_j,'Visible','Off') |
---|
| 923 | set(handles.nb_field2,'Visible','Off') |
---|
| 924 | set(handles.ref_j,'Visible','Off') |
---|
| 925 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') |
---|
[112] | 926 | for index=1:min(nbfield2-1,200) |
---|
| 927 | displ_num(1,index)=-floor(index/2); |
---|
| 928 | displ_num(2,index)=ceil(index/2); |
---|
| 929 | displ_num(3,index)=0; |
---|
| 930 | displ_num(4,index)=0; |
---|
| 931 | end |
---|
| 932 | set(handles.jtext,'Visible','On') |
---|
| 933 | set(handles.first_j,'Visible','On') |
---|
| 934 | set(handles.last_j,'Visible','On') |
---|
| 935 | set(handles.incr_j,'Visible','On') |
---|
| 936 | set(handles.nb_field2,'Visible','On') |
---|
| 937 | set(handles.ref_j,'Visible','On') |
---|
| 938 | if nbfield > 1 |
---|
[2] | 939 | set(handles.itext,'Visible','On') |
---|
| 940 | set(handles.first_i,'Visible','On') |
---|
| 941 | set(handles.last_i,'Visible','On') |
---|
| 942 | set(handles.incr_i,'Visible','On') |
---|
| 943 | set(handles.nb_field,'Visible','On') |
---|
| 944 | set(handles.ref_i,'Visible','On') |
---|
| 945 | else |
---|
| 946 | set(handles.itext,'Visible','Off') |
---|
| 947 | set(handles.first_i,'Visible','Off') |
---|
| 948 | set(handles.last_i,'Visible','Off') |
---|
| 949 | set(handles.incr_i,'Visible','Off') |
---|
| 950 | set(handles.nb_field,'Visible','Off') |
---|
| 951 | set(handles.ref_i,'Visible','Off') |
---|
| 952 | end |
---|
[112] | 953 | elseif isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 954 | for index=1:200%min(nbfield-1,200) |
---|
| 955 | displ_num(1,index)=0; |
---|
| 956 | displ_num(2,index)=0; |
---|
| 957 | displ_num(3,index)=-floor(index/2); |
---|
| 958 | displ_num(4,index)=ceil(index/2); |
---|
| 959 | end |
---|
| 960 | set(handles.itext,'Visible','On') |
---|
| 961 | set(handles.first_i,'Visible','On') |
---|
| 962 | set(handles.last_i,'Visible','On') |
---|
| 963 | set(handles.incr_i,'Visible','On') |
---|
| 964 | set(handles.nb_field,'Visible','On') |
---|
| 965 | set(handles.ref_i,'Visible','On') |
---|
| 966 | if nbfield2 > 1 |
---|
[2] | 967 | set(handles.jtext,'Visible','On') |
---|
| 968 | set(handles.first_j,'Visible','On') |
---|
| 969 | set(handles.last_j,'Visible','On') |
---|
| 970 | set(handles.incr_j,'Visible','On') |
---|
| 971 | set(handles.nb_field2,'Visible','On') |
---|
| 972 | set(handles.ref_j,'Visible','On') |
---|
[112] | 973 | else |
---|
[2] | 974 | set(handles.jtext,'Visible','Off') |
---|
| 975 | set(handles.first_j,'Visible','Off') |
---|
| 976 | set(handles.last_j,'Visible','Off') |
---|
| 977 | set(handles.incr_j,'Visible','Off') |
---|
| 978 | set(handles.nb_field2,'Visible','Off') |
---|
| 979 | set(handles.ref_j,'Visible','Off') |
---|
| 980 | end |
---|
| 981 | elseif isequal(mode,'displacement')%the pairs have the same indices |
---|
[112] | 982 | displ_num(1,1)=0; |
---|
| 983 | displ_num(2,1)=0; |
---|
| 984 | displ_num(3,1)=0; |
---|
| 985 | displ_num(4,1)=0; |
---|
| 986 | if nbfield > 1 |
---|
[2] | 987 | set(handles.itext,'Visible','On') |
---|
| 988 | set(handles.first_i,'Visible','On') |
---|
| 989 | set(handles.last_i,'Visible','On') |
---|
| 990 | set(handles.incr_i,'Visible','On') |
---|
| 991 | set(handles.nb_field,'Visible','On') |
---|
| 992 | set(handles.ref_i,'Visible','On') |
---|
| 993 | else |
---|
| 994 | set(handles.itext,'Visible','Off') |
---|
| 995 | set(handles.first_i,'Visible','Off') |
---|
| 996 | set(handles.last_i,'Visible','Off') |
---|
| 997 | set(handles.incr_i,'Visible','Off') |
---|
| 998 | set(handles.nb_field,'Visible','Off') |
---|
| 999 | set(handles.ref_i,'Visible','Off') |
---|
| 1000 | end |
---|
| 1001 | if nbfield2 > 1 |
---|
[112] | 1002 | set(handles.jtext,'Visible','On') |
---|
| 1003 | set(handles.first_j,'Visible','On') |
---|
| 1004 | set(handles.last_j,'Visible','On') |
---|
| 1005 | set(handles.incr_j,'Visible','On') |
---|
| 1006 | set(handles.nb_field2,'Visible','On') |
---|
| 1007 | set(handles.ref_j,'Visible','On') |
---|
[2] | 1008 | else |
---|
| 1009 | set(handles.jtext,'Visible','Off') |
---|
| 1010 | set(handles.first_j,'Visible','Off') |
---|
| 1011 | set(handles.last_j,'Visible','Off') |
---|
| 1012 | set(handles.incr_j,'Visible','Off') |
---|
| 1013 | set(handles.nb_field2,'Visible','Off') |
---|
| 1014 | set(handles.ref_j,'Visible','Off') |
---|
| 1015 | end |
---|
[112] | 1016 | end |
---|
[2] | 1017 | set(handles.list_pair_civ1,'UserData',displ_num); |
---|
| 1018 | find_netcpair_civ1(hObject, eventdata, handles) |
---|
| 1019 | find_netcpair_civ2(hObject, eventdata, handles) |
---|
| 1020 | |
---|
[12] | 1021 | %------------------------------------------------------------------------ |
---|
[2] | 1022 | % determine the menu for civ1 pairs depending on existing netcdf file at the middle of |
---|
| 1023 | % the field series set by first_i, incr, last_i |
---|
| 1024 | function find_netcpair_civ1(hObject, eventdata, handles) |
---|
[12] | 1025 | %------------------------------------------------------------------------ |
---|
[2] | 1026 | set(gcf,'Pointer','watch') |
---|
| 1027 | %nomenclature types |
---|
[273] | 1028 | 'TESTpair' |
---|
[71] | 1029 | filebase=get(handles.RootName,'String'); |
---|
[2] | 1030 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
[273] | 1031 | browse=get(handles.RootName,'UserData'); |
---|
[2] | 1032 | compare_list=get(handles.compare,'String'); |
---|
| 1033 | val=get(handles.compare,'Value'); |
---|
| 1034 | compare=compare_list{val}; |
---|
| 1035 | if strcmp(compare,'displacement') |
---|
| 1036 | mode='displacement'; |
---|
| 1037 | else |
---|
[273] | 1038 | mode_list=get(handles.CivMode,'String'); |
---|
| 1039 | mode_value=get(handles.CivMode,'Value'); |
---|
| 1040 | if isempty(mode_list) |
---|
| 1041 | return |
---|
| 1042 | end |
---|
[2] | 1043 | mode=mode_list{mode_value}; |
---|
| 1044 | end |
---|
| 1045 | |
---|
| 1046 | % nomenclature type of the .nc files |
---|
| 1047 | nom_type_ima=[];%default |
---|
| 1048 | if isfield(browse,'nom_type_ima') |
---|
| 1049 | nom_type_ima=browse.nom_type_ima; |
---|
| 1050 | end |
---|
| 1051 | |
---|
[112] | 1052 | %determine nom_type_nc: |
---|
[2] | 1053 | nom_type_nc=[];%default |
---|
| 1054 | if isfield(browse,'nom_type_nc') |
---|
| 1055 | nom_type_nc=browse.nom_type_nc; |
---|
| 1056 | end |
---|
| 1057 | if isempty(nom_type_nc) |
---|
[112] | 1058 | [nom_type_nc]=nomtype2pair(nom_type_ima,isequal(mode,'series(Di)'),isequal(mode,'series(Dj)')); |
---|
[2] | 1059 | end |
---|
| 1060 | browse.nom_type_nc=nom_type_nc; |
---|
[273] | 1061 | set(handles.RootName,'UserData',browse) |
---|
[2] | 1062 | |
---|
| 1063 | %reads .nc subdirectoy and image numbers from the interface |
---|
| 1064 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
[45] | 1065 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[2] | 1066 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
| 1067 | ref_j=0; |
---|
| 1068 | else |
---|
[45] | 1069 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
[2] | 1070 | end |
---|
[273] | 1071 | time=get(handles.ImaDoc,'UserData');%get the set of times |
---|
[2] | 1072 | if isempty(time) |
---|
| 1073 | time=[0 1]; |
---|
[112] | 1074 | end |
---|
[71] | 1075 | dt_unit=1000;%default |
---|
[2] | 1076 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 1077 | |
---|
[112] | 1078 | %eliminate the first pairs inconsistent with the position |
---|
| 1079 | if isempty(displ_num) |
---|
| 1080 | nbpair=0; |
---|
| 1081 | else |
---|
[2] | 1082 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
| 1083 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 1084 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1085 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 1086 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1087 | end |
---|
[112] | 1088 | end |
---|
[2] | 1089 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
| 1090 | |
---|
[112] | 1091 | %look for existing processed pairs involving the field at the middle of the series if civ1 will not |
---|
[2] | 1092 | % be performed, while the result is needed for next steps. |
---|
| 1093 | displ_pair={''}; |
---|
[273] | 1094 | select=ones(size(1:nbpair));%flag for displayed pairs =1 for display |
---|
[2] | 1095 | testpair=0; |
---|
[273] | 1096 | % case with no civ1 operation, netcdf files need to exist for reading |
---|
[2] | 1097 | if get(handles.CIV1,'Value')==0 % |
---|
[112] | 1098 | if ~exist(fullfile(filepath,subdir_civ1,ext_dir),'dir') |
---|
| 1099 | msgbox_uvmat('ERROR',['no civ1 file available: subdirectory ' subdir_civ1 ' does not exist']); |
---|
| 1100 | set(handles.list_pair_civ1,'String',{}); |
---|
| 1101 | return |
---|
[2] | 1102 | end |
---|
[112] | 1103 | for ipair=1:nbpair |
---|
[2] | 1104 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
[112] | 1105 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
[273] | 1106 | select(ipair)=exist(filename,'file')==2;% put flag to 0 if the file does not exist |
---|
| 1107 | end |
---|
| 1108 | % case of no displayed pair |
---|
| 1109 | if isequal(select,zeros(size(1:nbpair))) |
---|
| 1110 | 'TESTzero' |
---|
| 1111 | browse |
---|
| 1112 | if isfield(browse,'incr_pair') && ~isequal(browse.incr_pair,[0 0]) |
---|
[2] | 1113 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
| 1114 | num_i2=ref_i+ceil(browse.incr_pair(1)/2); |
---|
| 1115 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
| 1116 | num_j2=ref_j+ceil(browse.incr_pair(2)/2); |
---|
| 1117 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ1); |
---|
| 1118 | select(1)=exist(filename,'file')==2; |
---|
| 1119 | testpair=1; |
---|
| 1120 | else |
---|
[112] | 1121 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
[2] | 1122 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1]); |
---|
| 1123 | else |
---|
| 1124 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ1]); |
---|
| 1125 | end |
---|
[112] | 1126 | set(handles.list_pair_civ1,'String',{''}); |
---|
| 1127 | %COMPLETER CAS STEREO |
---|
[2] | 1128 | return |
---|
| 1129 | end |
---|
| 1130 | end |
---|
| 1131 | end |
---|
| 1132 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 1133 | if testpair |
---|
[73] | 1134 | displ_pair{1}=['Di= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
[2] | 1135 | else |
---|
[73] | 1136 | for ipair=1:nbpair |
---|
| 1137 | if select(ipair) |
---|
| 1138 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1139 | 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 |
---|
| 1140 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1141 | else |
---|
| 1142 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1143 | end |
---|
| 1144 | end |
---|
| 1145 | end |
---|
[2] | 1146 | end |
---|
| 1147 | elseif isequal(mode,'series(Dj)')%|isequal(mode,'st_series(Dj)')% series on the j index |
---|
| 1148 | if testpair |
---|
[112] | 1149 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
[2] | 1150 | else |
---|
[112] | 1151 | for ipair=1:nbpair |
---|
| 1152 | if select(ipair) |
---|
| 1153 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1154 | 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 |
---|
| 1155 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1156 | end |
---|
| 1157 | elseif testpair |
---|
| 1158 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(2)/2)) '|' num2str(ceil(browse.incr_pair(2)/2))]; |
---|
| 1159 | else |
---|
| 1160 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1161 | end |
---|
| 1162 | end |
---|
| 1163 | end |
---|
[2] | 1164 | elseif isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2')%case of pairs |
---|
| 1165 | for ipair=1:nbpair |
---|
| 1166 | if select(ipair) |
---|
[112] | 1167 | 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 |
---|
| 1168 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
| 1169 | ' :dt= ' num2str(dt*1000)]; |
---|
| 1170 | else |
---|
| 1171 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1172 | end |
---|
| 1173 | end |
---|
[2] | 1174 | elseif isequal(mode,'displacement') |
---|
[112] | 1175 | displ_pair={'Di=Dj=0'}; |
---|
| 1176 | end |
---|
[2] | 1177 | set(handles.list_pair_civ1,'String',displ_pair'); |
---|
[229] | 1178 | ichoice=find(select,1); |
---|
[45] | 1179 | if (isempty(ichoice) || ichoice < 1); ichoice=1; end; |
---|
| 1180 | initial=get(handles.list_pair_civ1,'Value');%initial choice of pair |
---|
[112] | 1181 | if initial>nbpair |
---|
| 1182 | set(handles.list_pair_civ1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
[45] | 1183 | end |
---|
| 1184 | if numel(select)>=initial && ~isequal(select(initial),1) |
---|
[2] | 1185 | set(handles.list_pair_civ1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
| 1186 | end |
---|
[45] | 1187 | |
---|
[2] | 1188 | %set(handles.list_pair_civ2,'String',displ_pair'); |
---|
| 1189 | initial=get(handles.list_pair_civ2,'Value'); |
---|
| 1190 | if initial>length(displ_pair')%|~isequal(select(initial),1) |
---|
| 1191 | if ichoice <= length(displ_pair') |
---|
| 1192 | set(handles.list_pair_civ2,'Value',ichoice);% same pair proposed by default for civ2 |
---|
| 1193 | else |
---|
| 1194 | set(handles.list_pair_civ2,'Value',1);% same pair proposed by default for civ2 |
---|
| 1195 | end |
---|
| 1196 | end |
---|
| 1197 | set(handles.list_pair_civ2,'String',displ_pair'); |
---|
| 1198 | set(gcf,'Pointer','arrow') |
---|
[12] | 1199 | |
---|
| 1200 | %------------------------------------------------------------------------ |
---|
[112] | 1201 | % determine the menu for civ2 pairs depending on the existing netcdf file at the |
---|
| 1202 | %middle of the series set by first_i, incr, last_i |
---|
[2] | 1203 | function find_netcpair_civ2(hObject, eventdata, handles) |
---|
[12] | 1204 | %------------------------------------------------------------------------ |
---|
[2] | 1205 | set(gcf,'Pointer','watch') |
---|
| 1206 | %nomenclature types |
---|
[71] | 1207 | filebase=get(handles.RootName,'String'); |
---|
[2] | 1208 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
[273] | 1209 | browse=get(handles.RootName,'UserData'); |
---|
[2] | 1210 | compare_list=get(handles.compare,'String'); |
---|
| 1211 | val=get(handles.compare,'Value'); |
---|
| 1212 | compare=compare_list{val}; |
---|
| 1213 | if strcmp(compare,'displacement') |
---|
| 1214 | mode='displacement'; |
---|
| 1215 | else |
---|
[273] | 1216 | mode_list=get(handles.CivMode,'String') |
---|
[270] | 1217 | if isempty(mode_list) |
---|
| 1218 | msgbox_uvmat('ERROR','please enter an input image or netcdf file') |
---|
| 1219 | return |
---|
| 1220 | end |
---|
[273] | 1221 | mode_value=get(handles.CivMode,'Value') |
---|
[2] | 1222 | mode=mode_list{mode_value}; |
---|
| 1223 | end |
---|
| 1224 | |
---|
| 1225 | % nomenclature type of the .nc files |
---|
| 1226 | nom_type_ima='ima_num';%default |
---|
| 1227 | if isfield(browse,'nom_type_ima') |
---|
| 1228 | nom_type_ima=browse.nom_type_ima; |
---|
| 1229 | end |
---|
| 1230 | nom_type_nc='_i1-i2';%default |
---|
| 1231 | if isfield(browse,'nom_type_nc') |
---|
| 1232 | nom_type_nc=browse.nom_type_nc; |
---|
| 1233 | end |
---|
[94] | 1234 | 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') |
---|
[2] | 1235 | nom_type_nc='netc_old';%nom_type for the netcdf files |
---|
[94] | 1236 | elseif isequal(nom_type_ima,'none')||isequal(nom_type_nc,'none') |
---|
[2] | 1237 | nom_type_nc='none'; |
---|
[94] | 1238 | elseif isequal(nom_type_ima,'avi')||isequal(nom_type_ima,'_i')||isequal(nom_type_ima,'ima_num')||isequal(nom_type_nc,'_i1-i2') |
---|
[112] | 1239 | nom_type_nc='_i1-i2'; |
---|
[2] | 1240 | else |
---|
| 1241 | if isequal(mode,'series(Di)')%|isequal(mode,'st_series(Di)') |
---|
| 1242 | nom_type_nc='_i1-i2_j'; % PIV in volume |
---|
| 1243 | else |
---|
| 1244 | nom_type_nc='_i_j1-j2'; |
---|
[112] | 1245 | end |
---|
[2] | 1246 | end |
---|
| 1247 | browse.nom_type_nc=nom_type_nc; |
---|
[273] | 1248 | set(handles.RootName,'UserData',browse) |
---|
[2] | 1249 | |
---|
| 1250 | %reads .nc subdirectory and image numbers from the interface |
---|
| 1251 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
| 1252 | subdir_civ2=get(handles.subdir_civ2,'String');%subdirectory subdir_civ2 for the netcdf data |
---|
[45] | 1253 | % first_i=str2num(get(handles.first_i,'String')); |
---|
| 1254 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 1255 | % incr=str2num(get(handles.incr_i,'String')); |
---|
| 1256 | % num1=first_i:incr:last_i; |
---|
| 1257 | % if isempty(num1) |
---|
| 1258 | % set(handles.list_pair_civ2,'Value',1); |
---|
| 1259 | % set(handles.list_pair_civ2,'String',{''}); |
---|
| 1260 | % return |
---|
| 1261 | % end |
---|
[273] | 1262 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[2] | 1263 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
| 1264 | ref_j=0; |
---|
| 1265 | else |
---|
[273] | 1266 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
[2] | 1267 | end |
---|
[273] | 1268 | time=get(handles.ImaDoc,'UserData'); %get the set of times |
---|
[2] | 1269 | if isempty(time) |
---|
| 1270 | time=[0 1];%default |
---|
| 1271 | end |
---|
[71] | 1272 | %dt_unit=str2num(get(handles.dt,'String'));% used when there is no image documentation file |
---|
[73] | 1273 | %dt_unit=1000; |
---|
[2] | 1274 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 1275 | |
---|
| 1276 | |
---|
[112] | 1277 | %eliminate the first pairs inconsistent with the position |
---|
[2] | 1278 | if isempty(displ_num) |
---|
| 1279 | nbpair=0; |
---|
| 1280 | else |
---|
| 1281 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
[112] | 1282 | if isequal(mode,'series(Di)')% | isequal(mode,'st_series(Di)') |
---|
[2] | 1283 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
[112] | 1284 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
[2] | 1285 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1286 | end |
---|
| 1287 | end |
---|
| 1288 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
| 1289 | |
---|
[112] | 1290 | %look for existing processed pairs involving the field at the middle of the series if civ1 will not |
---|
[2] | 1291 | % be performed, while the result is needed for next steps. |
---|
| 1292 | displ_pair={''}; %default |
---|
| 1293 | select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs |
---|
| 1294 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0%&... |
---|
[112] | 1295 | if ~exist(fullfile(filepath,subdir_civ2,ext_dir),'dir') |
---|
| 1296 | errordlg(['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist']) |
---|
| 1297 | set(handles.list_pair_civ2,'Value',1); |
---|
| 1298 | set(handles.list_pair_civ2,'String',{''}); |
---|
| 1299 | return |
---|
[2] | 1300 | end |
---|
[112] | 1301 | for ipair=1:nbpair |
---|
[2] | 1302 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
[112] | 1303 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
[2] | 1304 | select(ipair)=exist(filename,'file')==2; |
---|
| 1305 | end |
---|
| 1306 | if isequal(select,zeros(size(1:nbpair))) |
---|
[112] | 1307 | if isfield(browse,'incr_pair') |
---|
[2] | 1308 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
| 1309 | num_i2=ref_i+floor((browse.incr_pair(1)+1)/2); |
---|
| 1310 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
| 1311 | num_j2=ref_j+floor((browse.incr_pair(2)+1)/2); |
---|
| 1312 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ2); |
---|
| 1313 | select(1)=exist(filename,'file')==2; |
---|
| 1314 | else |
---|
[112] | 1315 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
[2] | 1316 | errordlg(['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2]) |
---|
| 1317 | else |
---|
| 1318 | errordlg(['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2]) |
---|
| 1319 | end |
---|
[112] | 1320 | set(handles.list_pair_civ2,'Value',1); |
---|
| 1321 | set(handles.list_pair_civ2,'String',{''}); |
---|
[2] | 1322 | return |
---|
| 1323 | end |
---|
| 1324 | end |
---|
| 1325 | end |
---|
[112] | 1326 | if isequal(mode,'series(Di)') % | isequal(mode,'st_series(Di)') |
---|
| 1327 | for ipair=1:nbpair |
---|
| 1328 | if select(ipair) |
---|
| 1329 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
[2] | 1330 | 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 |
---|
| 1331 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
[112] | 1332 | end |
---|
| 1333 | else |
---|
| 1334 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1335 | end |
---|
| 1336 | end |
---|
[2] | 1337 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') % series on the j index |
---|
[112] | 1338 | for ipair=1:nbpair |
---|
| 1339 | if select(ipair) |
---|
| 1340 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1341 | 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 |
---|
| 1342 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1343 | end |
---|
| 1344 | else |
---|
| 1345 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1346 | end |
---|
| 1347 | end |
---|
[2] | 1348 | elseif isequal(mode,'pair j1-j2')% | isequal(mode,'st_pair j1-j2') %case of pairs |
---|
| 1349 | for ipair=1:nbpair |
---|
| 1350 | if select(ipair) |
---|
[112] | 1351 | 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 |
---|
| 1352 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
| 1353 | ' :dt= ' num2str(dt*1000)]; |
---|
| 1354 | else |
---|
| 1355 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1356 | end |
---|
| 1357 | end |
---|
[2] | 1358 | elseif isequal(mode,'displacement') |
---|
[112] | 1359 | displ_pair={'Di=Dj=0'}; |
---|
| 1360 | end |
---|
[2] | 1361 | val=get(handles.list_pair_civ2,'Value'); |
---|
[229] | 1362 | ichoice=find(select,1); |
---|
[137] | 1363 | if (isempty(ichoice) || ichoice < 1); ichoice=1; end; |
---|
| 1364 | if get(handles.CIV2,'Value')==0 && get(handles.CIV1,'Value')==0 && get(handles.FIX1,'Value')==0 && get(handles.PATCH1,'Value')==0 |
---|
[2] | 1365 | val=ichoice;% first valid pair proposed by default in the menu |
---|
| 1366 | end |
---|
| 1367 | if val>length(displ_pair') |
---|
| 1368 | set(handles.list_pair_civ2,'Value',1);% first valid pair proposed by default in the menu |
---|
| 1369 | else |
---|
| 1370 | set(handles.list_pair_civ2,'Value',val); |
---|
| 1371 | end |
---|
| 1372 | set(handles.list_pair_civ2,'String',displ_pair'); |
---|
[12] | 1373 | set(gcf,'Pointer','arrow') |
---|
[2] | 1374 | |
---|
| 1375 | |
---|
[41] | 1376 | |
---|
[227] | 1377 | |
---|
[12] | 1378 | %------------------------------------------------------------------------ |
---|
[2] | 1379 | % --- Executes on selection change in list_pair_civ1. |
---|
| 1380 | function list_pair_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 1381 | %------------------------------------------------------------------------ |
---|
[2] | 1382 | %reproduce by default the chosen pair in the civ2 menu |
---|
| 1383 | list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs |
---|
| 1384 | index_pair=get(handles.list_pair_civ1,'Value'); |
---|
| 1385 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
[137] | 1386 | % num_a=displ_num(1,index_pair); |
---|
| 1387 | % num_b=displ_num(2,index_pair); |
---|
[2] | 1388 | list_pair2=get(handles.list_pair_civ2,'String');%get the menu of image pairs |
---|
| 1389 | if index_pair<=length(list_pair2) |
---|
| 1390 | set(handles.list_pair_civ2,'Value',index_pair); |
---|
| 1391 | end |
---|
| 1392 | |
---|
[112] | 1393 | %update first_i and last_i according to the chosen image pairs |
---|
[273] | 1394 | mode_list=get(handles.CivMode,'String'); |
---|
| 1395 | mode_value=get(handles.CivMode,'Value'); |
---|
[2] | 1396 | mode=mode_list{mode_value}; |
---|
| 1397 | if isequal(mode,'series(Di)') |
---|
[137] | 1398 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 1399 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 1400 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
[2] | 1401 | num1=first_i:incr_i:last_i; |
---|
[137] | 1402 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 1403 | if ~isnan(lastfield) |
---|
[229] | 1404 | test_find=(num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
| 1405 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield); |
---|
| 1406 | num1=num1(test_find); |
---|
[2] | 1407 | end |
---|
| 1408 | set(handles.first_i,'String',num2str(num1(1))); |
---|
| 1409 | set(handles.last_i,'String',num2str(num1(end))); |
---|
| 1410 | elseif isequal(mode,'series(Dj)') |
---|
[137] | 1411 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 1412 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 1413 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[2] | 1414 | num_j=first_j:incr_j:last_j; |
---|
[137] | 1415 | lastfield2=str2double(get(handles.nb_field2,'String')); |
---|
| 1416 | if ~isnan(lastfield2) |
---|
[229] | 1417 | test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 1418 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2); |
---|
| 1419 | num1=num_j(test_find); |
---|
[2] | 1420 | end |
---|
| 1421 | set(handles.first_j,'String',num2str(num1(1))); |
---|
| 1422 | set(handles.last_j,'String',num2str(num1(end))); |
---|
[112] | 1423 | end |
---|
[2] | 1424 | |
---|
[12] | 1425 | %------------------------------------------------------------------------ |
---|
[2] | 1426 | % --- Executes on selection change in list_pair_civ2. |
---|
| 1427 | function list_pair_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 1428 | %------------------------------------------------------------------------ |
---|
[112] | 1429 | index_pair=get(handles.list_pair_civ2,'Value');%get the selected position index in the menu |
---|
[2] | 1430 | |
---|
[112] | 1431 | %update first_i and last_i according to the chosen image pairs |
---|
[273] | 1432 | mode_list=get(handles.CivMode,'String'); |
---|
| 1433 | mode_value=get(handles.CivMode,'Value'); |
---|
[2] | 1434 | mode=mode_list{mode_value}; |
---|
| 1435 | if isequal(mode,'series(Di)') |
---|
[137] | 1436 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 1437 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 1438 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
[2] | 1439 | num1=first_i:incr_i:last_i; |
---|
[137] | 1440 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 1441 | if ~isnan(lastfield) |
---|
[229] | 1442 | test_find=(num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
| 1443 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield); |
---|
| 1444 | num1=num1(test_find); |
---|
[2] | 1445 | end |
---|
| 1446 | set(handles.first_i,'String',num2str(num1(1))); |
---|
| 1447 | set(handles.last_i,'String',num2str(num1(end))); |
---|
| 1448 | elseif isequal(mode,'series(Dj)') |
---|
[137] | 1449 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 1450 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 1451 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[2] | 1452 | num_j=first_j:incr_j:last_j; |
---|
[137] | 1453 | lastfield2=str2double(get(handles.nb_field2,'String')); |
---|
| 1454 | if ~isnan(lastfield2) |
---|
[229] | 1455 | test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 1456 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2); |
---|
| 1457 | num1=num_j(test_find); |
---|
[2] | 1458 | end |
---|
| 1459 | set(handles.first_j,'String',num2str(num1(1))); |
---|
| 1460 | set(handles.last_j,'String',num2str(num1(end))); |
---|
[112] | 1461 | end |
---|
[2] | 1462 | |
---|
[177] | 1463 | %------------------------------------------------------------------------ |
---|
| 1464 | % --- Executes on button press in RUN: processing on local computer |
---|
[67] | 1465 | function RUN_Callback(hObject, eventdata, handles) |
---|
| 1466 | %------------------------------------------------------------------------ |
---|
[73] | 1467 | set(handles.RUN, 'Enable','Off') |
---|
| 1468 | set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[67] | 1469 | batch=0; |
---|
[229] | 1470 | errormsg=launch_jobs(hObject, eventdata, handles,batch); |
---|
[73] | 1471 | set(handles.RUN, 'Enable','On') |
---|
| 1472 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
[36] | 1473 | |
---|
[177] | 1474 | % start status callback to visualise results |
---|
[229] | 1475 | if ~isempty(errormsg) |
---|
| 1476 | display(errormsg) |
---|
| 1477 | msgbox_uvmat('ERROR',errormsg) |
---|
[257] | 1478 | elseif isfield(handles,'status') %&& ~isequal(get(handles.CivMode,'Value'),3) |
---|
[225] | 1479 | set(handles.status,'Value',1);%suppress status display |
---|
| 1480 | status_Callback(hObject, eventdata, handles) |
---|
[178] | 1481 | end |
---|
[177] | 1482 | |
---|
[12] | 1483 | %------------------------------------------------------------------------ |
---|
[2] | 1484 | % --- Executes on button press in BATCH: remote processing |
---|
| 1485 | function BATCH_Callback(hObject, eventdata, handles) |
---|
[177] | 1486 | % ----------------------------------------------------------------------- |
---|
[73] | 1487 | set(handles.BATCH, 'Enable','Off') |
---|
| 1488 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[67] | 1489 | batch=1; |
---|
[229] | 1490 | errormsg=launch_jobs(hObject, eventdata, handles, batch); |
---|
[73] | 1491 | set(handles.BATCH, 'Enable','On') |
---|
| 1492 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
[67] | 1493 | |
---|
[177] | 1494 | % start status callback to visualise results |
---|
[229] | 1495 | if ~isempty(errormsg) |
---|
| 1496 | display(errormsg) |
---|
| 1497 | msgbox_uvmat('ERROR',errormsg) |
---|
| 1498 | elseif isfield(handles,'status') |
---|
| 1499 | set(handles.status,'Value',1);%suppress status display |
---|
| 1500 | status_Callback(hObject, eventdata, handles) |
---|
[178] | 1501 | end |
---|
[227] | 1502 | |
---|
[67] | 1503 | %------------------------------------------------------------------------ |
---|
[133] | 1504 | % --- Lauch command called by RUN and BATCH: remote processing |
---|
[229] | 1505 | function errormsg=launch_jobs(hObject, eventdata, handles, batch) |
---|
[67] | 1506 | %----------------------------------------------------------------------- |
---|
[229] | 1507 | errormsg='';%default |
---|
[272] | 1508 | |
---|
| 1509 | |
---|
[133] | 1510 | %% check the selected list of operations: |
---|
[2] | 1511 | operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'}; |
---|
| 1512 | box_test(1)=get(handles.CIV1,'Value'); |
---|
| 1513 | box_test(2)=get(handles.FIX1,'Value'); |
---|
| 1514 | box_test(3)=get(handles.PATCH1,'Value'); |
---|
| 1515 | box_test(4)=get(handles.CIV2,'Value'); |
---|
| 1516 | box_test(5)=get(handles.FIX2,'Value'); |
---|
| 1517 | box_test(6)=get(handles.PATCH2,'Value'); |
---|
[180] | 1518 | index_first=find(box_test==1,1); |
---|
| 1519 | if isempty(index_first) |
---|
[229] | 1520 | errormsg='no selected operation'; |
---|
[2] | 1521 | return |
---|
| 1522 | end |
---|
[180] | 1523 | index_last=find(box_test==1,1,'last'); |
---|
[159] | 1524 | box_used=box_test(index_first : index_last); |
---|
[2] | 1525 | [box_missing,ind_missing]=min(box_used); |
---|
[180] | 1526 | if isequal(box_missing,0); %there is a missing step in the sequence of operations |
---|
[229] | 1527 | errormsg=['missing' cell2mat(operations(ind_missing))]; |
---|
[2] | 1528 | return |
---|
| 1529 | end |
---|
| 1530 | |
---|
[272] | 1531 | %% check mask if selecetd |
---|
| 1532 | %could be included in get_mask callback ? |
---|
[2] | 1533 | if isequal(get(handles.get_mask_civ1,'Value'),1) |
---|
[12] | 1534 | maskname=get(handles.mask_civ1,'String'); |
---|
| 1535 | if ~exist(maskname,'file') |
---|
| 1536 | get_mask_civ1_Callback(hObject, eventdata, handles); |
---|
| 1537 | end |
---|
[2] | 1538 | end |
---|
| 1539 | if isequal(get(handles.get_mask_fix1,'Value'),1) |
---|
[12] | 1540 | maskname=get(handles.mask_fix1,'String'); |
---|
| 1541 | if ~exist(maskname,'file') |
---|
| 1542 | get_mask_fix1_Callback(hObject, eventdata, handles); |
---|
| 1543 | end |
---|
[2] | 1544 | end |
---|
| 1545 | if isequal(get(handles.get_mask_civ2,'Value'),1) |
---|
[12] | 1546 | maskname=get(handles.mask_civ2,'String'); |
---|
| 1547 | if ~exist(maskname,'file') |
---|
[112] | 1548 | get_mask_civ2_Callback(hObject, eventdata, handles); |
---|
[12] | 1549 | end |
---|
[2] | 1550 | end |
---|
| 1551 | if isequal(get(handles.get_mask_fix2,'Value'),1) |
---|
[12] | 1552 | maskname=get(handles.mask_fix2,'String'); |
---|
| 1553 | if ~exist(maskname,'file') |
---|
[112] | 1554 | get_mask_fix2_Callback(hObject, eventdata, handles); |
---|
[12] | 1555 | end |
---|
[2] | 1556 | end |
---|
| 1557 | |
---|
[177] | 1558 | %% reinitialise status callback |
---|
[178] | 1559 | if isfield(handles,'status') |
---|
[180] | 1560 | set(handles.status,'Value',0);%suppress status display |
---|
| 1561 | status_Callback(hObject, eventdata, handles) |
---|
[178] | 1562 | end |
---|
[133] | 1563 | |
---|
| 1564 | %% set the list of files and check them |
---|
| 1565 | display('checking the files...') |
---|
[227] | 1566 | [ref_i,ref_j,errormsg]=find_ref_indices(handles); |
---|
| 1567 | if ~isempty(errormsg) |
---|
| 1568 | return |
---|
| 1569 | end |
---|
[263] | 1570 | [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc,xx,yy,compare]=... |
---|
[273] | 1571 | set_civ_filenames(handles,ref_i,ref_j,box_test); |
---|
[274] | 1572 | % ADDED |
---|
| 1573 | [Rootbat,Filebat]=fileparts(filecell.nc.civ1{1,1});%output netcdf file (without extention) |
---|
| 1574 | %ADDED |
---|
[177] | 1575 | set(handles.civ,'UserData',filecell);%store for futur use of status callback |
---|
[137] | 1576 | if isempty(filecell)% (error message displayed in fct set_civ_filenames) |
---|
[133] | 1577 | return |
---|
| 1578 | end |
---|
| 1579 | nbfield=numel(num1_civ1); |
---|
| 1580 | nbslice=numel(num_a_civ1); |
---|
| 1581 | |
---|
[272] | 1582 | %% read the PARAM.xml file to get the binaries (and batch_mode if batch) |
---|
[133] | 1583 | path_UVMAT=fileparts(which('uvmat')); %path to the source directory of uvmat |
---|
[112] | 1584 | xmlfile='PARAM.xml'; |
---|
[133] | 1585 | if exist(xmlfile,'file')% search parameter xml file in the whole matlab path |
---|
[54] | 1586 | t=xmltree(xmlfile); |
---|
[67] | 1587 | s=convert(t); |
---|
[272] | 1588 | else |
---|
| 1589 | errormsg=['no file ' xmlfile]; |
---|
| 1590 | return |
---|
[2] | 1591 | end |
---|
[272] | 1592 | |
---|
| 1593 | test_interp=0; %eviter les variables test_ (LG) |
---|
| 1594 | |
---|
[127] | 1595 | if batch |
---|
[67] | 1596 | if isfield(s,'BatchParam') |
---|
[272] | 1597 | param.global=s.BatchParam; |
---|
| 1598 | if isfield(param.global,'BatchMode') |
---|
| 1599 | batch_mode=param.global.BatchMode; |
---|
[257] | 1600 | if ~ismember(batch_mode,{'sge','oar'}) |
---|
| 1601 | errormsg=['batch mode ' batch_mode ' not supported by UVMAT']; |
---|
| 1602 | return |
---|
| 1603 | end |
---|
[67] | 1604 | end |
---|
| 1605 | else |
---|
[229] | 1606 | errormsg='no batch civ binaries defined in PARAM.xml'; |
---|
[67] | 1607 | return |
---|
| 1608 | end |
---|
[257] | 1609 | else % run |
---|
[67] | 1610 | if isfield(s,'RunParam') |
---|
[272] | 1611 | param.global=s.RunParam; |
---|
[67] | 1612 | else |
---|
[225] | 1613 | msgbox_uvmat('ERROR','no run civ binaries defined in PARAM.xml') |
---|
[67] | 1614 | return |
---|
| 1615 | end |
---|
[225] | 1616 | end |
---|
[238] | 1617 | |
---|
[272] | 1618 | %% check batch mode supported |
---|
| 1619 | if batch |
---|
| 1620 | switch batch_mode |
---|
| 1621 | case 'sge' |
---|
| 1622 | test_command='qstat'; |
---|
| 1623 | case 'oar' |
---|
| 1624 | test_command='oartat'; |
---|
| 1625 | end |
---|
| 1626 | [s,w]=system(test_command); |
---|
| 1627 | if ~isequal(s,0) |
---|
| 1628 | msgbox_uvmat('ERROR',[batch_mode ' batch system not available']) |
---|
| 1629 | return |
---|
| 1630 | end |
---|
| 1631 | end |
---|
| 1632 | |
---|
| 1633 | %% check if the binaries exist |
---|
[273] | 1634 | if isequal(get(handles.Matlab,'checked'),'on') |
---|
| 1635 | CivMode='Matlab'; |
---|
| 1636 | else |
---|
| 1637 | CivMode='CivX'; |
---|
| 1638 | end |
---|
[257] | 1639 | switch CivMode |
---|
[274] | 1640 | case {'CivX','CivAll'} |
---|
| 1641 | for bin_name={'Civ1Bin','Civ2Bin','PatchBin','FixBin','CivBin'} |
---|
| 1642 | if isfield(param.global,bin_name{1}) |
---|
| 1643 | if ~exist(param.global.(bin_name{1}),'file')%look for the full path if the file name has been defined with a relative path in PARAM.xml |
---|
| 1644 | fullname=fullfile(path_UVMAT,param.global.(bin_name{1})); |
---|
| 1645 | if exist(fullname,'file') |
---|
| 1646 | param.global.(bin_name{1})=fullname; |
---|
| 1647 | else |
---|
| 1648 | msgbox_uvmat('ERROR',['Binary ' param.global.(bin_name{1}) ' defined in PARAM.xm does not exist']) |
---|
| 1649 | return |
---|
| 1650 | end |
---|
| 1651 | else |
---|
| 1652 | [path,name,ext]=fileparts(param.global.(bin_name{1})); |
---|
| 1653 | currentdir=pwd; |
---|
| 1654 | cd(path); |
---|
| 1655 | binpath=pwd;%path of the binary |
---|
| 1656 | param.global.(bin_name{1})=fullfile(binpath,[name ext]); |
---|
| 1657 | % display(param.global.(bin_name{1})); |
---|
| 1658 | cd(currentdir); |
---|
| 1659 | end |
---|
| 1660 | |
---|
| 1661 | end |
---|
| 1662 | end |
---|
[257] | 1663 | case 'Matlab' |
---|
| 1664 | if batch |
---|
[272] | 1665 | % vérifier Matlab installé sur le cluster |
---|
| 1666 | % difficile a faire a priori |
---|
[257] | 1667 | end |
---|
[225] | 1668 | end |
---|
[2] | 1669 | |
---|
[272] | 1670 | display('files OK, processing...') |
---|
[2] | 1671 | |
---|
[272] | 1672 | %% get civ1 parameters |
---|
| 1673 | if box_test(1) |
---|
| 1674 | param.civ1=read_param_civ1(handles,filecell); |
---|
[112] | 1675 | end |
---|
[2] | 1676 | |
---|
[272] | 1677 | %% get fix1 parameters |
---|
| 1678 | if box_test(2) |
---|
| 1679 | param.fix1=read_param_fix1(handles,filecell) |
---|
[2] | 1680 | end |
---|
[112] | 1681 | |
---|
[274] | 1682 | %% get patch1 parameters |
---|
[272] | 1683 | if box_test(3) |
---|
[274] | 1684 | param.Patch1=read_panel(handles.panel_Patch1); |
---|
| 1685 | %param.patch1=read_param_patch1(handles) |
---|
[112] | 1686 | end |
---|
| 1687 | |
---|
[133] | 1688 | %% get civ2 parameters: |
---|
[272] | 1689 | if box_test(4) |
---|
| 1690 | param.civ2=read_param_civ2(handles,cell2mat(filecell.ima1.civ2(1,1))); |
---|
[2] | 1691 | end |
---|
| 1692 | |
---|
[133] | 1693 | %% get fix2 parameters |
---|
[272] | 1694 | if box_test(5) |
---|
[2] | 1695 | flagindex2(1)=get(handles.vec_Fmin2_2, 'Value'); |
---|
| 1696 | flagindex2(2)=get(handles.vec_F3_2, 'Value'); |
---|
| 1697 | flagindex2(3)=get(handles.vec_F4, 'Value'); |
---|
[127] | 1698 | thresh_vec2C=str2double(get(handles.thresh_vec2C,'String'));%threshold on image correlation vec_C |
---|
| 1699 | thresh_vel2=str2double(get(handles.thresh_vel2,'String'));%threshold on velocity modulus |
---|
[2] | 1700 | test_mask=get(handles.get_mask_fix2,'Value'); |
---|
| 1701 | nbslice_mask=get(handles.mask_fix2,'UserData'); % get the number of slices (= number of masks) |
---|
[112] | 1702 | %%%%%%%%%%%%%COMPLETER LE PROGRAMME FIX AVEC REF FILE ET OPTION inf_sup=2 |
---|
| 1703 | % inf_sup=get(handles.inf_sup2,'Value'); |
---|
| 1704 | % ref=get(handles.ref_fix2,'UserData'); |
---|
| 1705 | |
---|
[2] | 1706 | %%%%%%%%%%%%%%%%%%% |
---|
| 1707 | end |
---|
| 1708 | |
---|
[133] | 1709 | %% get patch2 parameters |
---|
[2] | 1710 | if box_test(6)==1 |
---|
[274] | 1711 | param.Patch2=read_panel(handles.panel_Patch1); |
---|
| 1712 | % rho_patch2=str2double(get(handles.num_SmoothParam,'String')); |
---|
| 1713 | % if isnan(rho_patch2) |
---|
| 1714 | % rho_patch2='1000'; |
---|
| 1715 | % set(handles.num_SmoothParam,'String','1') |
---|
| 1716 | % else |
---|
| 1717 | % rho_patch2=num2str(1000*rho_patch2); |
---|
| 1718 | % end |
---|
| 1719 | % nx_patch2=get(handles.num_Nx,'String'); |
---|
| 1720 | % ny_patch2=get(handles.num_Ny,'String'); |
---|
| 1721 | % if isnan(str2double(nx_patch2)) |
---|
| 1722 | % nx_patch2='50' ;%default |
---|
| 1723 | % set(handles.num_Nx,'String','50'); |
---|
| 1724 | % end |
---|
| 1725 | % if isnan(str2double(ny_patch2)) |
---|
| 1726 | % ny_patch2='50' ;%default |
---|
| 1727 | % set(handles.num_Ny,'String','50'); |
---|
| 1728 | % end |
---|
| 1729 | % subdomain_patch2=get(handles.num_SubdomainSize,'String'); |
---|
| 1730 | % thresh_patch2=get(handles.num_MaxDiff,'String'); |
---|
[2] | 1731 | end |
---|
| 1732 | |
---|
[272] | 1733 | %% |
---|
| 1734 | |
---|
| 1735 | |
---|
[133] | 1736 | %% MAIN LOOP |
---|
[273] | 1737 | time=get(handles.ImaDoc,'UserData'); %get the set of times |
---|
[265] | 1738 | |
---|
[134] | 1739 | super_cmd=[]; |
---|
[269] | 1740 | batch_file_list=[]; |
---|
[265] | 1741 | |
---|
[2] | 1742 | for ifile=1:nbfield |
---|
| 1743 | for j=1:nbslice |
---|
[257] | 1744 | % initiate system command |
---|
| 1745 | switch CivMode |
---|
| 1746 | case 'CivX' |
---|
| 1747 | if isunix % check: necessaire aussi en RUN? |
---|
[272] | 1748 | cmd=['#!/bin/bash \n '... |
---|
| 1749 | '#$ -cwd \n '... |
---|
| 1750 | 'hostname && date \n '... |
---|
| 1751 | 'umask 002 \n'];%allow writting access to created files for user group |
---|
| 1752 | else |
---|
| 1753 | cmd=[]; |
---|
[257] | 1754 | end |
---|
| 1755 | case 'CivAll' |
---|
| 1756 | % if CivAll |
---|
| 1757 | CivAllxml=xmltree;% xml contents, all parameters |
---|
| 1758 | CivAllCmd=''; |
---|
| 1759 | CivAllxml=set(CivAllxml,1,'name','CivDoc'); |
---|
[2] | 1760 | end |
---|
[272] | 1761 | |
---|
| 1762 | |
---|
| 1763 | % define output file name |
---|
| 1764 | if box_test(4)==1 || box_test(5)==1 || box_test(6)==1 |
---|
| 1765 | OutputFile=filecell.nc.civ2{ifile,j}; |
---|
| 1766 | else |
---|
| 1767 | OutputFile=filecell.nc.civ1{ifile,j}; |
---|
| 1768 | end |
---|
| 1769 | OutputFile=regexprep(OutputFile,'.nc',''); |
---|
[269] | 1770 | |
---|
[2] | 1771 | |
---|
[112] | 1772 | %CIV1 |
---|
[272] | 1773 | if box_test(1) |
---|
| 1774 | % read image-dependent parameters |
---|
| 1775 | param.civ1.filename_ima_a=filecell.ima1.civ1{ifile,j}; |
---|
| 1776 | param.civ1.filename_ima_b=filecell.ima2.civ1{ifile,j}; |
---|
| 1777 | param.civ1.Dt=num2str(time(num2_civ1(ifile),num_b_civ1(j))-time(num1_civ1(ifile),num_a_civ1(j))); |
---|
| 1778 | param.civ1.T0=num2str((time(num2_civ1(ifile),num_b_civ1(j))+time(num1_civ1(ifile),num_a_civ1(j)))/2); |
---|
| 1779 | param.civ1.term_a=num2stra(num_a_civ1(j),nom_type_nc);%UTILITE? |
---|
| 1780 | param.civ1.term_b=num2stra(num_b_civ1(j),nom_type_nc);% |
---|
| 1781 | |
---|
| 1782 | % read mask parameters |
---|
| 1783 | if get(handles.get_mask_civ1,'Value') |
---|
[2] | 1784 | maskdispl=get(handles.mask_civ1,'String'); |
---|
[12] | 1785 | if exist(maskdispl,'file') |
---|
[272] | 1786 | param.civ1.maskname=maskdispl; |
---|
| 1787 | param.civ1.maskflag='y'; |
---|
[2] | 1788 | else |
---|
[136] | 1789 | maskbase=[filecell.filebase '_' maskdispl]; % |
---|
[137] | 1790 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
[12] | 1791 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
[272] | 1792 | param.civ1.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 1793 | if exist(param.civ1.maskname,'file') |
---|
| 1794 | param.civ1.maskflag='y'; |
---|
[12] | 1795 | else |
---|
[272] | 1796 | param.civ1.maskname='noFile use default'; |
---|
| 1797 | param.civ1.maskflag='n'; |
---|
[12] | 1798 | end |
---|
[2] | 1799 | end |
---|
[272] | 1800 | else |
---|
| 1801 | param.civ1.maskname='noFile use default'; |
---|
| 1802 | param.civ1.maskflag='n'; |
---|
[2] | 1803 | end |
---|
[272] | 1804 | |
---|
| 1805 | % read grid parameters |
---|
| 1806 | if get(handles.browse_gridciv1,'Value') |
---|
| 1807 | param.civ1.gridflag='y'; |
---|
[2] | 1808 | gridname=get(handles.grid_civ1,'String'); |
---|
| 1809 | if isequal(gridname(end-3:end),'grid') |
---|
[137] | 1810 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 1811 | if ~isnan(nbslice_grid) |
---|
[2] | 1812 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
[272] | 1813 | param.civ1.gridname=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 1814 | if ~exist(param.civ1.gridname,'file') |
---|
[112] | 1815 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
[2] | 1816 | end |
---|
| 1817 | elseif exist(gridname,'file') |
---|
[272] | 1818 | param.civ1.gridname=gridname; |
---|
[2] | 1819 | else |
---|
| 1820 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
| 1821 | end |
---|
| 1822 | end |
---|
| 1823 | else |
---|
[272] | 1824 | param.civ1.gridname='noFile use default'; |
---|
| 1825 | param.civ1.gridflag='n'; |
---|
[2] | 1826 | end |
---|
[257] | 1827 | |
---|
| 1828 | switch CivMode |
---|
| 1829 | case 'CivX' |
---|
[272] | 1830 | civ1_exe=CIV1_CMD(filecell.nc.civ1{ifile,j},param);%create the parameter file .civ1.cmx and set the execution string civ1_exe |
---|
[257] | 1831 | cmd=[cmd civ1_exe '\n']; |
---|
| 1832 | case 'CivAll' |
---|
| 1833 | CivAllCmd=[CivAllCmd ' civ1 ']; |
---|
[272] | 1834 | str=CIV1_CMD_Unified(filecell.nc.civ1{ifile,j},'',param.civ1); |
---|
[257] | 1835 | fieldnames=fields(str); |
---|
| 1836 | [CivAllxml,uid_civ1]=add(CivAllxml,1,'element','civ1'); |
---|
| 1837 | for ilist=1:length(fieldnames) |
---|
| 1838 | val=eval(['str.' fieldnames{ilist}]); |
---|
| 1839 | if ischar(val) |
---|
| 1840 | [CivAllxml,uid_t]=add(CivAllxml,uid_civ1,'element',fieldnames{ilist}); |
---|
| 1841 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 1842 | end |
---|
[112] | 1843 | end |
---|
[2] | 1844 | end |
---|
| 1845 | end |
---|
| 1846 | |
---|
[112] | 1847 | % FIX1 |
---|
[272] | 1848 | if box_test(2) |
---|
| 1849 | switch CivMode |
---|
[257] | 1850 | case 'CivX' |
---|
| 1851 | if isunix %unix system |
---|
[272] | 1852 | cmd_FIX=[param.global.FixBin ' -f ' filecell.nc.civ1{ifile,j} ' -fi1 ' num2str(param.fix1.flagindex1(1)) ... |
---|
| 1853 | ' -fi2 ' num2str(param.fix1.flagindex1(2)) ' -fi3 ' num2str(param.fix1.flagindex1(3)) ... |
---|
| 1854 | ' -threshC ' num2str(param.fix1.thresh_vecC1) ' -threshV ' num2str(param.fix1.thresh_vel1) ' -maskName ' param.fix1.maskname]; |
---|
[257] | 1855 | else %windows system |
---|
[272] | 1856 | cmd_FIX=['"' param.global.FixBin '" -f "' filecell.nc.civ1{ifile,j} '" -fi1 ' num2str(param.fix1.flagindex1(1)) ... |
---|
| 1857 | ' -fi2 ' num2str(param.fix1.flagindex1(2)) ' -fi3 ' num2str(param.fix1.flagindex1(3)) ... |
---|
| 1858 | ' -threshC ' num2str(param.fix1.thresh_vecC1) ' -threshV ' num2str(param.fix1.thresh_vel1) ' -maskName "' param.fix1.maskname '"']; |
---|
[257] | 1859 | cmd_FIX=regexprep(cmd_FIX,'\\','\\\\'); |
---|
[112] | 1860 | end |
---|
[257] | 1861 | cmd=[cmd cmd_FIX '\n']; |
---|
| 1862 | case 'CivAll' |
---|
| 1863 | fix1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
[272] | 1864 | fix1.fi1=num2str(param.fix1.flagindex1(1)); |
---|
| 1865 | fix1.fi2=num2str(param.fix1.flagindex1(2)); |
---|
| 1866 | fix1.fi3=num2str(param.fix1.flagindex1(3)); |
---|
| 1867 | fix1.threshC=num2str(param.fix1.thresh_vecC1); |
---|
| 1868 | fix1.threshV=num2str(param.fix1.thresh_vel1); |
---|
[257] | 1869 | fieldnames=fields(fix1); |
---|
| 1870 | [CivAllxml,uid_fix1]=add(CivAllxml,1,'element','fix1'); |
---|
| 1871 | for ilist=1:length(fieldnames) |
---|
| 1872 | val=eval(['fix1.' fieldnames{ilist}]); |
---|
| 1873 | if ischar(val) |
---|
| 1874 | [CivAllxml,uid_t]=add(CivAllxml,uid_fix1,'element',fieldnames{ilist}); |
---|
| 1875 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 1876 | end |
---|
| 1877 | end |
---|
| 1878 | CivAllCmd=[CivAllCmd ' fix1 ']; |
---|
[112] | 1879 | end |
---|
| 1880 | end |
---|
| 1881 | |
---|
| 1882 | %PATCH1 |
---|
| 1883 | if box_test(3)==1 |
---|
[257] | 1884 | switch CivMode |
---|
| 1885 | case 'CivX' |
---|
[274] | 1886 | cmd_PATCH=cmd_patch(filecell.nc.civ1{ifile,j},param.Patch1,param.global.PatchBin); |
---|
[257] | 1887 | cmd=[cmd cmd_PATCH '\n']; |
---|
| 1888 | case 'CivAll' |
---|
| 1889 | patch1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 1890 | patch1.nopt=subdomain_patch1; |
---|
| 1891 | patch1.maxdiff=thresh_patch1; |
---|
| 1892 | patch1.ro=rho_patch1; |
---|
| 1893 | test_grid=get(handles.get_gridpatch1,'Value'); |
---|
| 1894 | if test_grid |
---|
| 1895 | patch1.gridflag='y'; |
---|
| 1896 | gridname=get(handles.grid_patch1,'String'); |
---|
| 1897 | if isequal(gridname(end-3:end),'grid') |
---|
| 1898 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 1899 | if ~isnan(nbslice_grid) |
---|
| 1900 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
| 1901 | patch1.gridPatch=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 1902 | if ~exist(patch1.gridPatch,'file') |
---|
| 1903 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
| 1904 | end |
---|
| 1905 | elseif exist(gridname,'file') |
---|
| 1906 | patch1.gridPatch=gridname; |
---|
| 1907 | else |
---|
[112] | 1908 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
| 1909 | end |
---|
[2] | 1910 | end |
---|
[257] | 1911 | else |
---|
| 1912 | patch1.gridPatch='none'; |
---|
| 1913 | patch1.gridflag='n'; |
---|
| 1914 | patch1.m=nx_patch1; |
---|
| 1915 | patch1.n=ny_patch1; |
---|
[2] | 1916 | end |
---|
[257] | 1917 | patch1.convectFlow='n'; |
---|
| 1918 | fieldnames=fields(patch1); |
---|
| 1919 | [CivAllxml,uid_patch1]=add(CivAllxml,1,'element','patch1'); |
---|
| 1920 | for ilist=1:length(fieldnames) |
---|
| 1921 | val=eval(['patch1.' fieldnames{ilist}]); |
---|
| 1922 | if ischar(val) |
---|
| 1923 | [CivAllxml,uid_t]=add(CivAllxml,uid_patch1,'element',fieldnames{ilist}); |
---|
| 1924 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 1925 | end |
---|
[112] | 1926 | end |
---|
[257] | 1927 | CivAllCmd=[CivAllCmd ' patch1 ']; |
---|
[112] | 1928 | end |
---|
[2] | 1929 | end |
---|
[112] | 1930 | if box_test(4)==1 |
---|
[272] | 1931 | param.civ2.filename_ima_a=filecell.ima1.civ2{ifile,j}; |
---|
| 1932 | param.civ2.filename_ima_b=filecell.ima2.civ2{ifile,j}; |
---|
| 1933 | param.civ2.Dt=num2str(time(num2_civ2(ifile),num_b_civ2(j))-time(num1_civ2(ifile),num_a_civ2(j))); |
---|
| 1934 | param.civ2.T0=num2str((time(num2_civ1(ifile),num_b_civ2(j))+time(num1_civ2(ifile),num_a_civ2(j)))/2); |
---|
| 1935 | param.civ2.term_a=num2stra(num_a_civ2(j),nom_type_nc); |
---|
| 1936 | param.civ2.term_b=num2stra(num_b_civ2(j),nom_type_nc); |
---|
| 1937 | param.civ2.filename_nc1=filecell.nc.civ1{ifile,j}; |
---|
| 1938 | param.civ2.filename_nc1(end-2:end)=[]; % remove '.nc' |
---|
[2] | 1939 | test_mask=get(handles.get_mask_civ2,'Value'); |
---|
[112] | 1940 | if test_mask==0 |
---|
[272] | 1941 | param.civ2.maskname='noFile use default'; |
---|
| 1942 | param.civ2.maskflag='n'; |
---|
[2] | 1943 | else |
---|
| 1944 | maskdispl=get(handles.mask_civ2,'String'); |
---|
[12] | 1945 | if exist(maskdispl,'file') |
---|
[272] | 1946 | param.civ2.maskname=maskdispl; |
---|
| 1947 | param.civ2.maskflag='y'; |
---|
[2] | 1948 | else |
---|
[136] | 1949 | maskbase=[filecell.filebase '_' maskdispl]; % |
---|
[137] | 1950 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
[12] | 1951 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
[272] | 1952 | param.civ2.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 1953 | if exist(param.civ2.maskname,'file') |
---|
| 1954 | param.civ2.maskflag='y'; |
---|
[12] | 1955 | else |
---|
[272] | 1956 | param.civ2.maskname='noFile use default'; |
---|
| 1957 | param.civ2.maskflag='n'; |
---|
[12] | 1958 | end |
---|
[2] | 1959 | end |
---|
| 1960 | end |
---|
| 1961 | gridname=get(handles.grid_civ2,'String'); |
---|
| 1962 | if numel(gridname)>=4 && isequal(gridname(end-3:end),'grid') |
---|
[137] | 1963 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 1964 | if ~isnan(nbslice_grid) |
---|
[272] | 1965 | param.civ2.gridflag='y'; |
---|
[2] | 1966 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
[272] | 1967 | param.civ2.gridname=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 1968 | if exist(param.civ2.gridname,'file') |
---|
| 1969 | param.civ2.gridflag='y'; |
---|
[2] | 1970 | else |
---|
[272] | 1971 | param.civ2.gridname='noFile use default'; |
---|
| 1972 | param.civ2.gridflag='n'; |
---|
[2] | 1973 | end |
---|
| 1974 | elseif exist(gridname,'file') |
---|
[272] | 1975 | param.civ2.gridflag='y'; |
---|
[2] | 1976 | else |
---|
[272] | 1977 | param.civ2.gridname='noFile use default'; |
---|
| 1978 | param.civ2.gridflag='n'; |
---|
[2] | 1979 | end |
---|
| 1980 | end |
---|
[257] | 1981 | switch CivMode |
---|
| 1982 | case 'CivX' |
---|
[272] | 1983 | cmd_CIV2=CIV2_CMD(filecell.nc.civ2{ifile,j},[],param);%creates the cmx file [fullfile(Rootbat,Filebat) '.civ2.cmx] |
---|
[257] | 1984 | cmd=[cmd cmd_CIV2 '\n']; |
---|
| 1985 | case 'CivAll' |
---|
| 1986 | CivAllCmd=[CivAllCmd ' civ2 ']; |
---|
[272] | 1987 | str=CIV2_CMD_Unified(filecell.nc.civ2{ifile,j},'',param.civ2); |
---|
[257] | 1988 | fieldnames=fields(str); |
---|
| 1989 | [CivAllxml,uid_civ2]=add(CivAllxml,1,'element','civ2'); |
---|
| 1990 | for ilist=1:length(fieldnames) |
---|
| 1991 | val=eval(['str.' fieldnames{ilist}]); |
---|
| 1992 | if ischar(val) |
---|
| 1993 | [CivAllxml,uid_t]=add(CivAllxml,uid_civ2,'element',fieldnames{ilist}); |
---|
| 1994 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 1995 | end |
---|
[2] | 1996 | end |
---|
| 1997 | end |
---|
[112] | 1998 | end |
---|
| 1999 | |
---|
| 2000 | % FIX2 |
---|
| 2001 | if box_test(5)==1 |
---|
| 2002 | test_mask=get(handles.get_mask_fix2,'Value'); |
---|
| 2003 | if test_mask==0 |
---|
| 2004 | maskname=''; %no mask used |
---|
[2] | 2005 | else |
---|
| 2006 | maskdispl=get(handles.mask_fix2,'String'); |
---|
[136] | 2007 | maskbase=[filecell.filebase '_' maskdispl]; % |
---|
[137] | 2008 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
[2] | 2009 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
| 2010 | maskname =name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
[112] | 2011 | end |
---|
[257] | 2012 | switch CivMode |
---|
| 2013 | case 'CivX' |
---|
| 2014 | if isunix |
---|
[272] | 2015 | cmd_FIX=[param.global.FixBin ' -f ' filecell.nc.civ2{ifile,j} ' -fi1 ' num2str(flagindex2(1)) ... |
---|
[257] | 2016 | ' -fi2 ' num2str(flagindex2(2)) ' -fi3 ' num2str(flagindex2(3)) ... |
---|
| 2017 | ' -threshC ' num2str(thresh_vec2C) ' -threshV ' num2str(thresh_vel2) ' -maskName ' maskname]; |
---|
| 2018 | else |
---|
[272] | 2019 | cmd_FIX=['"' param.global.FixBin '" -f "' filecell.nc.civ2{ifile,j} '" -fi1 ' num2str(flagindex2(1)) ... |
---|
[257] | 2020 | ' -fi2 ' num2str(flagindex2(2)) ' -fi3 ' num2str(flagindex2(3)) ... |
---|
| 2021 | ' -threshC ' num2str(thresh_vec2C) ' -threshV ' num2str(thresh_vel2) ' -maskName "' maskname '"']; |
---|
| 2022 | cmd_FIX=regexprep(cmd_FIX,'\\','\\\\'); |
---|
[112] | 2023 | end |
---|
[257] | 2024 | cmd=[cmd cmd_FIX '\n']; |
---|
| 2025 | case 'CivAll' |
---|
| 2026 | fix2.inputFileName=filecell.nc.civ2{ifile,j} ; |
---|
| 2027 | fix2.fi1=num2str(flagindex2(1)); |
---|
| 2028 | fix2.fi2=num2str(flagindex2(2)); |
---|
| 2029 | fix2.fi3=num2str(flagindex2(3)); |
---|
| 2030 | fix2.threshC=num2str(thresh_vec2C); |
---|
| 2031 | fix2.threshV=num2str(thresh_vel2); |
---|
| 2032 | fieldnames=fields(fix2); |
---|
| 2033 | [CivAllxml,uid_fix2]=add(CivAllxml,1,'element','fix2'); |
---|
| 2034 | for ilist=1:length(fieldnames) |
---|
| 2035 | val=eval(['fix2.' fieldnames{ilist}]); |
---|
| 2036 | if ischar(val) |
---|
| 2037 | [CivAllxml,uid_t]=add(CivAllxml,uid_fix2,'element',fieldnames{ilist}); |
---|
| 2038 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 2039 | end |
---|
| 2040 | end |
---|
| 2041 | CivAllCmd=[CivAllCmd ' fix2 ']; |
---|
[112] | 2042 | end |
---|
| 2043 | end |
---|
| 2044 | |
---|
| 2045 | %PATCH2 |
---|
| 2046 | if box_test(6)==1 |
---|
[257] | 2047 | switch CivMode |
---|
| 2048 | case 'CivX' |
---|
[274] | 2049 | cmd_PATCH=cmd_path(filecell.nc.civ2{ifile,j},param); |
---|
[257] | 2050 | cmd=[cmd cmd_PATCH '\n']; |
---|
| 2051 | case 'CivAll' |
---|
| 2052 | patch2.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 2053 | patch2.nopt=subdomain_patch2; |
---|
| 2054 | patch2.maxdiff=thresh_patch2; |
---|
| 2055 | patch2.ro=rho_patch2; |
---|
| 2056 | test_grid=get(handles.get_gridpatch2,'Value'); |
---|
| 2057 | if test_grid |
---|
| 2058 | patch2.gridflag='y'; |
---|
| 2059 | gridname=get(handles.grid_patch2,'String'); |
---|
| 2060 | if isequal(gridname(end-3:end),'grid') |
---|
| 2061 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 2062 | if ~isnan(nbslice_grid) |
---|
| 2063 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
| 2064 | patch2.gridPatch=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 2065 | if ~exist(patch2.gridPatch,'file') |
---|
| 2066 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
| 2067 | end |
---|
| 2068 | elseif exist(gridname,'file') |
---|
| 2069 | patch2.gridPatch=gridname; |
---|
| 2070 | else |
---|
[112] | 2071 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
[12] | 2072 | end |
---|
[2] | 2073 | end |
---|
[257] | 2074 | else |
---|
| 2075 | patch2.gridPatch='none'; |
---|
| 2076 | patch2.gridflag='n'; |
---|
| 2077 | patch2.m=nx_patch2; |
---|
| 2078 | patch2.n=ny_patch2; |
---|
[2] | 2079 | end |
---|
[257] | 2080 | patch2.convectFlow='n'; |
---|
| 2081 | fieldnames=fields(patch2); |
---|
| 2082 | [CivAllxml,uid_patch2]=add(CivAllxml,1,'element','patch2'); |
---|
| 2083 | for ilist=1:length(fieldnames) |
---|
| 2084 | val=eval(['patch2.' fieldnames{ilist}]); |
---|
| 2085 | if ischar(val) |
---|
| 2086 | [CivAllxml,uid_t]=add(CivAllxml,uid_patch2,'element',fieldnames{ilist}); |
---|
| 2087 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 2088 | end |
---|
[112] | 2089 | end |
---|
[257] | 2090 | CivAllCmd=[CivAllCmd ' patch2 ']; |
---|
[112] | 2091 | end |
---|
[12] | 2092 | end |
---|
[257] | 2093 | |
---|
| 2094 | switch CivMode |
---|
| 2095 | case {'CivX','CivAll'} |
---|
| 2096 | if isequal(CivMode,'CivAll') |
---|
[272] | 2097 | save(CivAllxml,[OutputFile '.xml']); |
---|
| 2098 | cmd=[cmd sparam.CivBin ' -f ' OutputFile '.xml ' CivAllCmd ' >' OutputFile '.log' '\n']; |
---|
[238] | 2099 | end |
---|
[272] | 2100 | |
---|
| 2101 | % create the .bat file used in run or batch |
---|
| 2102 | filename_bat=[OutputFile '.bat']; |
---|
[257] | 2103 | [fid,message]=fopen(filename_bat,'w'); |
---|
| 2104 | if isequal(fid,-1) |
---|
| 2105 | msgbox_uvmat('ERROR', ['creation of .bat file: ' message]) |
---|
| 2106 | return |
---|
[238] | 2107 | end |
---|
[257] | 2108 | fprintf(fid,cmd); |
---|
| 2109 | fclose(fid); |
---|
[269] | 2110 | |
---|
| 2111 | batch_file_list{length(batch_file_list)+1}=filename_bat; |
---|
| 2112 | |
---|
| 2113 | % if batch |
---|
| 2114 | % switch batch_mode |
---|
| 2115 | % case 'sge' |
---|
| 2116 | % display(['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]); |
---|
| 2117 | % eval( ['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]); |
---|
| 2118 | % case 'oar' |
---|
| 2119 | % % eval( ['!chmod +x ' filename_bat]); |
---|
| 2120 | % % %eval( ['!oarsub -n CIVX -l /core=1,walltime=00:10:00 ' filename_bat]); |
---|
| 2121 | % % eval( ['!oarsub -n CIVX -l "/core=1+{type = ''smalljob''}/licence=1,walltime=00:10:00" ' filename_bat]); |
---|
| 2122 | % |
---|
| 2123 | % cmd_str=['sh ' filename_bat]; |
---|
| 2124 | % super_cmd{length(super_cmd)+1}=cmd_str; |
---|
| 2125 | % |
---|
| 2126 | % end |
---|
| 2127 | % else |
---|
| 2128 | % %% to lauch the jobs locally : |
---|
| 2129 | % if(isunix) |
---|
| 2130 | % cmd_str=['. ' filename_bat]; |
---|
| 2131 | % else %case of Windows |
---|
| 2132 | % cmd_str=['@call "' regexprep(filename_bat,'\\','\\\\') '"']; |
---|
| 2133 | % end |
---|
| 2134 | % super_cmd=[super_cmd cmd_str '\n']; |
---|
| 2135 | % disp(cmd_str); |
---|
| 2136 | % end |
---|
[257] | 2137 | case 'Matlab' |
---|
| 2138 | drawnow |
---|
| 2139 | if box_test(1)==1 |
---|
[272] | 2140 | Param.Civ1=param.civ1; |
---|
[252] | 2141 | end |
---|
[257] | 2142 | if box_test(2)==1 |
---|
| 2143 | fix1.WarnFlags=[]; |
---|
| 2144 | if get(handles.vec_Fmin2,'Value') |
---|
| 2145 | fix1.WarnFlags=[fix1.WarnFlags -2]; |
---|
| 2146 | end |
---|
| 2147 | if get(handles.vec_F3,'Value') |
---|
| 2148 | fix1.WarnFlags=[fix1.WarnFlags 3]; |
---|
| 2149 | end |
---|
| 2150 | fix1.LowerBoundCorr=thresh_vecC1; |
---|
| 2151 | if get(handles.inf_sup1,'Value') |
---|
| 2152 | fix1.UppperBoundVel=thresh_vel1; |
---|
| 2153 | else |
---|
| 2154 | fix1.LowerBoundVel=thresh_vel1; |
---|
| 2155 | end |
---|
| 2156 | if get(handles.get_mask_fix1,'Value') |
---|
| 2157 | fix1.MaskName=maskname; |
---|
| 2158 | end |
---|
| 2159 | Param.Fix1=fix1; |
---|
[252] | 2160 | end |
---|
[257] | 2161 | if box_test(3)==1 |
---|
[263] | 2162 | if strcmp(compare,'stereo PIV') |
---|
| 2163 | filebase_A=filecell.filebase; |
---|
| 2164 | [pp,ff]=fileparts(filebase_A); |
---|
| 2165 | filebase_B=fullfile(pp,get(handles.RootName_1,'String')); |
---|
| 2166 | RUN_STLIN(filecell.ncA.civ1{ifile,j},filecell.nc.civ1{ifile,j},'civ1',filecell.st{ifile,j},... |
---|
| 2167 | str2num(nx_patch1),str2num(ny_patch1),str2num(thresh_patch1),[filebase_A '.xml'],[filebase_B '.xml']) |
---|
| 2168 | else |
---|
| 2169 | Param.Patch1.Rho=rho_patch1; |
---|
| 2170 | Param.Patch1.Threshold=thresh_patch1; |
---|
| 2171 | Param.Patch1.SubDomain=subdomain_patch1; |
---|
| 2172 | end |
---|
[257] | 2173 | end |
---|
| 2174 | if box_test(4)==1 |
---|
[272] | 2175 | Param.Civ2=param.civ2; |
---|
[257] | 2176 | end |
---|
| 2177 | if box_test(5)==1 |
---|
| 2178 | fix2.WarnFlags=[]; |
---|
| 2179 | if get(handles.vec_Fmin2_2,'Value') |
---|
| 2180 | fix2.WarnFlags=[fix2.WarnFlags -2]; |
---|
| 2181 | end |
---|
| 2182 | if get(handles.vec_F4,'Value') |
---|
| 2183 | fix2.WarnFlags=[fix2.WarnFlags 4]; |
---|
| 2184 | end |
---|
| 2185 | if get(handles.vec_F3_2,'Value') |
---|
| 2186 | fix2.WarnFlags=[fix2.WarnFlags 3]; |
---|
| 2187 | end |
---|
| 2188 | fix2.LowerBoundCorr=thresh_vec2C; |
---|
| 2189 | if get(handles.inf_sup2,'Value') |
---|
| 2190 | fix2.UppperBoundVel=thresh_vel2; |
---|
| 2191 | else |
---|
| 2192 | fix2.LowerBoundVel=thresh_vel2; |
---|
| 2193 | end |
---|
| 2194 | if get(handles.get_mask_fix2,'Value') |
---|
| 2195 | fix2.MaskName=maskname; |
---|
| 2196 | end |
---|
| 2197 | Param.Fix2=fix2; |
---|
| 2198 | end |
---|
[263] | 2199 | if box_test(6)==1 |
---|
| 2200 | if strcmp(compare,'stereo PIV') |
---|
| 2201 | filebase_A=filecell.filebase; |
---|
| 2202 | [pp,ff]=fileparts(filebase_A); |
---|
| 2203 | filebase_B=fullfile(pp,get(handles.RootName_1,'String')); |
---|
| 2204 | RUN_STLIN(filecell.ncA.civ2{ifile,j},filecell.nc.civ2{ifile,j},'civ2',filecell.st{ifile,j},... |
---|
| 2205 | str2num(nx_patch2),str2num(ny_patch2),str2num(thresh_patch2),[filebase_A '.xml'],[filebase_B '.xml']) |
---|
[270] | 2206 | else |
---|
| 2207 | Param.Patch2.Rho=rho_patch2; |
---|
| 2208 | Param.Patch2.Threshold=thresh_patch2; |
---|
| 2209 | Param.Patch2.SubDomain=subdomain_patch2; |
---|
[263] | 2210 | end |
---|
[257] | 2211 | end |
---|
[263] | 2212 | if ~strcmp(compare,'stereo PIV') |
---|
| 2213 | [Data,erromsg]=civ_uvmat(Param,filecell.nc.civ1{ifile,j}); |
---|
| 2214 | if isempty(errormsg) |
---|
| 2215 | display([filecell.nc.civ1{ifile,j} ' written']) |
---|
| 2216 | else |
---|
| 2217 | msgbox_uvmat('ERROR',errormsg) |
---|
| 2218 | end |
---|
[270] | 2219 | |
---|
[263] | 2220 | end |
---|
[257] | 2221 | end |
---|
[112] | 2222 | end |
---|
[2] | 2223 | end |
---|
[134] | 2224 | |
---|
[265] | 2225 | if batch |
---|
[269] | 2226 | switch batch_mode |
---|
| 2227 | case 'sge' |
---|
| 2228 | for p=1:length(batch_file_list) |
---|
| 2229 | cmd=['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' batch_file_list{p}]; |
---|
| 2230 | display(cmd);eval(cmd); |
---|
| 2231 | end |
---|
[272] | 2232 | case 'sge' |
---|
| 2233 | [s,w]=unix('qstat -q civ.q|grep job_| wc -l'); %check the waiting list (command unix) |
---|
| 2234 | w(end)=[]; |
---|
| 2235 | str_displ={[w ' jobs in the waiting list'];... |
---|
| 2236 | '***********************';... |
---|
| 2237 | 'JOBS PRIORITY POLICY';... |
---|
| 2238 | '- urgent = less than 100 images pairs';... |
---|
| 2239 | '- normal = during the experiments';... |
---|
| 2240 | '- low = post processing';... |
---|
| 2241 | '***********************';... |
---|
| 2242 | 'Select a priority:'}; |
---|
| 2243 | str={'urgent';'normal';'low'}; |
---|
| 2244 | [ind_answer,v] = listdlg('PromptString',str_displ,... |
---|
| 2245 | 'SelectionMode','single',... |
---|
| 2246 | 'ListString',str,'ListSize',[200 100],'Name','job priority','InitialValue',3); |
---|
| 2247 | pvalue=num2str((1-ind_answer)*500); % |
---|
| 2248 | if isequal(v,0) % to handle Cancel button and figure close |
---|
| 2249 | errormsg='job submission cancelled'; |
---|
| 2250 | return |
---|
| 2251 | end |
---|
[265] | 2252 | case 'oar' |
---|
[269] | 2253 | for p=0:floor(length(batch_file_list)/6); |
---|
| 2254 | filename_batch_group=fullfile(Rootbat,['job_list_' num2str(p) '.bat']); |
---|
| 2255 | fid=fopen(filename_batch_group,'w'); |
---|
[265] | 2256 | if fid==-1 |
---|
| 2257 | msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat]) |
---|
| 2258 | return |
---|
| 2259 | end |
---|
[269] | 2260 | if p==floor(length(batch_file_list)/6) |
---|
| 2261 | kmax=mod(length(batch_file_list),6); |
---|
[265] | 2262 | else |
---|
| 2263 | kmax=6; |
---|
| 2264 | end |
---|
| 2265 | for k=1:kmax |
---|
[269] | 2266 | fprintf(fid,['sh ' batch_file_list{p*6+k} '\n']); |
---|
[265] | 2267 | end |
---|
| 2268 | fclose(fid); |
---|
[269] | 2269 | system(['chmod +x ' filename_batch_group]); |
---|
| 2270 | eval( ['!oarsub -n CIVX -q nicejob -l "/core=1+{type = ''smalljob''}/licence=1,walltime=00:60:00" ' filename_batch_group]); |
---|
| 2271 | end |
---|
| 2272 | case 'oar_new' % to be develloped with Patrick Begou |
---|
| 2273 | filename_joblist=fullfile(Rootbat,'job_list.txt'); |
---|
| 2274 | fid=fopen(filename_superbat,'w'); |
---|
| 2275 | if fid==-1 |
---|
| 2276 | msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat]) |
---|
| 2277 | return |
---|
[265] | 2278 | end |
---|
[269] | 2279 | for p=1:length(batch_file_list) |
---|
| 2280 | fprintf(fid,[batch_file_list{p} '\n']); |
---|
| 2281 | end |
---|
| 2282 | fclose(fid); |
---|
| 2283 | walltime=datestr(length(super_cmd)*10/24/60,13); |
---|
| 2284 | eval( ['!oarsub -n CIVX -q nicejob -l "/core=1+{type = ''smalljob''}/licence=1,walltime=' walltime '" ' filename_superbat]); |
---|
| 2285 | end |
---|
| 2286 | else |
---|
| 2287 | if ~isequal(CivMode,'Matlab') |
---|
| 2288 | filename_superbat=fullfile(Rootbat,'job_list.bat'); |
---|
| 2289 | fid=fopen(filename_superbat,'w'); |
---|
| 2290 | if fid==-1 |
---|
| 2291 | msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat]) |
---|
| 2292 | return |
---|
| 2293 | end |
---|
| 2294 | for p=1:length(batch_file_list) |
---|
| 2295 | if isunix |
---|
| 2296 | fprintf(fid,['sh ' batch_file_list{p} '\n']); |
---|
| 2297 | else |
---|
| 2298 | fprintf(fid,['@call "' regexprep(filename_bat,'\\','\\\\') '"' '\n']); |
---|
[265] | 2299 | end |
---|
[269] | 2300 | end |
---|
| 2301 | fclose(fid); |
---|
| 2302 | if(isunix) |
---|
| 2303 | system(['chmod +x ' filename_superbat]); |
---|
| 2304 | end |
---|
| 2305 | system([filename_superbat ' &']);% execute main commmand |
---|
[265] | 2306 | end |
---|
[269] | 2307 | |
---|
[265] | 2308 | end |
---|
| 2309 | |
---|
[2] | 2310 | |
---|
[137] | 2311 | %% save interface state |
---|
[2] | 2312 | if isfield(filecell,'nc') |
---|
| 2313 | if isfield(filecell.nc,'civ2') |
---|
| 2314 | fileresu=filecell.nc.civ2{1,1}; |
---|
| 2315 | else |
---|
| 2316 | fileresu=filecell.nc.civ1{1,1}; |
---|
| 2317 | end |
---|
| 2318 | end |
---|
| 2319 | [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileresu); |
---|
| 2320 | namedoc=fullfile(RootPath,subdir,RootFile); |
---|
[112] | 2321 | detect=1; |
---|
[2] | 2322 | while detect==1 |
---|
| 2323 | namefigfull=[namedoc '.fig']; |
---|
| 2324 | hh=dir(namefigfull); |
---|
| 2325 | if ~isempty(hh) |
---|
| 2326 | detect=1; |
---|
| 2327 | namedoc=[namedoc '.0']; |
---|
| 2328 | else |
---|
| 2329 | detect=0; |
---|
| 2330 | end |
---|
| 2331 | end |
---|
| 2332 | saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) |
---|
| 2333 | |
---|
[273] | 2334 | %Save info in personal profile (initiate browser next time) TODO |
---|
| 2335 | MenuFile={}; |
---|
| 2336 | dir_perso=prefdir; |
---|
| 2337 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 2338 | if exist(profil_perso,'file') |
---|
| 2339 | hh=load (profil_perso); |
---|
| 2340 | if isfield(hh,'MenuFile') |
---|
| 2341 | MenuFile=hh.MenuFile; |
---|
| 2342 | end |
---|
| 2343 | MenuFile=[filecell.ima1.civ1(1,1); MenuFile]; |
---|
| 2344 | save (profil_perso,'MenuFile','-append'); %store the file names for future opening of uvmat |
---|
| 2345 | else |
---|
| 2346 | MenuFile=filecell.ima1.civ1(1,1); |
---|
| 2347 | save (profil_perso,'MenuFile') |
---|
| 2348 | end |
---|
| 2349 | |
---|
| 2350 | |
---|
[227] | 2351 | %------------------------------------------------------------------------ |
---|
| 2352 | % --- determine the list of reference indices of processing file |
---|
| 2353 | function [ref_i,ref_j,errormsg]=find_ref_indices(handles) |
---|
| 2354 | %------------------------------------------------------------------------ |
---|
| 2355 | errormsg=''; %default error message |
---|
| 2356 | first_i=str2double(get(handles.first_i,'String'));%first index i |
---|
| 2357 | last_i=str2double(get(handles.last_i,'String'));%last index i |
---|
| 2358 | incr_i=str2double(get(handles.incr_i,'String'));% increment |
---|
| 2359 | if isequal(get(handles.first_j,'Visible'),'on') |
---|
| 2360 | first_j=str2double(get(handles.first_j,'String'));%first index j |
---|
| 2361 | last_j=str2double(get(handles.last_j,'String'));%last index j |
---|
| 2362 | incr_j=str2double(get(handles.incr_j,'String'));% increment |
---|
| 2363 | else |
---|
| 2364 | first_j=1; |
---|
| 2365 | last_j=1; |
---|
| 2366 | incr_j=1; |
---|
| 2367 | end |
---|
| 2368 | ref_i=first_i:incr_i:last_i;% list of i indices (reference values for each pair) |
---|
| 2369 | ref_j=first_j:incr_j:last_j;% list of j indices (reference values for each pair) |
---|
| 2370 | if isnan(first_i)||isnan(first_j) |
---|
| 2371 | errormsg='first field number not defined'; |
---|
| 2372 | elseif isnan(last_i)||isnan(last_j) |
---|
| 2373 | errormsg='last field number not defined'; |
---|
| 2374 | elseif isnan(incr_i)||isnan(incr_j) |
---|
| 2375 | errormsg='increment in field number not defined'; |
---|
| 2376 | elseif last_i < first_i || last_j < first_j |
---|
| 2377 | errormsg='last field number must be larger than the first one'; |
---|
| 2378 | end |
---|
[134] | 2379 | |
---|
[227] | 2380 | %------------------------------------------------------------------------ |
---|
| 2381 | % --- determine the list of filenames and indices needed for launch_job |
---|
[263] | 2382 | 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,compare]=... |
---|
[227] | 2383 | set_civ_filenames(handles,ref_i,ref_j,box_test) |
---|
[12] | 2384 | %------------------------------------------------------------------------ |
---|
[85] | 2385 | filecell=[];%default |
---|
[136] | 2386 | |
---|
| 2387 | %% get the root names nomenclature and numbers |
---|
[71] | 2388 | filebase=get(handles.RootName,'String'); |
---|
[136] | 2389 | |
---|
| 2390 | if isempty(filebase)||isequal(filebase,'') |
---|
| 2391 | msgbox_uvmat('ERROR','no input files') |
---|
| 2392 | return |
---|
| 2393 | end |
---|
| 2394 | |
---|
[137] | 2395 | %filebase=regexprep(filebase,'\.fsnet','fsnet');% temporary fix for cluster Coriolis |
---|
[136] | 2396 | filecell.filebase=filebase; |
---|
| 2397 | |
---|
[273] | 2398 | browse=get(handles.RootName,'UserData'); |
---|
[2] | 2399 | compare_list=get(handles.compare,'String'); |
---|
| 2400 | val=get(handles.compare,'Value'); |
---|
| 2401 | compare=compare_list{val}; |
---|
| 2402 | if strcmp(compare,'displacement') |
---|
| 2403 | mode='displacement'; |
---|
| 2404 | else |
---|
[273] | 2405 | mode_list=get(handles.CivMode,'String'); |
---|
| 2406 | mode_value=get(handles.CivMode,'Value'); |
---|
[2] | 2407 | mode=mode_list{mode_value}; |
---|
| 2408 | end |
---|
[137] | 2409 | %time=get(handles.RootName,'UserData'); %get the set of times |
---|
[71] | 2410 | ext_ima=get(handles.ImaExt,'String'); |
---|
[2] | 2411 | nom_type_nc=browse.nom_type_nc; |
---|
[122] | 2412 | if isfield(browse,'nom_type_ima') |
---|
| 2413 | nom_type_ima2=browse.nom_type_ima; |
---|
| 2414 | end |
---|
| 2415 | if isempty(nom_type_ima2),nom_type_ima2='1';end; %default |
---|
| 2416 | if isempty(nom_type_nc),nom_type_nc='_i1-i2';end; %default |
---|
[2] | 2417 | [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
[227] | 2418 | find_pair_indices(handles,ref_i,ref_j,mode); |
---|
[273] | 2419 | %determine the new filebase for 'displacement' CivMode (comparison of two series) |
---|
[2] | 2420 | filebase_B=filebase;% root name of the second field series for stereo |
---|
| 2421 | if strcmp(compare,'displacement') || strcmp(compare,'stereo PIV') |
---|
[127] | 2422 | % test_disp=1; |
---|
[2] | 2423 | nom_type_ima1=browse.nom_type_ima_1; %nomenclature type of the second file series |
---|
| 2424 | [Path2,Name2]=fileparts(filebase_B); |
---|
| 2425 | Path1=Path2; |
---|
[71] | 2426 | Name1=get(handles.RootName_1,'String');% root name of the first field series for stereo |
---|
[2] | 2427 | filebase_A=fullfile(Path1,Name1); |
---|
| 2428 | if length(Name1)>6 |
---|
| 2429 | Name1=Name1(end-5:end); |
---|
| 2430 | end |
---|
| 2431 | if length(Name2)>6 |
---|
| 2432 | Name2=Name2(end-5:end); |
---|
| 2433 | end |
---|
| 2434 | filebase_AB=fullfile(Path2,[Name2 '-' Name1]); |
---|
| 2435 | else |
---|
[127] | 2436 | % test_disp=0; |
---|
[2] | 2437 | filebase_A=filebase; |
---|
| 2438 | nom_type_ima1=nom_type_ima2; |
---|
| 2439 | filebase_AB=filebase; |
---|
| 2440 | end |
---|
| 2441 | if strcmp(compare,'displacement') |
---|
[112] | 2442 | filebase_ima1=filebase_A; |
---|
| 2443 | filebase_ima2=filebase_B; |
---|
| 2444 | filebase_nc=filebase_AB; %root name for the result of civ2 |
---|
[2] | 2445 | else |
---|
[112] | 2446 | filebase_ima1=filebase_B; |
---|
| 2447 | filebase_ima2=filebase_B; |
---|
| 2448 | filebase_nc=filebase_B; |
---|
| 2449 | end |
---|
[2] | 2450 | |
---|
| 2451 | %determine reference files for fix: |
---|
| 2452 | file_ref_fix1={};%default |
---|
| 2453 | file_ref_fix2={}; |
---|
| 2454 | nbfield=length(num1_civ1); |
---|
| 2455 | nbslice=length(num_a_civ1); |
---|
| 2456 | if box_test(2)==1% fix1 performed |
---|
| 2457 | ref=get(handles.ref_fix1,'UserData');%read data on the ref file stored by get_ref_fix1_Callback |
---|
| 2458 | if ~isempty(ref) |
---|
[137] | 2459 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 2460 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 2461 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 2462 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 2463 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 2464 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[127] | 2465 | num_i_ref=first_i:incr_i:last_i; |
---|
| 2466 | num_j_ref=first_j:incr_j:last_j; |
---|
[2] | 2467 | if isequal(mode,'displacement') |
---|
| 2468 | num_i1=num_i_ref; |
---|
| 2469 | num_i2=num_i_ref; |
---|
| 2470 | num_j1=num_j_ref; |
---|
| 2471 | num_j2=num_j_ref; |
---|
| 2472 | elseif isequal(mode,'pair j1-j2')% isequal(mode,'st_pair j1-j2') |
---|
| 2473 | num_i1=num_i_ref; |
---|
| 2474 | num_i2=num_i1; |
---|
| 2475 | num_j1=ref.num_a*ones(size(num_i_ref)); |
---|
| 2476 | num_j2=ref.num_b*ones(size(num_i_ref)); |
---|
| 2477 | elseif isequal(mode,'series(Di)') % isequal(mode,'st_series(Di)') |
---|
| 2478 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 2479 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 2480 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 2481 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 2482 | if isempty(ref.num_a) |
---|
| 2483 | ref.num_a=1; |
---|
| 2484 | end |
---|
| 2485 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 2486 | num_j2=num_j1; |
---|
| 2487 | elseif isequal(mode,'series(Dj)')%| isequal(mode,'st_series(Dj)') |
---|
| 2488 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 2489 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 2490 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 2491 | num_i2=num_i1; |
---|
| 2492 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 2493 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 2494 | end |
---|
| 2495 | for ifile=1:nbfield |
---|
| 2496 | for j=1:nbslice |
---|
| 2497 | 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);% |
---|
| 2498 | file_ref_fix1(ifile,j)={file_ref}; |
---|
| 2499 | if ~exist(file_ref,'file') |
---|
| 2500 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix1']) |
---|
[12] | 2501 | filecell=[]; |
---|
[2] | 2502 | return |
---|
| 2503 | end |
---|
| 2504 | end |
---|
| 2505 | end |
---|
| 2506 | end |
---|
| 2507 | end |
---|
| 2508 | |
---|
| 2509 | %determine reference files for fix2: |
---|
| 2510 | if box_test(5)==1% fix2 performed |
---|
| 2511 | ref=get(handles.ref_fix2,'UserData'); |
---|
| 2512 | if ~isempty(ref) |
---|
[127] | 2513 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 2514 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 2515 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 2516 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 2517 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 2518 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[229] | 2519 | num_i_ref=first_i:incr_i:last_i; |
---|
| 2520 | num_j_ref=first_j:incr_j:last_j; |
---|
[2] | 2521 | if isequal(mode,'displacement') |
---|
| 2522 | num_i1=num_i_ref; |
---|
| 2523 | num_i2=num_i_ref; |
---|
| 2524 | num_j1=num_j_ref; |
---|
| 2525 | num_j2=num_j_ref; |
---|
| 2526 | elseif isequal(mode,'pair j1-j2') |
---|
| 2527 | num_i1=num_i_ref; |
---|
| 2528 | num_i2=num_i1; |
---|
| 2529 | num_j1=ref.num_a; |
---|
| 2530 | num_j2=ref.num_b; |
---|
| 2531 | elseif isequal(mode,'series(Di)') |
---|
| 2532 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 2533 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 2534 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 2535 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 2536 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 2537 | num_j2=num_j1; |
---|
| 2538 | elseif isequal(mode,'series(Dj)') |
---|
| 2539 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 2540 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 2541 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 2542 | num_i2=num_i1; |
---|
| 2543 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 2544 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 2545 | end |
---|
| 2546 | for ifile=1:nbfield |
---|
| 2547 | for j=1:nbslice |
---|
| 2548 | 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);% |
---|
| 2549 | file_ref_fix2(ifile,j)={file_ref}; |
---|
| 2550 | if ~exist(file_ref,'file') |
---|
| 2551 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix2']) |
---|
[122] | 2552 | filecell={}; |
---|
[2] | 2553 | return |
---|
| 2554 | end |
---|
| 2555 | end |
---|
| 2556 | end |
---|
| 2557 | end |
---|
| 2558 | end |
---|
| 2559 | |
---|
| 2560 | %check dir |
---|
| 2561 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf output data |
---|
| 2562 | subdir_civ2=get(handles.subdir_civ2,'String'); |
---|
[174] | 2563 | if isequal(subdir_civ1,''),subdir_civ1='CIV'; end% put default subdir |
---|
[2] | 2564 | if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end% put default subdir |
---|
[266] | 2565 | % currentdir=pwd;%store the current working directory |
---|
[2] | 2566 | [Path_ima,Name]=fileparts(filebase);%Path of the image files (.civ) |
---|
| 2567 | if ~exist(Path_ima,'dir') |
---|
[12] | 2568 | msgbox_uvmat('ERROR',['path to images ' Path_ima ' not found']) |
---|
[122] | 2569 | filecell={}; |
---|
[2] | 2570 | return |
---|
| 2571 | end |
---|
[127] | 2572 | [xx,message]=fileattrib(Path_ima); |
---|
[122] | 2573 | if ~isempty(message) && ~isequal(message.UserWrite,1) |
---|
[112] | 2574 | msgbox_uvmat('ERROR',['No writting access to ' Path_ima]) |
---|
[122] | 2575 | filecell={}; |
---|
[266] | 2576 | % cd(currentdir); |
---|
[112] | 2577 | return |
---|
[2] | 2578 | end |
---|
| 2579 | |
---|
| 2580 | %check the existence of the netcdf and image files involved |
---|
| 2581 | % %%%%%%%%%%%% case CIV1 activated %%%%%%%%%%%%% |
---|
| 2582 | if box_test(1)==1; |
---|
[112] | 2583 | detect=1; |
---|
[127] | 2584 | vers=0; |
---|
| 2585 | subdir_civ1_new=subdir_civ1; |
---|
[153] | 2586 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
[122] | 2587 | for ifile=1:nbfield |
---|
[112] | 2588 | for j=1:nbslice |
---|
[122] | 2589 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1_new); |
---|
[112] | 2590 | detect=exist(filename,'file')==2; |
---|
| 2591 | if detect% if a netcdf file already exists |
---|
[137] | 2592 | indstr=regexp(subdir_civ1_new,'\D'); |
---|
| 2593 | if indstr(end)<length(subdir_civ1_new) %subdir_civ1 ends by a number |
---|
| 2594 | vers=str2double(subdir_civ1_new(indstr(end)+1:end))+1; |
---|
| 2595 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) num2str(vers)]; |
---|
[127] | 2596 | else |
---|
| 2597 | vers=vers+1; |
---|
[137] | 2598 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) '_' num2str(vers)]; |
---|
[127] | 2599 | end |
---|
[137] | 2600 | subdir_civ2=subdir_civ1_new; |
---|
[112] | 2601 | break |
---|
| 2602 | end |
---|
| 2603 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 2604 | end |
---|
| 2605 | if detect% if a netcdf file already exists |
---|
| 2606 | break |
---|
| 2607 | end |
---|
| 2608 | end |
---|
[134] | 2609 | |
---|
[112] | 2610 | %create the new subdir_civ1 |
---|
[127] | 2611 | if ~exist(fullfile(Path_ima,subdir_civ1_new),'dir') |
---|
[263] | 2612 | % cd(Path_ima); |
---|
| 2613 | [xx,msg1]=mkdir(fullfile(Path_ima,subdir_civ1_new)); |
---|
[134] | 2614 | |
---|
[128] | 2615 | if ~strcmp(msg1,'') |
---|
| 2616 | msgbox_uvmat('ERROR',['cannot create ' subdir_civ1_new ': ' msg1])%error message for directory creation |
---|
[122] | 2617 | filecell={}; |
---|
| 2618 | return |
---|
[163] | 2619 | elseif isunix |
---|
[266] | 2620 | [xx,msg2] = fileattrib(fullfile(Path_ima,subdir_civ1_new),'+w','g'); %yield writing access (+w) to user group (g) |
---|
[128] | 2621 | if ~strcmp(msg2,'') |
---|
[266] | 2622 | msgbox_uvmat('ERROR',['pb of permission for ' fullfile(Path_ima,subdir_civ1_new) ': ' msg2])%error message for directory creation |
---|
[128] | 2623 | filecell={}; |
---|
| 2624 | return |
---|
| 2625 | end |
---|
[112] | 2626 | end |
---|
[263] | 2627 | % cd(currentdir); |
---|
[112] | 2628 | end |
---|
| 2629 | if strcmp(compare,'stereo PIV')&&(strcmp(mode,'pair j1-j2')||strcmp(mode,'series(Dj)')||strcmp(mode,'series(Di)'))%check second nc series |
---|
| 2630 | for ifile=1:nbfield |
---|
| 2631 | for j=1:nbslice |
---|
[122] | 2632 | filename=name_generator(filebase_A,num1_civ1(ifile),num_a_civ1(j),'.nc',nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1_new);% |
---|
[112] | 2633 | detect=exist(filename,'file')==2; |
---|
[2] | 2634 | if detect% if a netcdf file already exists |
---|
[137] | 2635 | indstr=regexp(subdir_civ1_new,'\D'); |
---|
| 2636 | if indstr(end)<length(subdir_civ1_new) %subdir_civ1 ends by a number |
---|
| 2637 | vers=str2double(subdir_civ1_new(indstr(end)+1:end))+1; |
---|
| 2638 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) num2str(vers)]; |
---|
[127] | 2639 | else |
---|
| 2640 | vers=vers+1; |
---|
[137] | 2641 | subdir_civ1_new=[subdir_civ1_new '_' num2str(vers)]; |
---|
[127] | 2642 | end |
---|
| 2643 | subdir_civ2=subdir_civ1; |
---|
| 2644 | break |
---|
[2] | 2645 | end |
---|
[112] | 2646 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
| 2647 | end |
---|
| 2648 | if detect% if a netcdf file already exists |
---|
| 2649 | break |
---|
| 2650 | end |
---|
| 2651 | end |
---|
| 2652 | %create the new subdir_civ1 |
---|
[263] | 2653 | if ~exist(fullfile(Path_ima,subdir_civ1_new),'dir') |
---|
| 2654 | % cd(Path_ima); |
---|
| 2655 | [xx,msg1]=mkdir(fullfile(Path_ima,subdir_civ1_new)); |
---|
| 2656 | % cd(currentdir); |
---|
[252] | 2657 | if ~strcmp(msg1,'') |
---|
[128] | 2658 | msgbox_uvmat('ERROR',['cannot create ' subdir_civ1_new ': ' msg1]) |
---|
[263] | 2659 | % cd(currentdir) |
---|
[122] | 2660 | filecell={}; |
---|
| 2661 | return |
---|
[128] | 2662 | else |
---|
[266] | 2663 | [xx,msg2] = fileattrib(fullfile(Path_ima,subdir_civ1_new),'+w','g'); %yield writing access (+w) to user group (g) |
---|
[128] | 2664 | if ~strcmp(msg2,'') |
---|
| 2665 | msgbox_uvmat('ERROR',['pb of permission for ' subdir_civ1_new ': ' msg2])%error message for directory creation |
---|
[263] | 2666 | % cd(currentdir) |
---|
[128] | 2667 | filecell={}; |
---|
| 2668 | return |
---|
| 2669 | end |
---|
[112] | 2670 | end |
---|
| 2671 | end |
---|
| 2672 | end |
---|
| 2673 | end |
---|
[127] | 2674 | subdir_civ1=subdir_civ1_new; |
---|
[2] | 2675 | % get image names |
---|
| 2676 | for ifile=1:nbfield |
---|
[112] | 2677 | for j=1:nbslice |
---|
[2] | 2678 | filename=name_generator(filebase_ima1, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
| 2679 | idetect(j)=exist(filename,'file')==2; |
---|
| 2680 | filecell.ima1.civ1(ifile,j)={filename}; %first image |
---|
| 2681 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
| 2682 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 2683 | filecell.ima2.civ1(ifile,j)={filename};%second image |
---|
[112] | 2684 | end |
---|
| 2685 | [idetectmin,indexj]=min(idetect); |
---|
| 2686 | if idetectmin==0, |
---|
| 2687 | msgbox_uvmat('ERROR',[filecell.ima1.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2688 | filecell={}; |
---|
[266] | 2689 | % cd(currentdir) |
---|
[112] | 2690 | return |
---|
| 2691 | end |
---|
| 2692 | [idetectmin,indexj]=min(idetect_1); |
---|
| 2693 | if idetectmin==0, |
---|
| 2694 | msgbox_uvmat('ERROR',[filecell.ima2.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2695 | filecell={}; |
---|
[266] | 2696 | %cd(currentdir) |
---|
[112] | 2697 | return |
---|
| 2698 | end |
---|
| 2699 | end |
---|
| 2700 | if strcmp(compare,'stereo PIV') && (strcmp(mode,'pair j1-j2') || strcmp(mode,'series(Dj)') || strcmp(mode,'series(Di)')) |
---|
| 2701 | for ifile=1:nbfield |
---|
| 2702 | for j=1:nbslice |
---|
| 2703 | filename=name_generator(filebase_A, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
| 2704 | idetect(j)=exist(filename,'file')==2; |
---|
| 2705 | filecell.imaA1.civ1(ifile,j)={filename} ;%first image |
---|
| 2706 | filename=name_generator(filebase_A, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
| 2707 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 2708 | filecell.imaA2.civ1(ifile,j)={filename};%second image |
---|
| 2709 | end |
---|
[2] | 2710 | [idetectmin,indexj]=min(idetect); |
---|
[112] | 2711 | if idetectmin==0, |
---|
| 2712 | msgbox_uvmat('ERROR',[filecell.imaA1.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2713 | filecell={}; |
---|
[266] | 2714 | % cd(currentdir) |
---|
[2] | 2715 | return |
---|
[112] | 2716 | end |
---|
[2] | 2717 | [idetectmin,indexj]=min(idetect_1); |
---|
[112] | 2718 | if idetectmin==0, |
---|
| 2719 | msgbox_uvmat('ERROR',[filecell.imaA2.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2720 | filecell={}; |
---|
[266] | 2721 | % cd(currentdir) |
---|
[2] | 2722 | return |
---|
[112] | 2723 | end |
---|
| 2724 | end |
---|
[2] | 2725 | end |
---|
[112] | 2726 | |
---|
| 2727 | %%%%%%%%%%%%% fix1 or patch1 activated but no civ1 %%%%%%%%%%%%% |
---|
| 2728 | elseif (box_test(2)==1 || box_test(3)==1); |
---|
[2] | 2729 | for ifile=1:nbfield |
---|
| 2730 | for j=1:nbslice |
---|
| 2731 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
[112] | 2732 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 2733 | detect=exist(filename,'file')==2; |
---|
[122] | 2734 | if detect==0 |
---|
| 2735 | msgbox_uvmat('ERROR',[filename ' not found']) |
---|
| 2736 | filecell={}; |
---|
[266] | 2737 | % cd(currentdir) |
---|
[122] | 2738 | return |
---|
| 2739 | end |
---|
[2] | 2740 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 2741 | end |
---|
| 2742 | end |
---|
| 2743 | if strcmp(compare,'stereo PIV') |
---|
[112] | 2744 | for ifile=1:nbfield |
---|
| 2745 | for j=1:nbslice |
---|
| 2746 | 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);% |
---|
| 2747 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
| 2748 | if ~exist(filename,'file') |
---|
| 2749 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
| 2750 | set(handles.RUN, 'Enable','On') |
---|
| 2751 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
[122] | 2752 | filecell={}; |
---|
[266] | 2753 | %cd(currentdir) |
---|
[112] | 2754 | return |
---|
[2] | 2755 | end |
---|
| 2756 | end |
---|
[112] | 2757 | end |
---|
[2] | 2758 | end |
---|
| 2759 | end |
---|
| 2760 | |
---|
| 2761 | %%%%%%%%%%%%% if civ2 performed with pairs different than civ1 %%%%%%%%%%%%% |
---|
| 2762 | testdiff=0; |
---|
| 2763 | if (box_test(4)==1)&&... |
---|
[127] | 2764 | ((get(handles.list_pair_civ1,'Value')~=get(handles.list_pair_civ2,'Value'))||~strcmp(subdir_civ2,subdir_civ1)) |
---|
[2] | 2765 | testdiff=1; |
---|
[112] | 2766 | detect=1; |
---|
[127] | 2767 | vers=0; |
---|
| 2768 | subdir_civ2_new=subdir_civ2; |
---|
[2] | 2769 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
[112] | 2770 | for ifile=1:nbfield |
---|
| 2771 | for j=1:nbslice |
---|
[127] | 2772 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2_new);% |
---|
[112] | 2773 | detect=exist(filename,'file')==2; |
---|
| 2774 | if detect% if a netcdf file already exists |
---|
[127] | 2775 | indstr=regexp(subdir_civ2,'\D'); |
---|
| 2776 | if indstr(end)<length(subdir_civ2) %subdir_civ1 ends by a number |
---|
| 2777 | vers=str2double(subdir_civ2(indstr(end)+1:end))+1; |
---|
| 2778 | subdir_civ2_new=[subdir_civ2(1:indstr(end)) num2str(vers)]; |
---|
| 2779 | else |
---|
| 2780 | vers=vers+1; |
---|
| 2781 | subdir_civ2_new=[subdir_civ1 '_' num2str(vers)]; |
---|
| 2782 | end |
---|
[112] | 2783 | break |
---|
| 2784 | end |
---|
| 2785 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 2786 | end |
---|
| 2787 | if detect% if a netcdf file already exists |
---|
| 2788 | break |
---|
| 2789 | end |
---|
| 2790 | end |
---|
[128] | 2791 | %create the new subdir_civ2_new |
---|
| 2792 | if ~exist(fullfile(Path_ima,subdir_civ2_new),'dir') |
---|
[174] | 2793 | [xx,m2]=mkdir(fullfile(Path_ima,subdir_civ2_new)); |
---|
[266] | 2794 | [xx,msg2] = fileattrib(fullfile(Path_ima,subdir_civ2_new),'+w','g'); %yield writing access (+w) to user group (g) |
---|
[112] | 2795 | if ~isequal(m2,'') |
---|
[266] | 2796 | msgbox_uvmat('ERROR',['cannot create ' fullfile(Path_ima,subdir_civ2_new) ': ' m2]) |
---|
[122] | 2797 | filecell={}; |
---|
[266] | 2798 | % cd(currentdir) |
---|
[122] | 2799 | return |
---|
[112] | 2800 | end |
---|
| 2801 | end |
---|
| 2802 | if strcmp(compare,'stereo PIV')%check second nc series |
---|
| 2803 | for ifile=1:nbfield |
---|
| 2804 | for j=1:nbslice |
---|
| 2805 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
[122] | 2806 | nom_type_nc,1,num2_civ2(ifile),num_b_civ1(j),subdir_civ2_new);% |
---|
[112] | 2807 | detect=exist(filename,'file')==2; |
---|
[2] | 2808 | if detect% if a netcdf file already exists |
---|
[127] | 2809 | indstr=regexp(subdir_civ2,'\D'); |
---|
| 2810 | if indstr(end)<length(subdir_civ2) %subdir_civ1 ends by a number |
---|
| 2811 | vers=str2double(subdir_civ2(indstr(end)+1:end))+1; |
---|
| 2812 | subdir_civ2_new=[subdir_civ2(1:indstr(end)) num2str(vers)]; |
---|
| 2813 | else |
---|
| 2814 | vers=vers+1; |
---|
| 2815 | subdir_civ2_new=[subdir_civ1 '_' num2str(vers)]; |
---|
| 2816 | end |
---|
[112] | 2817 | break |
---|
[2] | 2818 | end |
---|
[112] | 2819 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 2820 | end |
---|
| 2821 | if detect% if a netcdf file already exists |
---|
| 2822 | break |
---|
| 2823 | end |
---|
| 2824 | end |
---|
[122] | 2825 | subdir_civ2=subdir_civ2_new; |
---|
[112] | 2826 | %create the new subdir_civ1 |
---|
[127] | 2827 | if ~exist(fullfile(Path_ima,subdir_civ2_new),'dir') |
---|
| 2828 | [xx,m2]=mkdir(subdir_civ2_new); |
---|
[266] | 2829 | [xx,msg2] = fileattrib(fullfile(Path_ima,subdir_civ2_new),'+w','g'); %yield writing access (+w) to user group (g) |
---|
[112] | 2830 | if ~isequal(m2,'') |
---|
[266] | 2831 | msgbox_uvmat('ERROR', ['cannot create ' fullfile(Path_ima,subdir_civ2_new) ': ' m2])%error message for directory creation |
---|
| 2832 | % cd(currentdir) |
---|
[122] | 2833 | filecell={}; |
---|
| 2834 | return |
---|
[112] | 2835 | end |
---|
| 2836 | end |
---|
| 2837 | end |
---|
| 2838 | end |
---|
[127] | 2839 | subdir_civ2=subdir_civ2_new; |
---|
[2] | 2840 | end |
---|
[266] | 2841 | %cd(currentdir);%come back to the current working directory |
---|
[2] | 2842 | |
---|
| 2843 | %%%%%%%%%%%%% if civ2 results are obtained or used %%%%%%%%%%%%% |
---|
| 2844 | if box_test(4)==1 || box_test(5)==1 || box_test(6)==1 %civ2 |
---|
| 2845 | %check source netcdf file of civ1 estimates |
---|
| 2846 | if box_test(1)==0; %no civ1 performed |
---|
| 2847 | for ifile=1:nbfield |
---|
| 2848 | for j=1:nbslice |
---|
| 2849 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 2850 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 2851 | filecell.nc.civ1(ifile,j)={filename};% name of the civ1 file |
---|
| 2852 | if ~exist(filename,'file') |
---|
| 2853 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
[122] | 2854 | filecell={}; |
---|
[2] | 2855 | return |
---|
| 2856 | end |
---|
| 2857 | if ~testdiff % civ2 or patch2 are written in the same file as civ1 |
---|
| 2858 | if box_test(4)==0 ; %check the existence of civ2 if it is not calculated |
---|
[248] | 2859 | Data=nc2struct(filename,'ListGlobalAttribute','CivStage','civ2'); |
---|
| 2860 | if ~isempty(Data.CivStage) && Data.CivStage<4 %test for civ files |
---|
[2] | 2861 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
[12] | 2862 | filecell=[]; |
---|
[2] | 2863 | return |
---|
[248] | 2864 | elseif isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
| 2865 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
| 2866 | filecell=[]; |
---|
| 2867 | return |
---|
[112] | 2868 | end |
---|
[2] | 2869 | elseif box_test(3)==0; %check the existence of patch if it is not calculated |
---|
[248] | 2870 | Data=nc2struct(filename,'ListGlobalAttribute','CivStage','patch') |
---|
| 2871 | if ~isempty(Data.CivStage) |
---|
| 2872 | if Data.CivStage<3 %test for civ files |
---|
| 2873 | msgbox_uvmat('ERROR',['no patch data in ' filename]) |
---|
| 2874 | filecell=[]; |
---|
| 2875 | return |
---|
| 2876 | end |
---|
| 2877 | elseif isempty(Data.patch)||isequal(Data.patch,0) |
---|
[2] | 2878 | msgbox_uvmat('ERROR',['no patch data in ' filename]) |
---|
[12] | 2879 | filecell=[]; |
---|
[2] | 2880 | return |
---|
| 2881 | end |
---|
[112] | 2882 | end |
---|
[2] | 2883 | end |
---|
| 2884 | end |
---|
| 2885 | end |
---|
| 2886 | if strcmp(compare,'stereo PIV') |
---|
| 2887 | for ifile=1:nbfield |
---|
| 2888 | for j=1:nbslice |
---|
| 2889 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 2890 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 2891 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 2892 | if ~exist(filename,'file') |
---|
| 2893 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
| 2894 | set(handles.RUN, 'Enable','On') |
---|
| 2895 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 2896 | return |
---|
| 2897 | end |
---|
| 2898 | end |
---|
| 2899 | end |
---|
| 2900 | end |
---|
| 2901 | end |
---|
[112] | 2902 | |
---|
| 2903 | detect=1; |
---|
| 2904 | % while detect==1%creates a new subdir if the netcdf files already contain civ2 data |
---|
| 2905 | for ifile=1:nbfield |
---|
| 2906 | for j=1:nbslice |
---|
| 2907 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
[2] | 2908 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2); |
---|
[112] | 2909 | detect=exist(filename,'file')==2; |
---|
| 2910 | filecell.nc.civ2(ifile,j)={filename}; |
---|
[2] | 2911 | end |
---|
[112] | 2912 | end |
---|
[2] | 2913 | %get first image names for civ2 |
---|
| 2914 | if box_test(1)==1 & isequal(num1_civ1,num1_civ2) & isequal(num_a_civ1,num_a_civ2) |
---|
| 2915 | filecell.ima1.civ2=filecell.ima1.civ1; |
---|
| 2916 | elseif box_test(4)==1 |
---|
| 2917 | for ifile=1:nbfield |
---|
| 2918 | for j=1:nbslice |
---|
| 2919 | filename=name_generator(filebase_ima1, num1_civ2(ifile),num_a_civ2(j),ext_ima,nom_type_ima1); |
---|
| 2920 | idetect_2(j)=exist(filename,'file')==2; |
---|
| 2921 | filecell.ima1.civ2(ifile,j)={filename};%first image |
---|
| 2922 | end |
---|
[112] | 2923 | [idetectmin,indexj]=min(idetect_2); |
---|
[2] | 2924 | if idetectmin==0, |
---|
[112] | 2925 | msgbox_uvmat('ERROR',['input image ' filecell.ima1.civ2{ifile,indexj} ' not found']) |
---|
| 2926 | filecell=[]; |
---|
| 2927 | return |
---|
[2] | 2928 | end |
---|
| 2929 | end |
---|
| 2930 | end |
---|
| 2931 | |
---|
| 2932 | %get second image names for civ2 |
---|
| 2933 | if box_test(1)==1 & isequal(num2_civ1,num2_civ2) & isequal(num_b_civ1,num_b_civ2) |
---|
| 2934 | filecell.ima2.civ2=filecell.ima2.civ1; |
---|
| 2935 | elseif box_test(4)==1 |
---|
| 2936 | for ifile=1:nbfield |
---|
| 2937 | for j=1:nbslice |
---|
| 2938 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),ext_ima,nom_type_ima2); |
---|
| 2939 | idetect_3(j)=exist(filename,'file')==2; |
---|
| 2940 | filecell.ima2.civ2(ifile,j)={filename};%first image |
---|
| 2941 | end |
---|
[112] | 2942 | [idetectmin,indexj]=min(idetect_3); |
---|
[2] | 2943 | if idetectmin==0, |
---|
[112] | 2944 | msgbox_uvmat('ERROR',['input image ' filecell.ima2.civ2{ifile,indexj} ' not found']) |
---|
| 2945 | filecell=[]; |
---|
| 2946 | return |
---|
[2] | 2947 | end |
---|
| 2948 | end |
---|
| 2949 | end |
---|
| 2950 | end |
---|
| 2951 | if (box_test(5)==1 || box_test(6)==1 ) && box_test(4)==0 % need to read an existing netcdf civ2 file |
---|
| 2952 | if ~testdiff |
---|
| 2953 | filecell.nc.civ2=filecell.nc.civ1;% file already checked |
---|
[112] | 2954 | else % check the civ2 files |
---|
[2] | 2955 | for ifile=1:nbfield |
---|
| 2956 | for j=1:nbslice |
---|
| 2957 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
[112] | 2958 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
[2] | 2959 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 2960 | if ~exist(filename,'file') |
---|
| 2961 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
[12] | 2962 | filecell=[]; |
---|
[2] | 2963 | return |
---|
| 2964 | else |
---|
[248] | 2965 | Data=nc2struct(filename,'ListGlobalAttribute','CivStage','civ2'); |
---|
| 2966 | if ~isempty(Data.CivStage) && Data.CivStage<4 %test for civ files |
---|
| 2967 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
| 2968 | filecell=[]; |
---|
| 2969 | return |
---|
| 2970 | elseif isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
[2] | 2971 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
[12] | 2972 | filecell=[]; |
---|
[2] | 2973 | return |
---|
| 2974 | end |
---|
| 2975 | end |
---|
| 2976 | end |
---|
| 2977 | end |
---|
| 2978 | end |
---|
| 2979 | end |
---|
| 2980 | |
---|
| 2981 | %%%%%%%%%%%%% if stereo fields are calculated by PATCH %%%%%%%%%%%%% |
---|
| 2982 | if strcmp(compare,'stereo PIV') |
---|
[127] | 2983 | if box_test(3)==1 && isequal(get(handles.test_stereo1,'Value'),1) |
---|
[2] | 2984 | for ifile=1:nbfield |
---|
| 2985 | for j=1:nbslice |
---|
| 2986 | filename=name_generator(filebase_AB,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 2987 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 2988 | filecell.st(ifile,j)={filename}; |
---|
| 2989 | end |
---|
| 2990 | end |
---|
| 2991 | end |
---|
[274] | 2992 | if box_test(6)==1 && isequal(get(handles.check_Stereo,'Value'),1) |
---|
[2] | 2993 | for ifile=1:nbfield |
---|
| 2994 | for j=1:nbslice |
---|
| 2995 | filename=name_generator(filebase_AB,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 2996 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 2997 | filecell.st(ifile,j)={filename}; |
---|
| 2998 | end |
---|
| 2999 | end |
---|
[112] | 3000 | end |
---|
[2] | 3001 | end |
---|
| 3002 | set(handles.subdir_civ1,'String',subdir_civ1);%update the edit box |
---|
| 3003 | set(handles.subdir_civ2,'String',subdir_civ2);%update the edit box |
---|
| 3004 | browse.nom_type_nc=nom_type_nc; |
---|
[273] | 3005 | set(handles.RootName,'UserData',browse); %update the nomenclature type for uvmat |
---|
[2] | 3006 | |
---|
| 3007 | |
---|
| 3008 | %COPY IMAGES TO THE FORMAT .png IF NEEDED |
---|
[45] | 3009 | if isequal(nom_type_ima1,'*')%case of movie files |
---|
| 3010 | nom_type_imanew1='_i'; |
---|
[2] | 3011 | else |
---|
| 3012 | nom_type_imanew1=nom_type_ima1; |
---|
| 3013 | end |
---|
[45] | 3014 | if isequal(nom_type_ima2,'*')%case of movie files |
---|
| 3015 | nom_type_imanew2='_i'; |
---|
[2] | 3016 | else |
---|
| 3017 | nom_type_imanew2=nom_type_ima2; |
---|
| 3018 | end |
---|
| 3019 | if ~isequal(ext_ima,'.png') |
---|
[45] | 3020 | %%type of image file |
---|
| 3021 | type_ima1='none';%default |
---|
| 3022 | movieobject1=[];%default |
---|
[133] | 3023 | if strcmpi(ext_ima,'.avi') |
---|
[45] | 3024 | hhh=which('mmreader'); |
---|
| 3025 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
---|
| 3026 | type_ima1='movie'; |
---|
| 3027 | movieobject1=mmreader([filebase_ima2 ext_ima]); |
---|
| 3028 | else |
---|
| 3029 | type_ima1='avi'; |
---|
| 3030 | end |
---|
[133] | 3031 | elseif ischar(ext_ima) && ~isempty(ext_ima(2:end)) |
---|
[112] | 3032 | form=imformats(ext_ima(2:end)); |
---|
| 3033 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 3034 | if isequal(nom_type_ima1,'*'); |
---|
| 3035 | type_ima1='multimage';%image series in a single image file |
---|
| 3036 | else |
---|
| 3037 | type_ima1='image'; |
---|
| 3038 | end |
---|
| 3039 | end |
---|
[45] | 3040 | end |
---|
| 3041 | type_ima2='none';%default |
---|
| 3042 | movieobject2=[]; |
---|
[133] | 3043 | if strcmpi(ext_ima,'.avi') |
---|
[45] | 3044 | hhh=which('mmreader'); |
---|
| 3045 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
---|
| 3046 | type_ima2='movie'; |
---|
| 3047 | movieobject2=mmreader([filebase_ima2 ext_ima]); |
---|
| 3048 | else |
---|
| 3049 | type_ima2='avi'; |
---|
| 3050 | end |
---|
[133] | 3051 | elseif ischar(ext_ima) && ~isempty(ext_ima(2:end)) |
---|
[112] | 3052 | form=imformats(ext_ima(2:end)); |
---|
| 3053 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 3054 | if isequal(nom_type_ima1,'*'); |
---|
| 3055 | type_ima2='multimage';%image series in a single image file |
---|
| 3056 | else |
---|
| 3057 | type_ima2='image'; |
---|
| 3058 | end |
---|
| 3059 | end |
---|
[45] | 3060 | end |
---|
[71] | 3061 | %npxy=get(handles.ImaExt,'UserData'); |
---|
[112] | 3062 | % % if numel(npxy)<2 |
---|
| 3063 | % |
---|
| 3064 | % filename=name_generator(filebase_ima1,num1_civ1(1),num_a_civ1(1),ImaExt,nom_type_ima1); |
---|
| 3065 | % A=imread(filename); |
---|
| 3066 | % npxy=size(A); |
---|
| 3067 | % % end |
---|
| 3068 | % npy=npxy(1); |
---|
| 3069 | % npx=npxy(2); |
---|
[2] | 3070 | if box_test(1)==1 %if civ1 is performed |
---|
[224] | 3071 | h = waitbar(0,'copy images to the .png format for civ1');% display a wait bar |
---|
[112] | 3072 | for ifile=1:nbfield |
---|
[2] | 3073 | waitbar(ifile/nbfield); |
---|
| 3074 | for j=1:nbslice |
---|
[112] | 3075 | filename=name_generator(filebase_ima1,num1_civ1(ifile),num_a_civ1(j),'.png',nom_type_imanew1); |
---|
| 3076 | if ~exist(filename,'file') |
---|
| 3077 | A=read_image(filecell.ima1.civ1{ifile,j},type_ima1,num1_civ1(ifile),movieobject1); |
---|
| 3078 | imwrite(A,filename,'BitDepth',16); |
---|
| 3079 | end |
---|
| 3080 | filecell.ima1.civ1(ifile,j)={filename}; |
---|
| 3081 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),'.png',nom_type_imanew2); |
---|
| 3082 | if ~exist(filename,'file') |
---|
| 3083 | A=read_image(filecell.ima2.civ1{ifile,j},type_ima2,num2_civ1(ifile),movieobject2); |
---|
| 3084 | imwrite(A,filename,'BitDepth',16); |
---|
| 3085 | end |
---|
| 3086 | filecell.ima2.civ1(ifile,j)={filename}; |
---|
[2] | 3087 | end |
---|
| 3088 | end |
---|
| 3089 | close(h) |
---|
| 3090 | end |
---|
| 3091 | if box_test(4)==1 %if civ2 is performed |
---|
[229] | 3092 | h = waitbar(0,'copy images to the .png format for civ2');% display a wait bar |
---|
[2] | 3093 | for ifile=1:nbfield |
---|
| 3094 | waitbar(ifile/nbfield); |
---|
| 3095 | for j=1:nbslice |
---|
[112] | 3096 | filename=name_generator(filebase_ima1,num1_civ2(ifile),num_a_civ2(j),'.png',nom_type_imanew1); |
---|
| 3097 | if ~exist(filename,'file') |
---|
| 3098 | A=read_image(cell2mat(filecell.ima1.civ2(ifile,j)),type_ima2,num1_civ2(ifile)); |
---|
| 3099 | imwrite(A,filename,'BitDepth',16); |
---|
| 3100 | end |
---|
| 3101 | filecell.ima1.civ2(ifile,j)={filename}; |
---|
| 3102 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),'.png',nom_type_imanew2); |
---|
| 3103 | if ~exist(filename,'file') |
---|
| 3104 | A=read_image(cell2mat(filecell.ima2.civ2(ifile,j)),type_ima2,num2_civ2(ifile)); |
---|
| 3105 | imwrite(A,filename,'BitDepth',16); |
---|
| 3106 | end |
---|
| 3107 | filecell.ima2.civ2(ifile,j)={filename}; |
---|
[2] | 3108 | end |
---|
| 3109 | end |
---|
| 3110 | close(h); |
---|
| 3111 | end |
---|
| 3112 | end |
---|
| 3113 | |
---|
[12] | 3114 | %------------------------------------------------------------------------ |
---|
[227] | 3115 | % --- determine the list of index pairs of processing file |
---|
| 3116 | function [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
| 3117 | find_pair_indices(handles,ref_i,ref_j,mode) |
---|
| 3118 | %------------------------------------------------------------------------ |
---|
| 3119 | |
---|
| 3120 | list_civ1=get(handles.list_pair_civ1,'String'); |
---|
| 3121 | index_civ1=get(handles.list_pair_civ1,'Value'); |
---|
| 3122 | str_civ1=list_civ1{index_civ1};%string defining the image pairs for civ1 |
---|
| 3123 | if isempty(str_civ1)||isequal(str_civ1,'') |
---|
| 3124 | msgbox_uvmat('ERROR','no image pair selected for civ1') |
---|
| 3125 | return |
---|
| 3126 | end |
---|
| 3127 | list_civ2=get(handles.list_pair_civ2,'String'); |
---|
| 3128 | index_civ2=get(handles.list_pair_civ2,'Value'); |
---|
| 3129 | if index_civ2>length(list_civ2) |
---|
| 3130 | list_civ2=list_civ1; |
---|
| 3131 | index_civ2=index_civ1; |
---|
| 3132 | end |
---|
| 3133 | str_civ2=list_civ2{index_civ2};%string defining the image pairs for civ2 |
---|
| 3134 | |
---|
| 3135 | if isequal (mode,'series(Di)') |
---|
| 3136 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 3137 | num1_civ1=ref_i-floor(index_civ1/2)*ones(size(ref_i));% set of first image numbers |
---|
| 3138 | num2_civ1=ref_i+ceil(index_civ1/2)*ones(size(ref_i)); |
---|
| 3139 | num_a_civ1=ref_j; |
---|
| 3140 | num_b_civ1=ref_j; |
---|
[229] | 3141 | num1_civ2=ref_i-floor(index_civ2/2)*ones(size(ref_i)); |
---|
[227] | 3142 | num2_civ2=ref_i+ceil(index_civ2/2)*ones(size(ref_i)); |
---|
| 3143 | num_a_civ2=ref_j; |
---|
| 3144 | num_b_civ2=ref_j; |
---|
| 3145 | |
---|
| 3146 | % adjust the first and last field number |
---|
| 3147 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 3148 | if isnan(lastfield) |
---|
| 3149 | indsel=find((num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
| 3150 | else |
---|
| 3151 | indsel=find((num2_civ1 <= lastfield)&(num2_civ2 <= lastfield)&(num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
| 3152 | end |
---|
| 3153 | if length(indsel)>=1 |
---|
| 3154 | firstind=indsel(1); |
---|
| 3155 | lastind=indsel(end); |
---|
| 3156 | set(handles.first_i,'String',num2str(ref_i(firstind)))%update the display of first and last fields |
---|
| 3157 | set(handles.last_i,'String',num2str(ref_i(lastind))) |
---|
| 3158 | ref_i=ref_i(indsel); |
---|
| 3159 | num1_civ1=num1_civ1(indsel); |
---|
| 3160 | num1_civ2=num1_civ2(indsel); |
---|
| 3161 | num2_civ1=num2_civ1(indsel); |
---|
| 3162 | num2_civ2=num2_civ2(indsel); |
---|
| 3163 | end |
---|
| 3164 | elseif isequal (mode,'series(Dj)') |
---|
| 3165 | lastfield_j=str2double(get(handles.nb_field2,'String')); |
---|
| 3166 | num1_civ1=ref_i;% set of first image numbers |
---|
| 3167 | num2_civ1=ref_i; |
---|
| 3168 | num_a_civ1=ref_j-floor(index_civ1/2)*ones(size(ref_j)); |
---|
| 3169 | num_b_civ1=ref_j+ceil(index_civ1/2)*ones(size(ref_j)); |
---|
| 3170 | num1_civ2=ref_i; |
---|
| 3171 | num2_civ2=ref_i; |
---|
| 3172 | num_a_civ2=ref_j-floor(index_civ2/2)*ones(size(ref_j)); |
---|
| 3173 | num_b_civ2=ref_j+ceil(index_civ2/2)*ones(size(ref_j)); |
---|
| 3174 | % adjust the first and last field number |
---|
| 3175 | if isnan(lastfield_j) |
---|
| 3176 | indsel=find((num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
| 3177 | else |
---|
| 3178 | indsel=find((num_b_civ1 <= lastfield_j)&(num_b_civ2 <= lastfield_j)&(num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
| 3179 | end |
---|
| 3180 | if length(indsel)>=1 |
---|
| 3181 | firstind=indsel(1); |
---|
| 3182 | lastind=indsel(end); |
---|
| 3183 | set(handles.first_j,'String',num2str(ref_j(firstind)))%update the display of first and last fields |
---|
| 3184 | set(handles.last_j,'String',num2str(ref_j(lastind))) |
---|
| 3185 | ref_j=ref_j(indsel); |
---|
| 3186 | num_a_civ1=num_a_civ1(indsel); |
---|
| 3187 | num_b_civ1=num_b_civ1(indsel); |
---|
| 3188 | num_a_civ2=num_a_civ2(indsel); |
---|
| 3189 | num_b_civ2=num_b_civ2(indsel); |
---|
| 3190 | end |
---|
| 3191 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
| 3192 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 3193 | num1_civ1=ref_i; |
---|
| 3194 | num2_civ1=ref_i; |
---|
| 3195 | num_a_civ1=displ_num(1,index_civ1); |
---|
| 3196 | num_b_civ1=displ_num(2,index_civ1); |
---|
| 3197 | num1_civ2=ref_i; |
---|
| 3198 | num2_civ2=ref_i; |
---|
| 3199 | num_a_civ2=displ_num(1,index_civ2); |
---|
| 3200 | num_b_civ2=displ_num(2,index_civ2); |
---|
| 3201 | elseif isequal(mode,'displacement') |
---|
| 3202 | num1_civ1=ref_i; |
---|
| 3203 | num2_civ1=ref_i; |
---|
| 3204 | num_a_civ1=ref_j; |
---|
| 3205 | num_b_civ1=ref_j; |
---|
| 3206 | num1_civ2=ref_i; |
---|
| 3207 | num2_civ2=ref_i; |
---|
| 3208 | num_a_civ2=ref_j; |
---|
| 3209 | num_b_civ2=ref_j; |
---|
| 3210 | end |
---|
| 3211 | |
---|
| 3212 | |
---|
| 3213 | %------------------------------------------------------------------------ |
---|
[12] | 3214 | % --- PATCH |
---|
[274] | 3215 | function cmd=cmd_patch(filename_nc,Param,PatchBin) |
---|
[12] | 3216 | %------------------------------------------------------------------------ |
---|
[224] | 3217 | namelog=[filename_nc(1:end-3) '_patch.log']; |
---|
[274] | 3218 | |
---|
[272] | 3219 | % if test_interp==0 |
---|
[163] | 3220 | if isunix |
---|
[274] | 3221 | cmd=[PatchBin... |
---|
| 3222 | ' -f ' filename_nc ' -m ' num2str(Param.Nx)... |
---|
| 3223 | ' -n ' num2str(Param.Ny) ' -ro ' num2str(Param.SmoothingParam)... |
---|
| 3224 | ' -nopt ' num2str(Param.SubdomainSize) ... |
---|
| 3225 | ' > ' namelog ' 2>&1'] % redirect standard output to the log file |
---|
[163] | 3226 | else |
---|
[272] | 3227 | cmd=['"' param.global.PatchBin... |
---|
[274] | 3228 | '" -f "' filename_nc '" -m ' param.Patch1.Nx... |
---|
| 3229 | ' -n ' param.Patch1.Ny ' -ro ' param.Patch1.SmoothParam... |
---|
| 3230 | ' -nopt ' Param.Patch1.SubdomainSize ... |
---|
[163] | 3231 | ' > "' namelog '" 2>&1']; % redirect standard output to the log file |
---|
| 3232 | end |
---|
[272] | 3233 | % else %nouveau programme patch |
---|
| 3234 | % cmd=[PatchBin ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ... |
---|
| 3235 | % ' -max ' thresh_value ' -nopt ' subdomain_patch ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
| 3236 | % end |
---|
| 3237 | cmd=regexprep(cmd,'\\','\\\\'); |
---|
[274] | 3238 | |
---|
[12] | 3239 | %------------------------------------------------------------------------ |
---|
| 3240 | % --- STEREO Interp |
---|
[67] | 3241 | function cmd=RUN_STINTERP(stinterpBin,filename_A_nc,filename_B_nc,filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,xmlA,xmlB) |
---|
[12] | 3242 | %------------------------------------------------------------------------ |
---|
[224] | 3243 | namelog=[filename_nc(1:end-3) '_stinterp.log']; |
---|
[67] | 3244 | cmd=[stinterpBin ' -f1 ' filename_A_nc ' -f2 ' filename_B_nc ' -f ' filename_nc ... |
---|
[2] | 3245 | ' -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 |
---|
| 3246 | |
---|
[12] | 3247 | %------------------------------------------------------------------------ |
---|
[2] | 3248 | % --- Executes on button press in CIV1. |
---|
| 3249 | function CIV1_Callback(hObject, eventdata, handles) |
---|
[12] | 3250 | %------------------------------------------------------------------------ |
---|
[273] | 3251 | state=get(handles.CIV1,'Value'); |
---|
| 3252 | enable_civ1(handles,state) |
---|
| 3253 | if state |
---|
[2] | 3254 | enable_pair1(handles,'on') |
---|
| 3255 | end |
---|
| 3256 | find_netcpair_civ1(hObject, eventdata, handles); |
---|
| 3257 | |
---|
[12] | 3258 | %------------------------------------------------------------------------ |
---|
[2] | 3259 | % --- Executes on button press in FIX1. |
---|
| 3260 | function FIX1_Callback(hObject, eventdata, handles) |
---|
[12] | 3261 | %------------------------------------------------------------------------ |
---|
[2] | 3262 | enable_fix1(handles,get(handles.FIX1,'Value')) |
---|
| 3263 | |
---|
[12] | 3264 | %------------------------------------------------------------------------ |
---|
[2] | 3265 | % --- Executes on button press in PATCH1. |
---|
| 3266 | function PATCH1_Callback(hObject, eventdata, handles) |
---|
[12] | 3267 | %------------------------------------------------------------------------ |
---|
[273] | 3268 | enable_patch1(handles,get(handles.PATCH1,'Value')) |
---|
[2] | 3269 | |
---|
[12] | 3270 | %------------------------------------------------------------------------ |
---|
[2] | 3271 | % --- Executes on button press in CIV2. |
---|
| 3272 | function CIV2_Callback(hObject, eventdata, handles) |
---|
[12] | 3273 | %------------------------------------------------------------------------ |
---|
[2] | 3274 | state=get(handles.CIV2,'Value'); |
---|
| 3275 | enable_civ2(handles,state) |
---|
| 3276 | if state |
---|
| 3277 | find_netcpair_civ2(hObject, eventdata, handles) |
---|
| 3278 | enable_pair1(handles,'on') |
---|
| 3279 | end |
---|
| 3280 | |
---|
[12] | 3281 | %------------------------------------------------------------------------ |
---|
[2] | 3282 | % --- Executes on button press in FIX2. |
---|
| 3283 | function FIX2_Callback(hObject, eventdata, handles) |
---|
[12] | 3284 | %------------------------------------------------------------------------ |
---|
[273] | 3285 | state=get(handles.FIX2,'Value'); |
---|
| 3286 | enable_fix2(handles,state) |
---|
| 3287 | if state |
---|
| 3288 | find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files |
---|
[2] | 3289 | end |
---|
| 3290 | |
---|
[12] | 3291 | %------------------------------------------------------------------------ |
---|
[2] | 3292 | % --- Executes on button press in PATCH2. |
---|
| 3293 | function PATCH2_Callback(hObject, eventdata, handles) |
---|
[12] | 3294 | %------------------------------------------------------------------------ |
---|
[273] | 3295 | state=get(handles.PATCH2,'Value'); |
---|
| 3296 | enable_patch2(handles,state) |
---|
| 3297 | if state |
---|
| 3298 | find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files |
---|
[2] | 3299 | end |
---|
| 3300 | |
---|
[12] | 3301 | %------------------------------------------------------------------------ |
---|
| 3302 | function first_i_Callback(hObject, eventdata, handles) |
---|
| 3303 | %------------------------------------------------------------------------ |
---|
| 3304 | % last_i_Callback(hObject, eventdata, handles) |
---|
[137] | 3305 | first_i=str2double(get(handles.first_i,'String')); |
---|
[12] | 3306 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 3307 | % ref_i=ceil((first_i+last_i)/2); |
---|
| 3308 | set(handles.ref_i,'String', num2str(first_i))% reference index for pair dt = first index |
---|
[273] | 3309 | %set(handles.ref_i_civ2,'String', num2str(first_i))% reference index for pair dt = first index |
---|
[12] | 3310 | ref_i_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3311 | |
---|
[12] | 3312 | %------------------------------------------------------------------------ |
---|
| 3313 | function first_j_Callback(hObject, eventdata, handles) |
---|
| 3314 | %------------------------------------------------------------------------ |
---|
| 3315 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 3316 | set(handles.ref_j,'String', num2str(first_j))% reference index for pair dt = first index |
---|
| 3317 | ref_j_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3318 | |
---|
[12] | 3319 | %------------------------------------------------------------------------ |
---|
[273] | 3320 | % --- Executes on button press in SearchRange: determine the search range isx,isy |
---|
| 3321 | function SearchRange_Callback(hObject, eventdata, handles) |
---|
[12] | 3322 | %------------------------------------------------------------------------ |
---|
[2] | 3323 | %determine pair numbers |
---|
[273] | 3324 | if strcmp(get(handles.umin,'Visible'),'off') |
---|
| 3325 | set(handles.u_title,'Visible','on') |
---|
| 3326 | set(handles.v_title,'Visible','on') |
---|
| 3327 | set(handles.umin,'Visible','on') |
---|
| 3328 | set(handles.umax,'Visible','on') |
---|
| 3329 | set(handles.vmin,'Visible','on') |
---|
| 3330 | set(handles.vmax,'Visible','on') |
---|
| 3331 | set(handles.CoordUnit,'Visible','on') |
---|
| 3332 | set(handles.TimeUnit,'Visible','on') |
---|
| 3333 | set(handles.slash_title,'Visible','on') |
---|
| 3334 | set(handles.min_title,'Visible','on') |
---|
| 3335 | set(handles.max_title,'Visible','on') |
---|
| 3336 | set(handles.unit_title,'Visible','on') |
---|
| 3337 | else |
---|
| 3338 | get_search_range(hObject, eventdata, handles) |
---|
[2] | 3339 | end |
---|
| 3340 | |
---|
[12] | 3341 | %------------------------------------------------------------------------ |
---|
[273] | 3342 | % --- determine the search range isx,isy and shift |
---|
| 3343 | function get_search_range(hObject, eventdata, handles) |
---|
| 3344 | umin=str2double(get(handles.umin,'String')); |
---|
| 3345 | umax=str2double(get(handles.umax,'String')); |
---|
| 3346 | vmin=str2double(get(handles.umin,'String')); |
---|
| 3347 | vmax=str2double(get(handles.vmax,'String')); |
---|
| 3348 | %switch min_title and max_title in case of error |
---|
| 3349 | if umax<=umin |
---|
| 3350 | umin_old=umin; |
---|
| 3351 | umin=umax; |
---|
| 3352 | umax=umin_old; |
---|
| 3353 | set(handles.umin,'String', num2str(umin)) |
---|
| 3354 | set(handles.umax,'String', num2str(umax)) |
---|
| 3355 | end |
---|
| 3356 | if vmax<=vmin |
---|
| 3357 | vmin_old=vmin; |
---|
| 3358 | vmin=vmax; |
---|
| 3359 | vmax=vmin_old; |
---|
| 3360 | set(handles.vmin,'String', num2str(vmin)) |
---|
| 3361 | set(handles.vmax,'String', num2str(vmax)) |
---|
| 3362 | end |
---|
| 3363 | if ~(isnan(umin)||isnan(umax)||isnan(vmin)||isnan(vmax)) |
---|
| 3364 | list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs |
---|
| 3365 | index=get(handles.list_pair_civ1,'Value'); |
---|
| 3366 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 3367 | time=get(handles.ImaDoc,'UserData'); %get the set of times |
---|
| 3368 | pxcm_xy=get(handles.SearchRange,'UserData'); |
---|
| 3369 | pxcmx=pxcm_xy(1); |
---|
| 3370 | pxcmy=pxcm_xy(2); |
---|
| 3371 | mode_list=get(handles.CivMode,'String'); |
---|
| 3372 | mode_value=get(handles.CivMode,'Value'); |
---|
| 3373 | mode=mode_list{mode_value}; |
---|
| 3374 | if isequal (mode, 'series(Di)' ) |
---|
| 3375 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
| 3376 | num1=ref_i-floor(index/2);% first image numbers |
---|
| 3377 | num2=ref_i+ceil(index/2); |
---|
| 3378 | num_a=1; |
---|
| 3379 | num_b=1; |
---|
| 3380 | elseif isequal (mode, 'series(Dj)') |
---|
| 3381 | num1=1; |
---|
| 3382 | num2=1; |
---|
| 3383 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
| 3384 | num_a=ref_j-floor(index/2);% first image numbers |
---|
| 3385 | num_b=ref_j+ceil(index/2); |
---|
| 3386 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
| 3387 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
| 3388 | num1=ref_i; |
---|
| 3389 | num2=ref_i; |
---|
| 3390 | num_a=displ_num(1,index); |
---|
| 3391 | num_b=displ_num(2,index); |
---|
| 3392 | end |
---|
| 3393 | dt=time(num2,num_b)-time(num1,num_a); |
---|
| 3394 | ibx=str2double(get(handles.ibx,'String')); |
---|
| 3395 | iby=str2double(get(handles.iby,'String')); |
---|
| 3396 | umin=dt*pxcmx*umin; |
---|
| 3397 | umax=dt*pxcmx*umax; |
---|
| 3398 | vmin=dt*pxcmy*vmin; |
---|
| 3399 | vmax=dt*pxcmy*vmax; |
---|
| 3400 | shiftx=round((umin+umax)/2); |
---|
| 3401 | shifty=round((vmin+vmax)/2); |
---|
| 3402 | isx=(umax+2-shiftx)*2+ibx; |
---|
| 3403 | isx=2*ceil(isx/2)+1; |
---|
| 3404 | isy=(vmax+2-shifty)*2+iby; |
---|
| 3405 | isy=2*ceil(isy/2)+1; |
---|
| 3406 | set(handles.shiftx,'String',num2str(shiftx)); |
---|
| 3407 | set(handles.shifty,'String',num2str(shifty)); |
---|
| 3408 | set(handles.isx,'String',num2str(isx)); |
---|
| 3409 | set(handles.isy,'String',num2str(isy)); |
---|
| 3410 | end |
---|
| 3411 | |
---|
| 3412 | %------------------------------------------------------------------------ |
---|
[12] | 3413 | % --- Executes on carriage return on the subdir civ1 edit window |
---|
[2] | 3414 | function subdir_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 3415 | %------------------------------------------------------------------------ |
---|
[2] | 3416 | subdir=get(handles.subdir_civ1,'String'); |
---|
[273] | 3417 | set(handles.subdir_civ2,'String',subdir);% set civ2 directory the same as civ1 by default |
---|
| 3418 | menu_str=get(handles.list_subdir_civ1,'String');% read the list of subdirectories for update |
---|
| 3419 | ichoice=find(strcmp(subdir,menu_str),1); |
---|
| 3420 | if isempty(ichoice) |
---|
| 3421 | ilist=numel(menu_str); %select 'new...' in the menu |
---|
| 3422 | else |
---|
| 3423 | ilist=ichoice; |
---|
| 3424 | end |
---|
| 3425 | set(handles.list_subdir_civ1,'Value',ilist)% select the selected subdir in the menu |
---|
[112] | 3426 | if get(handles.CIV1,'Value')==0 |
---|
[2] | 3427 | find_netcpair_civ1(hObject, eventdata, handles); %update the list of available pairs from netcdf files in the new directory |
---|
| 3428 | end |
---|
| 3429 | |
---|
[12] | 3430 | %------------------------------------------------------------------------ |
---|
| 3431 | % --- Executes on carriage return on the subdir civ1 edit window |
---|
[2] | 3432 | function subdir_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 3433 | %------------------------------------------------------------------------ |
---|
[273] | 3434 | subdir=get(handles.subdir_civ1,'String'); |
---|
| 3435 | menu_str=get(handles.list_subdir_civ2,'String');% read the list of subdirectories for update |
---|
| 3436 | ichoice=find(strcmp(subdir,menu_str),1); |
---|
| 3437 | if isempty(ichoice) |
---|
| 3438 | ilist=numel(menu_str); %select 'new...' in the menu |
---|
| 3439 | else |
---|
| 3440 | ilist=ichoice; |
---|
| 3441 | end |
---|
| 3442 | set(handles.list_subdir_civ2,'Value',ilist)% select the selected subdir in the menu |
---|
[2] | 3443 | %update the list of available pairs from netcdf files in the new directory |
---|
[273] | 3444 | if ~get(handles.CIV2,'Value') && ~get(handles.CIV1,'Value') && ~get(handles.FIX1,'Value') && ~get(handles.PATCH1,'Value') |
---|
[2] | 3445 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 3446 | end |
---|
| 3447 | |
---|
[12] | 3448 | %------------------------------------------------------------------------ |
---|
[133] | 3449 | % --- Executes on button press in get_mask_civ1: select box for mask option |
---|
[2] | 3450 | function get_mask_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 3451 | %------------------------------------------------------------------------ |
---|
[252] | 3452 | maskval=get(handles.get_mask_civ1,'Value') |
---|
[2] | 3453 | if isequal(maskval,0) |
---|
| 3454 | set(handles.mask_civ1,'String','') |
---|
| 3455 | else |
---|
| 3456 | mask_displ='no mask'; %default |
---|
[71] | 3457 | filebase=get(handles.RootName,'String'); |
---|
[2] | 3458 | [ nbslice_mask, flag_mask]=get_mask(filebase,handles); |
---|
| 3459 | if isequal(flag_mask,1) |
---|
[112] | 3460 | mask_displ=[num2str(nbslice_mask) 'mask']; |
---|
[2] | 3461 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[112] | 3462 | common_path=fileparts(filebase); |
---|
| 3463 | filebase_a=fullfile(common_path,get(handles.RootName_1,'String')); |
---|
| 3464 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
| 3465 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice_mask) |
---|
| 3466 | mask_displ='no mask'; |
---|
| 3467 | end |
---|
[2] | 3468 | end |
---|
| 3469 | if isequal(mask_displ,'no mask') |
---|
[12] | 3470 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3471 | {'*.png', ' (*.png)'; |
---|
| 3472 | '*.png', '.png files '; ... |
---|
| 3473 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3474 | 'Pick a mask file *.png',filebase); |
---|
| 3475 | mask_displ=fullfile(PathName,FileName); |
---|
[12] | 3476 | if ~exist(mask_displ,'file') |
---|
| 3477 | mask_displ='no mask'; |
---|
| 3478 | end |
---|
| 3479 | end |
---|
| 3480 | if isequal(mask_displ,'no mask') |
---|
[2] | 3481 | set(handles.get_mask_civ1,'Value',0) |
---|
| 3482 | set(handles.get_mask_fix1,'Value',0) |
---|
| 3483 | set(handles.get_mask_civ2,'Value',0) |
---|
| 3484 | set(handles.get_mask_fix2,'Value',0) |
---|
| 3485 | else |
---|
| 3486 | set(handles.get_mask_fix1,'Value',1) |
---|
| 3487 | set(handles.get_mask_fix2,'Value',1) |
---|
| 3488 | end |
---|
| 3489 | set(handles.mask_civ1,'String',mask_displ) |
---|
| 3490 | set(handles.mask_fix1,'String',mask_displ) |
---|
| 3491 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 3492 | set(handles.mask_fix2,'String',mask_displ) |
---|
| 3493 | end |
---|
[133] | 3494 | set(handles.get_mask_civ2,'Value',maskval)%update the civ2 mask with the same option as civ1 |
---|
[2] | 3495 | |
---|
[12] | 3496 | %------------------------------------------------------------------------ |
---|
[2] | 3497 | % --- Executes on button press in get_mask_fix1. |
---|
| 3498 | function get_mask_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 3499 | %------------------------------------------------------------------------ |
---|
[2] | 3500 | maskval=get(handles.get_mask_fix1,'Value'); |
---|
| 3501 | if isequal(maskval,0) |
---|
| 3502 | set(handles.mask_fix1,'String','') |
---|
| 3503 | else |
---|
[112] | 3504 | mask_displ='no mask'; %default |
---|
| 3505 | filebase=get(handles.RootName,'String'); |
---|
| 3506 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3507 | if isequal(flag_mask,1) |
---|
| 3508 | mask_displ=[num2str(nbslice) 'mask']; |
---|
| 3509 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[71] | 3510 | filebase_a=get(handles.RootName_1,'String'); |
---|
[2] | 3511 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[229] | 3512 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
[2] | 3513 | mask_displ='no mask'; |
---|
| 3514 | end |
---|
[112] | 3515 | end |
---|
| 3516 | if isequal(mask_displ,'no mask') |
---|
| 3517 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3518 | {'*.png', ' (*.png)'; |
---|
[12] | 3519 | '*.png', '.png files '; ... |
---|
| 3520 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3521 | 'Pick a mask file *.png',filebase); |
---|
[112] | 3522 | mask_displ=fullfile(PathName,FileName); |
---|
| 3523 | if ~exist(mask_displ,'file') |
---|
| 3524 | mask_displ='no mask'; |
---|
| 3525 | end |
---|
[12] | 3526 | end |
---|
[112] | 3527 | if isequal(mask_displ,'no mask') |
---|
| 3528 | set(handles.get_mask_fix1,'Value',0) |
---|
| 3529 | set(handles.get_mask_civ2,'Value',0) |
---|
| 3530 | set(handles.get_mask_fix2,'Value',0) |
---|
| 3531 | else |
---|
| 3532 | %set(handles.get_mask_civ2,'Value',1) |
---|
| 3533 | set(handles.get_mask_fix2,'Value',1) |
---|
| 3534 | end |
---|
| 3535 | set(handles.mask_fix1,'String',mask_displ) |
---|
| 3536 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 3537 | set(handles.mask_fix2,'String',mask_displ) |
---|
[12] | 3538 | end |
---|
| 3539 | |
---|
| 3540 | %------------------------------------------------------------------------ |
---|
[133] | 3541 | % --- Executes on button press in get_mask_civ2: select box for mask option |
---|
[2] | 3542 | function get_mask_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 3543 | %------------------------------------------------------------------------ |
---|
[2] | 3544 | maskval=get(handles.get_mask_civ2,'Value'); |
---|
| 3545 | if isequal(maskval,0) |
---|
| 3546 | set(handles.mask_civ2,'String','') |
---|
| 3547 | else |
---|
[112] | 3548 | mask_displ='no mask'; %default |
---|
| 3549 | filebase=get(handles.RootName,'String'); |
---|
| 3550 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3551 | if isequal(flag_mask,1) |
---|
| 3552 | mask_displ=[num2str(nbslice) 'mask']; |
---|
| 3553 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[71] | 3554 | filebase_a=get(handles.RootName_1,'String'); |
---|
[2] | 3555 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[229] | 3556 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
[2] | 3557 | mask_displ='no mask'; |
---|
| 3558 | end |
---|
[112] | 3559 | end |
---|
| 3560 | if isequal(mask_displ,'no mask') |
---|
| 3561 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3562 | {'*.png', ' (*.png)'; |
---|
[12] | 3563 | '*.png', '.png files '; ... |
---|
| 3564 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3565 | 'Pick a mask file *.png',filebase); |
---|
[112] | 3566 | mask_displ=fullfile(PathName,FileName); |
---|
| 3567 | if ~exist(mask_displ,'file') |
---|
| 3568 | mask_displ='no mask'; |
---|
| 3569 | end |
---|
[12] | 3570 | end |
---|
[112] | 3571 | if isequal(mask_displ,'no mask') |
---|
| 3572 | set(handles.get_mask_civ2,'Value',0) |
---|
| 3573 | set(handles.get_mask_fix2,'Value',0) |
---|
| 3574 | else |
---|
| 3575 | set(handles.get_mask_fix2,'Value',1) |
---|
| 3576 | end |
---|
| 3577 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 3578 | set(handles.mask_fix2,'String',mask_displ) |
---|
[12] | 3579 | end |
---|
| 3580 | |
---|
| 3581 | %------------------------------------------------------------------------ |
---|
[2] | 3582 | % --- Executes on button press in get_mask_fix2. |
---|
| 3583 | function get_mask_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 3584 | %------------------------------------------------------------------------ |
---|
[2] | 3585 | maskval=get(handles.get_mask_fix2,'Value'); |
---|
| 3586 | if isequal(maskval,0) |
---|
| 3587 | set(handles.mask_fix2,'String','') |
---|
| 3588 | else |
---|
[12] | 3589 | mask_displ='no mask'; %default |
---|
[71] | 3590 | filebase=get(handles.RootName,'String'); |
---|
[12] | 3591 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3592 | if isequal(flag_mask,1) |
---|
[112] | 3593 | mask_displ=[num2str(nbslice) 'mask']; |
---|
[12] | 3594 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[112] | 3595 | filebase_a=get(handles.RootName_1,'String'); |
---|
| 3596 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[229] | 3597 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
[112] | 3598 | mask_displ='no mask'; |
---|
| 3599 | end |
---|
[12] | 3600 | end |
---|
| 3601 | if isequal(mask_displ,'no mask') |
---|
| 3602 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3603 | {'*.png', ' (*.png)'; |
---|
| 3604 | '*.png', '.png files '; ... |
---|
| 3605 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3606 | 'Pick a mask file *.png',filebase); |
---|
| 3607 | mask_displ=fullfile(PathName,FileName); |
---|
[12] | 3608 | if ~exist(mask_displ,'file') |
---|
[2] | 3609 | mask_displ='no mask'; |
---|
| 3610 | end |
---|
[12] | 3611 | end |
---|
| 3612 | if isequal(mask_displ,'no mask') |
---|
| 3613 | set(handles.get_mask_fix2,'Value',0) |
---|
[112] | 3614 | end |
---|
[12] | 3615 | set(handles.mask_fix2,'String',mask_displ) |
---|
[2] | 3616 | end |
---|
| 3617 | |
---|
[12] | 3618 | %------------------------------------------------------------------------ |
---|
| 3619 | % --- function called to look for mask files |
---|
[2] | 3620 | function [nbslice, flag_mask]=get_mask(filebase,handles) |
---|
[12] | 3621 | %------------------------------------------------------------------------ |
---|
[112] | 3622 | %detect mask files, images with appropriate file base |
---|
[2] | 3623 | %[filebase '_' xx 'mask'], xx=nbslice |
---|
| 3624 | %flag_mask=1 indicates detection |
---|
| 3625 | |
---|
| 3626 | flag_mask=0;%default |
---|
| 3627 | nbslice=1; |
---|
| 3628 | |
---|
| 3629 | % subdir=get(handles.subdir_civ1,'String'); |
---|
| 3630 | [Path,Name]=fileparts(filebase); |
---|
[12] | 3631 | if ~isdir(Path) |
---|
| 3632 | msgbox_uvmat('ERROR','no path for input files') |
---|
| 3633 | return |
---|
| 3634 | end |
---|
[272] | 3635 | % currentdir=pwd; |
---|
| 3636 | % cd(Path);%move in the dir of the root name filebase |
---|
| 3637 | maskfiles=dir(fullfile(Path,[Name '_*mask_*.png']));%look for mask files |
---|
| 3638 | % cd(currentdir);%come back to the current working directory |
---|
[12] | 3639 | if ~isempty(maskfiles) |
---|
[112] | 3640 | % msgbox_uvmat('ERROR','no mask available, to create it use Tools/Make mask in the upper menu bar of uvmat') |
---|
| 3641 | % else |
---|
[2] | 3642 | flag_mask=1; |
---|
| 3643 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 3644 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 3645 | Namedouble=double(Name); |
---|
| 3646 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 3647 | ind_mask=findstr('mask',Name); |
---|
| 3648 | i=ind_mask-1; |
---|
[137] | 3649 | while val(i)==0 && i>0 |
---|
[112] | 3650 | i=i-1; |
---|
[2] | 3651 | end |
---|
[137] | 3652 | nbslice=str2double(Name(i+1:ind_mask-1)); |
---|
| 3653 | if ~isnan(nbslice) && Name(i)=='_' |
---|
[112] | 3654 | flag_mask=1; |
---|
[2] | 3655 | else |
---|
[112] | 3656 | msgbox_uvmat('ERROR',['bad mask file ' Name ext ' found in ' Path2]) |
---|
| 3657 | return |
---|
| 3658 | nbslice=1; |
---|
[2] | 3659 | end |
---|
[112] | 3660 | end |
---|
[2] | 3661 | |
---|
[12] | 3662 | %------------------------------------------------------------------------ |
---|
| 3663 | % --- function called to look for grid files |
---|
[2] | 3664 | function [nbslice, flag_mask]=get_grid(filebase,handles) |
---|
[12] | 3665 | %------------------------------------------------------------------------ |
---|
[2] | 3666 | flag_mask=0;%default |
---|
| 3667 | nbslice=1; |
---|
| 3668 | [Path,Name]=fileparts(filebase); |
---|
| 3669 | currentdir=pwd; |
---|
| 3670 | cd(Path);%move in the dir of the root name filebase |
---|
| 3671 | maskfiles=dir([Name '_*grid_*.grid']);%look for mask files |
---|
| 3672 | cd(currentdir);%come back to the current working directory |
---|
| 3673 | if ~isempty(maskfiles) |
---|
| 3674 | flag_mask=1; |
---|
| 3675 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 3676 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 3677 | Namedouble=double(Name); |
---|
| 3678 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 3679 | ind_mask=findstr('grid',Name); |
---|
| 3680 | i=ind_mask-1; |
---|
[137] | 3681 | while val(i)==0 && i>0 |
---|
[112] | 3682 | i=i-1; |
---|
[2] | 3683 | end |
---|
[137] | 3684 | nbslice=str2double(Name(i+1:ind_mask-1)); |
---|
| 3685 | if ~isnan(nbslice) && Name(i)=='_' |
---|
[112] | 3686 | flag_mask=1; |
---|
[2] | 3687 | else |
---|
[112] | 3688 | msgbox_uvmat('ERROR',['bad grid file ' Name ext ' found in ' Path2]) |
---|
| 3689 | return |
---|
| 3690 | nbslice=1; |
---|
[2] | 3691 | end |
---|
[12] | 3692 | end |
---|
[2] | 3693 | |
---|
[12] | 3694 | %------------------------------------------------------------------------ |
---|
| 3695 | % --- transform numbers to letters |
---|
[122] | 3696 | function str=num2stra(num,nom_type) |
---|
[12] | 3697 | %------------------------------------------------------------------------ |
---|
[122] | 3698 | if isempty(nom_type) |
---|
| 3699 | str=''; |
---|
| 3700 | elseif strcmp(nom_type(end),'a') |
---|
[2] | 3701 | str=char(96+num); |
---|
[122] | 3702 | elseif strcmp(nom_type(end),'A') |
---|
| 3703 | str=char(96+num); |
---|
| 3704 | elseif isempty(nom_type(2:end))%a single index |
---|
[2] | 3705 | str=''; |
---|
| 3706 | else |
---|
| 3707 | str=num2str(num); |
---|
| 3708 | end |
---|
[12] | 3709 | |
---|
| 3710 | %------------------------------------------------------------------------ |
---|
[2] | 3711 | % --- Executes on button press in list_subdir_civ1. |
---|
| 3712 | function list_subdir_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 3713 | %------------------------------------------------------------------------ |
---|
[2] | 3714 | list_subdir_civ1=get(handles.list_subdir_civ1,'String'); |
---|
| 3715 | val=get(handles.list_subdir_civ1,'Value'); |
---|
[273] | 3716 | subdir=list_subdir_civ1{val}; |
---|
| 3717 | if strcmp(subdir,'new...') |
---|
| 3718 | subdir='CIV'; %default subdirectory |
---|
[2] | 3719 | end |
---|
[273] | 3720 | set(handles.subdir_civ1,'String',subdir); |
---|
| 3721 | find_netcpair_civ1(hObject, eventdata, handles) |
---|
| 3722 | % end |
---|
[2] | 3723 | |
---|
[12] | 3724 | %------------------------------------------------------------------------ |
---|
[2] | 3725 | % --- Executes on button press in list_subdir_civ2. |
---|
| 3726 | function list_subdir_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 3727 | %------------------------------------------------------------------------ |
---|
[2] | 3728 | list_subdir_civ2=get(handles.list_subdir_civ2,'String'); |
---|
| 3729 | val=get(handles.list_subdir_civ2,'Value'); |
---|
[273] | 3730 | subdir=list_subdir_civ2{val}; |
---|
| 3731 | if strcmp(subdir,'new...') |
---|
| 3732 | subdir='CIV'; %default subdirectory |
---|
[2] | 3733 | end |
---|
[273] | 3734 | set(handles.subdir_civ2,'String',subdir); |
---|
| 3735 | % set(handles.list_subdir_civ2,'Value',1); |
---|
[2] | 3736 | |
---|
[273] | 3737 | |
---|
[12] | 3738 | %------------------------------------------------------------------------ |
---|
[2] | 3739 | % --- Executes on button press in browse_gridciv1. |
---|
| 3740 | function browse_gridciv1_Callback(hObject, eventdata, handles) |
---|
[12] | 3741 | %------------------------------------------------------------------------ |
---|
[2] | 3742 | value=get(handles.browse_gridciv1,'Value'); |
---|
| 3743 | testgrid=0; |
---|
| 3744 | if value |
---|
[112] | 3745 | filebase=get(handles.RootName,'String'); |
---|
[39] | 3746 | [nbslice, flag_grid]=get_grid(filebase,handles); |
---|
[2] | 3747 | if isequal(flag_grid,1) |
---|
[112] | 3748 | filegrid=[num2str(nbslice) 'grid']; |
---|
| 3749 | testgrid=1; |
---|
| 3750 | else |
---|
[2] | 3751 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3752 | {'*.grid', ' (*.grid)'; |
---|
| 3753 | '*.grid', '.grid files '; ... |
---|
| 3754 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3755 | 'Pick a file',filebase); |
---|
[2] | 3756 | filegrid=fullfile(PathName,FileName); |
---|
| 3757 | if ~(isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file')) |
---|
| 3758 | testgrid=1; |
---|
| 3759 | end |
---|
[112] | 3760 | end |
---|
[2] | 3761 | end |
---|
| 3762 | if testgrid |
---|
[112] | 3763 | set(handles.browse_gridciv2,'Value',1) |
---|
| 3764 | set(handles.get_gridpatch1,'Value',1) |
---|
| 3765 | set(handles.get_gridpatch2,'Value',1) |
---|
| 3766 | set(handles.dx_civ1,'Visible','off'); |
---|
| 3767 | set(handles.dy_civ1,'Visible','off'); |
---|
| 3768 | set(handles.dx_civ2,'Visible','off'); |
---|
| 3769 | set(handles.dy_civ2,'Visible','off'); |
---|
| 3770 | set(handles.grid_civ1,'String',filegrid) |
---|
| 3771 | set(handles.grid_patch1,'String',filegrid) |
---|
| 3772 | set(handles.grid_civ2,'String',filegrid) |
---|
| 3773 | set(handles.grid_patch2,'String',filegrid) |
---|
| 3774 | else |
---|
| 3775 | set(handles.browse_gridciv1,'Value',0); |
---|
| 3776 | set(handles.browse_gridciv2,'Value',0); |
---|
| 3777 | set(handles.get_gridpatch1,'Value',0) |
---|
| 3778 | set(handles.get_gridpatch2,'Value',0) |
---|
| 3779 | set(handles.dx_civ1,'Visible','on'); |
---|
| 3780 | set(handles.dy_civ1,'Visible','on'); |
---|
| 3781 | set(handles.dx_civ2,'Visible','on'); |
---|
| 3782 | set(handles.dy_civ2,'Visible','on'); |
---|
| 3783 | set(handles.grid_civ1,'String','') |
---|
| 3784 | set(handles.grid_patch1,'String','') |
---|
| 3785 | set(handles.grid_civ2,'String','') |
---|
| 3786 | set(handles.grid_patch2,'String','') |
---|
[2] | 3787 | end |
---|
| 3788 | |
---|
[12] | 3789 | %------------------------------------------------------------------------ |
---|
[2] | 3790 | % --- Executes on button press in browse_gridciv1. |
---|
| 3791 | function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
[12] | 3792 | %------------------------------------------------------------------------ |
---|
[2] | 3793 | value=get(handles.browse_gridciv2,'Value'); |
---|
| 3794 | if value |
---|
[112] | 3795 | filebase=get(handles.RootName,'String'); |
---|
[39] | 3796 | [nbslice, flag_grid]=get_grid(filebase,handles); |
---|
[2] | 3797 | if isequal(flag_grid,1) |
---|
| 3798 | mask_displ=[num2str(nbslice) 'grid']; |
---|
| 3799 | set(handles.grid_civ2,'String',mask_displ) |
---|
| 3800 | set(handles.dx_civ2,'Visible','off'); |
---|
| 3801 | set(handles.dy_civ2,'Visible','off'); |
---|
[112] | 3802 | else |
---|
[2] | 3803 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3804 | {'*.grid', ' (*.grid)'; |
---|
| 3805 | '*.grid', '.grid files '; ... |
---|
| 3806 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3807 | 'Pick a file',filebase); |
---|
[2] | 3808 | filegrid=fullfile(PathName,FileName); |
---|
[229] | 3809 | if isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file') |
---|
[2] | 3810 | set(handles.browse_gridciv2,'Value',0); |
---|
| 3811 | set(handles.grid_civ2,'string',''); |
---|
| 3812 | set(handles.dx_civ2,'Visible','on'); |
---|
| 3813 | set(handles.dy_civ2,'Visible','on'); |
---|
| 3814 | set(handles.grid_civ2,'string',''); |
---|
| 3815 | else |
---|
| 3816 | set(handles.grid_civ2,'string',filegrid); |
---|
| 3817 | set(handles.dx_civ2,'Visible','off'); |
---|
| 3818 | set(handles.dy_civ2,'Visible','off'); |
---|
| 3819 | set(handles.grid_civ2,'string',filegrid); |
---|
| 3820 | end |
---|
| 3821 | end |
---|
| 3822 | else |
---|
| 3823 | set(handles.grid_civ2,'string',''); |
---|
[112] | 3824 | set(handles.dx_civ2,'Visible','on'); |
---|
| 3825 | set(handles.dy_civ2,'Visible','on'); |
---|
| 3826 | set(handles.grid_civ2,'string',''); |
---|
[2] | 3827 | end |
---|
| 3828 | |
---|
| 3829 | % % --- Executes on button press in browse_gridciv2. |
---|
| 3830 | % function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
[112] | 3831 | % |
---|
[71] | 3832 | % filebase=get(handles.RootName,'String'); |
---|
[2] | 3833 | % [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3834 | % {'*.grid', ' (*.grid)'; |
---|
| 3835 | % '*.grid', '.grid files '; ... |
---|
| 3836 | % '*.*', 'All Files (*.*)'}, ... |
---|
| 3837 | % 'Pick a file',filebase); |
---|
| 3838 | % filegrid=fullfile(PathName,FileName); |
---|
| 3839 | % set(handles.grid_civ2,'string',filegrid); |
---|
| 3840 | % set(handles.dx_civ2,'String',' '); |
---|
| 3841 | % set(handles.dy_civ2,'String',' '); |
---|
| 3842 | % % set(handles.grid_patch2,'string',filegrid); |
---|
| 3843 | |
---|
| 3844 | % --- Executes on button press in get_gridpatch1. |
---|
| 3845 | function get_gridpatch1_Callback(hObject, eventdata, handles) |
---|
| 3846 | % hObject handle to get_gridpatch1 (see GCBO) |
---|
| 3847 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 3848 | % handles structure with handles and user data (see GUIDATA) |
---|
| 3849 | |
---|
[71] | 3850 | filebase=get(handles.RootName,'String'); |
---|
[2] | 3851 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3852 | {'*.grid', ' (*.grid)'; |
---|
| 3853 | '*.grid', '.grid files '; ... |
---|
| 3854 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3855 | 'Pick a file',filebase); |
---|
[2] | 3856 | filegrid=fullfile(PathName,FileName); |
---|
| 3857 | set(handles.grid_patch1,'string',filegrid); |
---|
| 3858 | % set(handles.grid_patch2,'string',filegrid |
---|
| 3859 | |
---|
[12] | 3860 | %------------------------------------------------------------------------ |
---|
[2] | 3861 | % --- Executes on button press in get_gridpatch2. |
---|
| 3862 | function get_gridpatch2_Callback(hObject, eventdata, handles) |
---|
[12] | 3863 | %------------------------------------------------------------------------ |
---|
[2] | 3864 | |
---|
[12] | 3865 | %------------------------------------------------------------------------ |
---|
[2] | 3866 | function enable_civ1(handles,state) |
---|
[12] | 3867 | %------------------------------------------------------------------------ |
---|
[273] | 3868 | if state |
---|
| 3869 | RootName=get(handles.RootName,'String'); |
---|
| 3870 | if isempty(RootName) |
---|
| 3871 | msgbox_uvmat('ERROR','No input file') |
---|
| 3872 | return |
---|
| 3873 | end |
---|
[274] | 3874 | set(handles.panel_Civ1,'Visible','on') |
---|
| 3875 | set(handles.panel_PairIndices,'Visible','on') |
---|
[273] | 3876 | % set(handles.frame_civ1,'BackgroundColor',[1 1 0]) |
---|
| 3877 | % set(handles.frame_para_civ1,'BackgroundColor',[1 1 0]) |
---|
| 3878 | % set(handles.frame_grid_civ1,'BackgroundColor',[1 1 0]) |
---|
[2] | 3879 | else |
---|
[274] | 3880 | set(handles.panel_Civ1,'Visible','off') |
---|
[273] | 3881 | % set(handles.frame_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3882 | % set(handles.frame_para_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3883 | % set(handles.frame_grid_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[2] | 3884 | end |
---|
[273] | 3885 | return |
---|
[2] | 3886 | set(handles.ibx,'Visible',state) |
---|
| 3887 | set(handles.iby,'Visible',state) |
---|
| 3888 | set(handles.isx,'Visible',state) |
---|
| 3889 | set(handles.isy,'Visible',state) |
---|
| 3890 | set(handles.shiftx,'Visible',state) |
---|
| 3891 | set(handles.shifty,'Visible',state) |
---|
| 3892 | set(handles.rho,'Visible',state) |
---|
| 3893 | set(handles.dx_civ1,'Visible',state) |
---|
| 3894 | set(handles.dy_civ1,'Visible',state) |
---|
[273] | 3895 | set(handles.SearchRange,'Visible',state) |
---|
| 3896 | set(handles.u_title,'Visible',state) |
---|
| 3897 | set(handles.v_title,'Visible',state) |
---|
| 3898 | set(handles.min_title,'Visible',state) |
---|
| 3899 | set(handles.max_title,'Visible',state) |
---|
[2] | 3900 | set(handles.umin,'Visible',state) |
---|
| 3901 | set(handles.umax,'Visible',state) |
---|
| 3902 | set(handles.vmin,'Visible',state) |
---|
| 3903 | set(handles.vmax,'Visible',state) |
---|
| 3904 | set(handles.grid_civ1,'Visible',state) |
---|
| 3905 | set(handles.mask_civ1,'Visible',state) |
---|
| 3906 | set(handles.browse_gridciv1,'Visible',state) |
---|
| 3907 | set(handles.get_mask_civ1,'Visible',state) |
---|
| 3908 | set(handles.parameters,'Visible',state) |
---|
| 3909 | set(handles.grid,'Visible',state) |
---|
| 3910 | set(handles.dx_civ1,'Visible',state) |
---|
| 3911 | set(handles.dy_civ1,'Visible',state) |
---|
| 3912 | set(handles.ImaThreshold,'Visible',state) |
---|
| 3913 | if isequal(state,'off') |
---|
| 3914 | set(handles.MinIma,'Visible','off') |
---|
| 3915 | set(handles.MaxIma,'Visible','off') |
---|
| 3916 | set(handles.ImaThreshold,'Value',0) |
---|
| 3917 | end |
---|
| 3918 | set(handles.dx_civ1_title,'Visible',state) |
---|
| 3919 | set(handles.dy_civ1_title,'Visible',state) |
---|
| 3920 | set(handles.ImaThreshold_title,'Visible',state) |
---|
| 3921 | set(handles.ib_title,'Visible',state) |
---|
| 3922 | set(handles.is_title,'Visible',state) |
---|
| 3923 | set(handles.shift_title,'Visible',state) |
---|
| 3924 | set(handles.rho_title,'Visible',state) |
---|
[224] | 3925 | set(handles.TestCiv1,'Visible',state) |
---|
[257] | 3926 | %set(handles.CivMode,'Visible',state) |
---|
[2] | 3927 | |
---|
[12] | 3928 | %------------------------------------------------------------------------ |
---|
[2] | 3929 | function enable_fix1(handles,state) |
---|
[12] | 3930 | %------------------------------------------------------------------------ |
---|
[273] | 3931 | |
---|
[2] | 3932 | if isequal(state,0) |
---|
| 3933 | state='off'; |
---|
| 3934 | end |
---|
| 3935 | if isequal(state,1) |
---|
| 3936 | state='on'; |
---|
[273] | 3937 | RootName=get(handles.RootName,'String'); |
---|
| 3938 | if isempty(RootName) |
---|
| 3939 | msgbox_uvmat('ERROR','No input file') |
---|
| 3940 | return |
---|
| 3941 | end |
---|
[2] | 3942 | end |
---|
| 3943 | if isequal(state,'on') |
---|
[274] | 3944 | set(handles.panel_Fix1,'Visible','on') |
---|
[273] | 3945 | % set(handles.frame_fix1,'BackgroundColor',[1 1 0]) |
---|
[2] | 3946 | else |
---|
[274] | 3947 | set(handles.panel_Fix1,'Visible','off') |
---|
[273] | 3948 | %set(handles.frame_fix1,'BackgroundColor',[0.7 0.7 0.7]) |
---|
[2] | 3949 | end |
---|
[273] | 3950 | % set(handles.REMOVE,'Visible',state) |
---|
[2] | 3951 | set(handles.vec_Fmin2,'Visible',state) |
---|
| 3952 | set(handles.vec_F2,'Visible',state) |
---|
| 3953 | set(handles.vec_F3,'Visible',state) |
---|
| 3954 | set(handles.thresh_vecC,'Visible',state) |
---|
| 3955 | set(handles.thresh_vecC_title,'Visible',state) |
---|
| 3956 | set(handles.thresh_vel,'Visible',state) |
---|
| 3957 | set(handles.thresh_vel_text,'Visible',state) |
---|
| 3958 | set(handles.mask_fix1,'Visible',state) |
---|
| 3959 | set(handles.get_mask_fix1,'Visible',state) |
---|
| 3960 | set(handles.get_ref_fix1,'Visible',state) |
---|
| 3961 | set(handles.ref_fix1,'Visible',state) |
---|
| 3962 | set(handles.inf_sup1,'Visible',state) |
---|
| 3963 | set(handles.field_ref1,'Visible',state) |
---|
| 3964 | |
---|
[12] | 3965 | %------------------------------------------------------------------------ |
---|
[273] | 3966 | function enable_patch1(handles,state) |
---|
[12] | 3967 | %------------------------------------------------------------------------ |
---|
[273] | 3968 | if state |
---|
| 3969 | RootName=get(handles.RootName,'String'); |
---|
| 3970 | if isempty(RootName) |
---|
| 3971 | msgbox_uvmat('ERROR','No input file') |
---|
| 3972 | return |
---|
| 3973 | end |
---|
[274] | 3974 | set(handles.panel_Patch1,'Visible','on') |
---|
[273] | 3975 | else |
---|
[274] | 3976 | set(handles.panel_Patch1,'Visible','off') |
---|
[273] | 3977 | end |
---|
| 3978 | return |
---|
[2] | 3979 | set(handles.frame_patch1,'BackgroundColor',[1 1 0]) |
---|
| 3980 | set(handles.rho_patch1,'Visible','on') |
---|
| 3981 | set(handles.rho_text1,'Visible','on') |
---|
[257] | 3982 | if get(handles.CivMode,'Value')==2 |
---|
[224] | 3983 | set(handles.thresh_patch1,'Visible','on') |
---|
| 3984 | set(handles.thresh_text1,'Visible','on') |
---|
| 3985 | end |
---|
[2] | 3986 | set(handles.subdomain_patch1,'Visible','on') |
---|
| 3987 | set(handles.subdomain_text1,'Visible','on') |
---|
| 3988 | set(handles.nx_patch1,'Visible','on') |
---|
[274] | 3989 | set(handles.num_Ny,'Visible','on') |
---|
[2] | 3990 | set(handles.nx_patch1_title,'Visible','on') |
---|
| 3991 | set(handles.ny_patch1_title,'Visible','on') |
---|
[112] | 3992 | % if ~isempty(patch_newBin) |
---|
[224] | 3993 | set(handles.test_interp,'Visible','off'); |
---|
[252] | 3994 | stereo_test=get(handles.compare,'Value'); |
---|
| 3995 | if stereo_test==3 |
---|
| 3996 | set(handles.test_stereo1,'Visible','on') |
---|
| 3997 | end |
---|
[100] | 3998 | % end |
---|
[252] | 3999 | %set(handles.get_gridpatch1,'Visible','on') |
---|
| 4000 | %set(handles.grid_patch1,'string','none'); |
---|
| 4001 | %set(handles.grid_patch1,'Visible','on') |
---|
[2] | 4002 | |
---|
[273] | 4003 | % %------------------------------------------------------------------------ |
---|
| 4004 | % function desable_patch1(handles) |
---|
| 4005 | % %------------------------------------------------------------------------ |
---|
| 4006 | % return |
---|
| 4007 | % set(handles.frame_patch1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4008 | % set(handles.rho_patch1,'Visible','off') |
---|
| 4009 | % set(handles.rho_text1,'Visible','off') |
---|
| 4010 | % set(handles.thresh_patch1,'Visible','off') |
---|
| 4011 | % set(handles.thresh_text1,'Visible','off') |
---|
| 4012 | % set(handles.subdomain_patch1,'Visible','off') |
---|
| 4013 | % set(handles.subdomain_text1,'Visible','off') |
---|
| 4014 | % set(handles.nx_patch1,'Visible','off') |
---|
[274] | 4015 | % set(handles.num_Ny,'Visible','off') |
---|
[273] | 4016 | % set(handles.nx_patch1_title,'Visible','off') |
---|
| 4017 | % set(handles.ny_patch1_title,'Visible','off') |
---|
| 4018 | % set(handles.test_stereo1,'Visible','off') |
---|
| 4019 | % %set(handles.test_interp,'Visible','off') |
---|
| 4020 | % %set(handles.get_gridpatch1,'Visible','off') |
---|
| 4021 | % %set(handles.grid_patch1,'Visible','off') |
---|
[2] | 4022 | |
---|
[12] | 4023 | %------------------------------------------------------------------------ |
---|
[2] | 4024 | function enable_civ2(handles,state) |
---|
[12] | 4025 | %------------------------------------------------------------------------ |
---|
[273] | 4026 | if state |
---|
| 4027 | RootName=get(handles.RootName,'String'); |
---|
| 4028 | if isempty(RootName) |
---|
| 4029 | msgbox_uvmat('ERROR','No input file') |
---|
| 4030 | return |
---|
| 4031 | end |
---|
[274] | 4032 | set(handles.panel_Civ2,'Visible','on') |
---|
[2] | 4033 | else |
---|
[274] | 4034 | set(handles.panel_Civ2,'Visible','off') |
---|
[2] | 4035 | end |
---|
[273] | 4036 | return |
---|
| 4037 | |
---|
[2] | 4038 | set(handles.ibx_civ2,'Visible',state) |
---|
| 4039 | set(handles.iby_civ2,'Visible',state) |
---|
| 4040 | set(handles.decimal,'Visible',state) |
---|
| 4041 | set(handles.deformation,'Visible',state) |
---|
| 4042 | set(handles.rho_civ2,'Visible',state) |
---|
| 4043 | set(handles.dx_civ2,'Visible',state) |
---|
| 4044 | set(handles.dy_civ2,'Visible',state) |
---|
| 4045 | set(handles.browse_gridciv2,'Visible',state) |
---|
| 4046 | set(handles.get_mask_civ2,'Visible',state) |
---|
| 4047 | set(handles.parameters,'Visible',state) |
---|
| 4048 | set(handles.grid,'Visible',state) |
---|
| 4049 | set(handles.parameters_text,'Visible',state) |
---|
| 4050 | set(handles.grid_text,'Visible',state) |
---|
| 4051 | set(handles.grid_civ2,'Visible',state) |
---|
| 4052 | set(handles.mask_civ2,'Visible',state) |
---|
| 4053 | set(handles.dx_civ2_title,'Visible',state) |
---|
| 4054 | set(handles.dy_civ2_title,'Visible',state) |
---|
| 4055 | set(handles.ibx_civ2_text,'Visible',state) |
---|
| 4056 | set(handles.rho_civ2_title,'Visible',state) |
---|
| 4057 | set(handles.ImaThreshold2,'Visible',state) |
---|
| 4058 | set(handles.ImaThreshold_title2,'Visible',state) |
---|
| 4059 | if isequal(state,'off') |
---|
| 4060 | set(handles.MinIma2,'Visible','off') |
---|
| 4061 | set(handles.MaxIma2,'Visible','off') |
---|
| 4062 | set(handles.ImaThreshold2,'Value',0) |
---|
[112] | 4063 | if isequal(get(handles.FIX2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) |
---|
[2] | 4064 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 4065 | set(handles.subdir_civ2,'Visible','off') |
---|
| 4066 | set(handles.subdir_civ2_text,'Visible','off') |
---|
[71] | 4067 | set(handles.dt_unit_civ2,'Visible','off') |
---|
[273] | 4068 | %set(handles.ref_i_civ2,'Visible','off') |
---|
[71] | 4069 | set(handles.i_ref_civ2_title,'Visible','off') |
---|
| 4070 | set(handles.j_ref_civ2_title,'Visible','off') |
---|
| 4071 | set(handles.ref_j_civ2,'Visible','off') |
---|
[2] | 4072 | end |
---|
| 4073 | else |
---|
| 4074 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 4075 | set(handles.subdir_civ2,'Visible','on') |
---|
| 4076 | set(handles.subdir_civ2_text,'Visible','on') |
---|
[71] | 4077 | set(handles.dt_unit_civ2,'Visible','on') |
---|
[273] | 4078 | % set(handles.ref_i_civ2,'Visible','on') |
---|
[71] | 4079 | set(handles.i_ref_civ2_title,'Visible','on') |
---|
| 4080 | set(handles.j_ref_civ2_title,'Visible','on') |
---|
| 4081 | set(handles.ref_j_civ2,'Visible','on') |
---|
[2] | 4082 | end |
---|
[71] | 4083 | set(handles.rho_civ2_title,'Visible',state) |
---|
[2] | 4084 | |
---|
[12] | 4085 | %------------------------------------------------------------------------ |
---|
[273] | 4086 | function enable_fix2(handles,state) |
---|
[12] | 4087 | %------------------------------------------------------------------------ |
---|
[273] | 4088 | % if isequal(state,'on') |
---|
[274] | 4089 | % set(handles.panel_Fix2,'Visible','on') |
---|
[273] | 4090 | % |
---|
| 4091 | % % set(handles.frame_civ2,'BackgroundColor',[1 1 0]) |
---|
| 4092 | % % set(handles.frame_para_civ2,'BackgroundColor',[1 1 0]) |
---|
| 4093 | % % set(handles.frame_grid_civ2,'BackgroundColor',[1 1 0]) |
---|
| 4094 | % % set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 4095 | % else |
---|
| 4096 | if state |
---|
| 4097 | RootName=get(handles.RootName,'String'); |
---|
| 4098 | if isempty(RootName) |
---|
| 4099 | msgbox_uvmat('ERROR','No input file') |
---|
| 4100 | return |
---|
| 4101 | end |
---|
[274] | 4102 | set(handles.panel_Fix2,'Visible','on') |
---|
[273] | 4103 | else |
---|
[274] | 4104 | set(handles.panel_Fix2,'Visible','off') |
---|
[273] | 4105 | end |
---|
| 4106 | return |
---|
[2] | 4107 | set(handles.frame_fix2,'BackgroundColor',[1 1 0]) |
---|
| 4108 | set(handles.REMOVE2,'Visible','on') |
---|
| 4109 | set(handles.vec_Fmin2_2,'Visible','on') |
---|
| 4110 | set(handles.vec_F4,'Visible','on') |
---|
| 4111 | set(handles.vec_F3_2,'Visible','on') |
---|
| 4112 | set(handles.thresh_vec2C,'Visible','on') |
---|
| 4113 | set(handles.thresh_vec2C_text,'Visible','on') |
---|
| 4114 | set(handles.thresh_vel2,'Visible','on') |
---|
| 4115 | set(handles.thresh_vel2_text,'Visible','on') |
---|
| 4116 | set(handles.mask_fix2,'Visible','on') |
---|
| 4117 | set(handles.get_mask_fix2,'Visible','on') |
---|
| 4118 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 4119 | set(handles.subdir_civ2,'Visible','on') |
---|
| 4120 | set(handles.subdir_civ2_text,'Visible','on') |
---|
| 4121 | set(handles.get_ref_fix2,'Visible','on') |
---|
| 4122 | set(handles.ref_fix2,'Visible','on') |
---|
| 4123 | set(handles.inf_sup2,'Visible','on') |
---|
| 4124 | set(handles.field_ref2,'Visible','on') |
---|
| 4125 | |
---|
[273] | 4126 | % %------------------------------------------------------------------------ |
---|
| 4127 | % function desable_fix2(handles) |
---|
| 4128 | % %------------------------------------------------------------------------ |
---|
| 4129 | % set(handles.frame_fix2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4130 | % set(handles.REMOVE2,'Visible','off') |
---|
| 4131 | % set(handles.vec_Fmin2_2,'Visible','off') |
---|
| 4132 | % set(handles.vec_F4,'Visible','off') |
---|
| 4133 | % set(handles.vec_F3_2,'Visible','off') |
---|
| 4134 | % set(handles.thresh_vec2C,'Visible','off') |
---|
| 4135 | % set(handles.thresh_vec2C_text,'Visible','off') |
---|
| 4136 | % set(handles.thresh_vel2,'Visible','off') |
---|
| 4137 | % set(handles.thresh_vel2_text,'Visible','off') |
---|
| 4138 | % set(handles.mask_fix2,'Visible','off') |
---|
| 4139 | % set(handles.get_mask_fix2,'Visible','off') |
---|
| 4140 | % set(handles.get_ref_fix2,'Visible','off') |
---|
| 4141 | % set(handles.ref_fix2,'Visible','off') |
---|
| 4142 | % set(handles.inf_sup2,'Visible','off') |
---|
| 4143 | % set(handles.field_ref2,'Visible','off') |
---|
| 4144 | % if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) |
---|
| 4145 | % set(handles.list_pair_civ2,'Visible','off') |
---|
| 4146 | % set(handles.subdir_civ2,'Visible','off') |
---|
| 4147 | % set(handles.subdir_civ2_text,'Visible','off') |
---|
| 4148 | % end |
---|
[2] | 4149 | |
---|
[12] | 4150 | %------------------------------------------------------------------------ |
---|
[273] | 4151 | function enable_patch2(handles,state) |
---|
[12] | 4152 | %------------------------------------------------------------------------ |
---|
[273] | 4153 | if state |
---|
| 4154 | RootName=get(handles.RootName,'String'); |
---|
| 4155 | if isempty(RootName) |
---|
| 4156 | msgbox_uvmat('ERROR','No input file') |
---|
| 4157 | return |
---|
| 4158 | end |
---|
[274] | 4159 | set(handles.panel_Patch2,'Visible','on') |
---|
[273] | 4160 | else |
---|
[274] | 4161 | set(handles.panel_Patch2,'Visible','off') |
---|
[252] | 4162 | end |
---|
[273] | 4163 | % set(handles.frame_patch2,'BackgroundColor',[1 1 0]) |
---|
[274] | 4164 | % set(handles.num_SmoothParam,'Visible','on') |
---|
| 4165 | % set(handles.num_SmoothingParam,'Visible','on') |
---|
| 4166 | % set(handles.num_MaxDiff,'Visible','on') |
---|
[273] | 4167 | % set(handles.thresh_text2,'Visible','on') |
---|
[274] | 4168 | % set(handles.num_SubdomainSize,'Visible','on') |
---|
[273] | 4169 | % set(handles.subdomain_text2,'Visible','on') |
---|
[274] | 4170 | % set(handles.num_Nx,'Visible','on') |
---|
| 4171 | % set(handles.num_Ny,'Visible','on') |
---|
[273] | 4172 | % set(handles.nx_patch2_title,'Visible','on') |
---|
| 4173 | % set(handles.ny_patch2_title,'Visible','on') |
---|
| 4174 | % % set(handles.get_gridpatch2,'Visible','on') |
---|
| 4175 | % % set(handles.grid_patch2,'Visible','on') |
---|
| 4176 | % set(handles.list_pair_civ2,'Visible','on') |
---|
| 4177 | % set(handles.subdir_civ2,'Visible','on') |
---|
| 4178 | % set(handles.subdir_civ2_text,'Visible','on') |
---|
| 4179 | % stereo_test=get(handles.compare,'Value'); |
---|
| 4180 | % if stereo_test==3 |
---|
[274] | 4181 | % set(handles.check_Stereo,'Visible','on') |
---|
[273] | 4182 | % end |
---|
[2] | 4183 | |
---|
[273] | 4184 | % %------------------------------------------------------------------------ |
---|
| 4185 | % function desable_patch2(handles) |
---|
| 4186 | % %------------------------------------------------------------------------ |
---|
[274] | 4187 | % %set(handles.panel_Patch2,'Visible','off') |
---|
[273] | 4188 | % return |
---|
| 4189 | % set(handles.frame_patch2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[274] | 4190 | % set(handles.num_SmoothParam,'Visible','off') |
---|
| 4191 | % set(handles.num_SmoothingParam,'Visible','off') |
---|
| 4192 | % set(handles.num_MaxDiff,'Visible','off') |
---|
[273] | 4193 | % set(handles.thresh_text2,'Visible','off') |
---|
[274] | 4194 | % set(handles.num_SubdomainSize,'Visible','off') |
---|
[273] | 4195 | % set(handles.subdomain_text2,'Visible','off') |
---|
[274] | 4196 | % set(handles.num_Nx,'Visible','off') |
---|
| 4197 | % set(handles.num_Ny,'Visible','off') |
---|
[273] | 4198 | % set(handles.nx_patch2_title,'Visible','off') |
---|
| 4199 | % set(handles.ny_patch2_title,'Visible','off') |
---|
| 4200 | % % set(handles.get_gridpatch2,'Visible','off') |
---|
| 4201 | % % set(handles.grid_patch2,'Visible','off') |
---|
| 4202 | % if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.FIX2,'Value'),0) |
---|
| 4203 | % set(handles.list_pair_civ2,'Visible','off') |
---|
| 4204 | % set(handles.subdir_civ2,'Visible','off') |
---|
| 4205 | % set(handles.subdir_civ2_text,'Visible','off') |
---|
| 4206 | % end |
---|
[274] | 4207 | % set(handles.check_Stereo,'Visible','off') |
---|
[12] | 4208 | %------------------------------------------------------------------------ |
---|
[2] | 4209 | function enable_pair1(handles,state) |
---|
[12] | 4210 | %------------------------------------------------------------------------ |
---|
[2] | 4211 | set(handles.subdir_civ1,'Visible',state) |
---|
| 4212 | set(handles.list_subdir_civ1,'Visible',state) |
---|
| 4213 | set(handles.SUBDIR_CIV1_txt,'Visible',state) |
---|
[273] | 4214 | %set(handles.frame_subdirciv1,'Visible',state) |
---|
[2] | 4215 | set(handles.list_pair_civ1,'Visible',state) |
---|
[273] | 4216 | set(handles.PairCiv1_title,'Visible',state) |
---|
[71] | 4217 | %set(handles.dt_unit,'Visible',state) |
---|
[273] | 4218 | %set(handles.PAIR_frame,'Visible',state) |
---|
[2] | 4219 | |
---|
[12] | 4220 | %------------------------------------------------------------------------ |
---|
| 4221 | % --- Read the parameters for civ1 on the interface |
---|
[272] | 4222 | function par=read_param_civ1(handles,filecell) |
---|
[12] | 4223 | %------------------------------------------------------------------------ |
---|
[127] | 4224 | ibx_val=str2double(get(handles.ibx,'String')); |
---|
[2] | 4225 | par.ibx=num2str(ibx_val); |
---|
[127] | 4226 | iby_val=str2double(get(handles.iby,'String')); |
---|
[2] | 4227 | par.iby=num2str(iby_val); |
---|
| 4228 | isx=get(handles.isx,'String'); |
---|
[127] | 4229 | if isnan(str2double(isx)), isx='41'; set(handles.isx,'String','41'), end; %default |
---|
| 4230 | if str2double(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.isx,'String',num2str(ibx_val+8)); end |
---|
[2] | 4231 | isy=get(handles.isy,'String'); |
---|
[127] | 4232 | if isnan(str2double(isy)), isy='41'; set(handles.isy,'String','41'), end;%default |
---|
| 4233 | if str2double(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.isy,'String',num2str(iby_val+8)); end |
---|
[2] | 4234 | par.isx=get(handles.isx,'String'); |
---|
| 4235 | par.isy=get(handles.isy,'String'); |
---|
| 4236 | par.shiftx=get(handles.shiftx,'String'); |
---|
| 4237 | par.shifty=get(handles.shifty,'String'); |
---|
[127] | 4238 | if isnan(str2double(par.isx)) |
---|
[112] | 4239 | par.isx='41';%default |
---|
| 4240 | set(handles.isx,'String','41'); |
---|
[2] | 4241 | end |
---|
[127] | 4242 | if isnan(str2double(par.isy)) |
---|
[112] | 4243 | par.isy='41'; %default |
---|
| 4244 | set(handles.isy,'String','41'); |
---|
[12] | 4245 | end |
---|
[127] | 4246 | if isnan(str2double(par.shiftx)) |
---|
[112] | 4247 | par.shiftx='0';%default |
---|
| 4248 | set(handles.shiftx,'String','0'); |
---|
| 4249 | end |
---|
[127] | 4250 | if isnan(str2double(par.shifty)) |
---|
[112] | 4251 | par.shifty='0'; %default |
---|
| 4252 | set(handles.shifty,'String','0'); |
---|
[12] | 4253 | end |
---|
[112] | 4254 | par.rho=get(handles.rho,'String'); |
---|
[238] | 4255 | if isequal(get(handles.rho,'Style'),'popupmenu') |
---|
| 4256 | index=get(handles.rho,'Value'); |
---|
| 4257 | par.rho=par.rho{index}; |
---|
| 4258 | end |
---|
[112] | 4259 | par.dx=get(handles.dx_civ1,'String'); |
---|
| 4260 | par.dy=get(handles.dy_civ1,'String'); |
---|
[127] | 4261 | if isnan(str2double(par.dx)) |
---|
[112] | 4262 | if isempty(get(handles.grid_civ1,'String')); |
---|
| 4263 | par.dx='0'; %just read by civ program, not used |
---|
| 4264 | else |
---|
[12] | 4265 | par.dx='20';%default |
---|
| 4266 | set(handles.dx_civ1,'String','20'); |
---|
[112] | 4267 | end |
---|
| 4268 | end |
---|
[127] | 4269 | if isnan(str2double(par.dy)) |
---|
[112] | 4270 | if isempty(get(handles.grid_civ1,'String')); |
---|
| 4271 | par.dy='0';%just read by civ program, not used |
---|
| 4272 | else |
---|
[12] | 4273 | par.dy='20';%default |
---|
| 4274 | set(handles.dy_civ1_title,'String','20'); |
---|
[112] | 4275 | end |
---|
| 4276 | end |
---|
| 4277 | par.pxcmx='1'; %velocities are expressed in pixel dispalcement |
---|
| 4278 | par.pxcmy='1'; |
---|
[272] | 4279 | % if exist('file_ima','var') |
---|
| 4280 | A=imread(filecell.ima1.civ1{1,1});%read the first image to get the size |
---|
[112] | 4281 | sizim=size(A); |
---|
| 4282 | par.npx=num2str(sizim(2)); |
---|
| 4283 | par.npy=num2str(sizim(1)); |
---|
[272] | 4284 | %TODO : civ should not need npx and npy |
---|
| 4285 | |
---|
| 4286 | |
---|
| 4287 | % end |
---|
[127] | 4288 | %time=get(handles.RootName,'UserData'); %get the set of times |
---|
[112] | 4289 | par.gridname=get(handles.grid_civ1,'String'); |
---|
| 4290 | par.gridflag='y'; |
---|
[127] | 4291 | if strcmp(par.gridname,'')|| isempty(par.gridname) |
---|
[112] | 4292 | par.gridname='nogrid'; |
---|
| 4293 | par.gridflag='n'; |
---|
| 4294 | end |
---|
[12] | 4295 | |
---|
| 4296 | %------------------------------------------------------------------------ |
---|
[272] | 4297 | function par=read_param_fix1(handles,filecell) |
---|
| 4298 | %------------------------------------------------------------------------ |
---|
| 4299 | par.flagindex1(1)=get(handles.vec_Fmin2, 'Value'); |
---|
| 4300 | par.flagindex1(2)=get(handles.vec_F3, 'Value'); |
---|
| 4301 | par.flagindex1(3)=get(handles.vec_F2, 'Value'); |
---|
| 4302 | par.thresh_vecC1=str2double(get(handles.thresh_vecC,'String'));%threshold on image correlation vec_C |
---|
| 4303 | par.thresh_vel1=str2double(get(handles.thresh_vel,'String'));%threshold on velocity modulus |
---|
| 4304 | par.test_mask=get(handles.get_mask_fix1,'Value'); |
---|
| 4305 | par.nbslice_mask=get(handles.mask_fix1,'UserData'); % get the number of slices (= number of masks) |
---|
| 4306 | %%%%%%%%%%%%%COMPLETER LE PROGRAMME FIX |
---|
| 4307 | % inf_sup=get(handles.inf_sup1,'Value');80 |
---|
| 4308 | % fileref=get(handles.ref_fix1,'String'); |
---|
| 4309 | % refpath=get(handles.ref_fix1,'UserData'); |
---|
| 4310 | % fileref=fullfile(refpath,fileref); |
---|
| 4311 | par.menu=get(handles.field_ref1,'String'); |
---|
| 4312 | par.index=get(handles.field_ref1,'Value'); |
---|
| 4313 | if isempty(par.menu) |
---|
| 4314 | par.fieldchoice=''; |
---|
| 4315 | else |
---|
| 4316 | par.fieldchoice=menu{index}; |
---|
| 4317 | msgbox_uvmat('WARNING','reference field is not used presently with batch, use RUN option') |
---|
| 4318 | end |
---|
| 4319 | if par.test_mask==0 |
---|
| 4320 | par.maskname=''; |
---|
| 4321 | else |
---|
| 4322 | maskdispl=get(handles.mask_fix1,'String'); |
---|
| 4323 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
| 4324 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
| 4325 | maskbase=[filecell.filebase '_' maskdispl]; |
---|
| 4326 | par.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 4327 | end |
---|
| 4328 | |
---|
| 4329 | %------------------------------------------------------------------------ |
---|
| 4330 | function par=read_param_patch1(handles) |
---|
| 4331 | %------------------------------------------------------------------------ |
---|
| 4332 | |
---|
| 4333 | par.rho_patch=str2double(get(handles.rho_patch1,'String')); |
---|
| 4334 | if isnan(par.rho_patch) |
---|
| 4335 | par.rho_patch='1000'; |
---|
| 4336 | set(handles.rho_patch1,'String','1') |
---|
| 4337 | else |
---|
| 4338 | par.rho_patch=num2str(1000*par.rho_patch); |
---|
| 4339 | end |
---|
| 4340 | par.nx_patch=get(handles.nx_patch1,'String'); |
---|
| 4341 | par.ny_patch=get(handles.ny_patch1,'String'); |
---|
| 4342 | if isnan(str2double(par.nx_patch)) |
---|
| 4343 | par.nx_patch='50' ;%default |
---|
| 4344 | set(handles.nx_patch1,'String','50'); |
---|
| 4345 | end |
---|
| 4346 | if isnan(str2double(par.ny_patch)) |
---|
| 4347 | par.ny_patch='50' ;%default |
---|
| 4348 | set(handles.ny_patch1,'String','50'); |
---|
| 4349 | end |
---|
| 4350 | par.subdomain_patch=get(handles.subdomain_patch1,'String'); |
---|
| 4351 | par.thresh_patch=get(handles.thresh_patch1,'String'); |
---|
| 4352 | |
---|
| 4353 | |
---|
| 4354 | %------------------------------------------------------------------------ |
---|
[2] | 4355 | function par=read_param_civ2(handles,file_ima) |
---|
[12] | 4356 | %------------------------------------------------------------------------ |
---|
| 4357 | par.ibx=get(handles.ibx_civ2,'String'); |
---|
| 4358 | par.iby=get(handles.iby_civ2,'String'); |
---|
| 4359 | par.rho=get(handles.rho_civ2,'String'); |
---|
| 4360 | par.decimal=int2str(get(handles.decimal,'Value')); |
---|
| 4361 | par.deformation=int2str(get(handles.deformation,'Value')); |
---|
| 4362 | par.dx=get(handles.dx_civ2,'String'); |
---|
| 4363 | par.dy=get(handles.dy_civ2,'String'); |
---|
[127] | 4364 | if isnan(str2double(par.dx)) |
---|
[112] | 4365 | if isempty(get(handles.grid_civ2,'String')); |
---|
| 4366 | par.dx='0'; %just read by civ program, not used |
---|
| 4367 | else |
---|
[12] | 4368 | par.dx='20';%default |
---|
| 4369 | set(handles.dx_civ2,'String','20'); |
---|
[112] | 4370 | end |
---|
| 4371 | end |
---|
[127] | 4372 | if isnan(str2double(par.dy)) |
---|
[112] | 4373 | if isempty(get(handles.grid_civ2,'String')); |
---|
| 4374 | par.dy='0';%just read by civ program, not used |
---|
| 4375 | else |
---|
[12] | 4376 | par.dy='20';%default |
---|
| 4377 | set(handles.dy_civ2,'String','20'); |
---|
[112] | 4378 | end |
---|
| 4379 | end |
---|
| 4380 | par.pxcmx='1'; |
---|
| 4381 | par.pxcmy='1'; |
---|
[12] | 4382 | A=imread(file_ima);%read the first image to get the size |
---|
| 4383 | sizim=size(A); |
---|
| 4384 | par.npx=num2str(sizim(2)); |
---|
| 4385 | par.npy=num2str(sizim(1)); |
---|
[127] | 4386 | %time=get(handles.RootName,'UserData'); %get the set of times |
---|
[12] | 4387 | par.gridname=get(handles.grid_civ2,'String'); |
---|
| 4388 | par.gridflag='y'; |
---|
[127] | 4389 | if strcmp(par.gridname,'')|| isempty(par.gridname) |
---|
[12] | 4390 | par.gridname='nogrid'; |
---|
| 4391 | par.gridflag='n'; |
---|
| 4392 | end |
---|
[2] | 4393 | |
---|
[272] | 4394 | function cmd_CIV1=CIV1_CMD(filename,param) |
---|
| 4395 | %TODO : include filename in par_civ1 |
---|
[12] | 4396 | %------------------------------------------------------------------------ |
---|
[2] | 4397 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 4398 | |
---|
| 4399 | %changes : filename_cmx -> filename ( no extension ) |
---|
[272] | 4400 | |
---|
| 4401 | filename=regexprep(filename,'.nc','') |
---|
| 4402 | |
---|
| 4403 | if isequal(param.civ1.Dt,'0') |
---|
| 4404 | param.civ1.Dt='1' ;%case of 'displacement' mode |
---|
[112] | 4405 | end |
---|
[272] | 4406 | param.civ1.filename_ima_a=regexprep(param.civ1.filename_ima_a,'.png',''); |
---|
| 4407 | param.civ1.filename_ima_b=regexprep(param.civ1.filename_ima_b,'.png',''); |
---|
[230] | 4408 | fid=fopen([filename '.civ1.cmx'],'w'); |
---|
[12] | 4409 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
[272] | 4410 | fprintf(fid, ['FirstImage ' regexprep(param.civ1.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4411 | fprintf(fid, ['LastImage ' regexprep(param.civ1.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
[112] | 4412 | fprintf(fid, ['XX' '\n' ]); |
---|
[272] | 4413 | fprintf(fid, ['Mask ' param.civ1.maskflag '\n' ]); |
---|
| 4414 | fprintf(fid, ['MaskName ' regexprep(param.civ1.maskname,'\\','\\\\') '\n' ]); |
---|
| 4415 | fprintf(fid, ['ImageSize ' param.civ1.npx ' ' param.civ1.npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 4416 | fprintf(fid, ['CorrelationBoxesSize ' param.civ1.ibx ' ' param.civ1.iby '\n' ]); |
---|
| 4417 | fprintf(fid, ['SearchBoxeSize ' param.civ1.isx ' ' param.civ1.isy '\n' ]); |
---|
| 4418 | fprintf(fid, ['RO ' param.civ1.rho '\n' ]); |
---|
| 4419 | fprintf(fid, ['GridSpacing ' param.civ1.dx ' ' param.civ1.dy '\n' ]); |
---|
[112] | 4420 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
[272] | 4421 | fprintf(fid, ['Dt_TO ' param.civ1.Dt ' ' param.civ1.T0 '\n' ]); |
---|
| 4422 | fprintf(fid, ['PixCmXY ' param.civ1.pxcmx ' ' param.civ1.pxcmy '\n' ]); |
---|
[112] | 4423 | fprintf(fid, ['XX 1' '\n' ]); |
---|
[272] | 4424 | fprintf(fid, ['ShiftXY ' param.civ1.shiftx ' ' param.civ1.shifty '\n' ]); |
---|
| 4425 | fprintf(fid, ['Grid ' param.civ1.gridflag '\n' ]); |
---|
| 4426 | fprintf(fid, ['GridName ' regexprep(param.civ1.gridname,'\\','\\\\') '\n' ]); |
---|
[112] | 4427 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 4428 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4429 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4430 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
| 4431 | fprintf(fid, [ 'DecimalShift 0' '\n' ]); |
---|
| 4432 | fprintf(fid, ['Deformation 0' '\n' ]); |
---|
| 4433 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 4434 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 4435 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 4436 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
[272] | 4437 | fprintf(fid, ['ImageToUse ' param.civ1.term_a ' ' param.civ1.term_b '\n' ]); % VERIFIER ? |
---|
[112] | 4438 | fprintf(fid, ['ImageUsedBefore null null' '\n' ]); |
---|
[12] | 4439 | fclose(fid); |
---|
[112] | 4440 | |
---|
[163] | 4441 | % cmd_CIV1=[sparam.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file |
---|
| 4442 | % cmd_CIV1=regexprep(cmd_CIV1,'\\','\\\\'); |
---|
| 4443 | % namelog=regexprep(namelog,'\\','\\\\'); |
---|
[12] | 4444 | if(isunix) |
---|
[272] | 4445 | cmd_CIV1=['cp -f ' filename '.civ1.cmx ' filename '.cmx']; |
---|
| 4446 | cmd_CIV1=[cmd_CIV1 '\n'... |
---|
| 4447 | param.global.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx |
---|
[219] | 4448 | cmd_CIV1=[cmd_CIV1 '\n' 'mv ' filename '.log' ' ' filename '.civ1.log' '\n' 'chmod g+w ' filename '.civ1.log' '\n' 'chmod g+w ' filename '.nc'];%rename .log as .civ1.log and set the netcdf result file for group user writting |
---|
[230] | 4449 | % cmd_CIV1=[cmd_CIV1 '\n' 'mv ' filename '.cmx' ' ' filename '.civ1.cmx' '\n'];%rename .cmx as .civ1.cmx |
---|
[163] | 4450 | else %Windows system |
---|
[269] | 4451 | % flname=regexprep(flname,'\\','\\\\'); |
---|
[230] | 4452 | % cmd=[cmd 'copy /Y "' flname '.civ1.cmx" "' flname '.cmx"\n']; |
---|
[269] | 4453 | % filename=regexprep(filename,'\\','\\\\'); |
---|
[272] | 4454 | cmd_CIV1=['copy /Y "' filename '.civ1.cmx" "' filename '.cmx"'];% copy the .civ1.cmx parameter file to .cmx |
---|
| 4455 | cmd_CIV1=[cmd_CIV1 '\n "' regexprep(param.global.Civ1Bin,'\\','\\\\') '" -f "' filename '.cmx" >"' filename '.log"' ]; % redirect standard output to the log file |
---|
| 4456 | % namelog=regexprep(namelog,'\\','\\\\'); |
---|
| 4457 | cmd_CIV1=[cmd_CIV1 '\n ' 'copy /Y "' filename '.log' '" "' filename '.civ1.log"']; %preserve the log file as .civ1.log |
---|
| 4458 | |
---|
| 4459 | % cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y "' filename '.cmx' '" "' filename '.civ1.cmx"']; |
---|
[12] | 4460 | end |
---|
[2] | 4461 | |
---|
[12] | 4462 | %------------------------------------------------------------------------ |
---|
| 4463 | % --- CIV1 Unified |
---|
[94] | 4464 | function xml_civ1_parameters=CIV1_CMD_Unified(filename,namelog,par) |
---|
[12] | 4465 | %------------------------------------------------------------------------ |
---|
[2] | 4466 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
[73] | 4467 | %global CivBin%name of the executable for civ1 calculation |
---|
[2] | 4468 | |
---|
[112] | 4469 | civ1.image1=par.filename_ima_a; |
---|
| 4470 | civ1.image2=par.filename_ima_b; |
---|
| 4471 | civ1.imageSize_X=par.npx; |
---|
| 4472 | civ1.imageSize_Y=par.npy; |
---|
| 4473 | civ1.outputFileName=[filename '.nc']; |
---|
| 4474 | civ1.correlationBoxesSize_X=par.ibx; |
---|
| 4475 | civ1.correlationBoxesSize_Y=par.iby; |
---|
| 4476 | civ1.searchBoxesSize_X=par.isx; |
---|
| 4477 | civ1.searchBoxesSize_Y=par.isy; |
---|
| 4478 | civ1.globalShift_X=par.shiftx; |
---|
| 4479 | civ1.globalShift_Y=par.shifty; |
---|
| 4480 | civ1.ro=par.rho; |
---|
| 4481 | civ1.hart='y'; |
---|
| 4482 | if isequal(par.gridflag,'y') |
---|
| 4483 | civ1.grid=par.gridname; |
---|
| 4484 | else |
---|
| 4485 | civ1.grid='n'; |
---|
| 4486 | civ1.gridSpacing_X=par.dx; |
---|
| 4487 | civ1.gridSpacing_Y=par.dy; |
---|
| 4488 | end |
---|
| 4489 | if isequal(par.maskflag,'y') |
---|
| 4490 | civ1.mask=par.maskname; |
---|
| 4491 | end |
---|
[229] | 4492 | civ1.dt=par.Dt; |
---|
[112] | 4493 | civ1.unit='pixel'; |
---|
| 4494 | civ1.absolut_time_T0=par.T0; |
---|
| 4495 | civ1.pixcmx=par.pxcmx; |
---|
| 4496 | civ1.pixcmy=par.pxcmy; |
---|
| 4497 | civ1.convectFlow='n'; |
---|
[12] | 4498 | |
---|
[112] | 4499 | xml_civ1_parameters=civ1; |
---|
| 4500 | |
---|
[12] | 4501 | %------------------------------------------------------------------------ |
---|
| 4502 | % --- CIV2 Unified |
---|
[94] | 4503 | function civ2=CIV2_CMD_Unified(filename,namelog,par) |
---|
[12] | 4504 | %------------------------------------------------------------------------ |
---|
[2] | 4505 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
[73] | 4506 | %global CivBin%name of the executable for civ1 calculation |
---|
[272] | 4507 | filename=regexprep(filename,'.nc',''); |
---|
[2] | 4508 | |
---|
| 4509 | civ2.image1=par.filename_ima_a; |
---|
| 4510 | civ2.image2=par.filename_ima_b; |
---|
[112] | 4511 | civ2.imageSize_X=par.npx; |
---|
[2] | 4512 | civ2.imageSize_Y=par.npy; |
---|
| 4513 | civ2.inputFileName=[par.filename_nc1 '.nc']; |
---|
| 4514 | civ2.outputFileName=[filename '.nc']; |
---|
| 4515 | civ2.correlationBoxesSize_X=par.ibx; |
---|
| 4516 | civ2.correlationBoxesSize_Y=par.iby; |
---|
| 4517 | civ2.ro=par.rho; |
---|
| 4518 | %civ2.decimalShift=par.decimal; |
---|
| 4519 | %civ2.deformation=par.deformation; |
---|
| 4520 | if isequal(par.decimal,'1') |
---|
| 4521 | civ2.decimalShift='y'; |
---|
| 4522 | else |
---|
| 4523 | civ2.decimalShift='n'; |
---|
| 4524 | end |
---|
| 4525 | if isequal(par.deformation,'1') |
---|
| 4526 | civ2.deformation='y'; |
---|
| 4527 | else |
---|
| 4528 | civ2.deformation='n'; |
---|
| 4529 | end |
---|
| 4530 | if isequal(par.gridflag,'y') |
---|
| 4531 | civ2.grid=par.gridname; |
---|
| 4532 | else |
---|
| 4533 | civ2.grid='n'; |
---|
| 4534 | civ2.gridSpacing_X=par.dx; |
---|
| 4535 | civ2.gridSpacing_Y=par.dy; |
---|
| 4536 | end |
---|
| 4537 | civ2.gridSpacing_X='10'; |
---|
| 4538 | civ2.gridSpacing_Y='10';%NOTE: faut mettre gridSpacing pourque ca tourne, meme si c'est la grille qui est utilisee |
---|
| 4539 | if isequal(par.maskflag,'y') |
---|
| 4540 | civ2.mask=par.maskname; |
---|
| 4541 | else |
---|
| 4542 | civ2.mask='n'; |
---|
| 4543 | end |
---|
| 4544 | civ2.dt=par.Dt; |
---|
| 4545 | civ2.unit='pixel'; |
---|
| 4546 | civ2.absolut_time_T0=par.T0; |
---|
| 4547 | civ2.pixcmx=par.pxcmx; |
---|
| 4548 | civ2.pixcmy=par.pxcmy; |
---|
| 4549 | civ2.convectFlow='n'; |
---|
| 4550 | civ2.pixcmx=par.pxcmx; |
---|
| 4551 | civ2.pixcmy=par.pxcmy; |
---|
| 4552 | civ2.convectFlow='n'; |
---|
| 4553 | |
---|
[12] | 4554 | %------------------------------------------------------------------------ |
---|
| 4555 | % --- CIV2 CIV2 CIV2 CIV2 |
---|
[272] | 4556 | function cmd_CIV2=CIV2_CMD(filename,param) |
---|
[12] | 4557 | %------------------------------------------------------------------------ |
---|
[2] | 4558 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
[67] | 4559 | % global civ2Bin sge%name of the executable for civ1 calculation |
---|
[112] | 4560 | if isequal(par.Dt,'0') |
---|
[272] | 4561 | param.civ2.Dt='1' ;%case of 'displacement' mode |
---|
[112] | 4562 | end |
---|
[272] | 4563 | param.civ2.filename_ima_a=regexprep(param.civ2.filename_ima_a,'.png',''); |
---|
| 4564 | param.civ2.filename_ima_b=regexprep(param.civ2.filename_ima_b,'.png','');% bug : .png appears two times ? |
---|
[174] | 4565 | [fid,errormsg]=fopen([filename '.civ2.cmx'],'w'); |
---|
| 4566 | if isequal(fid,-1) |
---|
| 4567 | msgbox_uvmat('ERROR',errormsg) |
---|
| 4568 | cmd_CIV2=''; |
---|
| 4569 | return |
---|
| 4570 | end |
---|
[94] | 4571 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
[272] | 4572 | fprintf(fid, ['FirstImage ' regexprep(param.civ2.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4573 | fprintf(fid, ['LastImage ' regexprep(param.civ2.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
[94] | 4574 | fprintf(fid, ['XX' '\n' ]); |
---|
[272] | 4575 | fprintf(fid, ['Mask ' param.civ2.maskflag '\n' ]); |
---|
| 4576 | fprintf(fid, ['MaskName ' regexprep(param.civ2.maskname,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4577 | fprintf(fid, ['ImageSize ' param.civ2.npx ' ' param.civ2.npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 4578 | fprintf(fid, ['CorrelationBoxesSize ' param.civ2.ibx ' ' param.civ2.iby '\n' ]); |
---|
| 4579 | fprintf(fid, ['SearchBoxeSize ' param.civ2.ibx ' ' param.civ2.iby '\n']); |
---|
| 4580 | fprintf(fid, ['RO ' param.civ2.rho '\n']); |
---|
| 4581 | fprintf(fid, ['GridSpacing ' param.civ2.dx ' ' param.civ2.dy '\n']); |
---|
[94] | 4582 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
[272] | 4583 | fprintf(fid, ['Dt_TO ' param.civ2.Dt ' ' param.civ2.T0 '\n' ]); |
---|
| 4584 | fprintf(fid, ['PixCmXY ' param.civ2.pxcmx ' ' param.civ2.pxcmy '\n' ]); |
---|
[94] | 4585 | fprintf(fid, ['XX 1' '\n' ]); |
---|
[122] | 4586 | fprintf(fid, 'ShiftXY 0 0\n'); |
---|
[272] | 4587 | fprintf(fid, ['Grid ' param.civ2.gridflag '\n' ]); |
---|
| 4588 | fprintf(fid, ['GridName ' regexprep(param.civ2.gridname,'\\','\\\\') '\n']); |
---|
[94] | 4589 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 4590 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4591 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4592 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
[272] | 4593 | fprintf(fid, ['DecimalShift ' param.civ2.decimal '\n']); |
---|
| 4594 | fprintf(fid, ['Deformation ' param.civ2.deformation '\n']); |
---|
[94] | 4595 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 4596 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 4597 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 4598 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
[272] | 4599 | fprintf(fid, ['ImageToUse ' param.civ2.term_a ' ' param.civ2.term_b '\n' ]); % VERIFIER ? |
---|
| 4600 | fprintf(fid, ['ImageUsedBefore ' regexprep(param.civ2.filename_nc1,'\\','\\\\') '\n']); |
---|
[94] | 4601 | fclose(fid); |
---|
| 4602 | |
---|
[134] | 4603 | if(isunix) |
---|
[230] | 4604 | cmd_CIV2=['cp -f ' filename '.civ2.cmx ' filename '.cmx\n']; |
---|
[272] | 4605 | cmd_CIV2=[cmd_CIV2 param.global.Civ2Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx |
---|
[230] | 4606 | cmd_CIV2=[cmd_CIV2 '\n' 'mv ' filename '.log' ' ' filename '.civ2.log' '\n' 'chmod g+w ' filename '.nc'];%preserve the log file as .civ2.log |
---|
| 4607 | % cmd_CIV2=[cmd_CIV2 '\n' 'mv ' filename '.cmx' ' ' filename '.civ2.cmx' '\n'];%rename .cmx as .civ2.cmx, the result file is named [filename '.nc'] by CIVx |
---|
| 4608 | |
---|
[163] | 4609 | else |
---|
[174] | 4610 | filename=regexprep(filename,'\\','\\\\'); |
---|
[272] | 4611 | cmd_CIV2=['copy /Y "' filename '.civ2.cmx" "' filename '.cmx"']; |
---|
| 4612 | cmd_CIV2=[cmd_CIV2 '\n "' regexprep(param.global.Civ2Bin,'\\','\\\\') '" -f "' filename '.cmx" >"' filename '.log"' ]; % redirect standard output to the log file |
---|
| 4613 | cmd_CIV2=[cmd_CIV2 '\n ' 'copy /Y "' filename '.log' '" "' filename '.civ2.log"']; |
---|
[230] | 4614 | % cmd_CIV2=[cmd_CIV2 '\n' 'copy /Y "' filename '.cmx' '" "' filename '.civ2.cmx"']; |
---|
[134] | 4615 | end |
---|
| 4616 | |
---|
| 4617 | |
---|
[12] | 4618 | %------------------------------------------------------------------------ |
---|
[2] | 4619 | %--read images and convert them to the uint16 format used for PIV |
---|
[45] | 4620 | function A=read_image(filename,type_ima,num,movieobject) |
---|
[12] | 4621 | %------------------------------------------------------------------------ |
---|
[2] | 4622 | %num is the view number needed for an avi movie |
---|
[45] | 4623 | switch type_ima |
---|
| 4624 | case 'movie' |
---|
| 4625 | A=read(movieobject,num); |
---|
| 4626 | case 'avi' |
---|
[112] | 4627 | mov=aviread(filename,num); |
---|
| 4628 | A=frame2im(mov(1)); |
---|
[45] | 4629 | case 'multimage' |
---|
| 4630 | A=imread(filename,num); |
---|
[112] | 4631 | case 'image' |
---|
[45] | 4632 | A=imread(filename); |
---|
| 4633 | end |
---|
| 4634 | siz=size(A); |
---|
| 4635 | if length(siz)==3;%color images |
---|
[2] | 4636 | A=sum(double(A),3); |
---|
| 4637 | A=uint16(A); |
---|
| 4638 | end |
---|
| 4639 | |
---|
[12] | 4640 | %------------------------------------------------------------------------ |
---|
[2] | 4641 | function ref_i_Callback(hObject, eventdata, handles) |
---|
[12] | 4642 | %------------------------------------------------------------------------ |
---|
[273] | 4643 | mode_list=get(handles.CivMode,'String'); |
---|
| 4644 | mode_value=get(handles.CivMode,'Value'); |
---|
[2] | 4645 | mode=mode_list{mode_value}; |
---|
[45] | 4646 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
[12] | 4647 | if isequal(mode,'series(Di)') || ...% we do patch2 only |
---|
[112] | 4648 | (get(handles.CIV2,'Value')==0 && get(handles.CIV1,'Value')==0 && get(handles.FIX1,'Value')==0 && get(handles.PATCH1,'Value')==0) |
---|
[2] | 4649 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 4650 | end |
---|
| 4651 | |
---|
[12] | 4652 | %------------------------------------------------------------------------ |
---|
[2] | 4653 | function ref_j_Callback(hObject, eventdata, handles) |
---|
[12] | 4654 | %------------------------------------------------------------------------ |
---|
[273] | 4655 | mode_list=get(handles.CivMode,'String'); |
---|
| 4656 | mode_value=get(handles.CivMode,'Value'); |
---|
[2] | 4657 | mode=mode_list{mode_value}; |
---|
[112] | 4658 | if isequal(get(handles.CIV1,'Value'),0)|| isequal(mode,'series(Dj)') |
---|
[2] | 4659 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
| 4660 | end |
---|
[45] | 4661 | if isequal(mode,'series(Dj)') || ... |
---|
[112] | 4662 | (get(handles.CIV2,'Value')==0 && get(handles.CIV1,'Value')==0 && get(handles.FIX1,'Value')==0 && get(handles.PATCH1,'Value')==0) |
---|
[2] | 4663 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 4664 | end |
---|
[12] | 4665 | |
---|
| 4666 | %------------------------------------------------------------------------ |
---|
[71] | 4667 | function ref_i_civ2_Callback(hObject, eventdata, handles) |
---|
| 4668 | %------------------------------------------------------------------------ |
---|
[273] | 4669 | mode_list=get(handles.CivMode,'String'); |
---|
| 4670 | mode_value=get(handles.CivMode,'Value'); |
---|
[71] | 4671 | mode=mode_list{mode_value}; |
---|
| 4672 | find_netcpair_civ2(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
| 4673 | |
---|
| 4674 | %------------------------------------------------------------------------ |
---|
| 4675 | function ref_j_civ2_Callback(hObject, eventdata, handles) |
---|
| 4676 | %------------------------------------------------------------------------ |
---|
[273] | 4677 | mode_list=get(handles.CivMode,'String'); |
---|
| 4678 | mode_value=get(handles.CivMode,'Value'); |
---|
[71] | 4679 | mode=mode_list{mode_value}; |
---|
[112] | 4680 | if isequal(mode,'series(Dj)') |
---|
[71] | 4681 | find_netcpair_civ2(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
| 4682 | end |
---|
| 4683 | |
---|
| 4684 | %------------------------------------------------------------------------ |
---|
[2] | 4685 | % --- Executes on button press in compare. |
---|
| 4686 | function compare_Callback(hObject, eventdata, handles) |
---|
[12] | 4687 | %------------------------------------------------------------------------ |
---|
[2] | 4688 | test=get(handles.compare,'Value'); |
---|
[263] | 4689 | if test==2 || test==3 % case 'dispalcemen' or 'stereo PIV' |
---|
[71] | 4690 | filebase=get(handles.RootName,'String'); |
---|
[273] | 4691 | browse=get(handlesRootName,'Userdata'); |
---|
[2] | 4692 | browse.nom_type_ima1=browse.nom_type_ima; |
---|
[273] | 4693 | set(handlesRootName,'UserData',browse); |
---|
[2] | 4694 | set(handles.sub_txt,'Visible','on') |
---|
[112] | 4695 | set(handles.RootName_1,'Visible','On');%mkes the second file input window visible |
---|
[273] | 4696 | mode_store=get(handles.CivMode,'String');%get the present 'mode' |
---|
[112] | 4697 | set(handles.compare,'UserData',mode_store);%store the mode display |
---|
[273] | 4698 | set(handles.CivMode,'Visible','off') |
---|
[2] | 4699 | if test==2 |
---|
[273] | 4700 | set(handles.CivMode,'Visible','off') |
---|
[263] | 4701 | set(handles.CivMode,'Value',1) % mode 'civX' selected by default |
---|
[2] | 4702 | else |
---|
[273] | 4703 | set(handles.CivMode,'Visible','on') |
---|
[263] | 4704 | set(handles.CivMode,'Value',3) % mode 'Matlab' selected for stereo |
---|
[2] | 4705 | end |
---|
| 4706 | |
---|
[273] | 4707 | %% menuopen an image file with the browser |
---|
[2] | 4708 | ind_opening=1;%default |
---|
| 4709 | browse.incr_pair=[0 0]; %default |
---|
[71] | 4710 | oldfile=get(handles.RootName,'String'); |
---|
[229] | 4711 | menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)'; |
---|
| 4712 | '*.xml', '.xml files '; ... |
---|
| 4713 | '*.civ', '.civ files '; ... |
---|
| 4714 | '*.png','.png image files'; ... |
---|
| 4715 | '*.jpg',' jpeg image files'; ... |
---|
| 4716 | '*.tif','.tif image files'; ... |
---|
| 4717 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 4718 | '*.nc','.netcdf files'; ... |
---|
| 4719 | '*.*', 'All Files (*.*)'}; |
---|
| 4720 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file of the second series',oldfile); |
---|
[112] | 4721 | fileinput=[PathName FileName];%complete file name |
---|
[2] | 4722 | sizf=size(fileinput); |
---|
[229] | 4723 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
[263] | 4724 | [path,name,ext]=fileparts(fileinput) |
---|
[2] | 4725 | [path1]=fileparts(filebase); |
---|
[263] | 4726 | if isunix |
---|
| 4727 | [status,path]=system(['readlink ' path]) |
---|
| 4728 | [status,path1]=system(['readlink ' path1])% look for the true path in case of symbolic paths |
---|
| 4729 | end |
---|
[2] | 4730 | if ~strcmp(path1,path) |
---|
[263] | 4731 | msgbox_uvmat('ERROR','The second image series must be in the same directory as the first one') |
---|
[2] | 4732 | return |
---|
[263] | 4733 | end |
---|
| 4734 | % set(handles.RootName_1,'String',name); |
---|
[2] | 4735 | [RootPath,RootFile,field_count,str2,str_a,str_b,xx,nom_type,subdir]=name2display(name); |
---|
[263] | 4736 | set(handles.RootName_1,'String',RootFile); |
---|
[273] | 4737 | browse=get(handlesRootName,'UserData'); |
---|
[2] | 4738 | browse.nom_type_ima_1=nom_type; |
---|
[273] | 4739 | set(handlesRootName,'UserData',browse) |
---|
[2] | 4740 | |
---|
| 4741 | %check image extension |
---|
[71] | 4742 | if ~strcmp(ext,get(handles.ImaExt,'String')) |
---|
[263] | 4743 | msgbox_uvmat('ERROR','The second image series must have the same extension name as the first one') |
---|
[2] | 4744 | return |
---|
| 4745 | end |
---|
| 4746 | |
---|
[229] | 4747 | %% check coincidence of image sizes |
---|
[263] | 4748 | % ref_i=get(handles.ref_i,'string'); |
---|
| 4749 | % ref_j=get(handles.ref_j,'string'); |
---|
| 4750 | % [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc]=set_civ_filenames(handles,ref_i,ref_j,[1 0 0 0 0 0]); |
---|
| 4751 | % A=imread(filecell.ima1.civ1{1}); |
---|
| 4752 | % A_1=imread(fileinput); |
---|
| 4753 | % npxy=size(A); |
---|
| 4754 | % npxy_1=size(A_1); |
---|
| 4755 | % if ~isequal(size(A),size(A_1)) |
---|
| 4756 | % msgbox_uvmat('ERROR','The two input image series do not have the same size') |
---|
| 4757 | % return |
---|
| 4758 | % end |
---|
[2] | 4759 | else |
---|
[273] | 4760 | set(handles.CivMode,'Visible','on') |
---|
[71] | 4761 | set(handles.RootName_1,'Visible','Off'); |
---|
[2] | 4762 | set(handles.sub_txt,'Visible','off') |
---|
[71] | 4763 | set(handles.RootName_1,'String',[]); |
---|
[2] | 4764 | mode_store=get(handles.compare,'UserData'); |
---|
[273] | 4765 | set(handles.CivMode,'Value',1) |
---|
| 4766 | set(handles.CivMode,'String',mode_store) |
---|
[2] | 4767 | set(handles.test_stereo1,'Value',0) |
---|
[274] | 4768 | set(handles.check_Stereo,'Value',0) |
---|
[263] | 4769 | set(handles.CivMode,'Value',1) % mode 'civX' selected by default |
---|
[2] | 4770 | end |
---|
[252] | 4771 | if test==3 && get(handles.PATCH1,'Value') |
---|
[263] | 4772 | set(handles.test_stereo1,'Visible','on') |
---|
[252] | 4773 | else |
---|
[263] | 4774 | set(handles.test_stereo1,'Visible','off') |
---|
[252] | 4775 | end |
---|
| 4776 | if test==3 && get(handles.PATCH2,'Value') |
---|
[274] | 4777 | set(handles.check_Stereo,'Visible','on') |
---|
[252] | 4778 | else |
---|
[274] | 4779 | set(handles.check_Stereo,'Visible','off') |
---|
[252] | 4780 | end |
---|
[2] | 4781 | mode_Callback(hObject, eventdata, handles) |
---|
| 4782 | |
---|
[12] | 4783 | %------------------------------------------------------------------------ |
---|
[2] | 4784 | % --- Executes on button press in get_ref_fix1. |
---|
| 4785 | function get_ref_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 4786 | %------------------------------------------------------------------------ |
---|
[71] | 4787 | filebase=get(handles.RootName,'String'); |
---|
[2] | 4788 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 4789 | {'*.nc', ' (*.nc)'; |
---|
| 4790 | '*.nc', 'netcdf files '; ... |
---|
| 4791 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4792 | 'Pick a file',filebase); |
---|
| 4793 | |
---|
[2] | 4794 | fileinput=[PathName FileName]; |
---|
| 4795 | sizf=size(fileinput); |
---|
[122] | 4796 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
[2] | 4797 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 4798 | ref.filebase=fullfile(Path,File); |
---|
| 4799 | ref.num_a=stra2num(str_a); |
---|
| 4800 | ref.num_b=stra2num(str_b); |
---|
[89] | 4801 | ref.num1=str2double(field_count); |
---|
| 4802 | ref.num2=str2double(str2); |
---|
[2] | 4803 | browse=[];%initialisation |
---|
| 4804 | if ~isequal(ref.ext,'.nc') |
---|
| 4805 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
| 4806 | return |
---|
| 4807 | end |
---|
| 4808 | set(handles.ref_fix1,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
| 4809 | set(handles.ref_fix1,'UserData',ref) |
---|
| 4810 | menu_field{1}='civ1'; |
---|
| 4811 | Data=nc2struct(fileinput,[]); |
---|
[45] | 4812 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
[2] | 4813 | menu_field{2}='filter1'; |
---|
| 4814 | end |
---|
[45] | 4815 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
[2] | 4816 | menu_field{3}='civ2'; |
---|
| 4817 | end |
---|
[45] | 4818 | if isfield(Data,'patch2') && isequal(Data.patch2,1) |
---|
[2] | 4819 | menu_field{4}='filter2'; |
---|
| 4820 | end |
---|
| 4821 | set(handles.field_ref1,'String',menu_field); |
---|
| 4822 | set(handles.field_ref1,'Value',length(menu_field)); |
---|
| 4823 | set(handles.inf_sup1,'Value',2); |
---|
| 4824 | set(handles.thresh_vel,'String','1');%default threshold |
---|
| 4825 | set(handles.ref_fix1,'Enable','on') |
---|
[12] | 4826 | |
---|
| 4827 | %------------------------------------------------------------------------ |
---|
[2] | 4828 | % --- Executes on button press in get_ref_fix2. |
---|
| 4829 | function get_ref_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 4830 | %------------------------------------------------------------------------ |
---|
[2] | 4831 | if isequal(get(handles.get_ref_fix2,'Value'),1) |
---|
[71] | 4832 | filebase=get(handles.RootName,'String'); |
---|
[2] | 4833 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 4834 | {'*.nc', ' (*.nc)'; |
---|
| 4835 | '*.nc', 'netcdf files '; ... |
---|
| 4836 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4837 | 'Pick a file',filebase); |
---|
[2] | 4838 | fileinput=[PathName FileName]; |
---|
| 4839 | sizf=size(fileinput); |
---|
[45] | 4840 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
[2] | 4841 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 4842 | ref.filebase=fullfile(Path,File); |
---|
| 4843 | ref.num_a=stra2num(str_a); |
---|
| 4844 | ref.num_b=stra2num(str_b); |
---|
| 4845 | ref.num1=str2num(field_count); |
---|
| 4846 | ref.num2=str2num(str2); |
---|
| 4847 | browse=[];%initialisation |
---|
| 4848 | if ~isequal(ref.ext,'.nc') |
---|
| 4849 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
| 4850 | return |
---|
| 4851 | end |
---|
| 4852 | set(handles.ref_fix2,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
[112] | 4853 | set(handles.ref_fix2,'UserData',ref) |
---|
[2] | 4854 | menu_field{1}='civ1'; |
---|
| 4855 | Data=nc2struct(fileinput,[]); |
---|
| 4856 | if isfield(Data,'patch') & isequal(Data.patch,1) |
---|
| 4857 | menu_field{2}='filter1'; |
---|
| 4858 | end |
---|
| 4859 | if isfield(Data,'civ2') & isequal(Data.civ2,1) |
---|
| 4860 | menu_field{3}='civ2'; |
---|
| 4861 | end |
---|
| 4862 | if isfield(Data,'patch2') & isequal(Data.patch2,1) |
---|
| 4863 | menu_field{4}='filter2'; |
---|
| 4864 | end |
---|
| 4865 | set(handles.field_ref2,'String',menu_field); |
---|
| 4866 | set(handles.field_ref2,'Value',length(menu_field)); |
---|
| 4867 | set(handles.inf_sup2,'Value',2); |
---|
| 4868 | set(handles.thresh_vel2,'String','1');%default threshold |
---|
| 4869 | set(handles.ref_fix2,'Enable','on') |
---|
| 4870 | set(handles.ref_fix2,'Visible','on') |
---|
| 4871 | set(handles.field_ref2,'Visible','on') |
---|
| 4872 | else |
---|
| 4873 | set(handles.ref_fix2,'Visible','off') |
---|
| 4874 | set(handles.field_ref2,'Visible','off') |
---|
| 4875 | end |
---|
| 4876 | |
---|
[12] | 4877 | %------------------------------------------------------------------------ |
---|
[2] | 4878 | function ref_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 4879 | %------------------------------------------------------------------------ |
---|
| 4880 | set(handles.inf_sup1,'Value',1); |
---|
| 4881 | set(handles.field_ref1,'Value',1) |
---|
| 4882 | set(handles.field_ref1,'String',{' '}) |
---|
| 4883 | set(handles.ref_fix1,'UserData',[]); |
---|
| 4884 | set(handles.ref_fix1,'String',''); |
---|
| 4885 | set(handles.thresh_vel1,'String','0'); |
---|
[112] | 4886 | |
---|
[12] | 4887 | %------------------------------------------------------------------------ |
---|
[2] | 4888 | function ref_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 4889 | %------------------------------------------------------------------------ |
---|
| 4890 | set(handles.inf_sup2,'Value',1); |
---|
| 4891 | set(handles.field_ref2,'Value',1) |
---|
| 4892 | set(handles.field_ref2,'String',{' '}) |
---|
| 4893 | set(handles.ref_fix2,'UserData',[]); |
---|
| 4894 | set(handles.ref_fix2,'String',''); |
---|
| 4895 | set(handles.thresh_vel2,'String','0'); |
---|
[2] | 4896 | |
---|
[12] | 4897 | %------------------------------------------------------------------------ |
---|
[2] | 4898 | % --- Executes on button press in test_stereo1. |
---|
| 4899 | function test_stereo1_Callback(hObject, eventdata, handles) |
---|
[12] | 4900 | %------------------------------------------------------------------------ |
---|
[2] | 4901 | if isequal(get(handles.test_stereo1,'Value'),0) |
---|
| 4902 | set(handles.subdomain_patch1,'Visible','on') |
---|
| 4903 | set(handles.rho_patch1,'Visible','on') |
---|
| 4904 | else |
---|
| 4905 | set(handles.subdomain_patch1,'Visible','off') |
---|
| 4906 | set(handles.rho_patch1,'Visible','off') |
---|
| 4907 | end |
---|
| 4908 | |
---|
[12] | 4909 | %------------------------------------------------------------------------ |
---|
[274] | 4910 | % --- Executes on button press in check_Stereo. |
---|
[273] | 4911 | function StereoCheck_Callback(hObject, eventdata, handles) |
---|
[12] | 4912 | %------------------------------------------------------------------------ |
---|
[274] | 4913 | if isequal(get(handles.check_Stereo,'Value'),0) |
---|
| 4914 | set(handles.num_SubdomainSize,'Visible','on') |
---|
| 4915 | set(handles.num_SmoothParam,'Visible','on') |
---|
[2] | 4916 | else |
---|
[274] | 4917 | set(handles.num_SubdomainSize,'Visible','off') |
---|
| 4918 | set(handles.num_SmoothParam,'Visible','off') |
---|
[2] | 4919 | end |
---|
| 4920 | |
---|
[12] | 4921 | %------------------------------------------------------------------------ |
---|
[2] | 4922 | % --- Executes on button press in ImaThreshold. |
---|
| 4923 | function ImaThreshold_Callback(hObject, eventdata, handles) |
---|
[12] | 4924 | %------------------------------------------------------------------------ |
---|
[2] | 4925 | if isequal(get(handles.ImaThreshold,'Value'),1) |
---|
| 4926 | set(handles.MinIma,'Visible','on') |
---|
| 4927 | set(handles.MaxIma,'Visible','on') |
---|
| 4928 | else |
---|
| 4929 | set(handles.MinIma,'Visible','off') |
---|
| 4930 | set(handles.MaxIma,'Visible','off') |
---|
| 4931 | end |
---|
| 4932 | |
---|
[12] | 4933 | %------------------------------------------------------------------------ |
---|
[2] | 4934 | % --- Executes on button press in ImaThreshold2. |
---|
| 4935 | function ImaThreshold2_Callback(hObject, eventdata, handles) |
---|
[12] | 4936 | %------------------------------------------------------------------------ |
---|
[2] | 4937 | if isequal(get(handles.ImaThreshold2,'Value'),1) |
---|
| 4938 | set(handles.MinIma2,'Visible','on') |
---|
| 4939 | set(handles.MaxIma2,'Visible','on') |
---|
| 4940 | else |
---|
| 4941 | set(handles.MinIma2,'Visible','off') |
---|
| 4942 | set(handles.MaxIma2,'Visible','off') |
---|
| 4943 | end |
---|
| 4944 | |
---|
[224] | 4945 | %------------------------------------------------------------------------ |
---|
[225] | 4946 | % --- Executes on button press in TestCiv1: display image correlation function |
---|
[150] | 4947 | function TestCiv1_Callback(hObject, eventdata, handles) |
---|
[224] | 4948 | %------------------------------------------------------------------------ |
---|
[233] | 4949 | set(handles.TestCiv1,'BackgroundColor',[1 1 0]) |
---|
| 4950 | drawnow |
---|
[150] | 4951 | test_civ1=get(handles.TestCiv1,'Value'); |
---|
| 4952 | if test_civ1 |
---|
[227] | 4953 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
| 4954 | if strcmp(get(handles.ref_j,'Visible'),'on') |
---|
| 4955 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
| 4956 | else |
---|
| 4957 | ref_j=1;%default |
---|
| 4958 | end |
---|
[224] | 4959 | [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]=... |
---|
[273] | 4960 | set_civ_filenames(handles,ref_i,ref_j,[1 0 0 0 0 0]); |
---|
[224] | 4961 | Data.ListVarName={'ny','nx','A'}; |
---|
| 4962 | Data.VarDimName={'ny','nx',{'ny','nx'}}; |
---|
| 4963 | Data.A=imread(filecell.ima1.civ1{1}); |
---|
| 4964 | Data.ny=[size(Data.A,1) 1]; |
---|
| 4965 | Data.nx=[1 size(Data.A,2)]; |
---|
[227] | 4966 | par_civ1=read_param_civ1(handles,filecell.ima1.civ1{1}); |
---|
[231] | 4967 | par_civ1.filename_ima_a=filecell.ima1.civ1{1}; |
---|
| 4968 | par_civ1.filename_ima_b=filecell.ima2.civ1{1}; |
---|
| 4969 | par_civ1.T0=0; |
---|
| 4970 | par_civ1.Dt=1; |
---|
[246] | 4971 | Param.Civ1=par_civ1; |
---|
| 4972 | Data=civ_uvmat(Param); |
---|
[231] | 4973 | Data.ListVarName=[Data.ListVarName {'ny','nx','A'}]; |
---|
| 4974 | Data.VarDimName=[Data.VarDimName {'ny','nx',{'ny','nx'}}]; |
---|
| 4975 | Data.A=imread(filecell.ima1.civ1{1}); |
---|
| 4976 | Data.ny=[size(Data.A,1) 1]; |
---|
| 4977 | Data.nx=[1 size(Data.A,2)]; |
---|
| 4978 | hview_field=view_field(Data); |
---|
| 4979 | set(0,'CurrentFigure',hview_field) |
---|
| 4980 | hhview_field=guihandles(hview_field); |
---|
| 4981 | set(hview_field,'CurrentAxes',hhview_field.axes3) |
---|
| 4982 | ViewData=get(hview_field,'UserData'); |
---|
| 4983 | ViewData.CivHandle=handles.civ;% indicate the handle of the civ GUI in view_field |
---|
[224] | 4984 | ViewData.axes3.B=imread(filecell.ima2.civ1{1});%store the second image in the UserData of the GUI view_field |
---|
[236] | 4985 | ViewData.axes3.X=Data.Civ1_X; %keep the set of points in memeory |
---|
| 4986 | ViewData.axes3.Y=Data.Civ1_Y; |
---|
[231] | 4987 | set(hview_field,'UserData',ViewData) |
---|
[224] | 4988 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
| 4989 | if isempty(corrfig) |
---|
| 4990 | corrfig=figure; |
---|
| 4991 | set(corrfig,'tag','corrfig') |
---|
| 4992 | set(corrfig,'name','image correlation') |
---|
| 4993 | set(corrfig,'DeleteFcn',{@closeview_field})% |
---|
| 4994 | end |
---|
[233] | 4995 | set(handles.TestCiv1,'BackgroundColor',[1 0 0]) |
---|
[224] | 4996 | else |
---|
| 4997 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
| 4998 | if ~isempty(corrfig) |
---|
| 4999 | delete(corrfig) |
---|
| 5000 | end |
---|
| 5001 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
| 5002 | if ~isempty(hview_field) |
---|
| 5003 | delete(hview_field) |
---|
| 5004 | end |
---|
[150] | 5005 | end |
---|
[71] | 5006 | |
---|
[224] | 5007 | function closeview_field(gcbo,eventdata) |
---|
| 5008 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
| 5009 | if ~isempty(hview_field) |
---|
| 5010 | delete(hview_field) |
---|
| 5011 | end |
---|
[177] | 5012 | %------------------------------------------------------------------- |
---|
| 5013 | % --- Executes on button press in status. |
---|
| 5014 | function status_Callback(hObject, eventdata, handles) |
---|
| 5015 | %------------------------------------------------------------------- |
---|
| 5016 | val=get(handles.status,'Value'); |
---|
| 5017 | if val==0 |
---|
[252] | 5018 | set(handles.status,'BackgroundColor',[0 1 0]) |
---|
[177] | 5019 | hfig=findobj(allchild(0),'name','civ_status'); |
---|
| 5020 | if ~isempty(hfig) |
---|
| 5021 | delete(hfig) |
---|
| 5022 | end |
---|
| 5023 | return |
---|
| 5024 | end |
---|
[252] | 5025 | set(handles.status,'BackgroundColor',[1 1 0]) |
---|
| 5026 | drawnow |
---|
[177] | 5027 | listtype={'civ1','fix1','patch1','civ2','fix2','patch2'}; |
---|
| 5028 | box_test(1)=get(handles.CIV1,'Value'); |
---|
| 5029 | box_test(2)=get(handles.FIX1,'Value'); |
---|
| 5030 | box_test(3)=get(handles.PATCH1,'Value'); |
---|
| 5031 | box_test(4)=get(handles.CIV2,'Value'); |
---|
| 5032 | box_test(5)=get(handles.FIX2,'Value'); |
---|
[180] | 5033 | box_test(6)=get(handles.PATCH2,'Value'); |
---|
| 5034 | option_civ=find(box_test,1,'last');%last selected option (non-zero index of box_test) |
---|
[252] | 5035 | filecell=get(handles.civ,'UserData');%retrieve the list of output files expected for PIV |
---|
| 5036 | test_new=0; |
---|
[177] | 5037 | if ~isfield(filecell,'nc') |
---|
[252] | 5038 | test_new=1; |
---|
[227] | 5039 | [ref_i,ref_j,errormsg]=find_ref_indices(handles); |
---|
| 5040 | if ~isempty(errormsg) |
---|
| 5041 | msgbox_uvmat('ERROR',errormsg) |
---|
| 5042 | return |
---|
| 5043 | end |
---|
[252] | 5044 | filecell=set_civ_filenames(handles,ref_i,ref_j,box_test);%determine the output file expected from the GUI status |
---|
[177] | 5045 | end |
---|
| 5046 | if ~isequal(box_test(4:6),[0 0 0]) |
---|
[252] | 5047 | civ_files=filecell.nc.civ2;%case of civ2 operations |
---|
[177] | 5048 | else |
---|
| 5049 | civ_files=filecell.nc.civ1; |
---|
| 5050 | end |
---|
| 5051 | [root,filename,ext]=fileparts(civ_files{1}); |
---|
| 5052 | [rootroot,subdir,extdir]=fileparts(root); |
---|
| 5053 | hfig=findobj(allchild(0),'name','civ_status'); |
---|
| 5054 | if isempty(hfig) |
---|
[252] | 5055 | hfig=figure('DeleteFcn',@stop_status); |
---|
[177] | 5056 | set(hfig,'name','civ_status') |
---|
[182] | 5057 | hlist=uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', @open_view_field,'tag','list'); |
---|
[252] | 5058 | uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','msgbox','Max',2,'String','checking files...'); |
---|
[177] | 5059 | uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]); |
---|
[182] | 5060 | uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'String','OK','FontWeight','bold','FontUnits','normalized','FontSize',0.9,'Callback',@close_GUI); |
---|
[177] | 5061 | BarPosition=[0.05 0.81 0.01 0.05]; |
---|
| 5062 | hwaitbar=uicontrol('Style','frame','Units','normalized', 'Position',BarPosition ,'BackgroundColor',[1 0 0],'tag','waitbar'); |
---|
[252] | 5063 | drawnow |
---|
[177] | 5064 | end |
---|
[188] | 5065 | % datnum=[]; |
---|
[177] | 5066 | Tabchar={}; |
---|
| 5067 | nbfiles=numel(civ_files); |
---|
| 5068 | count=0; |
---|
[188] | 5069 | testrecent=0; |
---|
[177] | 5070 | while count<nbfiles |
---|
| 5071 | count=0; |
---|
[188] | 5072 | datnum=zeros(1,nbfiles); |
---|
[177] | 5073 | for ifile=1:nbfiles |
---|
| 5074 | detect=exist(civ_files{ifile},'file'); % check the existence of the file |
---|
[179] | 5075 | option=0; |
---|
[177] | 5076 | if detect==0 |
---|
[179] | 5077 | option_str='not created'; |
---|
[177] | 5078 | else |
---|
[219] | 5079 | datfile=dir(civ_files{ifile}); |
---|
[188] | 5080 | if isfield(datfile,'datenum') |
---|
| 5081 | datnum(ifile)=datfile.datenum;%only available in recent matlab versions |
---|
| 5082 | testrecent=1; |
---|
| 5083 | end |
---|
[177] | 5084 | filefound(ifile)={datfile.name}; |
---|
| 5085 | lastfield=''; |
---|
| 5086 | % check the content netcdf file |
---|
| 5087 | Data=nc2struct(civ_files{ifile},'ListGlobalAttribute','patch2','fix2','civ2','patch','fix'); |
---|
| 5088 | if ~isempty(Data.patch2) && isequal(Data.patch2,1) |
---|
[179] | 5089 | option=6; |
---|
| 5090 | option_str='patch2'; |
---|
[177] | 5091 | elseif ~isempty(Data.fix2) && isequal(Data.fix2,1) |
---|
[179] | 5092 | option=5; |
---|
| 5093 | option_str='fix2'; |
---|
[177] | 5094 | elseif ~isempty(Data.civ2) && isequal(Data.civ2,1); |
---|
[179] | 5095 | option=4; |
---|
| 5096 | option_str='civ2'; |
---|
[177] | 5097 | elseif ~isempty(Data.patch) && isequal(Data.patch,1); |
---|
[179] | 5098 | option=3; |
---|
| 5099 | option_str='patch1'; |
---|
[177] | 5100 | elseif ~isempty(Data.fix) && isequal(Data.fix,1); |
---|
[179] | 5101 | option=2; |
---|
| 5102 | option_str='fix1'; |
---|
[177] | 5103 | else |
---|
[179] | 5104 | option=1; |
---|
| 5105 | option_str='civ1'; |
---|
[177] | 5106 | end |
---|
| 5107 | end |
---|
[179] | 5108 | if option >= option_civ |
---|
[177] | 5109 | count=count+1; |
---|
| 5110 | end |
---|
| 5111 | [rr,filename,ext]=fileparts(civ_files{ifile}); |
---|
[179] | 5112 | Tabchar{ifile,1}=[fullfile([subdir extdir],filename) ext '...' option_str]; |
---|
[177] | 5113 | end |
---|
[219] | 5114 | datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files |
---|
[188] | 5115 | if isempty(datnum) |
---|
| 5116 | if testrecent |
---|
| 5117 | message='no civ result created yet'; |
---|
| 5118 | else |
---|
| 5119 | message=''; |
---|
| 5120 | end |
---|
[177] | 5121 | else |
---|
[219] | 5122 | datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files |
---|
[177] | 5123 | [first,ind]=min(datnum); |
---|
| 5124 | [last,indlast]=max(datnum); |
---|
[252] | 5125 | if test_new |
---|
| 5126 | message='existing file status, no processing launched yet'; |
---|
| 5127 | else |
---|
[177] | 5128 | message={[num2str(count) ' file(s) done over ' num2str(nbfiles)] ;['oldest modification: ' cell2mat(filefound(ind)) ' : ' datestr(first)];... |
---|
| 5129 | ['latest modification: ' cell2mat(filefound(indlast)) ' : ' datestr(last)]}; |
---|
[252] | 5130 | end |
---|
[177] | 5131 | end |
---|
| 5132 | hfig=findobj(allchild(0),'name','civ_status'); |
---|
[252] | 5133 | if isempty(hfig)% the status list has been deleted |
---|
[177] | 5134 | return |
---|
| 5135 | else |
---|
| 5136 | hlist=findobj(hfig,'tag','list'); |
---|
| 5137 | hmsgbox=findobj(hfig,'tag','msgbox'); |
---|
| 5138 | hwaitbar=findobj(hfig,'tag','waitbar'); |
---|
| 5139 | set(hlist,'String',Tabchar) |
---|
| 5140 | set(hmsgbox,'String', message) |
---|
[252] | 5141 | if count>0 && ~test_new |
---|
[177] | 5142 | BarPosition(3)=0.9*count/nbfiles; |
---|
| 5143 | set(hwaitbar,'Position',BarPosition) |
---|
| 5144 | end |
---|
| 5145 | end |
---|
| 5146 | set(hlist,'UserData',rootroot) |
---|
[252] | 5147 | pause(10)% wait 10 seconds for next check |
---|
[177] | 5148 | end |
---|
[150] | 5149 | |
---|
[177] | 5150 | |
---|
[252] | 5151 | %------------------------------------------------------------------------ |
---|
| 5152 | % call 'view_field.fig' to display the field selected in the list of 'status' |
---|
[177] | 5153 | function open_view_field(hObject, eventdata) |
---|
[252] | 5154 | %------------------------------------------------------------------------ |
---|
| 5155 | list=get(hObject,'String'); |
---|
| 5156 | index=get(hObject,'Value'); |
---|
| 5157 | rootroot=get(hObject,'UserData'); |
---|
| 5158 | filename=list{index}; |
---|
| 5159 | ind_dot=findstr(filename,'...'); |
---|
| 5160 | filename=filename(1:ind_dot-1); |
---|
| 5161 | filename=fullfile(rootroot,filename); |
---|
| 5162 | delete(get(hObject,'parent'))%delete the display figure to stop the check process |
---|
| 5163 | if exist(filename,'file')%visualise the vel field if it exists |
---|
| 5164 | uvmat(filename) |
---|
| 5165 | set(gcbo,'Value',1) |
---|
| 5166 | end |
---|
[150] | 5167 | |
---|
[252] | 5168 | %------------------------------------------------------------------------ |
---|
| 5169 | % launched by pressing OK on the status figure |
---|
[182] | 5170 | function close_GUI(hObject, eventdata) |
---|
[252] | 5171 | %------------------------------------------------------------------------ |
---|
| 5172 | delete(gcbf) |
---|
| 5173 | |
---|
| 5174 | %------------------------------------------------------------------------ |
---|
| 5175 | % launched by deleting the status figure |
---|
| 5176 | function stop_status(hObject, eventdata) |
---|
| 5177 | %------------------------------------------------------------------------ |
---|
| 5178 | hciv=findobj(allchild(0),'tag','civ'); |
---|
| 5179 | hhciv=guidata(hciv); |
---|
| 5180 | set(hhciv.status,'value',0) %reset the status uicontrol in the GUI civ |
---|
| 5181 | set(hhciv.status,'BackgroundColor',[0 1 0]) |
---|
[220] | 5182 | |
---|
[252] | 5183 | %------------------------------------------------------------------------ |
---|
[273] | 5184 | % % --- Executes on button press in CivMode. |
---|
| 5185 | % function CivMode_Callback(hObject, eventdata, handles) |
---|
| 5186 | % %------------------------------------------------------------------------ |
---|
| 5187 | % Listprog=get(handles.CivMode,'String'); |
---|
| 5188 | % index=get(handles.CivMode,'Value'); |
---|
| 5189 | % prog=Listprog{index}; |
---|
| 5190 | % switch prog |
---|
| 5191 | % case 'CivX' |
---|
| 5192 | % set(handles.thresh_patch1,'Visible','off') |
---|
| 5193 | % set(handles.thresh_text1,'Visible','off') |
---|
[274] | 5194 | % set(handles.num_MaxDiff,'Visible','off') |
---|
[273] | 5195 | % set(handles.thresh_text2,'Visible','off') |
---|
| 5196 | % set(handles.rho,'Style','edit') |
---|
| 5197 | % set(handles.rho,'String','1') |
---|
| 5198 | % set(handles.BATCH,'Enable','on') |
---|
| 5199 | % case 'CivAll' |
---|
| 5200 | % if get(handles.PATCH1,'Value') |
---|
| 5201 | % set(handles.thresh_patch1,'Visible','on') |
---|
| 5202 | % set(handles.thresh_text1,'Visible','on') |
---|
| 5203 | % end |
---|
| 5204 | % set(handles.rho,'Style','edit') |
---|
| 5205 | % set(handles.rho,'String','1') |
---|
| 5206 | % set(handles.BATCH,'Enable','on') |
---|
| 5207 | % case 'CivUvmat' |
---|
| 5208 | % |
---|
| 5209 | % end |
---|
| 5210 | |
---|
| 5211 | |
---|
[274] | 5212 | % --- Executes on button press in check_Stereo. |
---|
| 5213 | function check_Stereo_Callback(hObject, eventdata, handles) |
---|
| 5214 | % hObject handle to check_Stereo (see GCBO) |
---|
[273] | 5215 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 5216 | % handles structure with handles and user data (see GUIDATA) |
---|
| 5217 | |
---|
[274] | 5218 | % Hint: get(hObject,'Value') returns toggle state of check_Stereo |
---|
[273] | 5219 | |
---|
| 5220 | |
---|
| 5221 | |
---|
[274] | 5222 | function num_SubdomainSize_Callback(hObject, eventdata, handles) |
---|
| 5223 | % hObject handle to num_SubdomainSize (see GCBO) |
---|
[273] | 5224 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 5225 | % handles structure with handles and user data (see GUIDATA) |
---|
| 5226 | |
---|
[274] | 5227 | % Hints: get(hObject,'String') returns contents of num_SubdomainSize as text |
---|
| 5228 | % str2double(get(hObject,'String')) returns contents of num_SubdomainSize as a double |
---|
[273] | 5229 | |
---|
| 5230 | |
---|
| 5231 | |
---|
[274] | 5232 | function num_SmoothingParam_Callback(hObject, eventdata, handles) |
---|
| 5233 | % hObject handle to num_SmoothingParam (see GCBO) |
---|
[273] | 5234 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 5235 | % handles structure with handles and user data (see GUIDATA) |
---|
| 5236 | |
---|
[274] | 5237 | % Hints: get(hObject,'String') returns contents of num_SmoothingParam as text |
---|
| 5238 | % str2double(get(hObject,'String')) returns contents of num_SmoothingParam as a double |
---|
[273] | 5239 | |
---|
| 5240 | |
---|
| 5241 | |
---|
[274] | 5242 | function num_MaxDiff_Callback(hObject, eventdata, handles) |
---|
| 5243 | % hObject handle to num_MaxDiff (see GCBO) |
---|
[273] | 5244 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 5245 | % handles structure with handles and user data (see GUIDATA) |
---|
| 5246 | |
---|
[274] | 5247 | % Hints: get(hObject,'String') returns contents of num_MaxDiff as text |
---|
| 5248 | % str2double(get(hObject,'String')) returns contents of num_MaxDiff as a double |
---|
[273] | 5249 | |
---|
| 5250 | |
---|
[274] | 5251 | function num_Nx_Callback(hObject, eventdata, handles) |
---|
| 5252 | % hObject handle to num_Nx (see GCBO) |
---|
[273] | 5253 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 5254 | % handles structure with handles and user data (see GUIDATA) |
---|
| 5255 | |
---|
[274] | 5256 | % Hints: get(hObject,'String') returns contents of num_Nx as text |
---|
| 5257 | % str2double(get(hObject,'String')) returns contents of num_Nx as a double |
---|
[273] | 5258 | |
---|
| 5259 | |
---|
[274] | 5260 | function num_Ny_Callback(hObject, eventdata, handles) |
---|
| 5261 | % hObject handle to num_Ny (see GCBO) |
---|
[273] | 5262 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 5263 | % handles structure with handles and user data (see GUIDATA) |
---|
| 5264 | |
---|
[274] | 5265 | % Hints: get(hObject,'String') returns contents of num_Ny as text |
---|
| 5266 | % str2double(get(hObject,'String')) returns contents of num_Ny as a double |
---|
[273] | 5267 | |
---|
| 5268 | |
---|
| 5269 | % -------------------------------------------------------------------- |
---|
| 5270 | function MenuHelp_Callback(hObject, eventdata, handles) |
---|
| 5271 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
| 5272 | pathelp=fileparts(path_to_uvmat); |
---|
| 5273 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html'); |
---|
| 5274 | 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') |
---|
| 5275 | else |
---|
| 5276 | addpath (fullfile(pathelp,'uvmat_doc')) |
---|
| 5277 | web([helpfile '#civ']) |
---|
[224] | 5278 | end |
---|
[273] | 5279 | |
---|
| 5280 | % -------------------------------------------------------------------- |
---|
| 5281 | function CivX_Callback(hObject, eventdata, handles) |
---|
| 5282 | %set(handles.thresh_patch1,'Visible','off') |
---|
| 5283 | set(handles.thresh_text1,'Visible','off') |
---|
[274] | 5284 | set(handles.num_MaxDiff,'Visible','off') |
---|
[273] | 5285 | set(handles.thresh_text2,'Visible','off') |
---|
| 5286 | set(handles.rho,'Style','edit') |
---|
| 5287 | set(handles.rho,'String','1') |
---|
| 5288 | set(handles.BATCH,'Enable','on') |
---|
| 5289 | |
---|
| 5290 | % -------------------------------------------------------------------- |
---|
| 5291 | function Matlab_Callback(hObject, eventdata, handles) |
---|
| 5292 | set(handles.Matlab,'checked','on') |
---|
| 5293 | set(handles.CivX,'checked','off') |
---|
| 5294 | if get(handles.PATCH1,'Value') |
---|
| 5295 | set(handles.thresh_patch1,'Visible','on') |
---|
| 5296 | set(handles.thresh_text1,'Visible','on') |
---|
| 5297 | end |
---|
| 5298 | if get(handles.PATCH2,'Value') |
---|
[274] | 5299 | set(handles.num_MaxDiff,'Visible','on') |
---|
[273] | 5300 | set(handles.thresh_text2,'Visible','on') |
---|
| 5301 | end |
---|
| 5302 | set(handles.rho,'Style','popupmenu') |
---|
| 5303 | set(handles.rho,'Value',1) |
---|
| 5304 | set(handles.rho,'String',{'1';'2'}) |
---|
| 5305 | set(handles.BATCH,'Enable','off') |
---|
| 5306 | |
---|
| 5307 | % -------------------------------------------------------------------- |
---|
| 5308 | % --- read a panel with handle 'handle' producing a structure 'struct' |
---|
| 5309 | function struct=read_panel(handle) |
---|
| 5310 | hchild=get(handle,'children'); |
---|
| 5311 | for ichild=1:numel(hchild) |
---|
| 5312 | object_style=get(hchild(ichild),'Style'); |
---|
[274] | 5313 | tag=get(hchild(ichild),'tag'); |
---|
[273] | 5314 | check_input=1;%default |
---|
| 5315 | switch object_style |
---|
| 5316 | case 'edit' |
---|
[274] | 5317 | switch(tag(1:4)) |
---|
| 5318 | case 'num_' |
---|
| 5319 | input=str2double(get(hchild(ichild),'String')); |
---|
| 5320 | %deal with undefined input: retrieve the default value stored as UserData |
---|
| 5321 | if isnan(input) |
---|
| 5322 | input=get(hchild(ichild),'UserData'); |
---|
| 5323 | set(hchild(ichild),'String',num2str(input)) |
---|
| 5324 | end |
---|
| 5325 | case 'txt_' |
---|
| 5326 | input=get(hchild(ichild),'String'); |
---|
[273] | 5327 | end |
---|
[274] | 5328 | key=tag(5:end); |
---|
[273] | 5329 | case 'checkbox' |
---|
[274] | 5330 | input=get(hchild(ichild),'Value'); |
---|
| 5331 | key=tag(7:end); |
---|
[273] | 5332 | otherwise |
---|
[274] | 5333 | check_input=0; |
---|
[273] | 5334 | end |
---|
| 5335 | if check_input |
---|
[274] | 5336 | key |
---|
| 5337 | eval(['struct.' key '=input;']) |
---|
[273] | 5338 | end |
---|
| 5339 | end |
---|