| 1 | %'civ': function associated with the interface 'civ.fig' for PIV, spline interpolation and stereo PIV (patch) |
|---|
| 2 | %------------------------------------------------------------------------ |
|---|
| 3 | % provides an interface for the software CIVx |
|---|
| 4 | % function varargout = civ(varargin) |
|---|
| 5 | % provides an interface for the software CIVx |
|---|
| 6 | % |
|---|
| 7 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
|---|
| 8 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org. |
|---|
| 9 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
|---|
| 10 | % This file is part of the toolbox UVMAT. |
|---|
| 11 | % |
|---|
| 12 | % UVMAT is free software; you can redistribute it and/or modify |
|---|
| 13 | % it under the terms of the GNU General Public License as published by |
|---|
| 14 | % the Free Software Foundation; either version 2 of the License, or |
|---|
| 15 | % (at your option) any later version. |
|---|
| 16 | % |
|---|
| 17 | % UVMAT is distributed in the hope that it will be useful, |
|---|
| 18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 20 | % GNU General Public License (file UVMAT/COPYING.txt) for more details. |
|---|
| 21 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
|---|
| 22 | function varargout = civ(varargin) |
|---|
| 23 | |
|---|
| 24 | % Last Modified by GUIDE v2.5 05-Jan-2011 16:19:30 |
|---|
| 25 | % Begin initialization code - DO NOT EDIT |
|---|
| 26 | gui_Singleton = 1; |
|---|
| 27 | gui_State = struct('gui_Name', mfilename, ... |
|---|
| 28 | 'gui_Singleton', gui_Singleton, ... |
|---|
| 29 | 'gui_OpeningFcn', @civ_OpeningFcn, ... |
|---|
| 30 | 'gui_OutputFcn', @civ_OutputFcn, ... |
|---|
| 31 | 'gui_LayoutFcn', [] , ... |
|---|
| 32 | 'gui_Callback', []); |
|---|
| 33 | if nargin && ischar(varargin{1}) |
|---|
| 34 | gui_State.gui_Callback = str2func(varargin{1}); |
|---|
| 35 | end |
|---|
| 36 | |
|---|
| 37 | if nargout |
|---|
| 38 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
|---|
| 39 | else |
|---|
| 40 | gui_mainfcn(gui_State, varargin{:}); |
|---|
| 41 | end |
|---|
| 42 | % End initialization code - DO NOT EDIT |
|---|
| 43 | |
|---|
| 44 | %------------------------------------------------------------------------ |
|---|
| 45 | % --- Executes just before civ is made visible. |
|---|
| 46 | function civ_OpeningFcn(hObject, eventdata, handles, param) |
|---|
| 47 | %------------------------------------------------------------------------ |
|---|
| 48 | % This function has no output args, see OutputFcn. |
|---|
| 49 | % hObject handle to figure |
|---|
| 50 | % eventdata reserved - to be defined in a future version of MATLAB |
|---|
| 51 | % handles structure with handles and user data (see GUIDATA) |
|---|
| 52 | % varargin command line arguments to civ (see VARARGIN) |
|---|
| 53 | global patch_newBin %=1 if new patch processing available |
|---|
| 54 | %filebase: root name |
|---|
| 55 | %nom_type: nomencalture used ('png_old','_i_j'...) |
|---|
| 56 | %list of field numbers to process |
|---|
| 57 | %subdir: subdirectory of the opened netcdf file |
|---|
| 58 | %ind_opening: operation number advised for beginning (1=civ1,2=fix1,3=patch1,4=civ2,5=fix2,6=patch2), |
|---|
| 59 | %ind_a_opening ind_b_opening chosen pair from the opened netcdf file |
|---|
| 60 | % Choose default command line output for civ |
|---|
| 61 | handles.output = hObject; |
|---|
| 62 | % Update handles structure |
|---|
| 63 | guidata(hObject, handles); |
|---|
| 64 | |
|---|
| 65 | %default initial parameters |
|---|
| 66 | filebase=''; % root file name ('filebase'.civ) |
|---|
| 67 | ext=[]; |
|---|
| 68 | testall=0; |
|---|
| 69 | %default input parameters: |
|---|
| 70 | num_i1=1; % set of field i numbers |
|---|
| 71 | num_i2=1; % set of field i numbers |
|---|
| 72 | num_j1=1; % set of field j numbers (fields a) |
|---|
| 73 | num_j2=1; % second set of field j numbers (fields b) |
|---|
| 74 | subdir='A'; % subdir for the netcdf result files |
|---|
| 75 | ind_opening=1; % proposed operation number (1=civ1,2=fix1,3=patch1,4=civ2,5=fix2,6=patch2) |
|---|
| 76 | %load the initial parameters if the interface is started from uvmat |
|---|
| 77 | if exist('param','var')&&isstruct(param)% the interface is opened from uvmat |
|---|
| 78 | filebase=param.RootName; |
|---|
| 79 | nom_type_read=param.NomType; |
|---|
| 80 | num_i1=param.num1; |
|---|
| 81 | if isnan(num_i1),num_i1=1;end |
|---|
| 82 | num_i2=param.num2; |
|---|
| 83 | if isnan(num_i2),num_i2=num_i1;end |
|---|
| 84 | num_j1=param.num_a; |
|---|
| 85 | if isnan(num_j1),num_j1=1;end |
|---|
| 86 | num_j2=param.num_b; |
|---|
| 87 | if isnan(num_j2),num_j2=num_j1;end |
|---|
| 88 | subdir=param.SubDir; |
|---|
| 89 | ind_opening=param.IndOpening; |
|---|
| 90 | ext=param.ImaExt; |
|---|
| 91 | end |
|---|
| 92 | browse.num_i1=num_i1; |
|---|
| 93 | browse.num_i2=num_i2; |
|---|
| 94 | browse.num_j1=num_j1; |
|---|
| 95 | browse.num_j2=num_j2; |
|---|
| 96 | if ~isempty(ext) && (~isempty(imformats(ext(2:end)))||strcmpi(ext,'.avi'));%if an image file has been opened by uvmat |
|---|
| 97 | set(handles.ImaExt,'String',ext) |
|---|
| 98 | browse.ext_ima=ext; |
|---|
| 99 | if exist('nom_type_read','var') |
|---|
| 100 | browse.nom_type_ima=nom_type_read; % the image nomenclature is stored |
|---|
| 101 | end |
|---|
| 102 | elseif isequal(ext,'.nc') |
|---|
| 103 | if exist('nom_type_read','var') |
|---|
| 104 | browse.nom_type_nc=nom_type_read;% the netcdf nomenclature is stored |
|---|
| 105 | end |
|---|
| 106 | end |
|---|
| 107 | set(handles.RootName,'String',filebase); |
|---|
| 108 | set(handles.ImaDoc,'UserData',testall); |
|---|
| 109 | set(handles.ImaDoc,'String',ext) |
|---|
| 110 | |
|---|
| 111 | %read names of the .exe file to adjust the interface according to available binaries |
|---|
| 112 | path_uvmat=which('uvmat');% check the path detected for source file uvmat |
|---|
| 113 | path_UVMAT=fileparts(path_uvmat); %path to UVMAT |
|---|
| 114 | errormsg=[];%default error message |
|---|
| 115 | % xmlfile=fullfile(path_UVMAT,'PARAM.xml'); |
|---|
| 116 | % if ~exist(xmlfile,'file') |
|---|
| 117 | xmlfile='PARAM.xml'; |
|---|
| 118 | % end |
|---|
| 119 | if exist(xmlfile,'file') |
|---|
| 120 | try |
|---|
| 121 | t=xmltree(xmlfile); |
|---|
| 122 | sparam=convert(t); |
|---|
| 123 | catch |
|---|
| 124 | errormsg={' Unable to read the file PARAM.xml defining the civx binaries:'; lasterr}; |
|---|
| 125 | end |
|---|
| 126 | else |
|---|
| 127 | errormsg=[xmlfile ' not found: path to civx binaries undefined']; |
|---|
| 128 | end |
|---|
| 129 | |
|---|
| 130 | |
|---|
| 131 | if ~isempty(errormsg) |
|---|
| 132 | msgbox_uvmat('ERROR',errormsg); |
|---|
| 133 | end |
|---|
| 134 | % patch_newBin=''; |
|---|
| 135 | test_batch=0;%default: ,no batch mode available |
|---|
| 136 | if isfield(sparam,'BatchParam') && isfield(sparam.BatchParam,'BatchMode') |
|---|
| 137 | test_batch=strcmp(sparam.BatchParam.BatchMode,'sge'); %sge is currently the only implemented batch mod |
|---|
| 138 | end |
|---|
| 139 | if test_batch==0 |
|---|
| 140 | set(handles.BATCH,'Enable','off')% put the BATCH button in grey (unactivated) |
|---|
| 141 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784])% put the BATCH button in grey (unactivated) |
|---|
| 142 | end |
|---|
| 143 | if isfield(sparam.RunParam,'CivBin') |
|---|
| 144 | if ~exist(sparam.RunParam.CivBin,'file') |
|---|
| 145 | sparam.RunParam.CivBin=fullfile(path_UVMAT,sparam.RunParam.CivBin); |
|---|
| 146 | end |
|---|
| 147 | else |
|---|
| 148 | sparam.RunParam.CivBin=''; |
|---|
| 149 | end |
|---|
| 150 | patch_newBin=exist(sparam.RunParam.CivBin,'file'); |
|---|
| 151 | set(handles.subdir_civ1,'String',subdir)%default subdir on which uvmat was working |
|---|
| 152 | set(handles.subdir_civ2,'String',subdir)%default subdir on which uvmat was working |
|---|
| 153 | |
|---|
| 154 | %initiate advised operations |
|---|
| 155 | if isequal(ind_opening,[]) |
|---|
| 156 | ind_opening=1; % default |
|---|
| 157 | end |
|---|
| 158 | % set default operation options |
|---|
| 159 | enable_civ1(handles,'off') |
|---|
| 160 | enable_civ2(handles,'off') |
|---|
| 161 | enable_pair1(handles,'on') |
|---|
| 162 | enable_fix1(handles,'off') |
|---|
| 163 | desable_patch1(handles) |
|---|
| 164 | desable_fix2(handles) |
|---|
| 165 | desable_patch2(handles) |
|---|
| 166 | set(handles.CIV1,'Value',0) |
|---|
| 167 | set(handles.FIX1,'Value',0) |
|---|
| 168 | set(handles.PATCH1,'Value',0) |
|---|
| 169 | set(handles.CIV2,'Value',0) |
|---|
| 170 | set(handles.FIX2,'Value',0) |
|---|
| 171 | set(handles.PATCH2,'Value',0) |
|---|
| 172 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
|---|
| 173 | if isequal(ind_opening,1) |
|---|
| 174 | set(handles.CIV1,'Value',1) |
|---|
| 175 | enable_civ1(handles,'on') |
|---|
| 176 | elseif isequal(ind_opening,2) |
|---|
| 177 | set(handles.FIX1,'Value',1) |
|---|
| 178 | enable_fix1(handles,'on') |
|---|
| 179 | elseif isequal(ind_opening,3) |
|---|
| 180 | set(handles.PATCH1,'Value',1) |
|---|
| 181 | enable_patch1(handles) |
|---|
| 182 | elseif isequal(ind_opening,4) |
|---|
| 183 | set(handles.CIV2,'Value',1) |
|---|
| 184 | enable_civ2(handles,1) |
|---|
| 185 | elseif isequal(ind_opening,5) |
|---|
| 186 | set(handles.FIX2,'Value',1) |
|---|
| 187 | enable_fix2(handles) |
|---|
| 188 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
|---|
| 189 | set(handles.list_pair_civ2,'Enable','On') |
|---|
| 190 | set(handles.list_pair_civ2,'Enable','On') |
|---|
| 191 | enable_pair1(handles,'off') |
|---|
| 192 | elseif isequal(ind_opening,6) |
|---|
| 193 | set(handles.PATCH2,'Value',1) |
|---|
| 194 | enable_patch2(handles) |
|---|
| 195 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
|---|
| 196 | set(handles.list_pair_civ2,'Enable','On') |
|---|
| 197 | enable_pair1(handles,'off') |
|---|
| 198 | end |
|---|
| 199 | |
|---|
| 200 | % set the range of fields (1:1 by default) and selected pair |
|---|
| 201 | if isequal(num_i2,num_i1) |
|---|
| 202 | num_ref_i=num_i1; |
|---|
| 203 | else |
|---|
| 204 | num_ref_i=floor((num_i1+num_i2)/2); |
|---|
| 205 | browse.incr_pair(1)=num_i2-num_i1; |
|---|
| 206 | browse.incr_pair(2)=0; |
|---|
| 207 | end |
|---|
| 208 | if isequal(num_j1,num_j2) |
|---|
| 209 | if isnan(num_j1) |
|---|
| 210 | num_ref_j=1; |
|---|
| 211 | else |
|---|
| 212 | num_ref_j=num_j1; |
|---|
| 213 | end |
|---|
| 214 | else |
|---|
| 215 | num_ref_j=floor((num_j1+num_j2)/2); |
|---|
| 216 | browse.incr_pair(2)=num_j2-num_j1; |
|---|
| 217 | end |
|---|
| 218 | set(handles.first_i,'String',num2str(num_ref_i)); |
|---|
| 219 | set(handles.last_i,'String',num2str(num_ref_i)); |
|---|
| 220 | set(handles.first_j,'String',num2str(num_ref_j)); |
|---|
| 221 | set(handles.last_j,'String',num2str(num_ref_j)); |
|---|
| 222 | set(handles.ref_i,'String',num2str(num_ref_i)); |
|---|
| 223 | set(handles.ref_j,'String',num2str(num_ref_j)); |
|---|
| 224 | set(handles.ref_i_civ2,'String',num2str(num_ref_i)); |
|---|
| 225 | set(handles.ref_j_civ2,'String',num2str(num_ref_j)); |
|---|
| 226 | set(handles.browse_root,'UserData',browse); |
|---|
| 227 | if exist('param','var')%varargin the interface is opened from uvmat |
|---|
| 228 | RootName_Callback(hObject, eventdata, handles); |
|---|
| 229 | end |
|---|
| 230 | |
|---|
| 231 | % set(handles.waitbar_1,'Position',[0.946 0.877 0.03 0.001]) |
|---|
| 232 | % set(handles.waitbar_patch1,'Position',[0.946 0.626 0.03 0.001]) |
|---|
| 233 | % set(handles.waitbar_civ2,'Position',[0.946 0.406 0.03 0.001]) |
|---|
| 234 | % set(handles.waitbar_patch2,'Position',[0.946 0.187 0.03 0.001]) |
|---|
| 235 | |
|---|
| 236 | %------------------------------------------------------------------------ |
|---|
| 237 | % --- Outputs from this function are returned to the command line. |
|---|
| 238 | function varargout = civ_OutputFcn(hObject, eventdata, handles) |
|---|
| 239 | %------------------------------------------------------------------------ |
|---|
| 240 | % varargout cell array for returning output args (see VARARGOUT); |
|---|
| 241 | % hObject handle to figure |
|---|
| 242 | % eventdata reserved - to be defined in a future version of MATLAB |
|---|
| 243 | % handles structure with handles and user data (see GUIDATA) |
|---|
| 244 | % Get default command line output from handles structure |
|---|
| 245 | varargout{1} = handles.output; |
|---|
| 246 | |
|---|
| 247 | %------------------------------------------------------------------------ |
|---|
| 248 | % --- Executes on button press in browse_root. |
|---|
| 249 | function browse_root_Callback(hObject, eventdata, handles) |
|---|
| 250 | %------------------------------------------------------------------------ |
|---|
| 251 | %get the input file properties |
|---|
| 252 | filebase=get(handles.RootName,'String'); |
|---|
| 253 | oldfile=''; %default |
|---|
| 254 | if isempty(filebase)|| isequal(filebase,'')%loads the previously stored file name and set it as default in the file_input box |
|---|
| 255 | dir_perso=prefdir; |
|---|
| 256 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
|---|
| 257 | if exist(profil_perso,'file') |
|---|
| 258 | h=load (profil_perso); |
|---|
| 259 | if isfield(h,'filebase')&& ischar(h.filebase) |
|---|
| 260 | oldfile=h.filebase; |
|---|
| 261 | end |
|---|
| 262 | if isfield(h,'RootPath') && ischar(h.RootPath) |
|---|
| 263 | oldfile=h.RootPath; |
|---|
| 264 | end |
|---|
| 265 | end |
|---|
| 266 | else |
|---|
| 267 | oldfile=filebase; |
|---|
| 268 | end |
|---|
| 269 | % testall=get(handles.ImaDoc,'UserData'); |
|---|
| 270 | ind_opening=1;%default |
|---|
| 271 | browse.incr_pair=[0 0]; %default |
|---|
| 272 | % if testall |
|---|
| 273 | % menu={'*.*', 'All Files (*.*)'; '*.xml; *.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ... |
|---|
| 274 | % '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc','.nc files'}; |
|---|
| 275 | % else % menu selecting only .civ or .avi files |
|---|
| 276 | menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)'; |
|---|
| 277 | '*.xml', '.xml files '; ... |
|---|
| 278 | '*.civ', '.civ files '; ... |
|---|
| 279 | '*.png','.png image files'; ... |
|---|
| 280 | '*.jpg',' jpeg image files'; ... |
|---|
| 281 | '*.tif','.tif image files'; ... |
|---|
| 282 | '*.avi;*.AVI','.avi movie files'; ... |
|---|
| 283 | '*.nc','.netcdf files'; ... |
|---|
| 284 | '*.*', 'All Files (*.*)'}; |
|---|
| 285 | % menu={'*.xml;*.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ... |
|---|
| 286 | % '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc', '.nc files';... |
|---|
| 287 | % '*.*', 'All Files (*.*)'}; |
|---|
| 288 | % end |
|---|
| 289 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile); |
|---|
| 290 | fileinput=[PathName FileName];%complete file name |
|---|
| 291 | sizf=size(fileinput); |
|---|
| 292 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
|---|
| 293 | [path,name,ext]=fileparts(fileinput); |
|---|
| 294 | testeditxml=0; |
|---|
| 295 | if isequal(ext,'.xml') |
|---|
| 296 | testeditxml=1; |
|---|
| 297 | t_browse=xmltree(fileinput); |
|---|
| 298 | head_element=get(t_browse,1); |
|---|
| 299 | if isfield(head_element,'name')&& isequal(head_element.name,'ImaDoc') |
|---|
| 300 | testeditxml=0; |
|---|
| 301 | end |
|---|
| 302 | end |
|---|
| 303 | if testeditxml==1 || isequal(ext,'.xls') |
|---|
| 304 | heditxml=editxml({fileinput}); |
|---|
| 305 | set(heditxml,'Tag','browser') |
|---|
| 306 | waitfor(heditxml,'Tag','idle') |
|---|
| 307 | if ~ishandle(heditxml) |
|---|
| 308 | return |
|---|
| 309 | end |
|---|
| 310 | attr=findobj(get(heditxml,'children'),'Tag','CurrentAttributes'); |
|---|
| 311 | set(handles.browse,'UserData',fileinput)% store for future opening with browser |
|---|
| 312 | fileinput=get(attr,'UserData'); |
|---|
| 313 | if ~exist(fileinput,'file') |
|---|
| 314 | return |
|---|
| 315 | end |
|---|
| 316 | end |
|---|
| 317 | [RootPath,RootFile,str1,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput); |
|---|
| 318 | filebase=fullfile(RootPath,RootFile); |
|---|
| 319 | num_i1=str2double(str1); |
|---|
| 320 | if isnan(num_i1),num_i1=1;end |
|---|
| 321 | num_i2=str2double(str2); |
|---|
| 322 | if isnan(num_i2),num_i2=num_i1;end |
|---|
| 323 | num_j1=stra2num(str_a); |
|---|
| 324 | if isnan(num_j1),num_j1=1;end |
|---|
| 325 | num_j2=stra2num(str_b); |
|---|
| 326 | if isnan(num_j2),num_j2=num_j1;end |
|---|
| 327 | if isequal(get(handles.compare,'Value'),1) |
|---|
| 328 | browse=[];%initialisation |
|---|
| 329 | else |
|---|
| 330 | browse=get(handles.browse_root,'UserData'); |
|---|
| 331 | end |
|---|
| 332 | browse.num_i1=num_i1; |
|---|
| 333 | browse.num_i2=num_i2; |
|---|
| 334 | browse.num_j1=num_j1; |
|---|
| 335 | browse.num_j2=num_j2; |
|---|
| 336 | if length(ext)>1 && (~isempty(imformats(ext(2:end)))||strcmpi(ext,'.avi'));%if an image file has been opened by uvmat |
|---|
| 337 | browse.nom_type_ima=nom_type; |
|---|
| 338 | browse.ext_ima=ext; |
|---|
| 339 | set(handles.ImaExt,'String',ext) |
|---|
| 340 | end |
|---|
| 341 | set(handles.ImaDoc,'String',ext); |
|---|
| 342 | |
|---|
| 343 | %%%%% read the state of the selected netcdf file to advise default operation |
|---|
| 344 | if isequal(ext,'.nc') |
|---|
| 345 | browse.nom_type_nc=nom_type; |
|---|
| 346 | ind_opening=2;% propose 'fix' as the default option |
|---|
| 347 | Data=nc2struct(fileinput,[]); |
|---|
| 348 | if isfield(Data,'absolut_time_T0')%test for civx files |
|---|
| 349 | if isfield(Data,'fix') && isequal(Data.fix,1) |
|---|
| 350 | ind_opening=3; |
|---|
| 351 | end |
|---|
| 352 | if isfield(Data,'patch') && isequal(Data.patch,1) |
|---|
| 353 | ind_opening=4; |
|---|
| 354 | end |
|---|
| 355 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
|---|
| 356 | ind_opening=5; |
|---|
| 357 | end |
|---|
| 358 | if isfield(Data,'fix2') && isequal(Data.fix2,1) |
|---|
| 359 | ind_opening=6; |
|---|
| 360 | end |
|---|
| 361 | testciv=1; %TO SUPPRESS WITH NEW VERSION OF CIVX |
|---|
| 362 | else |
|---|
| 363 | ind_opening=3; %GUI used only for patch |
|---|
| 364 | testciv=0; |
|---|
| 365 | end |
|---|
| 366 | set(handles.subdir_civ1,'String',subdir);%set the default subdir directories for installing the .nc results |
|---|
| 367 | set(handles.subdir_civ2,'String',subdir); |
|---|
| 368 | browse.testciv=testciv; |
|---|
| 369 | browse.ind_opening=ind_opening; |
|---|
| 370 | end |
|---|
| 371 | set(handles.RootName,'String',filebase); |
|---|
| 372 | set(handles.ImaDoc,'String',ext); |
|---|
| 373 | if ~isempty(num_i1) |
|---|
| 374 | ref_i=num_i1; |
|---|
| 375 | if ~isempty(num_i2) |
|---|
| 376 | ref_i=floor((ref_i+num_i2)/2);% reference image number corresponding to the file |
|---|
| 377 | browse.incr_pair(1)=num_i2-num_i1; |
|---|
| 378 | browse.incr_pair(2)=0; |
|---|
| 379 | end |
|---|
| 380 | set(handles.first_i,'String',num2str(ref_i)); |
|---|
| 381 | set(handles.last_i,'String',num2str(ref_i)); |
|---|
| 382 | set(handles.ref_i,'String',num2str(ref_i)); |
|---|
| 383 | set(handles.ref_i_civ2,'String',num2str(ref_i)) |
|---|
| 384 | end |
|---|
| 385 | if isempty(num_j1) |
|---|
| 386 | set(handles.ref_j,'String','1'); |
|---|
| 387 | set(handles.ref_j_civ2,'String','1'); |
|---|
| 388 | else |
|---|
| 389 | ref_j=num_j1; |
|---|
| 390 | if ~isempty(num_j2) |
|---|
| 391 | ref_j=floor((num_j1+num_j2)/2); |
|---|
| 392 | browse.incr_pair(2)=num_j2-num_j1; |
|---|
| 393 | end |
|---|
| 394 | set(handles.first_j,'String',num2str(ref_j)); |
|---|
| 395 | set(handles.last_j,'String',num2str(ref_j)); |
|---|
| 396 | set(handles.ref_j,'String',num2str(ref_j)); |
|---|
| 397 | set(handles.ref_j_civ2,'String',num2str(ref_j)); |
|---|
| 398 | end |
|---|
| 399 | |
|---|
| 400 | % set default operation options |
|---|
| 401 | enable_civ1(handles,'off') |
|---|
| 402 | enable_civ2(handles,'off') |
|---|
| 403 | enable_pair1(handles,'on') |
|---|
| 404 | enable_fix1(handles,'off') |
|---|
| 405 | desable_patch1(handles) |
|---|
| 406 | desable_fix2(handles) |
|---|
| 407 | desable_patch2(handles) |
|---|
| 408 | set(handles.CIV1,'Value',0) |
|---|
| 409 | set(handles.FIX1,'Value',0) |
|---|
| 410 | set(handles.PATCH1,'Value',0) |
|---|
| 411 | set(handles.CIV2,'Value',0) |
|---|
| 412 | set(handles.FIX2,'Value',0) |
|---|
| 413 | set(handles.PATCH2,'Value',0) |
|---|
| 414 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
|---|
| 415 | if isequal(ind_opening,1) |
|---|
| 416 | set(handles.CIV1,'Value',1) |
|---|
| 417 | enable_civ1(handles,'on') |
|---|
| 418 | elseif isequal(ind_opening,2) |
|---|
| 419 | set(handles.FIX1,'Value',1) |
|---|
| 420 | enable_fix1(handles,'on') |
|---|
| 421 | elseif isequal(ind_opening,3) |
|---|
| 422 | set(handles.PATCH1,'Value',1) |
|---|
| 423 | enable_patch1(handles) |
|---|
| 424 | elseif isequal(ind_opening,4) |
|---|
| 425 | set(handles.CIV2,'Value',1) |
|---|
| 426 | enable_civ2(handles,1) |
|---|
| 427 | elseif isequal(ind_opening,5) |
|---|
| 428 | enable_pair1(handles,'off') |
|---|
| 429 | set(handles.FIX2,'Value',1) |
|---|
| 430 | enable_fix2(handles) |
|---|
| 431 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
|---|
| 432 | set(handles.list_pair_civ2,'Enable','On') |
|---|
| 433 | set(handles.list_pair_civ2,'Enable','On') |
|---|
| 434 | elseif isequal(ind_opening,6) |
|---|
| 435 | enable_pair1(handles,'off') |
|---|
| 436 | set(handles.PATCH2,'Value',1) |
|---|
| 437 | enable_patch2(handles) |
|---|
| 438 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
|---|
| 439 | set(handles.list_pair_civ2,'Enable','On') |
|---|
| 440 | end |
|---|
| 441 | set(handles.browse_root,'UserData',browse);% store information from browser |
|---|
| 442 | % testall=isequal(menu(filtindex,1),{'*.*'}); |
|---|
| 443 | % set(handles.ImaDoc,'UserData',testall); |
|---|
| 444 | |
|---|
| 445 | RootName_Callback(hObject, eventdata, handles); |
|---|
| 446 | |
|---|
| 447 | %------------------------------------------------------------------------ |
|---|
| 448 | function ImaDoc_Callback(hObject, eventdata, handles) |
|---|
| 449 | %------------------------------------------------------------------------ |
|---|
| 450 | RootName_Callback(hObject, eventdata, handles) |
|---|
| 451 | |
|---|
| 452 | %------------------------------------------------------------------------ |
|---|
| 453 | % --- function activated when a new filebase (image series) is introduced |
|---|
| 454 | function RootName_Callback(hObject, eventdata, handles) |
|---|
| 455 | %------------------------------------------------------------------------ |
|---|
| 456 | set(handles.compare,'Visible','on') |
|---|
| 457 | %ext_ima=get(handles.ImaExt,'String'); |
|---|
| 458 | ext_ima='';%default |
|---|
| 459 | nom_type_ima=[];%default |
|---|
| 460 | field_count=1;%default |
|---|
| 461 | nom_type_nc=[]; |
|---|
| 462 | time=[]; |
|---|
| 463 | TimeUnit='frame'; %default |
|---|
| 464 | CoordUnit='px';%default |
|---|
| 465 | pxcmx_search=[];%default |
|---|
| 466 | pxcmy_search=[];%default |
|---|
| 467 | filebase=get(handles.RootName,'String'); |
|---|
| 468 | ext_imadoc=get(handles.ImaDoc,'String'); |
|---|
| 469 | browse=get(handles.browse_root,'UserData');%default |
|---|
| 470 | if isfield(browse,'nom_type_ima') |
|---|
| 471 | nom_type_ima=browse.nom_type_ima;% get an image nomenclature type already determined by an input image name |
|---|
| 472 | end |
|---|
| 473 | if isfield(browse,'ext_ima') |
|---|
| 474 | ext_ima=browse.ext_ima; |
|---|
| 475 | end |
|---|
| 476 | if isfield(browse,'nom_type_nc') |
|---|
| 477 | nom_type_nc=browse.nom_type_nc;% get an image nomenclature type already determined by an input image name |
|---|
| 478 | end |
|---|
| 479 | if isfield(browse,'num_i1') |
|---|
| 480 | field_count=browse.num_i1;% get an image index type already determined by an input file |
|---|
| 481 | end |
|---|
| 482 | |
|---|
| 483 | %default first_i and j and increments |
|---|
| 484 | first_i=str2double(get(handles.first_i,'String'));%value possibly set by uvmat_Opening |
|---|
| 485 | if isnan(first_i)|| first_i < 1 |
|---|
| 486 | first_i=1; %default first_i |
|---|
| 487 | end |
|---|
| 488 | last_i=str2double(get(handles.last_i,'String')); |
|---|
| 489 | if isnan(last_i)|| last_i < first_i |
|---|
| 490 | last_i=first_i; %default last_i |
|---|
| 491 | end |
|---|
| 492 | first_j=str2double(get(handles.first_j,'String')); |
|---|
| 493 | if isnan(first_j)|| first_j < 1 |
|---|
| 494 | first_j=1; %default first_j |
|---|
| 495 | end |
|---|
| 496 | last_j=str2double(get(handles.last_j,'String')); |
|---|
| 497 | if isnan(last_j)|| last_j < first_j |
|---|
| 498 | last_j=first_j; %default last_j |
|---|
| 499 | end |
|---|
| 500 | incr_i=str2double(get(handles.incr_i,'String')); |
|---|
| 501 | if isnan(incr_i) || incr_i < 1; |
|---|
| 502 | set(handles.incr_i,'String','1') %default incr_i |
|---|
| 503 | end |
|---|
| 504 | incr_j=str2double(get(handles.incr_j,'String')); |
|---|
| 505 | if isnan(incr_j) || incr_j < 1; |
|---|
| 506 | set(handles.incr_j,'String','1') %default incr_j |
|---|
| 507 | end |
|---|
| 508 | dt=[];%default |
|---|
| 509 | testmode=0;%default |
|---|
| 510 | nbfield=[]; %default |
|---|
| 511 | nburst=[];%default |
|---|
| 512 | pxcmx=1; |
|---|
| 513 | pxcmy=1; |
|---|
| 514 | |
|---|
| 515 | %look for an image documentation file |
|---|
| 516 | if ~strcmp(ext_imadoc,'.xml') && ~strcmp(ext_imadoc,'.civ')&& ~strcmpi(ext_imadoc,'.avi') |
|---|
| 517 | if exist([filebase '.xml'],'file') |
|---|
| 518 | ext_imadoc='.xml'; |
|---|
| 519 | elseif exist([filebase '.civxml'],'file') |
|---|
| 520 | ext_imadoc='.civxml'; |
|---|
| 521 | elseif exist([filebase '.civ'],'file') |
|---|
| 522 | ext_imadoc='.civ'; |
|---|
| 523 | elseif exist([filebase '.avi'],'file') |
|---|
| 524 | ext_imadoc='.avi'; |
|---|
| 525 | elseif exist([filebase '.AVI'],'file') |
|---|
| 526 | ext_imadoc='.AVI'; |
|---|
| 527 | end |
|---|
| 528 | set(handles.ImaDoc,'String',ext_imadoc) |
|---|
| 529 | end |
|---|
| 530 | |
|---|
| 531 | %%%%%%%% read image documentation file %%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 532 | mode=''; %default |
|---|
| 533 | set(handles.ImaDoc,'BackgroundColor',[1 1 0]) |
|---|
| 534 | drawnow |
|---|
| 535 | if isequal(ext_imadoc,'.civxml') || isequal(ext_imadoc,'.xml')|| isequal(ext_imadoc,'.civ') |
|---|
| 536 | set(handles.ref_i,'Visible','On')%use a reference index |
|---|
| 537 | set(handles.ref_j,'Visible','On') |
|---|
| 538 | elseif isequal(ext_imadoc,'.avi') || isequal(ext_imadoc,'.AVI') |
|---|
| 539 | set(handles.ref_j,'Visible','Off') |
|---|
| 540 | else |
|---|
| 541 | set(handles.ref_i,'Visible','Off') |
|---|
| 542 | set(handles.ref_j,'Visible','Off') |
|---|
| 543 | end |
|---|
| 544 | testima_xml=0; |
|---|
| 545 | if isequal(ext_imadoc,'.civxml')%TO ABANDON |
|---|
| 546 | [nbfield,nbfield2,time]=read_civxml([filebase '.civxml']); |
|---|
| 547 | mode='pair j1-j2'; |
|---|
| 548 | if isempty(nom_type_ima)% dtermine types by default if not already selected by browser or uvmat |
|---|
| 549 | nom_type_ima='_i_j'; |
|---|
| 550 | end |
|---|
| 551 | elseif isequal(ext_imadoc,'.xml') |
|---|
| 552 | [XmlData,warntext]=imadoc2struct([filebase '.xml']); |
|---|
| 553 | ext_ima_read=[]; |
|---|
| 554 | nom_type_read=[]; |
|---|
| 555 | if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')&&ischar(XmlData.Heading.ImageName)% get image nom type and extension from the xml file |
|---|
| 556 | [PP,FF,fc,str2,str_a,str_b,ext_ima_read,nom_type_read]=name2display(XmlData.Heading.ImageName); |
|---|
| 557 | fullname=fullfile(fileparts(filebase),XmlData.Heading.ImageName); %full name (including path) of the first image defined by the xmle file, |
|---|
| 558 | if ~exist(fullname,'file') |
|---|
| 559 | msgbox_uvmat('WARNING',['FirstImage ' fullname ' defined in the xml file does not exist']) |
|---|
| 560 | end |
|---|
| 561 | end |
|---|
| 562 | if isfield(XmlData,'Time') |
|---|
| 563 | time=XmlData.Time; |
|---|
| 564 | nbfield=size(time,1); |
|---|
| 565 | nbfield2=size(time,2); |
|---|
| 566 | %transform .Time to a column vector if it is a line vector thenomenclature uses a single index: correct possible bug in xml |
|---|
| 567 | if isequal(nbfield,1) && ~isequal(nbfield2,1)% .Time is a line vector |
|---|
| 568 | if numel(nom_type_read)>=2 && isempty(regexp(nom_type_read(2:end),'\D')) |
|---|
| 569 | time=time'; |
|---|
| 570 | nbfield=nbfield2; |
|---|
| 571 | nbfield2=1; |
|---|
| 572 | end |
|---|
| 573 | end |
|---|
| 574 | end |
|---|
| 575 | if isfield(XmlData,'TimeUnit') |
|---|
| 576 | TimeUnit=XmlData.TimeUnit; |
|---|
| 577 | end |
|---|
| 578 | if isfield(XmlData,'Npx') |
|---|
| 579 | npx=XmlData.Npx; |
|---|
| 580 | npy=XmlData.Npy; |
|---|
| 581 | end |
|---|
| 582 | pxcmx_search=1; |
|---|
| 583 | pxcmy_search=1; |
|---|
| 584 | if isfield(XmlData,'GeometryCalib') |
|---|
| 585 | tsai=XmlData.GeometryCalib; |
|---|
| 586 | if isfield(tsai,'f') && isfield(tsai,'Tz') && isfield(tsai,'dpx') && isfield(tsai,'dpy')&& isfield(tsai,'R') |
|---|
| 587 | rot2D=tsai.R(1:2,[1,2]); |
|---|
| 588 | pxcmx_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpx); |
|---|
| 589 | pxcmy_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpy); |
|---|
| 590 | end |
|---|
| 591 | if isfield(tsai,'CoordUnit') |
|---|
| 592 | CoordUnit=tsai.CoordUnit; |
|---|
| 593 | end |
|---|
| 594 | end |
|---|
| 595 | elseif strcmp(ext_imadoc,'.civ')% case of .civ image documentation file |
|---|
| 596 | [error,time,TimeUnit,mode,npx,npy]=read_imatext([filebase '.civ']); |
|---|
| 597 | if error==2, msgbox_uvmat('WARNING',['no file ' filebase '.civ']); |
|---|
| 598 | elseif error==1, msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file'); |
|---|
| 599 | end |
|---|
| 600 | nom_type_ima='001a'; |
|---|
| 601 | elseif strcmpi(ext_imadoc,'.avi') |
|---|
| 602 | nom_type_ima='*'; |
|---|
| 603 | ext_ima=ext_imadoc; |
|---|
| 604 | set(handles.mode,'Value',1); |
|---|
| 605 | set(handles.mode,'String',{'series(Di)'}) |
|---|
| 606 | dt=0.04;%default |
|---|
| 607 | if exist([filebase ext_imadoc],'file')==2 |
|---|
| 608 | info=aviinfo([filebase ext_imadoc]);%read infos on the avi movie |
|---|
| 609 | dt=1/info.FramesPerSecond;%time interval between successive frames |
|---|
| 610 | nbfield=info.NumFrames;%number of frames |
|---|
| 611 | end |
|---|
| 612 | time=(dt*(0:nbfield-1))';%list of image times |
|---|
| 613 | end |
|---|
| 614 | if isempty(time) |
|---|
| 615 | set(handles.ImaDoc,'String',''); %xml file not used for timing |
|---|
| 616 | end |
|---|
| 617 | set(handles.ImaDoc,'BackgroundColor',[1 1 1]) |
|---|
| 618 | |
|---|
| 619 | %get the imabe nomenclature type if not defined by the input file nor by the xml file |
|---|
| 620 | dirima=[];%default |
|---|
| 621 | if isempty(nom_type_ima) |
|---|
| 622 | %look for double image series '_i_j' |
|---|
| 623 | dirima=dir([filebase '_' num2str(first_i) '_' num2str(first_j) '.*']); |
|---|
| 624 | if isempty(dirima) |
|---|
| 625 | % look for images series with sub marker '_' |
|---|
| 626 | dirima=dir([filebase '_*' num2str(first_i) '.*']); |
|---|
| 627 | if isempty(dirima) |
|---|
| 628 | % look for other images series |
|---|
| 629 | dirima=dir([filebase '*' num2str(first_i) '.*']); |
|---|
| 630 | if isempty(dirima) |
|---|
| 631 | % look for other images series witth letter appendix |
|---|
| 632 | appendix=char(96+first_j); |
|---|
| 633 | dirima=dir([filebase '*' num2str(first_i) appendix '.*']); |
|---|
| 634 | end |
|---|
| 635 | end |
|---|
| 636 | end |
|---|
| 637 | end |
|---|
| 638 | for ilist=1:numel(dirima) |
|---|
| 639 | [pp,ff,fc,str2,str_a,str_b,ext_list,nom_type_list]=name2display(dirima(ilist).name); |
|---|
| 640 | form=imformats(ext_list(2:end)); |
|---|
| 641 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
|---|
| 642 | ext_ima=ext_list; |
|---|
| 643 | nom_type_ima=nom_type_list; |
|---|
| 644 | break |
|---|
| 645 | end |
|---|
| 646 | end |
|---|
| 647 | % no image documentation file found: look for a series of existing files,images by priority or .nc files |
|---|
| 648 | if isempty(nom_type_ima) |
|---|
| 649 | ext_search=ext_imadoc; |
|---|
| 650 | nom_type_search=nom_type_nc; |
|---|
| 651 | else |
|---|
| 652 | ext_search=ext_ima; |
|---|
| 653 | nom_type_search=nom_type_ima; |
|---|
| 654 | end |
|---|
| 655 | if isempty(time) && ~strcmp(nom_type_search,'none') && ~strcmp(nom_type_search,'') && ~strcmp(nom_type_search,'*') |
|---|
| 656 | subdir=get(handles.subdir_civ1,'String'); |
|---|
| 657 | incr_pair=[0 0];%default |
|---|
| 658 | if isfield(browse,'incr_pair') |
|---|
| 659 | incr_pair=browse.incr_pair; |
|---|
| 660 | end |
|---|
| 661 | % nbdetect=0;%test of detected images |
|---|
| 662 | field_i=browse.num_i2; |
|---|
| 663 | imagename=name_generator(filebase,field_i,1,ext_search,nom_type_search); |
|---|
| 664 | imagename_plus=''; |
|---|
| 665 | idetect=1; |
|---|
| 666 | while idetect %look for the maximum file number in the series |
|---|
| 667 | imagename_plus=name_generator(filebase,field_i+1,1,ext_search,nom_type_search); |
|---|
| 668 | idetect=(exist(imagename_plus,'file')==2)&& ~strcmp(imagename,imagename_plus); |
|---|
| 669 | if idetect |
|---|
| 670 | field_i=field_i+1; |
|---|
| 671 | end |
|---|
| 672 | %SEE CASE OF NETCDF FILES |
|---|
| 673 | % nbdetect=nbdetect+(exist(imagename,'file')==2); |
|---|
| 674 | end |
|---|
| 675 | nbfield=field_i;% last detected field number |
|---|
| 676 | field_i=browse.num_i1;%look for the minimum file number in the series |
|---|
| 677 | imagename_min=''; |
|---|
| 678 | idetect=1; |
|---|
| 679 | while idetect==1 |
|---|
| 680 | imagename_min=name_generator(filebase,field_i-1,1,ext_search,nom_type_search); |
|---|
| 681 | idetect=(exist(imagename_min,'file')==2)&& ~strcmp(imagename,imagename_min); |
|---|
| 682 | if idetect |
|---|
| 683 | field_i=field_i-1; |
|---|
| 684 | end |
|---|
| 685 | end |
|---|
| 686 | first_i=max(field_i,1); |
|---|
| 687 | if numel(regexp(nom_type_search,'\D'))>=1%two indices i and j |
|---|
| 688 | field_i=browse.num_i1; |
|---|
| 689 | field_j=browse.num_j2; |
|---|
| 690 | imagename=name_generator(filebase,field_i,field_j,ext_search,nom_type_search); |
|---|
| 691 | imagename_plus=''; |
|---|
| 692 | jdetect=1; |
|---|
| 693 | while jdetect==1 %look for the maximum file number in the series |
|---|
| 694 | imagename_plus=name_generator(filebase,field_i,field_j+1,ext_search,nom_type_search); |
|---|
| 695 | jdetect=(exist(imagename_plus,'file')==2)&& ~strcmp(imagename,imagename_plus); |
|---|
| 696 | if jdetect |
|---|
| 697 | field_j=field_j+1; |
|---|
| 698 | end |
|---|
| 699 | %SEE CASE OF NETCDF FILES |
|---|
| 700 | % nbdetect=nbdetect+(exist(imagename,'file')==2); |
|---|
| 701 | end |
|---|
| 702 | nbfield2=field_j;% last detected field number |
|---|
| 703 | end |
|---|
| 704 | |
|---|
| 705 | %determine the set of times and possible intervals for CIV |
|---|
| 706 | % dt=(1/1000)*str2double(get(handles.dt,'String')); |
|---|
| 707 | time=(0:nbfield-1)';% time=file index -1 by default |
|---|
| 708 | if numel(regexp(nom_type_search,'\D'))>=1%two indices i and j |
|---|
| 709 | [x,y]=meshgrid(0:nbfield2-1,0:nbfield-1); |
|---|
| 710 | time=x+y; |
|---|
| 711 | end |
|---|
| 712 | end |
|---|
| 713 | |
|---|
| 714 | if exist('time','var') |
|---|
| 715 | if size(time,1)+size(time,2)>=3 % if there are at least two time values to define dt |
|---|
| 716 | nbfield=size(time,1); |
|---|
| 717 | nbfield2=size(time,2); |
|---|
| 718 | set(handles.RootName,'UserData',time); %store the set of times |
|---|
| 719 | set(handles.dt_unit,'String',['dt in m' TimeUnit]); |
|---|
| 720 | set(handles.dt_unit_civ2,'String',['dt in m' TimeUnit]); |
|---|
| 721 | set(handles.TimeUnit,'String',TimeUnit); |
|---|
| 722 | set(handles.nb_field,'String',num2str(nbfield)); |
|---|
| 723 | set(handles.nb_field2,'String',num2str(nbfield2)); |
|---|
| 724 | end |
|---|
| 725 | end |
|---|
| 726 | set(handles.CoordUnit,'String',CoordUnit) |
|---|
| 727 | set(handles.calcul_search,'UserData',[pxcmx_search pxcmy_search]); |
|---|
| 728 | % npxy=[npy npx]; |
|---|
| 729 | set(handles.ImaExt,'String',ext_ima) |
|---|
| 730 | set(handles.first_i,'String',num2str(first_i)); |
|---|
| 731 | set(handles.last_i,'String',num2str(last_i));% |
|---|
| 732 | set(handles.first_j,'String',num2str(first_j)); |
|---|
| 733 | set(handles.last_j,'String',num2str(last_j));% |
|---|
| 734 | browse.nom_type_ima=nom_type_ima; |
|---|
| 735 | set(handles.browse_root,'UserData',browse)% store the nomenclature type |
|---|
| 736 | |
|---|
| 737 | %%%%%%%%%%% set the menus of image pairs and default selection for civ %%%%%%%%%%%%%%%%%%% |
|---|
| 738 | test_ima_i=numel(nom_type_ima)>1 && isempty(regexp(nom_type_ima(2:end),'\D','once'));%images with single indexing |
|---|
| 739 | if test_ima_i || isequal(nom_type_nc,'_i1-i2')||~(exist('nbfield2','var')&&(nbfield2~=1)) |
|---|
| 740 | set(handles.mode,'Value',1) |
|---|
| 741 | set(handles.mode,'String',{'series(Di)'}) |
|---|
| 742 | elseif (nbfield==1)% simple series in j |
|---|
| 743 | set(handles.mode,'Value',1) |
|---|
| 744 | set(handles.mode,'String',{'series(Dj)'}) |
|---|
| 745 | else |
|---|
| 746 | set(handles.mode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice |
|---|
| 747 | if nbfield2 <= 10 |
|---|
| 748 | set(handles.mode,'Value',1)% advice 'pair j1-j2' for small burst |
|---|
| 749 | end |
|---|
| 750 | end |
|---|
| 751 | |
|---|
| 752 | %update the subdir |
|---|
| 753 | pathdir=fileparts(filebase);%path to the current xml file |
|---|
| 754 | listot=dir(pathdir); |
|---|
| 755 | idir=0; |
|---|
| 756 | listdir={''};%default |
|---|
| 757 | for ilist=1:length(listot) |
|---|
| 758 | if listot(ilist).isdir |
|---|
| 759 | name=listot(ilist).name; |
|---|
| 760 | if ~isequal(name,'.') && ~isequal(name,'..') |
|---|
| 761 | idir=idir+1; |
|---|
| 762 | listdir{idir,1}=listot(ilist).name; |
|---|
| 763 | end |
|---|
| 764 | end |
|---|
| 765 | end |
|---|
| 766 | set(handles.list_subdir_civ1,'Value',1) |
|---|
| 767 | set(handles.list_subdir_civ2,'Value',1) |
|---|
| 768 | set(handles.list_subdir_civ1,'String',[{'browse...'};listdir]) |
|---|
| 769 | set(handles.list_subdir_civ2,'String',[{'browse...'};listdir]) |
|---|
| 770 | %check wether the current subdir exists: |
|---|
| 771 | subdir_civ1=get(handles.subdir_civ1,'String'); |
|---|
| 772 | subdir_civ2=get(handles.subdir_civ2,'String'); |
|---|
| 773 | |
|---|
| 774 | mode_Callback(hObject, eventdata, handles) |
|---|
| 775 | |
|---|
| 776 | %% desable status and RUN button |
|---|
| 777 | % set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001]) |
|---|
| 778 | % set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001]) |
|---|
| 779 | % set(handles.waitbar_civ2,'Position',[0.946 0.219 0.03 0.001]) |
|---|
| 780 | % set(handles.waitbar_patch2,'Position',[0.946 0.0 0.03 0.001]) |
|---|
| 781 | set(handles.RUN, 'Enable','On') |
|---|
| 782 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
|---|
| 783 | set(handles.BATCH,'Enable','On') |
|---|
| 784 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
|---|
| 785 | set(handles.status,'Value',0);%suppress status display |
|---|
| 786 | status_Callback(hObject, eventdata, handles) |
|---|
| 787 | |
|---|
| 788 | %% store the root input filename for future opening |
|---|
| 789 | dir_perso=prefdir; |
|---|
| 790 | profil_perso=fullfile(prefdir,'uvmat_perso.mat'); |
|---|
| 791 | RootPath=fileparts(filebase); |
|---|
| 792 | if exist(profil_perso,'file') |
|---|
| 793 | save (profil_perso,'RootPath','-append'); %store the root name for future opening of uvmat |
|---|
| 794 | else |
|---|
| 795 | txt=ver('MATLAB'); |
|---|
| 796 | Release=txt.Release; |
|---|
| 797 | relnumb=str2double(Release(3:4)); |
|---|
| 798 | if relnumb >= 14 |
|---|
| 799 | save (profil_perso,'RootPath','-V6'); %store the root name for future opening of uvmat |
|---|
| 800 | else |
|---|
| 801 | save (profil_perso,'RootPath'); %store the root name for future opening of uvmat |
|---|
| 802 | end |
|---|
| 803 | end |
|---|
| 804 | |
|---|
| 805 | %------------------------------------------------------------------------ |
|---|
| 806 | % --- Executes on button press in mode. |
|---|
| 807 | function mode_Callback(hObject, eventdata, handles) |
|---|
| 808 | %------------------------------------------------------------------------ |
|---|
| 809 | browse=get(handles.browse_root,'UserData'); |
|---|
| 810 | compare_list=get(handles.compare,'String'); |
|---|
| 811 | val=get(handles.compare,'Value'); |
|---|
| 812 | compare=compare_list{val}; |
|---|
| 813 | if strcmp(compare,'displacement') |
|---|
| 814 | mode='displacement'; |
|---|
| 815 | else |
|---|
| 816 | mode_list=get(handles.mode,'String'); |
|---|
| 817 | mode_value=get(handles.mode,'Value'); |
|---|
| 818 | mode=mode_list{mode_value}; |
|---|
| 819 | end |
|---|
| 820 | displ_num=[];%default |
|---|
| 821 | ref_i=str2double(get(handles.ref_i,'String')); |
|---|
| 822 | % last_i=str2num(get(handles.last_i,'String')); |
|---|
| 823 | time=get(handles.RootName,'UserData'); %get the set of times |
|---|
| 824 | siztime=size(time); |
|---|
| 825 | nbfield=siztime(1); |
|---|
| 826 | nbfield2=siztime(2); |
|---|
| 827 | indchosen=1; %%first pair selected by default |
|---|
| 828 | if isequal(mode,'pair j1-j2')%| isequal(mode,'st_pair j1-j2') |
|---|
| 829 | dt=1; |
|---|
| 830 | displ=''; |
|---|
| 831 | index=0; |
|---|
| 832 | numlist_a=[]; |
|---|
| 833 | numlist_B=[]; |
|---|
| 834 | %get all the time intervals in bursts |
|---|
| 835 | displ_dt=1;%default |
|---|
| 836 | nbfield2=min(nbfield2,10);%limitate the number of pairs to 10x10 |
|---|
| 837 | for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'pair j1-j2' mode |
|---|
| 838 | for numod_b=(numod_a+1):nbfield2 |
|---|
| 839 | index=index+1; |
|---|
| 840 | numlist_a(index)=numod_a; |
|---|
| 841 | numlist_b(index)=numod_b; |
|---|
| 842 | if ~isempty(time) |
|---|
| 843 | dt(numod_a,numod_b)=time(ref_i,numod_b)-time(ref_i,numod_a);%first time interval dt |
|---|
| 844 | displ_dt(index)=dt(numod_a,numod_b); |
|---|
| 845 | else |
|---|
| 846 | displ_dt(index)=1; |
|---|
| 847 | end |
|---|
| 848 | end |
|---|
| 849 | end |
|---|
| 850 | [dtsort,indsort]=sort(displ_dt); |
|---|
| 851 | if ~isempty(numlist_a) |
|---|
| 852 | displ_num(1,:)=numlist_a(indsort); |
|---|
| 853 | displ_num(2,:)=numlist_b(indsort); |
|---|
| 854 | end |
|---|
| 855 | displ_num(3,:)=0; |
|---|
| 856 | displ_num(4,:)=0; |
|---|
| 857 | set(handles.jtext,'Visible','Off') |
|---|
| 858 | set(handles.first_j,'Visible','Off') |
|---|
| 859 | set(handles.last_j,'Visible','Off') |
|---|
| 860 | set(handles.incr_j,'Visible','Off') |
|---|
| 861 | set(handles.nb_field2,'Visible','Off') |
|---|
| 862 | set(handles.ref_j,'Visible','Off') |
|---|
| 863 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') |
|---|
| 864 | for index=1:min(nbfield2-1,200) |
|---|
| 865 | displ_num(1,index)=-floor(index/2); |
|---|
| 866 | displ_num(2,index)=ceil(index/2); |
|---|
| 867 | displ_num(3,index)=0; |
|---|
| 868 | displ_num(4,index)=0; |
|---|
| 869 | end |
|---|
| 870 | set(handles.jtext,'Visible','On') |
|---|
| 871 | set(handles.first_j,'Visible','On') |
|---|
| 872 | set(handles.last_j,'Visible','On') |
|---|
| 873 | set(handles.incr_j,'Visible','On') |
|---|
| 874 | set(handles.nb_field2,'Visible','On') |
|---|
| 875 | set(handles.ref_j,'Visible','On') |
|---|
| 876 | if nbfield > 1 |
|---|
| 877 | set(handles.itext,'Visible','On') |
|---|
| 878 | set(handles.first_i,'Visible','On') |
|---|
| 879 | set(handles.last_i,'Visible','On') |
|---|
| 880 | set(handles.incr_i,'Visible','On') |
|---|
| 881 | set(handles.nb_field,'Visible','On') |
|---|
| 882 | set(handles.ref_i,'Visible','On') |
|---|
| 883 | else |
|---|
| 884 | set(handles.itext,'Visible','Off') |
|---|
| 885 | set(handles.first_i,'Visible','Off') |
|---|
| 886 | set(handles.last_i,'Visible','Off') |
|---|
| 887 | set(handles.incr_i,'Visible','Off') |
|---|
| 888 | set(handles.nb_field,'Visible','Off') |
|---|
| 889 | set(handles.ref_i,'Visible','Off') |
|---|
| 890 | end |
|---|
| 891 | elseif isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
|---|
| 892 | for index=1:200%min(nbfield-1,200) |
|---|
| 893 | displ_num(1,index)=0; |
|---|
| 894 | displ_num(2,index)=0; |
|---|
| 895 | displ_num(3,index)=-floor(index/2); |
|---|
| 896 | displ_num(4,index)=ceil(index/2); |
|---|
| 897 | end |
|---|
| 898 | set(handles.itext,'Visible','On') |
|---|
| 899 | set(handles.first_i,'Visible','On') |
|---|
| 900 | set(handles.last_i,'Visible','On') |
|---|
| 901 | set(handles.incr_i,'Visible','On') |
|---|
| 902 | set(handles.nb_field,'Visible','On') |
|---|
| 903 | set(handles.ref_i,'Visible','On') |
|---|
| 904 | if nbfield2 > 1 |
|---|
| 905 | set(handles.jtext,'Visible','On') |
|---|
| 906 | set(handles.first_j,'Visible','On') |
|---|
| 907 | set(handles.last_j,'Visible','On') |
|---|
| 908 | set(handles.incr_j,'Visible','On') |
|---|
| 909 | set(handles.nb_field2,'Visible','On') |
|---|
| 910 | set(handles.ref_j,'Visible','On') |
|---|
| 911 | else |
|---|
| 912 | set(handles.jtext,'Visible','Off') |
|---|
| 913 | set(handles.first_j,'Visible','Off') |
|---|
| 914 | set(handles.last_j,'Visible','Off') |
|---|
| 915 | set(handles.incr_j,'Visible','Off') |
|---|
| 916 | set(handles.nb_field2,'Visible','Off') |
|---|
| 917 | set(handles.ref_j,'Visible','Off') |
|---|
| 918 | end |
|---|
| 919 | elseif isequal(mode,'displacement')%the pairs have the same indices |
|---|
| 920 | displ_num(1,1)=0; |
|---|
| 921 | displ_num(2,1)=0; |
|---|
| 922 | displ_num(3,1)=0; |
|---|
| 923 | displ_num(4,1)=0; |
|---|
| 924 | if nbfield > 1 |
|---|
| 925 | set(handles.itext,'Visible','On') |
|---|
| 926 | set(handles.first_i,'Visible','On') |
|---|
| 927 | set(handles.last_i,'Visible','On') |
|---|
| 928 | set(handles.incr_i,'Visible','On') |
|---|
| 929 | set(handles.nb_field,'Visible','On') |
|---|
| 930 | set(handles.ref_i,'Visible','On') |
|---|
| 931 | else |
|---|
| 932 | set(handles.itext,'Visible','Off') |
|---|
| 933 | set(handles.first_i,'Visible','Off') |
|---|
| 934 | set(handles.last_i,'Visible','Off') |
|---|
| 935 | set(handles.incr_i,'Visible','Off') |
|---|
| 936 | set(handles.nb_field,'Visible','Off') |
|---|
| 937 | set(handles.ref_i,'Visible','Off') |
|---|
| 938 | end |
|---|
| 939 | if nbfield2 > 1 |
|---|
| 940 | set(handles.jtext,'Visible','On') |
|---|
| 941 | set(handles.first_j,'Visible','On') |
|---|
| 942 | set(handles.last_j,'Visible','On') |
|---|
| 943 | set(handles.incr_j,'Visible','On') |
|---|
| 944 | set(handles.nb_field2,'Visible','On') |
|---|
| 945 | set(handles.ref_j,'Visible','On') |
|---|
| 946 | else |
|---|
| 947 | set(handles.jtext,'Visible','Off') |
|---|
| 948 | set(handles.first_j,'Visible','Off') |
|---|
| 949 | set(handles.last_j,'Visible','Off') |
|---|
| 950 | set(handles.incr_j,'Visible','Off') |
|---|
| 951 | set(handles.nb_field2,'Visible','Off') |
|---|
| 952 | set(handles.ref_j,'Visible','Off') |
|---|
| 953 | end |
|---|
| 954 | end |
|---|
| 955 | set(handles.list_pair_civ1,'UserData',displ_num); |
|---|
| 956 | find_netcpair_civ1(hObject, eventdata, handles) |
|---|
| 957 | find_netcpair_civ2(hObject, eventdata, handles) |
|---|
| 958 | |
|---|
| 959 | %------------------------------------------------------------------------ |
|---|
| 960 | % determine the menu for civ1 pairs depending on existing netcdf file at the middle of |
|---|
| 961 | % the field series set by first_i, incr, last_i |
|---|
| 962 | function find_netcpair_civ1(hObject, eventdata, handles) |
|---|
| 963 | %------------------------------------------------------------------------ |
|---|
| 964 | set(gcf,'Pointer','watch') |
|---|
| 965 | %nomenclature types |
|---|
| 966 | filebase=get(handles.RootName,'String'); |
|---|
| 967 | [filepath,Nme,ext_dir]=fileparts(filebase); |
|---|
| 968 | browse=get(handles.browse_root,'UserData'); |
|---|
| 969 | compare_list=get(handles.compare,'String'); |
|---|
| 970 | val=get(handles.compare,'Value'); |
|---|
| 971 | compare=compare_list{val}; |
|---|
| 972 | if strcmp(compare,'displacement') |
|---|
| 973 | mode='displacement'; |
|---|
| 974 | else |
|---|
| 975 | mode_list=get(handles.mode,'String'); |
|---|
| 976 | mode_value=get(handles.mode,'Value'); |
|---|
| 977 | mode=mode_list{mode_value}; |
|---|
| 978 | end |
|---|
| 979 | |
|---|
| 980 | % nomenclature type of the .nc files |
|---|
| 981 | nom_type_ima=[];%default |
|---|
| 982 | if isfield(browse,'nom_type_ima') |
|---|
| 983 | nom_type_ima=browse.nom_type_ima; |
|---|
| 984 | end |
|---|
| 985 | |
|---|
| 986 | %determine nom_type_nc: |
|---|
| 987 | nom_type_nc=[];%default |
|---|
| 988 | if isfield(browse,'nom_type_nc') |
|---|
| 989 | nom_type_nc=browse.nom_type_nc; |
|---|
| 990 | end |
|---|
| 991 | if isempty(nom_type_nc) |
|---|
| 992 | [nom_type_nc]=nomtype2pair(nom_type_ima,isequal(mode,'series(Di)'),isequal(mode,'series(Dj)')); |
|---|
| 993 | end |
|---|
| 994 | browse.nom_type_nc=nom_type_nc; |
|---|
| 995 | set(handles.browse_root,'UserData',browse) |
|---|
| 996 | |
|---|
| 997 | %reads .nc subdirectoy and image numbers from the interface |
|---|
| 998 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf data |
|---|
| 999 | % first_i=str2num(get(handles.first_i,'String')); |
|---|
| 1000 | % last_i=str2num(get(handles.last_i,'String')); |
|---|
| 1001 | % incr=str2num(get(handles.incr_i,'String')); |
|---|
| 1002 | % num1=first_i:incr:last_i; |
|---|
| 1003 | % if isempty(num1) |
|---|
| 1004 | % set(handles.list_pair_civ1,'String',{''}); |
|---|
| 1005 | % return |
|---|
| 1006 | % end |
|---|
| 1007 | ref_i=str2double(get(handles.ref_i,'String')); |
|---|
| 1008 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
|---|
| 1009 | ref_j=0; |
|---|
| 1010 | else |
|---|
| 1011 | ref_j=str2double(get(handles.ref_j,'String')); |
|---|
| 1012 | end |
|---|
| 1013 | time=get(handles.RootName,'UserData');%get the set of times |
|---|
| 1014 | if isempty(time) |
|---|
| 1015 | time=[0 1]; |
|---|
| 1016 | end |
|---|
| 1017 | %dt_unit=str2double(get(handles.dt,'String'));% used when there is no image documentation file |
|---|
| 1018 | dt_unit=1000;%default |
|---|
| 1019 | displ_num=get(handles.list_pair_civ1,'UserData'); |
|---|
| 1020 | |
|---|
| 1021 | %eliminate the first pairs inconsistent with the position |
|---|
| 1022 | if isempty(displ_num) |
|---|
| 1023 | nbpair=0; |
|---|
| 1024 | else |
|---|
| 1025 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
|---|
| 1026 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
|---|
| 1027 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
|---|
| 1028 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
|---|
| 1029 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
|---|
| 1030 | end |
|---|
| 1031 | end |
|---|
| 1032 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
|---|
| 1033 | |
|---|
| 1034 | %look for existing processed pairs involving the field at the middle of the series if civ1 will not |
|---|
| 1035 | % be performed, while the result is needed for next steps. |
|---|
| 1036 | displ_pair={''}; |
|---|
| 1037 | select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs |
|---|
| 1038 | testpair=0; |
|---|
| 1039 | if get(handles.CIV1,'Value')==0 % |
|---|
| 1040 | if ~exist(fullfile(filepath,subdir_civ1,ext_dir),'dir') |
|---|
| 1041 | msgbox_uvmat('ERROR',['no civ1 file available: subdirectory ' subdir_civ1 ' does not exist']); |
|---|
| 1042 | set(handles.list_pair_civ1,'String',{}); |
|---|
| 1043 | return |
|---|
| 1044 | end |
|---|
| 1045 | for ipair=1:nbpair |
|---|
| 1046 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
|---|
| 1047 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
|---|
| 1048 | select(ipair)=exist(filename,'file')==2; |
|---|
| 1049 | end |
|---|
| 1050 | if ~exist('select','var') || isequal(select,zeros(size(1:nbpair))) |
|---|
| 1051 | if isfield(browse,'incr_pair') |
|---|
| 1052 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
|---|
| 1053 | num_i2=ref_i+ceil(browse.incr_pair(1)/2); |
|---|
| 1054 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
|---|
| 1055 | num_j2=ref_j+ceil(browse.incr_pair(2)/2); |
|---|
| 1056 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ1); |
|---|
| 1057 | select(1)=exist(filename,'file')==2; |
|---|
| 1058 | testpair=1; |
|---|
| 1059 | else |
|---|
| 1060 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
|---|
| 1061 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1]); |
|---|
| 1062 | else |
|---|
| 1063 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ1]); |
|---|
| 1064 | end |
|---|
| 1065 | set(handles.list_pair_civ1,'String',{''}); |
|---|
| 1066 | %COMPLETER CAS STEREO |
|---|
| 1067 | return |
|---|
| 1068 | end |
|---|
| 1069 | end |
|---|
| 1070 | end |
|---|
| 1071 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
|---|
| 1072 | if testpair |
|---|
| 1073 | displ_pair{1}=['Di= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
|---|
| 1074 | % elseif ~isequal(get(handles.root_txt,'String'),'dt(ms)=') |
|---|
| 1075 | % for ipair=1:nbpair |
|---|
| 1076 | % if select(ipair) |
|---|
| 1077 | % if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
|---|
| 1078 | % 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 |
|---|
| 1079 | % displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
|---|
| 1080 | % end |
|---|
| 1081 | % else |
|---|
| 1082 | % displ_pair{ipair}='...'; %pair not displayed in the menu |
|---|
| 1083 | % end |
|---|
| 1084 | % end |
|---|
| 1085 | else |
|---|
| 1086 | for ipair=1:nbpair |
|---|
| 1087 | if select(ipair) |
|---|
| 1088 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
|---|
| 1089 | 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 |
|---|
| 1090 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
|---|
| 1091 | else |
|---|
| 1092 | displ_pair{ipair}='...'; %pair not displayed in the menu |
|---|
| 1093 | end |
|---|
| 1094 | end |
|---|
| 1095 | end |
|---|
| 1096 | end |
|---|
| 1097 | elseif isequal(mode,'series(Dj)')%|isequal(mode,'st_series(Dj)')% series on the j index |
|---|
| 1098 | if testpair |
|---|
| 1099 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
|---|
| 1100 | else |
|---|
| 1101 | for ipair=1:nbpair |
|---|
| 1102 | if select(ipair) |
|---|
| 1103 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
|---|
| 1104 | 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 |
|---|
| 1105 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
|---|
| 1106 | end |
|---|
| 1107 | elseif testpair |
|---|
| 1108 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(2)/2)) '|' num2str(ceil(browse.incr_pair(2)/2))]; |
|---|
| 1109 | else |
|---|
| 1110 | displ_pair{ipair}='...'; %pair not displayed in the menu |
|---|
| 1111 | end |
|---|
| 1112 | end |
|---|
| 1113 | end |
|---|
| 1114 | elseif isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2')%case of pairs |
|---|
| 1115 | for ipair=1:nbpair |
|---|
| 1116 | if select(ipair) |
|---|
| 1117 | 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 |
|---|
| 1118 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
|---|
| 1119 | ' :dt= ' num2str(dt*1000)]; |
|---|
| 1120 | else |
|---|
| 1121 | displ_pair{ipair}='...'; %pair not displayed in the menu |
|---|
| 1122 | end |
|---|
| 1123 | end |
|---|
| 1124 | elseif isequal(mode,'displacement') |
|---|
| 1125 | displ_pair={'Di=Dj=0'}; |
|---|
| 1126 | end |
|---|
| 1127 | set(handles.list_pair_civ1,'String',displ_pair'); |
|---|
| 1128 | ichoice=min(find(select)); |
|---|
| 1129 | if (isempty(ichoice) || ichoice < 1); ichoice=1; end; |
|---|
| 1130 | initial=get(handles.list_pair_civ1,'Value');%initial choice of pair |
|---|
| 1131 | if initial>nbpair |
|---|
| 1132 | set(handles.list_pair_civ1,'Value',ichoice);% first valid pair proposed by default in the menu |
|---|
| 1133 | end |
|---|
| 1134 | if numel(select)>=initial && ~isequal(select(initial),1) |
|---|
| 1135 | set(handles.list_pair_civ1,'Value',ichoice);% first valid pair proposed by default in the menu |
|---|
| 1136 | end |
|---|
| 1137 | |
|---|
| 1138 | %set(handles.list_pair_civ2,'String',displ_pair'); |
|---|
| 1139 | initial=get(handles.list_pair_civ2,'Value'); |
|---|
| 1140 | if initial>length(displ_pair')%|~isequal(select(initial),1) |
|---|
| 1141 | if ichoice <= length(displ_pair') |
|---|
| 1142 | set(handles.list_pair_civ2,'Value',ichoice);% same pair proposed by default for civ2 |
|---|
| 1143 | else |
|---|
| 1144 | set(handles.list_pair_civ2,'Value',1);% same pair proposed by default for civ2 |
|---|
| 1145 | end |
|---|
| 1146 | end |
|---|
| 1147 | set(handles.list_pair_civ2,'String',displ_pair'); |
|---|
| 1148 | set(gcf,'Pointer','arrow') |
|---|
| 1149 | |
|---|
| 1150 | %------------------------------------------------------------------------ |
|---|
| 1151 | % determine the menu for civ2 pairs depending on the existing netcdf file at the |
|---|
| 1152 | %middle of the series set by first_i, incr, last_i |
|---|
| 1153 | function find_netcpair_civ2(hObject, eventdata, handles) |
|---|
| 1154 | %------------------------------------------------------------------------ |
|---|
| 1155 | set(gcf,'Pointer','watch') |
|---|
| 1156 | %nomenclature types |
|---|
| 1157 | filebase=get(handles.RootName,'String'); |
|---|
| 1158 | [filepath,Nme,ext_dir]=fileparts(filebase); |
|---|
| 1159 | browse=get(handles.browse_root,'UserData'); |
|---|
| 1160 | compare_list=get(handles.compare,'String'); |
|---|
| 1161 | val=get(handles.compare,'Value'); |
|---|
| 1162 | compare=compare_list{val}; |
|---|
| 1163 | if strcmp(compare,'displacement') |
|---|
| 1164 | mode='displacement'; |
|---|
| 1165 | else |
|---|
| 1166 | mode_list=get(handles.mode,'String'); |
|---|
| 1167 | mode_value=get(handles.mode,'Value'); |
|---|
| 1168 | mode=mode_list{mode_value}; |
|---|
| 1169 | end |
|---|
| 1170 | |
|---|
| 1171 | % nomenclature type of the .nc files |
|---|
| 1172 | nom_type_ima='ima_num';%default |
|---|
| 1173 | if isfield(browse,'nom_type_ima') |
|---|
| 1174 | nom_type_ima=browse.nom_type_ima; |
|---|
| 1175 | end |
|---|
| 1176 | nom_type_nc='_i1-i2';%default |
|---|
| 1177 | if isfield(browse,'nom_type_nc') |
|---|
| 1178 | nom_type_nc=browse.nom_type_nc; |
|---|
| 1179 | end |
|---|
| 1180 | 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') |
|---|
| 1181 | nom_type_nc='netc_old';%nom_type for the netcdf files |
|---|
| 1182 | elseif isequal(nom_type_ima,'none')||isequal(nom_type_nc,'none') |
|---|
| 1183 | nom_type_nc='none'; |
|---|
| 1184 | elseif isequal(nom_type_ima,'avi')||isequal(nom_type_ima,'_i')||isequal(nom_type_ima,'ima_num')||isequal(nom_type_nc,'_i1-i2') |
|---|
| 1185 | nom_type_nc='_i1-i2'; |
|---|
| 1186 | else |
|---|
| 1187 | if isequal(mode,'series(Di)')%|isequal(mode,'st_series(Di)') |
|---|
| 1188 | nom_type_nc='_i1-i2_j'; % PIV in volume |
|---|
| 1189 | else |
|---|
| 1190 | nom_type_nc='_i_j1-j2'; |
|---|
| 1191 | end |
|---|
| 1192 | end |
|---|
| 1193 | browse.nom_type_nc=nom_type_nc; |
|---|
| 1194 | set(handles.browse_root,'UserData',browse) |
|---|
| 1195 | |
|---|
| 1196 | %reads .nc subdirectory and image numbers from the interface |
|---|
| 1197 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf data |
|---|
| 1198 | subdir_civ2=get(handles.subdir_civ2,'String');%subdirectory subdir_civ2 for the netcdf data |
|---|
| 1199 | % first_i=str2num(get(handles.first_i,'String')); |
|---|
| 1200 | % last_i=str2num(get(handles.last_i,'String')); |
|---|
| 1201 | % incr=str2num(get(handles.incr_i,'String')); |
|---|
| 1202 | % num1=first_i:incr:last_i; |
|---|
| 1203 | % if isempty(num1) |
|---|
| 1204 | % set(handles.list_pair_civ2,'Value',1); |
|---|
| 1205 | % set(handles.list_pair_civ2,'String',{''}); |
|---|
| 1206 | % return |
|---|
| 1207 | % end |
|---|
| 1208 | ref_i=str2double(get(handles.ref_i_civ2,'String')); |
|---|
| 1209 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
|---|
| 1210 | ref_j=0; |
|---|
| 1211 | else |
|---|
| 1212 | ref_j=str2double(get(handles.ref_j_civ2,'String')); |
|---|
| 1213 | end |
|---|
| 1214 | time=get(handles.RootName,'UserData'); %get the set of times |
|---|
| 1215 | if isempty(time) |
|---|
| 1216 | time=[0 1];%default |
|---|
| 1217 | end |
|---|
| 1218 | %dt_unit=str2num(get(handles.dt,'String'));% used when there is no image documentation file |
|---|
| 1219 | %dt_unit=1000; |
|---|
| 1220 | displ_num=get(handles.list_pair_civ1,'UserData'); |
|---|
| 1221 | |
|---|
| 1222 | |
|---|
| 1223 | %eliminate the first pairs inconsistent with the position |
|---|
| 1224 | if isempty(displ_num) |
|---|
| 1225 | nbpair=0; |
|---|
| 1226 | else |
|---|
| 1227 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
|---|
| 1228 | if isequal(mode,'series(Di)')% | isequal(mode,'st_series(Di)') |
|---|
| 1229 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
|---|
| 1230 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
|---|
| 1231 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
|---|
| 1232 | end |
|---|
| 1233 | end |
|---|
| 1234 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
|---|
| 1235 | |
|---|
| 1236 | %look for existing processed pairs involving the field at the middle of the series if civ1 will not |
|---|
| 1237 | % be performed, while the result is needed for next steps. |
|---|
| 1238 | displ_pair={''}; %default |
|---|
| 1239 | select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs |
|---|
| 1240 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0%&... |
|---|
| 1241 | if ~exist(fullfile(filepath,subdir_civ2,ext_dir),'dir') |
|---|
| 1242 | errordlg(['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist']) |
|---|
| 1243 | set(handles.list_pair_civ2,'Value',1); |
|---|
| 1244 | set(handles.list_pair_civ2,'String',{''}); |
|---|
| 1245 | return |
|---|
| 1246 | end |
|---|
| 1247 | for ipair=1:nbpair |
|---|
| 1248 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
|---|
| 1249 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
|---|
| 1250 | select(ipair)=exist(filename,'file')==2; |
|---|
| 1251 | end |
|---|
| 1252 | if isequal(select,zeros(size(1:nbpair))) |
|---|
| 1253 | if isfield(browse,'incr_pair') |
|---|
| 1254 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
|---|
| 1255 | num_i2=ref_i+floor((browse.incr_pair(1)+1)/2); |
|---|
| 1256 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
|---|
| 1257 | num_j2=ref_j+floor((browse.incr_pair(2)+1)/2); |
|---|
| 1258 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ2); |
|---|
| 1259 | select(1)=exist(filename,'file')==2; |
|---|
| 1260 | else |
|---|
| 1261 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
|---|
| 1262 | errordlg(['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2]) |
|---|
| 1263 | else |
|---|
| 1264 | errordlg(['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2]) |
|---|
| 1265 | end |
|---|
| 1266 | set(handles.list_pair_civ2,'Value',1); |
|---|
| 1267 | set(handles.list_pair_civ2,'String',{''}); |
|---|
| 1268 | return |
|---|
| 1269 | end |
|---|
| 1270 | end |
|---|
| 1271 | end |
|---|
| 1272 | if isequal(mode,'series(Di)') % | isequal(mode,'st_series(Di)') |
|---|
| 1273 | for ipair=1:nbpair |
|---|
| 1274 | if select(ipair) |
|---|
| 1275 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
|---|
| 1276 | 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 |
|---|
| 1277 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
|---|
| 1278 | end |
|---|
| 1279 | else |
|---|
| 1280 | displ_pair{ipair}='...'; %pair not displayed in the menu |
|---|
| 1281 | end |
|---|
| 1282 | end |
|---|
| 1283 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') % series on the j index |
|---|
| 1284 | for ipair=1:nbpair |
|---|
| 1285 | if select(ipair) |
|---|
| 1286 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
|---|
| 1287 | 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 |
|---|
| 1288 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
|---|
| 1289 | end |
|---|
| 1290 | else |
|---|
| 1291 | displ_pair{ipair}='...'; %pair not displayed in the menu |
|---|
| 1292 | end |
|---|
| 1293 | end |
|---|
| 1294 | elseif isequal(mode,'pair j1-j2')% | isequal(mode,'st_pair j1-j2') %case of pairs |
|---|
| 1295 | for ipair=1:nbpair |
|---|
| 1296 | if select(ipair) |
|---|
| 1297 | 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 |
|---|
| 1298 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
|---|
| 1299 | ' :dt= ' num2str(dt*1000)]; |
|---|
| 1300 | else |
|---|
| 1301 | displ_pair{ipair}='...'; %pair not displayed in the menu |
|---|
| 1302 | end |
|---|
| 1303 | end |
|---|
| 1304 | elseif isequal(mode,'displacement') |
|---|
| 1305 | displ_pair={'Di=Dj=0'}; |
|---|
| 1306 | end |
|---|
| 1307 | val=get(handles.list_pair_civ2,'Value'); |
|---|
| 1308 | ichoice=min(find(select)); |
|---|
| 1309 | if (isempty(ichoice) || ichoice < 1); ichoice=1; end; |
|---|
| 1310 | if get(handles.CIV2,'Value')==0 && get(handles.CIV1,'Value')==0 && get(handles.FIX1,'Value')==0 && get(handles.PATCH1,'Value')==0 |
|---|
| 1311 | val=ichoice;% first valid pair proposed by default in the menu |
|---|
| 1312 | end |
|---|
| 1313 | if val>length(displ_pair') |
|---|
| 1314 | set(handles.list_pair_civ2,'Value',1);% first valid pair proposed by default in the menu |
|---|
| 1315 | else |
|---|
| 1316 | set(handles.list_pair_civ2,'Value',val); |
|---|
| 1317 | end |
|---|
| 1318 | set(handles.list_pair_civ2,'String',displ_pair'); |
|---|
| 1319 | set(gcf,'Pointer','arrow') |
|---|
| 1320 | |
|---|
| 1321 | %------------------------------------------------------------------------ |
|---|
| 1322 | % determine the list of index pairs of processing file |
|---|
| 1323 | function [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
|---|
| 1324 | find_pair_indices(handles,mode) |
|---|
| 1325 | %------------------------------------------------------------------------ |
|---|
| 1326 | first_i=str2double(get(handles.first_i,'String'));%first index i |
|---|
| 1327 | last_i=str2double(get(handles.last_i,'String'));%last index i |
|---|
| 1328 | incr=str2double(get(handles.incr_i,'String'));% increment |
|---|
| 1329 | num_i=first_i:incr:last_i;% list of i indices (reference values for each pair) |
|---|
| 1330 | if isequal(get(handles.first_j,'Visible'),'on') |
|---|
| 1331 | first_j=str2double(get(handles.first_j,'String'));%first index j |
|---|
| 1332 | last_j=str2double(get(handles.last_j,'String'));%last index j |
|---|
| 1333 | incr_j=str2double(get(handles.incr_j,'String'));% increment |
|---|
| 1334 | else |
|---|
| 1335 | first_j=1; |
|---|
| 1336 | last_j=1; |
|---|
| 1337 | incr_j=1; |
|---|
| 1338 | end |
|---|
| 1339 | num_j=[first_j:incr_j:last_j];% list of j indices (reference values for each pair) |
|---|
| 1340 | list_civ1=get(handles.list_pair_civ1,'String'); |
|---|
| 1341 | index_civ1=get(handles.list_pair_civ1,'Value'); |
|---|
| 1342 | str_civ1=list_civ1{index_civ1};%string defining the image pairs for civ1 |
|---|
| 1343 | if isempty(str_civ1)||isequal(str_civ1,'') |
|---|
| 1344 | msgbox_uvmat('ERROR','no image pair selected for civ1') |
|---|
| 1345 | return |
|---|
| 1346 | end |
|---|
| 1347 | list_civ2=get(handles.list_pair_civ2,'String'); |
|---|
| 1348 | index_civ2=get(handles.list_pair_civ2,'Value'); |
|---|
| 1349 | if index_civ2>length(list_civ2) |
|---|
| 1350 | list_civ2=list_civ1; |
|---|
| 1351 | index_civ2=index_civ1; |
|---|
| 1352 | end |
|---|
| 1353 | str_civ2=list_civ2{index_civ2};%string defining the image pairs for civ2 |
|---|
| 1354 | if isempty(first_i)||isempty(first_j), msgbox_uvmat('ERROR','first field number not defined'),... |
|---|
| 1355 | return,end; |
|---|
| 1356 | if isequal(last_i,[])|| isequal(last_j,[]),msgbox_uvmat('ERROR','last field number not defined'),... |
|---|
| 1357 | return,end; |
|---|
| 1358 | if isequal(incr,[])|| isequal(incr_j,[]),msgbox_uvmat('ERROR','increment in field number not defined'),... |
|---|
| 1359 | return,end; |
|---|
| 1360 | if last_i < first_i || last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),... |
|---|
| 1361 | return,end; |
|---|
| 1362 | if isequal (mode,'series(Di)') |
|---|
| 1363 | %recognize the pair civ1 from the display |
|---|
| 1364 | indsel=find((double(str_civ1)<48)|(double(str_civ1)>57));% character indices of non numerical characters |
|---|
| 1365 | str_raw=str_civ1(indsel); |
|---|
| 1366 | indsepar=find(str_raw=='|'); %character index of the separator |
|---|
| 1367 | d1=str2double(str_civ1(indsel(indsepar-1)+1:indsel(indsepar)-1)); |
|---|
| 1368 | if indsepar==length(str_raw) |
|---|
| 1369 | d2=str2double(str_civ1(indsel(indsepar)+1:end)); |
|---|
| 1370 | else |
|---|
| 1371 | d2=str2double(str_civ1(indsel(indsepar)+1:indsel(indsepar+1)-1)); |
|---|
| 1372 | end |
|---|
| 1373 | num1_civ1=num_i-d1;% set of first image numbers |
|---|
| 1374 | num2_civ1=num_i+d2; |
|---|
| 1375 | num_a_civ1=num_j; |
|---|
| 1376 | num_b_civ1=num_j; |
|---|
| 1377 | |
|---|
| 1378 | %recognize the pair civ2 from the display |
|---|
| 1379 | indsel=find((double(str_civ2)<48)|(double(str_civ2)>57));% character indices of non numerical characters |
|---|
| 1380 | str_raw=str_civ2(indsel); |
|---|
| 1381 | indsepar=find(str_raw=='|'); %character index of the separator |
|---|
| 1382 | d1=str2double(str_civ2(indsel(indsepar-1)+1:indsel(indsepar)-1)); |
|---|
| 1383 | if indsepar==length(str_raw) |
|---|
| 1384 | d2=str2double(str_civ2(indsel(indsepar)+1:end)); |
|---|
| 1385 | else |
|---|
| 1386 | d2=str2double(str_civ2(indsel(indsepar)+1:indsel(indsepar+1)-1)); |
|---|
| 1387 | end |
|---|
| 1388 | if isnan(d1) |
|---|
| 1389 | num1_civ2=num_i; |
|---|
| 1390 | else |
|---|
| 1391 | num1_civ2=num_i-d1;% set of first image numbers |
|---|
| 1392 | end |
|---|
| 1393 | if isnan(d2) |
|---|
| 1394 | num2_civ2=num_i; |
|---|
| 1395 | else |
|---|
| 1396 | num2_civ2=num_i+d2; |
|---|
| 1397 | end |
|---|
| 1398 | num_a_civ2=num_j; |
|---|
| 1399 | num_b_civ2=num_j; |
|---|
| 1400 | |
|---|
| 1401 | % adjust the first and last field number |
|---|
| 1402 | lastfield=str2double(get(handles.nb_field,'String')); |
|---|
| 1403 | if isequal(lastfield,[]) |
|---|
| 1404 | indsel=find((num1_civ1 >= 1)&(num1_civ2 >= 1)); |
|---|
| 1405 | else |
|---|
| 1406 | indsel=find((num2_civ1 <= lastfield)&(num2_civ2 <= lastfield)&(num1_civ1 >= 1)&(num1_civ2 >= 1)); |
|---|
| 1407 | end |
|---|
| 1408 | if length(indsel)>=1 |
|---|
| 1409 | firstind=indsel(1); |
|---|
| 1410 | lastind=indsel(end); |
|---|
| 1411 | set(handles.first_i,'String',num2str(num_i(firstind)))%update the display of first and last fields |
|---|
| 1412 | set(handles.last_i,'String',num2str(num_i(lastind))) |
|---|
| 1413 | num_i=num_i(indsel); |
|---|
| 1414 | num1_civ1=num1_civ1(indsel); |
|---|
| 1415 | num1_civ2=num1_civ2(indsel); |
|---|
| 1416 | num2_civ1=num2_civ1(indsel); |
|---|
| 1417 | num2_civ2=num2_civ2(indsel); |
|---|
| 1418 | end |
|---|
| 1419 | elseif isequal (mode,'series(Dj)') |
|---|
| 1420 | lastfield_j=str2double(get(handles.nb_field2,'String')); |
|---|
| 1421 | num1_civ1=num_i;% set of first image numbers |
|---|
| 1422 | num2_civ1=num_i; |
|---|
| 1423 | num_a_civ1=num_j-floor(index_civ1/2)*ones(size(num_j)); |
|---|
| 1424 | num_b_civ1=num_j+ceil(index_civ1/2)*ones(size(num_j)); |
|---|
| 1425 | num1_civ2=num_i; |
|---|
| 1426 | num2_civ2=num_i; |
|---|
| 1427 | num_a_civ2=num_j-floor(index_civ2/2)*ones(size(num_j)); |
|---|
| 1428 | num_b_civ2=num_j+ceil(index_civ2/2)*ones(size(num_j)); |
|---|
| 1429 | % adjust the first and last field number |
|---|
| 1430 | if isnan(lastfield_j) |
|---|
| 1431 | indsel=find((num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
|---|
| 1432 | else |
|---|
| 1433 | indsel=find((num_b_civ1 <= lastfield_j)&(num_b_civ2 <= lastfield_j)&(num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
|---|
| 1434 | end |
|---|
| 1435 | if length(indsel)>=1 |
|---|
| 1436 | firstind=indsel(1); |
|---|
| 1437 | lastind=indsel(end); |
|---|
| 1438 | set(handles.first_j,'String',num2str(num_j(firstind)))%update the display of first and last fields |
|---|
| 1439 | set(handles.last_j,'String',num2str(num_j(lastind))) |
|---|
| 1440 | num_j=num_j(indsel); |
|---|
| 1441 | num_a_civ1=num_a_civ1(indsel); |
|---|
| 1442 | num_a_civ2=num_a_civ2(indsel); |
|---|
| 1443 | num_b_civ1=num_b_civ1(indsel); |
|---|
| 1444 | num_b_civ2=num_b_civ2(indsel); |
|---|
| 1445 | end |
|---|
| 1446 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
|---|
| 1447 | num1_civ1=num_i; |
|---|
| 1448 | num1_civ2=num_i; |
|---|
| 1449 | displ_num=get(handles.list_pair_civ1,'UserData'); |
|---|
| 1450 | num2_civ1=num_i; |
|---|
| 1451 | num_a_civ1=displ_num(1,index_civ1); |
|---|
| 1452 | num_b_civ1=displ_num(2,index_civ1); |
|---|
| 1453 | num2_civ2=num_i; |
|---|
| 1454 | num_a_civ2=displ_num(1,index_civ2); |
|---|
| 1455 | num_b_civ2=displ_num(2,index_civ2); |
|---|
| 1456 | elseif isequal(mode,'displacement') |
|---|
| 1457 | num1_civ1=num_i; |
|---|
| 1458 | num2_civ1=num_i; |
|---|
| 1459 | num_a_civ1=num_j; |
|---|
| 1460 | num_b_civ1=num_j; |
|---|
| 1461 | num1_civ2=num_i; |
|---|
| 1462 | num2_civ2=num_i; |
|---|
| 1463 | num_a_civ2=num_j; |
|---|
| 1464 | num_b_civ2=num_j; |
|---|
| 1465 | end |
|---|
| 1466 | |
|---|
| 1467 | |
|---|
| 1468 | %------------------------------------------------------------------------ |
|---|
| 1469 | % --- Executes on selection change in list_pair_civ1. |
|---|
| 1470 | function list_pair_civ1_Callback(hObject, eventdata, handles) |
|---|
| 1471 | %------------------------------------------------------------------------ |
|---|
| 1472 | %reproduce by default the chosen pair in the civ2 menu |
|---|
| 1473 | list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs |
|---|
| 1474 | index_pair=get(handles.list_pair_civ1,'Value'); |
|---|
| 1475 | displ_num=get(handles.list_pair_civ1,'UserData'); |
|---|
| 1476 | % num_a=displ_num(1,index_pair); |
|---|
| 1477 | % num_b=displ_num(2,index_pair); |
|---|
| 1478 | list_pair2=get(handles.list_pair_civ2,'String');%get the menu of image pairs |
|---|
| 1479 | if index_pair<=length(list_pair2) |
|---|
| 1480 | set(handles.list_pair_civ2,'Value',index_pair); |
|---|
| 1481 | end |
|---|
| 1482 | |
|---|
| 1483 | %update first_i and last_i according to the chosen image pairs |
|---|
| 1484 | mode_list=get(handles.mode,'String'); |
|---|
| 1485 | mode_value=get(handles.mode,'Value'); |
|---|
| 1486 | mode=mode_list{mode_value}; |
|---|
| 1487 | if isequal(mode,'series(Di)') |
|---|
| 1488 | first_i=str2double(get(handles.first_i,'String')); |
|---|
| 1489 | last_i=str2double(get(handles.last_i,'String')); |
|---|
| 1490 | incr_i=str2double(get(handles.incr_i,'String')); |
|---|
| 1491 | num1=first_i:incr_i:last_i; |
|---|
| 1492 | lastfield=str2double(get(handles.nb_field,'String')); |
|---|
| 1493 | if ~isnan(lastfield) |
|---|
| 1494 | ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
|---|
| 1495 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield)); |
|---|
| 1496 | num1=num1(ind); |
|---|
| 1497 | end |
|---|
| 1498 | set(handles.first_i,'String',num2str(num1(1))); |
|---|
| 1499 | set(handles.last_i,'String',num2str(num1(end))); |
|---|
| 1500 | elseif isequal(mode,'series(Dj)') |
|---|
| 1501 | first_j=str2double(get(handles.first_j,'String')); |
|---|
| 1502 | last_j=str2double(get(handles.last_j,'String')); |
|---|
| 1503 | incr_j=str2double(get(handles.incr_j,'String')); |
|---|
| 1504 | num_j=first_j:incr_j:last_j; |
|---|
| 1505 | lastfield2=str2double(get(handles.nb_field2,'String')); |
|---|
| 1506 | if ~isnan(lastfield2) |
|---|
| 1507 | ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
|---|
| 1508 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2)); |
|---|
| 1509 | num1=num_j(ind); |
|---|
| 1510 | end |
|---|
| 1511 | set(handles.first_j,'String',num2str(num1(1))); |
|---|
| 1512 | set(handles.last_j,'String',num2str(num1(end))); |
|---|
| 1513 | end |
|---|
| 1514 | |
|---|
| 1515 | %------------------------------------------------------------------------ |
|---|
| 1516 | % --- Executes on selection change in list_pair_civ2. |
|---|
| 1517 | function list_pair_civ2_Callback(hObject, eventdata, handles) |
|---|
| 1518 | %------------------------------------------------------------------------ |
|---|
| 1519 | index_pair=get(handles.list_pair_civ2,'Value');%get the selected position index in the menu |
|---|
| 1520 | |
|---|
| 1521 | %update first_i and last_i according to the chosen image pairs |
|---|
| 1522 | mode_list=get(handles.mode,'String'); |
|---|
| 1523 | mode_value=get(handles.mode,'Value'); |
|---|
| 1524 | mode=mode_list{mode_value}; |
|---|
| 1525 | if isequal(mode,'series(Di)') |
|---|
| 1526 | first_i=str2double(get(handles.first_i,'String')); |
|---|
| 1527 | last_i=str2double(get(handles.last_i,'String')); |
|---|
| 1528 | incr_i=str2double(get(handles.incr_i,'String')); |
|---|
| 1529 | num1=first_i:incr_i:last_i; |
|---|
| 1530 | lastfield=str2double(get(handles.nb_field,'String')); |
|---|
| 1531 | if ~isnan(lastfield) |
|---|
| 1532 | ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
|---|
| 1533 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield)); |
|---|
| 1534 | num1=num1(ind); |
|---|
| 1535 | end |
|---|
| 1536 | set(handles.first_i,'String',num2str(num1(1))); |
|---|
| 1537 | set(handles.last_i,'String',num2str(num1(end))); |
|---|
| 1538 | elseif isequal(mode,'series(Dj)') |
|---|
| 1539 | first_j=str2double(get(handles.first_j,'String')); |
|---|
| 1540 | last_j=str2double(get(handles.last_j,'String')); |
|---|
| 1541 | incr_j=str2double(get(handles.incr_j,'String')); |
|---|
| 1542 | num_j=first_j:incr_j:last_j; |
|---|
| 1543 | lastfield2=str2double(get(handles.nb_field2,'String')); |
|---|
| 1544 | if ~isnan(lastfield2) |
|---|
| 1545 | ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
|---|
| 1546 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2)); |
|---|
| 1547 | num1=num_j(ind); |
|---|
| 1548 | end |
|---|
| 1549 | set(handles.first_j,'String',num2str(num1(1))); |
|---|
| 1550 | set(handles.last_j,'String',num2str(num1(end))); |
|---|
| 1551 | end |
|---|
| 1552 | |
|---|
| 1553 | %------------------------------------------------------------------------ |
|---|
| 1554 | % --- Executes on button press in RUN: processing on local computer |
|---|
| 1555 | function RUN_Callback(hObject, eventdata, handles) |
|---|
| 1556 | %------------------------------------------------------------------------ |
|---|
| 1557 | set(handles.RUN, 'Enable','Off') |
|---|
| 1558 | set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) |
|---|
| 1559 | batch=0; |
|---|
| 1560 | launch_jobs(hObject, eventdata, handles,batch); |
|---|
| 1561 | set(handles.RUN, 'Enable','On') |
|---|
| 1562 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
|---|
| 1563 | |
|---|
| 1564 | % start status callback to visualise results |
|---|
| 1565 | set(handles.status,'Value',1);%suppress status display |
|---|
| 1566 | status_Callback(hObject, eventdata, handles) |
|---|
| 1567 | |
|---|
| 1568 | %------------------------------------------------------------------------ |
|---|
| 1569 | % --- Executes on button press in BATCH: remote processing |
|---|
| 1570 | function BATCH_Callback(hObject, eventdata, handles) |
|---|
| 1571 | % ----------------------------------------------------------------------- |
|---|
| 1572 | set(handles.BATCH, 'Enable','Off') |
|---|
| 1573 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784]) |
|---|
| 1574 | batch=1; |
|---|
| 1575 | launch_jobs(hObject, eventdata, handles, batch) |
|---|
| 1576 | set(handles.BATCH, 'Enable','On') |
|---|
| 1577 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
|---|
| 1578 | |
|---|
| 1579 | % start status callback to visualise results |
|---|
| 1580 | set(handles.status,'Value',1);%suppress status display |
|---|
| 1581 | status_Callback(hObject, eventdata, handles) |
|---|
| 1582 | %------------------------------------------------------------------------ |
|---|
| 1583 | % --- Lauch command called by RUN and BATCH: remote processing |
|---|
| 1584 | function launch_jobs(hObject, eventdata, handles, batch) |
|---|
| 1585 | %----------------------------------------------------------------------- |
|---|
| 1586 | %% check the selected list of operations: |
|---|
| 1587 | operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'}; |
|---|
| 1588 | box_test(1)=get(handles.CIV1,'Value'); |
|---|
| 1589 | box_test(2)=get(handles.FIX1,'Value'); |
|---|
| 1590 | box_test(3)=get(handles.PATCH1,'Value'); |
|---|
| 1591 | box_test(4)=get(handles.CIV2,'Value'); |
|---|
| 1592 | box_test(5)=get(handles.FIX2,'Value'); |
|---|
| 1593 | box_test(6)=get(handles.PATCH2,'Value'); |
|---|
| 1594 | index=find(box_test==1); |
|---|
| 1595 | if isempty(index) |
|---|
| 1596 | msgbox_uvmat('ERROR','no selected operation') |
|---|
| 1597 | return |
|---|
| 1598 | end |
|---|
| 1599 | index_first=min(index); |
|---|
| 1600 | index_last=max(index); |
|---|
| 1601 | box_used=box_test(index_first : index_last); |
|---|
| 1602 | [box_missing,ind_missing]=min(box_used); |
|---|
| 1603 | if isequal(box_missing,0) |
|---|
| 1604 | msgbox_uvmat('ERROR',['missing' cell2mat(operations(ind_missing))]); |
|---|
| 1605 | return |
|---|
| 1606 | end |
|---|
| 1607 | |
|---|
| 1608 | %% check mask if selecetd |
|---|
| 1609 | if isequal(get(handles.get_mask_civ1,'Value'),1) |
|---|
| 1610 | maskname=get(handles.mask_civ1,'String'); |
|---|
| 1611 | if ~exist(maskname,'file') |
|---|
| 1612 | get_mask_civ1_Callback(hObject, eventdata, handles); |
|---|
| 1613 | end |
|---|
| 1614 | end |
|---|
| 1615 | if isequal(get(handles.get_mask_fix1,'Value'),1) |
|---|
| 1616 | maskname=get(handles.mask_fix1,'String'); |
|---|
| 1617 | if ~exist(maskname,'file') |
|---|
| 1618 | get_mask_fix1_Callback(hObject, eventdata, handles); |
|---|
| 1619 | end |
|---|
| 1620 | end |
|---|
| 1621 | if isequal(get(handles.get_mask_civ2,'Value'),1) |
|---|
| 1622 | maskname=get(handles.mask_civ2,'String'); |
|---|
| 1623 | if ~exist(maskname,'file') |
|---|
| 1624 | get_mask_civ2_Callback(hObject, eventdata, handles); |
|---|
| 1625 | end |
|---|
| 1626 | end |
|---|
| 1627 | if isequal(get(handles.get_mask_fix2,'Value'),1) |
|---|
| 1628 | maskname=get(handles.mask_fix2,'String'); |
|---|
| 1629 | if ~exist(maskname,'file') |
|---|
| 1630 | get_mask_fix2_Callback(hObject, eventdata, handles); |
|---|
| 1631 | end |
|---|
| 1632 | end |
|---|
| 1633 | |
|---|
| 1634 | %% reinitialise status callback |
|---|
| 1635 | set(handles.status,'Value',0);%suppress status display |
|---|
| 1636 | status_Callback(hObject, eventdata, handles) |
|---|
| 1637 | |
|---|
| 1638 | %% set the list of files and check them |
|---|
| 1639 | display('checking the files...') |
|---|
| 1640 | %compare=get(handles.compare,'Value');%test for usual PIV (compare=1) or displacement (=2) or stereo PIV (=3) |
|---|
| 1641 | [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc]=... |
|---|
| 1642 | set_civ_filenames(handles,box_test); |
|---|
| 1643 | set(handles.civ,'UserData',filecell);%store for futur use of status callback |
|---|
| 1644 | if isempty(filecell)% (error message displayed in fct set_civ_filenames) |
|---|
| 1645 | return |
|---|
| 1646 | end |
|---|
| 1647 | nbfield=numel(num1_civ1); |
|---|
| 1648 | nbslice=numel(num_a_civ1); |
|---|
| 1649 | |
|---|
| 1650 | %% choice of batch priority |
|---|
| 1651 | ind_answer=2; |
|---|
| 1652 | if batch |
|---|
| 1653 | [s,w]=unix('qstat -q civ.q|grep job_| wc -l'); %check the waiting list (command unix) |
|---|
| 1654 | if isequal(s,0) |
|---|
| 1655 | w(end)=[]; |
|---|
| 1656 | str_displ={[w ' jobs in the waiting list'];'Select a priority:'}; |
|---|
| 1657 | str={'urgent';'normal';'low'}; |
|---|
| 1658 | [ind_answer,v] = listdlg('PromptString',str_displ,... |
|---|
| 1659 | 'SelectionMode','single',... |
|---|
| 1660 | 'ListString',str,'ListSize',[200 200],'Name','job priority','InitialValue',3); |
|---|
| 1661 | if isequal(v,0) % to handle Cancel button and figure close, |
|---|
| 1662 | return % a better way should be create |
|---|
| 1663 | end |
|---|
| 1664 | else |
|---|
| 1665 | msgbox_uvmat('ERROR','batch system not available') |
|---|
| 1666 | return |
|---|
| 1667 | end |
|---|
| 1668 | else |
|---|
| 1669 | if isunix |
|---|
| 1670 | [xx,w]=unix('ps faux |grep civ|wc -l'); |
|---|
| 1671 | w(end)=[]; |
|---|
| 1672 | if str2double(w)+numel(num1_civ1)> 50 |
|---|
| 1673 | msgbox_uvmat('ERROR',{['There are already ' w ' civ processes running locally'];'Use BATCH or submit RUN later'}) |
|---|
| 1674 | return |
|---|
| 1675 | end |
|---|
| 1676 | end |
|---|
| 1677 | end |
|---|
| 1678 | |
|---|
| 1679 | |
|---|
| 1680 | %% read names of the .exe files for PIV and patch |
|---|
| 1681 | path_UVMAT=fileparts(which('uvmat')); %path to the source directory of uvmat |
|---|
| 1682 | xmlfile='PARAM.xml'; |
|---|
| 1683 | if exist(xmlfile,'file')% search parameter xml file in the whole matlab path |
|---|
| 1684 | t=xmltree(xmlfile); |
|---|
| 1685 | s=convert(t); |
|---|
| 1686 | end |
|---|
| 1687 | test_interp=0; |
|---|
| 1688 | if batch |
|---|
| 1689 | if isfield(s,'BatchParam') |
|---|
| 1690 | sparam=s.BatchParam; |
|---|
| 1691 | if ~ismember(sparam.BatchMode,{'sge'}) |
|---|
| 1692 | msgbox_uvmat('ERROR',['batch mode ' sparam.BatchMode ' not supported by UVMAT']) |
|---|
| 1693 | end |
|---|
| 1694 | else |
|---|
| 1695 | msgbox_uvmat('ERROR','no batch mode defined in PARAM.xml') |
|---|
| 1696 | return |
|---|
| 1697 | end |
|---|
| 1698 | else |
|---|
| 1699 | if isfield(s,'RunParam') |
|---|
| 1700 | sparam=s.RunParam; |
|---|
| 1701 | else |
|---|
| 1702 | msgbox_uvmat('ERROR','no civ binaries defined in PARAM.xml') |
|---|
| 1703 | return |
|---|
| 1704 | end |
|---|
| 1705 | if isfield(sparam,'CivBin') |
|---|
| 1706 | if ~exist(sparam.CivBin,'file') |
|---|
| 1707 | sparam.CivBin=fullfile(path_UVMAT,sparam.CivBin); |
|---|
| 1708 | end |
|---|
| 1709 | end |
|---|
| 1710 | if isfield(sparam,'Civ1Bin') |
|---|
| 1711 | if ~exist(sparam.Civ1Bin,'file') |
|---|
| 1712 | sparam.Civ1Bin=fullfile(path_UVMAT,sparam.Civ1Bin); |
|---|
| 1713 | end |
|---|
| 1714 | end |
|---|
| 1715 | if isfield(sparam,'Civ2Bin') |
|---|
| 1716 | if ~exist(sparam.Civ2Bin,'file') |
|---|
| 1717 | sparam.Civ2Bin=fullfile(path_UVMAT,sparam.Civ2Bin); |
|---|
| 1718 | end |
|---|
| 1719 | end |
|---|
| 1720 | %test_interp=get(handles.test_interp,'Value'); |
|---|
| 1721 | |
|---|
| 1722 | if isfield(sparam,'PatchBin') |
|---|
| 1723 | if ~exist(sparam.PatchBin,'file') |
|---|
| 1724 | sparam.PatchBin=fullfile(path_UVMAT,sparam.PatchBin); |
|---|
| 1725 | end |
|---|
| 1726 | end |
|---|
| 1727 | % if test_interp && isfield(sparam,'PatchNewBin') |
|---|
| 1728 | % if ~exist(sparam.PatchNewBin,'file') |
|---|
| 1729 | % sparam.PatchNewBin=fullfile(path_UVMAT,sparam.PatchNewBin); |
|---|
| 1730 | % end |
|---|
| 1731 | % end |
|---|
| 1732 | if isfield(sparam,'FixBin') |
|---|
| 1733 | if ~exist(sparam.FixBin,'file') |
|---|
| 1734 | sparam.FixBin=fullfile(path_UVMAT,sparam.FixBin); |
|---|
| 1735 | end |
|---|
| 1736 | end |
|---|
| 1737 | end |
|---|
| 1738 | if batch |
|---|
| 1739 | if isfield(sparam,'BatchMode') |
|---|
| 1740 | batch_mode=sparam.BatchMode; |
|---|
| 1741 | end |
|---|
| 1742 | else |
|---|
| 1743 | % MaxCivProcesses=50; |
|---|
| 1744 | % if isfield(sparam,'MaxCivProcesses') |
|---|
| 1745 | % MaxCivProcesses=str2double(sparam.MaxCivProcesses); |
|---|
| 1746 | % end |
|---|
| 1747 | end |
|---|
| 1748 | |
|---|
| 1749 | |
|---|
| 1750 | %% get civ1 parameters: |
|---|
| 1751 | display('files OK, processing...') |
|---|
| 1752 | %get civ parameters |
|---|
| 1753 | if box_test(1)==1 |
|---|
| 1754 | par_civ1=read_param_civ1(handles,filecell.ima1.civ1{1,1}); |
|---|
| 1755 | end |
|---|
| 1756 | |
|---|
| 1757 | %% get fix1 parameters |
|---|
| 1758 | if box_test(2)==1 |
|---|
| 1759 | flagindex1(1)=get(handles.vec_Fmin2, 'Value'); |
|---|
| 1760 | flagindex1(2)=get(handles.vec_F3, 'Value'); |
|---|
| 1761 | flagindex1(3)=get(handles.vec_F2, 'Value'); |
|---|
| 1762 | thresh_vecC1=str2double(get(handles.thresh_vecC,'String'));%threshold on image correlation vec_C |
|---|
| 1763 | thresh_vel1=str2double(get(handles.thresh_vel,'String'));%threshold on velocity modulus |
|---|
| 1764 | test_mask=get(handles.get_mask_fix1,'Value'); |
|---|
| 1765 | nbslice_mask=get(handles.mask_fix1,'UserData'); % get the number of slices (= number of masks) |
|---|
| 1766 | %%%%%%%%%%%%%COMPLETER LE PROGRAMME FIX |
|---|
| 1767 | % inf_sup=get(handles.inf_sup1,'Value');80 |
|---|
| 1768 | % fileref=get(handles.ref_fix1,'String'); |
|---|
| 1769 | % refpath=get(handles.ref_fix1,'UserData'); |
|---|
| 1770 | % fileref=fullfile(refpath,fileref); |
|---|
| 1771 | menu=get(handles.field_ref1,'String'); |
|---|
| 1772 | index=get(handles.field_ref1,'Value'); |
|---|
| 1773 | if isempty(menu) |
|---|
| 1774 | fieldchoice=''; |
|---|
| 1775 | else |
|---|
| 1776 | fieldchoice=menu{index}; |
|---|
| 1777 | msgbox_uvmat('WARNING','reference field is not used presently with batch, use RUN option') |
|---|
| 1778 | end |
|---|
| 1779 | end |
|---|
| 1780 | |
|---|
| 1781 | %% get patch1 parameters |
|---|
| 1782 | if box_test(3)==1 |
|---|
| 1783 | rho_patch1=str2double(get(handles.rho_patch1,'String')); |
|---|
| 1784 | if isnan(rho_patch1) |
|---|
| 1785 | rho_patch1='1000'; |
|---|
| 1786 | set(handles.rho_patch1,'String','1') |
|---|
| 1787 | else |
|---|
| 1788 | rho_patch1=num2str(1000*rho_patch1); |
|---|
| 1789 | end |
|---|
| 1790 | nx_patch1=get(handles.nx_patch1,'String'); |
|---|
| 1791 | ny_patch1=get(handles.ny_patch1,'String'); |
|---|
| 1792 | if isnan(str2double(nx_patch1)) |
|---|
| 1793 | nx_patch1='50' ;%default |
|---|
| 1794 | set(handles.nx_patch1,'String','50'); |
|---|
| 1795 | end |
|---|
| 1796 | if isnan(str2double(ny_patch1)) |
|---|
| 1797 | ny_patch1='50' ;%default |
|---|
| 1798 | set(handles.ny_patch1,'String','50'); |
|---|
| 1799 | end |
|---|
| 1800 | subdomain_patch1=get(handles.subdomain_patch1,'String'); |
|---|
| 1801 | thresh_patch1=get(handles.thresh_patch1,'String'); |
|---|
| 1802 | end |
|---|
| 1803 | |
|---|
| 1804 | %% get civ2 parameters: |
|---|
| 1805 | if box_test(4)==1 |
|---|
| 1806 | par_civ2=read_param_civ2(handles,cell2mat(filecell.ima1.civ2(1,1))); |
|---|
| 1807 | end |
|---|
| 1808 | |
|---|
| 1809 | %% get fix2 parameters |
|---|
| 1810 | if box_test(5)==1 |
|---|
| 1811 | flagindex2(1)=get(handles.vec_Fmin2_2, 'Value'); |
|---|
| 1812 | flagindex2(2)=get(handles.vec_F3_2, 'Value'); |
|---|
| 1813 | flagindex2(3)=get(handles.vec_F4, 'Value'); |
|---|
| 1814 | thresh_vec2C=str2double(get(handles.thresh_vec2C,'String'));%threshold on image correlation vec_C |
|---|
| 1815 | thresh_vel2=str2double(get(handles.thresh_vel2,'String'));%threshold on velocity modulus |
|---|
| 1816 | test_mask=get(handles.get_mask_fix2,'Value'); |
|---|
| 1817 | nbslice_mask=get(handles.mask_fix2,'UserData'); % get the number of slices (= number of masks) |
|---|
| 1818 | %%%%%%%%%%%%%COMPLETER LE PROGRAMME FIX AVEC REF FILE ET OPTION inf_sup=2 |
|---|
| 1819 | % inf_sup=get(handles.inf_sup2,'Value'); |
|---|
| 1820 | % ref=get(handles.ref_fix2,'UserData'); |
|---|
| 1821 | |
|---|
| 1822 | %%%%%%%%%%%%%%%%%%% |
|---|
| 1823 | end |
|---|
| 1824 | |
|---|
| 1825 | %% get patch2 parameters |
|---|
| 1826 | if box_test(6)==1 |
|---|
| 1827 | rho_patch2=str2double(get(handles.rho_patch2,'String')); |
|---|
| 1828 | if isnan(rho_patch2) |
|---|
| 1829 | rho_patch2='1000'; |
|---|
| 1830 | set(handles.rho_patch2,'String','1') |
|---|
| 1831 | else |
|---|
| 1832 | rho_patch2=num2str(1000*rho_patch2); |
|---|
| 1833 | end |
|---|
| 1834 | nx_patch2=get(handles.nx_patch2,'String'); |
|---|
| 1835 | ny_patch2=get(handles.ny_patch2,'String'); |
|---|
| 1836 | if isnan(str2double(nx_patch2)) |
|---|
| 1837 | nx_patch2='50' ;%default |
|---|
| 1838 | set(handles.nx_patch2,'String','50'); |
|---|
| 1839 | end |
|---|
| 1840 | if isnan(str2double(ny_patch2)) |
|---|
| 1841 | ny_patch2='50' ;%default |
|---|
| 1842 | set(handles.ny_patch2,'String','50'); |
|---|
| 1843 | end |
|---|
| 1844 | subdomain_patch2=get(handles.subdomain_patch2,'String'); |
|---|
| 1845 | thresh_patch2=get(handles.thresh_patch2,'String'); |
|---|
| 1846 | % test_interp=get(handles.test_interp,'Value'); |
|---|
| 1847 | end |
|---|
| 1848 | |
|---|
| 1849 | %% MAIN LOOP |
|---|
| 1850 | time=get(handles.RootName,'UserData'); %get the set of times |
|---|
| 1851 | civAll=get(handles.Experimental,'Value'); % Boolean for new civ excution method |
|---|
| 1852 | super_cmd=[]; |
|---|
| 1853 | |
|---|
| 1854 | for ifile=1:nbfield |
|---|
| 1855 | for j=1:nbslice |
|---|
| 1856 | i_cmd=0; |
|---|
| 1857 | cmd=''; |
|---|
| 1858 | if isunix % check: necessaire aussi en RUN? |
|---|
| 1859 | %fid=fopen([filename '.cmx'],'w') |
|---|
| 1860 | cmd='#!/bin/bash \n'; |
|---|
| 1861 | cmd=[cmd '#$ -cwd \n']; |
|---|
| 1862 | cmd=[cmd 'hostname && date \n']; |
|---|
| 1863 | cmd=[cmd 'umask 002 \n'];%allow writting access for user group for created files |
|---|
| 1864 | end |
|---|
| 1865 | if civAll |
|---|
| 1866 | civAllxml=xmltree;% xml contents, all parameters |
|---|
| 1867 | civAllCmd=''; |
|---|
| 1868 | civAllxml=set(civAllxml,1,'name','CivDoc'); |
|---|
| 1869 | end |
|---|
| 1870 | %filename_cur=filecell.nc.civ1{ifile,j};%output netcdf file |
|---|
| 1871 | [Rootbat,Filebat]=fileparts(filecell.nc.civ1{ifile,j});%output netcdf file (without extention) |
|---|
| 1872 | flname=fullfile(Rootbat,Filebat); |
|---|
| 1873 | %filename_cmx(end-1:end+6)='civ1.cmx';%name of cmx file |
|---|
| 1874 | if batch |
|---|
| 1875 | % [Rootbat,Filebat,extbat]=fileparts(filename_cmx); |
|---|
| 1876 | filename_bat=fullfile(Rootbat,['job_' Filebat]); |
|---|
| 1877 | else |
|---|
| 1878 | filename_bat=flname; |
|---|
| 1879 | end |
|---|
| 1880 | filename_bat=[filename_bat '.bat']; |
|---|
| 1881 | |
|---|
| 1882 | %CIV1 |
|---|
| 1883 | if box_test(1)==1 |
|---|
| 1884 | par_civ1.filename_ima_a=filecell.ima1.civ1{ifile,j}; |
|---|
| 1885 | par_civ1.filename_ima_b=filecell.ima2.civ1{ifile,j}; |
|---|
| 1886 | %namelog=[fullfile(Rootbat,Filebat) '.civ1.log']; |
|---|
| 1887 | par_civ1.Dt=num2str(time(num2_civ1(ifile),num_b_civ1(j))-time(num1_civ1(ifile),num_a_civ1(j))); |
|---|
| 1888 | par_civ1.T0=num2str((time(num2_civ1(ifile),num_b_civ1(j))+time(num1_civ1(ifile),num_a_civ1(j)))/2); |
|---|
| 1889 | par_civ1.term_a=num2stra(num_a_civ1(j),nom_type_nc);%UTILITE? |
|---|
| 1890 | par_civ1.term_b=num2stra(num_b_civ1(j),nom_type_nc);% |
|---|
| 1891 | test_mask=get(handles.get_mask_civ1,'Value'); |
|---|
| 1892 | if test_mask==0 |
|---|
| 1893 | par_civ1.maskname='noFile use default'; |
|---|
| 1894 | par_civ1.maskflag='n'; |
|---|
| 1895 | else |
|---|
| 1896 | maskdispl=get(handles.mask_civ1,'String'); |
|---|
| 1897 | if exist(maskdispl,'file') |
|---|
| 1898 | par_civ1.maskname=maskdispl; |
|---|
| 1899 | par_civ1.maskflag='y'; |
|---|
| 1900 | else |
|---|
| 1901 | maskbase=[filecell.filebase '_' maskdispl]; % |
|---|
| 1902 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
|---|
| 1903 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
|---|
| 1904 | par_civ1.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
|---|
| 1905 | if exist(par_civ1.maskname,'file') |
|---|
| 1906 | par_civ1.maskflag='y'; |
|---|
| 1907 | else |
|---|
| 1908 | par_civ1.maskname='noFile use default'; |
|---|
| 1909 | par_civ1.maskflag='n'; |
|---|
| 1910 | end |
|---|
| 1911 | end |
|---|
| 1912 | end |
|---|
| 1913 | |
|---|
| 1914 | test_grid=get(handles.browse_gridciv1,'Value'); |
|---|
| 1915 | if test_grid |
|---|
| 1916 | par_civ1.gridflag='y'; |
|---|
| 1917 | gridname=get(handles.grid_civ1,'String'); |
|---|
| 1918 | if isequal(gridname(end-3:end),'grid') |
|---|
| 1919 | nbslice_grid=str2double(gridname(1:end-4)); % |
|---|
| 1920 | if ~isnan(nbslice_grid) |
|---|
| 1921 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
|---|
| 1922 | par_civ1.gridname=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
|---|
| 1923 | if ~exist(par_civ1.gridname,'file') |
|---|
| 1924 | msgbox_uvmat('ERROR','grid file absent for civ1') |
|---|
| 1925 | end |
|---|
| 1926 | elseif exist(gridname,'file') |
|---|
| 1927 | par_civ1.gridname=gridname; |
|---|
| 1928 | else |
|---|
| 1929 | msgbox_uvmat('ERROR','grid file absent for civ1') |
|---|
| 1930 | end |
|---|
| 1931 | end |
|---|
| 1932 | else |
|---|
| 1933 | par_civ1.gridname='noFile use default'; |
|---|
| 1934 | par_civ1.gridflag='n'; |
|---|
| 1935 | end |
|---|
| 1936 | % |
|---|
| 1937 | i_cmd=i_cmd+1; |
|---|
| 1938 | if isequal(civAll,0) |
|---|
| 1939 | cmd=[cmd CIV1_CMD(fullfile(Rootbat,Filebat),'',par_civ1,handles,sparam) '\n']; |
|---|
| 1940 | else |
|---|
| 1941 | civAllCmd=[civAllCmd ' civ1 ']; |
|---|
| 1942 | str=CIV1_CMD_Unified(fullfile(Rootbat,Filebat),'',par_civ1); |
|---|
| 1943 | fieldnames=fields(str); |
|---|
| 1944 | [civAllxml,uid_civ1]=add(civAllxml,1,'element','civ1'); |
|---|
| 1945 | for ilist=1:length(fieldnames) |
|---|
| 1946 | val=eval(['str.' fieldnames{ilist}]); |
|---|
| 1947 | if ischar(val) |
|---|
| 1948 | [civAllxml,uid_t]=add(civAllxml,uid_civ1,'element',fieldnames{ilist}); |
|---|
| 1949 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
|---|
| 1950 | end |
|---|
| 1951 | end |
|---|
| 1952 | end |
|---|
| 1953 | end |
|---|
| 1954 | |
|---|
| 1955 | % FIX1 |
|---|
| 1956 | if box_test(2)==1 |
|---|
| 1957 | test_mask=get(handles.get_mask_fix1,'Value'); |
|---|
| 1958 | if test_mask==0 |
|---|
| 1959 | maskname=''; |
|---|
| 1960 | else |
|---|
| 1961 | maskdispl=get(handles.mask_fix1,'String'); |
|---|
| 1962 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
|---|
| 1963 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
|---|
| 1964 | maskbase=[filecell.filebase '_' maskdispl]; |
|---|
| 1965 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
|---|
| 1966 | end |
|---|
| 1967 | if isequal(civAll,0) |
|---|
| 1968 | if isunix %unix system |
|---|
| 1969 | cmd_FIX=[sparam.FixBin ' -f ' filecell.nc.civ1{ifile,j} ' -fi1 ' num2str(flagindex1(1)) ... |
|---|
| 1970 | ' -fi2 ' num2str(flagindex1(2)) ' -fi3 ' num2str(flagindex1(3)) ... |
|---|
| 1971 | ' -threshC ' num2str(thresh_vecC1) ' -threshV ' num2str(thresh_vel1) ' -maskName ' maskname]; |
|---|
| 1972 | else %windows system |
|---|
| 1973 | cmd_FIX=['"' sparam.FixBin '" -f "' filecell.nc.civ1{ifile,j} '" -fi1 ' num2str(flagindex1(1)) ... |
|---|
| 1974 | ' -fi2 ' num2str(flagindex1(2)) ' -fi3 ' num2str(flagindex1(3)) ... |
|---|
| 1975 | ' -threshC ' num2str(thresh_vecC1) ' -threshV ' num2str(thresh_vel1) ' -maskName "' maskname '"']; |
|---|
| 1976 | cmd_FIX=regexprep(cmd_FIX,'\\','\\\\'); |
|---|
| 1977 | end |
|---|
| 1978 | cmd=[cmd cmd_FIX '\n']; |
|---|
| 1979 | else |
|---|
| 1980 | fix1.inputFileName=filecell.nc.civ1{ifile,j} ; |
|---|
| 1981 | fix1.fi1=num2str(flagindex1(1)); |
|---|
| 1982 | fix1.fi2=num2str(flagindex1(2)); |
|---|
| 1983 | fix1.fi3=num2str(flagindex1(3)); |
|---|
| 1984 | fix1.threshC=num2str(thresh_vecC1); |
|---|
| 1985 | fix1.threshV=num2str(thresh_vel1); |
|---|
| 1986 | fieldnames=fields(fix1); |
|---|
| 1987 | [civAllxml,uid_fix1]=add(civAllxml,1,'element','fix1'); |
|---|
| 1988 | for ilist=1:length(fieldnames) |
|---|
| 1989 | val=eval(['fix1.' fieldnames{ilist}]); |
|---|
| 1990 | if ischar(val) |
|---|
| 1991 | [civAllxml,uid_t]=add(civAllxml,uid_fix1,'element',fieldnames{ilist}); |
|---|
| 1992 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
|---|
| 1993 | end |
|---|
| 1994 | end |
|---|
| 1995 | civAllCmd=[civAllCmd ' fix1 ']; |
|---|
| 1996 | end |
|---|
| 1997 | end |
|---|
| 1998 | |
|---|
| 1999 | %PATCH1 |
|---|
| 2000 | if box_test(3)==1 |
|---|
| 2001 | if isequal(civAll,0) |
|---|
| 2002 | cmd_PATCH=PATCH_CMD(filecell.nc.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp,sparam.PatchBin); |
|---|
| 2003 | cmd=[cmd cmd_PATCH '\n']; |
|---|
| 2004 | else |
|---|
| 2005 | patch1.inputFileName=filecell.nc.civ1{ifile,j} ; |
|---|
| 2006 | patch1.nopt=subdomain_patch1; |
|---|
| 2007 | patch1.maxdiff=thresh_patch1; |
|---|
| 2008 | patch1.ro=rho_patch1; |
|---|
| 2009 | test_grid=get(handles.get_gridpatch1,'Value'); |
|---|
| 2010 | if test_grid |
|---|
| 2011 | patch1.gridflag='y'; |
|---|
| 2012 | gridname=get(handles.grid_patch1,'String'); |
|---|
| 2013 | if isequal(gridname(end-3:end),'grid') |
|---|
| 2014 | nbslice_grid=str2double(gridname(1:end-4)); % |
|---|
| 2015 | if ~isnan(nbslice_grid) |
|---|
| 2016 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
|---|
| 2017 | patch1.gridPatch=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
|---|
| 2018 | if ~exist(patch1.gridPatch,'file') |
|---|
| 2019 | msgbox_uvmat('ERROR','grid file absent for patch1') |
|---|
| 2020 | end |
|---|
| 2021 | elseif exist(gridname,'file') |
|---|
| 2022 | patch1.gridPatch=gridname; |
|---|
| 2023 | else |
|---|
| 2024 | msgbox_uvmat('ERROR','grid file absent for patch1') |
|---|
| 2025 | end |
|---|
| 2026 | end |
|---|
| 2027 | else |
|---|
| 2028 | patch1.gridPatch='none'; |
|---|
| 2029 | patch1.gridflag='n'; |
|---|
| 2030 | patch1.m=nx_patch1; |
|---|
| 2031 | patch1.n=ny_patch1; |
|---|
| 2032 | end |
|---|
| 2033 | patch1.convectFlow='n'; |
|---|
| 2034 | fieldnames=fields(patch1); |
|---|
| 2035 | [civAllxml,uid_patch1]=add(civAllxml,1,'element','patch1'); |
|---|
| 2036 | for ilist=1:length(fieldnames) |
|---|
| 2037 | val=eval(['patch1.' fieldnames{ilist}]); |
|---|
| 2038 | if ischar(val) |
|---|
| 2039 | [civAllxml,uid_t]=add(civAllxml,uid_patch1,'element',fieldnames{ilist}); |
|---|
| 2040 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
|---|
| 2041 | end |
|---|
| 2042 | end |
|---|
| 2043 | civAllCmd=[civAllCmd ' patch1 ']; |
|---|
| 2044 | end |
|---|
| 2045 | end |
|---|
| 2046 | |
|---|
| 2047 | if box_test(4)==1 || box_test(5)==1 || box_test(6)==1 |
|---|
| 2048 | filename_cmx=filecell.nc.civ2{ifile,j};%output netcdf file |
|---|
| 2049 | filename_cmx([end-1:end+1])=[ 'cmx'];%name of cmx file |
|---|
| 2050 | % filename_cmx=[filename_cmx 'x']; |
|---|
| 2051 | end |
|---|
| 2052 | |
|---|
| 2053 | if box_test(4)==1 |
|---|
| 2054 | par_civ2.filename_ima_a=filecell.ima1.civ2{ifile,j}; |
|---|
| 2055 | %par_civ2.filename_ima_a([end-3:end])=[];%remove .png extension |
|---|
| 2056 | par_civ2.filename_ima_b=filecell.ima2.civ2{ifile,j}; |
|---|
| 2057 | %par_civ2.filename_ima_b([end-3:end])=[];%remove .png extension |
|---|
| 2058 | [Rootbat,Filebat]=fileparts(filecell.nc.civ2{ifile,j});%output netcdf file (without extention) |
|---|
| 2059 | %namelog=[fullfile(Rootbat,Filebat) '.civ2.log']; |
|---|
| 2060 | par_civ2.Dt=num2str(time(num2_civ2(ifile),num_b_civ2(j))-time(num1_civ2(ifile),num_a_civ2(j))); |
|---|
| 2061 | par_civ2.T0=num2str((time(num2_civ1(ifile),num_b_civ2(j))+time(num1_civ2(ifile),num_a_civ2(j)))/2); |
|---|
| 2062 | par_civ2.term_a=num2stra(num_a_civ2(j),nom_type_nc); |
|---|
| 2063 | par_civ2.term_b=num2stra(num_b_civ2(j),nom_type_nc); |
|---|
| 2064 | par_civ2.filename_nc1=filecell.nc.civ1{ifile,j}; |
|---|
| 2065 | par_civ2.filename_nc1([end-2:end])=[]; % remove '.nc' |
|---|
| 2066 | test_mask=get(handles.get_mask_civ2,'Value'); |
|---|
| 2067 | if test_mask==0 |
|---|
| 2068 | par_civ2.maskname='noFile use default'; |
|---|
| 2069 | par_civ2.maskflag='n'; |
|---|
| 2070 | else |
|---|
| 2071 | maskdispl=get(handles.mask_civ2,'String'); |
|---|
| 2072 | if exist(maskdispl,'file') |
|---|
| 2073 | par_civ2.maskname=maskdispl; |
|---|
| 2074 | par_civ2.maskflag='y'; |
|---|
| 2075 | else |
|---|
| 2076 | maskbase=[filecell.filebase '_' maskdispl]; % |
|---|
| 2077 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
|---|
| 2078 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
|---|
| 2079 | par_civ2.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
|---|
| 2080 | if exist(par_civ2.maskname,'file') |
|---|
| 2081 | par_civ2.maskflag='y'; |
|---|
| 2082 | else |
|---|
| 2083 | par_civ2.maskname='noFile use default'; |
|---|
| 2084 | par_civ2.maskflag='n'; |
|---|
| 2085 | end |
|---|
| 2086 | end |
|---|
| 2087 | end |
|---|
| 2088 | %TESTgrid |
|---|
| 2089 | %test_grid=get(handles.browse_gridciv2,'Value'); |
|---|
| 2090 | gridname=get(handles.grid_civ2,'String'); |
|---|
| 2091 | %gridflag='y'; |
|---|
| 2092 | if numel(gridname)>=4 && isequal(gridname(end-3:end),'grid') |
|---|
| 2093 | nbslice_grid=str2double(gridname(1:end-4)); % |
|---|
| 2094 | if ~isnan(nbslice_grid) |
|---|
| 2095 | par_civ2.gridflag='y'; |
|---|
| 2096 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
|---|
| 2097 | par_civ2.gridname=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
|---|
| 2098 | if exist(par_civ2.gridname,'file') |
|---|
| 2099 | par_civ2.gridflag='y'; |
|---|
| 2100 | else |
|---|
| 2101 | par_civ2.gridname='noFile use default'; |
|---|
| 2102 | par_civ2.gridflag='n'; |
|---|
| 2103 | end |
|---|
| 2104 | elseif exist(gridname,'file') |
|---|
| 2105 | par_civ2.gridflag='y'; |
|---|
| 2106 | else |
|---|
| 2107 | par_civ2.gridname='noFile use default'; |
|---|
| 2108 | par_civ2.gridflag='n'; |
|---|
| 2109 | end |
|---|
| 2110 | end |
|---|
| 2111 | %endTESTgrid |
|---|
| 2112 | i_cmd=i_cmd+1; |
|---|
| 2113 | flname=fullfile(Rootbat,Filebat); |
|---|
| 2114 | cmd_CIV2=CIV2_CMD(flname,[],par_civ2,sparam);%creates the cmx file [fullfile(Rootbat,Filebat) '.civ2.cmx] |
|---|
| 2115 | if isequal(civAll,0) |
|---|
| 2116 | if(isunix) |
|---|
| 2117 | cmd=[cmd 'cp -f ' flname '.civ2.cmx ' flname '.cmx\n' cmd_CIV2 '\n']; |
|---|
| 2118 | else |
|---|
| 2119 | flname=regexprep(flname,'\\','\\\\'); |
|---|
| 2120 | cmd=[cmd 'copy /Y "' flname '.civ2.cmx" "' flname '.cmx"\n' cmd_CIV2 '\n']; |
|---|
| 2121 | end |
|---|
| 2122 | else |
|---|
| 2123 | civAllCmd=[civAllCmd ' civ2 ']; |
|---|
| 2124 | str=CIV2_CMD_Unified(filename_cmx([1:end-4]),namelog,par_civ2); |
|---|
| 2125 | fieldnames=fields(str); |
|---|
| 2126 | [civAllxml,uid_civ2]=add(civAllxml,1,'element','civ2'); |
|---|
| 2127 | for ilist=1:length(fieldnames) |
|---|
| 2128 | val=eval(['str.' fieldnames{ilist}]); |
|---|
| 2129 | if ischar(val) |
|---|
| 2130 | [civAllxml,uid_t]=add(civAllxml,uid_civ2,'element',fieldnames{ilist}); |
|---|
| 2131 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
|---|
| 2132 | end |
|---|
| 2133 | end |
|---|
| 2134 | end |
|---|
| 2135 | end |
|---|
| 2136 | |
|---|
| 2137 | % FIX2 |
|---|
| 2138 | if box_test(5)==1 |
|---|
| 2139 | test_mask=get(handles.get_mask_fix2,'Value'); |
|---|
| 2140 | if test_mask==0 |
|---|
| 2141 | maskname=''; %no mask used |
|---|
| 2142 | else |
|---|
| 2143 | maskdispl=get(handles.mask_fix2,'String'); |
|---|
| 2144 | maskbase=[filecell.filebase '_' maskdispl]; % |
|---|
| 2145 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
|---|
| 2146 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
|---|
| 2147 | maskname =name_generator(maskbase,num1_mask,1,'.png','_i'); |
|---|
| 2148 | end |
|---|
| 2149 | if isequal(civAll,0) |
|---|
| 2150 | if isunix |
|---|
| 2151 | cmd_FIX=[sparam.FixBin ' -f ' filecell.nc.civ2{ifile,j} ' -fi1 ' num2str(flagindex2(1)) ... |
|---|
| 2152 | ' -fi2 ' num2str(flagindex2(2)) ' -fi3 ' num2str(flagindex2(3)) ... |
|---|
| 2153 | ' -threshC ' num2str(thresh_vec2C) ' -threshV ' num2str(thresh_vel2) ' -maskName ' maskname]; |
|---|
| 2154 | else |
|---|
| 2155 | cmd_FIX=['"' sparam.FixBin '" -f "' filecell.nc.civ2{ifile,j} '" -fi1 ' num2str(flagindex2(1)) ... |
|---|
| 2156 | ' -fi2 ' num2str(flagindex2(2)) ' -fi3 ' num2str(flagindex2(3)) ... |
|---|
| 2157 | ' -threshC ' num2str(thresh_vec2C) ' -threshV ' num2str(thresh_vel2) ' -maskName "' maskname '"']; |
|---|
| 2158 | cmd_FIX=regexprep(cmd_FIX,'\\','\\\\'); |
|---|
| 2159 | end |
|---|
| 2160 | cmd=[cmd cmd_FIX '\n']; |
|---|
| 2161 | else |
|---|
| 2162 | fix2.inputFileName=filecell.nc.civ2{ifile,j} ; |
|---|
| 2163 | fix2.fi1=num2str(flagindex2(1)); |
|---|
| 2164 | fix2.fi2=num2str(flagindex2(2)); |
|---|
| 2165 | fix2.fi3=num2str(flagindex2(3)); |
|---|
| 2166 | fix2.threshC=num2str(thresh_vec2C); |
|---|
| 2167 | fix2.threshV=num2str(thresh_vel2); |
|---|
| 2168 | fieldnames=fields(fix2); |
|---|
| 2169 | [civAllxml,uid_fix2]=add(civAllxml,1,'element','fix2'); |
|---|
| 2170 | for ilist=1:length(fieldnames) |
|---|
| 2171 | val=eval(['fix2.' fieldnames{ilist}]); |
|---|
| 2172 | if ischar(val) |
|---|
| 2173 | [civAllxml,uid_t]=add(civAllxml,uid_fix2,'element',fieldnames{ilist}); |
|---|
| 2174 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
|---|
| 2175 | end |
|---|
| 2176 | end |
|---|
| 2177 | civAllCmd=[civAllCmd ' fix2 ']; |
|---|
| 2178 | end |
|---|
| 2179 | end |
|---|
| 2180 | |
|---|
| 2181 | %PATCH2 |
|---|
| 2182 | if box_test(6)==1 |
|---|
| 2183 | if isequal(civAll,0) |
|---|
| 2184 | cmd_PATCH=PATCH_CMD(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,test_interp,sparam.PatchBin); |
|---|
| 2185 | cmd=[cmd cmd_PATCH '\n']; |
|---|
| 2186 | else |
|---|
| 2187 | patch2.inputFileName=filecell.nc.civ1{ifile,j} ; |
|---|
| 2188 | patch2.nopt=subdomain_patch1; |
|---|
| 2189 | patch2.maxdiff=thresh_patch1; |
|---|
| 2190 | patch2.ro=rho_patch1; |
|---|
| 2191 | test_grid=get(handles.get_gridpatch2,'Value'); |
|---|
| 2192 | if test_grid |
|---|
| 2193 | patch2.gridflag='y'; |
|---|
| 2194 | gridname=get(handles.grid_patch2,'String'); |
|---|
| 2195 | if isequal(gridname(end-3:end),'grid') |
|---|
| 2196 | nbslice_grid=str2double(gridname(1:end-4)); % |
|---|
| 2197 | if ~isnan(nbslice_grid) |
|---|
| 2198 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
|---|
| 2199 | patch2.gridPatch=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
|---|
| 2200 | if ~exist(patch2.gridPatch,'file') |
|---|
| 2201 | msgbox_uvmat('ERROR','grid file absent for patch2') |
|---|
| 2202 | end |
|---|
| 2203 | elseif exist(gridname,'file') |
|---|
| 2204 | patch2.gridPatch=gridname; |
|---|
| 2205 | else |
|---|
| 2206 | msgbox_uvmat('ERROR','grid file absent for patch2') |
|---|
| 2207 | end |
|---|
| 2208 | end |
|---|
| 2209 | else |
|---|
| 2210 | patch2.gridPatch='none'; |
|---|
| 2211 | patch2.gridflag='n'; |
|---|
| 2212 | patch2.m=nx_patch2; |
|---|
| 2213 | patch2.n=ny_patch2; |
|---|
| 2214 | end |
|---|
| 2215 | patch2.convectFlow='n'; |
|---|
| 2216 | fieldnames=fields(patch2); |
|---|
| 2217 | [civAllxml,uid_patch2]=add(civAllxml,1,'element','patch2'); |
|---|
| 2218 | for ilist=1:length(fieldnames) |
|---|
| 2219 | val=eval(['patch2.' fieldnames{ilist}]); |
|---|
| 2220 | if ischar(val) |
|---|
| 2221 | [civAllxml,uid_t]=add(civAllxml,uid_patch2,'element',fieldnames{ilist}); |
|---|
| 2222 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
|---|
| 2223 | end |
|---|
| 2224 | end |
|---|
| 2225 | civAllCmd=[civAllCmd ' patch2 ']; |
|---|
| 2226 | end |
|---|
| 2227 | end |
|---|
| 2228 | if isequal(civAll,1) |
|---|
| 2229 | save(civAllxml,[filename_cmx([1:end-4]) '.xml']); |
|---|
| 2230 | %cmd=char({cmd;[CivBin ' -f ' [filename_cmx([1:end-4]) '.xml'] ' ' civAllCmd]}); |
|---|
| 2231 | cmd=[cmd CivBin ' -f ' filename_cmx(1:end-4) '.xml ' civAllCmd '\n']; |
|---|
| 2232 | end |
|---|
| 2233 | % create the .bat file: |
|---|
| 2234 | [fid,message]=fopen(filename_bat,'w'); |
|---|
| 2235 | if isequal(fid,-1) |
|---|
| 2236 | msgbox_uvmat('ERROR', ['creation of .bat file: ' message]) |
|---|
| 2237 | return |
|---|
| 2238 | end |
|---|
| 2239 | fprintf(fid,cmd); |
|---|
| 2240 | fclose(fid); |
|---|
| 2241 | %dlmwrite(filename_bat,cmd,'');%write commands in filename_bat |
|---|
| 2242 | if batch |
|---|
| 2243 | switch batch_mode |
|---|
| 2244 | case 'sge' |
|---|
| 2245 | pvalue=num2str((1-ind_answer)*500); |
|---|
| 2246 | %namelog=[filename_bat '.patch.log']; |
|---|
| 2247 | display(['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]); |
|---|
| 2248 | eval( ['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]); |
|---|
| 2249 | end |
|---|
| 2250 | else |
|---|
| 2251 | %% to lauch the jobs locally : |
|---|
| 2252 | if(isunix) |
|---|
| 2253 | cmd_str=['. ' filename_bat]; |
|---|
| 2254 | % cmd_str=['!at -qb now -f ' filename_bat ' &']; %ou at -qb now -f bad idea... |
|---|
| 2255 | else %case of Windows |
|---|
| 2256 | cmd_str=['@call "' regexprep(filename_bat,'\\','\\\\') '"']; |
|---|
| 2257 | end |
|---|
| 2258 | super_cmd=[super_cmd cmd_str '\n']; |
|---|
| 2259 | disp(cmd_str); |
|---|
| 2260 | end |
|---|
| 2261 | end |
|---|
| 2262 | end |
|---|
| 2263 | |
|---|
| 2264 | if ~batch |
|---|
| 2265 | [Rootbat,Filebat,extbat]=fileparts(filename_bat); |
|---|
| 2266 | filename_superbat=fullfile(Rootbat,['job_list.bat']); |
|---|
| 2267 | fid=fopen(filename_superbat,'w'); |
|---|
| 2268 | fprintf(fid,super_cmd'); |
|---|
| 2269 | fclose(fid); |
|---|
| 2270 | if(isunix) |
|---|
| 2271 | eval(['!. ' filename_superbat ' &']); |
|---|
| 2272 | else |
|---|
| 2273 | eval(['!' filename_superbat ' &']); |
|---|
| 2274 | end |
|---|
| 2275 | end |
|---|
| 2276 | |
|---|
| 2277 | %% save interface state |
|---|
| 2278 | if isfield(filecell,'nc') |
|---|
| 2279 | if isfield(filecell.nc,'civ2') |
|---|
| 2280 | fileresu=filecell.nc.civ2{1,1}; |
|---|
| 2281 | else |
|---|
| 2282 | fileresu=filecell.nc.civ1{1,1}; |
|---|
| 2283 | end |
|---|
| 2284 | end |
|---|
| 2285 | [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileresu); |
|---|
| 2286 | namedoc=fullfile(RootPath,subdir,RootFile); |
|---|
| 2287 | detect=1; |
|---|
| 2288 | while detect==1 |
|---|
| 2289 | namefigfull=[namedoc '.fig']; |
|---|
| 2290 | hh=dir(namefigfull); |
|---|
| 2291 | if ~isempty(hh) |
|---|
| 2292 | detect=1; |
|---|
| 2293 | namedoc=[namedoc '.0']; |
|---|
| 2294 | else |
|---|
| 2295 | detect=0; |
|---|
| 2296 | end |
|---|
| 2297 | end |
|---|
| 2298 | saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) |
|---|
| 2299 | |
|---|
| 2300 | |
|---|
| 2301 | |
|---|
| 2302 | |
|---|
| 2303 | 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]=... |
|---|
| 2304 | set_civ_filenames(handles,box_test) |
|---|
| 2305 | %------------------------------------------------------------------------ |
|---|
| 2306 | filecell=[];%default |
|---|
| 2307 | |
|---|
| 2308 | %% get the root names nomenclature and numbers |
|---|
| 2309 | filebase=get(handles.RootName,'String'); |
|---|
| 2310 | |
|---|
| 2311 | if isempty(filebase)||isequal(filebase,'') |
|---|
| 2312 | msgbox_uvmat('ERROR','no input files') |
|---|
| 2313 | return |
|---|
| 2314 | end |
|---|
| 2315 | |
|---|
| 2316 | %filebase=regexprep(filebase,'\.fsnet','fsnet');% temporary fix for cluster Coriolis |
|---|
| 2317 | filecell.filebase=filebase; |
|---|
| 2318 | |
|---|
| 2319 | browse=get(handles.browse_root,'UserData'); |
|---|
| 2320 | compare_list=get(handles.compare,'String'); |
|---|
| 2321 | val=get(handles.compare,'Value'); |
|---|
| 2322 | compare=compare_list{val}; |
|---|
| 2323 | if strcmp(compare,'displacement') |
|---|
| 2324 | mode='displacement'; |
|---|
| 2325 | else |
|---|
| 2326 | mode_list=get(handles.mode,'String'); |
|---|
| 2327 | mode_value=get(handles.mode,'Value'); |
|---|
| 2328 | mode=mode_list{mode_value}; |
|---|
| 2329 | end |
|---|
| 2330 | %time=get(handles.RootName,'UserData'); %get the set of times |
|---|
| 2331 | ext_ima=get(handles.ImaExt,'String'); |
|---|
| 2332 | nom_type_nc=browse.nom_type_nc; |
|---|
| 2333 | if isfield(browse,'nom_type_ima') |
|---|
| 2334 | nom_type_ima2=browse.nom_type_ima; |
|---|
| 2335 | end |
|---|
| 2336 | if isempty(nom_type_ima2),nom_type_ima2='1';end; %default |
|---|
| 2337 | if isempty(nom_type_nc),nom_type_nc='_i1-i2';end; %default |
|---|
| 2338 | [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
|---|
| 2339 | find_pair_indices(handles,mode); |
|---|
| 2340 | %determine the new filebase for 'displacement' mode (comparison of two series) |
|---|
| 2341 | filebase_B=filebase;% root name of the second field series for stereo |
|---|
| 2342 | if strcmp(compare,'displacement') || strcmp(compare,'stereo PIV') |
|---|
| 2343 | % test_disp=1; |
|---|
| 2344 | nom_type_ima1=browse.nom_type_ima_1; %nomenclature type of the second file series |
|---|
| 2345 | [Path2,Name2]=fileparts(filebase_B); |
|---|
| 2346 | Path1=Path2; |
|---|
| 2347 | Name1=get(handles.RootName_1,'String');% root name of the first field series for stereo |
|---|
| 2348 | filebase_A=fullfile(Path1,Name1); |
|---|
| 2349 | if length(Name1)>6 |
|---|
| 2350 | Name1=Name1(end-5:end); |
|---|
| 2351 | end |
|---|
| 2352 | if length(Name2)>6 |
|---|
| 2353 | Name2=Name2(end-5:end); |
|---|
| 2354 | end |
|---|
| 2355 | filebase_AB=fullfile(Path2,[Name2 '-' Name1]); |
|---|
| 2356 | else |
|---|
| 2357 | % test_disp=0; |
|---|
| 2358 | filebase_A=filebase; |
|---|
| 2359 | nom_type_ima1=nom_type_ima2; |
|---|
| 2360 | filebase_AB=filebase; |
|---|
| 2361 | end |
|---|
| 2362 | if strcmp(compare,'displacement') |
|---|
| 2363 | filebase_ima1=filebase_A; |
|---|
| 2364 | filebase_ima2=filebase_B; |
|---|
| 2365 | filebase_nc=filebase_AB; %root name for the result of civ2 |
|---|
| 2366 | else |
|---|
| 2367 | filebase_ima1=filebase_B; |
|---|
| 2368 | filebase_ima2=filebase_B; |
|---|
| 2369 | filebase_nc=filebase_B; |
|---|
| 2370 | end |
|---|
| 2371 | |
|---|
| 2372 | %determine reference files for fix: |
|---|
| 2373 | file_ref_fix1={};%default |
|---|
| 2374 | file_ref_fix2={}; |
|---|
| 2375 | nbfield=length(num1_civ1); |
|---|
| 2376 | nbslice=length(num_a_civ1); |
|---|
| 2377 | if box_test(2)==1% fix1 performed |
|---|
| 2378 | ref=get(handles.ref_fix1,'UserData');%read data on the ref file stored by get_ref_fix1_Callback |
|---|
| 2379 | if ~isempty(ref) |
|---|
| 2380 | first_i=str2double(get(handles.first_i,'String')); |
|---|
| 2381 | last_i=str2double(get(handles.last_i,'String')); |
|---|
| 2382 | incr_i=str2double(get(handles.incr_i,'String')); |
|---|
| 2383 | first_j=str2double(get(handles.first_j,'String')); |
|---|
| 2384 | last_j=str2double(get(handles.last_j,'String')); |
|---|
| 2385 | incr_j=str2double(get(handles.incr_j,'String')); |
|---|
| 2386 | num_i_ref=first_i:incr_i:last_i; |
|---|
| 2387 | num_j_ref=first_j:incr_j:last_j; |
|---|
| 2388 | if isequal(mode,'displacement') |
|---|
| 2389 | num_i1=num_i_ref; |
|---|
| 2390 | num_i2=num_i_ref; |
|---|
| 2391 | num_j1=num_j_ref; |
|---|
| 2392 | num_j2=num_j_ref; |
|---|
| 2393 | elseif isequal(mode,'pair j1-j2')% isequal(mode,'st_pair j1-j2') |
|---|
| 2394 | num_i1=num_i_ref; |
|---|
| 2395 | num_i2=num_i1; |
|---|
| 2396 | num_j1=ref.num_a*ones(size(num_i_ref)); |
|---|
| 2397 | num_j2=ref.num_b*ones(size(num_i_ref)); |
|---|
| 2398 | elseif isequal(mode,'series(Di)') % isequal(mode,'st_series(Di)') |
|---|
| 2399 | delta1=floor((ref.num2-ref.num1)/2); |
|---|
| 2400 | delta2=ceil((ref.num2-ref.num1)/2); |
|---|
| 2401 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
|---|
| 2402 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
|---|
| 2403 | if isempty(ref.num_a) |
|---|
| 2404 | ref.num_a=1; |
|---|
| 2405 | end |
|---|
| 2406 | num_j1=ref.num_a*ones(size(num_i1)); |
|---|
| 2407 | num_j2=num_j1; |
|---|
| 2408 | elseif isequal(mode,'series(Dj)')%| isequal(mode,'st_series(Dj)') |
|---|
| 2409 | delta1=floor((ref.num_b-ref.num_a)/2); |
|---|
| 2410 | delta2=ceil((ref.num_b-ref.num_a)/2); |
|---|
| 2411 | num_i1=ref.num1*ones(size(num_i_ref)); |
|---|
| 2412 | num_i2=num_i1; |
|---|
| 2413 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
|---|
| 2414 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
|---|
| 2415 | end |
|---|
| 2416 | for ifile=1:nbfield |
|---|
| 2417 | for j=1:nbslice |
|---|
| 2418 | 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);% |
|---|
| 2419 | file_ref_fix1(ifile,j)={file_ref}; |
|---|
| 2420 | if ~exist(file_ref,'file') |
|---|
| 2421 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix1']) |
|---|
| 2422 | filecell=[]; |
|---|
| 2423 | return |
|---|
| 2424 | end |
|---|
| 2425 | end |
|---|
| 2426 | end |
|---|
| 2427 | end |
|---|
| 2428 | end |
|---|
| 2429 | |
|---|
| 2430 | %determine reference files for fix2: |
|---|
| 2431 | if box_test(5)==1% fix2 performed |
|---|
| 2432 | ref=get(handles.ref_fix2,'UserData'); |
|---|
| 2433 | if ~isempty(ref) |
|---|
| 2434 | first_i=str2double(get(handles.first_i,'String')); |
|---|
| 2435 | last_i=str2double(get(handles.last_i,'String')); |
|---|
| 2436 | incr_i=str2double(get(handles.incr_i,'String')); |
|---|
| 2437 | first_j=str2double(get(handles.first_j,'String')); |
|---|
| 2438 | last_j=str2double(get(handles.last_j,'String')); |
|---|
| 2439 | incr_j=str2double(get(handles.incr_j,'String')); |
|---|
| 2440 | num_i_ref=[first_i:incr_i:last_i]; |
|---|
| 2441 | num_j_ref=[first_j:incr_j:last_j]; |
|---|
| 2442 | if isequal(mode,'displacement') |
|---|
| 2443 | num_i1=num_i_ref; |
|---|
| 2444 | num_i2=num_i_ref; |
|---|
| 2445 | num_j1=num_j_ref; |
|---|
| 2446 | num_j2=num_j_ref; |
|---|
| 2447 | elseif isequal(mode,'pair j1-j2') |
|---|
| 2448 | num_i1=num_i_ref; |
|---|
| 2449 | num_i2=num_i1; |
|---|
| 2450 | num_j1=ref.num_a; |
|---|
| 2451 | num_j2=ref.num_b; |
|---|
| 2452 | elseif isequal(mode,'series(Di)') |
|---|
| 2453 | delta1=floor((ref.num2-ref.num1)/2); |
|---|
| 2454 | delta2=ceil((ref.num2-ref.num1)/2); |
|---|
| 2455 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
|---|
| 2456 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
|---|
| 2457 | num_j1=ref.num_a*ones(size(num_i1)); |
|---|
| 2458 | num_j2=num_j1; |
|---|
| 2459 | elseif isequal(mode,'series(Dj)') |
|---|
| 2460 | delta1=floor((ref.num_b-ref.num_a)/2); |
|---|
| 2461 | delta2=ceil((ref.num_b-ref.num_a)/2); |
|---|
| 2462 | num_i1=ref.num1*ones(size(num_i_ref)); |
|---|
| 2463 | num_i2=num_i1; |
|---|
| 2464 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
|---|
| 2465 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
|---|
| 2466 | end |
|---|
| 2467 | for ifile=1:nbfield |
|---|
| 2468 | for j=1:nbslice |
|---|
| 2469 | 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);% |
|---|
| 2470 | file_ref_fix2(ifile,j)={file_ref}; |
|---|
| 2471 | if ~exist(file_ref,'file') |
|---|
| 2472 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix2']) |
|---|
| 2473 | filecell={}; |
|---|
| 2474 | return |
|---|
| 2475 | end |
|---|
| 2476 | end |
|---|
| 2477 | end |
|---|
| 2478 | end |
|---|
| 2479 | end |
|---|
| 2480 | |
|---|
| 2481 | %check dir |
|---|
| 2482 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf output data |
|---|
| 2483 | subdir_civ2=get(handles.subdir_civ2,'String'); |
|---|
| 2484 | if isequal(subdir_civ1,''),subdir_civ1='CIV'; end% put default subdir |
|---|
| 2485 | if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end% put default subdir |
|---|
| 2486 | currentdir=pwd;%store the current working directory |
|---|
| 2487 | [Path_ima,Name]=fileparts(filebase);%Path of the image files (.civ) |
|---|
| 2488 | if ~exist(Path_ima,'dir') |
|---|
| 2489 | msgbox_uvmat('ERROR',['path to images ' Path_ima ' not found']) |
|---|
| 2490 | filecell={}; |
|---|
| 2491 | return |
|---|
| 2492 | end |
|---|
| 2493 | [xx,message]=fileattrib(Path_ima); |
|---|
| 2494 | if ~isempty(message) && ~isequal(message.UserWrite,1) |
|---|
| 2495 | msgbox_uvmat('ERROR',['No writting access to ' Path_ima]) |
|---|
| 2496 | filecell={}; |
|---|
| 2497 | cd(currentdir); |
|---|
| 2498 | return |
|---|
| 2499 | end |
|---|
| 2500 | |
|---|
| 2501 | %check the existence of the netcdf and image files involved |
|---|
| 2502 | % %%%%%%%%%%%% case CIV1 activated %%%%%%%%%%%%% |
|---|
| 2503 | if box_test(1)==1; |
|---|
| 2504 | detect=1; |
|---|
| 2505 | vers=0; |
|---|
| 2506 | subdir_civ1_new=subdir_civ1; |
|---|
| 2507 | while detect==1 %create a new subdir if the netcdf files already exist |
|---|
| 2508 | for ifile=1:nbfield |
|---|
| 2509 | for j=1:nbslice |
|---|
| 2510 | 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); |
|---|
| 2511 | detect=exist(filename,'file')==2; |
|---|
| 2512 | if detect% if a netcdf file already exists |
|---|
| 2513 | indstr=regexp(subdir_civ1_new,'\D'); |
|---|
| 2514 | if indstr(end)<length(subdir_civ1_new) %subdir_civ1 ends by a number |
|---|
| 2515 | vers=str2double(subdir_civ1_new(indstr(end)+1:end))+1; |
|---|
| 2516 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) num2str(vers)]; |
|---|
| 2517 | else |
|---|
| 2518 | vers=vers+1; |
|---|
| 2519 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) '_' num2str(vers)]; |
|---|
| 2520 | end |
|---|
| 2521 | subdir_civ2=subdir_civ1_new; |
|---|
| 2522 | break |
|---|
| 2523 | end |
|---|
| 2524 | filecell.nc.civ1(ifile,j)={filename}; |
|---|
| 2525 | end |
|---|
| 2526 | if detect% if a netcdf file already exists |
|---|
| 2527 | break |
|---|
| 2528 | end |
|---|
| 2529 | end |
|---|
| 2530 | |
|---|
| 2531 | %create the new subdir_civ1 |
|---|
| 2532 | if ~exist(fullfile(Path_ima,subdir_civ1_new),'dir') |
|---|
| 2533 | cd(Path_ima); |
|---|
| 2534 | [xx,msg1]=mkdir(subdir_civ1_new); |
|---|
| 2535 | |
|---|
| 2536 | if ~strcmp(msg1,'') |
|---|
| 2537 | msgbox_uvmat('ERROR',['cannot create ' subdir_civ1_new ': ' msg1])%error message for directory creation |
|---|
| 2538 | filecell={}; |
|---|
| 2539 | return |
|---|
| 2540 | elseif isunix |
|---|
| 2541 | [xx,msg2] = fileattrib(subdir_civ1_new,'+w','g'); %yield writing access (+w) to user group (g) |
|---|
| 2542 | if ~strcmp(msg2,'') |
|---|
| 2543 | msgbox_uvmat('ERROR',['pb of permission for ' subdir_civ1_new ': ' msg2])%error message for directory creation |
|---|
| 2544 | filecell={}; |
|---|
| 2545 | return |
|---|
| 2546 | end |
|---|
| 2547 | end |
|---|
| 2548 | cd(currentdir); |
|---|
| 2549 | end |
|---|
| 2550 | if strcmp(compare,'stereo PIV')&&(strcmp(mode,'pair j1-j2')||strcmp(mode,'series(Dj)')||strcmp(mode,'series(Di)'))%check second nc series |
|---|
| 2551 | for ifile=1:nbfield |
|---|
| 2552 | for j=1:nbslice |
|---|
| 2553 | 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);% |
|---|
| 2554 | detect=exist(filename,'file')==2; |
|---|
| 2555 | if detect% if a netcdf file already exists |
|---|
| 2556 | indstr=regexp(subdir_civ1_new,'\D'); |
|---|
| 2557 | if indstr(end)<length(subdir_civ1_new) %subdir_civ1 ends by a number |
|---|
| 2558 | vers=str2double(subdir_civ1_new(indstr(end)+1:end))+1; |
|---|
| 2559 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) num2str(vers)]; |
|---|
| 2560 | else |
|---|
| 2561 | vers=vers+1; |
|---|
| 2562 | subdir_civ1_new=[subdir_civ1_new '_' num2str(vers)]; |
|---|
| 2563 | end |
|---|
| 2564 | subdir_civ2=subdir_civ1; |
|---|
| 2565 | break |
|---|
| 2566 | end |
|---|
| 2567 | filecell.ncA.civ1(ifile,j)={filename}; |
|---|
| 2568 | end |
|---|
| 2569 | if detect% if a netcdf file already exists |
|---|
| 2570 | break |
|---|
| 2571 | end |
|---|
| 2572 | end |
|---|
| 2573 | %create the new subdir_civ1 |
|---|
| 2574 | if exist(fullfile(Path_ima,subdir_civ1_new),'dir') |
|---|
| 2575 | cd(Path_ima); |
|---|
| 2576 | [xx,msg1]=mkdir(subdir_civ1_new); |
|---|
| 2577 | cd(currentdir); |
|---|
| 2578 | if ~strcmpl(msg1,'') |
|---|
| 2579 | msgbox_uvmat('ERROR',['cannot create ' subdir_civ1_new ': ' msg1]) |
|---|
| 2580 | cd(currentdir) |
|---|
| 2581 | filecell={}; |
|---|
| 2582 | return |
|---|
| 2583 | else |
|---|
| 2584 | [xx,msg2] = fileattrib(subdir_civ1_new,'+w','g'); %yield writing access (+w) to user group (g) |
|---|
| 2585 | if ~strcmp(msg2,'') |
|---|
| 2586 | msgbox_uvmat('ERROR',['pb of permission for ' subdir_civ1_new ': ' msg2])%error message for directory creation |
|---|
| 2587 | cd(currentdir) |
|---|
| 2588 | filecell={}; |
|---|
| 2589 | return |
|---|
| 2590 | end |
|---|
| 2591 | end |
|---|
| 2592 | end |
|---|
| 2593 | end |
|---|
| 2594 | end |
|---|
| 2595 | subdir_civ1=subdir_civ1_new; |
|---|
| 2596 | % get image names |
|---|
| 2597 | for ifile=1:nbfield |
|---|
| 2598 | for j=1:nbslice |
|---|
| 2599 | filename=name_generator(filebase_ima1, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
|---|
| 2600 | idetect(j)=exist(filename,'file')==2; |
|---|
| 2601 | filecell.ima1.civ1(ifile,j)={filename}; %first image |
|---|
| 2602 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
|---|
| 2603 | idetect_1(j)=exist(filename,'file')==2; |
|---|
| 2604 | filecell.ima2.civ1(ifile,j)={filename};%second image |
|---|
| 2605 | end |
|---|
| 2606 | [idetectmin,indexj]=min(idetect); |
|---|
| 2607 | if idetectmin==0, |
|---|
| 2608 | msgbox_uvmat('ERROR',[filecell.ima1.civ1{ifile,indexj} ' not found']) |
|---|
| 2609 | filecell={}; |
|---|
| 2610 | cd(currentdir) |
|---|
| 2611 | return |
|---|
| 2612 | end |
|---|
| 2613 | [idetectmin,indexj]=min(idetect_1); |
|---|
| 2614 | if idetectmin==0, |
|---|
| 2615 | msgbox_uvmat('ERROR',[filecell.ima2.civ1{ifile,indexj} ' not found']) |
|---|
| 2616 | filecell={}; |
|---|
| 2617 | cd(currentdir) |
|---|
| 2618 | return |
|---|
| 2619 | end |
|---|
| 2620 | end |
|---|
| 2621 | if strcmp(compare,'stereo PIV') && (strcmp(mode,'pair j1-j2') || strcmp(mode,'series(Dj)') || strcmp(mode,'series(Di)')) |
|---|
| 2622 | for ifile=1:nbfield |
|---|
| 2623 | for j=1:nbslice |
|---|
| 2624 | filename=name_generator(filebase_A, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
|---|
| 2625 | idetect(j)=exist(filename,'file')==2; |
|---|
| 2626 | filecell.imaA1.civ1(ifile,j)={filename} ;%first image |
|---|
| 2627 | filename=name_generator(filebase_A, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
|---|
| 2628 | idetect_1(j)=exist(filename,'file')==2; |
|---|
| 2629 | filecell.imaA2.civ1(ifile,j)={filename};%second image |
|---|
| 2630 | end |
|---|
| 2631 | [idetectmin,indexj]=min(idetect); |
|---|
| 2632 | if idetectmin==0, |
|---|
| 2633 | msgbox_uvmat('ERROR',[filecell.imaA1.civ1{ifile,indexj} ' not found']) |
|---|
| 2634 | filecell={}; |
|---|
| 2635 | cd(currentdir) |
|---|
| 2636 | return |
|---|
| 2637 | end |
|---|
| 2638 | [idetectmin,indexj]=min(idetect_1); |
|---|
| 2639 | if idetectmin==0, |
|---|
| 2640 | msgbox_uvmat('ERROR',[filecell.imaA2.civ1{ifile,indexj} ' not found']) |
|---|
| 2641 | filecell={}; |
|---|
| 2642 | cd(currentdir) |
|---|
| 2643 | return |
|---|
| 2644 | end |
|---|
| 2645 | end |
|---|
| 2646 | end |
|---|
| 2647 | |
|---|
| 2648 | %%%%%%%%%%%%% fix1 or patch1 activated but no civ1 %%%%%%%%%%%%% |
|---|
| 2649 | elseif (box_test(2)==1 || box_test(3)==1); |
|---|
| 2650 | for ifile=1:nbfield |
|---|
| 2651 | for j=1:nbslice |
|---|
| 2652 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
|---|
| 2653 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
|---|
| 2654 | detect=exist(filename,'file')==2; |
|---|
| 2655 | if detect==0 |
|---|
| 2656 | msgbox_uvmat('ERROR',[filename ' not found']) |
|---|
| 2657 | filecell={}; |
|---|
| 2658 | cd(currentdir) |
|---|
| 2659 | return |
|---|
| 2660 | end |
|---|
| 2661 | filecell.nc.civ1(ifile,j)={filename}; |
|---|
| 2662 | end |
|---|
| 2663 | end |
|---|
| 2664 | if strcmp(compare,'stereo PIV') |
|---|
| 2665 | for ifile=1:nbfield |
|---|
| 2666 | for j=1:nbslice |
|---|
| 2667 | 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);% |
|---|
| 2668 | filecell.ncA.civ1(ifile,j)={filename}; |
|---|
| 2669 | if ~exist(filename,'file') |
|---|
| 2670 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
|---|
| 2671 | set(handles.RUN, 'Enable','On') |
|---|
| 2672 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
|---|
| 2673 | filecell={}; |
|---|
| 2674 | cd(currentdir) |
|---|
| 2675 | return |
|---|
| 2676 | end |
|---|
| 2677 | end |
|---|
| 2678 | end |
|---|
| 2679 | end |
|---|
| 2680 | end |
|---|
| 2681 | |
|---|
| 2682 | %%%%%%%%%%%%% if civ2 performed with pairs different than civ1 %%%%%%%%%%%%% |
|---|
| 2683 | testdiff=0; |
|---|
| 2684 | if (box_test(4)==1)&&... |
|---|
| 2685 | ((get(handles.list_pair_civ1,'Value')~=get(handles.list_pair_civ2,'Value'))||~strcmp(subdir_civ2,subdir_civ1)) |
|---|
| 2686 | testdiff=1; |
|---|
| 2687 | detect=1; |
|---|
| 2688 | vers=0; |
|---|
| 2689 | subdir_civ2_new=subdir_civ2; |
|---|
| 2690 | while detect==1 %create a new subdir if the netcdf files already exist |
|---|
| 2691 | for ifile=1:nbfield |
|---|
| 2692 | for j=1:nbslice |
|---|
| 2693 | 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);% |
|---|
| 2694 | detect=exist(filename,'file')==2; |
|---|
| 2695 | if detect% if a netcdf file already exists |
|---|
| 2696 | indstr=regexp(subdir_civ2,'\D'); |
|---|
| 2697 | if indstr(end)<length(subdir_civ2) %subdir_civ1 ends by a number |
|---|
| 2698 | vers=str2double(subdir_civ2(indstr(end)+1:end))+1; |
|---|
| 2699 | subdir_civ2_new=[subdir_civ2(1:indstr(end)) num2str(vers)]; |
|---|
| 2700 | else |
|---|
| 2701 | vers=vers+1; |
|---|
| 2702 | subdir_civ2_new=[subdir_civ1 '_' num2str(vers)]; |
|---|
| 2703 | end |
|---|
| 2704 | break |
|---|
| 2705 | end |
|---|
| 2706 | filecell.nc.civ2(ifile,j)={filename}; |
|---|
| 2707 | end |
|---|
| 2708 | if detect% if a netcdf file already exists |
|---|
| 2709 | break |
|---|
| 2710 | end |
|---|
| 2711 | end |
|---|
| 2712 | %create the new subdir_civ2_new |
|---|
| 2713 | if ~exist(fullfile(Path_ima,subdir_civ2_new),'dir') |
|---|
| 2714 | [xx,m2]=mkdir(fullfile(Path_ima,subdir_civ2_new)); |
|---|
| 2715 | [xx,msg2] = fileattrib(subdir_civ2_new,'+w','g'); %yield writing access (+w) to user group (g) |
|---|
| 2716 | if ~isequal(m2,'') |
|---|
| 2717 | msgbox_uvmat('ERROR',['cannot create ' subdir_civ2_new ': ' m2]) |
|---|
| 2718 | filecell={}; |
|---|
| 2719 | cd(currentdir) |
|---|
| 2720 | return |
|---|
| 2721 | end |
|---|
| 2722 | end |
|---|
| 2723 | if strcmp(compare,'stereo PIV')%check second nc series |
|---|
| 2724 | for ifile=1:nbfield |
|---|
| 2725 | for j=1:nbslice |
|---|
| 2726 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
|---|
| 2727 | nom_type_nc,1,num2_civ2(ifile),num_b_civ1(j),subdir_civ2_new);% |
|---|
| 2728 | detect=exist(filename,'file')==2; |
|---|
| 2729 | if detect% if a netcdf file already exists |
|---|
| 2730 | indstr=regexp(subdir_civ2,'\D'); |
|---|
| 2731 | if indstr(end)<length(subdir_civ2) %subdir_civ1 ends by a number |
|---|
| 2732 | vers=str2double(subdir_civ2(indstr(end)+1:end))+1; |
|---|
| 2733 | subdir_civ2_new=[subdir_civ2(1:indstr(end)) num2str(vers)]; |
|---|
| 2734 | else |
|---|
| 2735 | vers=vers+1; |
|---|
| 2736 | subdir_civ2_new=[subdir_civ1 '_' num2str(vers)]; |
|---|
| 2737 | end |
|---|
| 2738 | break |
|---|
| 2739 | end |
|---|
| 2740 | filecell.ncA.civ2(ifile,j)={filename}; |
|---|
| 2741 | end |
|---|
| 2742 | if detect% if a netcdf file already exists |
|---|
| 2743 | break |
|---|
| 2744 | end |
|---|
| 2745 | end |
|---|
| 2746 | subdir_civ2=subdir_civ2_new; |
|---|
| 2747 | %create the new subdir_civ1 |
|---|
| 2748 | if ~exist(fullfile(Path_ima,subdir_civ2_new),'dir') |
|---|
| 2749 | [xx,m2]=mkdir(subdir_civ2_new); |
|---|
| 2750 | [xx,msg2] = fileattrib(subdir_civ2_new,'+w','g'); %yield writing access (+w) to user group (g) |
|---|
| 2751 | if ~isequal(m2,'') |
|---|
| 2752 | msgbox_uvmat('ERROR', ['cannot create ' subdir_civ2_new ': ' m2])%error message for directory creation |
|---|
| 2753 | cd(currentdir) |
|---|
| 2754 | filecell={}; |
|---|
| 2755 | return |
|---|
| 2756 | end |
|---|
| 2757 | end |
|---|
| 2758 | end |
|---|
| 2759 | end |
|---|
| 2760 | subdir_civ2=subdir_civ2_new; |
|---|
| 2761 | end |
|---|
| 2762 | cd(currentdir);%come back to the current working directory |
|---|
| 2763 | |
|---|
| 2764 | %%%%%%%%%%%%% if civ2 results are obtained or used %%%%%%%%%%%%% |
|---|
| 2765 | if box_test(4)==1 || box_test(5)==1 || box_test(6)==1 %civ2 |
|---|
| 2766 | %check source netcdf file of civ1 estimates |
|---|
| 2767 | if box_test(1)==0; %no civ1 performed |
|---|
| 2768 | for ifile=1:nbfield |
|---|
| 2769 | for j=1:nbslice |
|---|
| 2770 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
|---|
| 2771 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
|---|
| 2772 | filecell.nc.civ1(ifile,j)={filename};% name of the civ1 file |
|---|
| 2773 | if ~exist(filename,'file') |
|---|
| 2774 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
|---|
| 2775 | filecell={}; |
|---|
| 2776 | return |
|---|
| 2777 | end |
|---|
| 2778 | if ~testdiff % civ2 or patch2 are written in the same file as civ1 |
|---|
| 2779 | if box_test(4)==0 ; %check the existence of civ2 if it is not calculated |
|---|
| 2780 | Data=nc2struct(filename,'ListGlobalAttribute','civ2'); |
|---|
| 2781 | if isempty(Data.civ2)||isequal(Data.civ2,0) |
|---|
| 2782 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
|---|
| 2783 | filecell=[]; |
|---|
| 2784 | return |
|---|
| 2785 | end |
|---|
| 2786 | elseif box_test(3)==0; %check the existence of patch if it is not calculated |
|---|
| 2787 | Data=nc2struct(filename,'ListGlobalAttribute','patch'); |
|---|
| 2788 | if isempty(Data.patch)||isequal(Data.patch,0) |
|---|
| 2789 | msgbox_uvmat('ERROR',['no patch data in ' filename]) |
|---|
| 2790 | filecell=[]; |
|---|
| 2791 | return |
|---|
| 2792 | end |
|---|
| 2793 | end |
|---|
| 2794 | end |
|---|
| 2795 | end |
|---|
| 2796 | end |
|---|
| 2797 | if strcmp(compare,'stereo PIV') |
|---|
| 2798 | for ifile=1:nbfield |
|---|
| 2799 | for j=1:nbslice |
|---|
| 2800 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
|---|
| 2801 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
|---|
| 2802 | filecell.ncA.civ2(ifile,j)={filename}; |
|---|
| 2803 | if ~exist(filename,'file') |
|---|
| 2804 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
|---|
| 2805 | set(handles.RUN, 'Enable','On') |
|---|
| 2806 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
|---|
| 2807 | return |
|---|
| 2808 | end |
|---|
| 2809 | end |
|---|
| 2810 | end |
|---|
| 2811 | end |
|---|
| 2812 | end |
|---|
| 2813 | |
|---|
| 2814 | detect=1; |
|---|
| 2815 | % while detect==1%creates a new subdir if the netcdf files already contain civ2 data |
|---|
| 2816 | for ifile=1:nbfield |
|---|
| 2817 | for j=1:nbslice |
|---|
| 2818 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
|---|
| 2819 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2); |
|---|
| 2820 | detect=exist(filename,'file')==2; |
|---|
| 2821 | filecell.nc.civ2(ifile,j)={filename}; |
|---|
| 2822 | end |
|---|
| 2823 | end |
|---|
| 2824 | %get first image names for civ2 |
|---|
| 2825 | if box_test(1)==1 & isequal(num1_civ1,num1_civ2) & isequal(num_a_civ1,num_a_civ2) |
|---|
| 2826 | filecell.ima1.civ2=filecell.ima1.civ1; |
|---|
| 2827 | elseif box_test(4)==1 |
|---|
| 2828 | for ifile=1:nbfield |
|---|
| 2829 | for j=1:nbslice |
|---|
| 2830 | filename=name_generator(filebase_ima1, num1_civ2(ifile),num_a_civ2(j),ext_ima,nom_type_ima1); |
|---|
| 2831 | idetect_2(j)=exist(filename,'file')==2; |
|---|
| 2832 | filecell.ima1.civ2(ifile,j)={filename};%first image |
|---|
| 2833 | end |
|---|
| 2834 | [idetectmin,indexj]=min(idetect_2); |
|---|
| 2835 | if idetectmin==0, |
|---|
| 2836 | msgbox_uvmat('ERROR',['input image ' filecell.ima1.civ2{ifile,indexj} ' not found']) |
|---|
| 2837 | filecell=[]; |
|---|
| 2838 | return |
|---|
| 2839 | end |
|---|
| 2840 | end |
|---|
| 2841 | end |
|---|
| 2842 | |
|---|
| 2843 | %get second image names for civ2 |
|---|
| 2844 | if box_test(1)==1 & isequal(num2_civ1,num2_civ2) & isequal(num_b_civ1,num_b_civ2) |
|---|
| 2845 | filecell.ima2.civ2=filecell.ima2.civ1; |
|---|
| 2846 | elseif box_test(4)==1 |
|---|
| 2847 | for ifile=1:nbfield |
|---|
| 2848 | for j=1:nbslice |
|---|
| 2849 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),ext_ima,nom_type_ima2); |
|---|
| 2850 | idetect_3(j)=exist(filename,'file')==2; |
|---|
| 2851 | filecell.ima2.civ2(ifile,j)={filename};%first image |
|---|
| 2852 | end |
|---|
| 2853 | [idetectmin,indexj]=min(idetect_3); |
|---|
| 2854 | if idetectmin==0, |
|---|
| 2855 | msgbox_uvmat('ERROR',['input image ' filecell.ima2.civ2{ifile,indexj} ' not found']) |
|---|
| 2856 | filecell=[]; |
|---|
| 2857 | return |
|---|
| 2858 | end |
|---|
| 2859 | end |
|---|
| 2860 | end |
|---|
| 2861 | end |
|---|
| 2862 | if (box_test(5)==1 || box_test(6)==1 ) && box_test(4)==0 % need to read an existing netcdf civ2 file |
|---|
| 2863 | if ~testdiff |
|---|
| 2864 | filecell.nc.civ2=filecell.nc.civ1;% file already checked |
|---|
| 2865 | else % check the civ2 files |
|---|
| 2866 | for ifile=1:nbfield |
|---|
| 2867 | for j=1:nbslice |
|---|
| 2868 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
|---|
| 2869 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
|---|
| 2870 | filecell.nc.civ2(ifile,j)={filename}; |
|---|
| 2871 | if ~exist(filename,'file') |
|---|
| 2872 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
|---|
| 2873 | filecell=[]; |
|---|
| 2874 | return |
|---|
| 2875 | else |
|---|
| 2876 | Data=nc2struct(filename,'ListGlobalAttribute','civ2'); |
|---|
| 2877 | if isempty(Data.civ2)||isequal(Data.civ2,0) |
|---|
| 2878 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
|---|
| 2879 | filecell=[]; |
|---|
| 2880 | return |
|---|
| 2881 | end |
|---|
| 2882 | end |
|---|
| 2883 | end |
|---|
| 2884 | end |
|---|
| 2885 | end |
|---|
| 2886 | end |
|---|
| 2887 | |
|---|
| 2888 | %%%%%%%%%%%%% if stereo fields are calculated by PATCH %%%%%%%%%%%%% |
|---|
| 2889 | if strcmp(compare,'stereo PIV') |
|---|
| 2890 | if box_test(3)==1 && isequal(get(handles.test_stereo1,'Value'),1) |
|---|
| 2891 | for ifile=1:nbfield |
|---|
| 2892 | for j=1:nbslice |
|---|
| 2893 | filename=name_generator(filebase_AB,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
|---|
| 2894 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
|---|
| 2895 | filecell.st(ifile,j)={filename}; |
|---|
| 2896 | end |
|---|
| 2897 | end |
|---|
| 2898 | end |
|---|
| 2899 | if box_test(6)==1 && isequal(get(handles.test_stereo2,'Value'),1) |
|---|
| 2900 | for ifile=1:nbfield |
|---|
| 2901 | for j=1:nbslice |
|---|
| 2902 | filename=name_generator(filebase_AB,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
|---|
| 2903 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
|---|
| 2904 | filecell.st(ifile,j)={filename}; |
|---|
| 2905 | end |
|---|
| 2906 | end |
|---|
| 2907 | end |
|---|
| 2908 | end |
|---|
| 2909 | set(handles.subdir_civ1,'String',subdir_civ1);%update the edit box |
|---|
| 2910 | set(handles.subdir_civ2,'String',subdir_civ2);%update the edit box |
|---|
| 2911 | browse.nom_type_nc=nom_type_nc; |
|---|
| 2912 | set(handles.browse_root,'UserData',browse); %update the nomenclature type for uvmat |
|---|
| 2913 | |
|---|
| 2914 | |
|---|
| 2915 | %COPY IMAGES TO THE FORMAT .png IF NEEDED |
|---|
| 2916 | if isequal(nom_type_ima1,'*')%case of movie files |
|---|
| 2917 | nom_type_imanew1='_i'; |
|---|
| 2918 | else |
|---|
| 2919 | nom_type_imanew1=nom_type_ima1; |
|---|
| 2920 | end |
|---|
| 2921 | if isequal(nom_type_ima2,'*')%case of movie files |
|---|
| 2922 | nom_type_imanew2='_i'; |
|---|
| 2923 | else |
|---|
| 2924 | nom_type_imanew2=nom_type_ima2; |
|---|
| 2925 | end |
|---|
| 2926 | if ~isequal(ext_ima,'.png') |
|---|
| 2927 | %%type of image file |
|---|
| 2928 | type_ima1='none';%default |
|---|
| 2929 | movieobject1=[];%default |
|---|
| 2930 | if strcmpi(ext_ima,'.avi') |
|---|
| 2931 | hhh=which('mmreader'); |
|---|
| 2932 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
|---|
| 2933 | type_ima1='movie'; |
|---|
| 2934 | movieobject1=mmreader([filebase_ima2 ext_ima]); |
|---|
| 2935 | else |
|---|
| 2936 | type_ima1='avi'; |
|---|
| 2937 | end |
|---|
| 2938 | elseif ischar(ext_ima) && ~isempty(ext_ima(2:end)) |
|---|
| 2939 | form=imformats(ext_ima(2:end)); |
|---|
| 2940 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
|---|
| 2941 | if isequal(nom_type_ima1,'*'); |
|---|
| 2942 | type_ima1='multimage';%image series in a single image file |
|---|
| 2943 | else |
|---|
| 2944 | type_ima1='image'; |
|---|
| 2945 | end |
|---|
| 2946 | end |
|---|
| 2947 | end |
|---|
| 2948 | type_ima2='none';%default |
|---|
| 2949 | movieobject2=[]; |
|---|
| 2950 | if strcmpi(ext_ima,'.avi') |
|---|
| 2951 | hhh=which('mmreader'); |
|---|
| 2952 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
|---|
| 2953 | type_ima2='movie'; |
|---|
| 2954 | movieobject2=mmreader([filebase_ima2 ext_ima]); |
|---|
| 2955 | else |
|---|
| 2956 | type_ima2='avi'; |
|---|
| 2957 | end |
|---|
| 2958 | elseif ischar(ext_ima) && ~isempty(ext_ima(2:end)) |
|---|
| 2959 | form=imformats(ext_ima(2:end)); |
|---|
| 2960 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
|---|
| 2961 | if isequal(nom_type_ima1,'*'); |
|---|
| 2962 | type_ima2='multimage';%image series in a single image file |
|---|
| 2963 | else |
|---|
| 2964 | type_ima2='image'; |
|---|
| 2965 | end |
|---|
| 2966 | end |
|---|
| 2967 | end |
|---|
| 2968 | %npxy=get(handles.ImaExt,'UserData'); |
|---|
| 2969 | % % if numel(npxy)<2 |
|---|
| 2970 | % |
|---|
| 2971 | % filename=name_generator(filebase_ima1,num1_civ1(1),num_a_civ1(1),ImaExt,nom_type_ima1); |
|---|
| 2972 | % A=imread(filename); |
|---|
| 2973 | % npxy=size(A); |
|---|
| 2974 | % % end |
|---|
| 2975 | % npy=npxy(1); |
|---|
| 2976 | % npx=npxy(2); |
|---|
| 2977 | if box_test(1)==1 %if civ1 is performed |
|---|
| 2978 | h = waitbar(0,['copy images to the .png format for civ1']);% display a wait bar |
|---|
| 2979 | for ifile=1:nbfield |
|---|
| 2980 | waitbar(ifile/nbfield); |
|---|
| 2981 | for j=1:nbslice |
|---|
| 2982 | filename=name_generator(filebase_ima1,num1_civ1(ifile),num_a_civ1(j),'.png',nom_type_imanew1); |
|---|
| 2983 | if ~exist(filename,'file') |
|---|
| 2984 | A=read_image(filecell.ima1.civ1{ifile,j},type_ima1,num1_civ1(ifile),movieobject1); |
|---|
| 2985 | imwrite(A,filename,'BitDepth',16); |
|---|
| 2986 | end |
|---|
| 2987 | filecell.ima1.civ1(ifile,j)={filename}; |
|---|
| 2988 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),'.png',nom_type_imanew2); |
|---|
| 2989 | if ~exist(filename,'file') |
|---|
| 2990 | A=read_image(filecell.ima2.civ1{ifile,j},type_ima2,num2_civ1(ifile),movieobject2); |
|---|
| 2991 | imwrite(A,filename,'BitDepth',16); |
|---|
| 2992 | end |
|---|
| 2993 | filecell.ima2.civ1(ifile,j)={filename}; |
|---|
| 2994 | end |
|---|
| 2995 | end |
|---|
| 2996 | close(h) |
|---|
| 2997 | end |
|---|
| 2998 | if box_test(4)==1 %if civ2 is performed |
|---|
| 2999 | h = waitbar(0,['copy images to the .png format for civ2']);% display a wait bar |
|---|
| 3000 | for ifile=1:nbfield |
|---|
| 3001 | waitbar(ifile/nbfield); |
|---|
| 3002 | for j=1:nbslice |
|---|
| 3003 | filename=name_generator(filebase_ima1,num1_civ2(ifile),num_a_civ2(j),'.png',nom_type_imanew1); |
|---|
| 3004 | if ~exist(filename,'file') |
|---|
| 3005 | A=read_image(cell2mat(filecell.ima1.civ2(ifile,j)),type_ima2,num1_civ2(ifile)); |
|---|
| 3006 | imwrite(A,filename,'BitDepth',16); |
|---|
| 3007 | end |
|---|
| 3008 | filecell.ima1.civ2(ifile,j)={filename}; |
|---|
| 3009 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),'.png',nom_type_imanew2); |
|---|
| 3010 | if ~exist(filename,'file') |
|---|
| 3011 | A=read_image(cell2mat(filecell.ima2.civ2(ifile,j)),type_ima2,num2_civ2(ifile)); |
|---|
| 3012 | imwrite(A,filename,'BitDepth',16); |
|---|
| 3013 | end |
|---|
| 3014 | filecell.ima2.civ2(ifile,j)={filename}; |
|---|
| 3015 | end |
|---|
| 3016 | end |
|---|
| 3017 | close(h); |
|---|
| 3018 | end |
|---|
| 3019 | end |
|---|
| 3020 | |
|---|
| 3021 | %------------------------------------------------------------------------ |
|---|
| 3022 | % --- PATCH |
|---|
| 3023 | function cmd_PATCH=PATCH_CMD(filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,test_interp,PatchBin) |
|---|
| 3024 | %------------------------------------------------------------------------ |
|---|
| 3025 | namelog=[filename_nc([1:end-3]) '_patch.log']; |
|---|
| 3026 | if test_interp==0 |
|---|
| 3027 | if isunix |
|---|
| 3028 | cmd_PATCH=[PatchBin ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ... |
|---|
| 3029 | ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
|---|
| 3030 | else |
|---|
| 3031 | cmd_PATCH=['"' PatchBin '" -f "' filename_nc '" -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ... |
|---|
| 3032 | ' > "' namelog '" 2>&1']; % redirect standard output to the log file |
|---|
| 3033 | end |
|---|
| 3034 | else %nouveau programme patch |
|---|
| 3035 | cmd_PATCH=[PatchBin ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ... |
|---|
| 3036 | ' -max ' thresh_value ' -nopt ' subdomain_patch ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
|---|
| 3037 | end |
|---|
| 3038 | cmd_PATCH=regexprep(cmd_PATCH,'\\','\\\\'); |
|---|
| 3039 | %------------------------------------------------------------------------ |
|---|
| 3040 | % --- STEREO Interp |
|---|
| 3041 | 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) |
|---|
| 3042 | %------------------------------------------------------------------------ |
|---|
| 3043 | namelog=[filename_nc([1:end-3]) '_stinterp.log']; |
|---|
| 3044 | cmd=[stinterpBin ' -f1 ' filename_A_nc ' -f2 ' filename_B_nc ' -f ' filename_nc ... |
|---|
| 3045 | ' -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 |
|---|
| 3046 | |
|---|
| 3047 | %------------------------------------------------------------------------ |
|---|
| 3048 | % --- Executes on button press in CIV1. |
|---|
| 3049 | function CIV1_Callback(hObject, eventdata, handles) |
|---|
| 3050 | %------------------------------------------------------------------------ |
|---|
| 3051 | val=get(handles.CIV1,'Value'); |
|---|
| 3052 | if isequal(val,1) |
|---|
| 3053 | enable_civ1(handles,'on') |
|---|
| 3054 | enable_pair1(handles,'on') |
|---|
| 3055 | else |
|---|
| 3056 | enable_civ1(handles,'off') |
|---|
| 3057 | end |
|---|
| 3058 | find_netcpair_civ1(hObject, eventdata, handles); |
|---|
| 3059 | |
|---|
| 3060 | %------------------------------------------------------------------------ |
|---|
| 3061 | % --- Executes on button press in FIX1. |
|---|
| 3062 | function FIX1_Callback(hObject, eventdata, handles) |
|---|
| 3063 | %------------------------------------------------------------------------ |
|---|
| 3064 | enable_fix1(handles,get(handles.FIX1,'Value')) |
|---|
| 3065 | |
|---|
| 3066 | %------------------------------------------------------------------------ |
|---|
| 3067 | % --- Executes on button press in PATCH1. |
|---|
| 3068 | function PATCH1_Callback(hObject, eventdata, handles) |
|---|
| 3069 | %------------------------------------------------------------------------ |
|---|
| 3070 | if get(handles.PATCH1,'Value')==1 |
|---|
| 3071 | enable_patch1(handles) |
|---|
| 3072 | else |
|---|
| 3073 | desable_patch1(handles) |
|---|
| 3074 | end |
|---|
| 3075 | |
|---|
| 3076 | %------------------------------------------------------------------------ |
|---|
| 3077 | % --- Executes on button press in CIV2. |
|---|
| 3078 | function CIV2_Callback(hObject, eventdata, handles) |
|---|
| 3079 | %------------------------------------------------------------------------ |
|---|
| 3080 | state=get(handles.CIV2,'Value'); |
|---|
| 3081 | enable_civ2(handles,state) |
|---|
| 3082 | if state |
|---|
| 3083 | find_netcpair_civ2(hObject, eventdata, handles) |
|---|
| 3084 | enable_pair1(handles,'on') |
|---|
| 3085 | end |
|---|
| 3086 | |
|---|
| 3087 | %------------------------------------------------------------------------ |
|---|
| 3088 | % --- Executes on button press in FIX2. |
|---|
| 3089 | function FIX2_Callback(hObject, eventdata, handles) |
|---|
| 3090 | %------------------------------------------------------------------------ |
|---|
| 3091 | if get(handles.FIX2,'Value')==1 |
|---|
| 3092 | enable_fix2(handles) |
|---|
| 3093 | if get(handles.CIV2,'Value')==0 |
|---|
| 3094 | find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files |
|---|
| 3095 | end |
|---|
| 3096 | else |
|---|
| 3097 | desable_fix2(handles) |
|---|
| 3098 | end |
|---|
| 3099 | |
|---|
| 3100 | %------------------------------------------------------------------------ |
|---|
| 3101 | % --- Executes on button press in PATCH2. |
|---|
| 3102 | function PATCH2_Callback(hObject, eventdata, handles) |
|---|
| 3103 | %------------------------------------------------------------------------ |
|---|
| 3104 | if get(handles.PATCH2,'Value')==1 |
|---|
| 3105 | enable_patch2(handles) |
|---|
| 3106 | if get(handles.CIV2,'Value')==0 |
|---|
| 3107 | find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files |
|---|
| 3108 | end |
|---|
| 3109 | else |
|---|
| 3110 | desable_patch2(handles) |
|---|
| 3111 | end |
|---|
| 3112 | |
|---|
| 3113 | %------------------------------------------------------------------------ |
|---|
| 3114 | function first_i_Callback(hObject, eventdata, handles) |
|---|
| 3115 | %------------------------------------------------------------------------ |
|---|
| 3116 | % last_i_Callback(hObject, eventdata, handles) |
|---|
| 3117 | first_i=str2double(get(handles.first_i,'String')); |
|---|
| 3118 | % last_i=str2num(get(handles.last_i,'String')); |
|---|
| 3119 | % ref_i=ceil((first_i+last_i)/2); |
|---|
| 3120 | set(handles.ref_i,'String', num2str(first_i))% reference index for pair dt = first index |
|---|
| 3121 | set(handles.ref_i_civ2,'String', num2str(first_i))% reference index for pair dt = first index |
|---|
| 3122 | ref_i_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
|---|
| 3123 | |
|---|
| 3124 | %------------------------------------------------------------------------ |
|---|
| 3125 | function first_j_Callback(hObject, eventdata, handles) |
|---|
| 3126 | %------------------------------------------------------------------------ |
|---|
| 3127 | first_j=str2num(get(handles.first_j,'String')); |
|---|
| 3128 | set(handles.ref_j,'String', num2str(first_j))% reference index for pair dt = first index |
|---|
| 3129 | ref_j_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
|---|
| 3130 | |
|---|
| 3131 | %------------------------------------------------------------------------ |
|---|
| 3132 | % --- Executes on button press in calcul_search: determine the search range isx,isy |
|---|
| 3133 | function calcul_search_Callback(hObject, eventdata, handles) |
|---|
| 3134 | %------------------------------------------------------------------------ |
|---|
| 3135 | %determine pair numbers |
|---|
| 3136 | list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs |
|---|
| 3137 | index=get(handles.list_pair_civ1,'Value'); |
|---|
| 3138 | displ_num=get(handles.list_pair_civ1,'UserData'); |
|---|
| 3139 | time=get(handles.RootName,'UserData'); %get the set of times |
|---|
| 3140 | pxcm_xy=get(handles.calcul_search,'UserData'); |
|---|
| 3141 | pxcmx=pxcm_xy(1); |
|---|
| 3142 | pxcmy=pxcm_xy(2); |
|---|
| 3143 | mode_list=get(handles.mode,'String'); |
|---|
| 3144 | mode_value=get(handles.mode,'Value'); |
|---|
| 3145 | mode=mode_list{mode_value}; |
|---|
| 3146 | if isequal (mode, 'series(Di)' ) |
|---|
| 3147 | ref_i=str2double(get(handles.ref_i,'String')); |
|---|
| 3148 | num1=ref_i-floor(index/2);% first image numbers |
|---|
| 3149 | num2=ref_i+ceil(index/2); |
|---|
| 3150 | num_a=1; |
|---|
| 3151 | num_b=1; |
|---|
| 3152 | elseif isequal (mode, 'series(Dj)') |
|---|
| 3153 | num1=1; |
|---|
| 3154 | num2=1; |
|---|
| 3155 | ref_j=str2double(get(handles.ref_j,'String')); |
|---|
| 3156 | num_a=ref_j-floor(index/2);% first image numbers |
|---|
| 3157 | num_b=ref_j+ceil(index/2); |
|---|
| 3158 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
|---|
| 3159 | ref_i=str2double(get(handles.ref_i,'String')); |
|---|
| 3160 | num1=ref_i; |
|---|
| 3161 | num2=ref_i; |
|---|
| 3162 | num_a=displ_num(1,index); |
|---|
| 3163 | num_b=displ_num(2,index); |
|---|
| 3164 | end |
|---|
| 3165 | dt=time(num2,num_b)-time(num1,num_a); |
|---|
| 3166 | ibx=str2double(get(handles.ibx,'String')); |
|---|
| 3167 | iby=str2double(get(handles.iby,'String')); |
|---|
| 3168 | umin=dt*pxcmx*str2double(get(handles.umin,'String')); |
|---|
| 3169 | umax=dt*pxcmx*str2double(get(handles.umax,'String')); |
|---|
| 3170 | vmin=dt*pxcmy*str2double(get(handles.vmin,'String')); |
|---|
| 3171 | vmax=dt*pxcmy*str2double(get(handles.vmax,'String')); |
|---|
| 3172 | shiftx=round((umin+umax)/2); |
|---|
| 3173 | shifty=round((vmin+vmax)/2); |
|---|
| 3174 | isx=(umax+2-shiftx)*2+ibx; |
|---|
| 3175 | isx=2*ceil(isx/2)+1; |
|---|
| 3176 | isy=(vmax+2-shifty)*2+iby; |
|---|
| 3177 | isy=2*ceil(isy/2)+1; |
|---|
| 3178 | set(handles.shiftx,'String',num2str(shiftx)); |
|---|
| 3179 | set(handles.shifty,'String',num2str(shifty)); |
|---|
| 3180 | set(handles.isx,'String',num2str(isx)); |
|---|
| 3181 | set(handles.isy,'String',num2str(isy)); |
|---|
| 3182 | |
|---|
| 3183 | %------------------------------------------------------------------------ |
|---|
| 3184 | % --- Executes on carriage return on the subdir civ1 edit window |
|---|
| 3185 | function subdir_civ1_Callback(hObject, eventdata, handles) |
|---|
| 3186 | %------------------------------------------------------------------------ |
|---|
| 3187 | subdir=get(handles.subdir_civ1,'String'); |
|---|
| 3188 | set(handles.subdir_civ2,'String',subdir); |
|---|
| 3189 | if get(handles.CIV1,'Value')==0 |
|---|
| 3190 | find_netcpair_civ1(hObject, eventdata, handles); %update the list of available pairs from netcdf files in the new directory |
|---|
| 3191 | end |
|---|
| 3192 | |
|---|
| 3193 | %------------------------------------------------------------------------ |
|---|
| 3194 | % --- Executes on carriage return on the subdir civ1 edit window |
|---|
| 3195 | function subdir_civ2_Callback(hObject, eventdata, handles) |
|---|
| 3196 | %------------------------------------------------------------------------ |
|---|
| 3197 | %update the list of available pairs from netcdf files in the new directory |
|---|
| 3198 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0 |
|---|
| 3199 | find_netcpair_civ2(hObject, eventdata, handles); |
|---|
| 3200 | end |
|---|
| 3201 | |
|---|
| 3202 | %------------------------------------------------------------------------ |
|---|
| 3203 | % --- Executes on button press in get_mask_civ1: select box for mask option |
|---|
| 3204 | function get_mask_civ1_Callback(hObject, eventdata, handles) |
|---|
| 3205 | %------------------------------------------------------------------------ |
|---|
| 3206 | maskval=get(handles.get_mask_civ1,'Value'); |
|---|
| 3207 | if isequal(maskval,0) |
|---|
| 3208 | set(handles.mask_civ1,'String','') |
|---|
| 3209 | else |
|---|
| 3210 | mask_displ='no mask'; %default |
|---|
| 3211 | filebase=get(handles.RootName,'String'); |
|---|
| 3212 | [ nbslice_mask, flag_mask]=get_mask(filebase,handles); |
|---|
| 3213 | if isequal(flag_mask,1) |
|---|
| 3214 | mask_displ=[num2str(nbslice_mask) 'mask']; |
|---|
| 3215 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
|---|
| 3216 | common_path=fileparts(filebase); |
|---|
| 3217 | filebase_a=fullfile(common_path,get(handles.RootName_1,'String')); |
|---|
| 3218 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
|---|
| 3219 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice_mask) |
|---|
| 3220 | mask_displ='no mask'; |
|---|
| 3221 | end |
|---|
| 3222 | end |
|---|
| 3223 | if isequal(mask_displ,'no mask') |
|---|
| 3224 | [FileName, PathName, filterindex] = uigetfile( ... |
|---|
| 3225 | {'*.png', ' (*.png)'; |
|---|
| 3226 | '*.png', '.png files '; ... |
|---|
| 3227 | '*.*', 'All Files (*.*)'}, ... |
|---|
| 3228 | 'Pick a mask file *.png',filebase); |
|---|
| 3229 | mask_displ=fullfile(PathName,FileName); |
|---|
| 3230 | if ~exist(mask_displ,'file') |
|---|
| 3231 | mask_displ='no mask'; |
|---|
| 3232 | end |
|---|
| 3233 | end |
|---|
| 3234 | if isequal(mask_displ,'no mask') |
|---|
| 3235 | set(handles.get_mask_civ1,'Value',0) |
|---|
| 3236 | set(handles.get_mask_fix1,'Value',0) |
|---|
| 3237 | set(handles.get_mask_civ2,'Value',0) |
|---|
| 3238 | set(handles.get_mask_fix2,'Value',0) |
|---|
| 3239 | else |
|---|
| 3240 | set(handles.get_mask_fix1,'Value',1) |
|---|
| 3241 | set(handles.get_mask_fix2,'Value',1) |
|---|
| 3242 | end |
|---|
| 3243 | set(handles.mask_civ1,'String',mask_displ) |
|---|
| 3244 | set(handles.mask_fix1,'String',mask_displ) |
|---|
| 3245 | set(handles.mask_civ2,'String',mask_displ) |
|---|
| 3246 | set(handles.mask_fix2,'String',mask_displ) |
|---|
| 3247 | end |
|---|
| 3248 | set(handles.get_mask_civ2,'Value',maskval)%update the civ2 mask with the same option as civ1 |
|---|
| 3249 | |
|---|
| 3250 | %------------------------------------------------------------------------ |
|---|
| 3251 | % --- Executes on button press in get_mask_fix1. |
|---|
| 3252 | function get_mask_fix1_Callback(hObject, eventdata, handles) |
|---|
| 3253 | %------------------------------------------------------------------------ |
|---|
| 3254 | maskval=get(handles.get_mask_fix1,'Value'); |
|---|
| 3255 | if isequal(maskval,0) |
|---|
| 3256 | set(handles.mask_fix1,'String','') |
|---|
| 3257 | else |
|---|
| 3258 | mask_displ='no mask'; %default |
|---|
| 3259 | filebase=get(handles.RootName,'String'); |
|---|
| 3260 | [nbslice, flag_mask]=get_mask(filebase,handles); |
|---|
| 3261 | if isequal(flag_mask,1) |
|---|
| 3262 | mask_displ=[num2str(nbslice) 'mask']; |
|---|
| 3263 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
|---|
| 3264 | filebase_a=get(handles.RootName_1,'String'); |
|---|
| 3265 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
|---|
| 3266 | if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice) |
|---|
| 3267 | mask_displ='no mask'; |
|---|
| 3268 | end |
|---|
| 3269 | end |
|---|
| 3270 | if isequal(mask_displ,'no mask') |
|---|
| 3271 | [FileName, PathName, filterindex] = uigetfile( ... |
|---|
| 3272 | {'*.png', ' (*.png)'; |
|---|
| 3273 | '*.png', '.png files '; ... |
|---|
| 3274 | '*.*', 'All Files (*.*)'}, ... |
|---|
| 3275 | 'Pick a mask file *.png',filebase); |
|---|
| 3276 | mask_displ=fullfile(PathName,FileName); |
|---|
| 3277 | if ~exist(mask_displ,'file') |
|---|
| 3278 | mask_displ='no mask'; |
|---|
| 3279 | end |
|---|
| 3280 | end |
|---|
| 3281 | if isequal(mask_displ,'no mask') |
|---|
| 3282 | set(handles.get_mask_fix1,'Value',0) |
|---|
| 3283 | set(handles.get_mask_civ2,'Value',0) |
|---|
| 3284 | set(handles.get_mask_fix2,'Value',0) |
|---|
| 3285 | else |
|---|
| 3286 | %set(handles.get_mask_civ2,'Value',1) |
|---|
| 3287 | set(handles.get_mask_fix2,'Value',1) |
|---|
| 3288 | end |
|---|
| 3289 | set(handles.mask_fix1,'String',mask_displ) |
|---|
| 3290 | set(handles.mask_civ2,'String',mask_displ) |
|---|
| 3291 | set(handles.mask_fix2,'String',mask_displ) |
|---|
| 3292 | end |
|---|
| 3293 | |
|---|
| 3294 | %------------------------------------------------------------------------ |
|---|
| 3295 | % --- Executes on button press in get_mask_civ2: select box for mask option |
|---|
| 3296 | function get_mask_civ2_Callback(hObject, eventdata, handles) |
|---|
| 3297 | %------------------------------------------------------------------------ |
|---|
| 3298 | maskval=get(handles.get_mask_civ2,'Value'); |
|---|
| 3299 | if isequal(maskval,0) |
|---|
| 3300 | set(handles.mask_civ2,'String','') |
|---|
| 3301 | else |
|---|
| 3302 | mask_displ='no mask'; %default |
|---|
| 3303 | filebase=get(handles.RootName,'String'); |
|---|
| 3304 | [nbslice, flag_mask]=get_mask(filebase,handles); |
|---|
| 3305 | if isequal(flag_mask,1) |
|---|
| 3306 | mask_displ=[num2str(nbslice) 'mask']; |
|---|
| 3307 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
|---|
| 3308 | filebase_a=get(handles.RootName_1,'String'); |
|---|
| 3309 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
|---|
| 3310 | if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice) |
|---|
| 3311 | mask_displ='no mask'; |
|---|
| 3312 | end |
|---|
| 3313 | end |
|---|
| 3314 | if isequal(mask_displ,'no mask') |
|---|
| 3315 | [FileName, PathName, filterindex] = uigetfile( ... |
|---|
| 3316 | {'*.png', ' (*.png)'; |
|---|
| 3317 | '*.png', '.png files '; ... |
|---|
| 3318 | '*.*', 'All Files (*.*)'}, ... |
|---|
| 3319 | 'Pick a mask file *.png',filebase); |
|---|
| 3320 | mask_displ=fullfile(PathName,FileName); |
|---|
| 3321 | if ~exist(mask_displ,'file') |
|---|
| 3322 | mask_displ='no mask'; |
|---|
| 3323 | end |
|---|
| 3324 | end |
|---|
| 3325 | if isequal(mask_displ,'no mask') |
|---|
| 3326 | set(handles.get_mask_civ2,'Value',0) |
|---|
| 3327 | set(handles.get_mask_fix2,'Value',0) |
|---|
| 3328 | else |
|---|
| 3329 | set(handles.get_mask_fix2,'Value',1) |
|---|
| 3330 | end |
|---|
| 3331 | set(handles.mask_civ2,'String',mask_displ) |
|---|
| 3332 | set(handles.mask_fix2,'String',mask_displ) |
|---|
| 3333 | end |
|---|
| 3334 | |
|---|
| 3335 | %------------------------------------------------------------------------ |
|---|
| 3336 | % --- Executes on button press in get_mask_fix2. |
|---|
| 3337 | function get_mask_fix2_Callback(hObject, eventdata, handles) |
|---|
| 3338 | %------------------------------------------------------------------------ |
|---|
| 3339 | maskval=get(handles.get_mask_fix2,'Value'); |
|---|
| 3340 | if isequal(maskval,0) |
|---|
| 3341 | set(handles.mask_fix2,'String','') |
|---|
| 3342 | else |
|---|
| 3343 | mask_displ='no mask'; %default |
|---|
| 3344 | filebase=get(handles.RootName,'String'); |
|---|
| 3345 | [nbslice, flag_mask]=get_mask(filebase,handles); |
|---|
| 3346 | if isequal(flag_mask,1) |
|---|
| 3347 | mask_displ=[num2str(nbslice) 'mask']; |
|---|
| 3348 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
|---|
| 3349 | filebase_a=get(handles.RootName_1,'String'); |
|---|
| 3350 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
|---|
| 3351 | if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice) |
|---|
| 3352 | mask_displ='no mask'; |
|---|
| 3353 | end |
|---|
| 3354 | end |
|---|
| 3355 | if isequal(mask_displ,'no mask') |
|---|
| 3356 | [FileName, PathName, filterindex] = uigetfile( ... |
|---|
| 3357 | {'*.png', ' (*.png)'; |
|---|
| 3358 | '*.png', '.png files '; ... |
|---|
| 3359 | '*.*', 'All Files (*.*)'}, ... |
|---|
| 3360 | 'Pick a mask file *.png',filebase); |
|---|
| 3361 | mask_displ=fullfile(PathName,FileName); |
|---|
| 3362 | if ~exist(mask_displ,'file') |
|---|
| 3363 | mask_displ='no mask'; |
|---|
| 3364 | end |
|---|
| 3365 | end |
|---|
| 3366 | if isequal(mask_displ,'no mask') |
|---|
| 3367 | set(handles.get_mask_fix2,'Value',0) |
|---|
| 3368 | end |
|---|
| 3369 | set(handles.mask_fix2,'String',mask_displ) |
|---|
| 3370 | end |
|---|
| 3371 | |
|---|
| 3372 | %------------------------------------------------------------------------ |
|---|
| 3373 | % --- function called to look for mask files |
|---|
| 3374 | function [nbslice, flag_mask]=get_mask(filebase,handles) |
|---|
| 3375 | %------------------------------------------------------------------------ |
|---|
| 3376 | %detect mask files, images with appropriate file base |
|---|
| 3377 | %[filebase '_' xx 'mask'], xx=nbslice |
|---|
| 3378 | %flag_mask=1 indicates detection |
|---|
| 3379 | |
|---|
| 3380 | flag_mask=0;%default |
|---|
| 3381 | nbslice=1; |
|---|
| 3382 | |
|---|
| 3383 | % subdir=get(handles.subdir_civ1,'String'); |
|---|
| 3384 | [Path,Name]=fileparts(filebase); |
|---|
| 3385 | if ~isdir(Path) |
|---|
| 3386 | msgbox_uvmat('ERROR','no path for input files') |
|---|
| 3387 | return |
|---|
| 3388 | end |
|---|
| 3389 | currentdir=pwd; |
|---|
| 3390 | cd(Path);%move in the dir of the root name filebase |
|---|
| 3391 | maskfiles=dir([Name '_*mask_*.png']);%look for mask files |
|---|
| 3392 | cd(currentdir);%come back to the current working directory |
|---|
| 3393 | if ~isempty(maskfiles) |
|---|
| 3394 | % msgbox_uvmat('ERROR','no mask available, to create it use Tools/Make mask in the upper menu bar of uvmat') |
|---|
| 3395 | % else |
|---|
| 3396 | flag_mask=1; |
|---|
| 3397 | maskname=maskfiles(1).name;% take the first mask file in the list |
|---|
| 3398 | [Path2,Name,ext]=fileparts(maskname); |
|---|
| 3399 | Namedouble=double(Name); |
|---|
| 3400 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
|---|
| 3401 | ind_mask=findstr('mask',Name); |
|---|
| 3402 | i=ind_mask-1; |
|---|
| 3403 | while val(i)==0 && i>0 |
|---|
| 3404 | i=i-1; |
|---|
| 3405 | end |
|---|
| 3406 | nbslice=str2double(Name(i+1:ind_mask-1)); |
|---|
| 3407 | if ~isnan(nbslice) && Name(i)=='_' |
|---|
| 3408 | flag_mask=1; |
|---|
| 3409 | else |
|---|
| 3410 | msgbox_uvmat('ERROR',['bad mask file ' Name ext ' found in ' Path2]) |
|---|
| 3411 | return |
|---|
| 3412 | nbslice=1; |
|---|
| 3413 | end |
|---|
| 3414 | end |
|---|
| 3415 | |
|---|
| 3416 | %------------------------------------------------------------------------ |
|---|
| 3417 | % --- function called to look for grid files |
|---|
| 3418 | function [nbslice, flag_mask]=get_grid(filebase,handles) |
|---|
| 3419 | %------------------------------------------------------------------------ |
|---|
| 3420 | flag_mask=0;%default |
|---|
| 3421 | nbslice=1; |
|---|
| 3422 | [Path,Name]=fileparts(filebase); |
|---|
| 3423 | currentdir=pwd; |
|---|
| 3424 | cd(Path);%move in the dir of the root name filebase |
|---|
| 3425 | maskfiles=dir([Name '_*grid_*.grid']);%look for mask files |
|---|
| 3426 | cd(currentdir);%come back to the current working directory |
|---|
| 3427 | if ~isempty(maskfiles) |
|---|
| 3428 | flag_mask=1; |
|---|
| 3429 | maskname=maskfiles(1).name;% take the first mask file in the list |
|---|
| 3430 | [Path2,Name,ext]=fileparts(maskname); |
|---|
| 3431 | Namedouble=double(Name); |
|---|
| 3432 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
|---|
| 3433 | ind_mask=findstr('grid',Name); |
|---|
| 3434 | i=ind_mask-1; |
|---|
| 3435 | while val(i)==0 && i>0 |
|---|
| 3436 | i=i-1; |
|---|
| 3437 | end |
|---|
| 3438 | nbslice=str2double(Name(i+1:ind_mask-1)); |
|---|
| 3439 | if ~isnan(nbslice) && Name(i)=='_' |
|---|
| 3440 | flag_mask=1; |
|---|
| 3441 | else |
|---|
| 3442 | msgbox_uvmat('ERROR',['bad grid file ' Name ext ' found in ' Path2]) |
|---|
| 3443 | return |
|---|
| 3444 | nbslice=1; |
|---|
| 3445 | end |
|---|
| 3446 | end |
|---|
| 3447 | |
|---|
| 3448 | %------------------------------------------------------------------------ |
|---|
| 3449 | % --- transform numbers to letters |
|---|
| 3450 | function str=num2stra(num,nom_type) |
|---|
| 3451 | %------------------------------------------------------------------------ |
|---|
| 3452 | if isempty(nom_type) |
|---|
| 3453 | str=''; |
|---|
| 3454 | elseif strcmp(nom_type(end),'a') |
|---|
| 3455 | str=char(96+num); |
|---|
| 3456 | elseif strcmp(nom_type(end),'A') |
|---|
| 3457 | str=char(96+num); |
|---|
| 3458 | elseif isempty(nom_type(2:end))%a single index |
|---|
| 3459 | str=''; |
|---|
| 3460 | else |
|---|
| 3461 | str=num2str(num); |
|---|
| 3462 | end |
|---|
| 3463 | |
|---|
| 3464 | % %------------------------------------------------------------------------ |
|---|
| 3465 | % function mask_civ1_Callback(hObject, eventdata, handles) |
|---|
| 3466 | % %------------------------------------------------------------------------ |
|---|
| 3467 | % set(handles.mask_civ1,'UserData',[]) |
|---|
| 3468 | % set(handles.mask_civ1,'String','') |
|---|
| 3469 | % |
|---|
| 3470 | % %------------------------------------------------------------------------ |
|---|
| 3471 | % function mask_civ2_Callback(hObject, eventdata, handles) |
|---|
| 3472 | % %------------------------------------------------------------------------ |
|---|
| 3473 | % set(handles.mask_civ2,'UserData',[]) |
|---|
| 3474 | % set(handles.mask_civ2,'String','') |
|---|
| 3475 | % |
|---|
| 3476 | % %------------------------------------------------------------------------ |
|---|
| 3477 | % function mask_fix1_Callback(hObject, eventdata, handles) |
|---|
| 3478 | % %------------------------------------------------------------------------ |
|---|
| 3479 | % set(handles.mask_fix1,'UserData',[]) |
|---|
| 3480 | % set(handles.mask_fix1,'String','') |
|---|
| 3481 | % |
|---|
| 3482 | % %------------------------------------------------------------------------ |
|---|
| 3483 | % function mask_fix2_Callback(hObject, eventdata, handles) |
|---|
| 3484 | % %------------------------------------------------------------------------ |
|---|
| 3485 | % set(handles.mask_fix2,'UserData',[]) |
|---|
| 3486 | % set(handles.mask_fix2,'String','') |
|---|
| 3487 | |
|---|
| 3488 | %------------------------------------------------------------------------ |
|---|
| 3489 | % --- Executes on button press in list_subdir_civ1. |
|---|
| 3490 | function list_subdir_civ1_Callback(hObject, eventdata, handles) |
|---|
| 3491 | %------------------------------------------------------------------------ |
|---|
| 3492 | list_subdir_civ1=get(handles.list_subdir_civ1,'String'); |
|---|
| 3493 | val=get(handles.list_subdir_civ1,'Value'); |
|---|
| 3494 | if val>1 |
|---|
| 3495 | subdir=list_subdir_civ1{val}; |
|---|
| 3496 | set(handles.subdir_civ1,'String',subdir); |
|---|
| 3497 | set(handles.list_subdir_civ1,'Value',1); |
|---|
| 3498 | end |
|---|
| 3499 | |
|---|
| 3500 | %------------------------------------------------------------------------ |
|---|
| 3501 | % --- Executes on button press in list_subdir_civ2. |
|---|
| 3502 | function list_subdir_civ2_Callback(hObject, eventdata, handles) |
|---|
| 3503 | %------------------------------------------------------------------------ |
|---|
| 3504 | list_subdir_civ2=get(handles.list_subdir_civ2,'String'); |
|---|
| 3505 | val=get(handles.list_subdir_civ2,'Value'); |
|---|
| 3506 | if val>1 |
|---|
| 3507 | subdir=list_subdir_civ2{val}; |
|---|
| 3508 | set(handles.subdir_civ2,'String',subdir); |
|---|
| 3509 | set(handles.list_subdir_civ2,'Value',1); |
|---|
| 3510 | end |
|---|
| 3511 | |
|---|
| 3512 | %------------------------------------------------------------------------ |
|---|
| 3513 | % --- Executes on button press in browse_gridciv1. |
|---|
| 3514 | function browse_gridciv1_Callback(hObject, eventdata, handles) |
|---|
| 3515 | %------------------------------------------------------------------------ |
|---|
| 3516 | value=get(handles.browse_gridciv1,'Value'); |
|---|
| 3517 | testgrid=0; |
|---|
| 3518 | if value |
|---|
| 3519 | filebase=get(handles.RootName,'String'); |
|---|
| 3520 | [nbslice, flag_grid]=get_grid(filebase,handles); |
|---|
| 3521 | if isequal(flag_grid,1) |
|---|
| 3522 | filegrid=[num2str(nbslice) 'grid']; |
|---|
| 3523 | testgrid=1; |
|---|
| 3524 | else |
|---|
| 3525 | [FileName, PathName, filterindex] = uigetfile( ... |
|---|
| 3526 | {'*.grid', ' (*.grid)'; |
|---|
| 3527 | '*.grid', '.grid files '; ... |
|---|
| 3528 | '*.*', 'All Files (*.*)'}, ... |
|---|
| 3529 | 'Pick a file',filebase); |
|---|
| 3530 | filegrid=fullfile(PathName,FileName); |
|---|
| 3531 | if ~(isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file')) |
|---|
| 3532 | testgrid=1; |
|---|
| 3533 | end |
|---|
| 3534 | end |
|---|
| 3535 | end |
|---|
| 3536 | if testgrid |
|---|
| 3537 | set(handles.browse_gridciv2,'Value',1) |
|---|
| 3538 | set(handles.get_gridpatch1,'Value',1) |
|---|
| 3539 | set(handles.get_gridpatch2,'Value',1) |
|---|
| 3540 | set(handles.dx_civ1,'Visible','off'); |
|---|
| 3541 | set(handles.dy_civ1,'Visible','off'); |
|---|
| 3542 | set(handles.dx_civ2,'Visible','off'); |
|---|
| 3543 | set(handles.dy_civ2,'Visible','off'); |
|---|
| 3544 | set(handles.grid_civ1,'String',filegrid) |
|---|
| 3545 | set(handles.grid_patch1,'String',filegrid) |
|---|
| 3546 | set(handles.grid_civ2,'String',filegrid) |
|---|
| 3547 | set(handles.grid_patch2,'String',filegrid) |
|---|
| 3548 | else |
|---|
| 3549 | set(handles.browse_gridciv1,'Value',0); |
|---|
| 3550 | set(handles.browse_gridciv2,'Value',0); |
|---|
| 3551 | set(handles.get_gridpatch1,'Value',0) |
|---|
| 3552 | set(handles.get_gridpatch2,'Value',0) |
|---|
| 3553 | set(handles.dx_civ1,'Visible','on'); |
|---|
| 3554 | set(handles.dy_civ1,'Visible','on'); |
|---|
| 3555 | set(handles.dx_civ2,'Visible','on'); |
|---|
| 3556 | set(handles.dy_civ2,'Visible','on'); |
|---|
| 3557 | set(handles.grid_civ1,'String','') |
|---|
| 3558 | set(handles.grid_patch1,'String','') |
|---|
| 3559 | set(handles.grid_civ2,'String','') |
|---|
| 3560 | set(handles.grid_patch2,'String','') |
|---|
| 3561 | end |
|---|
| 3562 | |
|---|
| 3563 | %------------------------------------------------------------------------ |
|---|
| 3564 | % --- Executes on button press in browse_gridciv1. |
|---|
| 3565 | function browse_gridciv2_Callback(hObject, eventdata, handles) |
|---|
| 3566 | %------------------------------------------------------------------------ |
|---|
| 3567 | value=get(handles.browse_gridciv2,'Value'); |
|---|
| 3568 | if value |
|---|
| 3569 | filebase=get(handles.RootName,'String'); |
|---|
| 3570 | [nbslice, flag_grid]=get_grid(filebase,handles); |
|---|
| 3571 | if isequal(flag_grid,1) |
|---|
| 3572 | mask_displ=[num2str(nbslice) 'grid']; |
|---|
| 3573 | set(handles.grid_civ2,'String',mask_displ) |
|---|
| 3574 | set(handles.dx_civ2,'Visible','off'); |
|---|
| 3575 | set(handles.dy_civ2,'Visible','off'); |
|---|
| 3576 | else |
|---|
| 3577 | [FileName, PathName, filterindex] = uigetfile( ... |
|---|
| 3578 | {'*.grid', ' (*.grid)'; |
|---|
| 3579 | '*.grid', '.grid files '; ... |
|---|
| 3580 | '*.*', 'All Files (*.*)'}, ... |
|---|
| 3581 | 'Pick a file',filebase); |
|---|
| 3582 | filegrid=fullfile(PathName,FileName); |
|---|
| 3583 | if isempty(FileName)|isempty(PathName)|isequal(FileName,0)|~exist(filegrid,'file') |
|---|
| 3584 | set(handles.browse_gridciv2,'Value',0); |
|---|
| 3585 | set(handles.grid_civ2,'string',''); |
|---|
| 3586 | set(handles.dx_civ2,'Visible','on'); |
|---|
| 3587 | set(handles.dy_civ2,'Visible','on'); |
|---|
| 3588 | set(handles.grid_civ2,'string',''); |
|---|
| 3589 | else |
|---|
| 3590 | set(handles.grid_civ2,'string',filegrid); |
|---|
| 3591 | set(handles.dx_civ2,'Visible','off'); |
|---|
| 3592 | set(handles.dy_civ2,'Visible','off'); |
|---|
| 3593 | set(handles.grid_civ2,'string',filegrid); |
|---|
| 3594 | end |
|---|
| 3595 | end |
|---|
| 3596 | else |
|---|
| 3597 | set(handles.grid_civ2,'string',''); |
|---|
| 3598 | set(handles.dx_civ2,'Visible','on'); |
|---|
| 3599 | set(handles.dy_civ2,'Visible','on'); |
|---|
| 3600 | set(handles.grid_civ2,'string',''); |
|---|
| 3601 | end |
|---|
| 3602 | |
|---|
| 3603 | % % --- Executes on button press in browse_gridciv2. |
|---|
| 3604 | % function browse_gridciv2_Callback(hObject, eventdata, handles) |
|---|
| 3605 | % |
|---|
| 3606 | % filebase=get(handles.RootName,'String'); |
|---|
| 3607 | % [FileName, PathName, filterindex] = uigetfile( ... |
|---|
| 3608 | % {'*.grid', ' (*.grid)'; |
|---|
| 3609 | % '*.grid', '.grid files '; ... |
|---|
| 3610 | % '*.*', 'All Files (*.*)'}, ... |
|---|
| 3611 | % 'Pick a file',filebase); |
|---|
| 3612 | % filegrid=fullfile(PathName,FileName); |
|---|
| 3613 | % set(handles.grid_civ2,'string',filegrid); |
|---|
| 3614 | % set(handles.dx_civ2,'String',' '); |
|---|
| 3615 | % set(handles.dy_civ2,'String',' '); |
|---|
| 3616 | % % set(handles.grid_patch2,'string',filegrid); |
|---|
| 3617 | |
|---|
| 3618 | % --- Executes on button press in get_gridpatch1. |
|---|
| 3619 | function get_gridpatch1_Callback(hObject, eventdata, handles) |
|---|
| 3620 | % hObject handle to get_gridpatch1 (see GCBO) |
|---|
| 3621 | % eventdata reserved - to be defined in a future version of MATLAB |
|---|
| 3622 | % handles structure with handles and user data (see GUIDATA) |
|---|
| 3623 | |
|---|
| 3624 | filebase=get(handles.RootName,'String'); |
|---|
| 3625 | [FileName, PathName, filterindex] = uigetfile( ... |
|---|
| 3626 | {'*.grid', ' (*.grid)'; |
|---|
| 3627 | '*.grid', '.grid files '; ... |
|---|
| 3628 | '*.*', 'All Files (*.*)'}, ... |
|---|
| 3629 | 'Pick a file',filebase); |
|---|
| 3630 | filegrid=fullfile(PathName,FileName); |
|---|
| 3631 | set(handles.grid_patch1,'string',filegrid); |
|---|
| 3632 | % set(handles.grid_patch2,'string',filegrid |
|---|
| 3633 | |
|---|
| 3634 | %------------------------------------------------------------------------ |
|---|
| 3635 | % --- Executes on button press in get_gridpatch2. |
|---|
| 3636 | function get_gridpatch2_Callback(hObject, eventdata, handles) |
|---|
| 3637 | %------------------------------------------------------------------------ |
|---|
| 3638 | |
|---|
| 3639 | %------------------------------------------------------------------------ |
|---|
| 3640 | function enable_civ1(handles,state) |
|---|
| 3641 | %------------------------------------------------------------------------ |
|---|
| 3642 | if isequal(state,0) |
|---|
| 3643 | state='off'; |
|---|
| 3644 | end |
|---|
| 3645 | if isequal(state,1) |
|---|
| 3646 | state='on'; |
|---|
| 3647 | end |
|---|
| 3648 | if isequal(state,'on') |
|---|
| 3649 | set(handles.frame_civ1,'BackgroundColor',[1 1 0]) |
|---|
| 3650 | set(handles.frame_para_civ1,'BackgroundColor',[1 1 0]) |
|---|
| 3651 | set(handles.frame_grid_civ1,'BackgroundColor',[1 1 0]) |
|---|
| 3652 | else |
|---|
| 3653 | set(handles.frame_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
|---|
| 3654 | set(handles.frame_para_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
|---|
| 3655 | set(handles.frame_grid_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
|---|
| 3656 | end |
|---|
| 3657 | set(handles.ibx,'Visible',state) |
|---|
| 3658 | set(handles.iby,'Visible',state) |
|---|
| 3659 | set(handles.isx,'Visible',state) |
|---|
| 3660 | set(handles.isy,'Visible',state) |
|---|
| 3661 | set(handles.shiftx,'Visible',state) |
|---|
| 3662 | set(handles.shifty,'Visible',state) |
|---|
| 3663 | set(handles.rho,'Visible',state) |
|---|
| 3664 | set(handles.dx_civ1,'Visible',state) |
|---|
| 3665 | set(handles.dy_civ1,'Visible',state) |
|---|
| 3666 | set(handles.calcul_search,'Visible',state) |
|---|
| 3667 | set(handles.u_text,'Visible',state) |
|---|
| 3668 | set(handles.v_text,'Visible',state) |
|---|
| 3669 | set(handles.min,'Visible',state) |
|---|
| 3670 | set(handles.max,'Visible',state) |
|---|
| 3671 | set(handles.umin,'Visible',state) |
|---|
| 3672 | set(handles.umax,'Visible',state) |
|---|
| 3673 | set(handles.vmin,'Visible',state) |
|---|
| 3674 | set(handles.vmax,'Visible',state) |
|---|
| 3675 | set(handles.grid_civ1,'Visible',state) |
|---|
| 3676 | set(handles.mask_civ1,'Visible',state) |
|---|
| 3677 | set(handles.browse_gridciv1,'Visible',state) |
|---|
| 3678 | set(handles.get_mask_civ1,'Visible',state) |
|---|
| 3679 | set(handles.parameters,'Visible',state) |
|---|
| 3680 | set(handles.grid,'Visible',state) |
|---|
| 3681 | set(handles.dx_civ1,'Visible',state) |
|---|
| 3682 | set(handles.dy_civ1,'Visible',state) |
|---|
| 3683 | set(handles.ImaThreshold,'Visible',state) |
|---|
| 3684 | if isequal(state,'off') |
|---|
| 3685 | set(handles.MinIma,'Visible','off') |
|---|
| 3686 | set(handles.MaxIma,'Visible','off') |
|---|
| 3687 | set(handles.ImaThreshold,'Value',0) |
|---|
| 3688 | end |
|---|
| 3689 | set(handles.dx_civ1_title,'Visible',state) |
|---|
| 3690 | set(handles.dy_civ1_title,'Visible',state) |
|---|
| 3691 | set(handles.ImaThreshold_title,'Visible',state) |
|---|
| 3692 | set(handles.ib_title,'Visible',state) |
|---|
| 3693 | set(handles.is_title,'Visible',state) |
|---|
| 3694 | set(handles.shift_title,'Visible',state) |
|---|
| 3695 | set(handles.rho_title,'Visible',state) |
|---|
| 3696 | |
|---|
| 3697 | %------------------------------------------------------------------------ |
|---|
| 3698 | function enable_fix1(handles,state) |
|---|
| 3699 | %------------------------------------------------------------------------ |
|---|
| 3700 | if isequal(state,0) |
|---|
| 3701 | state='off'; |
|---|
| 3702 | end |
|---|
| 3703 | if isequal(state,1) |
|---|
| 3704 | state='on'; |
|---|
| 3705 | end |
|---|
| 3706 | if isequal(state,'on') |
|---|
| 3707 | set(handles.frame_fix1,'BackgroundColor',[1 1 0]) |
|---|
| 3708 | else |
|---|
| 3709 | set(handles.frame_fix1,'BackgroundColor',[0.7 0.7 0.7]) |
|---|
| 3710 | end |
|---|
| 3711 | set(handles.REMOVE,'Visible',state) |
|---|
| 3712 | set(handles.vec_Fmin2,'Visible',state) |
|---|
| 3713 | set(handles.vec_F2,'Visible',state) |
|---|
| 3714 | set(handles.vec_F3,'Visible',state) |
|---|
| 3715 | set(handles.thresh_vecC,'Visible',state) |
|---|
| 3716 | set(handles.thresh_vecC_title,'Visible',state) |
|---|
| 3717 | set(handles.thresh_vel,'Visible',state) |
|---|
| 3718 | set(handles.thresh_vel_text,'Visible',state) |
|---|
| 3719 | set(handles.mask_fix1,'Visible',state) |
|---|
| 3720 | set(handles.get_mask_fix1,'Visible',state) |
|---|
| 3721 | set(handles.get_ref_fix1,'Visible',state) |
|---|
| 3722 | set(handles.ref_fix1,'Visible',state) |
|---|
| 3723 | set(handles.inf_sup1,'Visible',state) |
|---|
| 3724 | set(handles.field_ref1,'Visible',state) |
|---|
| 3725 | |
|---|
| 3726 | %------------------------------------------------------------------------ |
|---|
| 3727 | function enable_patch1(handles) |
|---|
| 3728 | %------------------------------------------------------------------------ |
|---|
| 3729 | global patch_newBin |
|---|
| 3730 | set(handles.frame_patch1,'BackgroundColor',[1 1 0]) |
|---|
| 3731 | set(handles.rho_patch1,'Visible','on') |
|---|
| 3732 | set(handles.rho_text1,'Visible','on') |
|---|
| 3733 | set(handles.thresh_patch1,'Visible','on') |
|---|
| 3734 | set(handles.thresh_text1,'Visible','on') |
|---|
| 3735 | set(handles.subdomain_patch1,'Visible','on') |
|---|
| 3736 | set(handles.subdomain_text1,'Visible','on') |
|---|
| 3737 | set(handles.nx_patch1,'Visible','on') |
|---|
| 3738 | set(handles.ny_patch1,'Visible','on') |
|---|
| 3739 | set(handles.nx_patch1_title,'Visible','on') |
|---|
| 3740 | set(handles.ny_patch1_title,'Visible','on') |
|---|
| 3741 | % if ~isempty(patch_newBin) |
|---|
| 3742 | % set(handles.test_interp,'Visible','on'); |
|---|
| 3743 | % end |
|---|
| 3744 | set(handles.get_gridpatch1,'Visible','on') |
|---|
| 3745 | set(handles.grid_patch1,'string','none'); |
|---|
| 3746 | set(handles.grid_patch1,'Visible','on') |
|---|
| 3747 | |
|---|
| 3748 | %------------------------------------------------------------------------ |
|---|
| 3749 | function desable_patch1(handles) |
|---|
| 3750 | %------------------------------------------------------------------------ |
|---|
| 3751 | set(handles.frame_patch1,'BackgroundColor',[0.831 0.816 0.784]) |
|---|
| 3752 | set(handles.rho_patch1,'Visible','off') |
|---|
| 3753 | set(handles.rho_text1,'Visible','off') |
|---|
| 3754 | set(handles.thresh_patch1,'Visible','off') |
|---|
| 3755 | set(handles.thresh_text1,'Visible','off') |
|---|
| 3756 | set(handles.subdomain_patch1,'Visible','off') |
|---|
| 3757 | set(handles.subdomain_text1,'Visible','off') |
|---|
| 3758 | set(handles.nx_patch1,'Visible','off') |
|---|
| 3759 | set(handles.ny_patch1,'Visible','off') |
|---|
| 3760 | set(handles.nx_patch1_title,'Visible','off') |
|---|
| 3761 | set(handles.ny_patch1_title,'Visible','off') |
|---|
| 3762 | %set(handles.test_interp,'Visible','off') |
|---|
| 3763 | set(handles.get_gridpatch1,'Visible','off') |
|---|
| 3764 | set(handles.grid_patch1,'Visible','off') |
|---|
| 3765 | |
|---|
| 3766 | %------------------------------------------------------------------------ |
|---|
| 3767 | function enable_civ2(handles,state) |
|---|
| 3768 | %------------------------------------------------------------------------ |
|---|
| 3769 | if isequal(state,0) |
|---|
| 3770 | state='off'; |
|---|
| 3771 | end |
|---|
| 3772 | if isequal(state,1) |
|---|
| 3773 | state='on'; |
|---|
| 3774 | end |
|---|
| 3775 | if isequal(state,'on') |
|---|
| 3776 | set(handles.frame_civ2,'BackgroundColor',[1 1 0]) |
|---|
| 3777 | set(handles.frame_para_civ2,'BackgroundColor',[1 1 0]) |
|---|
| 3778 | set(handles.frame_grid_civ2,'BackgroundColor',[1 1 0]) |
|---|
| 3779 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
|---|
| 3780 | else |
|---|
| 3781 | set(handles.frame_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
|---|
| 3782 | set(handles.frame_para_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
|---|
| 3783 | set(handles.frame_grid_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
|---|
| 3784 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
|---|
| 3785 | end |
|---|
| 3786 | set(handles.ibx_civ2,'Visible',state) |
|---|
| 3787 | set(handles.iby_civ2,'Visible',state) |
|---|
| 3788 | set(handles.decimal,'Visible',state) |
|---|
| 3789 | set(handles.deformation,'Visible',state) |
|---|
| 3790 | set(handles.rho_civ2,'Visible',state) |
|---|
| 3791 | set(handles.dx_civ2,'Visible',state) |
|---|
| 3792 | set(handles.dy_civ2,'Visible',state) |
|---|
| 3793 | set(handles.browse_gridciv2,'Visible',state) |
|---|
| 3794 | set(handles.get_mask_civ2,'Visible',state) |
|---|
| 3795 | set(handles.parameters,'Visible',state) |
|---|
| 3796 | set(handles.grid,'Visible',state) |
|---|
| 3797 | set(handles.parameters_text,'Visible',state) |
|---|
| 3798 | set(handles.grid_text,'Visible',state) |
|---|
| 3799 | set(handles.grid_civ2,'Visible',state) |
|---|
| 3800 | set(handles.mask_civ2,'Visible',state) |
|---|
| 3801 | set(handles.dx_civ2_title,'Visible',state) |
|---|
| 3802 | set(handles.dy_civ2_title,'Visible',state) |
|---|
| 3803 | set(handles.ibx_civ2_text,'Visible',state) |
|---|
| 3804 | set(handles.rho_civ2_title,'Visible',state) |
|---|
| 3805 | set(handles.ImaThreshold2,'Visible',state) |
|---|
| 3806 | set(handles.ImaThreshold_title2,'Visible',state) |
|---|
| 3807 | if isequal(state,'off') |
|---|
| 3808 | set(handles.MinIma2,'Visible','off') |
|---|
| 3809 | set(handles.MaxIma2,'Visible','off') |
|---|
| 3810 | set(handles.ImaThreshold2,'Value',0) |
|---|
| 3811 | if isequal(get(handles.FIX2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) |
|---|
| 3812 | set(handles.list_pair_civ2,'Visible','off') |
|---|
| 3813 | set(handles.subdir_civ2,'Visible','off') |
|---|
| 3814 | set(handles.subdir_civ2_text,'Visible','off') |
|---|
| 3815 | set(handles.dt_unit_civ2,'Visible','off') |
|---|
| 3816 | set(handles.ref_i_civ2,'Visible','off') |
|---|
| 3817 | set(handles.i_ref_civ2_title,'Visible','off') |
|---|
| 3818 | set(handles.j_ref_civ2_title,'Visible','off') |
|---|
| 3819 | set(handles.ref_j_civ2,'Visible','off') |
|---|
| 3820 | end |
|---|
| 3821 | else |
|---|
| 3822 | set(handles.list_pair_civ2,'Visible','on') |
|---|
| 3823 | set(handles.subdir_civ2,'Visible','on') |
|---|
| 3824 | set(handles.subdir_civ2_text,'Visible','on') |
|---|
| 3825 | set(handles.dt_unit_civ2,'Visible','on') |
|---|
| 3826 | set(handles.ref_i_civ2,'Visible','on') |
|---|
| 3827 | set(handles.i_ref_civ2_title,'Visible','on') |
|---|
| 3828 | set(handles.j_ref_civ2_title,'Visible','on') |
|---|
| 3829 | set(handles.ref_j_civ2,'Visible','on') |
|---|
| 3830 | end |
|---|
| 3831 | set(handles.rho_civ2_title,'Visible',state) |
|---|
| 3832 | |
|---|
| 3833 | %------------------------------------------------------------------------ |
|---|
| 3834 | function enable_fix2(handles) |
|---|
| 3835 | %------------------------------------------------------------------------ |
|---|
| 3836 | set(handles.frame_fix2,'BackgroundColor',[1 1 0]) |
|---|
| 3837 | set(handles.REMOVE2,'Visible','on') |
|---|
| 3838 | set(handles.vec_Fmin2_2,'Visible','on') |
|---|
| 3839 | set(handles.vec_F4,'Visible','on') |
|---|
| 3840 | set(handles.vec_F3_2,'Visible','on') |
|---|
| 3841 | set(handles.thresh_vec2C,'Visible','on') |
|---|
| 3842 | set(handles.thresh_vec2C_text,'Visible','on') |
|---|
| 3843 | set(handles.thresh_vel2,'Visible','on') |
|---|
| 3844 | set(handles.thresh_vel2_text,'Visible','on') |
|---|
| 3845 | set(handles.mask_fix2,'Visible','on') |
|---|
| 3846 | set(handles.get_mask_fix2,'Visible','on') |
|---|
| 3847 | set(handles.list_pair_civ2,'Visible','on') |
|---|
| 3848 | set(handles.subdir_civ2,'Visible','on') |
|---|
| 3849 | set(handles.subdir_civ2_text,'Visible','on') |
|---|
| 3850 | set(handles.get_ref_fix2,'Visible','on') |
|---|
| 3851 | set(handles.ref_fix2,'Visible','on') |
|---|
| 3852 | set(handles.inf_sup2,'Visible','on') |
|---|
| 3853 | set(handles.field_ref2,'Visible','on') |
|---|
| 3854 | |
|---|
| 3855 | %------------------------------------------------------------------------ |
|---|
| 3856 | function desable_fix2(handles) |
|---|
| 3857 | %------------------------------------------------------------------------ |
|---|
| 3858 | set(handles.frame_fix2,'BackgroundColor',[0.831 0.816 0.784]) |
|---|
| 3859 | set(handles.REMOVE2,'Visible','off') |
|---|
| 3860 | set(handles.vec_Fmin2_2,'Visible','off') |
|---|
| 3861 | set(handles.vec_F4,'Visible','off') |
|---|
| 3862 | set(handles.vec_F3_2,'Visible','off') |
|---|
| 3863 | set(handles.thresh_vec2C,'Visible','off') |
|---|
| 3864 | set(handles.thresh_vec2C_text,'Visible','off') |
|---|
| 3865 | set(handles.thresh_vel2,'Visible','off') |
|---|
| 3866 | set(handles.thresh_vel2_text,'Visible','off') |
|---|
| 3867 | set(handles.mask_fix2,'Visible','off') |
|---|
| 3868 | set(handles.get_mask_fix2,'Visible','off') |
|---|
| 3869 | set(handles.get_ref_fix2,'Visible','off') |
|---|
| 3870 | set(handles.ref_fix2,'Visible','off') |
|---|
| 3871 | set(handles.inf_sup2,'Visible','off') |
|---|
| 3872 | set(handles.field_ref2,'Visible','off') |
|---|
| 3873 | if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) |
|---|
| 3874 | set(handles.list_pair_civ2,'Visible','off') |
|---|
| 3875 | set(handles.subdir_civ2,'Visible','off') |
|---|
| 3876 | set(handles.subdir_civ2_text,'Visible','off') |
|---|
| 3877 | end |
|---|
| 3878 | |
|---|
| 3879 | %------------------------------------------------------------------------ |
|---|
| 3880 | function enable_patch2(handles) |
|---|
| 3881 | %------------------------------------------------------------------------ |
|---|
| 3882 | set(handles.frame_patch2,'BackgroundColor',[1 1 0]) |
|---|
| 3883 | set(handles.rho_patch2,'Visible','on') |
|---|
| 3884 | set(handles.rho_text2,'Visible','on') |
|---|
| 3885 | set(handles.thresh_patch2,'Visible','on') |
|---|
| 3886 | set(handles.thresh_text2,'Visible','on') |
|---|
| 3887 | set(handles.subdomain_patch2,'Visible','on') |
|---|
| 3888 | set(handles.subdomain_text2,'Visible','on') |
|---|
| 3889 | set(handles.nx_patch2,'Visible','on') |
|---|
| 3890 | set(handles.ny_patch2,'Visible','on') |
|---|
| 3891 | set(handles.nx_patch2_title,'Visible','on') |
|---|
| 3892 | set(handles.ny_patch2_title,'Visible','on') |
|---|
| 3893 | set(handles.get_gridpatch2,'Visible','on') |
|---|
| 3894 | set(handles.grid_patch2,'Visible','on') |
|---|
| 3895 | set(handles.list_pair_civ2,'Visible','on') |
|---|
| 3896 | set(handles.subdir_civ2,'Visible','on') |
|---|
| 3897 | set(handles.subdir_civ2_text,'Visible','on') |
|---|
| 3898 | |
|---|
| 3899 | %------------------------------------------------------------------------ |
|---|
| 3900 | function desable_patch2(handles) |
|---|
| 3901 | %------------------------------------------------------------------------ |
|---|
| 3902 | set(handles.frame_patch2,'BackgroundColor',[0.831 0.816 0.784]) |
|---|
| 3903 | set(handles.rho_patch2,'Visible','off') |
|---|
| 3904 | set(handles.rho_text2,'Visible','off') |
|---|
| 3905 | set(handles.thresh_patch2,'Visible','off') |
|---|
| 3906 | set(handles.thresh_text2,'Visible','off') |
|---|
| 3907 | set(handles.subdomain_patch2,'Visible','off') |
|---|
| 3908 | set(handles.subdomain_text2,'Visible','off') |
|---|
| 3909 | set(handles.nx_patch2,'Visible','off') |
|---|
| 3910 | set(handles.ny_patch2,'Visible','off') |
|---|
| 3911 | set(handles.nx_patch2_title,'Visible','off') |
|---|
| 3912 | set(handles.ny_patch2_title,'Visible','off') |
|---|
| 3913 | set(handles.get_gridpatch2,'Visible','off') |
|---|
| 3914 | set(handles.grid_patch2,'Visible','off') |
|---|
| 3915 | if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.FIX2,'Value'),0) |
|---|
| 3916 | set(handles.list_pair_civ2,'Visible','off') |
|---|
| 3917 | set(handles.subdir_civ2,'Visible','off') |
|---|
| 3918 | set(handles.subdir_civ2_text,'Visible','off') |
|---|
| 3919 | end |
|---|
| 3920 | |
|---|
| 3921 | %------------------------------------------------------------------------ |
|---|
| 3922 | function enable_pair1(handles,state) |
|---|
| 3923 | %------------------------------------------------------------------------ |
|---|
| 3924 | set(handles.subdir_civ1,'Visible',state) |
|---|
| 3925 | set(handles.list_subdir_civ1,'Visible',state) |
|---|
| 3926 | set(handles.SUBDIR_CIV1_txt,'Visible',state) |
|---|
| 3927 | set(handles.frame_subdirciv1,'Visible',state) |
|---|
| 3928 | set(handles.list_pair_civ1,'Visible',state) |
|---|
| 3929 | set(handles.PAIR_txt,'Visible',state) |
|---|
| 3930 | %set(handles.dt_unit,'Visible',state) |
|---|
| 3931 | set(handles.PAIR_frame,'Visible',state) |
|---|
| 3932 | |
|---|
| 3933 | %------------------------------------------------------------------------ |
|---|
| 3934 | % --- Read the parameters for civ1 on the interface |
|---|
| 3935 | function par=read_param_civ1(handles,file_ima) |
|---|
| 3936 | %------------------------------------------------------------------------ |
|---|
| 3937 | ibx_val=str2double(get(handles.ibx,'String')); |
|---|
| 3938 | par.ibx=num2str(ibx_val); |
|---|
| 3939 | iby_val=str2double(get(handles.iby,'String')); |
|---|
| 3940 | par.iby=num2str(iby_val); |
|---|
| 3941 | isx=get(handles.isx,'String'); |
|---|
| 3942 | if isnan(str2double(isx)), isx='41'; set(handles.isx,'String','41'), end; %default |
|---|
| 3943 | if str2double(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.isx,'String',num2str(ibx_val+8)); end |
|---|
| 3944 | isy=get(handles.isy,'String'); |
|---|
| 3945 | if isnan(str2double(isy)), isy='41'; set(handles.isy,'String','41'), end;%default |
|---|
| 3946 | if str2double(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.isy,'String',num2str(iby_val+8)); end |
|---|
| 3947 | par.isx=get(handles.isx,'String'); |
|---|
| 3948 | par.isy=get(handles.isy,'String'); |
|---|
| 3949 | par.shiftx=get(handles.shiftx,'String'); |
|---|
| 3950 | par.shifty=get(handles.shifty,'String'); |
|---|
| 3951 | if isnan(str2double(par.isx)) |
|---|
| 3952 | par.isx='41';%default |
|---|
| 3953 | set(handles.isx,'String','41'); |
|---|
| 3954 | end |
|---|
| 3955 | if isnan(str2double(par.isy)) |
|---|
| 3956 | par.isy='41'; %default |
|---|
| 3957 | set(handles.isy,'String','41'); |
|---|
| 3958 | end |
|---|
| 3959 | if isnan(str2double(par.shiftx)) |
|---|
| 3960 | par.shiftx='0';%default |
|---|
| 3961 | set(handles.shiftx,'String','0'); |
|---|
| 3962 | end |
|---|
| 3963 | if isnan(str2double(par.shifty)) |
|---|
| 3964 | par.shifty='0'; %default |
|---|
| 3965 | set(handles.shifty,'String','0'); |
|---|
| 3966 | end |
|---|
| 3967 | par.rho=get(handles.rho,'String'); |
|---|
| 3968 | par.dx=get(handles.dx_civ1,'String'); |
|---|
| 3969 | par.dy=get(handles.dy_civ1,'String'); |
|---|
| 3970 | if isnan(str2double(par.dx)) |
|---|
| 3971 | if isempty(get(handles.grid_civ1,'String')); |
|---|
| 3972 | par.dx='0'; %just read by civ program, not used |
|---|
| 3973 | else |
|---|
| 3974 | par.dx='20';%default |
|---|
| 3975 | set(handles.dx_civ1,'String','20'); |
|---|
| 3976 | end |
|---|
| 3977 | end |
|---|
| 3978 | if isnan(str2double(par.dy)) |
|---|
| 3979 | if isempty(get(handles.grid_civ1,'String')); |
|---|
| 3980 | par.dy='0';%just read by civ program, not used |
|---|
| 3981 | else |
|---|
| 3982 | par.dy='20';%default |
|---|
| 3983 | set(handles.dy_civ1_title,'String','20'); |
|---|
| 3984 | end |
|---|
| 3985 | end |
|---|
| 3986 | par.pxcmx='1'; %velocities are expressed in pixel dispalcement |
|---|
| 3987 | par.pxcmy='1'; |
|---|
| 3988 | if exist('file_ima','var') |
|---|
| 3989 | A=imread(file_ima);%read the first image to get the size |
|---|
| 3990 | sizim=size(A); |
|---|
| 3991 | par.npx=num2str(sizim(2)); |
|---|
| 3992 | par.npy=num2str(sizim(1)); |
|---|
| 3993 | end |
|---|
| 3994 | %time=get(handles.RootName,'UserData'); %get the set of times |
|---|
| 3995 | par.gridname=get(handles.grid_civ1,'String'); |
|---|
| 3996 | par.gridflag='y'; |
|---|
| 3997 | if strcmp(par.gridname,'')|| isempty(par.gridname) |
|---|
| 3998 | par.gridname='nogrid'; |
|---|
| 3999 | par.gridflag='n'; |
|---|
| 4000 | end |
|---|
| 4001 | |
|---|
| 4002 | %------------------------------------------------------------------------ |
|---|
| 4003 | function par=read_param_civ2(handles,file_ima) |
|---|
| 4004 | %------------------------------------------------------------------------ |
|---|
| 4005 | par.ibx=get(handles.ibx_civ2,'String'); |
|---|
| 4006 | par.iby=get(handles.iby_civ2,'String'); |
|---|
| 4007 | par.rho=get(handles.rho_civ2,'String'); |
|---|
| 4008 | par.decimal=int2str(get(handles.decimal,'Value')); |
|---|
| 4009 | par.deformation=int2str(get(handles.deformation,'Value')); |
|---|
| 4010 | par.dx=get(handles.dx_civ2,'String'); |
|---|
| 4011 | par.dy=get(handles.dy_civ2,'String'); |
|---|
| 4012 | if isnan(str2double(par.dx)) |
|---|
| 4013 | if isempty(get(handles.grid_civ2,'String')); |
|---|
| 4014 | par.dx='0'; %just read by civ program, not used |
|---|
| 4015 | else |
|---|
| 4016 | par.dx='20';%default |
|---|
| 4017 | set(handles.dx_civ2,'String','20'); |
|---|
| 4018 | end |
|---|
| 4019 | end |
|---|
| 4020 | if isnan(str2double(par.dy)) |
|---|
| 4021 | if isempty(get(handles.grid_civ2,'String')); |
|---|
| 4022 | par.dy='0';%just read by civ program, not used |
|---|
| 4023 | else |
|---|
| 4024 | par.dy='20';%default |
|---|
| 4025 | set(handles.dy_civ2,'String','20'); |
|---|
| 4026 | end |
|---|
| 4027 | end |
|---|
| 4028 | par.pxcmx='1'; |
|---|
| 4029 | par.pxcmy='1'; |
|---|
| 4030 | A=imread(file_ima);%read the first image to get the size |
|---|
| 4031 | sizim=size(A); |
|---|
| 4032 | par.npx=num2str(sizim(2)); |
|---|
| 4033 | par.npy=num2str(sizim(1)); |
|---|
| 4034 | %time=get(handles.RootName,'UserData'); %get the set of times |
|---|
| 4035 | par.gridname=get(handles.grid_civ2,'String'); |
|---|
| 4036 | par.gridflag='y'; |
|---|
| 4037 | if strcmp(par.gridname,'')|| isempty(par.gridname) |
|---|
| 4038 | par.gridname='nogrid'; |
|---|
| 4039 | par.gridflag='n'; |
|---|
| 4040 | end |
|---|
| 4041 | |
|---|
| 4042 | %------------------------------------------------------------------------ |
|---|
| 4043 | % --- CIV1 CIV1 CIV1 CIV1 |
|---|
| 4044 | function cmd_CIV1=CIV1_CMD(filename,namelog,par,handles,sparam) |
|---|
| 4045 | %------------------------------------------------------------------------ |
|---|
| 4046 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
|---|
| 4047 | |
|---|
| 4048 | %changes : filename_cmx -> filename ( no extension ) |
|---|
| 4049 | % input namelog not used |
|---|
| 4050 | if isequal(par.Dt,'0') |
|---|
| 4051 | par.Dt='1' ;%case of 'displacement' mode |
|---|
| 4052 | end |
|---|
| 4053 | par.filename_ima_a=regexprep(par.filename_ima_a,'.png',''); |
|---|
| 4054 | par.filename_ima_b=regexprep(par.filename_ima_b,'.png',''); |
|---|
| 4055 | fid=fopen([filename '.cmx'],'w'); |
|---|
| 4056 | fprintf(fid,['############## CMX file' '\n' ]); |
|---|
| 4057 | fprintf(fid, ['FirstImage ' regexprep(par.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility |
|---|
| 4058 | fprintf(fid, ['LastImage ' regexprep(par.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility |
|---|
| 4059 | fprintf(fid, ['XX' '\n' ]); |
|---|
| 4060 | fprintf(fid, ['Mask ' par.maskflag '\n' ]); |
|---|
| 4061 | fprintf(fid, ['MaskName ' regexprep(par.maskname,'\\','\\\\') '\n' ]); |
|---|
| 4062 | fprintf(fid, ['ImageSize ' par.npx ' ' par.npy '\n' ]); %VERIFIER CAS GENERAL ? |
|---|
| 4063 | fprintf(fid, ['CorrelationBoxesSize ' par.ibx ' ' par.iby '\n' ]); |
|---|
| 4064 | fprintf(fid, ['SearchBoxeSize ' par.isx ' ' par.isy '\n' ]); |
|---|
| 4065 | fprintf(fid, ['RO ' par.rho '\n' ]); |
|---|
| 4066 | fprintf(fid, ['GridSpacing ' par.dx ' ' par.dy '\n' ]); |
|---|
| 4067 | fprintf(fid, ['XX 1.0' '\n' ]); |
|---|
| 4068 | fprintf(fid, ['Dt_TO ' par.Dt ' ' par.T0 '\n' ]); |
|---|
| 4069 | fprintf(fid, ['PixCmXY ' par.pxcmx ' ' par.pxcmy '\n' ]); |
|---|
| 4070 | fprintf(fid, ['XX 1' '\n' ]); |
|---|
| 4071 | fprintf(fid, ['ShiftXY ' par.shiftx ' ' par.shifty '\n' ]); |
|---|
| 4072 | fprintf(fid, ['Grid ' par.gridflag '\n' ]); |
|---|
| 4073 | fprintf(fid, ['GridName ' regexprep(par.gridname,'\\','\\\\') '\n' ]); |
|---|
| 4074 | fprintf(fid, ['XX 85' '\n' ]); |
|---|
| 4075 | fprintf(fid, ['XX 1.0' '\n' ]); |
|---|
| 4076 | fprintf(fid, ['XX 1.0' '\n' ]); |
|---|
| 4077 | fprintf(fid, ['Hart 1' '\n' ]); |
|---|
| 4078 | fprintf(fid, [ 'DecimalShift 0' '\n' ]); |
|---|
| 4079 | fprintf(fid, ['Deformation 0' '\n' ]); |
|---|
| 4080 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
|---|
| 4081 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
|---|
| 4082 | fprintf(fid, ['SeuilImage n' '\n' ]); |
|---|
| 4083 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
|---|
| 4084 | fprintf(fid, ['ImageToUse ' par.term_a ' ' par.term_b '\n' ]); % VERIFIER ? |
|---|
| 4085 | fprintf(fid, ['ImageUsedBefore null null' '\n' ]); |
|---|
| 4086 | fclose(fid); |
|---|
| 4087 | |
|---|
| 4088 | % cmd_CIV1=[sparam.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file |
|---|
| 4089 | % cmd_CIV1=regexprep(cmd_CIV1,'\\','\\\\'); |
|---|
| 4090 | % namelog=regexprep(namelog,'\\','\\\\'); |
|---|
| 4091 | if(isunix) |
|---|
| 4092 | % filename |
|---|
| 4093 | % namelog |
|---|
| 4094 | % |
|---|
| 4095 | % [Rootbat,Filebat,extbat]=fileparts(namelog); |
|---|
| 4096 | % ncName=fullfile(Rootbat,[ Filebat '.nc']); |
|---|
| 4097 | cmd_CIV1=[sparam.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx |
|---|
| 4098 | cmd_CIV1=[cmd_CIV1 '\n' 'mv ' filename '.log' ' ' filename '.civ1.log' '\n' 'chmod g+w ' filename '.nc'];%rename .log as .civ1.log and set the netcdf result file for group user writting |
|---|
| 4099 | cmd_CIV1=[cmd_CIV1 '\n' 'mv ' filename '.cmx' ' ' filename '.civ1.cmx' '\n'];%rename .cmx as .civ1.cmx |
|---|
| 4100 | else %Windows system |
|---|
| 4101 | filename=regexprep(filename,'\\','\\\\'); |
|---|
| 4102 | cmd_CIV1=['"' sparam.Civ1Bin '" -f "' filename '.cmx" >"' filename '.log"' ]; % redirect standard output to the log file |
|---|
| 4103 | cmd_CIV1=regexprep(cmd_CIV1,'\\','\\\\'); |
|---|
| 4104 | namelog=regexprep(namelog,'\\','\\\\'); |
|---|
| 4105 | cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y "' filename '.log' '" "' filename '.civ1.log"']; |
|---|
| 4106 | cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y "' filename '.cmx' '" "' filename '.civ1.cmx"']; |
|---|
| 4107 | end |
|---|
| 4108 | |
|---|
| 4109 | %------------------------------------------------------------------------ |
|---|
| 4110 | % --- CIV1 Unified |
|---|
| 4111 | function xml_civ1_parameters=CIV1_CMD_Unified(filename,namelog,par) |
|---|
| 4112 | %------------------------------------------------------------------------ |
|---|
| 4113 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
|---|
| 4114 | %global CivBin%name of the executable for civ1 calculation |
|---|
| 4115 | |
|---|
| 4116 | civ1.image1=par.filename_ima_a; |
|---|
| 4117 | civ1.image2=par.filename_ima_b; |
|---|
| 4118 | civ1.imageSize_X=par.npx; |
|---|
| 4119 | civ1.imageSize_Y=par.npy; |
|---|
| 4120 | civ1.outputFileName=[filename '.nc']; |
|---|
| 4121 | civ1.correlationBoxesSize_X=par.ibx; |
|---|
| 4122 | civ1.correlationBoxesSize_Y=par.iby; |
|---|
| 4123 | civ1.searchBoxesSize_X=par.isx; |
|---|
| 4124 | civ1.searchBoxesSize_Y=par.isy; |
|---|
| 4125 | civ1.globalShift_X=par.shiftx; |
|---|
| 4126 | civ1.globalShift_Y=par.shifty; |
|---|
| 4127 | civ1.ro=par.rho; |
|---|
| 4128 | civ1.hart='y'; |
|---|
| 4129 | if isequal(par.gridflag,'y') |
|---|
| 4130 | civ1.grid=par.gridname; |
|---|
| 4131 | else |
|---|
| 4132 | civ1.grid='n'; |
|---|
| 4133 | civ1.gridSpacing_X=par.dx; |
|---|
| 4134 | civ1.gridSpacing_Y=par.dy; |
|---|
| 4135 | end |
|---|
| 4136 | if isequal(par.maskflag,'y') |
|---|
| 4137 | civ1.mask=par.maskname; |
|---|
| 4138 | end |
|---|
| 4139 | civ1.dt=par.Dt; |
|---|
| 4140 | civ1.unit='pixel'; |
|---|
| 4141 | civ1.absolut_time_T0=par.T0; |
|---|
| 4142 | civ1.pixcmx=par.pxcmx; |
|---|
| 4143 | civ1.pixcmy=par.pxcmy; |
|---|
| 4144 | civ1.convectFlow='n'; |
|---|
| 4145 | |
|---|
| 4146 | xml_civ1_parameters=civ1; |
|---|
| 4147 | |
|---|
| 4148 | %------------------------------------------------------------------------ |
|---|
| 4149 | % --- CIV2 Unified |
|---|
| 4150 | function civ2=CIV2_CMD_Unified(filename,namelog,par) |
|---|
| 4151 | %------------------------------------------------------------------------ |
|---|
| 4152 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
|---|
| 4153 | %global CivBin%name of the executable for civ1 calculation |
|---|
| 4154 | |
|---|
| 4155 | civ2.image1=par.filename_ima_a; |
|---|
| 4156 | civ2.image2=par.filename_ima_b; |
|---|
| 4157 | civ2.imageSize_X=par.npx; |
|---|
| 4158 | civ2.imageSize_Y=par.npy; |
|---|
| 4159 | civ2.inputFileName=[par.filename_nc1 '.nc']; |
|---|
| 4160 | civ2.outputFileName=[filename '.nc']; |
|---|
| 4161 | civ2.correlationBoxesSize_X=par.ibx; |
|---|
| 4162 | civ2.correlationBoxesSize_Y=par.iby; |
|---|
| 4163 | civ2.ro=par.rho; |
|---|
| 4164 | %civ2.decimalShift=par.decimal; |
|---|
| 4165 | %civ2.deformation=par.deformation; |
|---|
| 4166 | if isequal(par.decimal,'1') |
|---|
| 4167 | civ2.decimalShift='y'; |
|---|
| 4168 | else |
|---|
| 4169 | civ2.decimalShift='n'; |
|---|
| 4170 | end |
|---|
| 4171 | if isequal(par.deformation,'1') |
|---|
| 4172 | civ2.deformation='y'; |
|---|
| 4173 | else |
|---|
| 4174 | civ2.deformation='n'; |
|---|
| 4175 | end |
|---|
| 4176 | if isequal(par.gridflag,'y') |
|---|
| 4177 | civ2.grid=par.gridname; |
|---|
| 4178 | else |
|---|
| 4179 | civ2.grid='n'; |
|---|
| 4180 | civ2.gridSpacing_X=par.dx; |
|---|
| 4181 | civ2.gridSpacing_Y=par.dy; |
|---|
| 4182 | end |
|---|
| 4183 | civ2.gridSpacing_X='10'; |
|---|
| 4184 | civ2.gridSpacing_Y='10';%NOTE: faut mettre gridSpacing pourque ca tourne, meme si c'est la grille qui est utilisee |
|---|
| 4185 | if isequal(par.maskflag,'y') |
|---|
| 4186 | civ2.mask=par.maskname; |
|---|
| 4187 | else |
|---|
| 4188 | civ2.mask='n'; |
|---|
| 4189 | end |
|---|
| 4190 | civ2.dt=par.Dt; |
|---|
| 4191 | civ2.unit='pixel'; |
|---|
| 4192 | civ2.absolut_time_T0=par.T0; |
|---|
| 4193 | civ2.pixcmx=par.pxcmx; |
|---|
| 4194 | civ2.pixcmy=par.pxcmy; |
|---|
| 4195 | civ2.convectFlow='n'; |
|---|
| 4196 | civ2.pixcmx=par.pxcmx; |
|---|
| 4197 | civ2.pixcmy=par.pxcmy; |
|---|
| 4198 | civ2.convectFlow='n'; |
|---|
| 4199 | |
|---|
| 4200 | %------------------------------------------------------------------------ |
|---|
| 4201 | % --- CIV2 CIV2 CIV2 CIV2 |
|---|
| 4202 | function cmd_CIV2=CIV2_CMD(filename,namelog,par,sparam) |
|---|
| 4203 | %------------------------------------------------------------------------ |
|---|
| 4204 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
|---|
| 4205 | % global civ2Bin sge%name of the executable for civ1 calculation |
|---|
| 4206 | if isequal(par.Dt,'0') |
|---|
| 4207 | par.Dt='1' ;%case of 'displacement' mode |
|---|
| 4208 | end |
|---|
| 4209 | par.filename_ima_a=regexprep(par.filename_ima_a,'.png',''); |
|---|
| 4210 | par.filename_ima_b=regexprep(par.filename_ima_b,'.png','');% bug : .png appears two times ? |
|---|
| 4211 | [fid,errormsg]=fopen([filename '.civ2.cmx'],'w'); |
|---|
| 4212 | if isequal(fid,-1) |
|---|
| 4213 | msgbox_uvmat('ERROR',errormsg) |
|---|
| 4214 | cmd_CIV2=''; |
|---|
| 4215 | return |
|---|
| 4216 | end |
|---|
| 4217 | fprintf(fid,['############## CMX file' '\n' ]); |
|---|
| 4218 | fprintf(fid, ['FirstImage ' regexprep(par.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility |
|---|
| 4219 | fprintf(fid, ['LastImage ' regexprep(par.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility |
|---|
| 4220 | fprintf(fid, ['XX' '\n' ]); |
|---|
| 4221 | fprintf(fid, ['Mask ' par.maskflag '\n' ]); |
|---|
| 4222 | fprintf(fid, ['MaskName ' regexprep(par.maskname,'\\','\\\\') '\n' ]);% for windows compatibility |
|---|
| 4223 | fprintf(fid, ['ImageSize ' par.npx ' ' par.npy '\n' ]); %VERIFIER CAS GENERAL ? |
|---|
| 4224 | fprintf(fid, ['CorrelationBoxesSize ' par.ibx ' ' par.iby '\n' ]); |
|---|
| 4225 | fprintf(fid, ['SearchBoxeSize ' par.ibx ' ' par.iby '\n']); |
|---|
| 4226 | fprintf(fid, ['RO ' par.rho '\n']); |
|---|
| 4227 | fprintf(fid, ['GridSpacing ' par.dx ' ' par.dy '\n']); |
|---|
| 4228 | fprintf(fid, ['XX 1.0' '\n' ]); |
|---|
| 4229 | fprintf(fid, ['Dt_TO ' par.Dt ' ' par.T0 '\n' ]); |
|---|
| 4230 | fprintf(fid, ['PixCmXY ' par.pxcmx ' ' par.pxcmy '\n' ]); |
|---|
| 4231 | fprintf(fid, ['XX 1' '\n' ]); |
|---|
| 4232 | fprintf(fid, 'ShiftXY 0 0\n'); |
|---|
| 4233 | fprintf(fid, ['Grid ' par.gridflag '\n' ]); |
|---|
| 4234 | fprintf(fid, ['GridName ' regexprep(par.gridname,'\\','\\\\') '\n']); |
|---|
| 4235 | fprintf(fid, ['XX 85' '\n' ]); |
|---|
| 4236 | fprintf(fid, ['XX 1.0' '\n' ]); |
|---|
| 4237 | fprintf(fid, ['XX 1.0' '\n' ]); |
|---|
| 4238 | fprintf(fid, ['Hart 1' '\n' ]); |
|---|
| 4239 | fprintf(fid, ['DecimalShift ' par.decimal '\n']); |
|---|
| 4240 | fprintf(fid, ['Deformation ' par.deformation '\n']); |
|---|
| 4241 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
|---|
| 4242 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
|---|
| 4243 | fprintf(fid, ['SeuilImage n' '\n' ]); |
|---|
| 4244 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
|---|
| 4245 | fprintf(fid, ['ImageToUse ' par.term_a ' ' par.term_b '\n' ]); % VERIFIER ? |
|---|
| 4246 | fprintf(fid, ['ImageUsedBefore ' regexprep(par.filename_nc1,'\\','\\\\') '\n']); |
|---|
| 4247 | fclose(fid); |
|---|
| 4248 | |
|---|
| 4249 | if(isunix) |
|---|
| 4250 | % cmd_CIV1=[sparam.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx |
|---|
| 4251 | % cmd_CIV1=[cmd_CIV1 '\n' 'mv ' filename '.log' ' ' filename '.civ1.log' '\n' 'chmod g+w ' filename '.nc']; |
|---|
| 4252 | % cmd_CIV1=[cmd_CIV1 '\n' 'mv ' filename '.cmx' ' ' filename '.civ1.cmx' '\n'];%rename .cmx as .civ1.cmx, the result file is named [filename '.nc'] by CIVx |
|---|
| 4253 | |
|---|
| 4254 | cmd_CIV2=[sparam.Civ2Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx |
|---|
| 4255 | cmd_CIV2=[cmd_CIV2 '\n' 'mv ' filename '.log' ' ' filename '.civ2.log' '\n' 'chmod g+w ' filename '.nc']; |
|---|
| 4256 | 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 |
|---|
| 4257 | % [Rootbat,Filebat,extbat]=fileparts(namelog); |
|---|
| 4258 | % ncName=fullfile(Rootbat,[ Filebat '.nc']); |
|---|
| 4259 | % cmd_CIV2=[cmd_CIV2 '\n' 'mv ' namelog ' ' regexprep(namelog,'\.log','') '.civ2.log' '\n' 'chmod g+w ' ncName]; |
|---|
| 4260 | else |
|---|
| 4261 | filename=regexprep(filename,'\\','\\\\'); |
|---|
| 4262 | cmd_CIV2=['"' sparam.Civ2Bin '" -f "' filename '.cmx" >"' filename '.log"' ]; % redirect standard output to the log file |
|---|
| 4263 | cmd_CIV2=regexprep(cmd_CIV2,'\\','\\\\'); |
|---|
| 4264 | cmd_CIV2=[cmd_CIV2 '\n' 'copy /Y "' filename '.log' '" "' filename '.civ2.log"']; |
|---|
| 4265 | cmd_CIV2=[cmd_CIV2 '\n' 'copy /Y "' filename '.cmx' '" "' filename '.civ2.cmx"']; |
|---|
| 4266 | end |
|---|
| 4267 | |
|---|
| 4268 | |
|---|
| 4269 | |
|---|
| 4270 | %------------------------------------------------------------------------ |
|---|
| 4271 | % --- Executes on button press in HELP. |
|---|
| 4272 | function HELP_Callback(hObject, eventdata, handles) |
|---|
| 4273 | %------------------------------------------------------------------------ |
|---|
| 4274 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
|---|
| 4275 | pathelp=fileparts(path_to_uvmat); |
|---|
| 4276 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html'); |
|---|
| 4277 | 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') |
|---|
| 4278 | else |
|---|
| 4279 | addpath (fullfile(pathelp,'uvmat_doc')) |
|---|
| 4280 | web([helpfile '#civ']) |
|---|
| 4281 | end |
|---|
| 4282 | |
|---|
| 4283 | %------------------------------------------------------------------------ |
|---|
| 4284 | %--read images and convert them to the uint16 format used for PIV |
|---|
| 4285 | function A=read_image(filename,type_ima,num,movieobject) |
|---|
| 4286 | %------------------------------------------------------------------------ |
|---|
| 4287 | %num is the view number needed for an avi movie |
|---|
| 4288 | switch type_ima |
|---|
| 4289 | case 'movie' |
|---|
| 4290 | A=read(movieobject,num); |
|---|
| 4291 | case 'avi' |
|---|
| 4292 | mov=aviread(filename,num); |
|---|
| 4293 | A=frame2im(mov(1)); |
|---|
| 4294 | case 'multimage' |
|---|
| 4295 | A=imread(filename,num); |
|---|
| 4296 | case 'image' |
|---|
| 4297 | A=imread(filename); |
|---|
| 4298 | end |
|---|
| 4299 | siz=size(A); |
|---|
| 4300 | if length(siz)==3;%color images |
|---|
| 4301 | A=sum(double(A),3); |
|---|
| 4302 | A=uint16(A); |
|---|
| 4303 | end |
|---|
| 4304 | |
|---|
| 4305 | %------------------------------------------------------------------------ |
|---|
| 4306 | function ref_i_Callback(hObject, eventdata, handles) |
|---|
| 4307 | %------------------------------------------------------------------------ |
|---|
| 4308 | mode_list=get(handles.mode,'String'); |
|---|
| 4309 | mode_value=get(handles.mode,'Value'); |
|---|
| 4310 | mode=mode_list{mode_value}; |
|---|
| 4311 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
|---|
| 4312 | if isequal(mode,'series(Di)') || ...% we do patch2 only |
|---|
| 4313 | (get(handles.CIV2,'Value')==0 && get(handles.CIV1,'Value')==0 && get(handles.FIX1,'Value')==0 && get(handles.PATCH1,'Value')==0) |
|---|
| 4314 | find_netcpair_civ2(hObject, eventdata, handles); |
|---|
| 4315 | end |
|---|
| 4316 | |
|---|
| 4317 | %------------------------------------------------------------------------ |
|---|
| 4318 | function ref_j_Callback(hObject, eventdata, handles) |
|---|
| 4319 | %------------------------------------------------------------------------ |
|---|
| 4320 | mode_list=get(handles.mode,'String'); |
|---|
| 4321 | mode_value=get(handles.mode,'Value'); |
|---|
| 4322 | mode=mode_list{mode_value}; |
|---|
| 4323 | if isequal(get(handles.CIV1,'Value'),0)|| isequal(mode,'series(Dj)') |
|---|
| 4324 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
|---|
| 4325 | end |
|---|
| 4326 | if isequal(mode,'series(Dj)') || ... |
|---|
| 4327 | (get(handles.CIV2,'Value')==0 && get(handles.CIV1,'Value')==0 && get(handles.FIX1,'Value')==0 && get(handles.PATCH1,'Value')==0) |
|---|
| 4328 | find_netcpair_civ2(hObject, eventdata, handles); |
|---|
| 4329 | end |
|---|
| 4330 | |
|---|
| 4331 | %------------------------------------------------------------------------ |
|---|
| 4332 | function ref_i_civ2_Callback(hObject, eventdata, handles) |
|---|
| 4333 | %------------------------------------------------------------------------ |
|---|
| 4334 | mode_list=get(handles.mode,'String'); |
|---|
| 4335 | mode_value=get(handles.mode,'Value'); |
|---|
| 4336 | mode=mode_list{mode_value}; |
|---|
| 4337 | find_netcpair_civ2(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
|---|
| 4338 | |
|---|
| 4339 | %------------------------------------------------------------------------ |
|---|
| 4340 | function ref_j_civ2_Callback(hObject, eventdata, handles) |
|---|
| 4341 | %------------------------------------------------------------------------ |
|---|
| 4342 | mode_list=get(handles.mode,'String'); |
|---|
| 4343 | mode_value=get(handles.mode,'Value'); |
|---|
| 4344 | mode=mode_list{mode_value}; |
|---|
| 4345 | if isequal(mode,'series(Dj)') |
|---|
| 4346 | find_netcpair_civ2(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
|---|
| 4347 | end |
|---|
| 4348 | |
|---|
| 4349 | %------------------------------------------------------------------------ |
|---|
| 4350 | % --- Executes on button press in compare. |
|---|
| 4351 | function compare_Callback(hObject, eventdata, handles) |
|---|
| 4352 | %------------------------------------------------------------------------ |
|---|
| 4353 | test=get(handles.compare,'Value'); |
|---|
| 4354 | if test==2 || test==3 |
|---|
| 4355 | filebase=get(handles.RootName,'String'); |
|---|
| 4356 | browse=get(handles.browse_root,'Userdata'); |
|---|
| 4357 | browse.nom_type_ima1=browse.nom_type_ima; |
|---|
| 4358 | set(handles.browse_root,'UserData',browse); |
|---|
| 4359 | set(handles.sub_txt,'Visible','on') |
|---|
| 4360 | set(handles.RootName_1,'Visible','On');%mkes the second file input window visible |
|---|
| 4361 | mode_store=get(handles.mode,'String');%get the present 'mode' |
|---|
| 4362 | set(handles.compare,'UserData',mode_store);%store the mode display |
|---|
| 4363 | set(handles.mode,'Visible','off') |
|---|
| 4364 | if test==2 |
|---|
| 4365 | set(handles.mode,'Visible','off') |
|---|
| 4366 | else |
|---|
| 4367 | set(handles.mode,'Visible','on') |
|---|
| 4368 | end |
|---|
| 4369 | |
|---|
| 4370 | % open an image file with the browser |
|---|
| 4371 | ind_opening=1;%default |
|---|
| 4372 | browse.incr_pair=[0 0]; %default |
|---|
| 4373 | oldfile=get(handles.RootName,'String'); |
|---|
| 4374 | menu={'*.xml;*.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ... |
|---|
| 4375 | '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc', '.nc files';... |
|---|
| 4376 | '*.*', 'All Files (*.*)'}; |
|---|
| 4377 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile); |
|---|
| 4378 | fileinput=[PathName FileName];%complete file name |
|---|
| 4379 | sizf=size(fileinput); |
|---|
| 4380 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
|---|
| 4381 | [path,name,ext]=fileparts(fileinput); |
|---|
| 4382 | [path1]=fileparts(filebase); |
|---|
| 4383 | if ~strcmp(path1,path) |
|---|
| 4384 | msgbox_uvmat('ERROR','The two input image series must be in the same directory') |
|---|
| 4385 | return |
|---|
| 4386 | end |
|---|
| 4387 | set(handles.RootName_1,'String',name); |
|---|
| 4388 | [RootPath,RootFile,field_count,str2,str_a,str_b,xx,nom_type,subdir]=name2display(name); |
|---|
| 4389 | browse=get(handles.browse_root,'UserData'); |
|---|
| 4390 | browse.nom_type_ima_1=nom_type; |
|---|
| 4391 | set(handles.browse_root,'UserData',browse) |
|---|
| 4392 | |
|---|
| 4393 | %check image extension |
|---|
| 4394 | if ~strcmp(ext,get(handles.ImaExt,'String')) |
|---|
| 4395 | msgbox_uvmat('ERROR','The two input image series must have the same extenion name') |
|---|
| 4396 | return |
|---|
| 4397 | end |
|---|
| 4398 | |
|---|
| 4399 | %check image size |
|---|
| 4400 | A=imread(fileinput); |
|---|
| 4401 | npxy=get(handles.ImaExt,'UserData'); |
|---|
| 4402 | if ~isequal(npxy(1),size(A,1))|| ~isequal(npxy(2),size(A,2)) |
|---|
| 4403 | msgbox_uvmat('ERROR','The two input image series must have the same size') |
|---|
| 4404 | return |
|---|
| 4405 | end |
|---|
| 4406 | else |
|---|
| 4407 | set(handles.mode,'Visible','on') |
|---|
| 4408 | set(handles.RootName_1,'Visible','Off'); |
|---|
| 4409 | set(handles.sub_txt,'Visible','off') |
|---|
| 4410 | set(handles.RootName_1,'String',[]); |
|---|
| 4411 | mode_store=get(handles.compare,'UserData'); |
|---|
| 4412 | set(handles.mode,'Value',1) |
|---|
| 4413 | set(handles.mode,'String',mode_store) |
|---|
| 4414 | set(handles.test_stereo1,'Value',0) |
|---|
| 4415 | set(handles.test_stereo2,'Value',0) |
|---|
| 4416 | end |
|---|
| 4417 | mode_Callback(hObject, eventdata, handles) |
|---|
| 4418 | |
|---|
| 4419 | %------------------------------------------------------------------------ |
|---|
| 4420 | % --- Executes on button press in get_ref_fix1. |
|---|
| 4421 | function get_ref_fix1_Callback(hObject, eventdata, handles) |
|---|
| 4422 | %------------------------------------------------------------------------ |
|---|
| 4423 | filebase=get(handles.RootName,'String'); |
|---|
| 4424 | [FileName, PathName, filterindex] = uigetfile( ... |
|---|
| 4425 | {'*.nc', ' (*.nc)'; |
|---|
| 4426 | '*.nc', 'netcdf files '; ... |
|---|
| 4427 | '*.*', 'All Files (*.*)'}, ... |
|---|
| 4428 | 'Pick a file',filebase); |
|---|
| 4429 | |
|---|
| 4430 | fileinput=[PathName FileName]; |
|---|
| 4431 | sizf=size(fileinput); |
|---|
| 4432 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
|---|
| 4433 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
|---|
| 4434 | ref.filebase=fullfile(Path,File); |
|---|
| 4435 | ref.num_a=stra2num(str_a); |
|---|
| 4436 | ref.num_b=stra2num(str_b); |
|---|
| 4437 | ref.num1=str2double(field_count); |
|---|
| 4438 | ref.num2=str2double(str2); |
|---|
| 4439 | browse=[];%initialisation |
|---|
| 4440 | if ~isequal(ref.ext,'.nc') |
|---|
| 4441 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
|---|
| 4442 | return |
|---|
| 4443 | end |
|---|
| 4444 | set(handles.ref_fix1,'String',[fullfile(ref.subdir,File) '....nc']); |
|---|
| 4445 | set(handles.ref_fix1,'UserData',ref) |
|---|
| 4446 | menu_field{1}='civ1'; |
|---|
| 4447 | Data=nc2struct(fileinput,[]); |
|---|
| 4448 | if isfield(Data,'patch') && isequal(Data.patch,1) |
|---|
| 4449 | menu_field{2}='filter1'; |
|---|
| 4450 | end |
|---|
| 4451 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
|---|
| 4452 | menu_field{3}='civ2'; |
|---|
| 4453 | end |
|---|
| 4454 | if isfield(Data,'patch2') && isequal(Data.patch2,1) |
|---|
| 4455 | menu_field{4}='filter2'; |
|---|
| 4456 | end |
|---|
| 4457 | set(handles.field_ref1,'String',menu_field); |
|---|
| 4458 | set(handles.field_ref1,'Value',length(menu_field)); |
|---|
| 4459 | set(handles.inf_sup1,'Value',2); |
|---|
| 4460 | set(handles.thresh_vel,'String','1');%default threshold |
|---|
| 4461 | set(handles.ref_fix1,'Enable','on') |
|---|
| 4462 | |
|---|
| 4463 | %------------------------------------------------------------------------ |
|---|
| 4464 | % --- Executes on button press in get_ref_fix2. |
|---|
| 4465 | function get_ref_fix2_Callback(hObject, eventdata, handles) |
|---|
| 4466 | %------------------------------------------------------------------------ |
|---|
| 4467 | if isequal(get(handles.get_ref_fix2,'Value'),1) |
|---|
| 4468 | filebase=get(handles.RootName,'String'); |
|---|
| 4469 | [FileName, PathName, filterindex] = uigetfile( ... |
|---|
| 4470 | {'*.nc', ' (*.nc)'; |
|---|
| 4471 | '*.nc', 'netcdf files '; ... |
|---|
| 4472 | '*.*', 'All Files (*.*)'}, ... |
|---|
| 4473 | 'Pick a file',filebase); |
|---|
| 4474 | fileinput=[PathName FileName]; |
|---|
| 4475 | sizf=size(fileinput); |
|---|
| 4476 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
|---|
| 4477 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
|---|
| 4478 | ref.filebase=fullfile(Path,File); |
|---|
| 4479 | ref.num_a=stra2num(str_a); |
|---|
| 4480 | ref.num_b=stra2num(str_b); |
|---|
| 4481 | ref.num1=str2num(field_count); |
|---|
| 4482 | ref.num2=str2num(str2); |
|---|
| 4483 | browse=[];%initialisation |
|---|
| 4484 | if ~isequal(ref.ext,'.nc') |
|---|
| 4485 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
|---|
| 4486 | return |
|---|
| 4487 | end |
|---|
| 4488 | set(handles.ref_fix2,'String',[fullfile(ref.subdir,File) '....nc']); |
|---|
| 4489 | set(handles.ref_fix2,'UserData',ref) |
|---|
| 4490 | menu_field{1}='civ1'; |
|---|
| 4491 | Data=nc2struct(fileinput,[]); |
|---|
| 4492 | if isfield(Data,'patch') & isequal(Data.patch,1) |
|---|
| 4493 | menu_field{2}='filter1'; |
|---|
| 4494 | end |
|---|
| 4495 | if isfield(Data,'civ2') & isequal(Data.civ2,1) |
|---|
| 4496 | menu_field{3}='civ2'; |
|---|
| 4497 | end |
|---|
| 4498 | if isfield(Data,'patch2') & isequal(Data.patch2,1) |
|---|
| 4499 | menu_field{4}='filter2'; |
|---|
| 4500 | end |
|---|
| 4501 | set(handles.field_ref2,'String',menu_field); |
|---|
| 4502 | set(handles.field_ref2,'Value',length(menu_field)); |
|---|
| 4503 | set(handles.inf_sup2,'Value',2); |
|---|
| 4504 | set(handles.thresh_vel2,'String','1');%default threshold |
|---|
| 4505 | set(handles.ref_fix2,'Enable','on') |
|---|
| 4506 | set(handles.ref_fix2,'Visible','on') |
|---|
| 4507 | set(handles.field_ref2,'Visible','on') |
|---|
| 4508 | else |
|---|
| 4509 | set(handles.ref_fix2,'Visible','off') |
|---|
| 4510 | set(handles.field_ref2,'Visible','off') |
|---|
| 4511 | end |
|---|
| 4512 | |
|---|
| 4513 | %------------------------------------------------------------------------ |
|---|
| 4514 | function ref_fix1_Callback(hObject, eventdata, handles) |
|---|
| 4515 | %------------------------------------------------------------------------ |
|---|
| 4516 | set(handles.inf_sup1,'Value',1); |
|---|
| 4517 | set(handles.field_ref1,'Value',1) |
|---|
| 4518 | set(handles.field_ref1,'String',{' '}) |
|---|
| 4519 | set(handles.ref_fix1,'UserData',[]); |
|---|
| 4520 | set(handles.ref_fix1,'String',''); |
|---|
| 4521 | set(handles.thresh_vel1,'String','0'); |
|---|
| 4522 | |
|---|
| 4523 | %------------------------------------------------------------------------ |
|---|
| 4524 | function ref_fix2_Callback(hObject, eventdata, handles) |
|---|
| 4525 | %------------------------------------------------------------------------ |
|---|
| 4526 | set(handles.inf_sup2,'Value',1); |
|---|
| 4527 | set(handles.field_ref2,'Value',1) |
|---|
| 4528 | set(handles.field_ref2,'String',{' '}) |
|---|
| 4529 | set(handles.ref_fix2,'UserData',[]); |
|---|
| 4530 | set(handles.ref_fix2,'String',''); |
|---|
| 4531 | set(handles.thresh_vel2,'String','0'); |
|---|
| 4532 | |
|---|
| 4533 | %------------------------------------------------------------------------ |
|---|
| 4534 | % --- Executes on button press in test_stereo1. |
|---|
| 4535 | function test_stereo1_Callback(hObject, eventdata, handles) |
|---|
| 4536 | %------------------------------------------------------------------------ |
|---|
| 4537 | if isequal(get(handles.test_stereo1,'Value'),0) |
|---|
| 4538 | set(handles.subdomain_patch1,'Visible','on') |
|---|
| 4539 | set(handles.rho_patch1,'Visible','on') |
|---|
| 4540 | else |
|---|
| 4541 | set(handles.subdomain_patch1,'Visible','off') |
|---|
| 4542 | set(handles.rho_patch1,'Visible','off') |
|---|
| 4543 | end |
|---|
| 4544 | |
|---|
| 4545 | %------------------------------------------------------------------------ |
|---|
| 4546 | % --- Executes on button press in test_stereo2. |
|---|
| 4547 | function test_stereo2_Callback(hObject, eventdata, handles) |
|---|
| 4548 | %------------------------------------------------------------------------ |
|---|
| 4549 | if isequal(get(handles.test_stereo2,'Value'),0) |
|---|
| 4550 | set(handles.subdomain_patch2,'Visible','on') |
|---|
| 4551 | set(handles.rho_patch2,'Visible','on') |
|---|
| 4552 | else |
|---|
| 4553 | set(handles.subdomain_patch2,'Visible','off') |
|---|
| 4554 | set(handles.rho_patch2,'Visible','off') |
|---|
| 4555 | end |
|---|
| 4556 | |
|---|
| 4557 | %------------------------------------------------------------------------ |
|---|
| 4558 | % --- Executes on button press in ImaThreshold. |
|---|
| 4559 | function ImaThreshold_Callback(hObject, eventdata, handles) |
|---|
| 4560 | %------------------------------------------------------------------------ |
|---|
| 4561 | if isequal(get(handles.ImaThreshold,'Value'),1) |
|---|
| 4562 | set(handles.MinIma,'Visible','on') |
|---|
| 4563 | set(handles.MaxIma,'Visible','on') |
|---|
| 4564 | else |
|---|
| 4565 | set(handles.MinIma,'Visible','off') |
|---|
| 4566 | set(handles.MaxIma,'Visible','off') |
|---|
| 4567 | end |
|---|
| 4568 | |
|---|
| 4569 | %------------------------------------------------------------------------ |
|---|
| 4570 | % --- Executes on button press in ImaThreshold2. |
|---|
| 4571 | function ImaThreshold2_Callback(hObject, eventdata, handles) |
|---|
| 4572 | %------------------------------------------------------------------------ |
|---|
| 4573 | if isequal(get(handles.ImaThreshold2,'Value'),1) |
|---|
| 4574 | set(handles.MinIma2,'Visible','on') |
|---|
| 4575 | set(handles.MaxIma2,'Visible','on') |
|---|
| 4576 | else |
|---|
| 4577 | set(handles.MinIma2,'Visible','off') |
|---|
| 4578 | set(handles.MaxIma2,'Visible','off') |
|---|
| 4579 | end |
|---|
| 4580 | |
|---|
| 4581 | |
|---|
| 4582 | % --- Executes on button press in TestCiv1. |
|---|
| 4583 | function TestCiv1_Callback(hObject, eventdata, handles) |
|---|
| 4584 | test_civ1=get(handles.TestCiv1,'Value'); |
|---|
| 4585 | if test_civ1 |
|---|
| 4586 | [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]=... |
|---|
| 4587 | set_civ_filenames(handles,[1 0 0 0 0 0]); |
|---|
| 4588 | Data.ListVarName={'ny','nx','A'}; |
|---|
| 4589 | Data.VarDimName={'ny','nx',{'ny','nx'}}; |
|---|
| 4590 | Data.A=imread(filecell.ima1.civ1{1}); |
|---|
| 4591 | Data.ny=[size(Data.A,1) 1]; |
|---|
| 4592 | Data.nx=[1 size(Data.A,2)]; |
|---|
| 4593 | hh=view_field(Data); |
|---|
| 4594 | ViewData=get(hh,'UserData'); |
|---|
| 4595 | ViewData.axes3.B=imread(filecell.ima2.civ1{1}); |
|---|
| 4596 | set(hh,'UserData',ViewData) |
|---|
| 4597 | end |
|---|
| 4598 | |
|---|
| 4599 | %------------------------------------------------------------------- |
|---|
| 4600 | % --- Executes on button press in status. |
|---|
| 4601 | function status_Callback(hObject, eventdata, handles) |
|---|
| 4602 | %------------------------------------------------------------------- |
|---|
| 4603 | val=get(handles.status,'Value'); |
|---|
| 4604 | if val==0 |
|---|
| 4605 | hfig=findobj(allchild(0),'name','civ_status'); |
|---|
| 4606 | if ~isempty(hfig) |
|---|
| 4607 | delete(hfig) |
|---|
| 4608 | end |
|---|
| 4609 | return |
|---|
| 4610 | end |
|---|
| 4611 | listtype={'civ1','fix1','patch1','civ2','fix2','patch2'}; |
|---|
| 4612 | box_test(1)=get(handles.CIV1,'Value'); |
|---|
| 4613 | box_test(2)=get(handles.FIX1,'Value'); |
|---|
| 4614 | box_test(3)=get(handles.PATCH1,'Value'); |
|---|
| 4615 | box_test(4)=get(handles.CIV2,'Value'); |
|---|
| 4616 | box_test(5)=get(handles.FIX2,'Value'); |
|---|
| 4617 | box_test(6)=get(handles.PATCH2,'Value'); |
|---|
| 4618 | option=listtype{max(box_test(find(box_test)))}; |
|---|
| 4619 | filecell=get(handles.civ,'UserData'); |
|---|
| 4620 | if ~isfield(filecell,'nc') |
|---|
| 4621 | filecell=set_civ_filenames(handles,box_test);%determine the list of output files expected from the GUI status |
|---|
| 4622 | end |
|---|
| 4623 | |
|---|
| 4624 | if ~isequal(box_test(4:6),[0 0 0]) |
|---|
| 4625 | civ_files=filecell.nc.civ2; |
|---|
| 4626 | else |
|---|
| 4627 | civ_files=filecell.nc.civ1; |
|---|
| 4628 | end |
|---|
| 4629 | [root,filename,ext]=fileparts(civ_files{1}); |
|---|
| 4630 | [rootroot,subdir,extdir]=fileparts(root); |
|---|
| 4631 | hfig=findobj(allchild(0),'name','civ_status'); |
|---|
| 4632 | if isempty(hfig) |
|---|
| 4633 | hfig=figure; |
|---|
| 4634 | set(hfig,'name','civ_status') |
|---|
| 4635 | hlist=uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.05 0.9 0.75], 'Callback', @open_view_field,'tag','list'); |
|---|
| 4636 | uicontrol('Style','listbox','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','msgbox'); |
|---|
| 4637 | uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]); |
|---|
| 4638 | BarPosition=[0.05 0.81 0.01 0.05]; |
|---|
| 4639 | hwaitbar=uicontrol('Style','frame','Units','normalized', 'Position',BarPosition ,'BackgroundColor',[1 0 0],'tag','waitbar'); |
|---|
| 4640 | end |
|---|
| 4641 | datnum=[]; |
|---|
| 4642 | Tabchar={}; |
|---|
| 4643 | nbfiles=numel(civ_files); |
|---|
| 4644 | count=0; |
|---|
| 4645 | while count<nbfiles |
|---|
| 4646 | count=0; |
|---|
| 4647 | for ifile=1:nbfiles |
|---|
| 4648 | detect=exist(civ_files{ifile},'file'); % check the existence of the file |
|---|
| 4649 | if detect==0 |
|---|
| 4650 | lastfield='not created'; |
|---|
| 4651 | else |
|---|
| 4652 | datfile=dir(civ_files{ifile}); |
|---|
| 4653 | datnum(ifile)=datenum(datfile.date); |
|---|
| 4654 | filefound(ifile)={datfile.name}; |
|---|
| 4655 | lastfield=''; |
|---|
| 4656 | % check the content netcdf file |
|---|
| 4657 | Data=nc2struct(civ_files{ifile},'ListGlobalAttribute','patch2','fix2','civ2','patch','fix'); |
|---|
| 4658 | if ~isempty(Data.patch2) && isequal(Data.patch2,1) |
|---|
| 4659 | lastfield='patch2'; |
|---|
| 4660 | elseif ~isempty(Data.fix2) && isequal(Data.fix2,1) |
|---|
| 4661 | lastfield='fix2'; |
|---|
| 4662 | elseif ~isempty(Data.civ2) && isequal(Data.civ2,1); |
|---|
| 4663 | lastfield='civ2'; |
|---|
| 4664 | elseif ~isempty(Data.patch) && isequal(Data.patch,1); |
|---|
| 4665 | lastfield='patch1'; |
|---|
| 4666 | elseif ~isempty(Data.fix) && isequal(Data.fix,1); |
|---|
| 4667 | lastfield='fix1'; |
|---|
| 4668 | else |
|---|
| 4669 | lastfield='civ1'; |
|---|
| 4670 | end |
|---|
| 4671 | end |
|---|
| 4672 | if strcmp(lastfield,option) |
|---|
| 4673 | count=count+1; |
|---|
| 4674 | end |
|---|
| 4675 | [rr,filename,ext]=fileparts(civ_files{ifile}); |
|---|
| 4676 | Tabchar{ifile,1}=[fullfile([subdir extdir],filename) ext '...' lastfield]; |
|---|
| 4677 | end |
|---|
| 4678 | if isempty(datnum) |
|---|
| 4679 | message='no civ result created yet'; |
|---|
| 4680 | else |
|---|
| 4681 | datnum=datnum(find(datnum));%keep the non zero values corresponding to existing files |
|---|
| 4682 | [first,ind]=min(datnum); |
|---|
| 4683 | [last,indlast]=max(datnum); |
|---|
| 4684 | message={[num2str(count) ' file(s) done over ' num2str(nbfiles)] ;['oldest modification: ' cell2mat(filefound(ind)) ' : ' datestr(first)];... |
|---|
| 4685 | ['latest modification: ' cell2mat(filefound(indlast)) ' : ' datestr(last)]}; |
|---|
| 4686 | end |
|---|
| 4687 | hfig=findobj(allchild(0),'name','civ_status'); |
|---|
| 4688 | if isempty(hfig) |
|---|
| 4689 | set(handles.status,'Value',0)%stop program if the figure has been suppressed |
|---|
| 4690 | return |
|---|
| 4691 | else |
|---|
| 4692 | hlist=findobj(hfig,'tag','list'); |
|---|
| 4693 | hmsgbox=findobj(hfig,'tag','msgbox'); |
|---|
| 4694 | hwaitbar=findobj(hfig,'tag','waitbar'); |
|---|
| 4695 | set(hlist,'String',Tabchar) |
|---|
| 4696 | set(hmsgbox,'String', message) |
|---|
| 4697 | if count>0 |
|---|
| 4698 | BarPosition(3)=0.9*count/nbfiles; |
|---|
| 4699 | set(hwaitbar,'Position',BarPosition) |
|---|
| 4700 | end |
|---|
| 4701 | end |
|---|
| 4702 | set(hlist,'UserData',rootroot) |
|---|
| 4703 | pause(5)% wait 5 seconds for next check |
|---|
| 4704 | end |
|---|
| 4705 | |
|---|
| 4706 | |
|---|
| 4707 | %------------------------------------------------------------------- |
|---|
| 4708 | % call 'view_field.fig' to display the selected field |
|---|
| 4709 | function open_view_field(hObject, eventdata) |
|---|
| 4710 | %------------------------------------------------------------------- |
|---|
| 4711 | list=get(gcbo,'String'); |
|---|
| 4712 | index=get(gcbo,'Value'); |
|---|
| 4713 | rootroot=get(gcbo,'UserData'); |
|---|
| 4714 | filename=list{index}; |
|---|
| 4715 | ind_dot=findstr(filename,'...'); |
|---|
| 4716 | filename=filename(1:ind_dot-1); |
|---|
| 4717 | filename=fullfile(rootroot,filename); |
|---|
| 4718 | if exist(filename,'file')%visualise the vel field if it exists |
|---|
| 4719 | [Field,VelTypeOut]=read_civxdata(filename); |
|---|
| 4720 | view_field(Field) |
|---|
| 4721 | end |
|---|
| 4722 | |
|---|
| 4723 | |
|---|