[112] | 1 | %'civ': function associated with the interface 'civ.fig' for PIV, spline interpolation and stereo PIV (patch) |
---|
[2] | 2 | %------------------------------------------------------------------------ |
---|
| 3 | % provides an interface for the software CIVx |
---|
| 4 | % function varargout = civ(varargin) |
---|
| 5 | % provides an interface for the software CIVx |
---|
| 6 | % |
---|
| 7 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 8 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org. |
---|
| 9 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
[112] | 10 | % This file is part of the toolbox UVMAT. |
---|
| 11 | % |
---|
[2] | 12 | % UVMAT is free software; you can redistribute it and/or modify |
---|
| 13 | % it under the terms of the GNU General Public License as published by |
---|
| 14 | % the Free Software Foundation; either version 2 of the License, or |
---|
| 15 | % (at your option) any later version. |
---|
[112] | 16 | % |
---|
[2] | 17 | % UVMAT is distributed in the hope that it will be useful, |
---|
| 18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 20 | % GNU General Public License (file UVMAT/COPYING.txt) for more details. |
---|
| 21 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 22 | function varargout = civ(varargin) |
---|
| 23 | |
---|
[257] | 24 | % Last Modified by GUIDE v2.5 27-May-2011 17:55:50 |
---|
[2] | 25 | % Begin initialization code - DO NOT EDIT |
---|
| 26 | gui_Singleton = 1; |
---|
| 27 | gui_State = struct('gui_Name', mfilename, ... |
---|
[112] | 28 | 'gui_Singleton', gui_Singleton, ... |
---|
| 29 | 'gui_OpeningFcn', @civ_OpeningFcn, ... |
---|
| 30 | 'gui_OutputFcn', @civ_OutputFcn, ... |
---|
| 31 | 'gui_LayoutFcn', [] , ... |
---|
| 32 | 'gui_Callback', []); |
---|
[2] | 33 | if nargin && ischar(varargin{1}) |
---|
| 34 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
| 35 | end |
---|
| 36 | |
---|
| 37 | if nargout |
---|
| 38 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
| 39 | else |
---|
| 40 | gui_mainfcn(gui_State, varargin{:}); |
---|
| 41 | end |
---|
| 42 | % End initialization code - DO NOT EDIT |
---|
| 43 | |
---|
[12] | 44 | %------------------------------------------------------------------------ |
---|
[2] | 45 | % --- Executes just before civ is made visible. |
---|
[71] | 46 | function civ_OpeningFcn(hObject, eventdata, handles, param) |
---|
[12] | 47 | %------------------------------------------------------------------------ |
---|
[2] | 48 | % This function has no output args, see OutputFcn. |
---|
| 49 | % hObject handle to figure |
---|
| 50 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 51 | % handles structure with handles and user data (see GUIDATA) |
---|
| 52 | % varargin command line arguments to civ (see VARARGIN) |
---|
[84] | 53 | global patch_newBin %=1 if new patch processing available |
---|
[112] | 54 | %filebase: root name |
---|
[2] | 55 | %nom_type: nomencalture used ('png_old','_i_j'...) |
---|
| 56 | %list of field numbers to process |
---|
[112] | 57 | %subdir: subdirectory of the opened netcdf file |
---|
[2] | 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); |
---|
[252] | 64 | set(hObject,'WindowButtonDownFcn',{'mouse_alt_gui',handles}) % allows mouse action with right button (zoom for uicontrol display) |
---|
[2] | 65 | %default initial parameters |
---|
| 66 | filebase=''; % root file name ('filebase'.civ) |
---|
| 67 | ext=[]; |
---|
[252] | 68 | |
---|
[71] | 69 | %default input parameters: |
---|
[153] | 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) |
---|
[71] | 74 | subdir='A'; % subdir for the netcdf result files |
---|
[112] | 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 |
---|
[71] | 77 | if exist('param','var')&&isstruct(param)% the interface is opened from uvmat |
---|
| 78 | filebase=param.RootName; |
---|
| 79 | nom_type_read=param.NomType; |
---|
[153] | 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 |
---|
[71] | 88 | subdir=param.SubDir; |
---|
| 89 | ind_opening=param.IndOpening; |
---|
| 90 | ext=param.ImaExt; |
---|
[2] | 91 | end |
---|
[153] | 92 | browse.num_i1=num_i1; |
---|
| 93 | browse.num_i2=num_i2; |
---|
| 94 | browse.num_j1=num_j1; |
---|
| 95 | browse.num_j2=num_j2; |
---|
[122] | 96 | if ~isempty(ext) && (~isempty(imformats(ext(2:end)))||strcmpi(ext,'.avi'));%if an image file has been opened by uvmat |
---|
[112] | 97 | set(handles.ImaExt,'String',ext) |
---|
[128] | 98 | browse.ext_ima=ext; |
---|
[112] | 99 | if exist('nom_type_read','var') |
---|
| 100 | browse.nom_type_ima=nom_type_read; % the image nomenclature is stored |
---|
| 101 | end |
---|
[2] | 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 |
---|
[71] | 107 | set(handles.RootName,'String',filebase); |
---|
[2] | 108 | set(handles.ImaDoc,'String',ext) |
---|
| 109 | |
---|
[122] | 110 | %read names of the .exe file to adjust the interface according to available binaries |
---|
[2] | 111 | path_uvmat=which('uvmat');% check the path detected for source file uvmat |
---|
| 112 | path_UVMAT=fileparts(path_uvmat); %path to UVMAT |
---|
[45] | 113 | errormsg=[];%default error message |
---|
[112] | 114 | xmlfile='PARAM.xml'; |
---|
[54] | 115 | if exist(xmlfile,'file') |
---|
| 116 | try |
---|
[112] | 117 | t=xmltree(xmlfile); |
---|
| 118 | sparam=convert(t); |
---|
[54] | 119 | catch |
---|
[112] | 120 | errormsg={' Unable to read the file PARAM.xml defining the civx binaries:'; lasterr}; |
---|
[227] | 121 | return |
---|
[2] | 122 | end |
---|
[54] | 123 | else |
---|
| 124 | errormsg=[xmlfile ' not found: path to civx binaries undefined']; |
---|
[227] | 125 | return |
---|
[2] | 126 | end |
---|
[71] | 127 | |
---|
[110] | 128 | |
---|
[45] | 129 | if ~isempty(errormsg) |
---|
[112] | 130 | msgbox_uvmat('ERROR',errormsg); |
---|
[45] | 131 | end |
---|
[71] | 132 | % patch_newBin=''; |
---|
| 133 | test_batch=0;%default: ,no batch mode available |
---|
| 134 | if isfield(sparam,'BatchParam') && isfield(sparam.BatchParam,'BatchMode') |
---|
| 135 | test_batch=strcmp(sparam.BatchParam.BatchMode,'sge'); %sge is currently the only implemented batch mod |
---|
[2] | 136 | end |
---|
| 137 | if test_batch==0 |
---|
[84] | 138 | set(handles.BATCH,'Enable','off')% put the BATCH button in grey (unactivated) |
---|
[2] | 139 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784])% put the BATCH button in grey (unactivated) |
---|
| 140 | end |
---|
[94] | 141 | if isfield(sparam.RunParam,'CivBin') |
---|
| 142 | if ~exist(sparam.RunParam.CivBin,'file') |
---|
[112] | 143 | sparam.RunParam.CivBin=fullfile(path_UVMAT,sparam.RunParam.CivBin); |
---|
[94] | 144 | end |
---|
[97] | 145 | else |
---|
| 146 | sparam.RunParam.CivBin=''; |
---|
[94] | 147 | end |
---|
[96] | 148 | patch_newBin=exist(sparam.RunParam.CivBin,'file'); |
---|
[2] | 149 | set(handles.subdir_civ1,'String',subdir)%default subdir on which uvmat was working |
---|
| 150 | set(handles.subdir_civ2,'String',subdir)%default subdir on which uvmat was working |
---|
| 151 | |
---|
| 152 | %initiate advised operations |
---|
| 153 | if isequal(ind_opening,[]) |
---|
| 154 | ind_opening=1; % default |
---|
| 155 | end |
---|
| 156 | % set default operation options |
---|
[112] | 157 | enable_civ1(handles,'off') |
---|
| 158 | enable_civ2(handles,'off') |
---|
| 159 | enable_pair1(handles,'on') |
---|
| 160 | enable_fix1(handles,'off') |
---|
| 161 | desable_patch1(handles) |
---|
| 162 | desable_fix2(handles) |
---|
| 163 | desable_patch2(handles) |
---|
| 164 | set(handles.CIV1,'Value',0) |
---|
| 165 | set(handles.FIX1,'Value',0) |
---|
| 166 | set(handles.PATCH1,'Value',0) |
---|
| 167 | set(handles.CIV2,'Value',0) |
---|
| 168 | set(handles.FIX2,'Value',0) |
---|
| 169 | set(handles.PATCH2,'Value',0) |
---|
| 170 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[2] | 171 | if isequal(ind_opening,1) |
---|
| 172 | set(handles.CIV1,'Value',1) |
---|
| 173 | enable_civ1(handles,'on') |
---|
| 174 | elseif isequal(ind_opening,2) |
---|
| 175 | set(handles.FIX1,'Value',1) |
---|
| 176 | enable_fix1(handles,'on') |
---|
| 177 | elseif isequal(ind_opening,3) |
---|
| 178 | set(handles.PATCH1,'Value',1) |
---|
| 179 | enable_patch1(handles) |
---|
| 180 | elseif isequal(ind_opening,4) |
---|
| 181 | set(handles.CIV2,'Value',1) |
---|
[224] | 182 | enable_civ2(handles,'on') |
---|
[2] | 183 | elseif isequal(ind_opening,5) |
---|
| 184 | set(handles.FIX2,'Value',1) |
---|
| 185 | enable_fix2(handles) |
---|
[112] | 186 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 187 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 188 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 189 | enable_pair1(handles,'off') |
---|
[2] | 190 | elseif isequal(ind_opening,6) |
---|
| 191 | set(handles.PATCH2,'Value',1) |
---|
| 192 | enable_patch2(handles) |
---|
| 193 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 194 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 195 | enable_pair1(handles,'off') |
---|
| 196 | end |
---|
| 197 | |
---|
| 198 | % set the range of fields (1:1 by default) and selected pair |
---|
[153] | 199 | if isequal(num_i2,num_i1) |
---|
| 200 | num_ref_i=num_i1; |
---|
[2] | 201 | else |
---|
[153] | 202 | num_ref_i=floor((num_i1+num_i2)/2); |
---|
| 203 | browse.incr_pair(1)=num_i2-num_i1; |
---|
[2] | 204 | browse.incr_pair(2)=0; |
---|
| 205 | end |
---|
[153] | 206 | if isequal(num_j1,num_j2) |
---|
| 207 | if isnan(num_j1) |
---|
[2] | 208 | num_ref_j=1; |
---|
| 209 | else |
---|
[153] | 210 | num_ref_j=num_j1; |
---|
[2] | 211 | end |
---|
| 212 | else |
---|
[153] | 213 | num_ref_j=floor((num_j1+num_j2)/2); |
---|
| 214 | browse.incr_pair(2)=num_j2-num_j1; |
---|
[2] | 215 | end |
---|
| 216 | set(handles.first_i,'String',num2str(num_ref_i)); |
---|
| 217 | set(handles.last_i,'String',num2str(num_ref_i)); |
---|
| 218 | set(handles.first_j,'String',num2str(num_ref_j)); |
---|
| 219 | set(handles.last_j,'String',num2str(num_ref_j)); |
---|
| 220 | set(handles.ref_i,'String',num2str(num_ref_i)); |
---|
| 221 | set(handles.ref_j,'String',num2str(num_ref_j)); |
---|
[71] | 222 | set(handles.ref_i_civ2,'String',num2str(num_ref_i)); |
---|
| 223 | set(handles.ref_j_civ2,'String',num2str(num_ref_j)); |
---|
[2] | 224 | set(handles.browse_root,'UserData',browse); |
---|
[220] | 225 | if exist('param','var') && isfield(param,'RootName') && ~isempty(param.RootName)%varargin the interface is opened from uvmat |
---|
[112] | 226 | RootName_Callback(hObject, eventdata, handles); |
---|
[2] | 227 | end |
---|
| 228 | |
---|
[150] | 229 | % set(handles.waitbar_1,'Position',[0.946 0.877 0.03 0.001]) |
---|
| 230 | % set(handles.waitbar_patch1,'Position',[0.946 0.626 0.03 0.001]) |
---|
| 231 | % set(handles.waitbar_civ2,'Position',[0.946 0.406 0.03 0.001]) |
---|
| 232 | % set(handles.waitbar_patch2,'Position',[0.946 0.187 0.03 0.001]) |
---|
[2] | 233 | |
---|
[12] | 234 | %------------------------------------------------------------------------ |
---|
[2] | 235 | % --- Outputs from this function are returned to the command line. |
---|
| 236 | function varargout = civ_OutputFcn(hObject, eventdata, handles) |
---|
[12] | 237 | %------------------------------------------------------------------------ |
---|
[2] | 238 | % varargout cell array for returning output args (see VARARGOUT); |
---|
| 239 | % hObject handle to figure |
---|
| 240 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 241 | % handles structure with handles and user data (see GUIDATA) |
---|
| 242 | % Get default command line output from handles structure |
---|
| 243 | varargout{1} = handles.output; |
---|
| 244 | |
---|
[12] | 245 | %------------------------------------------------------------------------ |
---|
[2] | 246 | % --- Executes on button press in browse_root. |
---|
| 247 | function browse_root_Callback(hObject, eventdata, handles) |
---|
[12] | 248 | %------------------------------------------------------------------------ |
---|
[2] | 249 | %get the input file properties |
---|
[71] | 250 | filebase=get(handles.RootName,'String'); |
---|
[2] | 251 | oldfile=''; %default |
---|
[39] | 252 | if isempty(filebase)|| isequal(filebase,'')%loads the previously stored file name and set it as default in the file_input box |
---|
[112] | 253 | dir_perso=prefdir; |
---|
| 254 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 255 | if exist(profil_perso,'file') |
---|
| 256 | h=load (profil_perso); |
---|
| 257 | if isfield(h,'filebase')&& ischar(h.filebase) |
---|
| 258 | oldfile=h.filebase; |
---|
| 259 | end |
---|
| 260 | if isfield(h,'RootPath') && ischar(h.RootPath) |
---|
| 261 | oldfile=h.RootPath; |
---|
| 262 | end |
---|
| 263 | end |
---|
| 264 | else |
---|
| 265 | oldfile=filebase; |
---|
| 266 | end |
---|
[2] | 267 | ind_opening=1;%default |
---|
| 268 | browse.incr_pair=[0 0]; %default |
---|
[238] | 269 | menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)'; |
---|
[174] | 270 | '*.xml', '.xml files '; ... |
---|
| 271 | '*.civ', '.civ files '; ... |
---|
| 272 | '*.png','.png image files'; ... |
---|
| 273 | '*.jpg',' jpeg image files'; ... |
---|
| 274 | '*.tif','.tif image files'; ... |
---|
| 275 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 276 | '*.nc','.netcdf files'; ... |
---|
| 277 | '*.*', 'All Files (*.*)'}; |
---|
[2] | 278 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile); |
---|
[112] | 279 | fileinput=[PathName FileName];%complete file name |
---|
[2] | 280 | sizf=size(fileinput); |
---|
| 281 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
| 282 | [path,name,ext]=fileparts(fileinput); |
---|
| 283 | testeditxml=0; |
---|
| 284 | if isequal(ext,'.xml') |
---|
| 285 | testeditxml=1; |
---|
| 286 | t_browse=xmltree(fileinput); |
---|
| 287 | head_element=get(t_browse,1); |
---|
[45] | 288 | if isfield(head_element,'name')&& isequal(head_element.name,'ImaDoc') |
---|
[2] | 289 | testeditxml=0; |
---|
| 290 | end |
---|
| 291 | end |
---|
[45] | 292 | if testeditxml==1 || isequal(ext,'.xls') |
---|
[112] | 293 | heditxml=editxml({fileinput}); |
---|
| 294 | set(heditxml,'Tag','browser') |
---|
| 295 | waitfor(heditxml,'Tag','idle') |
---|
| 296 | if ~ishandle(heditxml) |
---|
| 297 | return |
---|
| 298 | end |
---|
| 299 | attr=findobj(get(heditxml,'children'),'Tag','CurrentAttributes'); |
---|
| 300 | set(handles.browse,'UserData',fileinput)% store for future opening with browser |
---|
| 301 | fileinput=get(attr,'UserData'); |
---|
| 302 | if ~exist(fileinput,'file') |
---|
| 303 | return |
---|
| 304 | end |
---|
[2] | 305 | end |
---|
[82] | 306 | [RootPath,RootFile,str1,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput); |
---|
[2] | 307 | filebase=fullfile(RootPath,RootFile); |
---|
[89] | 308 | num_i1=str2double(str1); |
---|
| 309 | if isnan(num_i1),num_i1=1;end |
---|
| 310 | num_i2=str2double(str2); |
---|
| 311 | if isnan(num_i2),num_i2=num_i1;end |
---|
[54] | 312 | num_j1=stra2num(str_a); |
---|
[89] | 313 | if isnan(num_j1),num_j1=1;end |
---|
[54] | 314 | num_j2=stra2num(str_b); |
---|
[112] | 315 | if isnan(num_j2),num_j2=num_j1;end |
---|
[2] | 316 | if isequal(get(handles.compare,'Value'),1) |
---|
| 317 | browse=[];%initialisation |
---|
| 318 | else |
---|
| 319 | browse=get(handles.browse_root,'UserData'); |
---|
| 320 | end |
---|
[122] | 321 | browse.num_i1=num_i1; |
---|
| 322 | browse.num_i2=num_i2; |
---|
| 323 | browse.num_j1=num_j1; |
---|
| 324 | browse.num_j2=num_j2; |
---|
| 325 | if length(ext)>1 && (~isempty(imformats(ext(2:end)))||strcmpi(ext,'.avi'));%if an image file has been opened by uvmat |
---|
[2] | 326 | browse.nom_type_ima=nom_type; |
---|
[122] | 327 | browse.ext_ima=ext; |
---|
[177] | 328 | set(handles.ImaExt,'String',ext) |
---|
[2] | 329 | end |
---|
| 330 | set(handles.ImaDoc,'String',ext); |
---|
| 331 | |
---|
| 332 | %%%%% read the state of the selected netcdf file to advise default operation |
---|
| 333 | if isequal(ext,'.nc') |
---|
| 334 | browse.nom_type_nc=nom_type; |
---|
[112] | 335 | ind_opening=2;% propose 'fix' as the default option |
---|
[246] | 336 | Data=nc2struct(fileinput,'ListGlobalAttribute','CivStage','absolut_time_T0','fix','patch','civ2','fix2'); |
---|
| 337 | if ~isempty(Data.CivStage)%test for civ files |
---|
| 338 | ind_opening=Data.CivStage; |
---|
[257] | 339 | set(handles.CivMode,'Value',3) |
---|
[246] | 340 | end |
---|
| 341 | if ~isempty(Data.absolut_time_T0)%test for civx files |
---|
[257] | 342 | set(handles.CivMode,'Value',1) |
---|
[2] | 343 | if isfield(Data,'fix') && isequal(Data.fix,1) |
---|
| 344 | ind_opening=3; |
---|
| 345 | end |
---|
[246] | 346 | if isequal(Data.patch,1) |
---|
[2] | 347 | ind_opening=4; |
---|
| 348 | end |
---|
[246] | 349 | if isequal(Data.civ2,1) |
---|
[2] | 350 | ind_opening=5; |
---|
| 351 | end |
---|
[246] | 352 | if isequal(Data.fix2,1) |
---|
[2] | 353 | ind_opening=6; |
---|
| 354 | end |
---|
| 355 | testciv=1; %TO SUPPRESS WITH NEW VERSION OF CIVX |
---|
| 356 | else |
---|
[112] | 357 | ind_opening=3; %GUI used only for patch |
---|
[2] | 358 | testciv=0; |
---|
| 359 | end |
---|
| 360 | set(handles.subdir_civ1,'String',subdir);%set the default subdir directories for installing the .nc results |
---|
| 361 | set(handles.subdir_civ2,'String',subdir); |
---|
| 362 | browse.testciv=testciv; |
---|
| 363 | browse.ind_opening=ind_opening; |
---|
| 364 | end |
---|
[71] | 365 | set(handles.RootName,'String',filebase); |
---|
[2] | 366 | set(handles.ImaDoc,'String',ext); |
---|
[45] | 367 | if ~isempty(num_i1) |
---|
[82] | 368 | ref_i=num_i1; |
---|
[45] | 369 | if ~isempty(num_i2) |
---|
| 370 | ref_i=floor((ref_i+num_i2)/2);% reference image number corresponding to the file |
---|
| 371 | browse.incr_pair(1)=num_i2-num_i1; |
---|
[2] | 372 | browse.incr_pair(2)=0; |
---|
| 373 | end |
---|
| 374 | set(handles.first_i,'String',num2str(ref_i)); |
---|
| 375 | set(handles.last_i,'String',num2str(ref_i)); |
---|
[71] | 376 | set(handles.ref_i,'String',num2str(ref_i)); |
---|
| 377 | set(handles.ref_i_civ2,'String',num2str(ref_i)) |
---|
[2] | 378 | end |
---|
[45] | 379 | if isempty(num_j1) |
---|
[2] | 380 | set(handles.ref_j,'String','1'); |
---|
[71] | 381 | set(handles.ref_j_civ2,'String','1'); |
---|
[2] | 382 | else |
---|
[45] | 383 | ref_j=num_j1; |
---|
| 384 | if ~isempty(num_j2) |
---|
| 385 | ref_j=floor((num_j1+num_j2)/2); |
---|
[112] | 386 | browse.incr_pair(2)=num_j2-num_j1; |
---|
[2] | 387 | end |
---|
| 388 | set(handles.first_j,'String',num2str(ref_j)); |
---|
| 389 | set(handles.last_j,'String',num2str(ref_j)); |
---|
[112] | 390 | set(handles.ref_j,'String',num2str(ref_j)); |
---|
[71] | 391 | set(handles.ref_j_civ2,'String',num2str(ref_j)); |
---|
[2] | 392 | end |
---|
| 393 | |
---|
| 394 | % set default operation options |
---|
| 395 | enable_civ1(handles,'off') |
---|
| 396 | enable_civ2(handles,'off') |
---|
| 397 | enable_pair1(handles,'on') |
---|
| 398 | enable_fix1(handles,'off') |
---|
| 399 | desable_patch1(handles) |
---|
| 400 | desable_fix2(handles) |
---|
| 401 | desable_patch2(handles) |
---|
| 402 | set(handles.CIV1,'Value',0) |
---|
| 403 | set(handles.FIX1,'Value',0) |
---|
| 404 | set(handles.PATCH1,'Value',0) |
---|
| 405 | set(handles.CIV2,'Value',0) |
---|
| 406 | set(handles.FIX2,'Value',0) |
---|
| 407 | set(handles.PATCH2,'Value',0) |
---|
| 408 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 409 | if isequal(ind_opening,1) |
---|
| 410 | set(handles.CIV1,'Value',1) |
---|
| 411 | enable_civ1(handles,'on') |
---|
| 412 | elseif isequal(ind_opening,2) |
---|
| 413 | set(handles.FIX1,'Value',1) |
---|
| 414 | enable_fix1(handles,'on') |
---|
| 415 | elseif isequal(ind_opening,3) |
---|
| 416 | set(handles.PATCH1,'Value',1) |
---|
| 417 | enable_patch1(handles) |
---|
| 418 | elseif isequal(ind_opening,4) |
---|
| 419 | set(handles.CIV2,'Value',1) |
---|
[224] | 420 | enable_civ2(handles,'on') |
---|
[2] | 421 | elseif isequal(ind_opening,5) |
---|
| 422 | enable_pair1(handles,'off') |
---|
| 423 | set(handles.FIX2,'Value',1) |
---|
| 424 | enable_fix2(handles) |
---|
[112] | 425 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 426 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 427 | set(handles.list_pair_civ2,'Enable','On') |
---|
[2] | 428 | elseif isequal(ind_opening,6) |
---|
| 429 | enable_pair1(handles,'off') |
---|
| 430 | set(handles.PATCH2,'Value',1) |
---|
| 431 | enable_patch2(handles) |
---|
| 432 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 433 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 434 | end |
---|
| 435 | set(handles.browse_root,'UserData',browse);% store information from browser |
---|
| 436 | |
---|
[71] | 437 | RootName_Callback(hObject, eventdata, handles); |
---|
[2] | 438 | |
---|
[12] | 439 | %------------------------------------------------------------------------ |
---|
[2] | 440 | function ImaDoc_Callback(hObject, eventdata, handles) |
---|
[12] | 441 | %------------------------------------------------------------------------ |
---|
[71] | 442 | RootName_Callback(hObject, eventdata, handles) |
---|
[2] | 443 | |
---|
[12] | 444 | %------------------------------------------------------------------------ |
---|
[54] | 445 | % --- function activated when a new filebase (image series) is introduced |
---|
[71] | 446 | function RootName_Callback(hObject, eventdata, handles) |
---|
[12] | 447 | %------------------------------------------------------------------------ |
---|
[2] | 448 | set(handles.compare,'Visible','on') |
---|
[122] | 449 | ext_ima='';%default |
---|
[2] | 450 | nom_type_ima=[];%default |
---|
| 451 | field_count=1;%default |
---|
| 452 | nom_type_nc=[]; |
---|
| 453 | time=[]; |
---|
[71] | 454 | TimeUnit='frame'; %default |
---|
| 455 | CoordUnit='px';%default |
---|
[2] | 456 | pxcmx_search=[];%default |
---|
| 457 | pxcmy_search=[];%default |
---|
[71] | 458 | filebase=get(handles.RootName,'String'); |
---|
[128] | 459 | ext_imadoc=get(handles.ImaDoc,'String'); |
---|
[135] | 460 | browse=get(handles.browse_root,'UserData');%default |
---|
[122] | 461 | if isfield(browse,'nom_type_ima') |
---|
| 462 | nom_type_ima=browse.nom_type_ima;% get an image nomenclature type already determined by an input image name |
---|
[133] | 463 | end |
---|
| 464 | if isfield(browse,'ext_ima') |
---|
[122] | 465 | ext_ima=browse.ext_ima; |
---|
[2] | 466 | end |
---|
[122] | 467 | if isfield(browse,'nom_type_nc') |
---|
| 468 | nom_type_nc=browse.nom_type_nc;% get an image nomenclature type already determined by an input image name |
---|
| 469 | end |
---|
| 470 | if isfield(browse,'num_i1') |
---|
| 471 | field_count=browse.num_i1;% get an image index type already determined by an input file |
---|
| 472 | end |
---|
[252] | 473 | set(handles.civ,'UserData',[]); %refresh list of previous civ files (for STATUS) |
---|
[2] | 474 | |
---|
| 475 | %default first_i and j and increments |
---|
[137] | 476 | first_i=str2double(get(handles.first_i,'String'));%value possibly set by uvmat_Opening |
---|
| 477 | if isnan(first_i)|| first_i < 1 |
---|
[2] | 478 | first_i=1; %default first_i |
---|
| 479 | end |
---|
[137] | 480 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 481 | if isnan(last_i)|| last_i < first_i |
---|
[2] | 482 | last_i=first_i; %default last_i |
---|
| 483 | end |
---|
[137] | 484 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 485 | if isnan(first_j)|| first_j < 1 |
---|
[2] | 486 | first_j=1; %default first_j |
---|
| 487 | end |
---|
[137] | 488 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 489 | if isnan(last_j)|| last_j < first_j |
---|
[2] | 490 | last_j=first_j; %default last_j |
---|
| 491 | end |
---|
[137] | 492 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 493 | if isnan(incr_i) || incr_i < 1; |
---|
[2] | 494 | set(handles.incr_i,'String','1') %default incr_i |
---|
| 495 | end |
---|
[137] | 496 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
| 497 | if isnan(incr_j) || incr_j < 1; |
---|
[2] | 498 | set(handles.incr_j,'String','1') %default incr_j |
---|
| 499 | end |
---|
| 500 | dt=[];%default |
---|
| 501 | testmode=0;%default |
---|
| 502 | nbfield=[]; %default |
---|
| 503 | nburst=[];%default |
---|
| 504 | pxcmx=1; |
---|
[112] | 505 | pxcmy=1; |
---|
[2] | 506 | |
---|
[112] | 507 | %look for an image documentation file |
---|
[128] | 508 | if ~strcmp(ext_imadoc,'.xml') && ~strcmp(ext_imadoc,'.civ')&& ~strcmpi(ext_imadoc,'.avi') |
---|
[2] | 509 | if exist([filebase '.xml'],'file') |
---|
[128] | 510 | ext_imadoc='.xml'; |
---|
[2] | 511 | elseif exist([filebase '.civxml'],'file') |
---|
[128] | 512 | ext_imadoc='.civxml'; |
---|
[2] | 513 | elseif exist([filebase '.civ'],'file') |
---|
[128] | 514 | ext_imadoc='.civ'; |
---|
[112] | 515 | elseif exist([filebase '.avi'],'file') |
---|
[128] | 516 | ext_imadoc='.avi'; |
---|
[2] | 517 | elseif exist([filebase '.AVI'],'file') |
---|
[128] | 518 | ext_imadoc='.AVI'; |
---|
[2] | 519 | end |
---|
[128] | 520 | set(handles.ImaDoc,'String',ext_imadoc) |
---|
[2] | 521 | end |
---|
| 522 | |
---|
| 523 | %%%%%%%% read image documentation file %%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[84] | 524 | mode=''; %default |
---|
| 525 | set(handles.ImaDoc,'BackgroundColor',[1 1 0]) |
---|
| 526 | drawnow |
---|
[128] | 527 | if isequal(ext_imadoc,'.civxml') || isequal(ext_imadoc,'.xml')|| isequal(ext_imadoc,'.civ') |
---|
[2] | 528 | set(handles.ref_i,'Visible','On')%use a reference index |
---|
| 529 | set(handles.ref_j,'Visible','On') |
---|
[128] | 530 | elseif isequal(ext_imadoc,'.avi') || isequal(ext_imadoc,'.AVI') |
---|
[2] | 531 | set(handles.ref_j,'Visible','Off') |
---|
| 532 | else |
---|
| 533 | set(handles.ref_i,'Visible','Off') |
---|
| 534 | set(handles.ref_j,'Visible','Off') |
---|
| 535 | end |
---|
[12] | 536 | testima_xml=0; |
---|
[128] | 537 | if isequal(ext_imadoc,'.civxml')%TO ABANDON |
---|
[122] | 538 | [nbfield,nbfield2,time]=read_civxml([filebase '.civxml']); |
---|
[2] | 539 | mode='pair j1-j2'; |
---|
| 540 | if isempty(nom_type_ima)% dtermine types by default if not already selected by browser or uvmat |
---|
[112] | 541 | nom_type_ima='_i_j'; |
---|
[2] | 542 | end |
---|
[128] | 543 | elseif isequal(ext_imadoc,'.xml') |
---|
[73] | 544 | [XmlData,warntext]=imadoc2struct([filebase '.xml']); |
---|
[2] | 545 | ext_ima_read=[]; |
---|
| 546 | nom_type_read=[]; |
---|
[12] | 547 | if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')&&ischar(XmlData.Heading.ImageName)% get image nom type and extension from the xml file |
---|
[2] | 548 | [PP,FF,fc,str2,str_a,str_b,ext_ima_read,nom_type_read]=name2display(XmlData.Heading.ImageName); |
---|
[112] | 549 | fullname=fullfile(fileparts(filebase),XmlData.Heading.ImageName); %full name (including path) of the first image defined by the xmle file, |
---|
[45] | 550 | if ~exist(fullname,'file') |
---|
[12] | 551 | msgbox_uvmat('WARNING',['FirstImage ' fullname ' defined in the xml file does not exist']) |
---|
| 552 | end |
---|
[2] | 553 | end |
---|
[84] | 554 | if isfield(XmlData,'Time') |
---|
[85] | 555 | time=XmlData.Time; |
---|
[84] | 556 | nbfield=size(time,1); |
---|
[122] | 557 | nbfield2=size(time,2); |
---|
[127] | 558 | %transform .Time to a column vector if it is a line vector thenomenclature uses a single index: correct possible bug in xml |
---|
[122] | 559 | if isequal(nbfield,1) && ~isequal(nbfield2,1)% .Time is a line vector |
---|
[127] | 560 | if numel(nom_type_read)>=2 && isempty(regexp(nom_type_read(2:end),'\D')) |
---|
[84] | 561 | time=time'; |
---|
[122] | 562 | nbfield=nbfield2; |
---|
| 563 | nbfield2=1; |
---|
[84] | 564 | end |
---|
| 565 | end |
---|
| 566 | end |
---|
[71] | 567 | if isfield(XmlData,'TimeUnit') |
---|
| 568 | TimeUnit=XmlData.TimeUnit; |
---|
[2] | 569 | end |
---|
[71] | 570 | if isfield(XmlData,'Npx') |
---|
| 571 | npx=XmlData.Npx; |
---|
| 572 | npy=XmlData.Npy; |
---|
| 573 | end |
---|
[2] | 574 | pxcmx_search=1; |
---|
| 575 | pxcmy_search=1; |
---|
| 576 | if isfield(XmlData,'GeometryCalib') |
---|
| 577 | tsai=XmlData.GeometryCalib; |
---|
[112] | 578 | if isfield(tsai,'f') && isfield(tsai,'Tz') && isfield(tsai,'dpx') && isfield(tsai,'dpy')&& isfield(tsai,'R') |
---|
| 579 | rot2D=tsai.R(1:2,[1,2]); |
---|
| 580 | pxcmx_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpx); |
---|
| 581 | pxcmy_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpy); |
---|
[2] | 582 | end |
---|
[112] | 583 | if isfield(tsai,'CoordUnit') |
---|
| 584 | CoordUnit=tsai.CoordUnit; |
---|
[2] | 585 | end |
---|
[112] | 586 | end |
---|
[128] | 587 | elseif strcmp(ext_imadoc,'.civ')% case of .civ image documentation file |
---|
[112] | 588 | [error,time,TimeUnit,mode,npx,npy]=read_imatext([filebase '.civ']); |
---|
| 589 | if error==2, msgbox_uvmat('WARNING',['no file ' filebase '.civ']); |
---|
| 590 | elseif error==1, msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file'); |
---|
| 591 | end |
---|
[128] | 592 | nom_type_ima='001a'; |
---|
| 593 | elseif strcmpi(ext_imadoc,'.avi') |
---|
[112] | 594 | nom_type_ima='*'; |
---|
[128] | 595 | ext_ima=ext_imadoc; |
---|
[177] | 596 | set(handles.mode,'Value',1); |
---|
[112] | 597 | set(handles.mode,'String',{'series(Di)'}) |
---|
| 598 | dt=0.04;%default |
---|
[128] | 599 | if exist([filebase ext_imadoc],'file')==2 |
---|
| 600 | info=aviinfo([filebase ext_imadoc]);%read infos on the avi movie |
---|
[112] | 601 | dt=1/info.FramesPerSecond;%time interval between successive frames |
---|
| 602 | nbfield=info.NumFrames;%number of frames |
---|
| 603 | end |
---|
| 604 | time=(dt*(0:nbfield-1))';%list of image times |
---|
[2] | 605 | end |
---|
| 606 | if isempty(time) |
---|
| 607 | set(handles.ImaDoc,'String',''); %xml file not used for timing |
---|
| 608 | end |
---|
| 609 | set(handles.ImaDoc,'BackgroundColor',[1 1 1]) |
---|
| 610 | |
---|
[122] | 611 | %get the imabe nomenclature type if not defined by the input file nor by the xml file |
---|
| 612 | dirima=[];%default |
---|
[12] | 613 | if isempty(nom_type_ima) |
---|
| 614 | %look for double image series '_i_j' |
---|
| 615 | dirima=dir([filebase '_' num2str(first_i) '_' num2str(first_j) '.*']); |
---|
| 616 | if isempty(dirima) |
---|
[112] | 617 | % look for images series with sub marker '_' |
---|
| 618 | dirima=dir([filebase '_*' num2str(first_i) '.*']); |
---|
| 619 | if isempty(dirima) |
---|
| 620 | % look for other images series |
---|
| 621 | dirima=dir([filebase '*' num2str(first_i) '.*']); |
---|
[122] | 622 | if isempty(dirima) |
---|
| 623 | % look for other images series witth letter appendix |
---|
| 624 | appendix=char(96+first_j); |
---|
| 625 | dirima=dir([filebase '*' num2str(first_i) appendix '.*']); |
---|
[112] | 626 | end |
---|
| 627 | end |
---|
[12] | 628 | end |
---|
[112] | 629 | end |
---|
[122] | 630 | for ilist=1:numel(dirima) |
---|
| 631 | [pp,ff,fc,str2,str_a,str_b,ext_list,nom_type_list]=name2display(dirima(ilist).name); |
---|
| 632 | form=imformats(ext_list(2:end)); |
---|
| 633 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 634 | ext_ima=ext_list; |
---|
| 635 | nom_type_ima=nom_type_list; |
---|
| 636 | break |
---|
| 637 | end |
---|
| 638 | end |
---|
| 639 | % no image documentation file found: look for a series of existing files,images by priority or .nc files |
---|
| 640 | if isempty(nom_type_ima) |
---|
[128] | 641 | ext_search=ext_imadoc; |
---|
[122] | 642 | nom_type_search=nom_type_nc; |
---|
| 643 | else |
---|
| 644 | ext_search=ext_ima; |
---|
| 645 | nom_type_search=nom_type_ima; |
---|
| 646 | end |
---|
| 647 | if isempty(time) && ~strcmp(nom_type_search,'none') && ~strcmp(nom_type_search,'') && ~strcmp(nom_type_search,'*') |
---|
[12] | 648 | subdir=get(handles.subdir_civ1,'String'); |
---|
| 649 | incr_pair=[0 0];%default |
---|
| 650 | if isfield(browse,'incr_pair') |
---|
[112] | 651 | incr_pair=browse.incr_pair; |
---|
[12] | 652 | end |
---|
[112] | 653 | % nbdetect=0;%test of detected images |
---|
[122] | 654 | field_i=browse.num_i2; |
---|
[153] | 655 | imagename=name_generator(filebase,field_i,1,ext_search,nom_type_search); |
---|
| 656 | imagename_plus=''; |
---|
[12] | 657 | idetect=1; |
---|
[153] | 658 | while idetect %look for the maximum file number in the series |
---|
| 659 | imagename_plus=name_generator(filebase,field_i+1,1,ext_search,nom_type_search); |
---|
| 660 | idetect=(exist(imagename_plus,'file')==2)&& ~strcmp(imagename,imagename_plus); |
---|
[81] | 661 | if idetect |
---|
[12] | 662 | field_i=field_i+1; |
---|
[81] | 663 | end |
---|
[112] | 664 | %SEE CASE OF NETCDF FILES |
---|
| 665 | % nbdetect=nbdetect+(exist(imagename,'file')==2); |
---|
[12] | 666 | end |
---|
[122] | 667 | nbfield=field_i;% last detected field number |
---|
| 668 | field_i=browse.num_i1;%look for the minimum file number in the series |
---|
[153] | 669 | imagename_min=''; |
---|
[12] | 670 | idetect=1; |
---|
[112] | 671 | while idetect==1 |
---|
[153] | 672 | imagename_min=name_generator(filebase,field_i-1,1,ext_search,nom_type_search); |
---|
| 673 | idetect=(exist(imagename_min,'file')==2)&& ~strcmp(imagename,imagename_min); |
---|
[81] | 674 | if idetect |
---|
[112] | 675 | field_i=field_i-1; |
---|
[81] | 676 | end |
---|
[12] | 677 | end |
---|
[122] | 678 | first_i=max(field_i,1); |
---|
| 679 | if numel(regexp(nom_type_search,'\D'))>=1%two indices i and j |
---|
| 680 | field_i=browse.num_i1; |
---|
| 681 | field_j=browse.num_j2; |
---|
[177] | 682 | imagename=name_generator(filebase,field_i,field_j,ext_search,nom_type_search); |
---|
[153] | 683 | imagename_plus=''; |
---|
[89] | 684 | jdetect=1; |
---|
| 685 | while jdetect==1 %look for the maximum file number in the series |
---|
[153] | 686 | imagename_plus=name_generator(filebase,field_i,field_j+1,ext_search,nom_type_search); |
---|
| 687 | jdetect=(exist(imagename_plus,'file')==2)&& ~strcmp(imagename,imagename_plus); |
---|
[89] | 688 | if jdetect |
---|
| 689 | field_j=field_j+1; |
---|
| 690 | end |
---|
| 691 | %SEE CASE OF NETCDF FILES |
---|
| 692 | % nbdetect=nbdetect+(exist(imagename,'file')==2); |
---|
| 693 | end |
---|
[122] | 694 | nbfield2=field_j;% last detected field number |
---|
[120] | 695 | end |
---|
[122] | 696 | |
---|
[89] | 697 | %determine the set of times and possible intervals for CIV |
---|
[137] | 698 | % dt=(1/1000)*str2double(get(handles.dt,'String')); |
---|
[122] | 699 | time=(0:nbfield-1)';% time=file index -1 by default |
---|
| 700 | if numel(regexp(nom_type_search,'\D'))>=1%two indices i and j |
---|
| 701 | [x,y]=meshgrid(0:nbfield2-1,0:nbfield-1); |
---|
[120] | 702 | time=x+y; |
---|
[89] | 703 | end |
---|
[2] | 704 | end |
---|
[120] | 705 | |
---|
[2] | 706 | if exist('time','var') |
---|
| 707 | if size(time,1)+size(time,2)>=3 % if there are at least two time values to define dt |
---|
| 708 | nbfield=size(time,1); |
---|
| 709 | nbfield2=size(time,2); |
---|
[71] | 710 | set(handles.RootName,'UserData',time); %store the set of times |
---|
| 711 | set(handles.dt_unit,'String',['dt in m' TimeUnit]); |
---|
| 712 | set(handles.dt_unit_civ2,'String',['dt in m' TimeUnit]); |
---|
| 713 | set(handles.TimeUnit,'String',TimeUnit); |
---|
[2] | 714 | set(handles.nb_field,'String',num2str(nbfield)); |
---|
| 715 | set(handles.nb_field2,'String',num2str(nbfield2)); |
---|
| 716 | end |
---|
| 717 | end |
---|
[71] | 718 | set(handles.CoordUnit,'String',CoordUnit) |
---|
[2] | 719 | set(handles.calcul_search,'UserData',[pxcmx_search pxcmy_search]); |
---|
| 720 | % npxy=[npy npx]; |
---|
[71] | 721 | set(handles.ImaExt,'String',ext_ima) |
---|
[2] | 722 | set(handles.first_i,'String',num2str(first_i)); |
---|
| 723 | set(handles.last_i,'String',num2str(last_i));% |
---|
| 724 | set(handles.first_j,'String',num2str(first_j)); |
---|
| 725 | set(handles.last_j,'String',num2str(last_j));% |
---|
| 726 | browse.nom_type_ima=nom_type_ima; |
---|
| 727 | set(handles.browse_root,'UserData',browse)% store the nomenclature type |
---|
| 728 | |
---|
[112] | 729 | %%%%%%%%%%% set the menus of image pairs and default selection for civ %%%%%%%%%%%%%%%%%%% |
---|
[177] | 730 | test_ima_i=numel(nom_type_ima)>1 && isempty(regexp(nom_type_ima(2:end),'\D','once'));%images with single indexing |
---|
[122] | 731 | if test_ima_i || isequal(nom_type_nc,'_i1-i2')||~(exist('nbfield2','var')&&(nbfield2~=1)) |
---|
[2] | 732 | set(handles.mode,'Value',1) |
---|
[177] | 733 | set(handles.mode,'String',{'series(Di)'}) |
---|
[2] | 734 | elseif (nbfield==1)% simple series in j |
---|
[177] | 735 | set(handles.mode,'Value',1) |
---|
[2] | 736 | set(handles.mode,'String',{'series(Dj)'}) |
---|
| 737 | else |
---|
| 738 | set(handles.mode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice |
---|
[122] | 739 | if nbfield2 <= 10 |
---|
[112] | 740 | set(handles.mode,'Value',1)% advice 'pair j1-j2' for small burst |
---|
[2] | 741 | end |
---|
| 742 | end |
---|
| 743 | |
---|
[112] | 744 | %update the subdir |
---|
[2] | 745 | pathdir=fileparts(filebase);%path to the current xml file |
---|
| 746 | listot=dir(pathdir); |
---|
| 747 | idir=0; |
---|
| 748 | listdir={''};%default |
---|
| 749 | for ilist=1:length(listot) |
---|
| 750 | if listot(ilist).isdir |
---|
| 751 | name=listot(ilist).name; |
---|
| 752 | if ~isequal(name,'.') && ~isequal(name,'..') |
---|
| 753 | idir=idir+1; |
---|
| 754 | listdir{idir,1}=listot(ilist).name; |
---|
| 755 | end |
---|
| 756 | end |
---|
| 757 | end |
---|
[112] | 758 | set(handles.list_subdir_civ1,'Value',1) |
---|
[2] | 759 | set(handles.list_subdir_civ2,'Value',1) |
---|
[107] | 760 | set(handles.list_subdir_civ1,'String',[{'browse...'};listdir]) |
---|
| 761 | set(handles.list_subdir_civ2,'String',[{'browse...'};listdir]) |
---|
[2] | 762 | %check wether the current subdir exists: |
---|
| 763 | subdir_civ1=get(handles.subdir_civ1,'String'); |
---|
| 764 | subdir_civ2=get(handles.subdir_civ2,'String'); |
---|
| 765 | |
---|
[112] | 766 | mode_Callback(hObject, eventdata, handles) |
---|
[2] | 767 | |
---|
[177] | 768 | %% desable status and RUN button |
---|
[150] | 769 | % set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001]) |
---|
| 770 | % set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001]) |
---|
| 771 | % set(handles.waitbar_civ2,'Position',[0.946 0.219 0.03 0.001]) |
---|
| 772 | % set(handles.waitbar_patch2,'Position',[0.946 0.0 0.03 0.001]) |
---|
[2] | 773 | set(handles.RUN, 'Enable','On') |
---|
| 774 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
[122] | 775 | set(handles.BATCH,'Enable','On') |
---|
| 776 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
[178] | 777 | if isfield(handles,'status') |
---|
[177] | 778 | set(handles.status,'Value',0);%suppress status display |
---|
| 779 | status_Callback(hObject, eventdata, handles) |
---|
[178] | 780 | end |
---|
[112] | 781 | |
---|
[177] | 782 | %% store the root input filename for future opening |
---|
[2] | 783 | dir_perso=prefdir; |
---|
| 784 | profil_perso=fullfile(prefdir,'uvmat_perso.mat'); |
---|
| 785 | RootPath=fileparts(filebase); |
---|
| 786 | if exist(profil_perso,'file') |
---|
| 787 | save (profil_perso,'RootPath','-append'); %store the root name for future opening of uvmat |
---|
| 788 | else |
---|
[147] | 789 | txt=ver('MATLAB'); |
---|
| 790 | Release=txt.Release; |
---|
[137] | 791 | relnumb=str2double(Release(3:4)); |
---|
[2] | 792 | if relnumb >= 14 |
---|
[112] | 793 | save (profil_perso,'RootPath','-V6'); %store the root name for future opening of uvmat |
---|
[2] | 794 | else |
---|
| 795 | save (profil_perso,'RootPath'); %store the root name for future opening of uvmat |
---|
| 796 | end |
---|
| 797 | end |
---|
| 798 | |
---|
[12] | 799 | %------------------------------------------------------------------------ |
---|
[2] | 800 | % --- Executes on button press in mode. |
---|
| 801 | function mode_Callback(hObject, eventdata, handles) |
---|
[12] | 802 | %------------------------------------------------------------------------ |
---|
[2] | 803 | browse=get(handles.browse_root,'UserData'); |
---|
| 804 | compare_list=get(handles.compare,'String'); |
---|
| 805 | val=get(handles.compare,'Value'); |
---|
| 806 | compare=compare_list{val}; |
---|
| 807 | if strcmp(compare,'displacement') |
---|
| 808 | mode='displacement'; |
---|
| 809 | else |
---|
| 810 | mode_list=get(handles.mode,'String'); |
---|
[236] | 811 | if ischar(mode_list) |
---|
| 812 | mode_list={mode_list}; |
---|
| 813 | end |
---|
[2] | 814 | mode_value=get(handles.mode,'Value'); |
---|
| 815 | mode=mode_list{mode_value}; |
---|
| 816 | end |
---|
| 817 | displ_num=[];%default |
---|
[137] | 818 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[2] | 819 | % last_i=str2num(get(handles.last_i,'String')); |
---|
[71] | 820 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
[2] | 821 | siztime=size(time); |
---|
| 822 | nbfield=siztime(1); |
---|
| 823 | nbfield2=siztime(2); |
---|
| 824 | indchosen=1; %%first pair selected by default |
---|
| 825 | if isequal(mode,'pair j1-j2')%| isequal(mode,'st_pair j1-j2') |
---|
| 826 | dt=1; |
---|
| 827 | displ=''; |
---|
| 828 | index=0; |
---|
| 829 | numlist_a=[]; |
---|
| 830 | numlist_B=[]; |
---|
| 831 | %get all the time intervals in bursts |
---|
| 832 | displ_dt=1;%default |
---|
| 833 | nbfield2=min(nbfield2,10);%limitate the number of pairs to 10x10 |
---|
| 834 | for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'pair j1-j2' mode |
---|
| 835 | for numod_b=(numod_a+1):nbfield2 |
---|
[112] | 836 | index=index+1; |
---|
| 837 | numlist_a(index)=numod_a; |
---|
| 838 | numlist_b(index)=numod_b; |
---|
| 839 | if ~isempty(time) |
---|
[54] | 840 | dt(numod_a,numod_b)=time(ref_i,numod_b)-time(ref_i,numod_a);%first time interval dt |
---|
[2] | 841 | displ_dt(index)=dt(numod_a,numod_b); |
---|
[112] | 842 | else |
---|
| 843 | displ_dt(index)=1; |
---|
| 844 | end |
---|
| 845 | end |
---|
| 846 | end |
---|
| 847 | [dtsort,indsort]=sort(displ_dt); |
---|
| 848 | if ~isempty(numlist_a) |
---|
| 849 | displ_num(1,:)=numlist_a(indsort); |
---|
| 850 | displ_num(2,:)=numlist_b(indsort); |
---|
| 851 | end |
---|
| 852 | displ_num(3,:)=0; |
---|
| 853 | displ_num(4,:)=0; |
---|
| 854 | set(handles.jtext,'Visible','Off') |
---|
[2] | 855 | set(handles.first_j,'Visible','Off') |
---|
| 856 | set(handles.last_j,'Visible','Off') |
---|
| 857 | set(handles.incr_j,'Visible','Off') |
---|
| 858 | set(handles.nb_field2,'Visible','Off') |
---|
| 859 | set(handles.ref_j,'Visible','Off') |
---|
| 860 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') |
---|
[112] | 861 | for index=1:min(nbfield2-1,200) |
---|
| 862 | displ_num(1,index)=-floor(index/2); |
---|
| 863 | displ_num(2,index)=ceil(index/2); |
---|
| 864 | displ_num(3,index)=0; |
---|
| 865 | displ_num(4,index)=0; |
---|
| 866 | end |
---|
| 867 | set(handles.jtext,'Visible','On') |
---|
| 868 | set(handles.first_j,'Visible','On') |
---|
| 869 | set(handles.last_j,'Visible','On') |
---|
| 870 | set(handles.incr_j,'Visible','On') |
---|
| 871 | set(handles.nb_field2,'Visible','On') |
---|
| 872 | set(handles.ref_j,'Visible','On') |
---|
| 873 | if nbfield > 1 |
---|
[2] | 874 | set(handles.itext,'Visible','On') |
---|
| 875 | set(handles.first_i,'Visible','On') |
---|
| 876 | set(handles.last_i,'Visible','On') |
---|
| 877 | set(handles.incr_i,'Visible','On') |
---|
| 878 | set(handles.nb_field,'Visible','On') |
---|
| 879 | set(handles.ref_i,'Visible','On') |
---|
| 880 | else |
---|
| 881 | set(handles.itext,'Visible','Off') |
---|
| 882 | set(handles.first_i,'Visible','Off') |
---|
| 883 | set(handles.last_i,'Visible','Off') |
---|
| 884 | set(handles.incr_i,'Visible','Off') |
---|
| 885 | set(handles.nb_field,'Visible','Off') |
---|
| 886 | set(handles.ref_i,'Visible','Off') |
---|
| 887 | end |
---|
[112] | 888 | elseif isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 889 | for index=1:200%min(nbfield-1,200) |
---|
| 890 | displ_num(1,index)=0; |
---|
| 891 | displ_num(2,index)=0; |
---|
| 892 | displ_num(3,index)=-floor(index/2); |
---|
| 893 | displ_num(4,index)=ceil(index/2); |
---|
| 894 | end |
---|
| 895 | set(handles.itext,'Visible','On') |
---|
| 896 | set(handles.first_i,'Visible','On') |
---|
| 897 | set(handles.last_i,'Visible','On') |
---|
| 898 | set(handles.incr_i,'Visible','On') |
---|
| 899 | set(handles.nb_field,'Visible','On') |
---|
| 900 | set(handles.ref_i,'Visible','On') |
---|
| 901 | if nbfield2 > 1 |
---|
[2] | 902 | set(handles.jtext,'Visible','On') |
---|
| 903 | set(handles.first_j,'Visible','On') |
---|
| 904 | set(handles.last_j,'Visible','On') |
---|
| 905 | set(handles.incr_j,'Visible','On') |
---|
| 906 | set(handles.nb_field2,'Visible','On') |
---|
| 907 | set(handles.ref_j,'Visible','On') |
---|
[112] | 908 | else |
---|
[2] | 909 | set(handles.jtext,'Visible','Off') |
---|
| 910 | set(handles.first_j,'Visible','Off') |
---|
| 911 | set(handles.last_j,'Visible','Off') |
---|
| 912 | set(handles.incr_j,'Visible','Off') |
---|
| 913 | set(handles.nb_field2,'Visible','Off') |
---|
| 914 | set(handles.ref_j,'Visible','Off') |
---|
| 915 | end |
---|
| 916 | elseif isequal(mode,'displacement')%the pairs have the same indices |
---|
[112] | 917 | displ_num(1,1)=0; |
---|
| 918 | displ_num(2,1)=0; |
---|
| 919 | displ_num(3,1)=0; |
---|
| 920 | displ_num(4,1)=0; |
---|
| 921 | if nbfield > 1 |
---|
[2] | 922 | set(handles.itext,'Visible','On') |
---|
| 923 | set(handles.first_i,'Visible','On') |
---|
| 924 | set(handles.last_i,'Visible','On') |
---|
| 925 | set(handles.incr_i,'Visible','On') |
---|
| 926 | set(handles.nb_field,'Visible','On') |
---|
| 927 | set(handles.ref_i,'Visible','On') |
---|
| 928 | else |
---|
| 929 | set(handles.itext,'Visible','Off') |
---|
| 930 | set(handles.first_i,'Visible','Off') |
---|
| 931 | set(handles.last_i,'Visible','Off') |
---|
| 932 | set(handles.incr_i,'Visible','Off') |
---|
| 933 | set(handles.nb_field,'Visible','Off') |
---|
| 934 | set(handles.ref_i,'Visible','Off') |
---|
| 935 | end |
---|
| 936 | if nbfield2 > 1 |
---|
[112] | 937 | set(handles.jtext,'Visible','On') |
---|
| 938 | set(handles.first_j,'Visible','On') |
---|
| 939 | set(handles.last_j,'Visible','On') |
---|
| 940 | set(handles.incr_j,'Visible','On') |
---|
| 941 | set(handles.nb_field2,'Visible','On') |
---|
| 942 | set(handles.ref_j,'Visible','On') |
---|
[2] | 943 | else |
---|
| 944 | set(handles.jtext,'Visible','Off') |
---|
| 945 | set(handles.first_j,'Visible','Off') |
---|
| 946 | set(handles.last_j,'Visible','Off') |
---|
| 947 | set(handles.incr_j,'Visible','Off') |
---|
| 948 | set(handles.nb_field2,'Visible','Off') |
---|
| 949 | set(handles.ref_j,'Visible','Off') |
---|
| 950 | end |
---|
[112] | 951 | end |
---|
[2] | 952 | set(handles.list_pair_civ1,'UserData',displ_num); |
---|
| 953 | find_netcpair_civ1(hObject, eventdata, handles) |
---|
| 954 | find_netcpair_civ2(hObject, eventdata, handles) |
---|
| 955 | |
---|
[12] | 956 | %------------------------------------------------------------------------ |
---|
[2] | 957 | % determine the menu for civ1 pairs depending on existing netcdf file at the middle of |
---|
| 958 | % the field series set by first_i, incr, last_i |
---|
| 959 | function find_netcpair_civ1(hObject, eventdata, handles) |
---|
[12] | 960 | %------------------------------------------------------------------------ |
---|
[2] | 961 | set(gcf,'Pointer','watch') |
---|
| 962 | %nomenclature types |
---|
[71] | 963 | filebase=get(handles.RootName,'String'); |
---|
[2] | 964 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
| 965 | browse=get(handles.browse_root,'UserData'); |
---|
| 966 | compare_list=get(handles.compare,'String'); |
---|
| 967 | val=get(handles.compare,'Value'); |
---|
| 968 | compare=compare_list{val}; |
---|
| 969 | if strcmp(compare,'displacement') |
---|
| 970 | mode='displacement'; |
---|
| 971 | else |
---|
| 972 | mode_list=get(handles.mode,'String'); |
---|
| 973 | mode_value=get(handles.mode,'Value'); |
---|
| 974 | mode=mode_list{mode_value}; |
---|
| 975 | end |
---|
| 976 | |
---|
| 977 | % nomenclature type of the .nc files |
---|
| 978 | nom_type_ima=[];%default |
---|
| 979 | if isfield(browse,'nom_type_ima') |
---|
| 980 | nom_type_ima=browse.nom_type_ima; |
---|
| 981 | end |
---|
| 982 | |
---|
[112] | 983 | %determine nom_type_nc: |
---|
[2] | 984 | nom_type_nc=[];%default |
---|
| 985 | if isfield(browse,'nom_type_nc') |
---|
| 986 | nom_type_nc=browse.nom_type_nc; |
---|
| 987 | end |
---|
| 988 | if isempty(nom_type_nc) |
---|
[112] | 989 | [nom_type_nc]=nomtype2pair(nom_type_ima,isequal(mode,'series(Di)'),isequal(mode,'series(Dj)')); |
---|
[2] | 990 | end |
---|
| 991 | browse.nom_type_nc=nom_type_nc; |
---|
| 992 | set(handles.browse_root,'UserData',browse) |
---|
| 993 | |
---|
| 994 | %reads .nc subdirectoy and image numbers from the interface |
---|
| 995 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
[45] | 996 | % first_i=str2num(get(handles.first_i,'String')); |
---|
| 997 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 998 | % incr=str2num(get(handles.incr_i,'String')); |
---|
| 999 | % num1=first_i:incr:last_i; |
---|
| 1000 | % if isempty(num1) |
---|
| 1001 | % set(handles.list_pair_civ1,'String',{''}); |
---|
| 1002 | % return |
---|
| 1003 | % end |
---|
| 1004 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[2] | 1005 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
| 1006 | ref_j=0; |
---|
| 1007 | else |
---|
[45] | 1008 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
[2] | 1009 | end |
---|
[71] | 1010 | time=get(handles.RootName,'UserData');%get the set of times |
---|
[2] | 1011 | if isempty(time) |
---|
| 1012 | time=[0 1]; |
---|
[112] | 1013 | end |
---|
[71] | 1014 | %dt_unit=str2double(get(handles.dt,'String'));% used when there is no image documentation file |
---|
| 1015 | dt_unit=1000;%default |
---|
[2] | 1016 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 1017 | |
---|
[112] | 1018 | %eliminate the first pairs inconsistent with the position |
---|
| 1019 | if isempty(displ_num) |
---|
| 1020 | nbpair=0; |
---|
| 1021 | else |
---|
[2] | 1022 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
| 1023 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 1024 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1025 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 1026 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1027 | end |
---|
[112] | 1028 | end |
---|
[2] | 1029 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
| 1030 | |
---|
[112] | 1031 | %look for existing processed pairs involving the field at the middle of the series if civ1 will not |
---|
[2] | 1032 | % be performed, while the result is needed for next steps. |
---|
| 1033 | displ_pair={''}; |
---|
| 1034 | select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs |
---|
| 1035 | testpair=0; |
---|
| 1036 | if get(handles.CIV1,'Value')==0 % |
---|
[112] | 1037 | if ~exist(fullfile(filepath,subdir_civ1,ext_dir),'dir') |
---|
| 1038 | msgbox_uvmat('ERROR',['no civ1 file available: subdirectory ' subdir_civ1 ' does not exist']); |
---|
| 1039 | set(handles.list_pair_civ1,'String',{}); |
---|
| 1040 | return |
---|
[2] | 1041 | end |
---|
[112] | 1042 | for ipair=1:nbpair |
---|
[2] | 1043 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
[112] | 1044 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
[2] | 1045 | select(ipair)=exist(filename,'file')==2; |
---|
| 1046 | end |
---|
| 1047 | if ~exist('select','var') || isequal(select,zeros(size(1:nbpair))) |
---|
[112] | 1048 | if isfield(browse,'incr_pair') |
---|
[2] | 1049 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
| 1050 | num_i2=ref_i+ceil(browse.incr_pair(1)/2); |
---|
| 1051 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
| 1052 | num_j2=ref_j+ceil(browse.incr_pair(2)/2); |
---|
| 1053 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ1); |
---|
| 1054 | select(1)=exist(filename,'file')==2; |
---|
| 1055 | testpair=1; |
---|
| 1056 | else |
---|
[112] | 1057 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
[2] | 1058 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1]); |
---|
| 1059 | else |
---|
| 1060 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ1]); |
---|
| 1061 | end |
---|
[112] | 1062 | set(handles.list_pair_civ1,'String',{''}); |
---|
| 1063 | %COMPLETER CAS STEREO |
---|
[2] | 1064 | return |
---|
| 1065 | end |
---|
| 1066 | end |
---|
| 1067 | end |
---|
| 1068 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 1069 | if testpair |
---|
[73] | 1070 | displ_pair{1}=['Di= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
| 1071 | % elseif ~isequal(get(handles.root_txt,'String'),'dt(ms)=') |
---|
| 1072 | % for ipair=1:nbpair |
---|
| 1073 | % if select(ipair) |
---|
| 1074 | % if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1075 | % dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));%time interval dt |
---|
| 1076 | % displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1077 | % end |
---|
| 1078 | % else |
---|
| 1079 | % displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1080 | % end |
---|
| 1081 | % end |
---|
[2] | 1082 | else |
---|
[73] | 1083 | for ipair=1:nbpair |
---|
| 1084 | if select(ipair) |
---|
| 1085 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1086 | 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 |
---|
| 1087 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1088 | else |
---|
| 1089 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1090 | end |
---|
| 1091 | end |
---|
| 1092 | end |
---|
[2] | 1093 | end |
---|
| 1094 | elseif isequal(mode,'series(Dj)')%|isequal(mode,'st_series(Dj)')% series on the j index |
---|
| 1095 | if testpair |
---|
[112] | 1096 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
[2] | 1097 | else |
---|
[112] | 1098 | for ipair=1:nbpair |
---|
| 1099 | if select(ipair) |
---|
| 1100 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1101 | 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 |
---|
| 1102 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1103 | end |
---|
| 1104 | elseif testpair |
---|
| 1105 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(2)/2)) '|' num2str(ceil(browse.incr_pair(2)/2))]; |
---|
| 1106 | else |
---|
| 1107 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1108 | end |
---|
| 1109 | end |
---|
| 1110 | end |
---|
[2] | 1111 | elseif isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2')%case of pairs |
---|
| 1112 | for ipair=1:nbpair |
---|
| 1113 | if select(ipair) |
---|
[112] | 1114 | 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 |
---|
| 1115 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
| 1116 | ' :dt= ' num2str(dt*1000)]; |
---|
| 1117 | else |
---|
| 1118 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1119 | end |
---|
| 1120 | end |
---|
[2] | 1121 | elseif isequal(mode,'displacement') |
---|
[112] | 1122 | displ_pair={'Di=Dj=0'}; |
---|
| 1123 | end |
---|
[2] | 1124 | set(handles.list_pair_civ1,'String',displ_pair'); |
---|
[229] | 1125 | ichoice=find(select,1); |
---|
[45] | 1126 | if (isempty(ichoice) || ichoice < 1); ichoice=1; end; |
---|
| 1127 | initial=get(handles.list_pair_civ1,'Value');%initial choice of pair |
---|
[112] | 1128 | if initial>nbpair |
---|
| 1129 | set(handles.list_pair_civ1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
[45] | 1130 | end |
---|
| 1131 | if numel(select)>=initial && ~isequal(select(initial),1) |
---|
[2] | 1132 | set(handles.list_pair_civ1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
| 1133 | end |
---|
[45] | 1134 | |
---|
[2] | 1135 | %set(handles.list_pair_civ2,'String',displ_pair'); |
---|
| 1136 | initial=get(handles.list_pair_civ2,'Value'); |
---|
| 1137 | if initial>length(displ_pair')%|~isequal(select(initial),1) |
---|
| 1138 | if ichoice <= length(displ_pair') |
---|
| 1139 | set(handles.list_pair_civ2,'Value',ichoice);% same pair proposed by default for civ2 |
---|
| 1140 | else |
---|
| 1141 | set(handles.list_pair_civ2,'Value',1);% same pair proposed by default for civ2 |
---|
| 1142 | end |
---|
| 1143 | end |
---|
| 1144 | set(handles.list_pair_civ2,'String',displ_pair'); |
---|
| 1145 | set(gcf,'Pointer','arrow') |
---|
[12] | 1146 | |
---|
| 1147 | %------------------------------------------------------------------------ |
---|
[112] | 1148 | % determine the menu for civ2 pairs depending on the existing netcdf file at the |
---|
| 1149 | %middle of the series set by first_i, incr, last_i |
---|
[2] | 1150 | function find_netcpair_civ2(hObject, eventdata, handles) |
---|
[12] | 1151 | %------------------------------------------------------------------------ |
---|
[2] | 1152 | set(gcf,'Pointer','watch') |
---|
| 1153 | %nomenclature types |
---|
[71] | 1154 | filebase=get(handles.RootName,'String'); |
---|
[2] | 1155 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
| 1156 | browse=get(handles.browse_root,'UserData'); |
---|
| 1157 | compare_list=get(handles.compare,'String'); |
---|
| 1158 | val=get(handles.compare,'Value'); |
---|
| 1159 | compare=compare_list{val}; |
---|
| 1160 | if strcmp(compare,'displacement') |
---|
| 1161 | mode='displacement'; |
---|
| 1162 | else |
---|
[252] | 1163 | mode_list=get(handles.mode,'String') |
---|
[270] | 1164 | if isempty(mode_list) |
---|
| 1165 | msgbox_uvmat('ERROR','please enter an input image or netcdf file') |
---|
| 1166 | return |
---|
| 1167 | end |
---|
[252] | 1168 | mode_value=get(handles.mode,'Value') |
---|
[2] | 1169 | mode=mode_list{mode_value}; |
---|
| 1170 | end |
---|
| 1171 | |
---|
| 1172 | % nomenclature type of the .nc files |
---|
| 1173 | nom_type_ima='ima_num';%default |
---|
| 1174 | if isfield(browse,'nom_type_ima') |
---|
| 1175 | nom_type_ima=browse.nom_type_ima; |
---|
| 1176 | end |
---|
| 1177 | nom_type_nc='_i1-i2';%default |
---|
| 1178 | if isfield(browse,'nom_type_nc') |
---|
| 1179 | nom_type_nc=browse.nom_type_nc; |
---|
| 1180 | end |
---|
[94] | 1181 | if isequal(nom_type_ima,'png_old') || isequal(nom_type_ima,'netc_old')|| isequal(nom_type_ima,'raw_SMD')|| isequal(nom_type_nc,'netc_old') |
---|
[2] | 1182 | nom_type_nc='netc_old';%nom_type for the netcdf files |
---|
[94] | 1183 | elseif isequal(nom_type_ima,'none')||isequal(nom_type_nc,'none') |
---|
[2] | 1184 | nom_type_nc='none'; |
---|
[94] | 1185 | elseif isequal(nom_type_ima,'avi')||isequal(nom_type_ima,'_i')||isequal(nom_type_ima,'ima_num')||isequal(nom_type_nc,'_i1-i2') |
---|
[112] | 1186 | nom_type_nc='_i1-i2'; |
---|
[2] | 1187 | else |
---|
| 1188 | if isequal(mode,'series(Di)')%|isequal(mode,'st_series(Di)') |
---|
| 1189 | nom_type_nc='_i1-i2_j'; % PIV in volume |
---|
| 1190 | else |
---|
| 1191 | nom_type_nc='_i_j1-j2'; |
---|
[112] | 1192 | end |
---|
[2] | 1193 | end |
---|
| 1194 | browse.nom_type_nc=nom_type_nc; |
---|
| 1195 | set(handles.browse_root,'UserData',browse) |
---|
| 1196 | |
---|
| 1197 | %reads .nc subdirectory and image numbers from the interface |
---|
| 1198 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
| 1199 | subdir_civ2=get(handles.subdir_civ2,'String');%subdirectory subdir_civ2 for the netcdf data |
---|
[45] | 1200 | % first_i=str2num(get(handles.first_i,'String')); |
---|
| 1201 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 1202 | % incr=str2num(get(handles.incr_i,'String')); |
---|
| 1203 | % num1=first_i:incr:last_i; |
---|
| 1204 | % if isempty(num1) |
---|
| 1205 | % set(handles.list_pair_civ2,'Value',1); |
---|
| 1206 | % set(handles.list_pair_civ2,'String',{''}); |
---|
| 1207 | % return |
---|
| 1208 | % end |
---|
[137] | 1209 | ref_i=str2double(get(handles.ref_i_civ2,'String')); |
---|
[2] | 1210 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
| 1211 | ref_j=0; |
---|
| 1212 | else |
---|
[137] | 1213 | ref_j=str2double(get(handles.ref_j_civ2,'String')); |
---|
[2] | 1214 | end |
---|
[71] | 1215 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
[2] | 1216 | if isempty(time) |
---|
| 1217 | time=[0 1];%default |
---|
| 1218 | end |
---|
[71] | 1219 | %dt_unit=str2num(get(handles.dt,'String'));% used when there is no image documentation file |
---|
[73] | 1220 | %dt_unit=1000; |
---|
[2] | 1221 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 1222 | |
---|
| 1223 | |
---|
[112] | 1224 | %eliminate the first pairs inconsistent with the position |
---|
[2] | 1225 | if isempty(displ_num) |
---|
| 1226 | nbpair=0; |
---|
| 1227 | else |
---|
| 1228 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
[112] | 1229 | if isequal(mode,'series(Di)')% | isequal(mode,'st_series(Di)') |
---|
[2] | 1230 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
[112] | 1231 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
[2] | 1232 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1233 | end |
---|
| 1234 | end |
---|
| 1235 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
| 1236 | |
---|
[112] | 1237 | %look for existing processed pairs involving the field at the middle of the series if civ1 will not |
---|
[2] | 1238 | % be performed, while the result is needed for next steps. |
---|
| 1239 | displ_pair={''}; %default |
---|
| 1240 | select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs |
---|
| 1241 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0%&... |
---|
[112] | 1242 | if ~exist(fullfile(filepath,subdir_civ2,ext_dir),'dir') |
---|
| 1243 | errordlg(['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist']) |
---|
| 1244 | set(handles.list_pair_civ2,'Value',1); |
---|
| 1245 | set(handles.list_pair_civ2,'String',{''}); |
---|
| 1246 | return |
---|
[2] | 1247 | end |
---|
[112] | 1248 | for ipair=1:nbpair |
---|
[2] | 1249 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
[112] | 1250 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
[2] | 1251 | select(ipair)=exist(filename,'file')==2; |
---|
| 1252 | end |
---|
| 1253 | if isequal(select,zeros(size(1:nbpair))) |
---|
[112] | 1254 | if isfield(browse,'incr_pair') |
---|
[2] | 1255 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
| 1256 | num_i2=ref_i+floor((browse.incr_pair(1)+1)/2); |
---|
| 1257 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
| 1258 | num_j2=ref_j+floor((browse.incr_pair(2)+1)/2); |
---|
| 1259 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ2); |
---|
| 1260 | select(1)=exist(filename,'file')==2; |
---|
| 1261 | else |
---|
[112] | 1262 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
[2] | 1263 | errordlg(['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2]) |
---|
| 1264 | else |
---|
| 1265 | errordlg(['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2]) |
---|
| 1266 | end |
---|
[112] | 1267 | set(handles.list_pair_civ2,'Value',1); |
---|
| 1268 | set(handles.list_pair_civ2,'String',{''}); |
---|
[2] | 1269 | return |
---|
| 1270 | end |
---|
| 1271 | end |
---|
| 1272 | end |
---|
[112] | 1273 | if isequal(mode,'series(Di)') % | isequal(mode,'st_series(Di)') |
---|
| 1274 | for ipair=1:nbpair |
---|
| 1275 | if select(ipair) |
---|
| 1276 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
[2] | 1277 | 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 |
---|
| 1278 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
[112] | 1279 | end |
---|
| 1280 | else |
---|
| 1281 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1282 | end |
---|
| 1283 | end |
---|
[2] | 1284 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') % series on the j index |
---|
[112] | 1285 | for ipair=1:nbpair |
---|
| 1286 | if select(ipair) |
---|
| 1287 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1288 | 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 |
---|
| 1289 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1290 | end |
---|
| 1291 | else |
---|
| 1292 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1293 | end |
---|
| 1294 | end |
---|
[2] | 1295 | elseif isequal(mode,'pair j1-j2')% | isequal(mode,'st_pair j1-j2') %case of pairs |
---|
| 1296 | for ipair=1:nbpair |
---|
| 1297 | if select(ipair) |
---|
[112] | 1298 | 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 |
---|
| 1299 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
| 1300 | ' :dt= ' num2str(dt*1000)]; |
---|
| 1301 | else |
---|
| 1302 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1303 | end |
---|
| 1304 | end |
---|
[2] | 1305 | elseif isequal(mode,'displacement') |
---|
[112] | 1306 | displ_pair={'Di=Dj=0'}; |
---|
| 1307 | end |
---|
[2] | 1308 | val=get(handles.list_pair_civ2,'Value'); |
---|
[229] | 1309 | ichoice=find(select,1); |
---|
[137] | 1310 | if (isempty(ichoice) || ichoice < 1); ichoice=1; end; |
---|
| 1311 | if get(handles.CIV2,'Value')==0 && get(handles.CIV1,'Value')==0 && get(handles.FIX1,'Value')==0 && get(handles.PATCH1,'Value')==0 |
---|
[2] | 1312 | val=ichoice;% first valid pair proposed by default in the menu |
---|
| 1313 | end |
---|
| 1314 | if val>length(displ_pair') |
---|
| 1315 | set(handles.list_pair_civ2,'Value',1);% first valid pair proposed by default in the menu |
---|
| 1316 | else |
---|
| 1317 | set(handles.list_pair_civ2,'Value',val); |
---|
| 1318 | end |
---|
| 1319 | set(handles.list_pair_civ2,'String',displ_pair'); |
---|
[12] | 1320 | set(gcf,'Pointer','arrow') |
---|
[2] | 1321 | |
---|
| 1322 | |
---|
[41] | 1323 | |
---|
[227] | 1324 | |
---|
[12] | 1325 | %------------------------------------------------------------------------ |
---|
[2] | 1326 | % --- Executes on selection change in list_pair_civ1. |
---|
| 1327 | function list_pair_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 1328 | %------------------------------------------------------------------------ |
---|
[2] | 1329 | %reproduce by default the chosen pair in the civ2 menu |
---|
| 1330 | list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs |
---|
| 1331 | index_pair=get(handles.list_pair_civ1,'Value'); |
---|
| 1332 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
[137] | 1333 | % num_a=displ_num(1,index_pair); |
---|
| 1334 | % num_b=displ_num(2,index_pair); |
---|
[2] | 1335 | list_pair2=get(handles.list_pair_civ2,'String');%get the menu of image pairs |
---|
| 1336 | if index_pair<=length(list_pair2) |
---|
| 1337 | set(handles.list_pair_civ2,'Value',index_pair); |
---|
| 1338 | end |
---|
| 1339 | |
---|
[112] | 1340 | %update first_i and last_i according to the chosen image pairs |
---|
[2] | 1341 | mode_list=get(handles.mode,'String'); |
---|
| 1342 | mode_value=get(handles.mode,'Value'); |
---|
| 1343 | mode=mode_list{mode_value}; |
---|
| 1344 | if isequal(mode,'series(Di)') |
---|
[137] | 1345 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 1346 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 1347 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
[2] | 1348 | num1=first_i:incr_i:last_i; |
---|
[137] | 1349 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 1350 | if ~isnan(lastfield) |
---|
[229] | 1351 | test_find=(num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
| 1352 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield); |
---|
| 1353 | num1=num1(test_find); |
---|
[2] | 1354 | end |
---|
| 1355 | set(handles.first_i,'String',num2str(num1(1))); |
---|
| 1356 | set(handles.last_i,'String',num2str(num1(end))); |
---|
| 1357 | elseif isequal(mode,'series(Dj)') |
---|
[137] | 1358 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 1359 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 1360 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[2] | 1361 | num_j=first_j:incr_j:last_j; |
---|
[137] | 1362 | lastfield2=str2double(get(handles.nb_field2,'String')); |
---|
| 1363 | if ~isnan(lastfield2) |
---|
[229] | 1364 | test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 1365 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2); |
---|
| 1366 | num1=num_j(test_find); |
---|
[2] | 1367 | end |
---|
| 1368 | set(handles.first_j,'String',num2str(num1(1))); |
---|
| 1369 | set(handles.last_j,'String',num2str(num1(end))); |
---|
[112] | 1370 | end |
---|
[2] | 1371 | |
---|
[12] | 1372 | %------------------------------------------------------------------------ |
---|
[2] | 1373 | % --- Executes on selection change in list_pair_civ2. |
---|
| 1374 | function list_pair_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 1375 | %------------------------------------------------------------------------ |
---|
[112] | 1376 | index_pair=get(handles.list_pair_civ2,'Value');%get the selected position index in the menu |
---|
[2] | 1377 | |
---|
[112] | 1378 | %update first_i and last_i according to the chosen image pairs |
---|
[2] | 1379 | mode_list=get(handles.mode,'String'); |
---|
| 1380 | mode_value=get(handles.mode,'Value'); |
---|
| 1381 | mode=mode_list{mode_value}; |
---|
| 1382 | if isequal(mode,'series(Di)') |
---|
[137] | 1383 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 1384 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 1385 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
[2] | 1386 | num1=first_i:incr_i:last_i; |
---|
[137] | 1387 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 1388 | if ~isnan(lastfield) |
---|
[229] | 1389 | test_find=(num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
| 1390 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield); |
---|
| 1391 | num1=num1(test_find); |
---|
[2] | 1392 | end |
---|
| 1393 | set(handles.first_i,'String',num2str(num1(1))); |
---|
| 1394 | set(handles.last_i,'String',num2str(num1(end))); |
---|
| 1395 | elseif isequal(mode,'series(Dj)') |
---|
[137] | 1396 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 1397 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 1398 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[2] | 1399 | num_j=first_j:incr_j:last_j; |
---|
[137] | 1400 | lastfield2=str2double(get(handles.nb_field2,'String')); |
---|
| 1401 | if ~isnan(lastfield2) |
---|
[229] | 1402 | test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 1403 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2); |
---|
| 1404 | num1=num_j(test_find); |
---|
[2] | 1405 | end |
---|
| 1406 | set(handles.first_j,'String',num2str(num1(1))); |
---|
| 1407 | set(handles.last_j,'String',num2str(num1(end))); |
---|
[112] | 1408 | end |
---|
[2] | 1409 | |
---|
[177] | 1410 | %------------------------------------------------------------------------ |
---|
| 1411 | % --- Executes on button press in RUN: processing on local computer |
---|
[67] | 1412 | function RUN_Callback(hObject, eventdata, handles) |
---|
| 1413 | %------------------------------------------------------------------------ |
---|
[73] | 1414 | set(handles.RUN, 'Enable','Off') |
---|
| 1415 | set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[67] | 1416 | batch=0; |
---|
[229] | 1417 | errormsg=launch_jobs(hObject, eventdata, handles,batch); |
---|
[73] | 1418 | set(handles.RUN, 'Enable','On') |
---|
| 1419 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
[36] | 1420 | |
---|
[177] | 1421 | % start status callback to visualise results |
---|
[229] | 1422 | if ~isempty(errormsg) |
---|
| 1423 | display(errormsg) |
---|
| 1424 | msgbox_uvmat('ERROR',errormsg) |
---|
[257] | 1425 | elseif isfield(handles,'status') %&& ~isequal(get(handles.CivMode,'Value'),3) |
---|
[225] | 1426 | set(handles.status,'Value',1);%suppress status display |
---|
| 1427 | status_Callback(hObject, eventdata, handles) |
---|
[178] | 1428 | end |
---|
[177] | 1429 | |
---|
[12] | 1430 | %------------------------------------------------------------------------ |
---|
[2] | 1431 | % --- Executes on button press in BATCH: remote processing |
---|
| 1432 | function BATCH_Callback(hObject, eventdata, handles) |
---|
[177] | 1433 | % ----------------------------------------------------------------------- |
---|
[73] | 1434 | set(handles.BATCH, 'Enable','Off') |
---|
| 1435 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[67] | 1436 | batch=1; |
---|
[229] | 1437 | errormsg=launch_jobs(hObject, eventdata, handles, batch); |
---|
[73] | 1438 | set(handles.BATCH, 'Enable','On') |
---|
| 1439 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
[67] | 1440 | |
---|
[177] | 1441 | % start status callback to visualise results |
---|
[229] | 1442 | if ~isempty(errormsg) |
---|
| 1443 | display(errormsg) |
---|
| 1444 | msgbox_uvmat('ERROR',errormsg) |
---|
| 1445 | elseif isfield(handles,'status') |
---|
| 1446 | set(handles.status,'Value',1);%suppress status display |
---|
| 1447 | status_Callback(hObject, eventdata, handles) |
---|
[178] | 1448 | end |
---|
[227] | 1449 | |
---|
[67] | 1450 | %------------------------------------------------------------------------ |
---|
[133] | 1451 | % --- Lauch command called by RUN and BATCH: remote processing |
---|
[229] | 1452 | function errormsg=launch_jobs(hObject, eventdata, handles, batch) |
---|
[67] | 1453 | %----------------------------------------------------------------------- |
---|
[229] | 1454 | errormsg='';%default |
---|
[133] | 1455 | %% check the selected list of operations: |
---|
[2] | 1456 | operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'}; |
---|
| 1457 | box_test(1)=get(handles.CIV1,'Value'); |
---|
| 1458 | box_test(2)=get(handles.FIX1,'Value'); |
---|
| 1459 | box_test(3)=get(handles.PATCH1,'Value'); |
---|
| 1460 | box_test(4)=get(handles.CIV2,'Value'); |
---|
| 1461 | box_test(5)=get(handles.FIX2,'Value'); |
---|
| 1462 | box_test(6)=get(handles.PATCH2,'Value'); |
---|
[180] | 1463 | index_first=find(box_test==1,1); |
---|
| 1464 | if isempty(index_first) |
---|
[229] | 1465 | errormsg='no selected operation'; |
---|
[2] | 1466 | return |
---|
| 1467 | end |
---|
[180] | 1468 | index_last=find(box_test==1,1,'last'); |
---|
[159] | 1469 | box_used=box_test(index_first : index_last); |
---|
[2] | 1470 | [box_missing,ind_missing]=min(box_used); |
---|
[180] | 1471 | if isequal(box_missing,0); %there is a missing step in the sequence of operations |
---|
[229] | 1472 | errormsg=['missing' cell2mat(operations(ind_missing))]; |
---|
[2] | 1473 | return |
---|
| 1474 | end |
---|
| 1475 | |
---|
[177] | 1476 | %% check mask if selecetd |
---|
[2] | 1477 | if isequal(get(handles.get_mask_civ1,'Value'),1) |
---|
[12] | 1478 | maskname=get(handles.mask_civ1,'String'); |
---|
| 1479 | if ~exist(maskname,'file') |
---|
| 1480 | get_mask_civ1_Callback(hObject, eventdata, handles); |
---|
| 1481 | end |
---|
[2] | 1482 | end |
---|
| 1483 | if isequal(get(handles.get_mask_fix1,'Value'),1) |
---|
[12] | 1484 | maskname=get(handles.mask_fix1,'String'); |
---|
| 1485 | if ~exist(maskname,'file') |
---|
| 1486 | get_mask_fix1_Callback(hObject, eventdata, handles); |
---|
| 1487 | end |
---|
[2] | 1488 | end |
---|
| 1489 | if isequal(get(handles.get_mask_civ2,'Value'),1) |
---|
[12] | 1490 | maskname=get(handles.mask_civ2,'String'); |
---|
| 1491 | if ~exist(maskname,'file') |
---|
[112] | 1492 | get_mask_civ2_Callback(hObject, eventdata, handles); |
---|
[12] | 1493 | end |
---|
[2] | 1494 | end |
---|
| 1495 | if isequal(get(handles.get_mask_fix2,'Value'),1) |
---|
[12] | 1496 | maskname=get(handles.mask_fix2,'String'); |
---|
| 1497 | if ~exist(maskname,'file') |
---|
[112] | 1498 | get_mask_fix2_Callback(hObject, eventdata, handles); |
---|
[12] | 1499 | end |
---|
[2] | 1500 | end |
---|
| 1501 | |
---|
[177] | 1502 | %% reinitialise status callback |
---|
[178] | 1503 | if isfield(handles,'status') |
---|
[180] | 1504 | set(handles.status,'Value',0);%suppress status display |
---|
| 1505 | status_Callback(hObject, eventdata, handles) |
---|
[178] | 1506 | end |
---|
[133] | 1507 | |
---|
| 1508 | %% set the list of files and check them |
---|
| 1509 | display('checking the files...') |
---|
[227] | 1510 | [ref_i,ref_j,errormsg]=find_ref_indices(handles); |
---|
| 1511 | if ~isempty(errormsg) |
---|
| 1512 | return |
---|
| 1513 | end |
---|
[263] | 1514 | [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc,xx,yy,compare]=... |
---|
| 1515 | set_civ_filenames(handles,ref_i,ref_j,box_test) |
---|
| 1516 | |
---|
[177] | 1517 | set(handles.civ,'UserData',filecell);%store for futur use of status callback |
---|
[137] | 1518 | if isempty(filecell)% (error message displayed in fct set_civ_filenames) |
---|
[133] | 1519 | return |
---|
| 1520 | end |
---|
| 1521 | nbfield=numel(num1_civ1); |
---|
| 1522 | nbslice=numel(num_a_civ1); |
---|
| 1523 | |
---|
[257] | 1524 | %% choose the batch or run mode |
---|
[133] | 1525 | path_UVMAT=fileparts(which('uvmat')); %path to the source directory of uvmat |
---|
[112] | 1526 | xmlfile='PARAM.xml'; |
---|
[133] | 1527 | if exist(xmlfile,'file')% search parameter xml file in the whole matlab path |
---|
[54] | 1528 | t=xmltree(xmlfile); |
---|
[67] | 1529 | s=convert(t); |
---|
[2] | 1530 | end |
---|
[127] | 1531 | test_interp=0; |
---|
| 1532 | if batch |
---|
[67] | 1533 | if isfield(s,'BatchParam') |
---|
| 1534 | sparam=s.BatchParam; |
---|
[257] | 1535 | if isfield(sparam,'BatchMode') |
---|
| 1536 | batch_mode=sparam.BatchMode; |
---|
| 1537 | if ~ismember(batch_mode,{'sge','oar'}) |
---|
| 1538 | errormsg=['batch mode ' batch_mode ' not supported by UVMAT']; |
---|
| 1539 | return |
---|
| 1540 | end |
---|
[67] | 1541 | end |
---|
| 1542 | else |
---|
[229] | 1543 | errormsg='no batch civ binaries defined in PARAM.xml'; |
---|
[67] | 1544 | return |
---|
| 1545 | end |
---|
[257] | 1546 | |
---|
| 1547 | switch batch_mode |
---|
| 1548 | case 'sge' |
---|
| 1549 | % choice of batch priority: |
---|
| 1550 | [s,w]=unix('qstat -q civ.q|grep job_| wc -l'); %check the waiting list (command unix) |
---|
| 1551 | if isequal(s,0) |
---|
| 1552 | w(end)=[]; |
---|
| 1553 | str_displ={[w ' jobs in the waiting list'];... |
---|
| 1554 | '***********************';... |
---|
| 1555 | 'JOBS PRIORITY POLICY';... |
---|
| 1556 | '- urgent = less than 100 images pairs';... |
---|
| 1557 | '- normal = during the experiments';... |
---|
| 1558 | '- low = post processing';... |
---|
| 1559 | '***********************';... |
---|
| 1560 | 'Select a priority:'}; |
---|
| 1561 | ' ';... |
---|
| 1562 | str={'urgent';'normal';'low'}; |
---|
| 1563 | [ind_answer,v] = listdlg('PromptString',str_displ,... |
---|
| 1564 | 'SelectionMode','single',... |
---|
| 1565 | 'ListString',str,'ListSize',[200 100],'Name','job priority','InitialValue',3); |
---|
[269] | 1566 | pvalue=num2str((1-ind_answer)*500); % |
---|
[257] | 1567 | if isequal(v,0) % to handle Cancel button and figure close, |
---|
| 1568 | errormsg='job cancelled'; |
---|
| 1569 | return % a better way should be create |
---|
| 1570 | end |
---|
| 1571 | else |
---|
| 1572 | msgbox_uvmat('ERROR','sge batch system not available') |
---|
| 1573 | return |
---|
| 1574 | end |
---|
[269] | 1575 | case 'oar' |
---|
| 1576 | [s,w]=unix('oarstat'); %check the waiting list (command unix) |
---|
| 1577 | if ~isequal(s,0) |
---|
| 1578 | msgbox_uvmat('ERROR','oar batch system not available') |
---|
| 1579 | return |
---|
| 1580 | end |
---|
[225] | 1581 | end |
---|
[257] | 1582 | else % run |
---|
[67] | 1583 | if isfield(s,'RunParam') |
---|
| 1584 | sparam=s.RunParam; |
---|
| 1585 | else |
---|
[225] | 1586 | msgbox_uvmat('ERROR','no run civ binaries defined in PARAM.xml') |
---|
[67] | 1587 | return |
---|
| 1588 | end |
---|
[225] | 1589 | end |
---|
[238] | 1590 | |
---|
| 1591 | %% choose the civ program |
---|
[257] | 1592 | ProgList=get(handles.CivMode,'String'); |
---|
| 1593 | index=get(handles.CivMode,'Value'); |
---|
| 1594 | % CivX=isequal(ProgList{index},'CivX'); |
---|
| 1595 | % CivAll=isequal(ProgList{index},'CivAll'); |
---|
| 1596 | % CivUvmat=isequal(ProgList{index},'CivUvmat'); |
---|
| 1597 | CivMode=ProgList{index}; |
---|
| 1598 | %CivMode=isequal(get(handles.CivMode,'Value'),2); % Boolean for new civ programs |
---|
| 1599 | |
---|
| 1600 | switch CivMode |
---|
| 1601 | case 'CivAll' |
---|
| 1602 | if isfield(sparam,'CivBin') |
---|
| 1603 | CivBin=sparam.CivBin; |
---|
[260] | 1604 | if ~exist(CivBin,'file') || isempty(which(CivBin))% if path defined as relative to uvmat |
---|
[257] | 1605 | sparam.CivBin=fullfile(path_UVMAT,CivBin); |
---|
| 1606 | if ~exist(sparam.CivBin,'file') |
---|
| 1607 | msgbox_uvmat('ERROR',['CIVx binary ' CivBin ' defined in PARAM.xm does not exist']) |
---|
| 1608 | return |
---|
| 1609 | end |
---|
| 1610 | end |
---|
[112] | 1611 | end |
---|
[257] | 1612 | case 'CivX' |
---|
| 1613 | if isfield(sparam,'Civ1Bin') |
---|
| 1614 | Civ1Bin=sparam.Civ1Bin; |
---|
[263] | 1615 | if ~exist(Civ1Bin,'file')&&~isempty(which(Civ1Bin))% if path defined as relative to uvmat |
---|
[257] | 1616 | sparam.Civ1Bin=fullfile(path_UVMAT,Civ1Bin); |
---|
| 1617 | if ~exist(sparam.Civ1Bin,'file') |
---|
| 1618 | msgbox_uvmat('ERROR',['civ1 binary ' Civ1Bin ' defined in PARAM.xm does not exist']) |
---|
| 1619 | return |
---|
| 1620 | end |
---|
| 1621 | end |
---|
[112] | 1622 | end |
---|
[257] | 1623 | if isfield(sparam,'Civ2Bin') |
---|
| 1624 | Civ2Bin=sparam.Civ2Bin; |
---|
[263] | 1625 | if ~exist(Civ2Bin,'file')&&~isempty(which(Civ2Bin))% if path defined as relative to uvmat |
---|
[257] | 1626 | sparam.Civ2Bin=fullfile(path_UVMAT,Civ2Bin); |
---|
| 1627 | if ~exist(sparam.Civ2Bin,'file') |
---|
| 1628 | msgbox_uvmat('ERROR',['civ2 binary ' Civ2Bin ' defined in PARAM.xm does not exist']) |
---|
| 1629 | return |
---|
| 1630 | end |
---|
| 1631 | end |
---|
[112] | 1632 | end |
---|
[257] | 1633 | if isfield(sparam,'PatchBin') |
---|
[263] | 1634 | if ~exist(sparam.PatchBin,'file')&&~isempty(which(sparam.PatchBin))% if path defined as relative to uvmat |
---|
[257] | 1635 | sparam.PatchBin=fullfile(path_UVMAT,sparam.PatchBin); |
---|
| 1636 | end |
---|
| 1637 | end |
---|
| 1638 | if isfield(sparam,'FixBin') |
---|
[263] | 1639 | if ~exist(sparam.FixBin,'file')&&~isempty(which(sparam.FixBin))% if path defined as relative to uvmat |
---|
[257] | 1640 | sparam.FixBin=fullfile(path_UVMAT,sparam.FixBin); |
---|
| 1641 | end |
---|
| 1642 | end |
---|
| 1643 | case 'Matlab' |
---|
| 1644 | if batch |
---|
[265] | 1645 | %% vᅵrifier Mtlab installᅵ sur le cluster |
---|
[257] | 1646 | end |
---|
[225] | 1647 | end |
---|
[2] | 1648 | |
---|
| 1649 | |
---|
[225] | 1650 | |
---|
[133] | 1651 | %% get civ1 parameters: |
---|
[112] | 1652 | display('files OK, processing...') |
---|
[2] | 1653 | if box_test(1)==1 |
---|
| 1654 | par_civ1=read_param_civ1(handles,filecell.ima1.civ1{1,1}); |
---|
[112] | 1655 | end |
---|
[2] | 1656 | |
---|
[257] | 1657 | %% get fix1 parameters TODO : par_fix1=read_param_fix1(handles); |
---|
[112] | 1658 | if box_test(2)==1 |
---|
[2] | 1659 | flagindex1(1)=get(handles.vec_Fmin2, 'Value'); |
---|
| 1660 | flagindex1(2)=get(handles.vec_F3, 'Value'); |
---|
| 1661 | flagindex1(3)=get(handles.vec_F2, 'Value'); |
---|
[127] | 1662 | thresh_vecC1=str2double(get(handles.thresh_vecC,'String'));%threshold on image correlation vec_C |
---|
| 1663 | thresh_vel1=str2double(get(handles.thresh_vel,'String'));%threshold on velocity modulus |
---|
[2] | 1664 | test_mask=get(handles.get_mask_fix1,'Value'); |
---|
| 1665 | nbslice_mask=get(handles.mask_fix1,'UserData'); % get the number of slices (= number of masks) |
---|
| 1666 | %%%%%%%%%%%%%COMPLETER LE PROGRAMME FIX |
---|
[112] | 1667 | % inf_sup=get(handles.inf_sup1,'Value');80 |
---|
| 1668 | % fileref=get(handles.ref_fix1,'String'); |
---|
| 1669 | % refpath=get(handles.ref_fix1,'UserData'); |
---|
| 1670 | % fileref=fullfile(refpath,fileref); |
---|
[2] | 1671 | menu=get(handles.field_ref1,'String'); |
---|
| 1672 | index=get(handles.field_ref1,'Value'); |
---|
| 1673 | if isempty(menu) |
---|
| 1674 | fieldchoice=''; |
---|
| 1675 | else |
---|
| 1676 | fieldchoice=menu{index}; |
---|
[112] | 1677 | msgbox_uvmat('WARNING','reference field is not used presently with batch, use RUN option') |
---|
| 1678 | end |
---|
[2] | 1679 | end |
---|
[112] | 1680 | |
---|
[133] | 1681 | %% get patch1 parameters |
---|
[67] | 1682 | if box_test(3)==1 |
---|
[127] | 1683 | rho_patch1=str2double(get(handles.rho_patch1,'String')); |
---|
| 1684 | if isnan(rho_patch1) |
---|
[112] | 1685 | rho_patch1='1000'; |
---|
| 1686 | set(handles.rho_patch1,'String','1') |
---|
| 1687 | else |
---|
| 1688 | rho_patch1=num2str(1000*rho_patch1); |
---|
| 1689 | end |
---|
| 1690 | nx_patch1=get(handles.nx_patch1,'String'); |
---|
| 1691 | ny_patch1=get(handles.ny_patch1,'String'); |
---|
[127] | 1692 | if isnan(str2double(nx_patch1)) |
---|
[112] | 1693 | nx_patch1='50' ;%default |
---|
| 1694 | set(handles.nx_patch1,'String','50'); |
---|
| 1695 | end |
---|
[127] | 1696 | if isnan(str2double(ny_patch1)) |
---|
[112] | 1697 | ny_patch1='50' ;%default |
---|
| 1698 | set(handles.ny_patch1,'String','50'); |
---|
| 1699 | end |
---|
| 1700 | subdomain_patch1=get(handles.subdomain_patch1,'String'); |
---|
| 1701 | thresh_patch1=get(handles.thresh_patch1,'String'); |
---|
| 1702 | end |
---|
| 1703 | |
---|
[133] | 1704 | %% get civ2 parameters: |
---|
[2] | 1705 | if box_test(4)==1 |
---|
| 1706 | par_civ2=read_param_civ2(handles,cell2mat(filecell.ima1.civ2(1,1))); |
---|
| 1707 | end |
---|
| 1708 | |
---|
[133] | 1709 | %% get fix2 parameters |
---|
[112] | 1710 | if box_test(5)==1 |
---|
[2] | 1711 | flagindex2(1)=get(handles.vec_Fmin2_2, 'Value'); |
---|
| 1712 | flagindex2(2)=get(handles.vec_F3_2, 'Value'); |
---|
| 1713 | flagindex2(3)=get(handles.vec_F4, 'Value'); |
---|
[127] | 1714 | thresh_vec2C=str2double(get(handles.thresh_vec2C,'String'));%threshold on image correlation vec_C |
---|
| 1715 | thresh_vel2=str2double(get(handles.thresh_vel2,'String'));%threshold on velocity modulus |
---|
[2] | 1716 | test_mask=get(handles.get_mask_fix2,'Value'); |
---|
| 1717 | nbslice_mask=get(handles.mask_fix2,'UserData'); % get the number of slices (= number of masks) |
---|
[112] | 1718 | %%%%%%%%%%%%%COMPLETER LE PROGRAMME FIX AVEC REF FILE ET OPTION inf_sup=2 |
---|
| 1719 | % inf_sup=get(handles.inf_sup2,'Value'); |
---|
| 1720 | % ref=get(handles.ref_fix2,'UserData'); |
---|
| 1721 | |
---|
[2] | 1722 | %%%%%%%%%%%%%%%%%%% |
---|
| 1723 | end |
---|
| 1724 | |
---|
[133] | 1725 | %% get patch2 parameters |
---|
[2] | 1726 | if box_test(6)==1 |
---|
[127] | 1727 | rho_patch2=str2double(get(handles.rho_patch2,'String')); |
---|
| 1728 | if isnan(rho_patch2) |
---|
[2] | 1729 | rho_patch2='1000'; |
---|
| 1730 | set(handles.rho_patch2,'String','1') |
---|
| 1731 | else |
---|
| 1732 | rho_patch2=num2str(1000*rho_patch2); |
---|
| 1733 | end |
---|
| 1734 | nx_patch2=get(handles.nx_patch2,'String'); |
---|
| 1735 | ny_patch2=get(handles.ny_patch2,'String'); |
---|
[127] | 1736 | if isnan(str2double(nx_patch2)) |
---|
[2] | 1737 | nx_patch2='50' ;%default |
---|
| 1738 | set(handles.nx_patch2,'String','50'); |
---|
| 1739 | end |
---|
[127] | 1740 | if isnan(str2double(ny_patch2)) |
---|
[2] | 1741 | ny_patch2='50' ;%default |
---|
| 1742 | set(handles.ny_patch2,'String','50'); |
---|
| 1743 | end |
---|
| 1744 | subdomain_patch2=get(handles.subdomain_patch2,'String'); |
---|
| 1745 | thresh_patch2=get(handles.thresh_patch2,'String'); |
---|
| 1746 | end |
---|
| 1747 | |
---|
[133] | 1748 | %% MAIN LOOP |
---|
[71] | 1749 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
[265] | 1750 | |
---|
[134] | 1751 | super_cmd=[]; |
---|
[269] | 1752 | batch_file_list=[]; |
---|
[265] | 1753 | |
---|
[2] | 1754 | for ifile=1:nbfield |
---|
| 1755 | for j=1:nbslice |
---|
[257] | 1756 | % initiate system command |
---|
[112] | 1757 | i_cmd=0; |
---|
[257] | 1758 | switch CivMode |
---|
| 1759 | case 'CivX' |
---|
| 1760 | cmd=''; |
---|
| 1761 | if isunix % check: necessaire aussi en RUN? |
---|
| 1762 | cmd='#!/bin/bash \n'; |
---|
| 1763 | cmd=[cmd '#$ -cwd \n']; |
---|
| 1764 | cmd=[cmd 'hostname && date \n']; |
---|
| 1765 | cmd=[cmd 'umask 002 \n'];%allow writting access to created files for user group |
---|
| 1766 | end |
---|
| 1767 | case 'CivAll' |
---|
| 1768 | % if CivAll |
---|
| 1769 | CivAllxml=xmltree;% xml contents, all parameters |
---|
| 1770 | CivAllCmd=''; |
---|
| 1771 | CivAllxml=set(CivAllxml,1,'name','CivDoc'); |
---|
[2] | 1772 | end |
---|
[263] | 1773 | [Rootbat,Filebat]=fileparts(filecell.nc.civ1{ifile,j});%output netcdf file (without extension) |
---|
[269] | 1774 | |
---|
| 1775 | filename_bat=[fullfile(Rootbat,Filebat) '.bat']; |
---|
[2] | 1776 | |
---|
[112] | 1777 | %CIV1 |
---|
[2] | 1778 | if box_test(1)==1 |
---|
[41] | 1779 | par_civ1.filename_ima_a=filecell.ima1.civ1{ifile,j}; |
---|
[112] | 1780 | par_civ1.filename_ima_b=filecell.ima2.civ1{ifile,j}; |
---|
[2] | 1781 | par_civ1.Dt=num2str(time(num2_civ1(ifile),num_b_civ1(j))-time(num1_civ1(ifile),num_a_civ1(j))); |
---|
[112] | 1782 | par_civ1.T0=num2str((time(num2_civ1(ifile),num_b_civ1(j))+time(num1_civ1(ifile),num_a_civ1(j)))/2); |
---|
[2] | 1783 | par_civ1.term_a=num2stra(num_a_civ1(j),nom_type_nc);%UTILITE? |
---|
[112] | 1784 | par_civ1.term_b=num2stra(num_b_civ1(j),nom_type_nc);% |
---|
[2] | 1785 | test_mask=get(handles.get_mask_civ1,'Value'); |
---|
[112] | 1786 | if test_mask==0 |
---|
[2] | 1787 | par_civ1.maskname='noFile use default'; |
---|
| 1788 | par_civ1.maskflag='n'; |
---|
| 1789 | else |
---|
| 1790 | maskdispl=get(handles.mask_civ1,'String'); |
---|
[12] | 1791 | if exist(maskdispl,'file') |
---|
| 1792 | par_civ1.maskname=maskdispl; |
---|
[112] | 1793 | par_civ1.maskflag='y'; |
---|
[2] | 1794 | else |
---|
[136] | 1795 | maskbase=[filecell.filebase '_' maskdispl]; % |
---|
[137] | 1796 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
[12] | 1797 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
| 1798 | par_civ1.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 1799 | if exist(par_civ1.maskname,'file') |
---|
[82] | 1800 | par_civ1.maskflag='y'; |
---|
[12] | 1801 | else |
---|
| 1802 | par_civ1.maskname='noFile use default'; |
---|
[112] | 1803 | par_civ1.maskflag='n'; |
---|
[12] | 1804 | end |
---|
[2] | 1805 | end |
---|
| 1806 | end |
---|
| 1807 | test_grid=get(handles.browse_gridciv1,'Value'); |
---|
| 1808 | if test_grid |
---|
| 1809 | par_civ1.gridflag='y'; |
---|
| 1810 | gridname=get(handles.grid_civ1,'String'); |
---|
| 1811 | if isequal(gridname(end-3:end),'grid') |
---|
[137] | 1812 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 1813 | if ~isnan(nbslice_grid) |
---|
[2] | 1814 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
[136] | 1815 | par_civ1.gridname=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
[2] | 1816 | if ~exist(par_civ1.gridname,'file') |
---|
[112] | 1817 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
[2] | 1818 | end |
---|
| 1819 | elseif exist(gridname,'file') |
---|
[112] | 1820 | par_civ1.gridname=gridname; |
---|
[2] | 1821 | else |
---|
| 1822 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
| 1823 | end |
---|
| 1824 | end |
---|
| 1825 | else |
---|
[112] | 1826 | par_civ1.gridname='noFile use default'; |
---|
| 1827 | par_civ1.gridflag='n'; |
---|
[2] | 1828 | end |
---|
[257] | 1829 | |
---|
[2] | 1830 | i_cmd=i_cmd+1; |
---|
[257] | 1831 | switch CivMode |
---|
| 1832 | case 'CivX' |
---|
| 1833 | civ1_exe=CIV1_CMD(fullfile(Rootbat,Filebat),'',par_civ1,handles,sparam);%create the parameter file .civ1.cmx and set the execution string civ1_exe |
---|
| 1834 | cmd=[cmd civ1_exe '\n']; |
---|
| 1835 | case 'CivAll' |
---|
| 1836 | CivAllCmd=[CivAllCmd ' civ1 ']; |
---|
| 1837 | str=CIV1_CMD_Unified(fullfile(Rootbat,Filebat),'',par_civ1); |
---|
| 1838 | fieldnames=fields(str); |
---|
| 1839 | [CivAllxml,uid_civ1]=add(CivAllxml,1,'element','civ1'); |
---|
| 1840 | for ilist=1:length(fieldnames) |
---|
| 1841 | val=eval(['str.' fieldnames{ilist}]); |
---|
| 1842 | if ischar(val) |
---|
| 1843 | [CivAllxml,uid_t]=add(CivAllxml,uid_civ1,'element',fieldnames{ilist}); |
---|
| 1844 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 1845 | end |
---|
[112] | 1846 | end |
---|
[2] | 1847 | end |
---|
| 1848 | end |
---|
| 1849 | |
---|
[112] | 1850 | % FIX1 |
---|
| 1851 | if box_test(2)==1 |
---|
| 1852 | test_mask=get(handles.get_mask_fix1,'Value'); |
---|
| 1853 | if test_mask==0 |
---|
[2] | 1854 | maskname=''; |
---|
[112] | 1855 | else |
---|
[2] | 1856 | maskdispl=get(handles.mask_fix1,'String'); |
---|
[137] | 1857 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
[2] | 1858 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
[136] | 1859 | maskbase=[filecell.filebase '_' maskdispl]; |
---|
[2] | 1860 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
[112] | 1861 | end |
---|
[257] | 1862 | switch CivMode |
---|
| 1863 | % if CivX |
---|
| 1864 | case 'CivX' |
---|
| 1865 | if isunix %unix system |
---|
| 1866 | cmd_FIX=[sparam.FixBin ' -f ' filecell.nc.civ1{ifile,j} ' -fi1 ' num2str(flagindex1(1)) ... |
---|
| 1867 | ' -fi2 ' num2str(flagindex1(2)) ' -fi3 ' num2str(flagindex1(3)) ... |
---|
| 1868 | ' -threshC ' num2str(thresh_vecC1) ' -threshV ' num2str(thresh_vel1) ' -maskName ' maskname]; |
---|
| 1869 | else %windows system |
---|
| 1870 | cmd_FIX=['"' sparam.FixBin '" -f "' filecell.nc.civ1{ifile,j} '" -fi1 ' num2str(flagindex1(1)) ... |
---|
| 1871 | ' -fi2 ' num2str(flagindex1(2)) ' -fi3 ' num2str(flagindex1(3)) ... |
---|
| 1872 | ' -threshC ' num2str(thresh_vecC1) ' -threshV ' num2str(thresh_vel1) ' -maskName "' maskname '"']; |
---|
| 1873 | cmd_FIX=regexprep(cmd_FIX,'\\','\\\\'); |
---|
[112] | 1874 | end |
---|
[257] | 1875 | cmd=[cmd cmd_FIX '\n']; |
---|
| 1876 | case 'CivAll' |
---|
| 1877 | fix1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 1878 | fix1.fi1=num2str(flagindex1(1)); |
---|
| 1879 | fix1.fi2=num2str(flagindex1(2)); |
---|
| 1880 | fix1.fi3=num2str(flagindex1(3)); |
---|
| 1881 | fix1.threshC=num2str(thresh_vecC1); |
---|
| 1882 | fix1.threshV=num2str(thresh_vel1); |
---|
| 1883 | fieldnames=fields(fix1); |
---|
| 1884 | [CivAllxml,uid_fix1]=add(CivAllxml,1,'element','fix1'); |
---|
| 1885 | for ilist=1:length(fieldnames) |
---|
| 1886 | val=eval(['fix1.' fieldnames{ilist}]); |
---|
| 1887 | if ischar(val) |
---|
| 1888 | [CivAllxml,uid_t]=add(CivAllxml,uid_fix1,'element',fieldnames{ilist}); |
---|
| 1889 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 1890 | end |
---|
| 1891 | end |
---|
| 1892 | CivAllCmd=[CivAllCmd ' fix1 ']; |
---|
[112] | 1893 | end |
---|
| 1894 | end |
---|
| 1895 | |
---|
| 1896 | %PATCH1 |
---|
| 1897 | if box_test(3)==1 |
---|
[257] | 1898 | switch CivMode |
---|
| 1899 | case 'CivX' |
---|
| 1900 | cmd_PATCH=PATCH_CMD(filecell.nc.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp,sparam.PatchBin); |
---|
| 1901 | cmd=[cmd cmd_PATCH '\n']; |
---|
| 1902 | case 'CivAll' |
---|
| 1903 | patch1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 1904 | patch1.nopt=subdomain_patch1; |
---|
| 1905 | patch1.maxdiff=thresh_patch1; |
---|
| 1906 | patch1.ro=rho_patch1; |
---|
| 1907 | test_grid=get(handles.get_gridpatch1,'Value'); |
---|
| 1908 | if test_grid |
---|
| 1909 | patch1.gridflag='y'; |
---|
| 1910 | gridname=get(handles.grid_patch1,'String'); |
---|
| 1911 | if isequal(gridname(end-3:end),'grid') |
---|
| 1912 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 1913 | if ~isnan(nbslice_grid) |
---|
| 1914 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
| 1915 | patch1.gridPatch=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 1916 | if ~exist(patch1.gridPatch,'file') |
---|
| 1917 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
| 1918 | end |
---|
| 1919 | elseif exist(gridname,'file') |
---|
| 1920 | patch1.gridPatch=gridname; |
---|
| 1921 | else |
---|
[112] | 1922 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
| 1923 | end |
---|
[2] | 1924 | end |
---|
[257] | 1925 | else |
---|
| 1926 | patch1.gridPatch='none'; |
---|
| 1927 | patch1.gridflag='n'; |
---|
| 1928 | patch1.m=nx_patch1; |
---|
| 1929 | patch1.n=ny_patch1; |
---|
[2] | 1930 | end |
---|
[257] | 1931 | patch1.convectFlow='n'; |
---|
| 1932 | fieldnames=fields(patch1); |
---|
| 1933 | [CivAllxml,uid_patch1]=add(CivAllxml,1,'element','patch1'); |
---|
| 1934 | for ilist=1:length(fieldnames) |
---|
| 1935 | val=eval(['patch1.' fieldnames{ilist}]); |
---|
| 1936 | if ischar(val) |
---|
| 1937 | [CivAllxml,uid_t]=add(CivAllxml,uid_patch1,'element',fieldnames{ilist}); |
---|
| 1938 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 1939 | end |
---|
[112] | 1940 | end |
---|
[257] | 1941 | CivAllCmd=[CivAllCmd ' patch1 ']; |
---|
[112] | 1942 | end |
---|
[2] | 1943 | end |
---|
[127] | 1944 | if box_test(4)==1 || box_test(5)==1 || box_test(6)==1 |
---|
[265] | 1945 | % pvalue=num2str((1-ind_answer)*500); |
---|
| 1946 | filename_cmx=filecell.nc.civ2{ifile,j};%output netcdf file |
---|
[229] | 1947 | filename_cmx(end-1:end+1)='cmx';%name of cmx file |
---|
[112] | 1948 | end |
---|
| 1949 | if box_test(4)==1 |
---|
[2] | 1950 | par_civ2.filename_ima_a=filecell.ima1.civ2{ifile,j}; |
---|
| 1951 | par_civ2.filename_ima_b=filecell.ima2.civ2{ifile,j}; |
---|
[174] | 1952 | [Rootbat,Filebat]=fileparts(filecell.nc.civ2{ifile,j});%output netcdf file (without extention) |
---|
[2] | 1953 | par_civ2.Dt=num2str(time(num2_civ2(ifile),num_b_civ2(j))-time(num1_civ2(ifile),num_a_civ2(j))); |
---|
[112] | 1954 | par_civ2.T0=num2str((time(num2_civ1(ifile),num_b_civ2(j))+time(num1_civ2(ifile),num_a_civ2(j)))/2); |
---|
[2] | 1955 | par_civ2.term_a=num2stra(num_a_civ2(j),nom_type_nc); |
---|
[112] | 1956 | par_civ2.term_b=num2stra(num_b_civ2(j),nom_type_nc); |
---|
[2] | 1957 | par_civ2.filename_nc1=filecell.nc.civ1{ifile,j}; |
---|
[229] | 1958 | par_civ2.filename_nc1(end-2:end)=[]; % remove '.nc' |
---|
[2] | 1959 | test_mask=get(handles.get_mask_civ2,'Value'); |
---|
[112] | 1960 | if test_mask==0 |
---|
[2] | 1961 | par_civ2.maskname='noFile use default'; |
---|
| 1962 | par_civ2.maskflag='n'; |
---|
| 1963 | else |
---|
| 1964 | maskdispl=get(handles.mask_civ2,'String'); |
---|
[12] | 1965 | if exist(maskdispl,'file') |
---|
| 1966 | par_civ2.maskname=maskdispl; |
---|
| 1967 | par_civ2.maskflag='y'; |
---|
[2] | 1968 | else |
---|
[136] | 1969 | maskbase=[filecell.filebase '_' maskdispl]; % |
---|
[137] | 1970 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
[12] | 1971 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
| 1972 | par_civ2.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 1973 | if exist(par_civ2.maskname,'file') |
---|
[112] | 1974 | par_civ2.maskflag='y'; |
---|
[12] | 1975 | else |
---|
| 1976 | par_civ2.maskname='noFile use default'; |
---|
[112] | 1977 | par_civ2.maskflag='n'; |
---|
[12] | 1978 | end |
---|
[2] | 1979 | end |
---|
| 1980 | end |
---|
| 1981 | gridname=get(handles.grid_civ2,'String'); |
---|
| 1982 | if numel(gridname)>=4 && isequal(gridname(end-3:end),'grid') |
---|
[137] | 1983 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 1984 | if ~isnan(nbslice_grid) |
---|
[2] | 1985 | par_civ2.gridflag='y'; |
---|
| 1986 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
[136] | 1987 | par_civ2.gridname=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
[2] | 1988 | if exist(par_civ2.gridname,'file') |
---|
[112] | 1989 | par_civ2.gridflag='y'; |
---|
[2] | 1990 | else |
---|
| 1991 | par_civ2.gridname='noFile use default'; |
---|
[112] | 1992 | par_civ2.gridflag='n'; |
---|
[2] | 1993 | end |
---|
| 1994 | elseif exist(gridname,'file') |
---|
[112] | 1995 | par_civ2.gridflag='y'; |
---|
[2] | 1996 | else |
---|
| 1997 | par_civ2.gridname='noFile use default'; |
---|
[112] | 1998 | par_civ2.gridflag='n'; |
---|
[2] | 1999 | end |
---|
| 2000 | end |
---|
| 2001 | i_cmd=i_cmd+1; |
---|
[177] | 2002 | flname=fullfile(Rootbat,Filebat); |
---|
[257] | 2003 | switch CivMode |
---|
| 2004 | case 'CivX' |
---|
| 2005 | cmd_CIV2=CIV2_CMD(flname,[],par_civ2,sparam);%creates the cmx file [fullfile(Rootbat,Filebat) '.civ2.cmx] |
---|
| 2006 | cmd=[cmd cmd_CIV2 '\n']; |
---|
| 2007 | case 'CivAll' |
---|
| 2008 | CivAllCmd=[CivAllCmd ' civ2 ']; |
---|
| 2009 | str=CIV2_CMD_Unified(flname,'',par_civ2); |
---|
| 2010 | fieldnames=fields(str); |
---|
| 2011 | [CivAllxml,uid_civ2]=add(CivAllxml,1,'element','civ2'); |
---|
| 2012 | for ilist=1:length(fieldnames) |
---|
| 2013 | val=eval(['str.' fieldnames{ilist}]); |
---|
| 2014 | if ischar(val) |
---|
| 2015 | [CivAllxml,uid_t]=add(CivAllxml,uid_civ2,'element',fieldnames{ilist}); |
---|
| 2016 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 2017 | end |
---|
[2] | 2018 | end |
---|
| 2019 | end |
---|
[112] | 2020 | end |
---|
| 2021 | |
---|
| 2022 | % FIX2 |
---|
| 2023 | if box_test(5)==1 |
---|
| 2024 | test_mask=get(handles.get_mask_fix2,'Value'); |
---|
| 2025 | if test_mask==0 |
---|
| 2026 | maskname=''; %no mask used |
---|
[2] | 2027 | else |
---|
| 2028 | maskdispl=get(handles.mask_fix2,'String'); |
---|
[136] | 2029 | maskbase=[filecell.filebase '_' maskdispl]; % |
---|
[137] | 2030 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
[2] | 2031 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
| 2032 | maskname =name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
[112] | 2033 | end |
---|
[257] | 2034 | switch CivMode |
---|
| 2035 | case 'CivX' |
---|
| 2036 | if isunix |
---|
| 2037 | cmd_FIX=[sparam.FixBin ' -f ' filecell.nc.civ2{ifile,j} ' -fi1 ' num2str(flagindex2(1)) ... |
---|
| 2038 | ' -fi2 ' num2str(flagindex2(2)) ' -fi3 ' num2str(flagindex2(3)) ... |
---|
| 2039 | ' -threshC ' num2str(thresh_vec2C) ' -threshV ' num2str(thresh_vel2) ' -maskName ' maskname]; |
---|
| 2040 | else |
---|
| 2041 | cmd_FIX=['"' sparam.FixBin '" -f "' filecell.nc.civ2{ifile,j} '" -fi1 ' num2str(flagindex2(1)) ... |
---|
| 2042 | ' -fi2 ' num2str(flagindex2(2)) ' -fi3 ' num2str(flagindex2(3)) ... |
---|
| 2043 | ' -threshC ' num2str(thresh_vec2C) ' -threshV ' num2str(thresh_vel2) ' -maskName "' maskname '"']; |
---|
| 2044 | cmd_FIX=regexprep(cmd_FIX,'\\','\\\\'); |
---|
[112] | 2045 | end |
---|
[257] | 2046 | cmd=[cmd cmd_FIX '\n']; |
---|
| 2047 | case 'CivAll' |
---|
| 2048 | fix2.inputFileName=filecell.nc.civ2{ifile,j} ; |
---|
| 2049 | fix2.fi1=num2str(flagindex2(1)); |
---|
| 2050 | fix2.fi2=num2str(flagindex2(2)); |
---|
| 2051 | fix2.fi3=num2str(flagindex2(3)); |
---|
| 2052 | fix2.threshC=num2str(thresh_vec2C); |
---|
| 2053 | fix2.threshV=num2str(thresh_vel2); |
---|
| 2054 | fieldnames=fields(fix2); |
---|
| 2055 | [CivAllxml,uid_fix2]=add(CivAllxml,1,'element','fix2'); |
---|
| 2056 | for ilist=1:length(fieldnames) |
---|
| 2057 | val=eval(['fix2.' fieldnames{ilist}]); |
---|
| 2058 | if ischar(val) |
---|
| 2059 | [CivAllxml,uid_t]=add(CivAllxml,uid_fix2,'element',fieldnames{ilist}); |
---|
| 2060 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 2061 | end |
---|
| 2062 | end |
---|
| 2063 | CivAllCmd=[CivAllCmd ' fix2 ']; |
---|
[112] | 2064 | end |
---|
| 2065 | end |
---|
| 2066 | |
---|
| 2067 | %PATCH2 |
---|
| 2068 | if box_test(6)==1 |
---|
[257] | 2069 | switch CivMode |
---|
| 2070 | case 'CivX' |
---|
| 2071 | cmd_PATCH=PATCH_CMD(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,test_interp,sparam.PatchBin); |
---|
| 2072 | cmd=[cmd cmd_PATCH '\n']; |
---|
| 2073 | case 'CivAll' |
---|
| 2074 | patch2.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 2075 | patch2.nopt=subdomain_patch2; |
---|
| 2076 | patch2.maxdiff=thresh_patch2; |
---|
| 2077 | patch2.ro=rho_patch2; |
---|
| 2078 | test_grid=get(handles.get_gridpatch2,'Value'); |
---|
| 2079 | if test_grid |
---|
| 2080 | patch2.gridflag='y'; |
---|
| 2081 | gridname=get(handles.grid_patch2,'String'); |
---|
| 2082 | if isequal(gridname(end-3:end),'grid') |
---|
| 2083 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 2084 | if ~isnan(nbslice_grid) |
---|
| 2085 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
| 2086 | patch2.gridPatch=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 2087 | if ~exist(patch2.gridPatch,'file') |
---|
| 2088 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
| 2089 | end |
---|
| 2090 | elseif exist(gridname,'file') |
---|
| 2091 | patch2.gridPatch=gridname; |
---|
| 2092 | else |
---|
[112] | 2093 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
[12] | 2094 | end |
---|
[2] | 2095 | end |
---|
[257] | 2096 | else |
---|
| 2097 | patch2.gridPatch='none'; |
---|
| 2098 | patch2.gridflag='n'; |
---|
| 2099 | patch2.m=nx_patch2; |
---|
| 2100 | patch2.n=ny_patch2; |
---|
[2] | 2101 | end |
---|
[257] | 2102 | patch2.convectFlow='n'; |
---|
| 2103 | fieldnames=fields(patch2); |
---|
| 2104 | [CivAllxml,uid_patch2]=add(CivAllxml,1,'element','patch2'); |
---|
| 2105 | for ilist=1:length(fieldnames) |
---|
| 2106 | val=eval(['patch2.' fieldnames{ilist}]); |
---|
| 2107 | if ischar(val) |
---|
| 2108 | [CivAllxml,uid_t]=add(CivAllxml,uid_patch2,'element',fieldnames{ilist}); |
---|
| 2109 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 2110 | end |
---|
[112] | 2111 | end |
---|
[257] | 2112 | CivAllCmd=[CivAllCmd ' patch2 ']; |
---|
[112] | 2113 | end |
---|
[12] | 2114 | end |
---|
[257] | 2115 | |
---|
| 2116 | switch CivMode |
---|
| 2117 | case {'CivX','CivAll'} |
---|
| 2118 | if isequal(CivMode,'CivAll') |
---|
| 2119 | save(CivAllxml,[flname '.xml']); |
---|
| 2120 | cmd=[cmd sparam.CivBin ' -f ' flname '.xml ' CivAllCmd ' >' flname '.log' '\n']; |
---|
[238] | 2121 | end |
---|
[257] | 2122 | % create the .bat file: |
---|
| 2123 | [fid,message]=fopen(filename_bat,'w'); |
---|
| 2124 | if isequal(fid,-1) |
---|
| 2125 | msgbox_uvmat('ERROR', ['creation of .bat file: ' message]) |
---|
| 2126 | return |
---|
[238] | 2127 | end |
---|
[257] | 2128 | fprintf(fid,cmd); |
---|
| 2129 | fclose(fid); |
---|
[269] | 2130 | |
---|
| 2131 | batch_file_list{length(batch_file_list)+1}=filename_bat; |
---|
| 2132 | |
---|
| 2133 | % if batch |
---|
| 2134 | % switch batch_mode |
---|
| 2135 | % case 'sge' |
---|
| 2136 | % display(['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]); |
---|
| 2137 | % eval( ['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]); |
---|
| 2138 | % case 'oar' |
---|
| 2139 | % % eval( ['!chmod +x ' filename_bat]); |
---|
| 2140 | % % %eval( ['!oarsub -n CIVX -l /core=1,walltime=00:10:00 ' filename_bat]); |
---|
| 2141 | % % eval( ['!oarsub -n CIVX -l "/core=1+{type = ''smalljob''}/licence=1,walltime=00:10:00" ' filename_bat]); |
---|
| 2142 | % |
---|
| 2143 | % cmd_str=['sh ' filename_bat]; |
---|
| 2144 | % super_cmd{length(super_cmd)+1}=cmd_str; |
---|
| 2145 | % |
---|
| 2146 | % end |
---|
| 2147 | % else |
---|
| 2148 | % %% to lauch the jobs locally : |
---|
| 2149 | % if(isunix) |
---|
| 2150 | % cmd_str=['. ' filename_bat]; |
---|
| 2151 | % else %case of Windows |
---|
| 2152 | % cmd_str=['@call "' regexprep(filename_bat,'\\','\\\\') '"']; |
---|
| 2153 | % end |
---|
| 2154 | % super_cmd=[super_cmd cmd_str '\n']; |
---|
| 2155 | % disp(cmd_str); |
---|
| 2156 | % end |
---|
[257] | 2157 | case 'Matlab' |
---|
| 2158 | drawnow |
---|
| 2159 | if box_test(1)==1 |
---|
| 2160 | Param.Civ1=par_civ1; |
---|
[252] | 2161 | end |
---|
[257] | 2162 | if box_test(2)==1 |
---|
| 2163 | fix1.WarnFlags=[]; |
---|
| 2164 | if get(handles.vec_Fmin2,'Value') |
---|
| 2165 | fix1.WarnFlags=[fix1.WarnFlags -2]; |
---|
| 2166 | end |
---|
| 2167 | if get(handles.vec_F3,'Value') |
---|
| 2168 | fix1.WarnFlags=[fix1.WarnFlags 3]; |
---|
| 2169 | end |
---|
| 2170 | fix1.LowerBoundCorr=thresh_vecC1; |
---|
| 2171 | if get(handles.inf_sup1,'Value') |
---|
| 2172 | fix1.UppperBoundVel=thresh_vel1; |
---|
| 2173 | else |
---|
| 2174 | fix1.LowerBoundVel=thresh_vel1; |
---|
| 2175 | end |
---|
| 2176 | if get(handles.get_mask_fix1,'Value') |
---|
| 2177 | fix1.MaskName=maskname; |
---|
| 2178 | end |
---|
| 2179 | Param.Fix1=fix1; |
---|
[252] | 2180 | end |
---|
[257] | 2181 | if box_test(3)==1 |
---|
[263] | 2182 | if strcmp(compare,'stereo PIV') |
---|
| 2183 | filebase_A=filecell.filebase; |
---|
| 2184 | [pp,ff]=fileparts(filebase_A); |
---|
| 2185 | filebase_B=fullfile(pp,get(handles.RootName_1,'String')); |
---|
| 2186 | RUN_STLIN(filecell.ncA.civ1{ifile,j},filecell.nc.civ1{ifile,j},'civ1',filecell.st{ifile,j},... |
---|
| 2187 | str2num(nx_patch1),str2num(ny_patch1),str2num(thresh_patch1),[filebase_A '.xml'],[filebase_B '.xml']) |
---|
| 2188 | else |
---|
| 2189 | Param.Patch1.Rho=rho_patch1; |
---|
| 2190 | Param.Patch1.Threshold=thresh_patch1; |
---|
| 2191 | Param.Patch1.SubDomain=subdomain_patch1; |
---|
| 2192 | end |
---|
[257] | 2193 | end |
---|
| 2194 | if box_test(4)==1 |
---|
| 2195 | Param.Civ2=par_civ2; |
---|
| 2196 | end |
---|
| 2197 | if box_test(5)==1 |
---|
| 2198 | fix2.WarnFlags=[]; |
---|
| 2199 | if get(handles.vec_Fmin2_2,'Value') |
---|
| 2200 | fix2.WarnFlags=[fix2.WarnFlags -2]; |
---|
| 2201 | end |
---|
| 2202 | if get(handles.vec_F4,'Value') |
---|
| 2203 | fix2.WarnFlags=[fix2.WarnFlags 4]; |
---|
| 2204 | end |
---|
| 2205 | if get(handles.vec_F3_2,'Value') |
---|
| 2206 | fix2.WarnFlags=[fix2.WarnFlags 3]; |
---|
| 2207 | end |
---|
| 2208 | fix2.LowerBoundCorr=thresh_vec2C; |
---|
| 2209 | if get(handles.inf_sup2,'Value') |
---|
| 2210 | fix2.UppperBoundVel=thresh_vel2; |
---|
| 2211 | else |
---|
| 2212 | fix2.LowerBoundVel=thresh_vel2; |
---|
| 2213 | end |
---|
| 2214 | if get(handles.get_mask_fix2,'Value') |
---|
| 2215 | fix2.MaskName=maskname; |
---|
| 2216 | end |
---|
| 2217 | Param.Fix2=fix2; |
---|
| 2218 | end |
---|
[263] | 2219 | if box_test(6)==1 |
---|
| 2220 | if strcmp(compare,'stereo PIV') |
---|
| 2221 | filebase_A=filecell.filebase; |
---|
| 2222 | [pp,ff]=fileparts(filebase_A); |
---|
| 2223 | filebase_B=fullfile(pp,get(handles.RootName_1,'String')); |
---|
| 2224 | RUN_STLIN(filecell.ncA.civ2{ifile,j},filecell.nc.civ2{ifile,j},'civ2',filecell.st{ifile,j},... |
---|
| 2225 | str2num(nx_patch2),str2num(ny_patch2),str2num(thresh_patch2),[filebase_A '.xml'],[filebase_B '.xml']) |
---|
[270] | 2226 | else |
---|
| 2227 | Param.Patch2.Rho=rho_patch2; |
---|
| 2228 | Param.Patch2.Threshold=thresh_patch2; |
---|
| 2229 | Param.Patch2.SubDomain=subdomain_patch2; |
---|
[263] | 2230 | end |
---|
[257] | 2231 | end |
---|
[263] | 2232 | if ~strcmp(compare,'stereo PIV') |
---|
| 2233 | [Data,erromsg]=civ_uvmat(Param,filecell.nc.civ1{ifile,j}); |
---|
| 2234 | if isempty(errormsg) |
---|
| 2235 | display([filecell.nc.civ1{ifile,j} ' written']) |
---|
| 2236 | else |
---|
| 2237 | msgbox_uvmat('ERROR',errormsg) |
---|
| 2238 | end |
---|
[270] | 2239 | |
---|
[263] | 2240 | end |
---|
[257] | 2241 | end |
---|
[112] | 2242 | end |
---|
[2] | 2243 | end |
---|
[134] | 2244 | |
---|
[265] | 2245 | if batch |
---|
[269] | 2246 | switch batch_mode |
---|
| 2247 | case 'sge' |
---|
| 2248 | for p=1:length(batch_file_list) |
---|
| 2249 | cmd=['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' batch_file_list{p}]; |
---|
| 2250 | display(cmd);eval(cmd); |
---|
| 2251 | end |
---|
[265] | 2252 | case 'oar' |
---|
[269] | 2253 | for p=0:floor(length(batch_file_list)/6); |
---|
| 2254 | filename_batch_group=fullfile(Rootbat,['job_list_' num2str(p) '.bat']); |
---|
| 2255 | fid=fopen(filename_batch_group,'w'); |
---|
[265] | 2256 | if fid==-1 |
---|
| 2257 | msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat]) |
---|
| 2258 | return |
---|
| 2259 | end |
---|
[269] | 2260 | if p==floor(length(batch_file_list)/6) |
---|
| 2261 | kmax=mod(length(batch_file_list),6); |
---|
[265] | 2262 | else |
---|
| 2263 | kmax=6; |
---|
| 2264 | end |
---|
| 2265 | for k=1:kmax |
---|
[269] | 2266 | fprintf(fid,['sh ' batch_file_list{p*6+k} '\n']); |
---|
[265] | 2267 | end |
---|
| 2268 | fclose(fid); |
---|
[269] | 2269 | system(['chmod +x ' filename_batch_group]); |
---|
| 2270 | eval( ['!oarsub -n CIVX -q nicejob -l "/core=1+{type = ''smalljob''}/licence=1,walltime=00:60:00" ' filename_batch_group]); |
---|
| 2271 | end |
---|
| 2272 | case 'oar_new' % to be develloped with Patrick Begou |
---|
| 2273 | filename_joblist=fullfile(Rootbat,'job_list.txt'); |
---|
| 2274 | fid=fopen(filename_superbat,'w'); |
---|
| 2275 | if fid==-1 |
---|
| 2276 | msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat]) |
---|
| 2277 | return |
---|
[265] | 2278 | end |
---|
[269] | 2279 | for p=1:length(batch_file_list) |
---|
| 2280 | fprintf(fid,[batch_file_list{p} '\n']); |
---|
| 2281 | end |
---|
| 2282 | fclose(fid); |
---|
| 2283 | walltime=datestr(length(super_cmd)*10/24/60,13); |
---|
| 2284 | eval( ['!oarsub -n CIVX -q nicejob -l "/core=1+{type = ''smalljob''}/licence=1,walltime=' walltime '" ' filename_superbat]); |
---|
| 2285 | end |
---|
| 2286 | else |
---|
| 2287 | if ~isequal(CivMode,'Matlab') |
---|
| 2288 | filename_superbat=fullfile(Rootbat,'job_list.bat'); |
---|
| 2289 | fid=fopen(filename_superbat,'w'); |
---|
| 2290 | if fid==-1 |
---|
| 2291 | msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat]) |
---|
| 2292 | return |
---|
| 2293 | end |
---|
| 2294 | for p=1:length(batch_file_list) |
---|
| 2295 | if isunix |
---|
| 2296 | fprintf(fid,['sh ' batch_file_list{p} '\n']); |
---|
| 2297 | else |
---|
| 2298 | fprintf(fid,['@call "' regexprep(filename_bat,'\\','\\\\') '"' '\n']); |
---|
[265] | 2299 | end |
---|
[269] | 2300 | end |
---|
| 2301 | fclose(fid); |
---|
| 2302 | if(isunix) |
---|
| 2303 | system(['chmod +x ' filename_superbat]); |
---|
| 2304 | end |
---|
| 2305 | system([filename_superbat ' &']);% execute main commmand |
---|
[265] | 2306 | end |
---|
[269] | 2307 | |
---|
[265] | 2308 | end |
---|
| 2309 | |
---|
[2] | 2310 | |
---|
[137] | 2311 | %% save interface state |
---|
[2] | 2312 | if isfield(filecell,'nc') |
---|
| 2313 | if isfield(filecell.nc,'civ2') |
---|
| 2314 | fileresu=filecell.nc.civ2{1,1}; |
---|
| 2315 | else |
---|
| 2316 | fileresu=filecell.nc.civ1{1,1}; |
---|
| 2317 | end |
---|
| 2318 | end |
---|
| 2319 | [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileresu); |
---|
| 2320 | namedoc=fullfile(RootPath,subdir,RootFile); |
---|
[112] | 2321 | detect=1; |
---|
[2] | 2322 | while detect==1 |
---|
| 2323 | namefigfull=[namedoc '.fig']; |
---|
| 2324 | hh=dir(namefigfull); |
---|
| 2325 | if ~isempty(hh) |
---|
| 2326 | detect=1; |
---|
| 2327 | namedoc=[namedoc '.0']; |
---|
| 2328 | else |
---|
| 2329 | detect=0; |
---|
| 2330 | end |
---|
| 2331 | end |
---|
| 2332 | saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) |
---|
| 2333 | |
---|
[227] | 2334 | %------------------------------------------------------------------------ |
---|
| 2335 | % --- determine the list of reference indices of processing file |
---|
| 2336 | function [ref_i,ref_j,errormsg]=find_ref_indices(handles) |
---|
| 2337 | %------------------------------------------------------------------------ |
---|
| 2338 | errormsg=''; %default error message |
---|
| 2339 | first_i=str2double(get(handles.first_i,'String'));%first index i |
---|
| 2340 | last_i=str2double(get(handles.last_i,'String'));%last index i |
---|
| 2341 | incr_i=str2double(get(handles.incr_i,'String'));% increment |
---|
| 2342 | if isequal(get(handles.first_j,'Visible'),'on') |
---|
| 2343 | first_j=str2double(get(handles.first_j,'String'));%first index j |
---|
| 2344 | last_j=str2double(get(handles.last_j,'String'));%last index j |
---|
| 2345 | incr_j=str2double(get(handles.incr_j,'String'));% increment |
---|
| 2346 | else |
---|
| 2347 | first_j=1; |
---|
| 2348 | last_j=1; |
---|
| 2349 | incr_j=1; |
---|
| 2350 | end |
---|
| 2351 | ref_i=first_i:incr_i:last_i;% list of i indices (reference values for each pair) |
---|
| 2352 | ref_j=first_j:incr_j:last_j;% list of j indices (reference values for each pair) |
---|
| 2353 | if isnan(first_i)||isnan(first_j) |
---|
| 2354 | errormsg='first field number not defined'; |
---|
| 2355 | elseif isnan(last_i)||isnan(last_j) |
---|
| 2356 | errormsg='last field number not defined'; |
---|
| 2357 | elseif isnan(incr_i)||isnan(incr_j) |
---|
| 2358 | errormsg='increment in field number not defined'; |
---|
| 2359 | elseif last_i < first_i || last_j < first_j |
---|
| 2360 | errormsg='last field number must be larger than the first one'; |
---|
| 2361 | end |
---|
[134] | 2362 | |
---|
[227] | 2363 | %------------------------------------------------------------------------ |
---|
| 2364 | % --- determine the list of filenames and indices needed for launch_job |
---|
[263] | 2365 | function [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc,file_ref_fix1,file_ref_fix2,compare]=... |
---|
[227] | 2366 | set_civ_filenames(handles,ref_i,ref_j,box_test) |
---|
[12] | 2367 | %------------------------------------------------------------------------ |
---|
[85] | 2368 | filecell=[];%default |
---|
[136] | 2369 | |
---|
| 2370 | %% get the root names nomenclature and numbers |
---|
[71] | 2371 | filebase=get(handles.RootName,'String'); |
---|
[136] | 2372 | |
---|
| 2373 | if isempty(filebase)||isequal(filebase,'') |
---|
| 2374 | msgbox_uvmat('ERROR','no input files') |
---|
| 2375 | return |
---|
| 2376 | end |
---|
| 2377 | |
---|
[137] | 2378 | %filebase=regexprep(filebase,'\.fsnet','fsnet');% temporary fix for cluster Coriolis |
---|
[136] | 2379 | filecell.filebase=filebase; |
---|
| 2380 | |
---|
[2] | 2381 | browse=get(handles.browse_root,'UserData'); |
---|
| 2382 | compare_list=get(handles.compare,'String'); |
---|
| 2383 | val=get(handles.compare,'Value'); |
---|
| 2384 | compare=compare_list{val}; |
---|
| 2385 | if strcmp(compare,'displacement') |
---|
| 2386 | mode='displacement'; |
---|
| 2387 | else |
---|
| 2388 | mode_list=get(handles.mode,'String'); |
---|
| 2389 | mode_value=get(handles.mode,'Value'); |
---|
| 2390 | mode=mode_list{mode_value}; |
---|
| 2391 | end |
---|
[137] | 2392 | %time=get(handles.RootName,'UserData'); %get the set of times |
---|
[71] | 2393 | ext_ima=get(handles.ImaExt,'String'); |
---|
[2] | 2394 | nom_type_nc=browse.nom_type_nc; |
---|
[122] | 2395 | if isfield(browse,'nom_type_ima') |
---|
| 2396 | nom_type_ima2=browse.nom_type_ima; |
---|
| 2397 | end |
---|
| 2398 | if isempty(nom_type_ima2),nom_type_ima2='1';end; %default |
---|
| 2399 | if isempty(nom_type_nc),nom_type_nc='_i1-i2';end; %default |
---|
[2] | 2400 | [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
[227] | 2401 | find_pair_indices(handles,ref_i,ref_j,mode); |
---|
[2] | 2402 | %determine the new filebase for 'displacement' mode (comparison of two series) |
---|
| 2403 | filebase_B=filebase;% root name of the second field series for stereo |
---|
| 2404 | if strcmp(compare,'displacement') || strcmp(compare,'stereo PIV') |
---|
[127] | 2405 | % test_disp=1; |
---|
[2] | 2406 | nom_type_ima1=browse.nom_type_ima_1; %nomenclature type of the second file series |
---|
| 2407 | [Path2,Name2]=fileparts(filebase_B); |
---|
| 2408 | Path1=Path2; |
---|
[71] | 2409 | Name1=get(handles.RootName_1,'String');% root name of the first field series for stereo |
---|
[2] | 2410 | filebase_A=fullfile(Path1,Name1); |
---|
| 2411 | if length(Name1)>6 |
---|
| 2412 | Name1=Name1(end-5:end); |
---|
| 2413 | end |
---|
| 2414 | if length(Name2)>6 |
---|
| 2415 | Name2=Name2(end-5:end); |
---|
| 2416 | end |
---|
| 2417 | filebase_AB=fullfile(Path2,[Name2 '-' Name1]); |
---|
| 2418 | else |
---|
[127] | 2419 | % test_disp=0; |
---|
[2] | 2420 | filebase_A=filebase; |
---|
| 2421 | nom_type_ima1=nom_type_ima2; |
---|
| 2422 | filebase_AB=filebase; |
---|
| 2423 | end |
---|
| 2424 | if strcmp(compare,'displacement') |
---|
[112] | 2425 | filebase_ima1=filebase_A; |
---|
| 2426 | filebase_ima2=filebase_B; |
---|
| 2427 | filebase_nc=filebase_AB; %root name for the result of civ2 |
---|
[2] | 2428 | else |
---|
[112] | 2429 | filebase_ima1=filebase_B; |
---|
| 2430 | filebase_ima2=filebase_B; |
---|
| 2431 | filebase_nc=filebase_B; |
---|
| 2432 | end |
---|
[2] | 2433 | |
---|
| 2434 | %determine reference files for fix: |
---|
| 2435 | file_ref_fix1={};%default |
---|
| 2436 | file_ref_fix2={}; |
---|
| 2437 | nbfield=length(num1_civ1); |
---|
| 2438 | nbslice=length(num_a_civ1); |
---|
| 2439 | if box_test(2)==1% fix1 performed |
---|
| 2440 | ref=get(handles.ref_fix1,'UserData');%read data on the ref file stored by get_ref_fix1_Callback |
---|
| 2441 | if ~isempty(ref) |
---|
[137] | 2442 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 2443 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 2444 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 2445 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 2446 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 2447 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[127] | 2448 | num_i_ref=first_i:incr_i:last_i; |
---|
| 2449 | num_j_ref=first_j:incr_j:last_j; |
---|
[2] | 2450 | if isequal(mode,'displacement') |
---|
| 2451 | num_i1=num_i_ref; |
---|
| 2452 | num_i2=num_i_ref; |
---|
| 2453 | num_j1=num_j_ref; |
---|
| 2454 | num_j2=num_j_ref; |
---|
| 2455 | elseif isequal(mode,'pair j1-j2')% isequal(mode,'st_pair j1-j2') |
---|
| 2456 | num_i1=num_i_ref; |
---|
| 2457 | num_i2=num_i1; |
---|
| 2458 | num_j1=ref.num_a*ones(size(num_i_ref)); |
---|
| 2459 | num_j2=ref.num_b*ones(size(num_i_ref)); |
---|
| 2460 | elseif isequal(mode,'series(Di)') % isequal(mode,'st_series(Di)') |
---|
| 2461 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 2462 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 2463 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 2464 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 2465 | if isempty(ref.num_a) |
---|
| 2466 | ref.num_a=1; |
---|
| 2467 | end |
---|
| 2468 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 2469 | num_j2=num_j1; |
---|
| 2470 | elseif isequal(mode,'series(Dj)')%| isequal(mode,'st_series(Dj)') |
---|
| 2471 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 2472 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 2473 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 2474 | num_i2=num_i1; |
---|
| 2475 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 2476 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 2477 | end |
---|
| 2478 | for ifile=1:nbfield |
---|
| 2479 | for j=1:nbslice |
---|
| 2480 | 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);% |
---|
| 2481 | file_ref_fix1(ifile,j)={file_ref}; |
---|
| 2482 | if ~exist(file_ref,'file') |
---|
| 2483 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix1']) |
---|
[12] | 2484 | filecell=[]; |
---|
[2] | 2485 | return |
---|
| 2486 | end |
---|
| 2487 | end |
---|
| 2488 | end |
---|
| 2489 | end |
---|
| 2490 | end |
---|
| 2491 | |
---|
| 2492 | %determine reference files for fix2: |
---|
| 2493 | if box_test(5)==1% fix2 performed |
---|
| 2494 | ref=get(handles.ref_fix2,'UserData'); |
---|
| 2495 | if ~isempty(ref) |
---|
[127] | 2496 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 2497 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 2498 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 2499 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 2500 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 2501 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[229] | 2502 | num_i_ref=first_i:incr_i:last_i; |
---|
| 2503 | num_j_ref=first_j:incr_j:last_j; |
---|
[2] | 2504 | if isequal(mode,'displacement') |
---|
| 2505 | num_i1=num_i_ref; |
---|
| 2506 | num_i2=num_i_ref; |
---|
| 2507 | num_j1=num_j_ref; |
---|
| 2508 | num_j2=num_j_ref; |
---|
| 2509 | elseif isequal(mode,'pair j1-j2') |
---|
| 2510 | num_i1=num_i_ref; |
---|
| 2511 | num_i2=num_i1; |
---|
| 2512 | num_j1=ref.num_a; |
---|
| 2513 | num_j2=ref.num_b; |
---|
| 2514 | elseif isequal(mode,'series(Di)') |
---|
| 2515 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 2516 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 2517 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 2518 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 2519 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 2520 | num_j2=num_j1; |
---|
| 2521 | elseif isequal(mode,'series(Dj)') |
---|
| 2522 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 2523 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 2524 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 2525 | num_i2=num_i1; |
---|
| 2526 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 2527 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 2528 | end |
---|
| 2529 | for ifile=1:nbfield |
---|
| 2530 | for j=1:nbslice |
---|
| 2531 | 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);% |
---|
| 2532 | file_ref_fix2(ifile,j)={file_ref}; |
---|
| 2533 | if ~exist(file_ref,'file') |
---|
| 2534 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix2']) |
---|
[122] | 2535 | filecell={}; |
---|
[2] | 2536 | return |
---|
| 2537 | end |
---|
| 2538 | end |
---|
| 2539 | end |
---|
| 2540 | end |
---|
| 2541 | end |
---|
| 2542 | |
---|
| 2543 | %check dir |
---|
| 2544 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf output data |
---|
| 2545 | subdir_civ2=get(handles.subdir_civ2,'String'); |
---|
[174] | 2546 | if isequal(subdir_civ1,''),subdir_civ1='CIV'; end% put default subdir |
---|
[2] | 2547 | if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end% put default subdir |
---|
[266] | 2548 | % currentdir=pwd;%store the current working directory |
---|
[2] | 2549 | [Path_ima,Name]=fileparts(filebase);%Path of the image files (.civ) |
---|
| 2550 | if ~exist(Path_ima,'dir') |
---|
[12] | 2551 | msgbox_uvmat('ERROR',['path to images ' Path_ima ' not found']) |
---|
[122] | 2552 | filecell={}; |
---|
[2] | 2553 | return |
---|
| 2554 | end |
---|
[127] | 2555 | [xx,message]=fileattrib(Path_ima); |
---|
[122] | 2556 | if ~isempty(message) && ~isequal(message.UserWrite,1) |
---|
[112] | 2557 | msgbox_uvmat('ERROR',['No writting access to ' Path_ima]) |
---|
[122] | 2558 | filecell={}; |
---|
[266] | 2559 | % cd(currentdir); |
---|
[112] | 2560 | return |
---|
[2] | 2561 | end |
---|
| 2562 | |
---|
| 2563 | %check the existence of the netcdf and image files involved |
---|
| 2564 | % %%%%%%%%%%%% case CIV1 activated %%%%%%%%%%%%% |
---|
| 2565 | if box_test(1)==1; |
---|
[112] | 2566 | detect=1; |
---|
[127] | 2567 | vers=0; |
---|
| 2568 | subdir_civ1_new=subdir_civ1; |
---|
[153] | 2569 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
[122] | 2570 | for ifile=1:nbfield |
---|
[112] | 2571 | for j=1:nbslice |
---|
[122] | 2572 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1_new); |
---|
[112] | 2573 | detect=exist(filename,'file')==2; |
---|
| 2574 | if detect% if a netcdf file already exists |
---|
[137] | 2575 | indstr=regexp(subdir_civ1_new,'\D'); |
---|
| 2576 | if indstr(end)<length(subdir_civ1_new) %subdir_civ1 ends by a number |
---|
| 2577 | vers=str2double(subdir_civ1_new(indstr(end)+1:end))+1; |
---|
| 2578 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) num2str(vers)]; |
---|
[127] | 2579 | else |
---|
| 2580 | vers=vers+1; |
---|
[137] | 2581 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) '_' num2str(vers)]; |
---|
[127] | 2582 | end |
---|
[137] | 2583 | subdir_civ2=subdir_civ1_new; |
---|
[112] | 2584 | break |
---|
| 2585 | end |
---|
| 2586 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 2587 | end |
---|
| 2588 | if detect% if a netcdf file already exists |
---|
| 2589 | break |
---|
| 2590 | end |
---|
| 2591 | end |
---|
[134] | 2592 | |
---|
[112] | 2593 | %create the new subdir_civ1 |
---|
[127] | 2594 | if ~exist(fullfile(Path_ima,subdir_civ1_new),'dir') |
---|
[263] | 2595 | % cd(Path_ima); |
---|
| 2596 | [xx,msg1]=mkdir(fullfile(Path_ima,subdir_civ1_new)); |
---|
[134] | 2597 | |
---|
[128] | 2598 | if ~strcmp(msg1,'') |
---|
| 2599 | msgbox_uvmat('ERROR',['cannot create ' subdir_civ1_new ': ' msg1])%error message for directory creation |
---|
[122] | 2600 | filecell={}; |
---|
| 2601 | return |
---|
[163] | 2602 | elseif isunix |
---|
[266] | 2603 | [xx,msg2] = fileattrib(fullfile(Path_ima,subdir_civ1_new),'+w','g'); %yield writing access (+w) to user group (g) |
---|
[128] | 2604 | if ~strcmp(msg2,'') |
---|
[266] | 2605 | msgbox_uvmat('ERROR',['pb of permission for ' fullfile(Path_ima,subdir_civ1_new) ': ' msg2])%error message for directory creation |
---|
[128] | 2606 | filecell={}; |
---|
| 2607 | return |
---|
| 2608 | end |
---|
[112] | 2609 | end |
---|
[263] | 2610 | % cd(currentdir); |
---|
[112] | 2611 | end |
---|
| 2612 | if strcmp(compare,'stereo PIV')&&(strcmp(mode,'pair j1-j2')||strcmp(mode,'series(Dj)')||strcmp(mode,'series(Di)'))%check second nc series |
---|
| 2613 | for ifile=1:nbfield |
---|
| 2614 | for j=1:nbslice |
---|
[122] | 2615 | filename=name_generator(filebase_A,num1_civ1(ifile),num_a_civ1(j),'.nc',nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1_new);% |
---|
[112] | 2616 | detect=exist(filename,'file')==2; |
---|
[2] | 2617 | if detect% if a netcdf file already exists |
---|
[137] | 2618 | indstr=regexp(subdir_civ1_new,'\D'); |
---|
| 2619 | if indstr(end)<length(subdir_civ1_new) %subdir_civ1 ends by a number |
---|
| 2620 | vers=str2double(subdir_civ1_new(indstr(end)+1:end))+1; |
---|
| 2621 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) num2str(vers)]; |
---|
[127] | 2622 | else |
---|
| 2623 | vers=vers+1; |
---|
[137] | 2624 | subdir_civ1_new=[subdir_civ1_new '_' num2str(vers)]; |
---|
[127] | 2625 | end |
---|
| 2626 | subdir_civ2=subdir_civ1; |
---|
| 2627 | break |
---|
[2] | 2628 | end |
---|
[112] | 2629 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
| 2630 | end |
---|
| 2631 | if detect% if a netcdf file already exists |
---|
| 2632 | break |
---|
| 2633 | end |
---|
| 2634 | end |
---|
| 2635 | %create the new subdir_civ1 |
---|
[263] | 2636 | if ~exist(fullfile(Path_ima,subdir_civ1_new),'dir') |
---|
| 2637 | % cd(Path_ima); |
---|
| 2638 | [xx,msg1]=mkdir(fullfile(Path_ima,subdir_civ1_new)); |
---|
| 2639 | % cd(currentdir); |
---|
[252] | 2640 | if ~strcmp(msg1,'') |
---|
[128] | 2641 | msgbox_uvmat('ERROR',['cannot create ' subdir_civ1_new ': ' msg1]) |
---|
[263] | 2642 | % cd(currentdir) |
---|
[122] | 2643 | filecell={}; |
---|
| 2644 | return |
---|
[128] | 2645 | else |
---|
[266] | 2646 | [xx,msg2] = fileattrib(fullfile(Path_ima,subdir_civ1_new),'+w','g'); %yield writing access (+w) to user group (g) |
---|
[128] | 2647 | if ~strcmp(msg2,'') |
---|
| 2648 | msgbox_uvmat('ERROR',['pb of permission for ' subdir_civ1_new ': ' msg2])%error message for directory creation |
---|
[263] | 2649 | % cd(currentdir) |
---|
[128] | 2650 | filecell={}; |
---|
| 2651 | return |
---|
| 2652 | end |
---|
[112] | 2653 | end |
---|
| 2654 | end |
---|
| 2655 | end |
---|
| 2656 | end |
---|
[127] | 2657 | subdir_civ1=subdir_civ1_new; |
---|
[2] | 2658 | % get image names |
---|
| 2659 | for ifile=1:nbfield |
---|
[112] | 2660 | for j=1:nbslice |
---|
[2] | 2661 | filename=name_generator(filebase_ima1, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
| 2662 | idetect(j)=exist(filename,'file')==2; |
---|
| 2663 | filecell.ima1.civ1(ifile,j)={filename}; %first image |
---|
| 2664 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
| 2665 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 2666 | filecell.ima2.civ1(ifile,j)={filename};%second image |
---|
[112] | 2667 | end |
---|
| 2668 | [idetectmin,indexj]=min(idetect); |
---|
| 2669 | if idetectmin==0, |
---|
| 2670 | msgbox_uvmat('ERROR',[filecell.ima1.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2671 | filecell={}; |
---|
[266] | 2672 | % cd(currentdir) |
---|
[112] | 2673 | return |
---|
| 2674 | end |
---|
| 2675 | [idetectmin,indexj]=min(idetect_1); |
---|
| 2676 | if idetectmin==0, |
---|
| 2677 | msgbox_uvmat('ERROR',[filecell.ima2.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2678 | filecell={}; |
---|
[266] | 2679 | %cd(currentdir) |
---|
[112] | 2680 | return |
---|
| 2681 | end |
---|
| 2682 | end |
---|
| 2683 | if strcmp(compare,'stereo PIV') && (strcmp(mode,'pair j1-j2') || strcmp(mode,'series(Dj)') || strcmp(mode,'series(Di)')) |
---|
| 2684 | for ifile=1:nbfield |
---|
| 2685 | for j=1:nbslice |
---|
| 2686 | filename=name_generator(filebase_A, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
| 2687 | idetect(j)=exist(filename,'file')==2; |
---|
| 2688 | filecell.imaA1.civ1(ifile,j)={filename} ;%first image |
---|
| 2689 | filename=name_generator(filebase_A, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
| 2690 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 2691 | filecell.imaA2.civ1(ifile,j)={filename};%second image |
---|
| 2692 | end |
---|
[2] | 2693 | [idetectmin,indexj]=min(idetect); |
---|
[112] | 2694 | if idetectmin==0, |
---|
| 2695 | msgbox_uvmat('ERROR',[filecell.imaA1.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2696 | filecell={}; |
---|
[266] | 2697 | % cd(currentdir) |
---|
[2] | 2698 | return |
---|
[112] | 2699 | end |
---|
[2] | 2700 | [idetectmin,indexj]=min(idetect_1); |
---|
[112] | 2701 | if idetectmin==0, |
---|
| 2702 | msgbox_uvmat('ERROR',[filecell.imaA2.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2703 | filecell={}; |
---|
[266] | 2704 | % cd(currentdir) |
---|
[2] | 2705 | return |
---|
[112] | 2706 | end |
---|
| 2707 | end |
---|
[2] | 2708 | end |
---|
[112] | 2709 | |
---|
| 2710 | %%%%%%%%%%%%% fix1 or patch1 activated but no civ1 %%%%%%%%%%%%% |
---|
| 2711 | elseif (box_test(2)==1 || box_test(3)==1); |
---|
[2] | 2712 | for ifile=1:nbfield |
---|
| 2713 | for j=1:nbslice |
---|
| 2714 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
[112] | 2715 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 2716 | detect=exist(filename,'file')==2; |
---|
[122] | 2717 | if detect==0 |
---|
| 2718 | msgbox_uvmat('ERROR',[filename ' not found']) |
---|
| 2719 | filecell={}; |
---|
[266] | 2720 | % cd(currentdir) |
---|
[122] | 2721 | return |
---|
| 2722 | end |
---|
[2] | 2723 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 2724 | end |
---|
| 2725 | end |
---|
| 2726 | if strcmp(compare,'stereo PIV') |
---|
[112] | 2727 | for ifile=1:nbfield |
---|
| 2728 | for j=1:nbslice |
---|
| 2729 | 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);% |
---|
| 2730 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
| 2731 | if ~exist(filename,'file') |
---|
| 2732 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
| 2733 | set(handles.RUN, 'Enable','On') |
---|
| 2734 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
[122] | 2735 | filecell={}; |
---|
[266] | 2736 | %cd(currentdir) |
---|
[112] | 2737 | return |
---|
[2] | 2738 | end |
---|
| 2739 | end |
---|
[112] | 2740 | end |
---|
[2] | 2741 | end |
---|
| 2742 | end |
---|
| 2743 | |
---|
| 2744 | %%%%%%%%%%%%% if civ2 performed with pairs different than civ1 %%%%%%%%%%%%% |
---|
| 2745 | testdiff=0; |
---|
| 2746 | if (box_test(4)==1)&&... |
---|
[127] | 2747 | ((get(handles.list_pair_civ1,'Value')~=get(handles.list_pair_civ2,'Value'))||~strcmp(subdir_civ2,subdir_civ1)) |
---|
[2] | 2748 | testdiff=1; |
---|
[112] | 2749 | detect=1; |
---|
[127] | 2750 | vers=0; |
---|
| 2751 | subdir_civ2_new=subdir_civ2; |
---|
[2] | 2752 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
[112] | 2753 | for ifile=1:nbfield |
---|
| 2754 | for j=1:nbslice |
---|
[127] | 2755 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2_new);% |
---|
[112] | 2756 | detect=exist(filename,'file')==2; |
---|
| 2757 | if detect% if a netcdf file already exists |
---|
[127] | 2758 | indstr=regexp(subdir_civ2,'\D'); |
---|
| 2759 | if indstr(end)<length(subdir_civ2) %subdir_civ1 ends by a number |
---|
| 2760 | vers=str2double(subdir_civ2(indstr(end)+1:end))+1; |
---|
| 2761 | subdir_civ2_new=[subdir_civ2(1:indstr(end)) num2str(vers)]; |
---|
| 2762 | else |
---|
| 2763 | vers=vers+1; |
---|
| 2764 | subdir_civ2_new=[subdir_civ1 '_' num2str(vers)]; |
---|
| 2765 | end |
---|
[112] | 2766 | break |
---|
| 2767 | end |
---|
| 2768 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 2769 | end |
---|
| 2770 | if detect% if a netcdf file already exists |
---|
| 2771 | break |
---|
| 2772 | end |
---|
| 2773 | end |
---|
[128] | 2774 | %create the new subdir_civ2_new |
---|
| 2775 | if ~exist(fullfile(Path_ima,subdir_civ2_new),'dir') |
---|
[174] | 2776 | [xx,m2]=mkdir(fullfile(Path_ima,subdir_civ2_new)); |
---|
[266] | 2777 | [xx,msg2] = fileattrib(fullfile(Path_ima,subdir_civ2_new),'+w','g'); %yield writing access (+w) to user group (g) |
---|
[112] | 2778 | if ~isequal(m2,'') |
---|
[266] | 2779 | msgbox_uvmat('ERROR',['cannot create ' fullfile(Path_ima,subdir_civ2_new) ': ' m2]) |
---|
[122] | 2780 | filecell={}; |
---|
[266] | 2781 | % cd(currentdir) |
---|
[122] | 2782 | return |
---|
[112] | 2783 | end |
---|
| 2784 | end |
---|
| 2785 | if strcmp(compare,'stereo PIV')%check second nc series |
---|
| 2786 | for ifile=1:nbfield |
---|
| 2787 | for j=1:nbslice |
---|
| 2788 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
[122] | 2789 | nom_type_nc,1,num2_civ2(ifile),num_b_civ1(j),subdir_civ2_new);% |
---|
[112] | 2790 | detect=exist(filename,'file')==2; |
---|
[2] | 2791 | if detect% if a netcdf file already exists |
---|
[127] | 2792 | indstr=regexp(subdir_civ2,'\D'); |
---|
| 2793 | if indstr(end)<length(subdir_civ2) %subdir_civ1 ends by a number |
---|
| 2794 | vers=str2double(subdir_civ2(indstr(end)+1:end))+1; |
---|
| 2795 | subdir_civ2_new=[subdir_civ2(1:indstr(end)) num2str(vers)]; |
---|
| 2796 | else |
---|
| 2797 | vers=vers+1; |
---|
| 2798 | subdir_civ2_new=[subdir_civ1 '_' num2str(vers)]; |
---|
| 2799 | end |
---|
[112] | 2800 | break |
---|
[2] | 2801 | end |
---|
[112] | 2802 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 2803 | end |
---|
| 2804 | if detect% if a netcdf file already exists |
---|
| 2805 | break |
---|
| 2806 | end |
---|
| 2807 | end |
---|
[122] | 2808 | subdir_civ2=subdir_civ2_new; |
---|
[112] | 2809 | %create the new subdir_civ1 |
---|
[127] | 2810 | if ~exist(fullfile(Path_ima,subdir_civ2_new),'dir') |
---|
| 2811 | [xx,m2]=mkdir(subdir_civ2_new); |
---|
[266] | 2812 | [xx,msg2] = fileattrib(fullfile(Path_ima,subdir_civ2_new),'+w','g'); %yield writing access (+w) to user group (g) |
---|
[112] | 2813 | if ~isequal(m2,'') |
---|
[266] | 2814 | msgbox_uvmat('ERROR', ['cannot create ' fullfile(Path_ima,subdir_civ2_new) ': ' m2])%error message for directory creation |
---|
| 2815 | % cd(currentdir) |
---|
[122] | 2816 | filecell={}; |
---|
| 2817 | return |
---|
[112] | 2818 | end |
---|
| 2819 | end |
---|
| 2820 | end |
---|
| 2821 | end |
---|
[127] | 2822 | subdir_civ2=subdir_civ2_new; |
---|
[2] | 2823 | end |
---|
[266] | 2824 | %cd(currentdir);%come back to the current working directory |
---|
[2] | 2825 | |
---|
| 2826 | %%%%%%%%%%%%% if civ2 results are obtained or used %%%%%%%%%%%%% |
---|
| 2827 | if box_test(4)==1 || box_test(5)==1 || box_test(6)==1 %civ2 |
---|
| 2828 | %check source netcdf file of civ1 estimates |
---|
| 2829 | if box_test(1)==0; %no civ1 performed |
---|
| 2830 | for ifile=1:nbfield |
---|
| 2831 | for j=1:nbslice |
---|
| 2832 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 2833 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 2834 | filecell.nc.civ1(ifile,j)={filename};% name of the civ1 file |
---|
| 2835 | if ~exist(filename,'file') |
---|
| 2836 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
[122] | 2837 | filecell={}; |
---|
[2] | 2838 | return |
---|
| 2839 | end |
---|
| 2840 | if ~testdiff % civ2 or patch2 are written in the same file as civ1 |
---|
| 2841 | if box_test(4)==0 ; %check the existence of civ2 if it is not calculated |
---|
[248] | 2842 | Data=nc2struct(filename,'ListGlobalAttribute','CivStage','civ2'); |
---|
| 2843 | if ~isempty(Data.CivStage) && Data.CivStage<4 %test for civ files |
---|
[2] | 2844 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
[12] | 2845 | filecell=[]; |
---|
[2] | 2846 | return |
---|
[248] | 2847 | elseif isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
| 2848 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
| 2849 | filecell=[]; |
---|
| 2850 | return |
---|
[112] | 2851 | end |
---|
[2] | 2852 | elseif box_test(3)==0; %check the existence of patch if it is not calculated |
---|
[248] | 2853 | Data=nc2struct(filename,'ListGlobalAttribute','CivStage','patch') |
---|
| 2854 | if ~isempty(Data.CivStage) |
---|
| 2855 | if Data.CivStage<3 %test for civ files |
---|
| 2856 | msgbox_uvmat('ERROR',['no patch data in ' filename]) |
---|
| 2857 | filecell=[]; |
---|
| 2858 | return |
---|
| 2859 | end |
---|
| 2860 | elseif isempty(Data.patch)||isequal(Data.patch,0) |
---|
[2] | 2861 | msgbox_uvmat('ERROR',['no patch data in ' filename]) |
---|
[12] | 2862 | filecell=[]; |
---|
[2] | 2863 | return |
---|
| 2864 | end |
---|
[112] | 2865 | end |
---|
[2] | 2866 | end |
---|
| 2867 | end |
---|
| 2868 | end |
---|
| 2869 | if strcmp(compare,'stereo PIV') |
---|
| 2870 | for ifile=1:nbfield |
---|
| 2871 | for j=1:nbslice |
---|
| 2872 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 2873 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 2874 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 2875 | if ~exist(filename,'file') |
---|
| 2876 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
| 2877 | set(handles.RUN, 'Enable','On') |
---|
| 2878 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 2879 | return |
---|
| 2880 | end |
---|
| 2881 | end |
---|
| 2882 | end |
---|
| 2883 | end |
---|
| 2884 | end |
---|
[112] | 2885 | |
---|
| 2886 | detect=1; |
---|
| 2887 | % while detect==1%creates a new subdir if the netcdf files already contain civ2 data |
---|
| 2888 | for ifile=1:nbfield |
---|
| 2889 | for j=1:nbslice |
---|
| 2890 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
[2] | 2891 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2); |
---|
[112] | 2892 | detect=exist(filename,'file')==2; |
---|
| 2893 | filecell.nc.civ2(ifile,j)={filename}; |
---|
[2] | 2894 | end |
---|
[112] | 2895 | end |
---|
[2] | 2896 | %get first image names for civ2 |
---|
| 2897 | if box_test(1)==1 & isequal(num1_civ1,num1_civ2) & isequal(num_a_civ1,num_a_civ2) |
---|
| 2898 | filecell.ima1.civ2=filecell.ima1.civ1; |
---|
| 2899 | elseif box_test(4)==1 |
---|
| 2900 | for ifile=1:nbfield |
---|
| 2901 | for j=1:nbslice |
---|
| 2902 | filename=name_generator(filebase_ima1, num1_civ2(ifile),num_a_civ2(j),ext_ima,nom_type_ima1); |
---|
| 2903 | idetect_2(j)=exist(filename,'file')==2; |
---|
| 2904 | filecell.ima1.civ2(ifile,j)={filename};%first image |
---|
| 2905 | end |
---|
[112] | 2906 | [idetectmin,indexj]=min(idetect_2); |
---|
[2] | 2907 | if idetectmin==0, |
---|
[112] | 2908 | msgbox_uvmat('ERROR',['input image ' filecell.ima1.civ2{ifile,indexj} ' not found']) |
---|
| 2909 | filecell=[]; |
---|
| 2910 | return |
---|
[2] | 2911 | end |
---|
| 2912 | end |
---|
| 2913 | end |
---|
| 2914 | |
---|
| 2915 | %get second image names for civ2 |
---|
| 2916 | if box_test(1)==1 & isequal(num2_civ1,num2_civ2) & isequal(num_b_civ1,num_b_civ2) |
---|
| 2917 | filecell.ima2.civ2=filecell.ima2.civ1; |
---|
| 2918 | elseif box_test(4)==1 |
---|
| 2919 | for ifile=1:nbfield |
---|
| 2920 | for j=1:nbslice |
---|
| 2921 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),ext_ima,nom_type_ima2); |
---|
| 2922 | idetect_3(j)=exist(filename,'file')==2; |
---|
| 2923 | filecell.ima2.civ2(ifile,j)={filename};%first image |
---|
| 2924 | end |
---|
[112] | 2925 | [idetectmin,indexj]=min(idetect_3); |
---|
[2] | 2926 | if idetectmin==0, |
---|
[112] | 2927 | msgbox_uvmat('ERROR',['input image ' filecell.ima2.civ2{ifile,indexj} ' not found']) |
---|
| 2928 | filecell=[]; |
---|
| 2929 | return |
---|
[2] | 2930 | end |
---|
| 2931 | end |
---|
| 2932 | end |
---|
| 2933 | end |
---|
| 2934 | if (box_test(5)==1 || box_test(6)==1 ) && box_test(4)==0 % need to read an existing netcdf civ2 file |
---|
| 2935 | if ~testdiff |
---|
| 2936 | filecell.nc.civ2=filecell.nc.civ1;% file already checked |
---|
[112] | 2937 | else % check the civ2 files |
---|
[2] | 2938 | for ifile=1:nbfield |
---|
| 2939 | for j=1:nbslice |
---|
| 2940 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
[112] | 2941 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
[2] | 2942 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 2943 | if ~exist(filename,'file') |
---|
| 2944 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
[12] | 2945 | filecell=[]; |
---|
[2] | 2946 | return |
---|
| 2947 | else |
---|
[248] | 2948 | Data=nc2struct(filename,'ListGlobalAttribute','CivStage','civ2'); |
---|
| 2949 | if ~isempty(Data.CivStage) && Data.CivStage<4 %test for civ files |
---|
| 2950 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
| 2951 | filecell=[]; |
---|
| 2952 | return |
---|
| 2953 | elseif isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
[2] | 2954 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
[12] | 2955 | filecell=[]; |
---|
[2] | 2956 | return |
---|
| 2957 | end |
---|
| 2958 | end |
---|
| 2959 | end |
---|
| 2960 | end |
---|
| 2961 | end |
---|
| 2962 | end |
---|
| 2963 | |
---|
| 2964 | %%%%%%%%%%%%% if stereo fields are calculated by PATCH %%%%%%%%%%%%% |
---|
| 2965 | if strcmp(compare,'stereo PIV') |
---|
[127] | 2966 | if box_test(3)==1 && isequal(get(handles.test_stereo1,'Value'),1) |
---|
[2] | 2967 | for ifile=1:nbfield |
---|
| 2968 | for j=1:nbslice |
---|
| 2969 | filename=name_generator(filebase_AB,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 2970 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 2971 | filecell.st(ifile,j)={filename}; |
---|
| 2972 | end |
---|
| 2973 | end |
---|
| 2974 | end |
---|
[127] | 2975 | if box_test(6)==1 && isequal(get(handles.test_stereo2,'Value'),1) |
---|
[2] | 2976 | for ifile=1:nbfield |
---|
| 2977 | for j=1:nbslice |
---|
| 2978 | filename=name_generator(filebase_AB,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 2979 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 2980 | filecell.st(ifile,j)={filename}; |
---|
| 2981 | end |
---|
| 2982 | end |
---|
[112] | 2983 | end |
---|
[2] | 2984 | end |
---|
| 2985 | set(handles.subdir_civ1,'String',subdir_civ1);%update the edit box |
---|
| 2986 | set(handles.subdir_civ2,'String',subdir_civ2);%update the edit box |
---|
| 2987 | browse.nom_type_nc=nom_type_nc; |
---|
| 2988 | set(handles.browse_root,'UserData',browse); %update the nomenclature type for uvmat |
---|
| 2989 | |
---|
| 2990 | |
---|
| 2991 | %COPY IMAGES TO THE FORMAT .png IF NEEDED |
---|
[45] | 2992 | if isequal(nom_type_ima1,'*')%case of movie files |
---|
| 2993 | nom_type_imanew1='_i'; |
---|
[2] | 2994 | else |
---|
| 2995 | nom_type_imanew1=nom_type_ima1; |
---|
| 2996 | end |
---|
[45] | 2997 | if isequal(nom_type_ima2,'*')%case of movie files |
---|
| 2998 | nom_type_imanew2='_i'; |
---|
[2] | 2999 | else |
---|
| 3000 | nom_type_imanew2=nom_type_ima2; |
---|
| 3001 | end |
---|
| 3002 | if ~isequal(ext_ima,'.png') |
---|
[45] | 3003 | %%type of image file |
---|
| 3004 | type_ima1='none';%default |
---|
| 3005 | movieobject1=[];%default |
---|
[133] | 3006 | if strcmpi(ext_ima,'.avi') |
---|
[45] | 3007 | hhh=which('mmreader'); |
---|
| 3008 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
---|
| 3009 | type_ima1='movie'; |
---|
| 3010 | movieobject1=mmreader([filebase_ima2 ext_ima]); |
---|
| 3011 | else |
---|
| 3012 | type_ima1='avi'; |
---|
| 3013 | end |
---|
[133] | 3014 | elseif ischar(ext_ima) && ~isempty(ext_ima(2:end)) |
---|
[112] | 3015 | form=imformats(ext_ima(2:end)); |
---|
| 3016 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 3017 | if isequal(nom_type_ima1,'*'); |
---|
| 3018 | type_ima1='multimage';%image series in a single image file |
---|
| 3019 | else |
---|
| 3020 | type_ima1='image'; |
---|
| 3021 | end |
---|
| 3022 | end |
---|
[45] | 3023 | end |
---|
| 3024 | type_ima2='none';%default |
---|
| 3025 | movieobject2=[]; |
---|
[133] | 3026 | if strcmpi(ext_ima,'.avi') |
---|
[45] | 3027 | hhh=which('mmreader'); |
---|
| 3028 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
---|
| 3029 | type_ima2='movie'; |
---|
| 3030 | movieobject2=mmreader([filebase_ima2 ext_ima]); |
---|
| 3031 | else |
---|
| 3032 | type_ima2='avi'; |
---|
| 3033 | end |
---|
[133] | 3034 | elseif ischar(ext_ima) && ~isempty(ext_ima(2:end)) |
---|
[112] | 3035 | form=imformats(ext_ima(2:end)); |
---|
| 3036 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 3037 | if isequal(nom_type_ima1,'*'); |
---|
| 3038 | type_ima2='multimage';%image series in a single image file |
---|
| 3039 | else |
---|
| 3040 | type_ima2='image'; |
---|
| 3041 | end |
---|
| 3042 | end |
---|
[45] | 3043 | end |
---|
[71] | 3044 | %npxy=get(handles.ImaExt,'UserData'); |
---|
[112] | 3045 | % % if numel(npxy)<2 |
---|
| 3046 | % |
---|
| 3047 | % filename=name_generator(filebase_ima1,num1_civ1(1),num_a_civ1(1),ImaExt,nom_type_ima1); |
---|
| 3048 | % A=imread(filename); |
---|
| 3049 | % npxy=size(A); |
---|
| 3050 | % % end |
---|
| 3051 | % npy=npxy(1); |
---|
| 3052 | % npx=npxy(2); |
---|
[2] | 3053 | if box_test(1)==1 %if civ1 is performed |
---|
[224] | 3054 | h = waitbar(0,'copy images to the .png format for civ1');% display a wait bar |
---|
[112] | 3055 | for ifile=1:nbfield |
---|
[2] | 3056 | waitbar(ifile/nbfield); |
---|
| 3057 | for j=1:nbslice |
---|
[112] | 3058 | filename=name_generator(filebase_ima1,num1_civ1(ifile),num_a_civ1(j),'.png',nom_type_imanew1); |
---|
| 3059 | if ~exist(filename,'file') |
---|
| 3060 | A=read_image(filecell.ima1.civ1{ifile,j},type_ima1,num1_civ1(ifile),movieobject1); |
---|
| 3061 | imwrite(A,filename,'BitDepth',16); |
---|
| 3062 | end |
---|
| 3063 | filecell.ima1.civ1(ifile,j)={filename}; |
---|
| 3064 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),'.png',nom_type_imanew2); |
---|
| 3065 | if ~exist(filename,'file') |
---|
| 3066 | A=read_image(filecell.ima2.civ1{ifile,j},type_ima2,num2_civ1(ifile),movieobject2); |
---|
| 3067 | imwrite(A,filename,'BitDepth',16); |
---|
| 3068 | end |
---|
| 3069 | filecell.ima2.civ1(ifile,j)={filename}; |
---|
[2] | 3070 | end |
---|
| 3071 | end |
---|
| 3072 | close(h) |
---|
| 3073 | end |
---|
| 3074 | if box_test(4)==1 %if civ2 is performed |
---|
[229] | 3075 | h = waitbar(0,'copy images to the .png format for civ2');% display a wait bar |
---|
[2] | 3076 | for ifile=1:nbfield |
---|
| 3077 | waitbar(ifile/nbfield); |
---|
| 3078 | for j=1:nbslice |
---|
[112] | 3079 | filename=name_generator(filebase_ima1,num1_civ2(ifile),num_a_civ2(j),'.png',nom_type_imanew1); |
---|
| 3080 | if ~exist(filename,'file') |
---|
| 3081 | A=read_image(cell2mat(filecell.ima1.civ2(ifile,j)),type_ima2,num1_civ2(ifile)); |
---|
| 3082 | imwrite(A,filename,'BitDepth',16); |
---|
| 3083 | end |
---|
| 3084 | filecell.ima1.civ2(ifile,j)={filename}; |
---|
| 3085 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),'.png',nom_type_imanew2); |
---|
| 3086 | if ~exist(filename,'file') |
---|
| 3087 | A=read_image(cell2mat(filecell.ima2.civ2(ifile,j)),type_ima2,num2_civ2(ifile)); |
---|
| 3088 | imwrite(A,filename,'BitDepth',16); |
---|
| 3089 | end |
---|
| 3090 | filecell.ima2.civ2(ifile,j)={filename}; |
---|
[2] | 3091 | end |
---|
| 3092 | end |
---|
| 3093 | close(h); |
---|
| 3094 | end |
---|
| 3095 | end |
---|
| 3096 | |
---|
[12] | 3097 | %------------------------------------------------------------------------ |
---|
[227] | 3098 | % --- determine the list of index pairs of processing file |
---|
| 3099 | function [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
| 3100 | find_pair_indices(handles,ref_i,ref_j,mode) |
---|
| 3101 | %------------------------------------------------------------------------ |
---|
| 3102 | |
---|
| 3103 | list_civ1=get(handles.list_pair_civ1,'String'); |
---|
| 3104 | index_civ1=get(handles.list_pair_civ1,'Value'); |
---|
| 3105 | str_civ1=list_civ1{index_civ1};%string defining the image pairs for civ1 |
---|
| 3106 | if isempty(str_civ1)||isequal(str_civ1,'') |
---|
| 3107 | msgbox_uvmat('ERROR','no image pair selected for civ1') |
---|
| 3108 | return |
---|
| 3109 | end |
---|
| 3110 | list_civ2=get(handles.list_pair_civ2,'String'); |
---|
| 3111 | index_civ2=get(handles.list_pair_civ2,'Value'); |
---|
| 3112 | if index_civ2>length(list_civ2) |
---|
| 3113 | list_civ2=list_civ1; |
---|
| 3114 | index_civ2=index_civ1; |
---|
| 3115 | end |
---|
| 3116 | str_civ2=list_civ2{index_civ2};%string defining the image pairs for civ2 |
---|
| 3117 | |
---|
| 3118 | if isequal (mode,'series(Di)') |
---|
| 3119 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 3120 | num1_civ1=ref_i-floor(index_civ1/2)*ones(size(ref_i));% set of first image numbers |
---|
| 3121 | num2_civ1=ref_i+ceil(index_civ1/2)*ones(size(ref_i)); |
---|
| 3122 | num_a_civ1=ref_j; |
---|
| 3123 | num_b_civ1=ref_j; |
---|
[229] | 3124 | num1_civ2=ref_i-floor(index_civ2/2)*ones(size(ref_i)); |
---|
[227] | 3125 | num2_civ2=ref_i+ceil(index_civ2/2)*ones(size(ref_i)); |
---|
| 3126 | num_a_civ2=ref_j; |
---|
| 3127 | num_b_civ2=ref_j; |
---|
| 3128 | |
---|
| 3129 | % adjust the first and last field number |
---|
| 3130 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 3131 | if isnan(lastfield) |
---|
| 3132 | indsel=find((num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
| 3133 | else |
---|
| 3134 | indsel=find((num2_civ1 <= lastfield)&(num2_civ2 <= lastfield)&(num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
| 3135 | end |
---|
| 3136 | if length(indsel)>=1 |
---|
| 3137 | firstind=indsel(1); |
---|
| 3138 | lastind=indsel(end); |
---|
| 3139 | set(handles.first_i,'String',num2str(ref_i(firstind)))%update the display of first and last fields |
---|
| 3140 | set(handles.last_i,'String',num2str(ref_i(lastind))) |
---|
| 3141 | ref_i=ref_i(indsel); |
---|
| 3142 | num1_civ1=num1_civ1(indsel); |
---|
| 3143 | num1_civ2=num1_civ2(indsel); |
---|
| 3144 | num2_civ1=num2_civ1(indsel); |
---|
| 3145 | num2_civ2=num2_civ2(indsel); |
---|
| 3146 | end |
---|
| 3147 | elseif isequal (mode,'series(Dj)') |
---|
| 3148 | lastfield_j=str2double(get(handles.nb_field2,'String')); |
---|
| 3149 | num1_civ1=ref_i;% set of first image numbers |
---|
| 3150 | num2_civ1=ref_i; |
---|
| 3151 | num_a_civ1=ref_j-floor(index_civ1/2)*ones(size(ref_j)); |
---|
| 3152 | num_b_civ1=ref_j+ceil(index_civ1/2)*ones(size(ref_j)); |
---|
| 3153 | num1_civ2=ref_i; |
---|
| 3154 | num2_civ2=ref_i; |
---|
| 3155 | num_a_civ2=ref_j-floor(index_civ2/2)*ones(size(ref_j)); |
---|
| 3156 | num_b_civ2=ref_j+ceil(index_civ2/2)*ones(size(ref_j)); |
---|
| 3157 | % adjust the first and last field number |
---|
| 3158 | if isnan(lastfield_j) |
---|
| 3159 | indsel=find((num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
| 3160 | else |
---|
| 3161 | indsel=find((num_b_civ1 <= lastfield_j)&(num_b_civ2 <= lastfield_j)&(num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
| 3162 | end |
---|
| 3163 | if length(indsel)>=1 |
---|
| 3164 | firstind=indsel(1); |
---|
| 3165 | lastind=indsel(end); |
---|
| 3166 | set(handles.first_j,'String',num2str(ref_j(firstind)))%update the display of first and last fields |
---|
| 3167 | set(handles.last_j,'String',num2str(ref_j(lastind))) |
---|
| 3168 | ref_j=ref_j(indsel); |
---|
| 3169 | num_a_civ1=num_a_civ1(indsel); |
---|
| 3170 | num_b_civ1=num_b_civ1(indsel); |
---|
| 3171 | num_a_civ2=num_a_civ2(indsel); |
---|
| 3172 | num_b_civ2=num_b_civ2(indsel); |
---|
| 3173 | end |
---|
| 3174 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
| 3175 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 3176 | num1_civ1=ref_i; |
---|
| 3177 | num2_civ1=ref_i; |
---|
| 3178 | num_a_civ1=displ_num(1,index_civ1); |
---|
| 3179 | num_b_civ1=displ_num(2,index_civ1); |
---|
| 3180 | num1_civ2=ref_i; |
---|
| 3181 | num2_civ2=ref_i; |
---|
| 3182 | num_a_civ2=displ_num(1,index_civ2); |
---|
| 3183 | num_b_civ2=displ_num(2,index_civ2); |
---|
| 3184 | elseif isequal(mode,'displacement') |
---|
| 3185 | num1_civ1=ref_i; |
---|
| 3186 | num2_civ1=ref_i; |
---|
| 3187 | num_a_civ1=ref_j; |
---|
| 3188 | num_b_civ1=ref_j; |
---|
| 3189 | num1_civ2=ref_i; |
---|
| 3190 | num2_civ2=ref_i; |
---|
| 3191 | num_a_civ2=ref_j; |
---|
| 3192 | num_b_civ2=ref_j; |
---|
| 3193 | end |
---|
| 3194 | |
---|
| 3195 | |
---|
| 3196 | %------------------------------------------------------------------------ |
---|
[12] | 3197 | % --- PATCH |
---|
[94] | 3198 | function cmd_PATCH=PATCH_CMD(filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,test_interp,PatchBin) |
---|
[12] | 3199 | %------------------------------------------------------------------------ |
---|
[224] | 3200 | namelog=[filename_nc(1:end-3) '_patch.log']; |
---|
[112] | 3201 | if test_interp==0 |
---|
[163] | 3202 | if isunix |
---|
[112] | 3203 | cmd_PATCH=[PatchBin ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ... |
---|
| 3204 | ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
[163] | 3205 | else |
---|
| 3206 | cmd_PATCH=['"' PatchBin '" -f "' filename_nc '" -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ... |
---|
| 3207 | ' > "' namelog '" 2>&1']; % redirect standard output to the log file |
---|
| 3208 | end |
---|
[112] | 3209 | else %nouveau programme patch |
---|
| 3210 | cmd_PATCH=[PatchBin ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ... |
---|
| 3211 | ' -max ' thresh_value ' -nopt ' subdomain_patch ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
| 3212 | end |
---|
[163] | 3213 | cmd_PATCH=regexprep(cmd_PATCH,'\\','\\\\'); |
---|
[12] | 3214 | %------------------------------------------------------------------------ |
---|
| 3215 | % --- STEREO Interp |
---|
[67] | 3216 | function cmd=RUN_STINTERP(stinterpBin,filename_A_nc,filename_B_nc,filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,xmlA,xmlB) |
---|
[12] | 3217 | %------------------------------------------------------------------------ |
---|
[224] | 3218 | namelog=[filename_nc(1:end-3) '_stinterp.log']; |
---|
[67] | 3219 | cmd=[stinterpBin ' -f1 ' filename_A_nc ' -f2 ' filename_B_nc ' -f ' filename_nc ... |
---|
[2] | 3220 | ' -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 |
---|
| 3221 | |
---|
[12] | 3222 | %------------------------------------------------------------------------ |
---|
[2] | 3223 | % --- Executes on button press in CIV1. |
---|
| 3224 | function CIV1_Callback(hObject, eventdata, handles) |
---|
[12] | 3225 | %------------------------------------------------------------------------ |
---|
[2] | 3226 | val=get(handles.CIV1,'Value'); |
---|
| 3227 | if isequal(val,1) |
---|
| 3228 | enable_civ1(handles,'on') |
---|
| 3229 | enable_pair1(handles,'on') |
---|
| 3230 | else |
---|
| 3231 | enable_civ1(handles,'off') |
---|
| 3232 | end |
---|
| 3233 | find_netcpair_civ1(hObject, eventdata, handles); |
---|
| 3234 | |
---|
[12] | 3235 | %------------------------------------------------------------------------ |
---|
[2] | 3236 | % --- Executes on button press in FIX1. |
---|
| 3237 | function FIX1_Callback(hObject, eventdata, handles) |
---|
[12] | 3238 | %------------------------------------------------------------------------ |
---|
[2] | 3239 | enable_fix1(handles,get(handles.FIX1,'Value')) |
---|
| 3240 | |
---|
[12] | 3241 | %------------------------------------------------------------------------ |
---|
[2] | 3242 | % --- Executes on button press in PATCH1. |
---|
| 3243 | function PATCH1_Callback(hObject, eventdata, handles) |
---|
[12] | 3244 | %------------------------------------------------------------------------ |
---|
[2] | 3245 | if get(handles.PATCH1,'Value')==1 |
---|
[12] | 3246 | enable_patch1(handles) |
---|
[2] | 3247 | else |
---|
[12] | 3248 | desable_patch1(handles) |
---|
[2] | 3249 | end |
---|
| 3250 | |
---|
[12] | 3251 | %------------------------------------------------------------------------ |
---|
[2] | 3252 | % --- Executes on button press in CIV2. |
---|
| 3253 | function CIV2_Callback(hObject, eventdata, handles) |
---|
[12] | 3254 | %------------------------------------------------------------------------ |
---|
[2] | 3255 | state=get(handles.CIV2,'Value'); |
---|
| 3256 | enable_civ2(handles,state) |
---|
| 3257 | if state |
---|
| 3258 | find_netcpair_civ2(hObject, eventdata, handles) |
---|
| 3259 | enable_pair1(handles,'on') |
---|
| 3260 | end |
---|
| 3261 | |
---|
[12] | 3262 | %------------------------------------------------------------------------ |
---|
[2] | 3263 | % --- Executes on button press in FIX2. |
---|
| 3264 | function FIX2_Callback(hObject, eventdata, handles) |
---|
[12] | 3265 | %------------------------------------------------------------------------ |
---|
[2] | 3266 | if get(handles.FIX2,'Value')==1 |
---|
| 3267 | enable_fix2(handles) |
---|
| 3268 | if get(handles.CIV2,'Value')==0 |
---|
| 3269 | find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files |
---|
| 3270 | end |
---|
| 3271 | else |
---|
| 3272 | desable_fix2(handles) |
---|
| 3273 | end |
---|
| 3274 | |
---|
[12] | 3275 | %------------------------------------------------------------------------ |
---|
[2] | 3276 | % --- Executes on button press in PATCH2. |
---|
| 3277 | function PATCH2_Callback(hObject, eventdata, handles) |
---|
[12] | 3278 | %------------------------------------------------------------------------ |
---|
[2] | 3279 | if get(handles.PATCH2,'Value')==1 |
---|
| 3280 | enable_patch2(handles) |
---|
| 3281 | if get(handles.CIV2,'Value')==0 |
---|
| 3282 | find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files |
---|
| 3283 | end |
---|
| 3284 | else |
---|
| 3285 | desable_patch2(handles) |
---|
| 3286 | end |
---|
| 3287 | |
---|
[12] | 3288 | %------------------------------------------------------------------------ |
---|
| 3289 | function first_i_Callback(hObject, eventdata, handles) |
---|
| 3290 | %------------------------------------------------------------------------ |
---|
| 3291 | % last_i_Callback(hObject, eventdata, handles) |
---|
[137] | 3292 | first_i=str2double(get(handles.first_i,'String')); |
---|
[12] | 3293 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 3294 | % ref_i=ceil((first_i+last_i)/2); |
---|
| 3295 | set(handles.ref_i,'String', num2str(first_i))% reference index for pair dt = first index |
---|
[71] | 3296 | set(handles.ref_i_civ2,'String', num2str(first_i))% reference index for pair dt = first index |
---|
[12] | 3297 | ref_i_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3298 | |
---|
[12] | 3299 | %------------------------------------------------------------------------ |
---|
| 3300 | function first_j_Callback(hObject, eventdata, handles) |
---|
| 3301 | %------------------------------------------------------------------------ |
---|
| 3302 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 3303 | set(handles.ref_j,'String', num2str(first_j))% reference index for pair dt = first index |
---|
| 3304 | ref_j_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3305 | |
---|
[12] | 3306 | %------------------------------------------------------------------------ |
---|
[2] | 3307 | % --- Executes on button press in calcul_search: determine the search range isx,isy |
---|
| 3308 | function calcul_search_Callback(hObject, eventdata, handles) |
---|
[12] | 3309 | %------------------------------------------------------------------------ |
---|
[2] | 3310 | %determine pair numbers |
---|
| 3311 | list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs |
---|
| 3312 | index=get(handles.list_pair_civ1,'Value'); |
---|
| 3313 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
[71] | 3314 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
[2] | 3315 | pxcm_xy=get(handles.calcul_search,'UserData'); |
---|
| 3316 | pxcmx=pxcm_xy(1); |
---|
| 3317 | pxcmy=pxcm_xy(2); |
---|
| 3318 | mode_list=get(handles.mode,'String'); |
---|
| 3319 | mode_value=get(handles.mode,'Value'); |
---|
| 3320 | mode=mode_list{mode_value}; |
---|
| 3321 | if isequal (mode, 'series(Di)' ) |
---|
[137] | 3322 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[2] | 3323 | num1=ref_i-floor(index/2);% first image numbers |
---|
| 3324 | num2=ref_i+ceil(index/2); |
---|
| 3325 | num_a=1; |
---|
| 3326 | num_b=1; |
---|
[112] | 3327 | elseif isequal (mode, 'series(Dj)') |
---|
[2] | 3328 | num1=1; |
---|
| 3329 | num2=1; |
---|
[137] | 3330 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
[2] | 3331 | num_a=ref_j-floor(index/2);% first image numbers |
---|
| 3332 | num_b=ref_j+ceil(index/2); |
---|
| 3333 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
[137] | 3334 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[2] | 3335 | num1=ref_i; |
---|
| 3336 | num2=ref_i; |
---|
| 3337 | num_a=displ_num(1,index); |
---|
| 3338 | num_b=displ_num(2,index); |
---|
| 3339 | end |
---|
| 3340 | dt=time(num2,num_b)-time(num1,num_a); |
---|
[137] | 3341 | ibx=str2double(get(handles.ibx,'String')); |
---|
| 3342 | iby=str2double(get(handles.iby,'String')); |
---|
| 3343 | umin=dt*pxcmx*str2double(get(handles.umin,'String')); |
---|
| 3344 | umax=dt*pxcmx*str2double(get(handles.umax,'String')); |
---|
| 3345 | vmin=dt*pxcmy*str2double(get(handles.vmin,'String')); |
---|
| 3346 | vmax=dt*pxcmy*str2double(get(handles.vmax,'String')); |
---|
[2] | 3347 | shiftx=round((umin+umax)/2); |
---|
| 3348 | shifty=round((vmin+vmax)/2); |
---|
| 3349 | isx=(umax+2-shiftx)*2+ibx; |
---|
| 3350 | isx=2*ceil(isx/2)+1; |
---|
| 3351 | isy=(vmax+2-shifty)*2+iby; |
---|
| 3352 | isy=2*ceil(isy/2)+1; |
---|
| 3353 | set(handles.shiftx,'String',num2str(shiftx)); |
---|
| 3354 | set(handles.shifty,'String',num2str(shifty)); |
---|
| 3355 | set(handles.isx,'String',num2str(isx)); |
---|
| 3356 | set(handles.isy,'String',num2str(isy)); |
---|
| 3357 | |
---|
[12] | 3358 | %------------------------------------------------------------------------ |
---|
| 3359 | % --- Executes on carriage return on the subdir civ1 edit window |
---|
[2] | 3360 | function subdir_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 3361 | %------------------------------------------------------------------------ |
---|
[2] | 3362 | subdir=get(handles.subdir_civ1,'String'); |
---|
| 3363 | set(handles.subdir_civ2,'String',subdir); |
---|
[112] | 3364 | if get(handles.CIV1,'Value')==0 |
---|
[2] | 3365 | find_netcpair_civ1(hObject, eventdata, handles); %update the list of available pairs from netcdf files in the new directory |
---|
| 3366 | end |
---|
| 3367 | |
---|
[12] | 3368 | %------------------------------------------------------------------------ |
---|
| 3369 | % --- Executes on carriage return on the subdir civ1 edit window |
---|
[2] | 3370 | function subdir_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 3371 | %------------------------------------------------------------------------ |
---|
[2] | 3372 | %update the list of available pairs from netcdf files in the new directory |
---|
| 3373 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0 |
---|
| 3374 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 3375 | end |
---|
| 3376 | |
---|
[12] | 3377 | %------------------------------------------------------------------------ |
---|
[133] | 3378 | % --- Executes on button press in get_mask_civ1: select box for mask option |
---|
[2] | 3379 | function get_mask_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 3380 | %------------------------------------------------------------------------ |
---|
[252] | 3381 | maskval=get(handles.get_mask_civ1,'Value') |
---|
[2] | 3382 | if isequal(maskval,0) |
---|
| 3383 | set(handles.mask_civ1,'String','') |
---|
| 3384 | else |
---|
| 3385 | mask_displ='no mask'; %default |
---|
[71] | 3386 | filebase=get(handles.RootName,'String'); |
---|
[2] | 3387 | [ nbslice_mask, flag_mask]=get_mask(filebase,handles); |
---|
| 3388 | if isequal(flag_mask,1) |
---|
[112] | 3389 | mask_displ=[num2str(nbslice_mask) 'mask']; |
---|
[2] | 3390 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[112] | 3391 | common_path=fileparts(filebase); |
---|
| 3392 | filebase_a=fullfile(common_path,get(handles.RootName_1,'String')); |
---|
| 3393 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
| 3394 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice_mask) |
---|
| 3395 | mask_displ='no mask'; |
---|
| 3396 | end |
---|
[2] | 3397 | end |
---|
| 3398 | if isequal(mask_displ,'no mask') |
---|
[12] | 3399 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3400 | {'*.png', ' (*.png)'; |
---|
| 3401 | '*.png', '.png files '; ... |
---|
| 3402 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3403 | 'Pick a mask file *.png',filebase); |
---|
| 3404 | mask_displ=fullfile(PathName,FileName); |
---|
[12] | 3405 | if ~exist(mask_displ,'file') |
---|
| 3406 | mask_displ='no mask'; |
---|
| 3407 | end |
---|
| 3408 | end |
---|
| 3409 | if isequal(mask_displ,'no mask') |
---|
[2] | 3410 | set(handles.get_mask_civ1,'Value',0) |
---|
| 3411 | set(handles.get_mask_fix1,'Value',0) |
---|
| 3412 | set(handles.get_mask_civ2,'Value',0) |
---|
| 3413 | set(handles.get_mask_fix2,'Value',0) |
---|
| 3414 | else |
---|
| 3415 | set(handles.get_mask_fix1,'Value',1) |
---|
| 3416 | set(handles.get_mask_fix2,'Value',1) |
---|
| 3417 | end |
---|
| 3418 | set(handles.mask_civ1,'String',mask_displ) |
---|
| 3419 | set(handles.mask_fix1,'String',mask_displ) |
---|
| 3420 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 3421 | set(handles.mask_fix2,'String',mask_displ) |
---|
| 3422 | end |
---|
[133] | 3423 | set(handles.get_mask_civ2,'Value',maskval)%update the civ2 mask with the same option as civ1 |
---|
[2] | 3424 | |
---|
[12] | 3425 | %------------------------------------------------------------------------ |
---|
[2] | 3426 | % --- Executes on button press in get_mask_fix1. |
---|
| 3427 | function get_mask_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 3428 | %------------------------------------------------------------------------ |
---|
[2] | 3429 | maskval=get(handles.get_mask_fix1,'Value'); |
---|
| 3430 | if isequal(maskval,0) |
---|
| 3431 | set(handles.mask_fix1,'String','') |
---|
| 3432 | else |
---|
[112] | 3433 | mask_displ='no mask'; %default |
---|
| 3434 | filebase=get(handles.RootName,'String'); |
---|
| 3435 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3436 | if isequal(flag_mask,1) |
---|
| 3437 | mask_displ=[num2str(nbslice) 'mask']; |
---|
| 3438 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[71] | 3439 | filebase_a=get(handles.RootName_1,'String'); |
---|
[2] | 3440 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[229] | 3441 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
[2] | 3442 | mask_displ='no mask'; |
---|
| 3443 | end |
---|
[112] | 3444 | end |
---|
| 3445 | if isequal(mask_displ,'no mask') |
---|
| 3446 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3447 | {'*.png', ' (*.png)'; |
---|
[12] | 3448 | '*.png', '.png files '; ... |
---|
| 3449 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3450 | 'Pick a mask file *.png',filebase); |
---|
[112] | 3451 | mask_displ=fullfile(PathName,FileName); |
---|
| 3452 | if ~exist(mask_displ,'file') |
---|
| 3453 | mask_displ='no mask'; |
---|
| 3454 | end |
---|
[12] | 3455 | end |
---|
[112] | 3456 | if isequal(mask_displ,'no mask') |
---|
| 3457 | set(handles.get_mask_fix1,'Value',0) |
---|
| 3458 | set(handles.get_mask_civ2,'Value',0) |
---|
| 3459 | set(handles.get_mask_fix2,'Value',0) |
---|
| 3460 | else |
---|
| 3461 | %set(handles.get_mask_civ2,'Value',1) |
---|
| 3462 | set(handles.get_mask_fix2,'Value',1) |
---|
| 3463 | end |
---|
| 3464 | set(handles.mask_fix1,'String',mask_displ) |
---|
| 3465 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 3466 | set(handles.mask_fix2,'String',mask_displ) |
---|
[12] | 3467 | end |
---|
| 3468 | |
---|
| 3469 | %------------------------------------------------------------------------ |
---|
[133] | 3470 | % --- Executes on button press in get_mask_civ2: select box for mask option |
---|
[2] | 3471 | function get_mask_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 3472 | %------------------------------------------------------------------------ |
---|
[2] | 3473 | maskval=get(handles.get_mask_civ2,'Value'); |
---|
| 3474 | if isequal(maskval,0) |
---|
| 3475 | set(handles.mask_civ2,'String','') |
---|
| 3476 | else |
---|
[112] | 3477 | mask_displ='no mask'; %default |
---|
| 3478 | filebase=get(handles.RootName,'String'); |
---|
| 3479 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3480 | if isequal(flag_mask,1) |
---|
| 3481 | mask_displ=[num2str(nbslice) 'mask']; |
---|
| 3482 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[71] | 3483 | filebase_a=get(handles.RootName_1,'String'); |
---|
[2] | 3484 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[229] | 3485 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
[2] | 3486 | mask_displ='no mask'; |
---|
| 3487 | end |
---|
[112] | 3488 | end |
---|
| 3489 | if isequal(mask_displ,'no mask') |
---|
| 3490 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3491 | {'*.png', ' (*.png)'; |
---|
[12] | 3492 | '*.png', '.png files '; ... |
---|
| 3493 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3494 | 'Pick a mask file *.png',filebase); |
---|
[112] | 3495 | mask_displ=fullfile(PathName,FileName); |
---|
| 3496 | if ~exist(mask_displ,'file') |
---|
| 3497 | mask_displ='no mask'; |
---|
| 3498 | end |
---|
[12] | 3499 | end |
---|
[112] | 3500 | if isequal(mask_displ,'no mask') |
---|
| 3501 | set(handles.get_mask_civ2,'Value',0) |
---|
| 3502 | set(handles.get_mask_fix2,'Value',0) |
---|
| 3503 | else |
---|
| 3504 | set(handles.get_mask_fix2,'Value',1) |
---|
| 3505 | end |
---|
| 3506 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 3507 | set(handles.mask_fix2,'String',mask_displ) |
---|
[12] | 3508 | end |
---|
| 3509 | |
---|
| 3510 | %------------------------------------------------------------------------ |
---|
[2] | 3511 | % --- Executes on button press in get_mask_fix2. |
---|
| 3512 | function get_mask_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 3513 | %------------------------------------------------------------------------ |
---|
[2] | 3514 | maskval=get(handles.get_mask_fix2,'Value'); |
---|
| 3515 | if isequal(maskval,0) |
---|
| 3516 | set(handles.mask_fix2,'String','') |
---|
| 3517 | else |
---|
[12] | 3518 | mask_displ='no mask'; %default |
---|
[71] | 3519 | filebase=get(handles.RootName,'String'); |
---|
[12] | 3520 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3521 | if isequal(flag_mask,1) |
---|
[112] | 3522 | mask_displ=[num2str(nbslice) 'mask']; |
---|
[12] | 3523 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[112] | 3524 | filebase_a=get(handles.RootName_1,'String'); |
---|
| 3525 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[229] | 3526 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
[112] | 3527 | mask_displ='no mask'; |
---|
| 3528 | end |
---|
[12] | 3529 | end |
---|
| 3530 | if isequal(mask_displ,'no mask') |
---|
| 3531 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3532 | {'*.png', ' (*.png)'; |
---|
| 3533 | '*.png', '.png files '; ... |
---|
| 3534 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3535 | 'Pick a mask file *.png',filebase); |
---|
| 3536 | mask_displ=fullfile(PathName,FileName); |
---|
[12] | 3537 | if ~exist(mask_displ,'file') |
---|
[2] | 3538 | mask_displ='no mask'; |
---|
| 3539 | end |
---|
[12] | 3540 | end |
---|
| 3541 | if isequal(mask_displ,'no mask') |
---|
| 3542 | set(handles.get_mask_fix2,'Value',0) |
---|
[112] | 3543 | end |
---|
[12] | 3544 | set(handles.mask_fix2,'String',mask_displ) |
---|
[2] | 3545 | end |
---|
| 3546 | |
---|
[12] | 3547 | %------------------------------------------------------------------------ |
---|
| 3548 | % --- function called to look for mask files |
---|
[2] | 3549 | function [nbslice, flag_mask]=get_mask(filebase,handles) |
---|
[12] | 3550 | %------------------------------------------------------------------------ |
---|
[112] | 3551 | %detect mask files, images with appropriate file base |
---|
[2] | 3552 | %[filebase '_' xx 'mask'], xx=nbslice |
---|
| 3553 | %flag_mask=1 indicates detection |
---|
| 3554 | |
---|
| 3555 | flag_mask=0;%default |
---|
| 3556 | nbslice=1; |
---|
| 3557 | |
---|
| 3558 | % subdir=get(handles.subdir_civ1,'String'); |
---|
| 3559 | [Path,Name]=fileparts(filebase); |
---|
[12] | 3560 | if ~isdir(Path) |
---|
| 3561 | msgbox_uvmat('ERROR','no path for input files') |
---|
| 3562 | return |
---|
| 3563 | end |
---|
[2] | 3564 | currentdir=pwd; |
---|
| 3565 | cd(Path);%move in the dir of the root name filebase |
---|
| 3566 | maskfiles=dir([Name '_*mask_*.png']);%look for mask files |
---|
| 3567 | cd(currentdir);%come back to the current working directory |
---|
[12] | 3568 | if ~isempty(maskfiles) |
---|
[112] | 3569 | % msgbox_uvmat('ERROR','no mask available, to create it use Tools/Make mask in the upper menu bar of uvmat') |
---|
| 3570 | % else |
---|
[2] | 3571 | flag_mask=1; |
---|
| 3572 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 3573 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 3574 | Namedouble=double(Name); |
---|
| 3575 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 3576 | ind_mask=findstr('mask',Name); |
---|
| 3577 | i=ind_mask-1; |
---|
[137] | 3578 | while val(i)==0 && i>0 |
---|
[112] | 3579 | i=i-1; |
---|
[2] | 3580 | end |
---|
[137] | 3581 | nbslice=str2double(Name(i+1:ind_mask-1)); |
---|
| 3582 | if ~isnan(nbslice) && Name(i)=='_' |
---|
[112] | 3583 | flag_mask=1; |
---|
[2] | 3584 | else |
---|
[112] | 3585 | msgbox_uvmat('ERROR',['bad mask file ' Name ext ' found in ' Path2]) |
---|
| 3586 | return |
---|
| 3587 | nbslice=1; |
---|
[2] | 3588 | end |
---|
[112] | 3589 | end |
---|
[2] | 3590 | |
---|
[12] | 3591 | %------------------------------------------------------------------------ |
---|
| 3592 | % --- function called to look for grid files |
---|
[2] | 3593 | function [nbslice, flag_mask]=get_grid(filebase,handles) |
---|
[12] | 3594 | %------------------------------------------------------------------------ |
---|
[2] | 3595 | flag_mask=0;%default |
---|
| 3596 | nbslice=1; |
---|
| 3597 | [Path,Name]=fileparts(filebase); |
---|
| 3598 | currentdir=pwd; |
---|
| 3599 | cd(Path);%move in the dir of the root name filebase |
---|
| 3600 | maskfiles=dir([Name '_*grid_*.grid']);%look for mask files |
---|
| 3601 | cd(currentdir);%come back to the current working directory |
---|
| 3602 | if ~isempty(maskfiles) |
---|
| 3603 | flag_mask=1; |
---|
| 3604 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 3605 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 3606 | Namedouble=double(Name); |
---|
| 3607 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 3608 | ind_mask=findstr('grid',Name); |
---|
| 3609 | i=ind_mask-1; |
---|
[137] | 3610 | while val(i)==0 && i>0 |
---|
[112] | 3611 | i=i-1; |
---|
[2] | 3612 | end |
---|
[137] | 3613 | nbslice=str2double(Name(i+1:ind_mask-1)); |
---|
| 3614 | if ~isnan(nbslice) && Name(i)=='_' |
---|
[112] | 3615 | flag_mask=1; |
---|
[2] | 3616 | else |
---|
[112] | 3617 | msgbox_uvmat('ERROR',['bad grid file ' Name ext ' found in ' Path2]) |
---|
| 3618 | return |
---|
| 3619 | nbslice=1; |
---|
[2] | 3620 | end |
---|
[12] | 3621 | end |
---|
[2] | 3622 | |
---|
[12] | 3623 | %------------------------------------------------------------------------ |
---|
| 3624 | % --- transform numbers to letters |
---|
[122] | 3625 | function str=num2stra(num,nom_type) |
---|
[12] | 3626 | %------------------------------------------------------------------------ |
---|
[122] | 3627 | if isempty(nom_type) |
---|
| 3628 | str=''; |
---|
| 3629 | elseif strcmp(nom_type(end),'a') |
---|
[2] | 3630 | str=char(96+num); |
---|
[122] | 3631 | elseif strcmp(nom_type(end),'A') |
---|
| 3632 | str=char(96+num); |
---|
| 3633 | elseif isempty(nom_type(2:end))%a single index |
---|
[2] | 3634 | str=''; |
---|
| 3635 | else |
---|
| 3636 | str=num2str(num); |
---|
| 3637 | end |
---|
[12] | 3638 | |
---|
| 3639 | %------------------------------------------------------------------------ |
---|
[2] | 3640 | % --- Executes on button press in list_subdir_civ1. |
---|
| 3641 | function list_subdir_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 3642 | %------------------------------------------------------------------------ |
---|
[2] | 3643 | list_subdir_civ1=get(handles.list_subdir_civ1,'String'); |
---|
| 3644 | val=get(handles.list_subdir_civ1,'Value'); |
---|
| 3645 | if val>1 |
---|
| 3646 | subdir=list_subdir_civ1{val}; |
---|
| 3647 | set(handles.subdir_civ1,'String',subdir); |
---|
| 3648 | set(handles.list_subdir_civ1,'Value',1); |
---|
| 3649 | end |
---|
| 3650 | |
---|
[12] | 3651 | %------------------------------------------------------------------------ |
---|
[2] | 3652 | % --- Executes on button press in list_subdir_civ2. |
---|
| 3653 | function list_subdir_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 3654 | %------------------------------------------------------------------------ |
---|
[2] | 3655 | list_subdir_civ2=get(handles.list_subdir_civ2,'String'); |
---|
| 3656 | val=get(handles.list_subdir_civ2,'Value'); |
---|
| 3657 | if val>1 |
---|
| 3658 | subdir=list_subdir_civ2{val}; |
---|
| 3659 | set(handles.subdir_civ2,'String',subdir); |
---|
| 3660 | set(handles.list_subdir_civ2,'Value',1); |
---|
| 3661 | end |
---|
| 3662 | |
---|
[12] | 3663 | %------------------------------------------------------------------------ |
---|
[2] | 3664 | % --- Executes on button press in browse_gridciv1. |
---|
| 3665 | function browse_gridciv1_Callback(hObject, eventdata, handles) |
---|
[12] | 3666 | %------------------------------------------------------------------------ |
---|
[2] | 3667 | value=get(handles.browse_gridciv1,'Value'); |
---|
| 3668 | testgrid=0; |
---|
| 3669 | if value |
---|
[112] | 3670 | filebase=get(handles.RootName,'String'); |
---|
[39] | 3671 | [nbslice, flag_grid]=get_grid(filebase,handles); |
---|
[2] | 3672 | if isequal(flag_grid,1) |
---|
[112] | 3673 | filegrid=[num2str(nbslice) 'grid']; |
---|
| 3674 | testgrid=1; |
---|
| 3675 | else |
---|
[2] | 3676 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3677 | {'*.grid', ' (*.grid)'; |
---|
| 3678 | '*.grid', '.grid files '; ... |
---|
| 3679 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3680 | 'Pick a file',filebase); |
---|
[2] | 3681 | filegrid=fullfile(PathName,FileName); |
---|
| 3682 | if ~(isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file')) |
---|
| 3683 | testgrid=1; |
---|
| 3684 | end |
---|
[112] | 3685 | end |
---|
[2] | 3686 | end |
---|
| 3687 | if testgrid |
---|
[112] | 3688 | set(handles.browse_gridciv2,'Value',1) |
---|
| 3689 | set(handles.get_gridpatch1,'Value',1) |
---|
| 3690 | set(handles.get_gridpatch2,'Value',1) |
---|
| 3691 | set(handles.dx_civ1,'Visible','off'); |
---|
| 3692 | set(handles.dy_civ1,'Visible','off'); |
---|
| 3693 | set(handles.dx_civ2,'Visible','off'); |
---|
| 3694 | set(handles.dy_civ2,'Visible','off'); |
---|
| 3695 | set(handles.grid_civ1,'String',filegrid) |
---|
| 3696 | set(handles.grid_patch1,'String',filegrid) |
---|
| 3697 | set(handles.grid_civ2,'String',filegrid) |
---|
| 3698 | set(handles.grid_patch2,'String',filegrid) |
---|
| 3699 | else |
---|
| 3700 | set(handles.browse_gridciv1,'Value',0); |
---|
| 3701 | set(handles.browse_gridciv2,'Value',0); |
---|
| 3702 | set(handles.get_gridpatch1,'Value',0) |
---|
| 3703 | set(handles.get_gridpatch2,'Value',0) |
---|
| 3704 | set(handles.dx_civ1,'Visible','on'); |
---|
| 3705 | set(handles.dy_civ1,'Visible','on'); |
---|
| 3706 | set(handles.dx_civ2,'Visible','on'); |
---|
| 3707 | set(handles.dy_civ2,'Visible','on'); |
---|
| 3708 | set(handles.grid_civ1,'String','') |
---|
| 3709 | set(handles.grid_patch1,'String','') |
---|
| 3710 | set(handles.grid_civ2,'String','') |
---|
| 3711 | set(handles.grid_patch2,'String','') |
---|
[2] | 3712 | end |
---|
| 3713 | |
---|
[12] | 3714 | %------------------------------------------------------------------------ |
---|
[2] | 3715 | % --- Executes on button press in browse_gridciv1. |
---|
| 3716 | function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
[12] | 3717 | %------------------------------------------------------------------------ |
---|
[2] | 3718 | value=get(handles.browse_gridciv2,'Value'); |
---|
| 3719 | if value |
---|
[112] | 3720 | filebase=get(handles.RootName,'String'); |
---|
[39] | 3721 | [nbslice, flag_grid]=get_grid(filebase,handles); |
---|
[2] | 3722 | if isequal(flag_grid,1) |
---|
| 3723 | mask_displ=[num2str(nbslice) 'grid']; |
---|
| 3724 | set(handles.grid_civ2,'String',mask_displ) |
---|
| 3725 | set(handles.dx_civ2,'Visible','off'); |
---|
| 3726 | set(handles.dy_civ2,'Visible','off'); |
---|
[112] | 3727 | else |
---|
[2] | 3728 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3729 | {'*.grid', ' (*.grid)'; |
---|
| 3730 | '*.grid', '.grid files '; ... |
---|
| 3731 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3732 | 'Pick a file',filebase); |
---|
[2] | 3733 | filegrid=fullfile(PathName,FileName); |
---|
[229] | 3734 | if isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file') |
---|
[2] | 3735 | set(handles.browse_gridciv2,'Value',0); |
---|
| 3736 | set(handles.grid_civ2,'string',''); |
---|
| 3737 | set(handles.dx_civ2,'Visible','on'); |
---|
| 3738 | set(handles.dy_civ2,'Visible','on'); |
---|
| 3739 | set(handles.grid_civ2,'string',''); |
---|
| 3740 | else |
---|
| 3741 | set(handles.grid_civ2,'string',filegrid); |
---|
| 3742 | set(handles.dx_civ2,'Visible','off'); |
---|
| 3743 | set(handles.dy_civ2,'Visible','off'); |
---|
| 3744 | set(handles.grid_civ2,'string',filegrid); |
---|
| 3745 | end |
---|
| 3746 | end |
---|
| 3747 | else |
---|
| 3748 | set(handles.grid_civ2,'string',''); |
---|
[112] | 3749 | set(handles.dx_civ2,'Visible','on'); |
---|
| 3750 | set(handles.dy_civ2,'Visible','on'); |
---|
| 3751 | set(handles.grid_civ2,'string',''); |
---|
[2] | 3752 | end |
---|
| 3753 | |
---|
| 3754 | % % --- Executes on button press in browse_gridciv2. |
---|
| 3755 | % function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
[112] | 3756 | % |
---|
[71] | 3757 | % filebase=get(handles.RootName,'String'); |
---|
[2] | 3758 | % [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3759 | % {'*.grid', ' (*.grid)'; |
---|
| 3760 | % '*.grid', '.grid files '; ... |
---|
| 3761 | % '*.*', 'All Files (*.*)'}, ... |
---|
| 3762 | % 'Pick a file',filebase); |
---|
| 3763 | % filegrid=fullfile(PathName,FileName); |
---|
| 3764 | % set(handles.grid_civ2,'string',filegrid); |
---|
| 3765 | % set(handles.dx_civ2,'String',' '); |
---|
| 3766 | % set(handles.dy_civ2,'String',' '); |
---|
| 3767 | % % set(handles.grid_patch2,'string',filegrid); |
---|
| 3768 | |
---|
| 3769 | % --- Executes on button press in get_gridpatch1. |
---|
| 3770 | function get_gridpatch1_Callback(hObject, eventdata, handles) |
---|
| 3771 | % hObject handle to get_gridpatch1 (see GCBO) |
---|
| 3772 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 3773 | % handles structure with handles and user data (see GUIDATA) |
---|
| 3774 | |
---|
[71] | 3775 | filebase=get(handles.RootName,'String'); |
---|
[2] | 3776 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3777 | {'*.grid', ' (*.grid)'; |
---|
| 3778 | '*.grid', '.grid files '; ... |
---|
| 3779 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3780 | 'Pick a file',filebase); |
---|
[2] | 3781 | filegrid=fullfile(PathName,FileName); |
---|
| 3782 | set(handles.grid_patch1,'string',filegrid); |
---|
| 3783 | % set(handles.grid_patch2,'string',filegrid |
---|
| 3784 | |
---|
[12] | 3785 | %------------------------------------------------------------------------ |
---|
[2] | 3786 | % --- Executes on button press in get_gridpatch2. |
---|
| 3787 | function get_gridpatch2_Callback(hObject, eventdata, handles) |
---|
[12] | 3788 | %------------------------------------------------------------------------ |
---|
[2] | 3789 | |
---|
[12] | 3790 | %------------------------------------------------------------------------ |
---|
[2] | 3791 | function enable_civ1(handles,state) |
---|
[12] | 3792 | %------------------------------------------------------------------------ |
---|
[2] | 3793 | if isequal(state,'on') |
---|
| 3794 | set(handles.frame_civ1,'BackgroundColor',[1 1 0]) |
---|
| 3795 | set(handles.frame_para_civ1,'BackgroundColor',[1 1 0]) |
---|
| 3796 | set(handles.frame_grid_civ1,'BackgroundColor',[1 1 0]) |
---|
| 3797 | else |
---|
| 3798 | set(handles.frame_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3799 | set(handles.frame_para_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3800 | set(handles.frame_grid_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3801 | end |
---|
| 3802 | set(handles.ibx,'Visible',state) |
---|
| 3803 | set(handles.iby,'Visible',state) |
---|
| 3804 | set(handles.isx,'Visible',state) |
---|
| 3805 | set(handles.isy,'Visible',state) |
---|
| 3806 | set(handles.shiftx,'Visible',state) |
---|
| 3807 | set(handles.shifty,'Visible',state) |
---|
| 3808 | set(handles.rho,'Visible',state) |
---|
| 3809 | set(handles.dx_civ1,'Visible',state) |
---|
| 3810 | set(handles.dy_civ1,'Visible',state) |
---|
| 3811 | set(handles.calcul_search,'Visible',state) |
---|
| 3812 | set(handles.u_text,'Visible',state) |
---|
| 3813 | set(handles.v_text,'Visible',state) |
---|
| 3814 | set(handles.min,'Visible',state) |
---|
| 3815 | set(handles.max,'Visible',state) |
---|
| 3816 | set(handles.umin,'Visible',state) |
---|
| 3817 | set(handles.umax,'Visible',state) |
---|
| 3818 | set(handles.vmin,'Visible',state) |
---|
| 3819 | set(handles.vmax,'Visible',state) |
---|
| 3820 | set(handles.grid_civ1,'Visible',state) |
---|
| 3821 | set(handles.mask_civ1,'Visible',state) |
---|
| 3822 | set(handles.browse_gridciv1,'Visible',state) |
---|
| 3823 | set(handles.get_mask_civ1,'Visible',state) |
---|
| 3824 | set(handles.parameters,'Visible',state) |
---|
| 3825 | set(handles.grid,'Visible',state) |
---|
| 3826 | set(handles.dx_civ1,'Visible',state) |
---|
| 3827 | set(handles.dy_civ1,'Visible',state) |
---|
| 3828 | set(handles.ImaThreshold,'Visible',state) |
---|
| 3829 | if isequal(state,'off') |
---|
| 3830 | set(handles.MinIma,'Visible','off') |
---|
| 3831 | set(handles.MaxIma,'Visible','off') |
---|
| 3832 | set(handles.ImaThreshold,'Value',0) |
---|
| 3833 | end |
---|
| 3834 | set(handles.dx_civ1_title,'Visible',state) |
---|
| 3835 | set(handles.dy_civ1_title,'Visible',state) |
---|
| 3836 | set(handles.ImaThreshold_title,'Visible',state) |
---|
| 3837 | set(handles.ib_title,'Visible',state) |
---|
| 3838 | set(handles.is_title,'Visible',state) |
---|
| 3839 | set(handles.shift_title,'Visible',state) |
---|
| 3840 | set(handles.rho_title,'Visible',state) |
---|
[224] | 3841 | set(handles.TestCiv1,'Visible',state) |
---|
[257] | 3842 | %set(handles.CivMode,'Visible',state) |
---|
[2] | 3843 | |
---|
[12] | 3844 | %------------------------------------------------------------------------ |
---|
[2] | 3845 | function enable_fix1(handles,state) |
---|
[12] | 3846 | %------------------------------------------------------------------------ |
---|
[2] | 3847 | if isequal(state,0) |
---|
| 3848 | state='off'; |
---|
| 3849 | end |
---|
| 3850 | if isequal(state,1) |
---|
| 3851 | state='on'; |
---|
| 3852 | end |
---|
| 3853 | if isequal(state,'on') |
---|
| 3854 | set(handles.frame_fix1,'BackgroundColor',[1 1 0]) |
---|
| 3855 | else |
---|
| 3856 | set(handles.frame_fix1,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3857 | end |
---|
| 3858 | set(handles.REMOVE,'Visible',state) |
---|
| 3859 | set(handles.vec_Fmin2,'Visible',state) |
---|
| 3860 | set(handles.vec_F2,'Visible',state) |
---|
| 3861 | set(handles.vec_F3,'Visible',state) |
---|
| 3862 | set(handles.thresh_vecC,'Visible',state) |
---|
| 3863 | set(handles.thresh_vecC_title,'Visible',state) |
---|
| 3864 | set(handles.thresh_vel,'Visible',state) |
---|
| 3865 | set(handles.thresh_vel_text,'Visible',state) |
---|
| 3866 | set(handles.mask_fix1,'Visible',state) |
---|
| 3867 | set(handles.get_mask_fix1,'Visible',state) |
---|
| 3868 | set(handles.get_ref_fix1,'Visible',state) |
---|
| 3869 | set(handles.ref_fix1,'Visible',state) |
---|
| 3870 | set(handles.inf_sup1,'Visible',state) |
---|
| 3871 | set(handles.field_ref1,'Visible',state) |
---|
| 3872 | |
---|
[12] | 3873 | %------------------------------------------------------------------------ |
---|
[2] | 3874 | function enable_patch1(handles) |
---|
[12] | 3875 | %------------------------------------------------------------------------ |
---|
[2] | 3876 | set(handles.frame_patch1,'BackgroundColor',[1 1 0]) |
---|
| 3877 | set(handles.rho_patch1,'Visible','on') |
---|
| 3878 | set(handles.rho_text1,'Visible','on') |
---|
[257] | 3879 | if get(handles.CivMode,'Value')==2 |
---|
[224] | 3880 | set(handles.thresh_patch1,'Visible','on') |
---|
| 3881 | set(handles.thresh_text1,'Visible','on') |
---|
| 3882 | end |
---|
[2] | 3883 | set(handles.subdomain_patch1,'Visible','on') |
---|
| 3884 | set(handles.subdomain_text1,'Visible','on') |
---|
| 3885 | set(handles.nx_patch1,'Visible','on') |
---|
| 3886 | set(handles.ny_patch1,'Visible','on') |
---|
| 3887 | set(handles.nx_patch1_title,'Visible','on') |
---|
| 3888 | set(handles.ny_patch1_title,'Visible','on') |
---|
[112] | 3889 | % if ~isempty(patch_newBin) |
---|
[224] | 3890 | set(handles.test_interp,'Visible','off'); |
---|
[252] | 3891 | stereo_test=get(handles.compare,'Value'); |
---|
| 3892 | if stereo_test==3 |
---|
| 3893 | set(handles.test_stereo1,'Visible','on') |
---|
| 3894 | end |
---|
[100] | 3895 | % end |
---|
[252] | 3896 | %set(handles.get_gridpatch1,'Visible','on') |
---|
| 3897 | %set(handles.grid_patch1,'string','none'); |
---|
| 3898 | %set(handles.grid_patch1,'Visible','on') |
---|
[2] | 3899 | |
---|
[12] | 3900 | %------------------------------------------------------------------------ |
---|
[2] | 3901 | function desable_patch1(handles) |
---|
[12] | 3902 | %------------------------------------------------------------------------ |
---|
[2] | 3903 | set(handles.frame_patch1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3904 | set(handles.rho_patch1,'Visible','off') |
---|
| 3905 | set(handles.rho_text1,'Visible','off') |
---|
| 3906 | set(handles.thresh_patch1,'Visible','off') |
---|
| 3907 | set(handles.thresh_text1,'Visible','off') |
---|
| 3908 | set(handles.subdomain_patch1,'Visible','off') |
---|
| 3909 | set(handles.subdomain_text1,'Visible','off') |
---|
| 3910 | set(handles.nx_patch1,'Visible','off') |
---|
| 3911 | set(handles.ny_patch1,'Visible','off') |
---|
| 3912 | set(handles.nx_patch1_title,'Visible','off') |
---|
| 3913 | set(handles.ny_patch1_title,'Visible','off') |
---|
[252] | 3914 | set(handles.test_stereo1,'Visible','off') |
---|
[100] | 3915 | %set(handles.test_interp,'Visible','off') |
---|
[252] | 3916 | %set(handles.get_gridpatch1,'Visible','off') |
---|
| 3917 | %set(handles.grid_patch1,'Visible','off') |
---|
[2] | 3918 | |
---|
[12] | 3919 | %------------------------------------------------------------------------ |
---|
[2] | 3920 | function enable_civ2(handles,state) |
---|
[12] | 3921 | %------------------------------------------------------------------------ |
---|
[2] | 3922 | if isequal(state,0) |
---|
| 3923 | state='off'; |
---|
| 3924 | end |
---|
| 3925 | if isequal(state,1) |
---|
| 3926 | state='on'; |
---|
| 3927 | end |
---|
| 3928 | if isequal(state,'on') |
---|
| 3929 | set(handles.frame_civ2,'BackgroundColor',[1 1 0]) |
---|
| 3930 | set(handles.frame_para_civ2,'BackgroundColor',[1 1 0]) |
---|
| 3931 | set(handles.frame_grid_civ2,'BackgroundColor',[1 1 0]) |
---|
| 3932 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 3933 | else |
---|
| 3934 | set(handles.frame_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3935 | set(handles.frame_para_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3936 | set(handles.frame_grid_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3937 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3938 | end |
---|
| 3939 | set(handles.ibx_civ2,'Visible',state) |
---|
| 3940 | set(handles.iby_civ2,'Visible',state) |
---|
| 3941 | set(handles.decimal,'Visible',state) |
---|
| 3942 | set(handles.deformation,'Visible',state) |
---|
| 3943 | set(handles.rho_civ2,'Visible',state) |
---|
| 3944 | set(handles.dx_civ2,'Visible',state) |
---|
| 3945 | set(handles.dy_civ2,'Visible',state) |
---|
| 3946 | set(handles.browse_gridciv2,'Visible',state) |
---|
| 3947 | set(handles.get_mask_civ2,'Visible',state) |
---|
| 3948 | set(handles.parameters,'Visible',state) |
---|
| 3949 | set(handles.grid,'Visible',state) |
---|
| 3950 | set(handles.parameters_text,'Visible',state) |
---|
| 3951 | set(handles.grid_text,'Visible',state) |
---|
| 3952 | set(handles.grid_civ2,'Visible',state) |
---|
| 3953 | set(handles.mask_civ2,'Visible',state) |
---|
| 3954 | set(handles.dx_civ2_title,'Visible',state) |
---|
| 3955 | set(handles.dy_civ2_title,'Visible',state) |
---|
| 3956 | set(handles.ibx_civ2_text,'Visible',state) |
---|
| 3957 | set(handles.rho_civ2_title,'Visible',state) |
---|
| 3958 | set(handles.ImaThreshold2,'Visible',state) |
---|
| 3959 | set(handles.ImaThreshold_title2,'Visible',state) |
---|
| 3960 | if isequal(state,'off') |
---|
| 3961 | set(handles.MinIma2,'Visible','off') |
---|
| 3962 | set(handles.MaxIma2,'Visible','off') |
---|
| 3963 | set(handles.ImaThreshold2,'Value',0) |
---|
[112] | 3964 | if isequal(get(handles.FIX2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) |
---|
[2] | 3965 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 3966 | set(handles.subdir_civ2,'Visible','off') |
---|
| 3967 | set(handles.subdir_civ2_text,'Visible','off') |
---|
[71] | 3968 | set(handles.dt_unit_civ2,'Visible','off') |
---|
| 3969 | set(handles.ref_i_civ2,'Visible','off') |
---|
| 3970 | set(handles.i_ref_civ2_title,'Visible','off') |
---|
| 3971 | set(handles.j_ref_civ2_title,'Visible','off') |
---|
| 3972 | set(handles.ref_j_civ2,'Visible','off') |
---|
[2] | 3973 | end |
---|
| 3974 | else |
---|
| 3975 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 3976 | set(handles.subdir_civ2,'Visible','on') |
---|
| 3977 | set(handles.subdir_civ2_text,'Visible','on') |
---|
[71] | 3978 | set(handles.dt_unit_civ2,'Visible','on') |
---|
| 3979 | set(handles.ref_i_civ2,'Visible','on') |
---|
| 3980 | set(handles.i_ref_civ2_title,'Visible','on') |
---|
| 3981 | set(handles.j_ref_civ2_title,'Visible','on') |
---|
| 3982 | set(handles.ref_j_civ2,'Visible','on') |
---|
[2] | 3983 | end |
---|
[71] | 3984 | set(handles.rho_civ2_title,'Visible',state) |
---|
[2] | 3985 | |
---|
[12] | 3986 | %------------------------------------------------------------------------ |
---|
[2] | 3987 | function enable_fix2(handles) |
---|
[12] | 3988 | %------------------------------------------------------------------------ |
---|
[2] | 3989 | set(handles.frame_fix2,'BackgroundColor',[1 1 0]) |
---|
| 3990 | set(handles.REMOVE2,'Visible','on') |
---|
| 3991 | set(handles.vec_Fmin2_2,'Visible','on') |
---|
| 3992 | set(handles.vec_F4,'Visible','on') |
---|
| 3993 | set(handles.vec_F3_2,'Visible','on') |
---|
| 3994 | set(handles.thresh_vec2C,'Visible','on') |
---|
| 3995 | set(handles.thresh_vec2C_text,'Visible','on') |
---|
| 3996 | set(handles.thresh_vel2,'Visible','on') |
---|
| 3997 | set(handles.thresh_vel2_text,'Visible','on') |
---|
| 3998 | set(handles.mask_fix2,'Visible','on') |
---|
| 3999 | set(handles.get_mask_fix2,'Visible','on') |
---|
| 4000 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 4001 | set(handles.subdir_civ2,'Visible','on') |
---|
| 4002 | set(handles.subdir_civ2_text,'Visible','on') |
---|
| 4003 | set(handles.get_ref_fix2,'Visible','on') |
---|
| 4004 | set(handles.ref_fix2,'Visible','on') |
---|
| 4005 | set(handles.inf_sup2,'Visible','on') |
---|
| 4006 | set(handles.field_ref2,'Visible','on') |
---|
| 4007 | |
---|
[12] | 4008 | %------------------------------------------------------------------------ |
---|
[2] | 4009 | function desable_fix2(handles) |
---|
[12] | 4010 | %------------------------------------------------------------------------ |
---|
[2] | 4011 | set(handles.frame_fix2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4012 | set(handles.REMOVE2,'Visible','off') |
---|
| 4013 | set(handles.vec_Fmin2_2,'Visible','off') |
---|
| 4014 | set(handles.vec_F4,'Visible','off') |
---|
| 4015 | set(handles.vec_F3_2,'Visible','off') |
---|
| 4016 | set(handles.thresh_vec2C,'Visible','off') |
---|
| 4017 | set(handles.thresh_vec2C_text,'Visible','off') |
---|
| 4018 | set(handles.thresh_vel2,'Visible','off') |
---|
| 4019 | set(handles.thresh_vel2_text,'Visible','off') |
---|
| 4020 | set(handles.mask_fix2,'Visible','off') |
---|
| 4021 | set(handles.get_mask_fix2,'Visible','off') |
---|
| 4022 | set(handles.get_ref_fix2,'Visible','off') |
---|
| 4023 | set(handles.ref_fix2,'Visible','off') |
---|
| 4024 | set(handles.inf_sup2,'Visible','off') |
---|
| 4025 | set(handles.field_ref2,'Visible','off') |
---|
[112] | 4026 | if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) |
---|
[2] | 4027 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 4028 | set(handles.subdir_civ2,'Visible','off') |
---|
| 4029 | set(handles.subdir_civ2_text,'Visible','off') |
---|
| 4030 | end |
---|
| 4031 | |
---|
[12] | 4032 | %------------------------------------------------------------------------ |
---|
[2] | 4033 | function enable_patch2(handles) |
---|
[12] | 4034 | %------------------------------------------------------------------------ |
---|
[2] | 4035 | set(handles.frame_patch2,'BackgroundColor',[1 1 0]) |
---|
[119] | 4036 | set(handles.rho_patch2,'Visible','on') |
---|
[2] | 4037 | set(handles.rho_text2,'Visible','on') |
---|
| 4038 | set(handles.thresh_patch2,'Visible','on') |
---|
| 4039 | set(handles.thresh_text2,'Visible','on') |
---|
| 4040 | set(handles.subdomain_patch2,'Visible','on') |
---|
| 4041 | set(handles.subdomain_text2,'Visible','on') |
---|
| 4042 | set(handles.nx_patch2,'Visible','on') |
---|
| 4043 | set(handles.ny_patch2,'Visible','on') |
---|
| 4044 | set(handles.nx_patch2_title,'Visible','on') |
---|
| 4045 | set(handles.ny_patch2_title,'Visible','on') |
---|
[252] | 4046 | % set(handles.get_gridpatch2,'Visible','on') |
---|
| 4047 | % set(handles.grid_patch2,'Visible','on') |
---|
[2] | 4048 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 4049 | set(handles.subdir_civ2,'Visible','on') |
---|
| 4050 | set(handles.subdir_civ2_text,'Visible','on') |
---|
[252] | 4051 | stereo_test=get(handles.compare,'Value'); |
---|
| 4052 | if stereo_test==3 |
---|
| 4053 | set(handles.test_stereo2,'Visible','on') |
---|
| 4054 | end |
---|
[2] | 4055 | |
---|
[12] | 4056 | %------------------------------------------------------------------------ |
---|
[2] | 4057 | function desable_patch2(handles) |
---|
[12] | 4058 | %------------------------------------------------------------------------ |
---|
[2] | 4059 | set(handles.frame_patch2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4060 | set(handles.rho_patch2,'Visible','off') |
---|
| 4061 | set(handles.rho_text2,'Visible','off') |
---|
| 4062 | set(handles.thresh_patch2,'Visible','off') |
---|
| 4063 | set(handles.thresh_text2,'Visible','off') |
---|
| 4064 | set(handles.subdomain_patch2,'Visible','off') |
---|
| 4065 | set(handles.subdomain_text2,'Visible','off') |
---|
| 4066 | set(handles.nx_patch2,'Visible','off') |
---|
| 4067 | set(handles.ny_patch2,'Visible','off') |
---|
| 4068 | set(handles.nx_patch2_title,'Visible','off') |
---|
| 4069 | set(handles.ny_patch2_title,'Visible','off') |
---|
[252] | 4070 | % set(handles.get_gridpatch2,'Visible','off') |
---|
| 4071 | % set(handles.grid_patch2,'Visible','off') |
---|
[112] | 4072 | if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.FIX2,'Value'),0) |
---|
[2] | 4073 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 4074 | set(handles.subdir_civ2,'Visible','off') |
---|
| 4075 | set(handles.subdir_civ2_text,'Visible','off') |
---|
| 4076 | end |
---|
[252] | 4077 | set(handles.test_stereo2,'Visible','off') |
---|
[12] | 4078 | %------------------------------------------------------------------------ |
---|
[2] | 4079 | function enable_pair1(handles,state) |
---|
[12] | 4080 | %------------------------------------------------------------------------ |
---|
[2] | 4081 | set(handles.subdir_civ1,'Visible',state) |
---|
| 4082 | set(handles.list_subdir_civ1,'Visible',state) |
---|
| 4083 | set(handles.SUBDIR_CIV1_txt,'Visible',state) |
---|
| 4084 | set(handles.frame_subdirciv1,'Visible',state) |
---|
| 4085 | set(handles.list_pair_civ1,'Visible',state) |
---|
| 4086 | set(handles.PAIR_txt,'Visible',state) |
---|
[71] | 4087 | %set(handles.dt_unit,'Visible',state) |
---|
[2] | 4088 | set(handles.PAIR_frame,'Visible',state) |
---|
| 4089 | |
---|
[12] | 4090 | %------------------------------------------------------------------------ |
---|
| 4091 | % --- Read the parameters for civ1 on the interface |
---|
[2] | 4092 | function par=read_param_civ1(handles,file_ima) |
---|
[12] | 4093 | %------------------------------------------------------------------------ |
---|
[127] | 4094 | ibx_val=str2double(get(handles.ibx,'String')); |
---|
[2] | 4095 | par.ibx=num2str(ibx_val); |
---|
[127] | 4096 | iby_val=str2double(get(handles.iby,'String')); |
---|
[2] | 4097 | par.iby=num2str(iby_val); |
---|
| 4098 | isx=get(handles.isx,'String'); |
---|
[127] | 4099 | if isnan(str2double(isx)), isx='41'; set(handles.isx,'String','41'), end; %default |
---|
| 4100 | if str2double(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.isx,'String',num2str(ibx_val+8)); end |
---|
[2] | 4101 | isy=get(handles.isy,'String'); |
---|
[127] | 4102 | if isnan(str2double(isy)), isy='41'; set(handles.isy,'String','41'), end;%default |
---|
| 4103 | if str2double(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.isy,'String',num2str(iby_val+8)); end |
---|
[2] | 4104 | par.isx=get(handles.isx,'String'); |
---|
| 4105 | par.isy=get(handles.isy,'String'); |
---|
| 4106 | par.shiftx=get(handles.shiftx,'String'); |
---|
| 4107 | par.shifty=get(handles.shifty,'String'); |
---|
[127] | 4108 | if isnan(str2double(par.isx)) |
---|
[112] | 4109 | par.isx='41';%default |
---|
| 4110 | set(handles.isx,'String','41'); |
---|
[2] | 4111 | end |
---|
[127] | 4112 | if isnan(str2double(par.isy)) |
---|
[112] | 4113 | par.isy='41'; %default |
---|
| 4114 | set(handles.isy,'String','41'); |
---|
[12] | 4115 | end |
---|
[127] | 4116 | if isnan(str2double(par.shiftx)) |
---|
[112] | 4117 | par.shiftx='0';%default |
---|
| 4118 | set(handles.shiftx,'String','0'); |
---|
| 4119 | end |
---|
[127] | 4120 | if isnan(str2double(par.shifty)) |
---|
[112] | 4121 | par.shifty='0'; %default |
---|
| 4122 | set(handles.shifty,'String','0'); |
---|
[12] | 4123 | end |
---|
[112] | 4124 | par.rho=get(handles.rho,'String'); |
---|
[238] | 4125 | if isequal(get(handles.rho,'Style'),'popupmenu') |
---|
| 4126 | index=get(handles.rho,'Value'); |
---|
| 4127 | par.rho=par.rho{index}; |
---|
| 4128 | end |
---|
[112] | 4129 | par.dx=get(handles.dx_civ1,'String'); |
---|
| 4130 | par.dy=get(handles.dy_civ1,'String'); |
---|
[127] | 4131 | if isnan(str2double(par.dx)) |
---|
[112] | 4132 | if isempty(get(handles.grid_civ1,'String')); |
---|
| 4133 | par.dx='0'; %just read by civ program, not used |
---|
| 4134 | else |
---|
[12] | 4135 | par.dx='20';%default |
---|
| 4136 | set(handles.dx_civ1,'String','20'); |
---|
[112] | 4137 | end |
---|
| 4138 | end |
---|
[127] | 4139 | if isnan(str2double(par.dy)) |
---|
[112] | 4140 | if isempty(get(handles.grid_civ1,'String')); |
---|
| 4141 | par.dy='0';%just read by civ program, not used |
---|
| 4142 | else |
---|
[12] | 4143 | par.dy='20';%default |
---|
| 4144 | set(handles.dy_civ1_title,'String','20'); |
---|
[112] | 4145 | end |
---|
| 4146 | end |
---|
| 4147 | par.pxcmx='1'; %velocities are expressed in pixel dispalcement |
---|
| 4148 | par.pxcmy='1'; |
---|
[150] | 4149 | if exist('file_ima','var') |
---|
[112] | 4150 | A=imread(file_ima);%read the first image to get the size |
---|
| 4151 | sizim=size(A); |
---|
| 4152 | par.npx=num2str(sizim(2)); |
---|
| 4153 | par.npy=num2str(sizim(1)); |
---|
[150] | 4154 | end |
---|
[127] | 4155 | %time=get(handles.RootName,'UserData'); %get the set of times |
---|
[112] | 4156 | par.gridname=get(handles.grid_civ1,'String'); |
---|
| 4157 | par.gridflag='y'; |
---|
[127] | 4158 | if strcmp(par.gridname,'')|| isempty(par.gridname) |
---|
[112] | 4159 | par.gridname='nogrid'; |
---|
| 4160 | par.gridflag='n'; |
---|
| 4161 | end |
---|
[12] | 4162 | |
---|
| 4163 | %------------------------------------------------------------------------ |
---|
[2] | 4164 | function par=read_param_civ2(handles,file_ima) |
---|
[12] | 4165 | %------------------------------------------------------------------------ |
---|
| 4166 | par.ibx=get(handles.ibx_civ2,'String'); |
---|
| 4167 | par.iby=get(handles.iby_civ2,'String'); |
---|
| 4168 | par.rho=get(handles.rho_civ2,'String'); |
---|
| 4169 | par.decimal=int2str(get(handles.decimal,'Value')); |
---|
| 4170 | par.deformation=int2str(get(handles.deformation,'Value')); |
---|
| 4171 | par.dx=get(handles.dx_civ2,'String'); |
---|
| 4172 | par.dy=get(handles.dy_civ2,'String'); |
---|
[127] | 4173 | if isnan(str2double(par.dx)) |
---|
[112] | 4174 | if isempty(get(handles.grid_civ2,'String')); |
---|
| 4175 | par.dx='0'; %just read by civ program, not used |
---|
| 4176 | else |
---|
[12] | 4177 | par.dx='20';%default |
---|
| 4178 | set(handles.dx_civ2,'String','20'); |
---|
[112] | 4179 | end |
---|
| 4180 | end |
---|
[127] | 4181 | if isnan(str2double(par.dy)) |
---|
[112] | 4182 | if isempty(get(handles.grid_civ2,'String')); |
---|
| 4183 | par.dy='0';%just read by civ program, not used |
---|
| 4184 | else |
---|
[12] | 4185 | par.dy='20';%default |
---|
| 4186 | set(handles.dy_civ2,'String','20'); |
---|
[112] | 4187 | end |
---|
| 4188 | end |
---|
| 4189 | par.pxcmx='1'; |
---|
| 4190 | par.pxcmy='1'; |
---|
[12] | 4191 | A=imread(file_ima);%read the first image to get the size |
---|
| 4192 | sizim=size(A); |
---|
| 4193 | par.npx=num2str(sizim(2)); |
---|
| 4194 | par.npy=num2str(sizim(1)); |
---|
[127] | 4195 | %time=get(handles.RootName,'UserData'); %get the set of times |
---|
[12] | 4196 | par.gridname=get(handles.grid_civ2,'String'); |
---|
| 4197 | par.gridflag='y'; |
---|
[127] | 4198 | if strcmp(par.gridname,'')|| isempty(par.gridname) |
---|
[12] | 4199 | par.gridname='nogrid'; |
---|
| 4200 | par.gridflag='n'; |
---|
| 4201 | end |
---|
[2] | 4202 | |
---|
[12] | 4203 | %------------------------------------------------------------------------ |
---|
| 4204 | % --- CIV1 CIV1 CIV1 CIV1 |
---|
[94] | 4205 | function cmd_CIV1=CIV1_CMD(filename,namelog,par,handles,sparam) |
---|
[12] | 4206 | %------------------------------------------------------------------------ |
---|
[2] | 4207 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 4208 | |
---|
| 4209 | %changes : filename_cmx -> filename ( no extension ) |
---|
[174] | 4210 | % input namelog not used |
---|
[112] | 4211 | if isequal(par.Dt,'0') |
---|
| 4212 | par.Dt='1' ;%case of 'displacement' mode |
---|
| 4213 | end |
---|
[90] | 4214 | par.filename_ima_a=regexprep(par.filename_ima_a,'.png',''); |
---|
[94] | 4215 | par.filename_ima_b=regexprep(par.filename_ima_b,'.png',''); |
---|
[230] | 4216 | fid=fopen([filename '.civ1.cmx'],'w'); |
---|
[12] | 4217 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
[112] | 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' ]); |
---|
| 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.isx ' ' par.isy '\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 ' par.shiftx ' ' par.shifty '\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 0' '\n' ]); |
---|
| 4240 | fprintf(fid, ['Deformation 0' '\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 null null' '\n' ]); |
---|
[12] | 4247 | fclose(fid); |
---|
[112] | 4248 | |
---|
[163] | 4249 | % cmd_CIV1=[sparam.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file |
---|
| 4250 | % cmd_CIV1=regexprep(cmd_CIV1,'\\','\\\\'); |
---|
| 4251 | % namelog=regexprep(namelog,'\\','\\\\'); |
---|
[12] | 4252 | if(isunix) |
---|
[230] | 4253 | cmd_CIV1=['cp -f ' filename '.civ1.cmx ' filename '.cmx\n']; |
---|
| 4254 | cmd_CIV1=[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 |
---|
[219] | 4255 | cmd_CIV1=[cmd_CIV1 '\n' 'mv ' filename '.log' ' ' filename '.civ1.log' '\n' 'chmod g+w ' filename '.civ1.log' '\n' 'chmod g+w ' filename '.nc'];%rename .log as .civ1.log and set the netcdf result file for group user writting |
---|
[230] | 4256 | % cmd_CIV1=[cmd_CIV1 '\n' 'mv ' filename '.cmx' ' ' filename '.civ1.cmx' '\n'];%rename .cmx as .civ1.cmx |
---|
[163] | 4257 | else %Windows system |
---|
[269] | 4258 | % flname=regexprep(flname,'\\','\\\\'); |
---|
[230] | 4259 | % cmd=[cmd 'copy /Y "' flname '.civ1.cmx" "' flname '.cmx"\n']; |
---|
[269] | 4260 | % filename=regexprep(filename,'\\','\\\\'); |
---|
[230] | 4261 | cmd_CIV1=['copy /Y "' filename '.civ1.cmx" "' filename '.cmx"\n'];% copy the .civ1.cmx parameter file to .cmx |
---|
[163] | 4262 | cmd_CIV1=['"' sparam.Civ1Bin '" -f "' filename '.cmx" >"' filename '.log"' ]; % redirect standard output to the log file |
---|
| 4263 | cmd_CIV1=regexprep(cmd_CIV1,'\\','\\\\'); |
---|
| 4264 | namelog=regexprep(namelog,'\\','\\\\'); |
---|
[230] | 4265 | cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y "' filename '.log' '" "' filename '.civ1.log"']; %preserve the log file as .civ1.log |
---|
| 4266 | % cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y "' filename '.cmx' '" "' filename '.civ1.cmx"']; |
---|
[12] | 4267 | end |
---|
[2] | 4268 | |
---|
[12] | 4269 | %------------------------------------------------------------------------ |
---|
| 4270 | % --- CIV1 Unified |
---|
[94] | 4271 | function xml_civ1_parameters=CIV1_CMD_Unified(filename,namelog,par) |
---|
[12] | 4272 | %------------------------------------------------------------------------ |
---|
[2] | 4273 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
[73] | 4274 | %global CivBin%name of the executable for civ1 calculation |
---|
[2] | 4275 | |
---|
[112] | 4276 | civ1.image1=par.filename_ima_a; |
---|
| 4277 | civ1.image2=par.filename_ima_b; |
---|
| 4278 | civ1.imageSize_X=par.npx; |
---|
| 4279 | civ1.imageSize_Y=par.npy; |
---|
| 4280 | civ1.outputFileName=[filename '.nc']; |
---|
| 4281 | civ1.correlationBoxesSize_X=par.ibx; |
---|
| 4282 | civ1.correlationBoxesSize_Y=par.iby; |
---|
| 4283 | civ1.searchBoxesSize_X=par.isx; |
---|
| 4284 | civ1.searchBoxesSize_Y=par.isy; |
---|
| 4285 | civ1.globalShift_X=par.shiftx; |
---|
| 4286 | civ1.globalShift_Y=par.shifty; |
---|
| 4287 | civ1.ro=par.rho; |
---|
| 4288 | civ1.hart='y'; |
---|
| 4289 | if isequal(par.gridflag,'y') |
---|
| 4290 | civ1.grid=par.gridname; |
---|
| 4291 | else |
---|
| 4292 | civ1.grid='n'; |
---|
| 4293 | civ1.gridSpacing_X=par.dx; |
---|
| 4294 | civ1.gridSpacing_Y=par.dy; |
---|
| 4295 | end |
---|
| 4296 | if isequal(par.maskflag,'y') |
---|
| 4297 | civ1.mask=par.maskname; |
---|
| 4298 | end |
---|
[229] | 4299 | civ1.dt=par.Dt; |
---|
[112] | 4300 | civ1.unit='pixel'; |
---|
| 4301 | civ1.absolut_time_T0=par.T0; |
---|
| 4302 | civ1.pixcmx=par.pxcmx; |
---|
| 4303 | civ1.pixcmy=par.pxcmy; |
---|
| 4304 | civ1.convectFlow='n'; |
---|
[12] | 4305 | |
---|
[112] | 4306 | xml_civ1_parameters=civ1; |
---|
| 4307 | |
---|
[12] | 4308 | %------------------------------------------------------------------------ |
---|
| 4309 | % --- CIV2 Unified |
---|
[94] | 4310 | function civ2=CIV2_CMD_Unified(filename,namelog,par) |
---|
[12] | 4311 | %------------------------------------------------------------------------ |
---|
[2] | 4312 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
[73] | 4313 | %global CivBin%name of the executable for civ1 calculation |
---|
[2] | 4314 | |
---|
| 4315 | civ2.image1=par.filename_ima_a; |
---|
| 4316 | civ2.image2=par.filename_ima_b; |
---|
[112] | 4317 | civ2.imageSize_X=par.npx; |
---|
[2] | 4318 | civ2.imageSize_Y=par.npy; |
---|
| 4319 | civ2.inputFileName=[par.filename_nc1 '.nc']; |
---|
| 4320 | civ2.outputFileName=[filename '.nc']; |
---|
| 4321 | civ2.correlationBoxesSize_X=par.ibx; |
---|
| 4322 | civ2.correlationBoxesSize_Y=par.iby; |
---|
| 4323 | civ2.ro=par.rho; |
---|
| 4324 | %civ2.decimalShift=par.decimal; |
---|
| 4325 | %civ2.deformation=par.deformation; |
---|
| 4326 | if isequal(par.decimal,'1') |
---|
| 4327 | civ2.decimalShift='y'; |
---|
| 4328 | else |
---|
| 4329 | civ2.decimalShift='n'; |
---|
| 4330 | end |
---|
| 4331 | if isequal(par.deformation,'1') |
---|
| 4332 | civ2.deformation='y'; |
---|
| 4333 | else |
---|
| 4334 | civ2.deformation='n'; |
---|
| 4335 | end |
---|
| 4336 | if isequal(par.gridflag,'y') |
---|
| 4337 | civ2.grid=par.gridname; |
---|
| 4338 | else |
---|
| 4339 | civ2.grid='n'; |
---|
| 4340 | civ2.gridSpacing_X=par.dx; |
---|
| 4341 | civ2.gridSpacing_Y=par.dy; |
---|
| 4342 | end |
---|
| 4343 | civ2.gridSpacing_X='10'; |
---|
| 4344 | civ2.gridSpacing_Y='10';%NOTE: faut mettre gridSpacing pourque ca tourne, meme si c'est la grille qui est utilisee |
---|
| 4345 | if isequal(par.maskflag,'y') |
---|
| 4346 | civ2.mask=par.maskname; |
---|
| 4347 | else |
---|
| 4348 | civ2.mask='n'; |
---|
| 4349 | end |
---|
| 4350 | civ2.dt=par.Dt; |
---|
| 4351 | civ2.unit='pixel'; |
---|
| 4352 | civ2.absolut_time_T0=par.T0; |
---|
| 4353 | civ2.pixcmx=par.pxcmx; |
---|
| 4354 | civ2.pixcmy=par.pxcmy; |
---|
| 4355 | civ2.convectFlow='n'; |
---|
| 4356 | civ2.pixcmx=par.pxcmx; |
---|
| 4357 | civ2.pixcmy=par.pxcmy; |
---|
| 4358 | civ2.convectFlow='n'; |
---|
| 4359 | |
---|
[12] | 4360 | %------------------------------------------------------------------------ |
---|
| 4361 | % --- CIV2 CIV2 CIV2 CIV2 |
---|
[134] | 4362 | function cmd_CIV2=CIV2_CMD(filename,namelog,par,sparam) |
---|
[12] | 4363 | %------------------------------------------------------------------------ |
---|
[2] | 4364 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
[67] | 4365 | % global civ2Bin sge%name of the executable for civ1 calculation |
---|
[112] | 4366 | if isequal(par.Dt,'0') |
---|
| 4367 | par.Dt='1' ;%case of 'displacement' mode |
---|
| 4368 | end |
---|
[94] | 4369 | par.filename_ima_a=regexprep(par.filename_ima_a,'.png',''); |
---|
| 4370 | par.filename_ima_b=regexprep(par.filename_ima_b,'.png','');% bug : .png appears two times ? |
---|
[174] | 4371 | [fid,errormsg]=fopen([filename '.civ2.cmx'],'w'); |
---|
| 4372 | if isequal(fid,-1) |
---|
| 4373 | msgbox_uvmat('ERROR',errormsg) |
---|
| 4374 | cmd_CIV2=''; |
---|
| 4375 | return |
---|
| 4376 | end |
---|
[94] | 4377 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
| 4378 | fprintf(fid, ['FirstImage ' regexprep(par.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4379 | fprintf(fid, ['LastImage ' regexprep(par.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4380 | fprintf(fid, ['XX' '\n' ]); |
---|
| 4381 | fprintf(fid, ['Mask ' par.maskflag '\n' ]); |
---|
| 4382 | fprintf(fid, ['MaskName ' regexprep(par.maskname,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4383 | fprintf(fid, ['ImageSize ' par.npx ' ' par.npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 4384 | fprintf(fid, ['CorrelationBoxesSize ' par.ibx ' ' par.iby '\n' ]); |
---|
| 4385 | fprintf(fid, ['SearchBoxeSize ' par.ibx ' ' par.iby '\n']); |
---|
| 4386 | fprintf(fid, ['RO ' par.rho '\n']); |
---|
| 4387 | fprintf(fid, ['GridSpacing ' par.dx ' ' par.dy '\n']); |
---|
| 4388 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4389 | fprintf(fid, ['Dt_TO ' par.Dt ' ' par.T0 '\n' ]); |
---|
| 4390 | fprintf(fid, ['PixCmXY ' par.pxcmx ' ' par.pxcmy '\n' ]); |
---|
| 4391 | fprintf(fid, ['XX 1' '\n' ]); |
---|
[122] | 4392 | fprintf(fid, 'ShiftXY 0 0\n'); |
---|
[94] | 4393 | fprintf(fid, ['Grid ' par.gridflag '\n' ]); |
---|
| 4394 | fprintf(fid, ['GridName ' regexprep(par.gridname,'\\','\\\\') '\n']); |
---|
| 4395 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 4396 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4397 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4398 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
| 4399 | fprintf(fid, ['DecimalShift ' par.decimal '\n']); |
---|
| 4400 | fprintf(fid, ['Deformation ' par.deformation '\n']); |
---|
| 4401 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 4402 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 4403 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 4404 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
| 4405 | fprintf(fid, ['ImageToUse ' par.term_a ' ' par.term_b '\n' ]); % VERIFIER ? |
---|
| 4406 | fprintf(fid, ['ImageUsedBefore ' regexprep(par.filename_nc1,'\\','\\\\') '\n']); |
---|
| 4407 | fclose(fid); |
---|
| 4408 | |
---|
[134] | 4409 | if(isunix) |
---|
[230] | 4410 | cmd_CIV2=['cp -f ' filename '.civ2.cmx ' filename '.cmx\n']; |
---|
| 4411 | cmd_CIV2=[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 |
---|
| 4412 | cmd_CIV2=[cmd_CIV2 '\n' 'mv ' filename '.log' ' ' filename '.civ2.log' '\n' 'chmod g+w ' filename '.nc'];%preserve the log file as .civ2.log |
---|
| 4413 | % 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 |
---|
| 4414 | |
---|
[163] | 4415 | else |
---|
[174] | 4416 | filename=regexprep(filename,'\\','\\\\'); |
---|
[230] | 4417 | cmd_CIV2=['copy /Y "' filename '.civ2.cmx" "' filename '.cmx"\n']; |
---|
| 4418 | cmd_CIV2=[cmd_CIV2 '"' sparam.Civ2Bin '" -f "' filename '.cmx" >"' filename '.log"' ]; % redirect standard output to the log file |
---|
[163] | 4419 | cmd_CIV2=regexprep(cmd_CIV2,'\\','\\\\'); |
---|
[174] | 4420 | cmd_CIV2=[cmd_CIV2 '\n' 'copy /Y "' filename '.log' '" "' filename '.civ2.log"']; |
---|
[230] | 4421 | % cmd_CIV2=[cmd_CIV2 '\n' 'copy /Y "' filename '.cmx' '" "' filename '.civ2.cmx"']; |
---|
[134] | 4422 | end |
---|
| 4423 | |
---|
[238] | 4424 | % %------------------------------------------------------------------------ |
---|
| 4425 | % % --- civ using pivlab |
---|
| 4426 | % function Data=civ_uvmat(par_civ1) |
---|
| 4427 | % %------------------------------------------------------------------------ |
---|
| 4428 | % image1=imread(par_civ1.filename_ima_a); |
---|
| 4429 | % image2=imread(par_civ1.filename_ima_b); |
---|
| 4430 | % stepx=str2num(par_civ1.dx); |
---|
| 4431 | % stepy=str2num(par_civ1.dy); |
---|
| 4432 | % ibx2=ceil(str2num(par_civ1.ibx)/2); |
---|
| 4433 | % iby2=ceil(str2num(par_civ1.iby)/2); |
---|
| 4434 | % isx2=ceil(str2num(par_civ1.isx)/2); |
---|
| 4435 | % isy2=ceil(str2num(par_civ1.isy)/2); |
---|
| 4436 | % shiftx=str2num(par_civ1.shiftx); |
---|
| 4437 | % shifty=str2num(par_civ1.shifty); |
---|
| 4438 | % miniy=max(1+isy2-shifty,1+iby2); |
---|
| 4439 | % minix=max(1+isx2-shiftx,1+ibx2); |
---|
| 4440 | % maxiy=min(size(image1,1)-isy2-shifty,size(image1,1)-iby2); |
---|
| 4441 | % maxix=min(size(image1,2)-isx2-shiftx,size(image1,2)-ibx2); |
---|
| 4442 | % [GridX,GridY]=meshgrid(minix:stepx:maxix,miniy:stepy:maxiy); |
---|
| 4443 | % PointCoord(:,1)=reshape(GridX,[],1); |
---|
| 4444 | % PointCoord(:,2)=reshape(GridY,[],1); |
---|
| 4445 | % % caluclate velocity data (y and v in indices, reverse to y component) |
---|
| 4446 | % [xtable ytable utable vtable ctable F] = pivlab (image1,image2,ibx2,iby2,isx2,isy2,shiftx,shifty,PointCoord, 1, []); |
---|
| 4447 | % Data.ListGlobalAttribute=[{'Conventions','Program','CivStage'} {'Time','Dt'}]; |
---|
| 4448 | % Data.Conventions='uvmat/civdata'; |
---|
| 4449 | % Data.Program='civ_uvmat'; |
---|
| 4450 | % Data.CivStage=1; |
---|
| 4451 | % % list_param=fieldnames(Param.Civ1); |
---|
| 4452 | % % for ilist=1:length(list_param) |
---|
| 4453 | % % eval(['Data.Civ1_' list_param{ilist} '=Param.Civ1.' list_param{ilist} ';']) |
---|
| 4454 | % % end |
---|
| 4455 | % Data.Time=str2double(par_civ1.T0); |
---|
| 4456 | % Data.Dt=str2double(par_civ1.Dt); |
---|
| 4457 | % Data.ListVarName={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_F'};% cell array containing the names of the fields to record |
---|
| 4458 | % Data.VarDimName={'nbvec','nbvec','nbvec','nbvec','nbvec','nbvec'}; |
---|
| 4459 | % Data.VarAttribute{1}.Role='coord_x'; |
---|
| 4460 | % Data.VarAttribute{2}.Role='coord_y'; |
---|
| 4461 | % Data.VarAttribute{3}.Role='vector_x'; |
---|
| 4462 | % Data.VarAttribute{4}.Role='vector_y'; |
---|
| 4463 | % Data.VarAttribute{5}.Role='warnflag'; |
---|
| 4464 | % Data.Civ1_X=reshape(xtable,[],1); |
---|
| 4465 | % Data.Civ1_Y=reshape(size(image1,1)-ytable+1,[],1); |
---|
| 4466 | % Data.Civ1_U=reshape(utable,[],1); |
---|
| 4467 | % Data.Civ1_V=reshape(-vtable,[],1); |
---|
| 4468 | % Data.Civ1_C=reshape(ctable,[],1); |
---|
| 4469 | % Data.Civ1_F=reshape(F,[],1); |
---|
[134] | 4470 | |
---|
[12] | 4471 | %------------------------------------------------------------------------ |
---|
[2] | 4472 | % --- Executes on button press in HELP. |
---|
| 4473 | function HELP_Callback(hObject, eventdata, handles) |
---|
[12] | 4474 | %------------------------------------------------------------------------ |
---|
[2] | 4475 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
| 4476 | pathelp=fileparts(path_to_uvmat); |
---|
[85] | 4477 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html'); |
---|
[36] | 4478 | if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package') |
---|
[2] | 4479 | else |
---|
[36] | 4480 | addpath (fullfile(pathelp,'uvmat_doc')) |
---|
[112] | 4481 | web([helpfile '#civ']) |
---|
[2] | 4482 | end |
---|
| 4483 | |
---|
[12] | 4484 | %------------------------------------------------------------------------ |
---|
[2] | 4485 | %--read images and convert them to the uint16 format used for PIV |
---|
[45] | 4486 | function A=read_image(filename,type_ima,num,movieobject) |
---|
[12] | 4487 | %------------------------------------------------------------------------ |
---|
[2] | 4488 | %num is the view number needed for an avi movie |
---|
[45] | 4489 | switch type_ima |
---|
| 4490 | case 'movie' |
---|
| 4491 | A=read(movieobject,num); |
---|
| 4492 | case 'avi' |
---|
[112] | 4493 | mov=aviread(filename,num); |
---|
| 4494 | A=frame2im(mov(1)); |
---|
[45] | 4495 | case 'multimage' |
---|
| 4496 | A=imread(filename,num); |
---|
[112] | 4497 | case 'image' |
---|
[45] | 4498 | A=imread(filename); |
---|
| 4499 | end |
---|
| 4500 | siz=size(A); |
---|
| 4501 | if length(siz)==3;%color images |
---|
[2] | 4502 | A=sum(double(A),3); |
---|
| 4503 | A=uint16(A); |
---|
| 4504 | end |
---|
| 4505 | |
---|
[12] | 4506 | %------------------------------------------------------------------------ |
---|
[2] | 4507 | function ref_i_Callback(hObject, eventdata, handles) |
---|
[12] | 4508 | %------------------------------------------------------------------------ |
---|
[2] | 4509 | mode_list=get(handles.mode,'String'); |
---|
| 4510 | mode_value=get(handles.mode,'Value'); |
---|
| 4511 | mode=mode_list{mode_value}; |
---|
[45] | 4512 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
[12] | 4513 | if isequal(mode,'series(Di)') || ...% we do patch2 only |
---|
[112] | 4514 | (get(handles.CIV2,'Value')==0 && get(handles.CIV1,'Value')==0 && get(handles.FIX1,'Value')==0 && get(handles.PATCH1,'Value')==0) |
---|
[2] | 4515 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 4516 | end |
---|
| 4517 | |
---|
[12] | 4518 | %------------------------------------------------------------------------ |
---|
[2] | 4519 | function ref_j_Callback(hObject, eventdata, handles) |
---|
[12] | 4520 | %------------------------------------------------------------------------ |
---|
[2] | 4521 | mode_list=get(handles.mode,'String'); |
---|
| 4522 | mode_value=get(handles.mode,'Value'); |
---|
| 4523 | mode=mode_list{mode_value}; |
---|
[112] | 4524 | if isequal(get(handles.CIV1,'Value'),0)|| isequal(mode,'series(Dj)') |
---|
[2] | 4525 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
| 4526 | end |
---|
[45] | 4527 | if isequal(mode,'series(Dj)') || ... |
---|
[112] | 4528 | (get(handles.CIV2,'Value')==0 && get(handles.CIV1,'Value')==0 && get(handles.FIX1,'Value')==0 && get(handles.PATCH1,'Value')==0) |
---|
[2] | 4529 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 4530 | end |
---|
[12] | 4531 | |
---|
| 4532 | %------------------------------------------------------------------------ |
---|
[71] | 4533 | function ref_i_civ2_Callback(hObject, eventdata, handles) |
---|
| 4534 | %------------------------------------------------------------------------ |
---|
| 4535 | mode_list=get(handles.mode,'String'); |
---|
| 4536 | mode_value=get(handles.mode,'Value'); |
---|
| 4537 | mode=mode_list{mode_value}; |
---|
| 4538 | find_netcpair_civ2(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
| 4539 | |
---|
| 4540 | %------------------------------------------------------------------------ |
---|
| 4541 | function ref_j_civ2_Callback(hObject, eventdata, handles) |
---|
| 4542 | %------------------------------------------------------------------------ |
---|
| 4543 | mode_list=get(handles.mode,'String'); |
---|
| 4544 | mode_value=get(handles.mode,'Value'); |
---|
| 4545 | mode=mode_list{mode_value}; |
---|
[112] | 4546 | if isequal(mode,'series(Dj)') |
---|
[71] | 4547 | find_netcpair_civ2(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
| 4548 | end |
---|
| 4549 | |
---|
| 4550 | %------------------------------------------------------------------------ |
---|
[2] | 4551 | % --- Executes on button press in compare. |
---|
| 4552 | function compare_Callback(hObject, eventdata, handles) |
---|
[12] | 4553 | %------------------------------------------------------------------------ |
---|
[2] | 4554 | test=get(handles.compare,'Value'); |
---|
[263] | 4555 | if test==2 || test==3 % case 'dispalcemen' or 'stereo PIV' |
---|
[71] | 4556 | filebase=get(handles.RootName,'String'); |
---|
[2] | 4557 | browse=get(handles.browse_root,'Userdata'); |
---|
| 4558 | browse.nom_type_ima1=browse.nom_type_ima; |
---|
| 4559 | set(handles.browse_root,'UserData',browse); |
---|
| 4560 | set(handles.sub_txt,'Visible','on') |
---|
[112] | 4561 | set(handles.RootName_1,'Visible','On');%mkes the second file input window visible |
---|
[2] | 4562 | mode_store=get(handles.mode,'String');%get the present 'mode' |
---|
[112] | 4563 | set(handles.compare,'UserData',mode_store);%store the mode display |
---|
[2] | 4564 | set(handles.mode,'Visible','off') |
---|
| 4565 | if test==2 |
---|
[112] | 4566 | set(handles.mode,'Visible','off') |
---|
[263] | 4567 | set(handles.CivMode,'Value',1) % mode 'civX' selected by default |
---|
[2] | 4568 | else |
---|
| 4569 | set(handles.mode,'Visible','on') |
---|
[263] | 4570 | set(handles.CivMode,'Value',3) % mode 'Matlab' selected for stereo |
---|
[2] | 4571 | end |
---|
| 4572 | |
---|
[229] | 4573 | %% open an image file with the browser |
---|
[2] | 4574 | ind_opening=1;%default |
---|
| 4575 | browse.incr_pair=[0 0]; %default |
---|
[71] | 4576 | oldfile=get(handles.RootName,'String'); |
---|
[229] | 4577 | menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)'; |
---|
| 4578 | '*.xml', '.xml files '; ... |
---|
| 4579 | '*.civ', '.civ files '; ... |
---|
| 4580 | '*.png','.png image files'; ... |
---|
| 4581 | '*.jpg',' jpeg image files'; ... |
---|
| 4582 | '*.tif','.tif image files'; ... |
---|
| 4583 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 4584 | '*.nc','.netcdf files'; ... |
---|
| 4585 | '*.*', 'All Files (*.*)'}; |
---|
| 4586 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file of the second series',oldfile); |
---|
[112] | 4587 | fileinput=[PathName FileName];%complete file name |
---|
[2] | 4588 | sizf=size(fileinput); |
---|
[229] | 4589 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
[263] | 4590 | [path,name,ext]=fileparts(fileinput) |
---|
[2] | 4591 | [path1]=fileparts(filebase); |
---|
[263] | 4592 | if isunix |
---|
| 4593 | [status,path]=system(['readlink ' path]) |
---|
| 4594 | [status,path1]=system(['readlink ' path1])% look for the true path in case of symbolic paths |
---|
| 4595 | end |
---|
[2] | 4596 | if ~strcmp(path1,path) |
---|
[263] | 4597 | msgbox_uvmat('ERROR','The second image series must be in the same directory as the first one') |
---|
[2] | 4598 | return |
---|
[263] | 4599 | end |
---|
| 4600 | % set(handles.RootName_1,'String',name); |
---|
[2] | 4601 | [RootPath,RootFile,field_count,str2,str_a,str_b,xx,nom_type,subdir]=name2display(name); |
---|
[263] | 4602 | set(handles.RootName_1,'String',RootFile); |
---|
[2] | 4603 | browse=get(handles.browse_root,'UserData'); |
---|
| 4604 | browse.nom_type_ima_1=nom_type; |
---|
[112] | 4605 | set(handles.browse_root,'UserData',browse) |
---|
[2] | 4606 | |
---|
| 4607 | %check image extension |
---|
[71] | 4608 | if ~strcmp(ext,get(handles.ImaExt,'String')) |
---|
[263] | 4609 | msgbox_uvmat('ERROR','The second image series must have the same extension name as the first one') |
---|
[2] | 4610 | return |
---|
| 4611 | end |
---|
| 4612 | |
---|
[229] | 4613 | %% check coincidence of image sizes |
---|
[263] | 4614 | % ref_i=get(handles.ref_i,'string'); |
---|
| 4615 | % ref_j=get(handles.ref_j,'string'); |
---|
| 4616 | % [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc]=set_civ_filenames(handles,ref_i,ref_j,[1 0 0 0 0 0]); |
---|
| 4617 | % A=imread(filecell.ima1.civ1{1}); |
---|
| 4618 | % A_1=imread(fileinput); |
---|
| 4619 | % npxy=size(A); |
---|
| 4620 | % npxy_1=size(A_1); |
---|
| 4621 | % if ~isequal(size(A),size(A_1)) |
---|
| 4622 | % msgbox_uvmat('ERROR','The two input image series do not have the same size') |
---|
| 4623 | % return |
---|
| 4624 | % end |
---|
[2] | 4625 | else |
---|
| 4626 | set(handles.mode,'Visible','on') |
---|
[71] | 4627 | set(handles.RootName_1,'Visible','Off'); |
---|
[2] | 4628 | set(handles.sub_txt,'Visible','off') |
---|
[71] | 4629 | set(handles.RootName_1,'String',[]); |
---|
[2] | 4630 | mode_store=get(handles.compare,'UserData'); |
---|
[177] | 4631 | set(handles.mode,'Value',1) |
---|
[2] | 4632 | set(handles.mode,'String',mode_store) |
---|
| 4633 | set(handles.test_stereo1,'Value',0) |
---|
| 4634 | set(handles.test_stereo2,'Value',0) |
---|
[263] | 4635 | set(handles.CivMode,'Value',1) % mode 'civX' selected by default |
---|
[2] | 4636 | end |
---|
[252] | 4637 | if test==3 && get(handles.PATCH1,'Value') |
---|
[263] | 4638 | set(handles.test_stereo1,'Visible','on') |
---|
[252] | 4639 | else |
---|
[263] | 4640 | set(handles.test_stereo1,'Visible','off') |
---|
[252] | 4641 | end |
---|
| 4642 | if test==3 && get(handles.PATCH2,'Value') |
---|
[263] | 4643 | set(handles.test_stereo2,'Visible','on') |
---|
[252] | 4644 | else |
---|
[263] | 4645 | set(handles.test_stereo2,'Visible','off') |
---|
[252] | 4646 | end |
---|
[2] | 4647 | mode_Callback(hObject, eventdata, handles) |
---|
| 4648 | |
---|
[12] | 4649 | %------------------------------------------------------------------------ |
---|
[2] | 4650 | % --- Executes on button press in get_ref_fix1. |
---|
| 4651 | function get_ref_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 4652 | %------------------------------------------------------------------------ |
---|
[71] | 4653 | filebase=get(handles.RootName,'String'); |
---|
[2] | 4654 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 4655 | {'*.nc', ' (*.nc)'; |
---|
| 4656 | '*.nc', 'netcdf files '; ... |
---|
| 4657 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4658 | 'Pick a file',filebase); |
---|
| 4659 | |
---|
[2] | 4660 | fileinput=[PathName FileName]; |
---|
| 4661 | sizf=size(fileinput); |
---|
[122] | 4662 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
[2] | 4663 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 4664 | ref.filebase=fullfile(Path,File); |
---|
| 4665 | ref.num_a=stra2num(str_a); |
---|
| 4666 | ref.num_b=stra2num(str_b); |
---|
[89] | 4667 | ref.num1=str2double(field_count); |
---|
| 4668 | ref.num2=str2double(str2); |
---|
[2] | 4669 | browse=[];%initialisation |
---|
| 4670 | if ~isequal(ref.ext,'.nc') |
---|
| 4671 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
| 4672 | return |
---|
| 4673 | end |
---|
| 4674 | set(handles.ref_fix1,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
| 4675 | set(handles.ref_fix1,'UserData',ref) |
---|
| 4676 | menu_field{1}='civ1'; |
---|
| 4677 | Data=nc2struct(fileinput,[]); |
---|
[45] | 4678 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
[2] | 4679 | menu_field{2}='filter1'; |
---|
| 4680 | end |
---|
[45] | 4681 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
[2] | 4682 | menu_field{3}='civ2'; |
---|
| 4683 | end |
---|
[45] | 4684 | if isfield(Data,'patch2') && isequal(Data.patch2,1) |
---|
[2] | 4685 | menu_field{4}='filter2'; |
---|
| 4686 | end |
---|
| 4687 | set(handles.field_ref1,'String',menu_field); |
---|
| 4688 | set(handles.field_ref1,'Value',length(menu_field)); |
---|
| 4689 | set(handles.inf_sup1,'Value',2); |
---|
| 4690 | set(handles.thresh_vel,'String','1');%default threshold |
---|
| 4691 | set(handles.ref_fix1,'Enable','on') |
---|
[12] | 4692 | |
---|
| 4693 | %------------------------------------------------------------------------ |
---|
[2] | 4694 | % --- Executes on button press in get_ref_fix2. |
---|
| 4695 | function get_ref_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 4696 | %------------------------------------------------------------------------ |
---|
[2] | 4697 | if isequal(get(handles.get_ref_fix2,'Value'),1) |
---|
[71] | 4698 | filebase=get(handles.RootName,'String'); |
---|
[2] | 4699 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 4700 | {'*.nc', ' (*.nc)'; |
---|
| 4701 | '*.nc', 'netcdf files '; ... |
---|
| 4702 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4703 | 'Pick a file',filebase); |
---|
[2] | 4704 | fileinput=[PathName FileName]; |
---|
| 4705 | sizf=size(fileinput); |
---|
[45] | 4706 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
[2] | 4707 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 4708 | ref.filebase=fullfile(Path,File); |
---|
| 4709 | ref.num_a=stra2num(str_a); |
---|
| 4710 | ref.num_b=stra2num(str_b); |
---|
| 4711 | ref.num1=str2num(field_count); |
---|
| 4712 | ref.num2=str2num(str2); |
---|
| 4713 | browse=[];%initialisation |
---|
| 4714 | if ~isequal(ref.ext,'.nc') |
---|
| 4715 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
| 4716 | return |
---|
| 4717 | end |
---|
| 4718 | set(handles.ref_fix2,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
[112] | 4719 | set(handles.ref_fix2,'UserData',ref) |
---|
[2] | 4720 | menu_field{1}='civ1'; |
---|
| 4721 | Data=nc2struct(fileinput,[]); |
---|
| 4722 | if isfield(Data,'patch') & isequal(Data.patch,1) |
---|
| 4723 | menu_field{2}='filter1'; |
---|
| 4724 | end |
---|
| 4725 | if isfield(Data,'civ2') & isequal(Data.civ2,1) |
---|
| 4726 | menu_field{3}='civ2'; |
---|
| 4727 | end |
---|
| 4728 | if isfield(Data,'patch2') & isequal(Data.patch2,1) |
---|
| 4729 | menu_field{4}='filter2'; |
---|
| 4730 | end |
---|
| 4731 | set(handles.field_ref2,'String',menu_field); |
---|
| 4732 | set(handles.field_ref2,'Value',length(menu_field)); |
---|
| 4733 | set(handles.inf_sup2,'Value',2); |
---|
| 4734 | set(handles.thresh_vel2,'String','1');%default threshold |
---|
| 4735 | set(handles.ref_fix2,'Enable','on') |
---|
| 4736 | set(handles.ref_fix2,'Visible','on') |
---|
| 4737 | set(handles.field_ref2,'Visible','on') |
---|
| 4738 | else |
---|
| 4739 | set(handles.ref_fix2,'Visible','off') |
---|
| 4740 | set(handles.field_ref2,'Visible','off') |
---|
| 4741 | end |
---|
| 4742 | |
---|
[12] | 4743 | %------------------------------------------------------------------------ |
---|
[2] | 4744 | function ref_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 4745 | %------------------------------------------------------------------------ |
---|
| 4746 | set(handles.inf_sup1,'Value',1); |
---|
| 4747 | set(handles.field_ref1,'Value',1) |
---|
| 4748 | set(handles.field_ref1,'String',{' '}) |
---|
| 4749 | set(handles.ref_fix1,'UserData',[]); |
---|
| 4750 | set(handles.ref_fix1,'String',''); |
---|
| 4751 | set(handles.thresh_vel1,'String','0'); |
---|
[112] | 4752 | |
---|
[12] | 4753 | %------------------------------------------------------------------------ |
---|
[2] | 4754 | function ref_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 4755 | %------------------------------------------------------------------------ |
---|
| 4756 | set(handles.inf_sup2,'Value',1); |
---|
| 4757 | set(handles.field_ref2,'Value',1) |
---|
| 4758 | set(handles.field_ref2,'String',{' '}) |
---|
| 4759 | set(handles.ref_fix2,'UserData',[]); |
---|
| 4760 | set(handles.ref_fix2,'String',''); |
---|
| 4761 | set(handles.thresh_vel2,'String','0'); |
---|
[2] | 4762 | |
---|
[12] | 4763 | %------------------------------------------------------------------------ |
---|
[2] | 4764 | % --- Executes on button press in test_stereo1. |
---|
| 4765 | function test_stereo1_Callback(hObject, eventdata, handles) |
---|
[12] | 4766 | %------------------------------------------------------------------------ |
---|
[2] | 4767 | if isequal(get(handles.test_stereo1,'Value'),0) |
---|
| 4768 | set(handles.subdomain_patch1,'Visible','on') |
---|
| 4769 | set(handles.rho_patch1,'Visible','on') |
---|
| 4770 | else |
---|
| 4771 | set(handles.subdomain_patch1,'Visible','off') |
---|
| 4772 | set(handles.rho_patch1,'Visible','off') |
---|
| 4773 | end |
---|
| 4774 | |
---|
[12] | 4775 | %------------------------------------------------------------------------ |
---|
[2] | 4776 | % --- Executes on button press in test_stereo2. |
---|
| 4777 | function test_stereo2_Callback(hObject, eventdata, handles) |
---|
[12] | 4778 | %------------------------------------------------------------------------ |
---|
[2] | 4779 | if isequal(get(handles.test_stereo2,'Value'),0) |
---|
| 4780 | set(handles.subdomain_patch2,'Visible','on') |
---|
| 4781 | set(handles.rho_patch2,'Visible','on') |
---|
| 4782 | else |
---|
| 4783 | set(handles.subdomain_patch2,'Visible','off') |
---|
| 4784 | set(handles.rho_patch2,'Visible','off') |
---|
| 4785 | end |
---|
| 4786 | |
---|
[12] | 4787 | %------------------------------------------------------------------------ |
---|
[2] | 4788 | % --- Executes on button press in ImaThreshold. |
---|
| 4789 | function ImaThreshold_Callback(hObject, eventdata, handles) |
---|
[12] | 4790 | %------------------------------------------------------------------------ |
---|
[2] | 4791 | if isequal(get(handles.ImaThreshold,'Value'),1) |
---|
| 4792 | set(handles.MinIma,'Visible','on') |
---|
| 4793 | set(handles.MaxIma,'Visible','on') |
---|
| 4794 | else |
---|
| 4795 | set(handles.MinIma,'Visible','off') |
---|
| 4796 | set(handles.MaxIma,'Visible','off') |
---|
| 4797 | end |
---|
| 4798 | |
---|
[12] | 4799 | %------------------------------------------------------------------------ |
---|
[2] | 4800 | % --- Executes on button press in ImaThreshold2. |
---|
| 4801 | function ImaThreshold2_Callback(hObject, eventdata, handles) |
---|
[12] | 4802 | %------------------------------------------------------------------------ |
---|
[2] | 4803 | if isequal(get(handles.ImaThreshold2,'Value'),1) |
---|
| 4804 | set(handles.MinIma2,'Visible','on') |
---|
| 4805 | set(handles.MaxIma2,'Visible','on') |
---|
| 4806 | else |
---|
| 4807 | set(handles.MinIma2,'Visible','off') |
---|
| 4808 | set(handles.MaxIma2,'Visible','off') |
---|
| 4809 | end |
---|
| 4810 | |
---|
[224] | 4811 | %------------------------------------------------------------------------ |
---|
[225] | 4812 | % --- Executes on button press in TestCiv1: display image correlation function |
---|
[150] | 4813 | function TestCiv1_Callback(hObject, eventdata, handles) |
---|
[224] | 4814 | %------------------------------------------------------------------------ |
---|
[233] | 4815 | set(handles.TestCiv1,'BackgroundColor',[1 1 0]) |
---|
| 4816 | drawnow |
---|
[150] | 4817 | test_civ1=get(handles.TestCiv1,'Value'); |
---|
| 4818 | if test_civ1 |
---|
[227] | 4819 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
| 4820 | if strcmp(get(handles.ref_j,'Visible'),'on') |
---|
| 4821 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
| 4822 | else |
---|
| 4823 | ref_j=1;%default |
---|
| 4824 | end |
---|
[224] | 4825 | [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]=... |
---|
[248] | 4826 | set_civ_filenames(handles,ref_i,ref_j,[1 0 0 0 0 0]) |
---|
[224] | 4827 | Data.ListVarName={'ny','nx','A'}; |
---|
| 4828 | Data.VarDimName={'ny','nx',{'ny','nx'}}; |
---|
| 4829 | Data.A=imread(filecell.ima1.civ1{1}); |
---|
| 4830 | Data.ny=[size(Data.A,1) 1]; |
---|
| 4831 | Data.nx=[1 size(Data.A,2)]; |
---|
[227] | 4832 | par_civ1=read_param_civ1(handles,filecell.ima1.civ1{1}); |
---|
[231] | 4833 | par_civ1.filename_ima_a=filecell.ima1.civ1{1}; |
---|
| 4834 | par_civ1.filename_ima_b=filecell.ima2.civ1{1}; |
---|
| 4835 | par_civ1.T0=0; |
---|
| 4836 | par_civ1.Dt=1; |
---|
[246] | 4837 | Param.Civ1=par_civ1; |
---|
| 4838 | Data=civ_uvmat(Param); |
---|
[231] | 4839 | Data.ListVarName=[Data.ListVarName {'ny','nx','A'}]; |
---|
| 4840 | Data.VarDimName=[Data.VarDimName {'ny','nx',{'ny','nx'}}]; |
---|
| 4841 | Data.A=imread(filecell.ima1.civ1{1}); |
---|
| 4842 | Data.ny=[size(Data.A,1) 1]; |
---|
| 4843 | Data.nx=[1 size(Data.A,2)]; |
---|
| 4844 | hview_field=view_field(Data); |
---|
| 4845 | set(0,'CurrentFigure',hview_field) |
---|
| 4846 | hhview_field=guihandles(hview_field); |
---|
| 4847 | set(hview_field,'CurrentAxes',hhview_field.axes3) |
---|
| 4848 | ViewData=get(hview_field,'UserData'); |
---|
| 4849 | ViewData.CivHandle=handles.civ;% indicate the handle of the civ GUI in view_field |
---|
[224] | 4850 | ViewData.axes3.B=imread(filecell.ima2.civ1{1});%store the second image in the UserData of the GUI view_field |
---|
[236] | 4851 | ViewData.axes3.X=Data.Civ1_X; %keep the set of points in memeory |
---|
| 4852 | ViewData.axes3.Y=Data.Civ1_Y; |
---|
[231] | 4853 | set(hview_field,'UserData',ViewData) |
---|
[224] | 4854 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
| 4855 | if isempty(corrfig) |
---|
| 4856 | corrfig=figure; |
---|
| 4857 | set(corrfig,'tag','corrfig') |
---|
| 4858 | set(corrfig,'name','image correlation') |
---|
| 4859 | set(corrfig,'DeleteFcn',{@closeview_field})% |
---|
| 4860 | end |
---|
[233] | 4861 | set(handles.TestCiv1,'BackgroundColor',[1 0 0]) |
---|
[224] | 4862 | else |
---|
| 4863 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
| 4864 | if ~isempty(corrfig) |
---|
| 4865 | delete(corrfig) |
---|
| 4866 | end |
---|
| 4867 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
| 4868 | if ~isempty(hview_field) |
---|
| 4869 | delete(hview_field) |
---|
| 4870 | end |
---|
[150] | 4871 | end |
---|
[71] | 4872 | |
---|
[224] | 4873 | function closeview_field(gcbo,eventdata) |
---|
| 4874 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
| 4875 | if ~isempty(hview_field) |
---|
| 4876 | delete(hview_field) |
---|
| 4877 | end |
---|
[177] | 4878 | %------------------------------------------------------------------- |
---|
| 4879 | % --- Executes on button press in status. |
---|
| 4880 | function status_Callback(hObject, eventdata, handles) |
---|
| 4881 | %------------------------------------------------------------------- |
---|
| 4882 | val=get(handles.status,'Value'); |
---|
| 4883 | if val==0 |
---|
[252] | 4884 | set(handles.status,'BackgroundColor',[0 1 0]) |
---|
[177] | 4885 | hfig=findobj(allchild(0),'name','civ_status'); |
---|
| 4886 | if ~isempty(hfig) |
---|
| 4887 | delete(hfig) |
---|
| 4888 | end |
---|
| 4889 | return |
---|
| 4890 | end |
---|
[252] | 4891 | set(handles.status,'BackgroundColor',[1 1 0]) |
---|
| 4892 | drawnow |
---|
[177] | 4893 | listtype={'civ1','fix1','patch1','civ2','fix2','patch2'}; |
---|
| 4894 | box_test(1)=get(handles.CIV1,'Value'); |
---|
| 4895 | box_test(2)=get(handles.FIX1,'Value'); |
---|
| 4896 | box_test(3)=get(handles.PATCH1,'Value'); |
---|
| 4897 | box_test(4)=get(handles.CIV2,'Value'); |
---|
| 4898 | box_test(5)=get(handles.FIX2,'Value'); |
---|
[180] | 4899 | box_test(6)=get(handles.PATCH2,'Value'); |
---|
| 4900 | option_civ=find(box_test,1,'last');%last selected option (non-zero index of box_test) |
---|
[252] | 4901 | filecell=get(handles.civ,'UserData');%retrieve the list of output files expected for PIV |
---|
| 4902 | test_new=0; |
---|
[177] | 4903 | if ~isfield(filecell,'nc') |
---|
[252] | 4904 | test_new=1; |
---|
[227] | 4905 | [ref_i,ref_j,errormsg]=find_ref_indices(handles); |
---|
| 4906 | if ~isempty(errormsg) |
---|
| 4907 | msgbox_uvmat('ERROR',errormsg) |
---|
| 4908 | return |
---|
| 4909 | end |
---|
[252] | 4910 | filecell=set_civ_filenames(handles,ref_i,ref_j,box_test);%determine the output file expected from the GUI status |
---|
[177] | 4911 | end |
---|
| 4912 | if ~isequal(box_test(4:6),[0 0 0]) |
---|
[252] | 4913 | civ_files=filecell.nc.civ2;%case of civ2 operations |
---|
[177] | 4914 | else |
---|
| 4915 | civ_files=filecell.nc.civ1; |
---|
| 4916 | end |
---|
| 4917 | [root,filename,ext]=fileparts(civ_files{1}); |
---|
| 4918 | [rootroot,subdir,extdir]=fileparts(root); |
---|
| 4919 | hfig=findobj(allchild(0),'name','civ_status'); |
---|
| 4920 | if isempty(hfig) |
---|
[252] | 4921 | hfig=figure('DeleteFcn',@stop_status); |
---|
[177] | 4922 | set(hfig,'name','civ_status') |
---|
[182] | 4923 | hlist=uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', @open_view_field,'tag','list'); |
---|
[252] | 4924 | uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','msgbox','Max',2,'String','checking files...'); |
---|
[177] | 4925 | uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]); |
---|
[182] | 4926 | uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'String','OK','FontWeight','bold','FontUnits','normalized','FontSize',0.9,'Callback',@close_GUI); |
---|
[177] | 4927 | BarPosition=[0.05 0.81 0.01 0.05]; |
---|
| 4928 | hwaitbar=uicontrol('Style','frame','Units','normalized', 'Position',BarPosition ,'BackgroundColor',[1 0 0],'tag','waitbar'); |
---|
[252] | 4929 | drawnow |
---|
[177] | 4930 | end |
---|
[188] | 4931 | % datnum=[]; |
---|
[177] | 4932 | Tabchar={}; |
---|
| 4933 | nbfiles=numel(civ_files); |
---|
| 4934 | count=0; |
---|
[188] | 4935 | testrecent=0; |
---|
[177] | 4936 | while count<nbfiles |
---|
| 4937 | count=0; |
---|
[188] | 4938 | datnum=zeros(1,nbfiles); |
---|
[177] | 4939 | for ifile=1:nbfiles |
---|
| 4940 | detect=exist(civ_files{ifile},'file'); % check the existence of the file |
---|
[179] | 4941 | option=0; |
---|
[177] | 4942 | if detect==0 |
---|
[179] | 4943 | option_str='not created'; |
---|
[177] | 4944 | else |
---|
[219] | 4945 | datfile=dir(civ_files{ifile}); |
---|
[188] | 4946 | if isfield(datfile,'datenum') |
---|
| 4947 | datnum(ifile)=datfile.datenum;%only available in recent matlab versions |
---|
| 4948 | testrecent=1; |
---|
| 4949 | end |
---|
[177] | 4950 | filefound(ifile)={datfile.name}; |
---|
| 4951 | lastfield=''; |
---|
| 4952 | % check the content netcdf file |
---|
| 4953 | Data=nc2struct(civ_files{ifile},'ListGlobalAttribute','patch2','fix2','civ2','patch','fix'); |
---|
| 4954 | if ~isempty(Data.patch2) && isequal(Data.patch2,1) |
---|
[179] | 4955 | option=6; |
---|
| 4956 | option_str='patch2'; |
---|
[177] | 4957 | elseif ~isempty(Data.fix2) && isequal(Data.fix2,1) |
---|
[179] | 4958 | option=5; |
---|
| 4959 | option_str='fix2'; |
---|
[177] | 4960 | elseif ~isempty(Data.civ2) && isequal(Data.civ2,1); |
---|
[179] | 4961 | option=4; |
---|
| 4962 | option_str='civ2'; |
---|
[177] | 4963 | elseif ~isempty(Data.patch) && isequal(Data.patch,1); |
---|
[179] | 4964 | option=3; |
---|
| 4965 | option_str='patch1'; |
---|
[177] | 4966 | elseif ~isempty(Data.fix) && isequal(Data.fix,1); |
---|
[179] | 4967 | option=2; |
---|
| 4968 | option_str='fix1'; |
---|
[177] | 4969 | else |
---|
[179] | 4970 | option=1; |
---|
| 4971 | option_str='civ1'; |
---|
[177] | 4972 | end |
---|
| 4973 | end |
---|
[179] | 4974 | if option >= option_civ |
---|
[177] | 4975 | count=count+1; |
---|
| 4976 | end |
---|
| 4977 | [rr,filename,ext]=fileparts(civ_files{ifile}); |
---|
[179] | 4978 | Tabchar{ifile,1}=[fullfile([subdir extdir],filename) ext '...' option_str]; |
---|
[177] | 4979 | end |
---|
[219] | 4980 | datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files |
---|
[188] | 4981 | if isempty(datnum) |
---|
| 4982 | if testrecent |
---|
| 4983 | message='no civ result created yet'; |
---|
| 4984 | else |
---|
| 4985 | message=''; |
---|
| 4986 | end |
---|
[177] | 4987 | else |
---|
[219] | 4988 | datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files |
---|
[177] | 4989 | [first,ind]=min(datnum); |
---|
| 4990 | [last,indlast]=max(datnum); |
---|
[252] | 4991 | if test_new |
---|
| 4992 | message='existing file status, no processing launched yet'; |
---|
| 4993 | else |
---|
[177] | 4994 | message={[num2str(count) ' file(s) done over ' num2str(nbfiles)] ;['oldest modification: ' cell2mat(filefound(ind)) ' : ' datestr(first)];... |
---|
| 4995 | ['latest modification: ' cell2mat(filefound(indlast)) ' : ' datestr(last)]}; |
---|
[252] | 4996 | end |
---|
[177] | 4997 | end |
---|
| 4998 | hfig=findobj(allchild(0),'name','civ_status'); |
---|
[252] | 4999 | if isempty(hfig)% the status list has been deleted |
---|
[177] | 5000 | return |
---|
| 5001 | else |
---|
| 5002 | hlist=findobj(hfig,'tag','list'); |
---|
| 5003 | hmsgbox=findobj(hfig,'tag','msgbox'); |
---|
| 5004 | hwaitbar=findobj(hfig,'tag','waitbar'); |
---|
| 5005 | set(hlist,'String',Tabchar) |
---|
| 5006 | set(hmsgbox,'String', message) |
---|
[252] | 5007 | if count>0 && ~test_new |
---|
[177] | 5008 | BarPosition(3)=0.9*count/nbfiles; |
---|
| 5009 | set(hwaitbar,'Position',BarPosition) |
---|
| 5010 | end |
---|
| 5011 | end |
---|
| 5012 | set(hlist,'UserData',rootroot) |
---|
[252] | 5013 | pause(10)% wait 10 seconds for next check |
---|
[177] | 5014 | end |
---|
[150] | 5015 | |
---|
[177] | 5016 | |
---|
[252] | 5017 | %------------------------------------------------------------------------ |
---|
| 5018 | % call 'view_field.fig' to display the field selected in the list of 'status' |
---|
[177] | 5019 | function open_view_field(hObject, eventdata) |
---|
[252] | 5020 | %------------------------------------------------------------------------ |
---|
| 5021 | list=get(hObject,'String'); |
---|
| 5022 | index=get(hObject,'Value'); |
---|
| 5023 | rootroot=get(hObject,'UserData'); |
---|
| 5024 | filename=list{index}; |
---|
| 5025 | ind_dot=findstr(filename,'...'); |
---|
| 5026 | filename=filename(1:ind_dot-1); |
---|
| 5027 | filename=fullfile(rootroot,filename); |
---|
| 5028 | delete(get(hObject,'parent'))%delete the display figure to stop the check process |
---|
| 5029 | if exist(filename,'file')%visualise the vel field if it exists |
---|
| 5030 | uvmat(filename) |
---|
| 5031 | set(gcbo,'Value',1) |
---|
| 5032 | end |
---|
[150] | 5033 | |
---|
[252] | 5034 | %------------------------------------------------------------------------ |
---|
| 5035 | % launched by pressing OK on the status figure |
---|
[182] | 5036 | function close_GUI(hObject, eventdata) |
---|
[252] | 5037 | %------------------------------------------------------------------------ |
---|
| 5038 | delete(gcbf) |
---|
| 5039 | |
---|
| 5040 | %------------------------------------------------------------------------ |
---|
| 5041 | % launched by deleting the status figure |
---|
| 5042 | function stop_status(hObject, eventdata) |
---|
| 5043 | %------------------------------------------------------------------------ |
---|
| 5044 | hciv=findobj(allchild(0),'tag','civ'); |
---|
| 5045 | hhciv=guidata(hciv); |
---|
| 5046 | set(hhciv.status,'value',0) %reset the status uicontrol in the GUI civ |
---|
| 5047 | set(hhciv.status,'BackgroundColor',[0 1 0]) |
---|
[220] | 5048 | |
---|
[252] | 5049 | %------------------------------------------------------------------------ |
---|
[257] | 5050 | % --- Executes on button press in CivMode. |
---|
| 5051 | function CivMode_Callback(hObject, eventdata, handles) |
---|
[252] | 5052 | %------------------------------------------------------------------------ |
---|
[257] | 5053 | Listprog=get(handles.CivMode,'String'); |
---|
| 5054 | index=get(handles.CivMode,'Value'); |
---|
[238] | 5055 | prog=Listprog{index}; |
---|
| 5056 | switch prog |
---|
| 5057 | case 'CivX' |
---|
| 5058 | set(handles.thresh_patch1,'Visible','off') |
---|
| 5059 | set(handles.thresh_text1,'Visible','off') |
---|
[252] | 5060 | set(handles.thresh_patch2,'Visible','off') |
---|
| 5061 | set(handles.thresh_text2,'Visible','off') |
---|
[238] | 5062 | set(handles.rho,'Style','edit') |
---|
| 5063 | set(handles.rho,'String','1') |
---|
[252] | 5064 | set(handles.BATCH,'Enable','on') |
---|
[238] | 5065 | case 'CivAll' |
---|
| 5066 | if get(handles.PATCH1,'Value') |
---|
| 5067 | set(handles.thresh_patch1,'Visible','on') |
---|
| 5068 | set(handles.thresh_text1,'Visible','on') |
---|
| 5069 | end |
---|
| 5070 | set(handles.rho,'Style','edit') |
---|
| 5071 | set(handles.rho,'String','1') |
---|
[252] | 5072 | set(handles.BATCH,'Enable','on') |
---|
[238] | 5073 | case 'CivUvmat' |
---|
| 5074 | if get(handles.PATCH1,'Value') |
---|
| 5075 | set(handles.thresh_patch1,'Visible','on') |
---|
| 5076 | set(handles.thresh_text1,'Visible','on') |
---|
| 5077 | end |
---|
[252] | 5078 | if get(handles.PATCH2,'Value') |
---|
| 5079 | set(handles.thresh_patch2,'Visible','on') |
---|
| 5080 | set(handles.thresh_text2,'Visible','on') |
---|
| 5081 | end |
---|
[238] | 5082 | set(handles.rho,'Style','popupmenu') |
---|
| 5083 | set(handles.rho,'Value',1) |
---|
| 5084 | set(handles.rho,'String',{'1';'2'}) |
---|
[252] | 5085 | set(handles.BATCH,'Enable','off') |
---|
[224] | 5086 | end |
---|