[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') |
---|
| 1164 | mode_value=get(handles.mode,'Value') |
---|
[2] | 1165 | mode=mode_list{mode_value}; |
---|
| 1166 | end |
---|
| 1167 | |
---|
| 1168 | % nomenclature type of the .nc files |
---|
| 1169 | nom_type_ima='ima_num';%default |
---|
| 1170 | if isfield(browse,'nom_type_ima') |
---|
| 1171 | nom_type_ima=browse.nom_type_ima; |
---|
| 1172 | end |
---|
| 1173 | nom_type_nc='_i1-i2';%default |
---|
| 1174 | if isfield(browse,'nom_type_nc') |
---|
| 1175 | nom_type_nc=browse.nom_type_nc; |
---|
| 1176 | end |
---|
[94] | 1177 | 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] | 1178 | nom_type_nc='netc_old';%nom_type for the netcdf files |
---|
[94] | 1179 | elseif isequal(nom_type_ima,'none')||isequal(nom_type_nc,'none') |
---|
[2] | 1180 | nom_type_nc='none'; |
---|
[94] | 1181 | elseif isequal(nom_type_ima,'avi')||isequal(nom_type_ima,'_i')||isequal(nom_type_ima,'ima_num')||isequal(nom_type_nc,'_i1-i2') |
---|
[112] | 1182 | nom_type_nc='_i1-i2'; |
---|
[2] | 1183 | else |
---|
| 1184 | if isequal(mode,'series(Di)')%|isequal(mode,'st_series(Di)') |
---|
| 1185 | nom_type_nc='_i1-i2_j'; % PIV in volume |
---|
| 1186 | else |
---|
| 1187 | nom_type_nc='_i_j1-j2'; |
---|
[112] | 1188 | end |
---|
[2] | 1189 | end |
---|
| 1190 | browse.nom_type_nc=nom_type_nc; |
---|
| 1191 | set(handles.browse_root,'UserData',browse) |
---|
| 1192 | |
---|
| 1193 | %reads .nc subdirectory and image numbers from the interface |
---|
| 1194 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
| 1195 | subdir_civ2=get(handles.subdir_civ2,'String');%subdirectory subdir_civ2 for the netcdf data |
---|
[45] | 1196 | % first_i=str2num(get(handles.first_i,'String')); |
---|
| 1197 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 1198 | % incr=str2num(get(handles.incr_i,'String')); |
---|
| 1199 | % num1=first_i:incr:last_i; |
---|
| 1200 | % if isempty(num1) |
---|
| 1201 | % set(handles.list_pair_civ2,'Value',1); |
---|
| 1202 | % set(handles.list_pair_civ2,'String',{''}); |
---|
| 1203 | % return |
---|
| 1204 | % end |
---|
[137] | 1205 | ref_i=str2double(get(handles.ref_i_civ2,'String')); |
---|
[2] | 1206 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
| 1207 | ref_j=0; |
---|
| 1208 | else |
---|
[137] | 1209 | ref_j=str2double(get(handles.ref_j_civ2,'String')); |
---|
[2] | 1210 | end |
---|
[71] | 1211 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
[2] | 1212 | if isempty(time) |
---|
| 1213 | time=[0 1];%default |
---|
| 1214 | end |
---|
[71] | 1215 | %dt_unit=str2num(get(handles.dt,'String'));% used when there is no image documentation file |
---|
[73] | 1216 | %dt_unit=1000; |
---|
[2] | 1217 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 1218 | |
---|
| 1219 | |
---|
[112] | 1220 | %eliminate the first pairs inconsistent with the position |
---|
[2] | 1221 | if isempty(displ_num) |
---|
| 1222 | nbpair=0; |
---|
| 1223 | else |
---|
| 1224 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
[112] | 1225 | if isequal(mode,'series(Di)')% | isequal(mode,'st_series(Di)') |
---|
[2] | 1226 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
[112] | 1227 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
[2] | 1228 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1229 | end |
---|
| 1230 | end |
---|
| 1231 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
| 1232 | |
---|
[112] | 1233 | %look for existing processed pairs involving the field at the middle of the series if civ1 will not |
---|
[2] | 1234 | % be performed, while the result is needed for next steps. |
---|
| 1235 | displ_pair={''}; %default |
---|
| 1236 | select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs |
---|
| 1237 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0%&... |
---|
[112] | 1238 | if ~exist(fullfile(filepath,subdir_civ2,ext_dir),'dir') |
---|
| 1239 | errordlg(['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist']) |
---|
| 1240 | set(handles.list_pair_civ2,'Value',1); |
---|
| 1241 | set(handles.list_pair_civ2,'String',{''}); |
---|
| 1242 | return |
---|
[2] | 1243 | end |
---|
[112] | 1244 | for ipair=1:nbpair |
---|
[2] | 1245 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
[112] | 1246 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
[2] | 1247 | select(ipair)=exist(filename,'file')==2; |
---|
| 1248 | end |
---|
| 1249 | if isequal(select,zeros(size(1:nbpair))) |
---|
[112] | 1250 | if isfield(browse,'incr_pair') |
---|
[2] | 1251 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
| 1252 | num_i2=ref_i+floor((browse.incr_pair(1)+1)/2); |
---|
| 1253 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
| 1254 | num_j2=ref_j+floor((browse.incr_pair(2)+1)/2); |
---|
| 1255 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ2); |
---|
| 1256 | select(1)=exist(filename,'file')==2; |
---|
| 1257 | else |
---|
[112] | 1258 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
[2] | 1259 | errordlg(['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2]) |
---|
| 1260 | else |
---|
| 1261 | errordlg(['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2]) |
---|
| 1262 | end |
---|
[112] | 1263 | set(handles.list_pair_civ2,'Value',1); |
---|
| 1264 | set(handles.list_pair_civ2,'String',{''}); |
---|
[2] | 1265 | return |
---|
| 1266 | end |
---|
| 1267 | end |
---|
| 1268 | end |
---|
[112] | 1269 | if isequal(mode,'series(Di)') % | isequal(mode,'st_series(Di)') |
---|
| 1270 | for ipair=1:nbpair |
---|
| 1271 | if select(ipair) |
---|
| 1272 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
[2] | 1273 | 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 |
---|
| 1274 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
[112] | 1275 | end |
---|
| 1276 | else |
---|
| 1277 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1278 | end |
---|
| 1279 | end |
---|
[2] | 1280 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') % series on the j index |
---|
[112] | 1281 | for ipair=1:nbpair |
---|
| 1282 | if select(ipair) |
---|
| 1283 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1284 | 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 |
---|
| 1285 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1286 | end |
---|
| 1287 | else |
---|
| 1288 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1289 | end |
---|
| 1290 | end |
---|
[2] | 1291 | elseif isequal(mode,'pair j1-j2')% | isequal(mode,'st_pair j1-j2') %case of pairs |
---|
| 1292 | for ipair=1:nbpair |
---|
| 1293 | if select(ipair) |
---|
[112] | 1294 | 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 |
---|
| 1295 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
| 1296 | ' :dt= ' num2str(dt*1000)]; |
---|
| 1297 | else |
---|
| 1298 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1299 | end |
---|
| 1300 | end |
---|
[2] | 1301 | elseif isequal(mode,'displacement') |
---|
[112] | 1302 | displ_pair={'Di=Dj=0'}; |
---|
| 1303 | end |
---|
[2] | 1304 | val=get(handles.list_pair_civ2,'Value'); |
---|
[229] | 1305 | ichoice=find(select,1); |
---|
[137] | 1306 | if (isempty(ichoice) || ichoice < 1); ichoice=1; end; |
---|
| 1307 | if get(handles.CIV2,'Value')==0 && get(handles.CIV1,'Value')==0 && get(handles.FIX1,'Value')==0 && get(handles.PATCH1,'Value')==0 |
---|
[2] | 1308 | val=ichoice;% first valid pair proposed by default in the menu |
---|
| 1309 | end |
---|
| 1310 | if val>length(displ_pair') |
---|
| 1311 | set(handles.list_pair_civ2,'Value',1);% first valid pair proposed by default in the menu |
---|
| 1312 | else |
---|
| 1313 | set(handles.list_pair_civ2,'Value',val); |
---|
| 1314 | end |
---|
| 1315 | set(handles.list_pair_civ2,'String',displ_pair'); |
---|
[12] | 1316 | set(gcf,'Pointer','arrow') |
---|
[2] | 1317 | |
---|
| 1318 | |
---|
[41] | 1319 | |
---|
[227] | 1320 | |
---|
[12] | 1321 | %------------------------------------------------------------------------ |
---|
[2] | 1322 | % --- Executes on selection change in list_pair_civ1. |
---|
| 1323 | function list_pair_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 1324 | %------------------------------------------------------------------------ |
---|
[2] | 1325 | %reproduce by default the chosen pair in the civ2 menu |
---|
| 1326 | list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs |
---|
| 1327 | index_pair=get(handles.list_pair_civ1,'Value'); |
---|
| 1328 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
[137] | 1329 | % num_a=displ_num(1,index_pair); |
---|
| 1330 | % num_b=displ_num(2,index_pair); |
---|
[2] | 1331 | list_pair2=get(handles.list_pair_civ2,'String');%get the menu of image pairs |
---|
| 1332 | if index_pair<=length(list_pair2) |
---|
| 1333 | set(handles.list_pair_civ2,'Value',index_pair); |
---|
| 1334 | end |
---|
| 1335 | |
---|
[112] | 1336 | %update first_i and last_i according to the chosen image pairs |
---|
[2] | 1337 | mode_list=get(handles.mode,'String'); |
---|
| 1338 | mode_value=get(handles.mode,'Value'); |
---|
| 1339 | mode=mode_list{mode_value}; |
---|
| 1340 | if isequal(mode,'series(Di)') |
---|
[137] | 1341 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 1342 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 1343 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
[2] | 1344 | num1=first_i:incr_i:last_i; |
---|
[137] | 1345 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 1346 | if ~isnan(lastfield) |
---|
[229] | 1347 | test_find=(num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
| 1348 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield); |
---|
| 1349 | num1=num1(test_find); |
---|
[2] | 1350 | end |
---|
| 1351 | set(handles.first_i,'String',num2str(num1(1))); |
---|
| 1352 | set(handles.last_i,'String',num2str(num1(end))); |
---|
| 1353 | elseif isequal(mode,'series(Dj)') |
---|
[137] | 1354 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 1355 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 1356 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[2] | 1357 | num_j=first_j:incr_j:last_j; |
---|
[137] | 1358 | lastfield2=str2double(get(handles.nb_field2,'String')); |
---|
| 1359 | if ~isnan(lastfield2) |
---|
[229] | 1360 | test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 1361 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2); |
---|
| 1362 | num1=num_j(test_find); |
---|
[2] | 1363 | end |
---|
| 1364 | set(handles.first_j,'String',num2str(num1(1))); |
---|
| 1365 | set(handles.last_j,'String',num2str(num1(end))); |
---|
[112] | 1366 | end |
---|
[2] | 1367 | |
---|
[12] | 1368 | %------------------------------------------------------------------------ |
---|
[2] | 1369 | % --- Executes on selection change in list_pair_civ2. |
---|
| 1370 | function list_pair_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 1371 | %------------------------------------------------------------------------ |
---|
[112] | 1372 | index_pair=get(handles.list_pair_civ2,'Value');%get the selected position index in the menu |
---|
[2] | 1373 | |
---|
[112] | 1374 | %update first_i and last_i according to the chosen image pairs |
---|
[2] | 1375 | mode_list=get(handles.mode,'String'); |
---|
| 1376 | mode_value=get(handles.mode,'Value'); |
---|
| 1377 | mode=mode_list{mode_value}; |
---|
| 1378 | if isequal(mode,'series(Di)') |
---|
[137] | 1379 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 1380 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 1381 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
[2] | 1382 | num1=first_i:incr_i:last_i; |
---|
[137] | 1383 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 1384 | if ~isnan(lastfield) |
---|
[229] | 1385 | test_find=(num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
| 1386 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield); |
---|
| 1387 | num1=num1(test_find); |
---|
[2] | 1388 | end |
---|
| 1389 | set(handles.first_i,'String',num2str(num1(1))); |
---|
| 1390 | set(handles.last_i,'String',num2str(num1(end))); |
---|
| 1391 | elseif isequal(mode,'series(Dj)') |
---|
[137] | 1392 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 1393 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 1394 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[2] | 1395 | num_j=first_j:incr_j:last_j; |
---|
[137] | 1396 | lastfield2=str2double(get(handles.nb_field2,'String')); |
---|
| 1397 | if ~isnan(lastfield2) |
---|
[229] | 1398 | test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 1399 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2); |
---|
| 1400 | num1=num_j(test_find); |
---|
[2] | 1401 | end |
---|
| 1402 | set(handles.first_j,'String',num2str(num1(1))); |
---|
| 1403 | set(handles.last_j,'String',num2str(num1(end))); |
---|
[112] | 1404 | end |
---|
[2] | 1405 | |
---|
[177] | 1406 | %------------------------------------------------------------------------ |
---|
| 1407 | % --- Executes on button press in RUN: processing on local computer |
---|
[67] | 1408 | function RUN_Callback(hObject, eventdata, handles) |
---|
| 1409 | %------------------------------------------------------------------------ |
---|
[73] | 1410 | set(handles.RUN, 'Enable','Off') |
---|
| 1411 | set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[67] | 1412 | batch=0; |
---|
[229] | 1413 | errormsg=launch_jobs(hObject, eventdata, handles,batch); |
---|
[73] | 1414 | set(handles.RUN, 'Enable','On') |
---|
| 1415 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
[36] | 1416 | |
---|
[177] | 1417 | % start status callback to visualise results |
---|
[229] | 1418 | if ~isempty(errormsg) |
---|
| 1419 | display(errormsg) |
---|
| 1420 | msgbox_uvmat('ERROR',errormsg) |
---|
[257] | 1421 | elseif isfield(handles,'status') %&& ~isequal(get(handles.CivMode,'Value'),3) |
---|
[225] | 1422 | set(handles.status,'Value',1);%suppress status display |
---|
| 1423 | status_Callback(hObject, eventdata, handles) |
---|
[178] | 1424 | end |
---|
[177] | 1425 | |
---|
[12] | 1426 | %------------------------------------------------------------------------ |
---|
[2] | 1427 | % --- Executes on button press in BATCH: remote processing |
---|
| 1428 | function BATCH_Callback(hObject, eventdata, handles) |
---|
[177] | 1429 | % ----------------------------------------------------------------------- |
---|
[73] | 1430 | set(handles.BATCH, 'Enable','Off') |
---|
| 1431 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[67] | 1432 | batch=1; |
---|
[229] | 1433 | errormsg=launch_jobs(hObject, eventdata, handles, batch); |
---|
[73] | 1434 | set(handles.BATCH, 'Enable','On') |
---|
| 1435 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
[67] | 1436 | |
---|
[177] | 1437 | % start status callback to visualise results |
---|
[229] | 1438 | if ~isempty(errormsg) |
---|
| 1439 | display(errormsg) |
---|
| 1440 | msgbox_uvmat('ERROR',errormsg) |
---|
| 1441 | elseif isfield(handles,'status') |
---|
| 1442 | set(handles.status,'Value',1);%suppress status display |
---|
| 1443 | status_Callback(hObject, eventdata, handles) |
---|
[178] | 1444 | end |
---|
[227] | 1445 | |
---|
[67] | 1446 | %------------------------------------------------------------------------ |
---|
[133] | 1447 | % --- Lauch command called by RUN and BATCH: remote processing |
---|
[229] | 1448 | function errormsg=launch_jobs(hObject, eventdata, handles, batch) |
---|
[67] | 1449 | %----------------------------------------------------------------------- |
---|
[229] | 1450 | errormsg='';%default |
---|
[133] | 1451 | %% check the selected list of operations: |
---|
[2] | 1452 | operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'}; |
---|
| 1453 | box_test(1)=get(handles.CIV1,'Value'); |
---|
| 1454 | box_test(2)=get(handles.FIX1,'Value'); |
---|
| 1455 | box_test(3)=get(handles.PATCH1,'Value'); |
---|
| 1456 | box_test(4)=get(handles.CIV2,'Value'); |
---|
| 1457 | box_test(5)=get(handles.FIX2,'Value'); |
---|
| 1458 | box_test(6)=get(handles.PATCH2,'Value'); |
---|
[180] | 1459 | index_first=find(box_test==1,1); |
---|
| 1460 | if isempty(index_first) |
---|
[229] | 1461 | errormsg='no selected operation'; |
---|
[2] | 1462 | return |
---|
| 1463 | end |
---|
[180] | 1464 | index_last=find(box_test==1,1,'last'); |
---|
[159] | 1465 | box_used=box_test(index_first : index_last); |
---|
[2] | 1466 | [box_missing,ind_missing]=min(box_used); |
---|
[180] | 1467 | if isequal(box_missing,0); %there is a missing step in the sequence of operations |
---|
[229] | 1468 | errormsg=['missing' cell2mat(operations(ind_missing))]; |
---|
[2] | 1469 | return |
---|
| 1470 | end |
---|
| 1471 | |
---|
[177] | 1472 | %% check mask if selecetd |
---|
[2] | 1473 | if isequal(get(handles.get_mask_civ1,'Value'),1) |
---|
[12] | 1474 | maskname=get(handles.mask_civ1,'String'); |
---|
| 1475 | if ~exist(maskname,'file') |
---|
| 1476 | get_mask_civ1_Callback(hObject, eventdata, handles); |
---|
| 1477 | end |
---|
[2] | 1478 | end |
---|
| 1479 | if isequal(get(handles.get_mask_fix1,'Value'),1) |
---|
[12] | 1480 | maskname=get(handles.mask_fix1,'String'); |
---|
| 1481 | if ~exist(maskname,'file') |
---|
| 1482 | get_mask_fix1_Callback(hObject, eventdata, handles); |
---|
| 1483 | end |
---|
[2] | 1484 | end |
---|
| 1485 | if isequal(get(handles.get_mask_civ2,'Value'),1) |
---|
[12] | 1486 | maskname=get(handles.mask_civ2,'String'); |
---|
| 1487 | if ~exist(maskname,'file') |
---|
[112] | 1488 | get_mask_civ2_Callback(hObject, eventdata, handles); |
---|
[12] | 1489 | end |
---|
[2] | 1490 | end |
---|
| 1491 | if isequal(get(handles.get_mask_fix2,'Value'),1) |
---|
[12] | 1492 | maskname=get(handles.mask_fix2,'String'); |
---|
| 1493 | if ~exist(maskname,'file') |
---|
[112] | 1494 | get_mask_fix2_Callback(hObject, eventdata, handles); |
---|
[12] | 1495 | end |
---|
[2] | 1496 | end |
---|
| 1497 | |
---|
[177] | 1498 | %% reinitialise status callback |
---|
[178] | 1499 | if isfield(handles,'status') |
---|
[180] | 1500 | set(handles.status,'Value',0);%suppress status display |
---|
| 1501 | status_Callback(hObject, eventdata, handles) |
---|
[178] | 1502 | end |
---|
[133] | 1503 | |
---|
| 1504 | %% set the list of files and check them |
---|
| 1505 | display('checking the files...') |
---|
[227] | 1506 | [ref_i,ref_j,errormsg]=find_ref_indices(handles); |
---|
| 1507 | if ~isempty(errormsg) |
---|
| 1508 | return |
---|
| 1509 | end |
---|
[263] | 1510 | [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]=... |
---|
| 1511 | set_civ_filenames(handles,ref_i,ref_j,box_test) |
---|
| 1512 | |
---|
[177] | 1513 | set(handles.civ,'UserData',filecell);%store for futur use of status callback |
---|
[137] | 1514 | if isempty(filecell)% (error message displayed in fct set_civ_filenames) |
---|
[133] | 1515 | return |
---|
| 1516 | end |
---|
| 1517 | nbfield=numel(num1_civ1); |
---|
| 1518 | nbslice=numel(num_a_civ1); |
---|
| 1519 | |
---|
[257] | 1520 | %% choose the batch or run mode |
---|
[133] | 1521 | path_UVMAT=fileparts(which('uvmat')); %path to the source directory of uvmat |
---|
[112] | 1522 | xmlfile='PARAM.xml'; |
---|
[133] | 1523 | if exist(xmlfile,'file')% search parameter xml file in the whole matlab path |
---|
[54] | 1524 | t=xmltree(xmlfile); |
---|
[67] | 1525 | s=convert(t); |
---|
[2] | 1526 | end |
---|
[127] | 1527 | test_interp=0; |
---|
| 1528 | if batch |
---|
[67] | 1529 | if isfield(s,'BatchParam') |
---|
| 1530 | sparam=s.BatchParam; |
---|
[257] | 1531 | if isfield(sparam,'BatchMode') |
---|
| 1532 | batch_mode=sparam.BatchMode; |
---|
| 1533 | if ~ismember(batch_mode,{'sge','oar'}) |
---|
| 1534 | errormsg=['batch mode ' batch_mode ' not supported by UVMAT']; |
---|
| 1535 | return |
---|
| 1536 | end |
---|
[67] | 1537 | end |
---|
| 1538 | else |
---|
[229] | 1539 | errormsg='no batch civ binaries defined in PARAM.xml'; |
---|
[67] | 1540 | return |
---|
| 1541 | end |
---|
[257] | 1542 | |
---|
| 1543 | switch batch_mode |
---|
| 1544 | case 'sge' |
---|
| 1545 | % choice of batch priority: |
---|
| 1546 | ind_answer=2; |
---|
| 1547 | [s,w]=unix('qstat -q civ.q|grep job_| wc -l'); %check the waiting list (command unix) |
---|
| 1548 | if isequal(s,0) |
---|
| 1549 | w(end)=[]; |
---|
| 1550 | str_displ={[w ' jobs in the waiting list'];... |
---|
| 1551 | '***********************';... |
---|
| 1552 | 'JOBS PRIORITY POLICY';... |
---|
| 1553 | '- urgent = less than 100 images pairs';... |
---|
| 1554 | '- normal = during the experiments';... |
---|
| 1555 | '- low = post processing';... |
---|
| 1556 | '***********************';... |
---|
| 1557 | 'Select a priority:'}; |
---|
| 1558 | ' ';... |
---|
| 1559 | str={'urgent';'normal';'low'}; |
---|
| 1560 | [ind_answer,v] = listdlg('PromptString',str_displ,... |
---|
| 1561 | 'SelectionMode','single',... |
---|
| 1562 | 'ListString',str,'ListSize',[200 100],'Name','job priority','InitialValue',3); |
---|
| 1563 | if isequal(v,0) % to handle Cancel button and figure close, |
---|
| 1564 | errormsg='job cancelled'; |
---|
| 1565 | return % a better way should be create |
---|
| 1566 | end |
---|
| 1567 | else |
---|
| 1568 | msgbox_uvmat('ERROR','sge batch system not available') |
---|
| 1569 | return |
---|
| 1570 | end |
---|
[225] | 1571 | end |
---|
[257] | 1572 | else % run |
---|
[67] | 1573 | if isfield(s,'RunParam') |
---|
| 1574 | sparam=s.RunParam; |
---|
| 1575 | else |
---|
[225] | 1576 | msgbox_uvmat('ERROR','no run civ binaries defined in PARAM.xml') |
---|
[67] | 1577 | return |
---|
| 1578 | end |
---|
[225] | 1579 | end |
---|
[238] | 1580 | |
---|
| 1581 | %% choose the civ program |
---|
[257] | 1582 | ProgList=get(handles.CivMode,'String'); |
---|
| 1583 | index=get(handles.CivMode,'Value'); |
---|
| 1584 | % CivX=isequal(ProgList{index},'CivX'); |
---|
| 1585 | % CivAll=isequal(ProgList{index},'CivAll'); |
---|
| 1586 | % CivUvmat=isequal(ProgList{index},'CivUvmat'); |
---|
| 1587 | CivMode=ProgList{index}; |
---|
| 1588 | %CivMode=isequal(get(handles.CivMode,'Value'),2); % Boolean for new civ programs |
---|
| 1589 | |
---|
| 1590 | switch CivMode |
---|
| 1591 | case 'CivAll' |
---|
| 1592 | if isfield(sparam,'CivBin') |
---|
| 1593 | CivBin=sparam.CivBin; |
---|
[260] | 1594 | if ~exist(CivBin,'file') || isempty(which(CivBin))% if path defined as relative to uvmat |
---|
[257] | 1595 | sparam.CivBin=fullfile(path_UVMAT,CivBin); |
---|
| 1596 | if ~exist(sparam.CivBin,'file') |
---|
| 1597 | msgbox_uvmat('ERROR',['CIVx binary ' CivBin ' defined in PARAM.xm does not exist']) |
---|
| 1598 | return |
---|
| 1599 | end |
---|
| 1600 | end |
---|
[112] | 1601 | end |
---|
[257] | 1602 | case 'CivX' |
---|
| 1603 | if isfield(sparam,'Civ1Bin') |
---|
| 1604 | Civ1Bin=sparam.Civ1Bin; |
---|
[263] | 1605 | if ~exist(Civ1Bin,'file')&&~isempty(which(Civ1Bin))% if path defined as relative to uvmat |
---|
[257] | 1606 | sparam.Civ1Bin=fullfile(path_UVMAT,Civ1Bin); |
---|
| 1607 | if ~exist(sparam.Civ1Bin,'file') |
---|
| 1608 | msgbox_uvmat('ERROR',['civ1 binary ' Civ1Bin ' defined in PARAM.xm does not exist']) |
---|
| 1609 | return |
---|
| 1610 | end |
---|
| 1611 | end |
---|
[112] | 1612 | end |
---|
[257] | 1613 | if isfield(sparam,'Civ2Bin') |
---|
| 1614 | Civ2Bin=sparam.Civ2Bin; |
---|
[263] | 1615 | if ~exist(Civ2Bin,'file')&&~isempty(which(Civ2Bin))% if path defined as relative to uvmat |
---|
[257] | 1616 | sparam.Civ2Bin=fullfile(path_UVMAT,Civ2Bin); |
---|
| 1617 | if ~exist(sparam.Civ2Bin,'file') |
---|
| 1618 | msgbox_uvmat('ERROR',['civ2 binary ' Civ2Bin ' defined in PARAM.xm does not exist']) |
---|
| 1619 | return |
---|
| 1620 | end |
---|
| 1621 | end |
---|
[112] | 1622 | end |
---|
[257] | 1623 | if isfield(sparam,'PatchBin') |
---|
[263] | 1624 | if ~exist(sparam.PatchBin,'file')&&~isempty(which(sparam.PatchBin))% if path defined as relative to uvmat |
---|
[257] | 1625 | sparam.PatchBin=fullfile(path_UVMAT,sparam.PatchBin); |
---|
| 1626 | end |
---|
| 1627 | end |
---|
| 1628 | if isfield(sparam,'FixBin') |
---|
[263] | 1629 | if ~exist(sparam.FixBin,'file')&&~isempty(which(sparam.FixBin))% if path defined as relative to uvmat |
---|
[257] | 1630 | sparam.FixBin=fullfile(path_UVMAT,sparam.FixBin); |
---|
| 1631 | end |
---|
| 1632 | end |
---|
| 1633 | case 'Matlab' |
---|
| 1634 | if batch |
---|
| 1635 | %% vérifier Mtlab installé sur le cluster |
---|
| 1636 | end |
---|
[225] | 1637 | end |
---|
[2] | 1638 | |
---|
| 1639 | |
---|
[225] | 1640 | |
---|
[133] | 1641 | %% get civ1 parameters: |
---|
[112] | 1642 | display('files OK, processing...') |
---|
[2] | 1643 | if box_test(1)==1 |
---|
| 1644 | par_civ1=read_param_civ1(handles,filecell.ima1.civ1{1,1}); |
---|
[112] | 1645 | end |
---|
[2] | 1646 | |
---|
[257] | 1647 | %% get fix1 parameters TODO : par_fix1=read_param_fix1(handles); |
---|
[112] | 1648 | if box_test(2)==1 |
---|
[2] | 1649 | flagindex1(1)=get(handles.vec_Fmin2, 'Value'); |
---|
| 1650 | flagindex1(2)=get(handles.vec_F3, 'Value'); |
---|
| 1651 | flagindex1(3)=get(handles.vec_F2, 'Value'); |
---|
[127] | 1652 | thresh_vecC1=str2double(get(handles.thresh_vecC,'String'));%threshold on image correlation vec_C |
---|
| 1653 | thresh_vel1=str2double(get(handles.thresh_vel,'String'));%threshold on velocity modulus |
---|
[2] | 1654 | test_mask=get(handles.get_mask_fix1,'Value'); |
---|
| 1655 | nbslice_mask=get(handles.mask_fix1,'UserData'); % get the number of slices (= number of masks) |
---|
| 1656 | %%%%%%%%%%%%%COMPLETER LE PROGRAMME FIX |
---|
[112] | 1657 | % inf_sup=get(handles.inf_sup1,'Value');80 |
---|
| 1658 | % fileref=get(handles.ref_fix1,'String'); |
---|
| 1659 | % refpath=get(handles.ref_fix1,'UserData'); |
---|
| 1660 | % fileref=fullfile(refpath,fileref); |
---|
[2] | 1661 | menu=get(handles.field_ref1,'String'); |
---|
| 1662 | index=get(handles.field_ref1,'Value'); |
---|
| 1663 | if isempty(menu) |
---|
| 1664 | fieldchoice=''; |
---|
| 1665 | else |
---|
| 1666 | fieldchoice=menu{index}; |
---|
[112] | 1667 | msgbox_uvmat('WARNING','reference field is not used presently with batch, use RUN option') |
---|
| 1668 | end |
---|
[2] | 1669 | end |
---|
[112] | 1670 | |
---|
[133] | 1671 | %% get patch1 parameters |
---|
[67] | 1672 | if box_test(3)==1 |
---|
[127] | 1673 | rho_patch1=str2double(get(handles.rho_patch1,'String')); |
---|
| 1674 | if isnan(rho_patch1) |
---|
[112] | 1675 | rho_patch1='1000'; |
---|
| 1676 | set(handles.rho_patch1,'String','1') |
---|
| 1677 | else |
---|
| 1678 | rho_patch1=num2str(1000*rho_patch1); |
---|
| 1679 | end |
---|
| 1680 | nx_patch1=get(handles.nx_patch1,'String'); |
---|
| 1681 | ny_patch1=get(handles.ny_patch1,'String'); |
---|
[127] | 1682 | if isnan(str2double(nx_patch1)) |
---|
[112] | 1683 | nx_patch1='50' ;%default |
---|
| 1684 | set(handles.nx_patch1,'String','50'); |
---|
| 1685 | end |
---|
[127] | 1686 | if isnan(str2double(ny_patch1)) |
---|
[112] | 1687 | ny_patch1='50' ;%default |
---|
| 1688 | set(handles.ny_patch1,'String','50'); |
---|
| 1689 | end |
---|
| 1690 | subdomain_patch1=get(handles.subdomain_patch1,'String'); |
---|
| 1691 | thresh_patch1=get(handles.thresh_patch1,'String'); |
---|
| 1692 | end |
---|
| 1693 | |
---|
[133] | 1694 | %% get civ2 parameters: |
---|
[2] | 1695 | if box_test(4)==1 |
---|
| 1696 | par_civ2=read_param_civ2(handles,cell2mat(filecell.ima1.civ2(1,1))); |
---|
| 1697 | end |
---|
| 1698 | |
---|
[133] | 1699 | %% get fix2 parameters |
---|
[112] | 1700 | if box_test(5)==1 |
---|
[2] | 1701 | flagindex2(1)=get(handles.vec_Fmin2_2, 'Value'); |
---|
| 1702 | flagindex2(2)=get(handles.vec_F3_2, 'Value'); |
---|
| 1703 | flagindex2(3)=get(handles.vec_F4, 'Value'); |
---|
[127] | 1704 | thresh_vec2C=str2double(get(handles.thresh_vec2C,'String'));%threshold on image correlation vec_C |
---|
| 1705 | thresh_vel2=str2double(get(handles.thresh_vel2,'String'));%threshold on velocity modulus |
---|
[2] | 1706 | test_mask=get(handles.get_mask_fix2,'Value'); |
---|
| 1707 | nbslice_mask=get(handles.mask_fix2,'UserData'); % get the number of slices (= number of masks) |
---|
[112] | 1708 | %%%%%%%%%%%%%COMPLETER LE PROGRAMME FIX AVEC REF FILE ET OPTION inf_sup=2 |
---|
| 1709 | % inf_sup=get(handles.inf_sup2,'Value'); |
---|
| 1710 | % ref=get(handles.ref_fix2,'UserData'); |
---|
| 1711 | |
---|
[2] | 1712 | %%%%%%%%%%%%%%%%%%% |
---|
| 1713 | end |
---|
| 1714 | |
---|
[133] | 1715 | %% get patch2 parameters |
---|
[2] | 1716 | if box_test(6)==1 |
---|
[127] | 1717 | rho_patch2=str2double(get(handles.rho_patch2,'String')); |
---|
| 1718 | if isnan(rho_patch2) |
---|
[2] | 1719 | rho_patch2='1000'; |
---|
| 1720 | set(handles.rho_patch2,'String','1') |
---|
| 1721 | else |
---|
| 1722 | rho_patch2=num2str(1000*rho_patch2); |
---|
| 1723 | end |
---|
| 1724 | nx_patch2=get(handles.nx_patch2,'String'); |
---|
| 1725 | ny_patch2=get(handles.ny_patch2,'String'); |
---|
[127] | 1726 | if isnan(str2double(nx_patch2)) |
---|
[2] | 1727 | nx_patch2='50' ;%default |
---|
| 1728 | set(handles.nx_patch2,'String','50'); |
---|
| 1729 | end |
---|
[127] | 1730 | if isnan(str2double(ny_patch2)) |
---|
[2] | 1731 | ny_patch2='50' ;%default |
---|
| 1732 | set(handles.ny_patch2,'String','50'); |
---|
| 1733 | end |
---|
| 1734 | subdomain_patch2=get(handles.subdomain_patch2,'String'); |
---|
| 1735 | thresh_patch2=get(handles.thresh_patch2,'String'); |
---|
| 1736 | end |
---|
| 1737 | |
---|
[133] | 1738 | %% MAIN LOOP |
---|
[71] | 1739 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
[134] | 1740 | super_cmd=[]; |
---|
| 1741 | |
---|
[2] | 1742 | for ifile=1:nbfield |
---|
| 1743 | for j=1:nbslice |
---|
[257] | 1744 | % initiate system command |
---|
[112] | 1745 | i_cmd=0; |
---|
[257] | 1746 | switch CivMode |
---|
| 1747 | case 'CivX' |
---|
| 1748 | cmd=''; |
---|
| 1749 | if isunix % check: necessaire aussi en RUN? |
---|
| 1750 | cmd='#!/bin/bash \n'; |
---|
| 1751 | cmd=[cmd '#$ -cwd \n']; |
---|
| 1752 | cmd=[cmd 'hostname && date \n']; |
---|
| 1753 | cmd=[cmd 'umask 002 \n'];%allow writting access to created files for user group |
---|
| 1754 | end |
---|
| 1755 | case 'CivAll' |
---|
| 1756 | % if CivAll |
---|
| 1757 | CivAllxml=xmltree;% xml contents, all parameters |
---|
| 1758 | CivAllCmd=''; |
---|
| 1759 | CivAllxml=set(CivAllxml,1,'name','CivDoc'); |
---|
[2] | 1760 | end |
---|
[263] | 1761 | [Rootbat,Filebat]=fileparts(filecell.nc.civ1{ifile,j});%output netcdf file (without extension) |
---|
[177] | 1762 | flname=fullfile(Rootbat,Filebat); |
---|
[159] | 1763 | if batch |
---|
[174] | 1764 | filename_bat=fullfile(Rootbat,['job_' Filebat]); |
---|
[257] | 1765 | else |
---|
[177] | 1766 | filename_bat=flname; |
---|
[159] | 1767 | end |
---|
[174] | 1768 | filename_bat=[filename_bat '.bat']; |
---|
[2] | 1769 | |
---|
[112] | 1770 | %CIV1 |
---|
[2] | 1771 | if box_test(1)==1 |
---|
[41] | 1772 | par_civ1.filename_ima_a=filecell.ima1.civ1{ifile,j}; |
---|
[112] | 1773 | par_civ1.filename_ima_b=filecell.ima2.civ1{ifile,j}; |
---|
[2] | 1774 | par_civ1.Dt=num2str(time(num2_civ1(ifile),num_b_civ1(j))-time(num1_civ1(ifile),num_a_civ1(j))); |
---|
[112] | 1775 | par_civ1.T0=num2str((time(num2_civ1(ifile),num_b_civ1(j))+time(num1_civ1(ifile),num_a_civ1(j)))/2); |
---|
[2] | 1776 | par_civ1.term_a=num2stra(num_a_civ1(j),nom_type_nc);%UTILITE? |
---|
[112] | 1777 | par_civ1.term_b=num2stra(num_b_civ1(j),nom_type_nc);% |
---|
[2] | 1778 | test_mask=get(handles.get_mask_civ1,'Value'); |
---|
[112] | 1779 | if test_mask==0 |
---|
[2] | 1780 | par_civ1.maskname='noFile use default'; |
---|
| 1781 | par_civ1.maskflag='n'; |
---|
| 1782 | else |
---|
| 1783 | maskdispl=get(handles.mask_civ1,'String'); |
---|
[12] | 1784 | if exist(maskdispl,'file') |
---|
| 1785 | par_civ1.maskname=maskdispl; |
---|
[112] | 1786 | par_civ1.maskflag='y'; |
---|
[2] | 1787 | else |
---|
[136] | 1788 | maskbase=[filecell.filebase '_' maskdispl]; % |
---|
[137] | 1789 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
[12] | 1790 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
| 1791 | par_civ1.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 1792 | if exist(par_civ1.maskname,'file') |
---|
[82] | 1793 | par_civ1.maskflag='y'; |
---|
[12] | 1794 | else |
---|
| 1795 | par_civ1.maskname='noFile use default'; |
---|
[112] | 1796 | par_civ1.maskflag='n'; |
---|
[12] | 1797 | end |
---|
[2] | 1798 | end |
---|
| 1799 | end |
---|
| 1800 | test_grid=get(handles.browse_gridciv1,'Value'); |
---|
| 1801 | if test_grid |
---|
| 1802 | par_civ1.gridflag='y'; |
---|
| 1803 | gridname=get(handles.grid_civ1,'String'); |
---|
| 1804 | if isequal(gridname(end-3:end),'grid') |
---|
[137] | 1805 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 1806 | if ~isnan(nbslice_grid) |
---|
[2] | 1807 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
[136] | 1808 | par_civ1.gridname=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
[2] | 1809 | if ~exist(par_civ1.gridname,'file') |
---|
[112] | 1810 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
[2] | 1811 | end |
---|
| 1812 | elseif exist(gridname,'file') |
---|
[112] | 1813 | par_civ1.gridname=gridname; |
---|
[2] | 1814 | else |
---|
| 1815 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
| 1816 | end |
---|
| 1817 | end |
---|
| 1818 | else |
---|
[112] | 1819 | par_civ1.gridname='noFile use default'; |
---|
| 1820 | par_civ1.gridflag='n'; |
---|
[2] | 1821 | end |
---|
[257] | 1822 | |
---|
[2] | 1823 | i_cmd=i_cmd+1; |
---|
[257] | 1824 | switch CivMode |
---|
| 1825 | case 'CivX' |
---|
| 1826 | civ1_exe=CIV1_CMD(fullfile(Rootbat,Filebat),'',par_civ1,handles,sparam);%create the parameter file .civ1.cmx and set the execution string civ1_exe |
---|
| 1827 | cmd=[cmd civ1_exe '\n']; |
---|
| 1828 | case 'CivAll' |
---|
| 1829 | CivAllCmd=[CivAllCmd ' civ1 ']; |
---|
| 1830 | str=CIV1_CMD_Unified(fullfile(Rootbat,Filebat),'',par_civ1); |
---|
| 1831 | fieldnames=fields(str); |
---|
| 1832 | [CivAllxml,uid_civ1]=add(CivAllxml,1,'element','civ1'); |
---|
| 1833 | for ilist=1:length(fieldnames) |
---|
| 1834 | val=eval(['str.' fieldnames{ilist}]); |
---|
| 1835 | if ischar(val) |
---|
| 1836 | [CivAllxml,uid_t]=add(CivAllxml,uid_civ1,'element',fieldnames{ilist}); |
---|
| 1837 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 1838 | end |
---|
[112] | 1839 | end |
---|
[2] | 1840 | end |
---|
| 1841 | end |
---|
| 1842 | |
---|
[112] | 1843 | % FIX1 |
---|
| 1844 | if box_test(2)==1 |
---|
| 1845 | test_mask=get(handles.get_mask_fix1,'Value'); |
---|
| 1846 | if test_mask==0 |
---|
[2] | 1847 | maskname=''; |
---|
[112] | 1848 | else |
---|
[2] | 1849 | maskdispl=get(handles.mask_fix1,'String'); |
---|
[137] | 1850 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
[2] | 1851 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
[136] | 1852 | maskbase=[filecell.filebase '_' maskdispl]; |
---|
[2] | 1853 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
[112] | 1854 | end |
---|
[257] | 1855 | switch CivMode |
---|
| 1856 | % if CivX |
---|
| 1857 | case 'CivX' |
---|
| 1858 | if isunix %unix system |
---|
| 1859 | cmd_FIX=[sparam.FixBin ' -f ' filecell.nc.civ1{ifile,j} ' -fi1 ' num2str(flagindex1(1)) ... |
---|
| 1860 | ' -fi2 ' num2str(flagindex1(2)) ' -fi3 ' num2str(flagindex1(3)) ... |
---|
| 1861 | ' -threshC ' num2str(thresh_vecC1) ' -threshV ' num2str(thresh_vel1) ' -maskName ' maskname]; |
---|
| 1862 | else %windows system |
---|
| 1863 | cmd_FIX=['"' sparam.FixBin '" -f "' filecell.nc.civ1{ifile,j} '" -fi1 ' num2str(flagindex1(1)) ... |
---|
| 1864 | ' -fi2 ' num2str(flagindex1(2)) ' -fi3 ' num2str(flagindex1(3)) ... |
---|
| 1865 | ' -threshC ' num2str(thresh_vecC1) ' -threshV ' num2str(thresh_vel1) ' -maskName "' maskname '"']; |
---|
| 1866 | cmd_FIX=regexprep(cmd_FIX,'\\','\\\\'); |
---|
[112] | 1867 | end |
---|
[257] | 1868 | cmd=[cmd cmd_FIX '\n']; |
---|
| 1869 | case 'CivAll' |
---|
| 1870 | fix1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 1871 | fix1.fi1=num2str(flagindex1(1)); |
---|
| 1872 | fix1.fi2=num2str(flagindex1(2)); |
---|
| 1873 | fix1.fi3=num2str(flagindex1(3)); |
---|
| 1874 | fix1.threshC=num2str(thresh_vecC1); |
---|
| 1875 | fix1.threshV=num2str(thresh_vel1); |
---|
| 1876 | fieldnames=fields(fix1); |
---|
| 1877 | [CivAllxml,uid_fix1]=add(CivAllxml,1,'element','fix1'); |
---|
| 1878 | for ilist=1:length(fieldnames) |
---|
| 1879 | val=eval(['fix1.' fieldnames{ilist}]); |
---|
| 1880 | if ischar(val) |
---|
| 1881 | [CivAllxml,uid_t]=add(CivAllxml,uid_fix1,'element',fieldnames{ilist}); |
---|
| 1882 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 1883 | end |
---|
| 1884 | end |
---|
| 1885 | CivAllCmd=[CivAllCmd ' fix1 ']; |
---|
[112] | 1886 | end |
---|
| 1887 | end |
---|
| 1888 | |
---|
| 1889 | %PATCH1 |
---|
| 1890 | if box_test(3)==1 |
---|
[257] | 1891 | switch CivMode |
---|
| 1892 | case 'CivX' |
---|
| 1893 | cmd_PATCH=PATCH_CMD(filecell.nc.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp,sparam.PatchBin); |
---|
| 1894 | cmd=[cmd cmd_PATCH '\n']; |
---|
| 1895 | case 'CivAll' |
---|
| 1896 | patch1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 1897 | patch1.nopt=subdomain_patch1; |
---|
| 1898 | patch1.maxdiff=thresh_patch1; |
---|
| 1899 | patch1.ro=rho_patch1; |
---|
| 1900 | test_grid=get(handles.get_gridpatch1,'Value'); |
---|
| 1901 | if test_grid |
---|
| 1902 | patch1.gridflag='y'; |
---|
| 1903 | gridname=get(handles.grid_patch1,'String'); |
---|
| 1904 | if isequal(gridname(end-3:end),'grid') |
---|
| 1905 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 1906 | if ~isnan(nbslice_grid) |
---|
| 1907 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
| 1908 | patch1.gridPatch=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 1909 | if ~exist(patch1.gridPatch,'file') |
---|
| 1910 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
| 1911 | end |
---|
| 1912 | elseif exist(gridname,'file') |
---|
| 1913 | patch1.gridPatch=gridname; |
---|
| 1914 | else |
---|
[112] | 1915 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
| 1916 | end |
---|
[2] | 1917 | end |
---|
[257] | 1918 | else |
---|
| 1919 | patch1.gridPatch='none'; |
---|
| 1920 | patch1.gridflag='n'; |
---|
| 1921 | patch1.m=nx_patch1; |
---|
| 1922 | patch1.n=ny_patch1; |
---|
[2] | 1923 | end |
---|
[257] | 1924 | patch1.convectFlow='n'; |
---|
| 1925 | fieldnames=fields(patch1); |
---|
| 1926 | [CivAllxml,uid_patch1]=add(CivAllxml,1,'element','patch1'); |
---|
| 1927 | for ilist=1:length(fieldnames) |
---|
| 1928 | val=eval(['patch1.' fieldnames{ilist}]); |
---|
| 1929 | if ischar(val) |
---|
| 1930 | [CivAllxml,uid_t]=add(CivAllxml,uid_patch1,'element',fieldnames{ilist}); |
---|
| 1931 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 1932 | end |
---|
[112] | 1933 | end |
---|
[257] | 1934 | CivAllCmd=[CivAllCmd ' patch1 ']; |
---|
[112] | 1935 | end |
---|
[2] | 1936 | end |
---|
[127] | 1937 | if box_test(4)==1 || box_test(5)==1 || box_test(6)==1 |
---|
[112] | 1938 | filename_cmx=filecell.nc.civ2{ifile,j};%output netcdf file |
---|
[229] | 1939 | filename_cmx(end-1:end+1)='cmx';%name of cmx file |
---|
[112] | 1940 | end |
---|
| 1941 | if box_test(4)==1 |
---|
[2] | 1942 | par_civ2.filename_ima_a=filecell.ima1.civ2{ifile,j}; |
---|
| 1943 | par_civ2.filename_ima_b=filecell.ima2.civ2{ifile,j}; |
---|
[174] | 1944 | [Rootbat,Filebat]=fileparts(filecell.nc.civ2{ifile,j});%output netcdf file (without extention) |
---|
[2] | 1945 | par_civ2.Dt=num2str(time(num2_civ2(ifile),num_b_civ2(j))-time(num1_civ2(ifile),num_a_civ2(j))); |
---|
[112] | 1946 | par_civ2.T0=num2str((time(num2_civ1(ifile),num_b_civ2(j))+time(num1_civ2(ifile),num_a_civ2(j)))/2); |
---|
[2] | 1947 | par_civ2.term_a=num2stra(num_a_civ2(j),nom_type_nc); |
---|
[112] | 1948 | par_civ2.term_b=num2stra(num_b_civ2(j),nom_type_nc); |
---|
[2] | 1949 | par_civ2.filename_nc1=filecell.nc.civ1{ifile,j}; |
---|
[229] | 1950 | par_civ2.filename_nc1(end-2:end)=[]; % remove '.nc' |
---|
[2] | 1951 | test_mask=get(handles.get_mask_civ2,'Value'); |
---|
[112] | 1952 | if test_mask==0 |
---|
[2] | 1953 | par_civ2.maskname='noFile use default'; |
---|
| 1954 | par_civ2.maskflag='n'; |
---|
| 1955 | else |
---|
| 1956 | maskdispl=get(handles.mask_civ2,'String'); |
---|
[12] | 1957 | if exist(maskdispl,'file') |
---|
| 1958 | par_civ2.maskname=maskdispl; |
---|
| 1959 | par_civ2.maskflag='y'; |
---|
[2] | 1960 | else |
---|
[136] | 1961 | maskbase=[filecell.filebase '_' maskdispl]; % |
---|
[137] | 1962 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
[12] | 1963 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
| 1964 | par_civ2.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 1965 | if exist(par_civ2.maskname,'file') |
---|
[112] | 1966 | par_civ2.maskflag='y'; |
---|
[12] | 1967 | else |
---|
| 1968 | par_civ2.maskname='noFile use default'; |
---|
[112] | 1969 | par_civ2.maskflag='n'; |
---|
[12] | 1970 | end |
---|
[2] | 1971 | end |
---|
| 1972 | end |
---|
| 1973 | gridname=get(handles.grid_civ2,'String'); |
---|
| 1974 | if numel(gridname)>=4 && isequal(gridname(end-3:end),'grid') |
---|
[137] | 1975 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 1976 | if ~isnan(nbslice_grid) |
---|
[2] | 1977 | par_civ2.gridflag='y'; |
---|
| 1978 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
[136] | 1979 | par_civ2.gridname=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
[2] | 1980 | if exist(par_civ2.gridname,'file') |
---|
[112] | 1981 | par_civ2.gridflag='y'; |
---|
[2] | 1982 | else |
---|
| 1983 | par_civ2.gridname='noFile use default'; |
---|
[112] | 1984 | par_civ2.gridflag='n'; |
---|
[2] | 1985 | end |
---|
| 1986 | elseif exist(gridname,'file') |
---|
[112] | 1987 | par_civ2.gridflag='y'; |
---|
[2] | 1988 | else |
---|
| 1989 | par_civ2.gridname='noFile use default'; |
---|
[112] | 1990 | par_civ2.gridflag='n'; |
---|
[2] | 1991 | end |
---|
| 1992 | end |
---|
| 1993 | i_cmd=i_cmd+1; |
---|
[177] | 1994 | flname=fullfile(Rootbat,Filebat); |
---|
[257] | 1995 | switch CivMode |
---|
| 1996 | case 'CivX' |
---|
| 1997 | cmd_CIV2=CIV2_CMD(flname,[],par_civ2,sparam);%creates the cmx file [fullfile(Rootbat,Filebat) '.civ2.cmx] |
---|
| 1998 | cmd=[cmd cmd_CIV2 '\n']; |
---|
| 1999 | case 'CivAll' |
---|
| 2000 | CivAllCmd=[CivAllCmd ' civ2 ']; |
---|
| 2001 | str=CIV2_CMD_Unified(flname,'',par_civ2); |
---|
| 2002 | fieldnames=fields(str); |
---|
| 2003 | [CivAllxml,uid_civ2]=add(CivAllxml,1,'element','civ2'); |
---|
| 2004 | for ilist=1:length(fieldnames) |
---|
| 2005 | val=eval(['str.' fieldnames{ilist}]); |
---|
| 2006 | if ischar(val) |
---|
| 2007 | [CivAllxml,uid_t]=add(CivAllxml,uid_civ2,'element',fieldnames{ilist}); |
---|
| 2008 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 2009 | end |
---|
[2] | 2010 | end |
---|
| 2011 | end |
---|
[112] | 2012 | end |
---|
| 2013 | |
---|
| 2014 | % FIX2 |
---|
| 2015 | if box_test(5)==1 |
---|
| 2016 | test_mask=get(handles.get_mask_fix2,'Value'); |
---|
| 2017 | if test_mask==0 |
---|
| 2018 | maskname=''; %no mask used |
---|
[2] | 2019 | else |
---|
| 2020 | maskdispl=get(handles.mask_fix2,'String'); |
---|
[136] | 2021 | maskbase=[filecell.filebase '_' maskdispl]; % |
---|
[137] | 2022 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
[2] | 2023 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
| 2024 | maskname =name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
[112] | 2025 | end |
---|
[257] | 2026 | switch CivMode |
---|
| 2027 | case 'CivX' |
---|
| 2028 | if isunix |
---|
| 2029 | cmd_FIX=[sparam.FixBin ' -f ' filecell.nc.civ2{ifile,j} ' -fi1 ' num2str(flagindex2(1)) ... |
---|
| 2030 | ' -fi2 ' num2str(flagindex2(2)) ' -fi3 ' num2str(flagindex2(3)) ... |
---|
| 2031 | ' -threshC ' num2str(thresh_vec2C) ' -threshV ' num2str(thresh_vel2) ' -maskName ' maskname]; |
---|
| 2032 | else |
---|
| 2033 | cmd_FIX=['"' sparam.FixBin '" -f "' filecell.nc.civ2{ifile,j} '" -fi1 ' num2str(flagindex2(1)) ... |
---|
| 2034 | ' -fi2 ' num2str(flagindex2(2)) ' -fi3 ' num2str(flagindex2(3)) ... |
---|
| 2035 | ' -threshC ' num2str(thresh_vec2C) ' -threshV ' num2str(thresh_vel2) ' -maskName "' maskname '"']; |
---|
| 2036 | cmd_FIX=regexprep(cmd_FIX,'\\','\\\\'); |
---|
[112] | 2037 | end |
---|
[257] | 2038 | cmd=[cmd cmd_FIX '\n']; |
---|
| 2039 | case 'CivAll' |
---|
| 2040 | fix2.inputFileName=filecell.nc.civ2{ifile,j} ; |
---|
| 2041 | fix2.fi1=num2str(flagindex2(1)); |
---|
| 2042 | fix2.fi2=num2str(flagindex2(2)); |
---|
| 2043 | fix2.fi3=num2str(flagindex2(3)); |
---|
| 2044 | fix2.threshC=num2str(thresh_vec2C); |
---|
| 2045 | fix2.threshV=num2str(thresh_vel2); |
---|
| 2046 | fieldnames=fields(fix2); |
---|
| 2047 | [CivAllxml,uid_fix2]=add(CivAllxml,1,'element','fix2'); |
---|
| 2048 | for ilist=1:length(fieldnames) |
---|
| 2049 | val=eval(['fix2.' fieldnames{ilist}]); |
---|
| 2050 | if ischar(val) |
---|
| 2051 | [CivAllxml,uid_t]=add(CivAllxml,uid_fix2,'element',fieldnames{ilist}); |
---|
| 2052 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 2053 | end |
---|
| 2054 | end |
---|
| 2055 | CivAllCmd=[CivAllCmd ' fix2 ']; |
---|
[112] | 2056 | end |
---|
| 2057 | end |
---|
| 2058 | |
---|
| 2059 | %PATCH2 |
---|
| 2060 | if box_test(6)==1 |
---|
[257] | 2061 | switch CivMode |
---|
| 2062 | case 'CivX' |
---|
| 2063 | cmd_PATCH=PATCH_CMD(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,test_interp,sparam.PatchBin); |
---|
| 2064 | cmd=[cmd cmd_PATCH '\n']; |
---|
| 2065 | case 'CivAll' |
---|
| 2066 | patch2.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 2067 | patch2.nopt=subdomain_patch2; |
---|
| 2068 | patch2.maxdiff=thresh_patch2; |
---|
| 2069 | patch2.ro=rho_patch2; |
---|
| 2070 | test_grid=get(handles.get_gridpatch2,'Value'); |
---|
| 2071 | if test_grid |
---|
| 2072 | patch2.gridflag='y'; |
---|
| 2073 | gridname=get(handles.grid_patch2,'String'); |
---|
| 2074 | if isequal(gridname(end-3:end),'grid') |
---|
| 2075 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 2076 | if ~isnan(nbslice_grid) |
---|
| 2077 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
| 2078 | patch2.gridPatch=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 2079 | if ~exist(patch2.gridPatch,'file') |
---|
| 2080 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
| 2081 | end |
---|
| 2082 | elseif exist(gridname,'file') |
---|
| 2083 | patch2.gridPatch=gridname; |
---|
| 2084 | else |
---|
[112] | 2085 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
[12] | 2086 | end |
---|
[2] | 2087 | end |
---|
[257] | 2088 | else |
---|
| 2089 | patch2.gridPatch='none'; |
---|
| 2090 | patch2.gridflag='n'; |
---|
| 2091 | patch2.m=nx_patch2; |
---|
| 2092 | patch2.n=ny_patch2; |
---|
[2] | 2093 | end |
---|
[257] | 2094 | patch2.convectFlow='n'; |
---|
| 2095 | fieldnames=fields(patch2); |
---|
| 2096 | [CivAllxml,uid_patch2]=add(CivAllxml,1,'element','patch2'); |
---|
| 2097 | for ilist=1:length(fieldnames) |
---|
| 2098 | val=eval(['patch2.' fieldnames{ilist}]); |
---|
| 2099 | if ischar(val) |
---|
| 2100 | [CivAllxml,uid_t]=add(CivAllxml,uid_patch2,'element',fieldnames{ilist}); |
---|
| 2101 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 2102 | end |
---|
[112] | 2103 | end |
---|
[257] | 2104 | CivAllCmd=[CivAllCmd ' patch2 ']; |
---|
[112] | 2105 | end |
---|
[12] | 2106 | end |
---|
[257] | 2107 | |
---|
| 2108 | switch CivMode |
---|
| 2109 | case {'CivX','CivAll'} |
---|
| 2110 | if isequal(CivMode,'CivAll') |
---|
| 2111 | save(CivAllxml,[flname '.xml']); |
---|
| 2112 | cmd=[cmd sparam.CivBin ' -f ' flname '.xml ' CivAllCmd ' >' flname '.log' '\n']; |
---|
[238] | 2113 | end |
---|
[257] | 2114 | % create the .bat file: |
---|
| 2115 | [fid,message]=fopen(filename_bat,'w'); |
---|
| 2116 | if isequal(fid,-1) |
---|
| 2117 | msgbox_uvmat('ERROR', ['creation of .bat file: ' message]) |
---|
| 2118 | return |
---|
[238] | 2119 | end |
---|
[257] | 2120 | fprintf(fid,cmd); |
---|
| 2121 | fclose(fid); |
---|
| 2122 | if batch |
---|
| 2123 | switch batch_mode |
---|
| 2124 | case 'sge' |
---|
| 2125 | pvalue=num2str((1-ind_answer)*500); |
---|
| 2126 | display(['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]); |
---|
| 2127 | eval( ['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]); |
---|
| 2128 | case 'oar' |
---|
| 2129 | eval( ['!chmod +x ' filename_bat]); |
---|
[262] | 2130 | eval( ['!oarsub -n CIVX -l /core=1,walltime=00:10:00 ' filename_bat]); |
---|
[257] | 2131 | end |
---|
[238] | 2132 | else |
---|
[257] | 2133 | %% to lauch the jobs locally : |
---|
| 2134 | if(isunix) |
---|
| 2135 | cmd_str=['. ' filename_bat]; |
---|
| 2136 | else %case of Windows |
---|
| 2137 | cmd_str=['@call "' regexprep(filename_bat,'\\','\\\\') '"']; |
---|
| 2138 | end |
---|
| 2139 | super_cmd=[super_cmd cmd_str '\n']; |
---|
| 2140 | disp(cmd_str); |
---|
[252] | 2141 | end |
---|
[257] | 2142 | case 'Matlab' |
---|
| 2143 | drawnow |
---|
| 2144 | if box_test(1)==1 |
---|
| 2145 | Param.Civ1=par_civ1; |
---|
[252] | 2146 | end |
---|
[257] | 2147 | if box_test(2)==1 |
---|
| 2148 | fix1.WarnFlags=[]; |
---|
| 2149 | if get(handles.vec_Fmin2,'Value') |
---|
| 2150 | fix1.WarnFlags=[fix1.WarnFlags -2]; |
---|
| 2151 | end |
---|
| 2152 | if get(handles.vec_F3,'Value') |
---|
| 2153 | fix1.WarnFlags=[fix1.WarnFlags 3]; |
---|
| 2154 | end |
---|
| 2155 | fix1.LowerBoundCorr=thresh_vecC1; |
---|
| 2156 | if get(handles.inf_sup1,'Value') |
---|
| 2157 | fix1.UppperBoundVel=thresh_vel1; |
---|
| 2158 | else |
---|
| 2159 | fix1.LowerBoundVel=thresh_vel1; |
---|
| 2160 | end |
---|
| 2161 | if get(handles.get_mask_fix1,'Value') |
---|
| 2162 | fix1.MaskName=maskname; |
---|
| 2163 | end |
---|
| 2164 | Param.Fix1=fix1; |
---|
[252] | 2165 | end |
---|
[257] | 2166 | if box_test(3)==1 |
---|
[263] | 2167 | if strcmp(compare,'stereo PIV') |
---|
| 2168 | filebase_A=filecell.filebase; |
---|
| 2169 | [pp,ff]=fileparts(filebase_A); |
---|
| 2170 | filebase_B=fullfile(pp,get(handles.RootName_1,'String')); |
---|
| 2171 | RUN_STLIN(filecell.ncA.civ1{ifile,j},filecell.nc.civ1{ifile,j},'civ1',filecell.st{ifile,j},... |
---|
| 2172 | str2num(nx_patch1),str2num(ny_patch1),str2num(thresh_patch1),[filebase_A '.xml'],[filebase_B '.xml']) |
---|
| 2173 | else |
---|
| 2174 | Param.Patch1.Rho=rho_patch1; |
---|
| 2175 | Param.Patch1.Threshold=thresh_patch1; |
---|
| 2176 | Param.Patch1.SubDomain=subdomain_patch1; |
---|
| 2177 | end |
---|
[257] | 2178 | end |
---|
| 2179 | if box_test(4)==1 |
---|
| 2180 | Param.Civ2=par_civ2; |
---|
| 2181 | end |
---|
| 2182 | if box_test(5)==1 |
---|
| 2183 | fix2.WarnFlags=[]; |
---|
| 2184 | if get(handles.vec_Fmin2_2,'Value') |
---|
| 2185 | fix2.WarnFlags=[fix2.WarnFlags -2]; |
---|
| 2186 | end |
---|
| 2187 | if get(handles.vec_F4,'Value') |
---|
| 2188 | fix2.WarnFlags=[fix2.WarnFlags 4]; |
---|
| 2189 | end |
---|
| 2190 | if get(handles.vec_F3_2,'Value') |
---|
| 2191 | fix2.WarnFlags=[fix2.WarnFlags 3]; |
---|
| 2192 | end |
---|
| 2193 | fix2.LowerBoundCorr=thresh_vec2C; |
---|
| 2194 | if get(handles.inf_sup2,'Value') |
---|
| 2195 | fix2.UppperBoundVel=thresh_vel2; |
---|
| 2196 | else |
---|
| 2197 | fix2.LowerBoundVel=thresh_vel2; |
---|
| 2198 | end |
---|
| 2199 | if get(handles.get_mask_fix2,'Value') |
---|
| 2200 | fix2.MaskName=maskname; |
---|
| 2201 | end |
---|
| 2202 | Param.Fix2=fix2; |
---|
| 2203 | end |
---|
[263] | 2204 | if box_test(6)==1 |
---|
| 2205 | if strcmp(compare,'stereo PIV') |
---|
| 2206 | filebase_A=filecell.filebase; |
---|
| 2207 | [pp,ff]=fileparts(filebase_A); |
---|
| 2208 | filebase_B=fullfile(pp,get(handles.RootName_1,'String')); |
---|
| 2209 | RUN_STLIN(filecell.ncA.civ2{ifile,j},filecell.nc.civ2{ifile,j},'civ2',filecell.st{ifile,j},... |
---|
| 2210 | str2num(nx_patch2),str2num(ny_patch2),str2num(thresh_patch2),[filebase_A '.xml'],[filebase_B '.xml']) |
---|
| 2211 | end |
---|
[257] | 2212 | end |
---|
[263] | 2213 | if ~strcmp(compare,'stereo PIV') |
---|
| 2214 | [Data,erromsg]=civ_uvmat(Param,filecell.nc.civ1{ifile,j}); |
---|
| 2215 | if isempty(errormsg) |
---|
| 2216 | display([filecell.nc.civ1{ifile,j} ' written']) |
---|
| 2217 | else |
---|
| 2218 | msgbox_uvmat('ERROR',errormsg) |
---|
| 2219 | end |
---|
| 2220 | end |
---|
[257] | 2221 | end |
---|
[112] | 2222 | end |
---|
[2] | 2223 | end |
---|
[134] | 2224 | |
---|
[257] | 2225 | if ~batch && ~isequal(CivMode,'Matlab') |
---|
[159] | 2226 | [Rootbat,Filebat,extbat]=fileparts(filename_bat); |
---|
[229] | 2227 | filename_superbat=fullfile(Rootbat,'job_list.bat'); |
---|
[134] | 2228 | fid=fopen(filename_superbat,'w'); |
---|
[257] | 2229 | if fid==-1 |
---|
| 2230 | msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat]) |
---|
| 2231 | return |
---|
| 2232 | end |
---|
[134] | 2233 | fprintf(fid,super_cmd'); |
---|
| 2234 | fclose(fid); |
---|
[257] | 2235 | if(isunix) |
---|
[219] | 2236 | system(['chmod +x ' filename_superbat]) |
---|
[257] | 2237 | end |
---|
| 2238 | system([filename_superbat ' &'])% execute main commmand |
---|
[133] | 2239 | end |
---|
[2] | 2240 | |
---|
[137] | 2241 | %% save interface state |
---|
[2] | 2242 | if isfield(filecell,'nc') |
---|
| 2243 | if isfield(filecell.nc,'civ2') |
---|
| 2244 | fileresu=filecell.nc.civ2{1,1}; |
---|
| 2245 | else |
---|
| 2246 | fileresu=filecell.nc.civ1{1,1}; |
---|
| 2247 | end |
---|
| 2248 | end |
---|
| 2249 | [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileresu); |
---|
| 2250 | namedoc=fullfile(RootPath,subdir,RootFile); |
---|
[112] | 2251 | detect=1; |
---|
[2] | 2252 | while detect==1 |
---|
| 2253 | namefigfull=[namedoc '.fig']; |
---|
| 2254 | hh=dir(namefigfull); |
---|
| 2255 | if ~isempty(hh) |
---|
| 2256 | detect=1; |
---|
| 2257 | namedoc=[namedoc '.0']; |
---|
| 2258 | else |
---|
| 2259 | detect=0; |
---|
| 2260 | end |
---|
| 2261 | end |
---|
| 2262 | saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) |
---|
| 2263 | |
---|
[227] | 2264 | %------------------------------------------------------------------------ |
---|
| 2265 | % --- determine the list of reference indices of processing file |
---|
| 2266 | function [ref_i,ref_j,errormsg]=find_ref_indices(handles) |
---|
| 2267 | %------------------------------------------------------------------------ |
---|
| 2268 | errormsg=''; %default error message |
---|
| 2269 | first_i=str2double(get(handles.first_i,'String'));%first index i |
---|
| 2270 | last_i=str2double(get(handles.last_i,'String'));%last index i |
---|
| 2271 | incr_i=str2double(get(handles.incr_i,'String'));% increment |
---|
| 2272 | if isequal(get(handles.first_j,'Visible'),'on') |
---|
| 2273 | first_j=str2double(get(handles.first_j,'String'));%first index j |
---|
| 2274 | last_j=str2double(get(handles.last_j,'String'));%last index j |
---|
| 2275 | incr_j=str2double(get(handles.incr_j,'String'));% increment |
---|
| 2276 | else |
---|
| 2277 | first_j=1; |
---|
| 2278 | last_j=1; |
---|
| 2279 | incr_j=1; |
---|
| 2280 | end |
---|
| 2281 | ref_i=first_i:incr_i:last_i;% list of i indices (reference values for each pair) |
---|
| 2282 | ref_j=first_j:incr_j:last_j;% list of j indices (reference values for each pair) |
---|
| 2283 | if isnan(first_i)||isnan(first_j) |
---|
| 2284 | errormsg='first field number not defined'; |
---|
| 2285 | elseif isnan(last_i)||isnan(last_j) |
---|
| 2286 | errormsg='last field number not defined'; |
---|
| 2287 | elseif isnan(incr_i)||isnan(incr_j) |
---|
| 2288 | errormsg='increment in field number not defined'; |
---|
| 2289 | elseif last_i < first_i || last_j < first_j |
---|
| 2290 | errormsg='last field number must be larger than the first one'; |
---|
| 2291 | end |
---|
[134] | 2292 | |
---|
[227] | 2293 | %------------------------------------------------------------------------ |
---|
| 2294 | % --- determine the list of filenames and indices needed for launch_job |
---|
[263] | 2295 | 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] | 2296 | set_civ_filenames(handles,ref_i,ref_j,box_test) |
---|
[12] | 2297 | %------------------------------------------------------------------------ |
---|
[85] | 2298 | filecell=[];%default |
---|
[136] | 2299 | |
---|
| 2300 | %% get the root names nomenclature and numbers |
---|
[71] | 2301 | filebase=get(handles.RootName,'String'); |
---|
[136] | 2302 | |
---|
| 2303 | if isempty(filebase)||isequal(filebase,'') |
---|
| 2304 | msgbox_uvmat('ERROR','no input files') |
---|
| 2305 | return |
---|
| 2306 | end |
---|
| 2307 | |
---|
[137] | 2308 | %filebase=regexprep(filebase,'\.fsnet','fsnet');% temporary fix for cluster Coriolis |
---|
[136] | 2309 | filecell.filebase=filebase; |
---|
| 2310 | |
---|
[2] | 2311 | browse=get(handles.browse_root,'UserData'); |
---|
| 2312 | compare_list=get(handles.compare,'String'); |
---|
| 2313 | val=get(handles.compare,'Value'); |
---|
| 2314 | compare=compare_list{val}; |
---|
| 2315 | if strcmp(compare,'displacement') |
---|
| 2316 | mode='displacement'; |
---|
| 2317 | else |
---|
| 2318 | mode_list=get(handles.mode,'String'); |
---|
| 2319 | mode_value=get(handles.mode,'Value'); |
---|
| 2320 | mode=mode_list{mode_value}; |
---|
| 2321 | end |
---|
[137] | 2322 | %time=get(handles.RootName,'UserData'); %get the set of times |
---|
[71] | 2323 | ext_ima=get(handles.ImaExt,'String'); |
---|
[2] | 2324 | nom_type_nc=browse.nom_type_nc; |
---|
[122] | 2325 | if isfield(browse,'nom_type_ima') |
---|
| 2326 | nom_type_ima2=browse.nom_type_ima; |
---|
| 2327 | end |
---|
| 2328 | if isempty(nom_type_ima2),nom_type_ima2='1';end; %default |
---|
| 2329 | if isempty(nom_type_nc),nom_type_nc='_i1-i2';end; %default |
---|
[2] | 2330 | [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
[227] | 2331 | find_pair_indices(handles,ref_i,ref_j,mode); |
---|
[2] | 2332 | %determine the new filebase for 'displacement' mode (comparison of two series) |
---|
| 2333 | filebase_B=filebase;% root name of the second field series for stereo |
---|
| 2334 | if strcmp(compare,'displacement') || strcmp(compare,'stereo PIV') |
---|
[127] | 2335 | % test_disp=1; |
---|
[2] | 2336 | nom_type_ima1=browse.nom_type_ima_1; %nomenclature type of the second file series |
---|
| 2337 | [Path2,Name2]=fileparts(filebase_B); |
---|
| 2338 | Path1=Path2; |
---|
[71] | 2339 | Name1=get(handles.RootName_1,'String');% root name of the first field series for stereo |
---|
[2] | 2340 | filebase_A=fullfile(Path1,Name1); |
---|
| 2341 | if length(Name1)>6 |
---|
| 2342 | Name1=Name1(end-5:end); |
---|
| 2343 | end |
---|
| 2344 | if length(Name2)>6 |
---|
| 2345 | Name2=Name2(end-5:end); |
---|
| 2346 | end |
---|
| 2347 | filebase_AB=fullfile(Path2,[Name2 '-' Name1]); |
---|
| 2348 | else |
---|
[127] | 2349 | % test_disp=0; |
---|
[2] | 2350 | filebase_A=filebase; |
---|
| 2351 | nom_type_ima1=nom_type_ima2; |
---|
| 2352 | filebase_AB=filebase; |
---|
| 2353 | end |
---|
| 2354 | if strcmp(compare,'displacement') |
---|
[112] | 2355 | filebase_ima1=filebase_A; |
---|
| 2356 | filebase_ima2=filebase_B; |
---|
| 2357 | filebase_nc=filebase_AB; %root name for the result of civ2 |
---|
[2] | 2358 | else |
---|
[112] | 2359 | filebase_ima1=filebase_B; |
---|
| 2360 | filebase_ima2=filebase_B; |
---|
| 2361 | filebase_nc=filebase_B; |
---|
| 2362 | end |
---|
[2] | 2363 | |
---|
| 2364 | %determine reference files for fix: |
---|
| 2365 | file_ref_fix1={};%default |
---|
| 2366 | file_ref_fix2={}; |
---|
| 2367 | nbfield=length(num1_civ1); |
---|
| 2368 | nbslice=length(num_a_civ1); |
---|
| 2369 | if box_test(2)==1% fix1 performed |
---|
| 2370 | ref=get(handles.ref_fix1,'UserData');%read data on the ref file stored by get_ref_fix1_Callback |
---|
| 2371 | if ~isempty(ref) |
---|
[137] | 2372 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 2373 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 2374 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 2375 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 2376 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 2377 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[127] | 2378 | num_i_ref=first_i:incr_i:last_i; |
---|
| 2379 | num_j_ref=first_j:incr_j:last_j; |
---|
[2] | 2380 | if isequal(mode,'displacement') |
---|
| 2381 | num_i1=num_i_ref; |
---|
| 2382 | num_i2=num_i_ref; |
---|
| 2383 | num_j1=num_j_ref; |
---|
| 2384 | num_j2=num_j_ref; |
---|
| 2385 | elseif isequal(mode,'pair j1-j2')% isequal(mode,'st_pair j1-j2') |
---|
| 2386 | num_i1=num_i_ref; |
---|
| 2387 | num_i2=num_i1; |
---|
| 2388 | num_j1=ref.num_a*ones(size(num_i_ref)); |
---|
| 2389 | num_j2=ref.num_b*ones(size(num_i_ref)); |
---|
| 2390 | elseif isequal(mode,'series(Di)') % isequal(mode,'st_series(Di)') |
---|
| 2391 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 2392 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 2393 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 2394 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 2395 | if isempty(ref.num_a) |
---|
| 2396 | ref.num_a=1; |
---|
| 2397 | end |
---|
| 2398 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 2399 | num_j2=num_j1; |
---|
| 2400 | elseif isequal(mode,'series(Dj)')%| isequal(mode,'st_series(Dj)') |
---|
| 2401 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 2402 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 2403 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 2404 | num_i2=num_i1; |
---|
| 2405 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 2406 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 2407 | end |
---|
| 2408 | for ifile=1:nbfield |
---|
| 2409 | for j=1:nbslice |
---|
| 2410 | 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);% |
---|
| 2411 | file_ref_fix1(ifile,j)={file_ref}; |
---|
| 2412 | if ~exist(file_ref,'file') |
---|
| 2413 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix1']) |
---|
[12] | 2414 | filecell=[]; |
---|
[2] | 2415 | return |
---|
| 2416 | end |
---|
| 2417 | end |
---|
| 2418 | end |
---|
| 2419 | end |
---|
| 2420 | end |
---|
| 2421 | |
---|
| 2422 | %determine reference files for fix2: |
---|
| 2423 | if box_test(5)==1% fix2 performed |
---|
| 2424 | ref=get(handles.ref_fix2,'UserData'); |
---|
| 2425 | if ~isempty(ref) |
---|
[127] | 2426 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 2427 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 2428 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 2429 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 2430 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 2431 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[229] | 2432 | num_i_ref=first_i:incr_i:last_i; |
---|
| 2433 | num_j_ref=first_j:incr_j:last_j; |
---|
[2] | 2434 | if isequal(mode,'displacement') |
---|
| 2435 | num_i1=num_i_ref; |
---|
| 2436 | num_i2=num_i_ref; |
---|
| 2437 | num_j1=num_j_ref; |
---|
| 2438 | num_j2=num_j_ref; |
---|
| 2439 | elseif isequal(mode,'pair j1-j2') |
---|
| 2440 | num_i1=num_i_ref; |
---|
| 2441 | num_i2=num_i1; |
---|
| 2442 | num_j1=ref.num_a; |
---|
| 2443 | num_j2=ref.num_b; |
---|
| 2444 | elseif isequal(mode,'series(Di)') |
---|
| 2445 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 2446 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 2447 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 2448 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 2449 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 2450 | num_j2=num_j1; |
---|
| 2451 | elseif isequal(mode,'series(Dj)') |
---|
| 2452 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 2453 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 2454 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 2455 | num_i2=num_i1; |
---|
| 2456 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 2457 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 2458 | end |
---|
| 2459 | for ifile=1:nbfield |
---|
| 2460 | for j=1:nbslice |
---|
| 2461 | 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);% |
---|
| 2462 | file_ref_fix2(ifile,j)={file_ref}; |
---|
| 2463 | if ~exist(file_ref,'file') |
---|
| 2464 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix2']) |
---|
[122] | 2465 | filecell={}; |
---|
[2] | 2466 | return |
---|
| 2467 | end |
---|
| 2468 | end |
---|
| 2469 | end |
---|
| 2470 | end |
---|
| 2471 | end |
---|
| 2472 | |
---|
| 2473 | %check dir |
---|
| 2474 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf output data |
---|
| 2475 | subdir_civ2=get(handles.subdir_civ2,'String'); |
---|
[174] | 2476 | if isequal(subdir_civ1,''),subdir_civ1='CIV'; end% put default subdir |
---|
[2] | 2477 | if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end% put default subdir |
---|
[135] | 2478 | currentdir=pwd;%store the current working directory |
---|
[2] | 2479 | [Path_ima,Name]=fileparts(filebase);%Path of the image files (.civ) |
---|
| 2480 | if ~exist(Path_ima,'dir') |
---|
[12] | 2481 | msgbox_uvmat('ERROR',['path to images ' Path_ima ' not found']) |
---|
[122] | 2482 | filecell={}; |
---|
[2] | 2483 | return |
---|
| 2484 | end |
---|
[127] | 2485 | [xx,message]=fileattrib(Path_ima); |
---|
[122] | 2486 | if ~isempty(message) && ~isequal(message.UserWrite,1) |
---|
[112] | 2487 | msgbox_uvmat('ERROR',['No writting access to ' Path_ima]) |
---|
[122] | 2488 | filecell={}; |
---|
[112] | 2489 | cd(currentdir); |
---|
| 2490 | return |
---|
[2] | 2491 | end |
---|
| 2492 | |
---|
| 2493 | %check the existence of the netcdf and image files involved |
---|
| 2494 | % %%%%%%%%%%%% case CIV1 activated %%%%%%%%%%%%% |
---|
| 2495 | if box_test(1)==1; |
---|
[112] | 2496 | detect=1; |
---|
[127] | 2497 | vers=0; |
---|
| 2498 | subdir_civ1_new=subdir_civ1; |
---|
[153] | 2499 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
[122] | 2500 | for ifile=1:nbfield |
---|
[112] | 2501 | for j=1:nbslice |
---|
[122] | 2502 | 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] | 2503 | detect=exist(filename,'file')==2; |
---|
| 2504 | if detect% if a netcdf file already exists |
---|
[137] | 2505 | indstr=regexp(subdir_civ1_new,'\D'); |
---|
| 2506 | if indstr(end)<length(subdir_civ1_new) %subdir_civ1 ends by a number |
---|
| 2507 | vers=str2double(subdir_civ1_new(indstr(end)+1:end))+1; |
---|
| 2508 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) num2str(vers)]; |
---|
[127] | 2509 | else |
---|
| 2510 | vers=vers+1; |
---|
[137] | 2511 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) '_' num2str(vers)]; |
---|
[127] | 2512 | end |
---|
[137] | 2513 | subdir_civ2=subdir_civ1_new; |
---|
[112] | 2514 | break |
---|
| 2515 | end |
---|
| 2516 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 2517 | end |
---|
| 2518 | if detect% if a netcdf file already exists |
---|
| 2519 | break |
---|
| 2520 | end |
---|
| 2521 | end |
---|
[134] | 2522 | |
---|
[112] | 2523 | %create the new subdir_civ1 |
---|
[127] | 2524 | if ~exist(fullfile(Path_ima,subdir_civ1_new),'dir') |
---|
[263] | 2525 | % cd(Path_ima); |
---|
| 2526 | [xx,msg1]=mkdir(fullfile(Path_ima,subdir_civ1_new)); |
---|
[134] | 2527 | |
---|
[128] | 2528 | if ~strcmp(msg1,'') |
---|
| 2529 | msgbox_uvmat('ERROR',['cannot create ' subdir_civ1_new ': ' msg1])%error message for directory creation |
---|
[122] | 2530 | filecell={}; |
---|
| 2531 | return |
---|
[163] | 2532 | elseif isunix |
---|
[128] | 2533 | [xx,msg2] = fileattrib(subdir_civ1_new,'+w','g'); %yield writing access (+w) to user group (g) |
---|
| 2534 | if ~strcmp(msg2,'') |
---|
[134] | 2535 | msgbox_uvmat('ERROR',['pb of permission for ' subdir_civ1_new ': ' msg2])%error message for directory creation |
---|
[128] | 2536 | filecell={}; |
---|
| 2537 | return |
---|
| 2538 | end |
---|
[112] | 2539 | end |
---|
[263] | 2540 | % cd(currentdir); |
---|
[112] | 2541 | end |
---|
| 2542 | if strcmp(compare,'stereo PIV')&&(strcmp(mode,'pair j1-j2')||strcmp(mode,'series(Dj)')||strcmp(mode,'series(Di)'))%check second nc series |
---|
| 2543 | for ifile=1:nbfield |
---|
| 2544 | for j=1:nbslice |
---|
[122] | 2545 | 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] | 2546 | detect=exist(filename,'file')==2; |
---|
[2] | 2547 | if detect% if a netcdf file already exists |
---|
[137] | 2548 | indstr=regexp(subdir_civ1_new,'\D'); |
---|
| 2549 | if indstr(end)<length(subdir_civ1_new) %subdir_civ1 ends by a number |
---|
| 2550 | vers=str2double(subdir_civ1_new(indstr(end)+1:end))+1; |
---|
| 2551 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) num2str(vers)]; |
---|
[127] | 2552 | else |
---|
| 2553 | vers=vers+1; |
---|
[137] | 2554 | subdir_civ1_new=[subdir_civ1_new '_' num2str(vers)]; |
---|
[127] | 2555 | end |
---|
| 2556 | subdir_civ2=subdir_civ1; |
---|
| 2557 | break |
---|
[2] | 2558 | end |
---|
[112] | 2559 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
| 2560 | end |
---|
| 2561 | if detect% if a netcdf file already exists |
---|
| 2562 | break |
---|
| 2563 | end |
---|
| 2564 | end |
---|
| 2565 | %create the new subdir_civ1 |
---|
[263] | 2566 | if ~exist(fullfile(Path_ima,subdir_civ1_new),'dir') |
---|
| 2567 | % cd(Path_ima); |
---|
| 2568 | [xx,msg1]=mkdir(fullfile(Path_ima,subdir_civ1_new)); |
---|
| 2569 | % cd(currentdir); |
---|
[252] | 2570 | if ~strcmp(msg1,'') |
---|
[128] | 2571 | msgbox_uvmat('ERROR',['cannot create ' subdir_civ1_new ': ' msg1]) |
---|
[263] | 2572 | % cd(currentdir) |
---|
[122] | 2573 | filecell={}; |
---|
| 2574 | return |
---|
[128] | 2575 | else |
---|
| 2576 | [xx,msg2] = fileattrib(subdir_civ1_new,'+w','g'); %yield writing access (+w) to user group (g) |
---|
| 2577 | if ~strcmp(msg2,'') |
---|
| 2578 | msgbox_uvmat('ERROR',['pb of permission for ' subdir_civ1_new ': ' msg2])%error message for directory creation |
---|
[263] | 2579 | % cd(currentdir) |
---|
[128] | 2580 | filecell={}; |
---|
| 2581 | return |
---|
| 2582 | end |
---|
[112] | 2583 | end |
---|
| 2584 | end |
---|
| 2585 | end |
---|
| 2586 | end |
---|
[127] | 2587 | subdir_civ1=subdir_civ1_new; |
---|
[2] | 2588 | % get image names |
---|
| 2589 | for ifile=1:nbfield |
---|
[112] | 2590 | for j=1:nbslice |
---|
[2] | 2591 | filename=name_generator(filebase_ima1, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
| 2592 | idetect(j)=exist(filename,'file')==2; |
---|
| 2593 | filecell.ima1.civ1(ifile,j)={filename}; %first image |
---|
| 2594 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
| 2595 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 2596 | filecell.ima2.civ1(ifile,j)={filename};%second image |
---|
[112] | 2597 | end |
---|
| 2598 | [idetectmin,indexj]=min(idetect); |
---|
| 2599 | if idetectmin==0, |
---|
| 2600 | msgbox_uvmat('ERROR',[filecell.ima1.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2601 | filecell={}; |
---|
| 2602 | cd(currentdir) |
---|
[112] | 2603 | return |
---|
| 2604 | end |
---|
| 2605 | [idetectmin,indexj]=min(idetect_1); |
---|
| 2606 | if idetectmin==0, |
---|
| 2607 | msgbox_uvmat('ERROR',[filecell.ima2.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2608 | filecell={}; |
---|
[112] | 2609 | cd(currentdir) |
---|
| 2610 | return |
---|
| 2611 | end |
---|
| 2612 | end |
---|
| 2613 | if strcmp(compare,'stereo PIV') && (strcmp(mode,'pair j1-j2') || strcmp(mode,'series(Dj)') || strcmp(mode,'series(Di)')) |
---|
| 2614 | for ifile=1:nbfield |
---|
| 2615 | for j=1:nbslice |
---|
| 2616 | filename=name_generator(filebase_A, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
| 2617 | idetect(j)=exist(filename,'file')==2; |
---|
| 2618 | filecell.imaA1.civ1(ifile,j)={filename} ;%first image |
---|
| 2619 | filename=name_generator(filebase_A, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
| 2620 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 2621 | filecell.imaA2.civ1(ifile,j)={filename};%second image |
---|
| 2622 | end |
---|
[2] | 2623 | [idetectmin,indexj]=min(idetect); |
---|
[112] | 2624 | if idetectmin==0, |
---|
| 2625 | msgbox_uvmat('ERROR',[filecell.imaA1.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2626 | filecell={}; |
---|
[112] | 2627 | cd(currentdir) |
---|
[2] | 2628 | return |
---|
[112] | 2629 | end |
---|
[2] | 2630 | [idetectmin,indexj]=min(idetect_1); |
---|
[112] | 2631 | if idetectmin==0, |
---|
| 2632 | msgbox_uvmat('ERROR',[filecell.imaA2.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2633 | filecell={}; |
---|
[2] | 2634 | cd(currentdir) |
---|
| 2635 | return |
---|
[112] | 2636 | end |
---|
| 2637 | end |
---|
[2] | 2638 | end |
---|
[112] | 2639 | |
---|
| 2640 | %%%%%%%%%%%%% fix1 or patch1 activated but no civ1 %%%%%%%%%%%%% |
---|
| 2641 | elseif (box_test(2)==1 || box_test(3)==1); |
---|
[2] | 2642 | for ifile=1:nbfield |
---|
| 2643 | for j=1:nbslice |
---|
| 2644 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
[112] | 2645 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 2646 | detect=exist(filename,'file')==2; |
---|
[122] | 2647 | if detect==0 |
---|
| 2648 | msgbox_uvmat('ERROR',[filename ' not found']) |
---|
| 2649 | filecell={}; |
---|
| 2650 | cd(currentdir) |
---|
| 2651 | return |
---|
| 2652 | end |
---|
[2] | 2653 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 2654 | end |
---|
| 2655 | end |
---|
| 2656 | if strcmp(compare,'stereo PIV') |
---|
[112] | 2657 | for ifile=1:nbfield |
---|
| 2658 | for j=1:nbslice |
---|
| 2659 | 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);% |
---|
| 2660 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
| 2661 | if ~exist(filename,'file') |
---|
| 2662 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
| 2663 | set(handles.RUN, 'Enable','On') |
---|
| 2664 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
[122] | 2665 | filecell={}; |
---|
[112] | 2666 | cd(currentdir) |
---|
| 2667 | return |
---|
[2] | 2668 | end |
---|
| 2669 | end |
---|
[112] | 2670 | end |
---|
[2] | 2671 | end |
---|
| 2672 | end |
---|
| 2673 | |
---|
| 2674 | %%%%%%%%%%%%% if civ2 performed with pairs different than civ1 %%%%%%%%%%%%% |
---|
| 2675 | testdiff=0; |
---|
| 2676 | if (box_test(4)==1)&&... |
---|
[127] | 2677 | ((get(handles.list_pair_civ1,'Value')~=get(handles.list_pair_civ2,'Value'))||~strcmp(subdir_civ2,subdir_civ1)) |
---|
[2] | 2678 | testdiff=1; |
---|
[112] | 2679 | detect=1; |
---|
[127] | 2680 | vers=0; |
---|
| 2681 | subdir_civ2_new=subdir_civ2; |
---|
[2] | 2682 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
[112] | 2683 | for ifile=1:nbfield |
---|
| 2684 | for j=1:nbslice |
---|
[127] | 2685 | 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] | 2686 | detect=exist(filename,'file')==2; |
---|
| 2687 | if detect% if a netcdf file already exists |
---|
[127] | 2688 | indstr=regexp(subdir_civ2,'\D'); |
---|
| 2689 | if indstr(end)<length(subdir_civ2) %subdir_civ1 ends by a number |
---|
| 2690 | vers=str2double(subdir_civ2(indstr(end)+1:end))+1; |
---|
| 2691 | subdir_civ2_new=[subdir_civ2(1:indstr(end)) num2str(vers)]; |
---|
| 2692 | else |
---|
| 2693 | vers=vers+1; |
---|
| 2694 | subdir_civ2_new=[subdir_civ1 '_' num2str(vers)]; |
---|
| 2695 | end |
---|
[112] | 2696 | break |
---|
| 2697 | end |
---|
| 2698 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 2699 | end |
---|
| 2700 | if detect% if a netcdf file already exists |
---|
| 2701 | break |
---|
| 2702 | end |
---|
| 2703 | end |
---|
[128] | 2704 | %create the new subdir_civ2_new |
---|
| 2705 | if ~exist(fullfile(Path_ima,subdir_civ2_new),'dir') |
---|
[174] | 2706 | [xx,m2]=mkdir(fullfile(Path_ima,subdir_civ2_new)); |
---|
[128] | 2707 | [xx,msg2] = fileattrib(subdir_civ2_new,'+w','g'); %yield writing access (+w) to user group (g) |
---|
[112] | 2708 | if ~isequal(m2,'') |
---|
[128] | 2709 | msgbox_uvmat('ERROR',['cannot create ' subdir_civ2_new ': ' m2]) |
---|
[122] | 2710 | filecell={}; |
---|
| 2711 | cd(currentdir) |
---|
| 2712 | return |
---|
[112] | 2713 | end |
---|
| 2714 | end |
---|
| 2715 | if strcmp(compare,'stereo PIV')%check second nc series |
---|
| 2716 | for ifile=1:nbfield |
---|
| 2717 | for j=1:nbslice |
---|
| 2718 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
[122] | 2719 | nom_type_nc,1,num2_civ2(ifile),num_b_civ1(j),subdir_civ2_new);% |
---|
[112] | 2720 | detect=exist(filename,'file')==2; |
---|
[2] | 2721 | if detect% if a netcdf file already exists |
---|
[127] | 2722 | indstr=regexp(subdir_civ2,'\D'); |
---|
| 2723 | if indstr(end)<length(subdir_civ2) %subdir_civ1 ends by a number |
---|
| 2724 | vers=str2double(subdir_civ2(indstr(end)+1:end))+1; |
---|
| 2725 | subdir_civ2_new=[subdir_civ2(1:indstr(end)) num2str(vers)]; |
---|
| 2726 | else |
---|
| 2727 | vers=vers+1; |
---|
| 2728 | subdir_civ2_new=[subdir_civ1 '_' num2str(vers)]; |
---|
| 2729 | end |
---|
[112] | 2730 | break |
---|
[2] | 2731 | end |
---|
[112] | 2732 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 2733 | end |
---|
| 2734 | if detect% if a netcdf file already exists |
---|
| 2735 | break |
---|
| 2736 | end |
---|
| 2737 | end |
---|
[122] | 2738 | subdir_civ2=subdir_civ2_new; |
---|
[112] | 2739 | %create the new subdir_civ1 |
---|
[127] | 2740 | if ~exist(fullfile(Path_ima,subdir_civ2_new),'dir') |
---|
| 2741 | [xx,m2]=mkdir(subdir_civ2_new); |
---|
[128] | 2742 | [xx,msg2] = fileattrib(subdir_civ2_new,'+w','g'); %yield writing access (+w) to user group (g) |
---|
[112] | 2743 | if ~isequal(m2,'') |
---|
[128] | 2744 | msgbox_uvmat('ERROR', ['cannot create ' subdir_civ2_new ': ' m2])%error message for directory creation |
---|
[122] | 2745 | cd(currentdir) |
---|
| 2746 | filecell={}; |
---|
| 2747 | return |
---|
[112] | 2748 | end |
---|
| 2749 | end |
---|
| 2750 | end |
---|
| 2751 | end |
---|
[127] | 2752 | subdir_civ2=subdir_civ2_new; |
---|
[2] | 2753 | end |
---|
| 2754 | cd(currentdir);%come back to the current working directory |
---|
| 2755 | |
---|
| 2756 | %%%%%%%%%%%%% if civ2 results are obtained or used %%%%%%%%%%%%% |
---|
| 2757 | if box_test(4)==1 || box_test(5)==1 || box_test(6)==1 %civ2 |
---|
| 2758 | %check source netcdf file of civ1 estimates |
---|
| 2759 | if box_test(1)==0; %no civ1 performed |
---|
| 2760 | for ifile=1:nbfield |
---|
| 2761 | for j=1:nbslice |
---|
| 2762 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 2763 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 2764 | filecell.nc.civ1(ifile,j)={filename};% name of the civ1 file |
---|
| 2765 | if ~exist(filename,'file') |
---|
| 2766 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
[122] | 2767 | filecell={}; |
---|
[2] | 2768 | return |
---|
| 2769 | end |
---|
| 2770 | if ~testdiff % civ2 or patch2 are written in the same file as civ1 |
---|
| 2771 | if box_test(4)==0 ; %check the existence of civ2 if it is not calculated |
---|
[248] | 2772 | Data=nc2struct(filename,'ListGlobalAttribute','CivStage','civ2'); |
---|
| 2773 | if ~isempty(Data.CivStage) && Data.CivStage<4 %test for civ files |
---|
[2] | 2774 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
[12] | 2775 | filecell=[]; |
---|
[2] | 2776 | return |
---|
[248] | 2777 | elseif isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
| 2778 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
| 2779 | filecell=[]; |
---|
| 2780 | return |
---|
[112] | 2781 | end |
---|
[2] | 2782 | elseif box_test(3)==0; %check the existence of patch if it is not calculated |
---|
[248] | 2783 | Data=nc2struct(filename,'ListGlobalAttribute','CivStage','patch') |
---|
| 2784 | if ~isempty(Data.CivStage) |
---|
| 2785 | if Data.CivStage<3 %test for civ files |
---|
| 2786 | msgbox_uvmat('ERROR',['no patch data in ' filename]) |
---|
| 2787 | filecell=[]; |
---|
| 2788 | return |
---|
| 2789 | end |
---|
| 2790 | elseif isempty(Data.patch)||isequal(Data.patch,0) |
---|
[2] | 2791 | msgbox_uvmat('ERROR',['no patch data in ' filename]) |
---|
[12] | 2792 | filecell=[]; |
---|
[2] | 2793 | return |
---|
| 2794 | end |
---|
[112] | 2795 | end |
---|
[2] | 2796 | end |
---|
| 2797 | end |
---|
| 2798 | end |
---|
| 2799 | if strcmp(compare,'stereo PIV') |
---|
| 2800 | for ifile=1:nbfield |
---|
| 2801 | for j=1:nbslice |
---|
| 2802 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 2803 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 2804 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 2805 | if ~exist(filename,'file') |
---|
| 2806 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
| 2807 | set(handles.RUN, 'Enable','On') |
---|
| 2808 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 2809 | return |
---|
| 2810 | end |
---|
| 2811 | end |
---|
| 2812 | end |
---|
| 2813 | end |
---|
| 2814 | end |
---|
[112] | 2815 | |
---|
| 2816 | detect=1; |
---|
| 2817 | % while detect==1%creates a new subdir if the netcdf files already contain civ2 data |
---|
| 2818 | for ifile=1:nbfield |
---|
| 2819 | for j=1:nbslice |
---|
| 2820 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
[2] | 2821 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2); |
---|
[112] | 2822 | detect=exist(filename,'file')==2; |
---|
| 2823 | filecell.nc.civ2(ifile,j)={filename}; |
---|
[2] | 2824 | end |
---|
[112] | 2825 | end |
---|
[2] | 2826 | %get first image names for civ2 |
---|
| 2827 | if box_test(1)==1 & isequal(num1_civ1,num1_civ2) & isequal(num_a_civ1,num_a_civ2) |
---|
| 2828 | filecell.ima1.civ2=filecell.ima1.civ1; |
---|
| 2829 | elseif box_test(4)==1 |
---|
| 2830 | for ifile=1:nbfield |
---|
| 2831 | for j=1:nbslice |
---|
| 2832 | filename=name_generator(filebase_ima1, num1_civ2(ifile),num_a_civ2(j),ext_ima,nom_type_ima1); |
---|
| 2833 | idetect_2(j)=exist(filename,'file')==2; |
---|
| 2834 | filecell.ima1.civ2(ifile,j)={filename};%first image |
---|
| 2835 | end |
---|
[112] | 2836 | [idetectmin,indexj]=min(idetect_2); |
---|
[2] | 2837 | if idetectmin==0, |
---|
[112] | 2838 | msgbox_uvmat('ERROR',['input image ' filecell.ima1.civ2{ifile,indexj} ' not found']) |
---|
| 2839 | filecell=[]; |
---|
| 2840 | return |
---|
[2] | 2841 | end |
---|
| 2842 | end |
---|
| 2843 | end |
---|
| 2844 | |
---|
| 2845 | %get second image names for civ2 |
---|
| 2846 | if box_test(1)==1 & isequal(num2_civ1,num2_civ2) & isequal(num_b_civ1,num_b_civ2) |
---|
| 2847 | filecell.ima2.civ2=filecell.ima2.civ1; |
---|
| 2848 | elseif box_test(4)==1 |
---|
| 2849 | for ifile=1:nbfield |
---|
| 2850 | for j=1:nbslice |
---|
| 2851 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),ext_ima,nom_type_ima2); |
---|
| 2852 | idetect_3(j)=exist(filename,'file')==2; |
---|
| 2853 | filecell.ima2.civ2(ifile,j)={filename};%first image |
---|
| 2854 | end |
---|
[112] | 2855 | [idetectmin,indexj]=min(idetect_3); |
---|
[2] | 2856 | if idetectmin==0, |
---|
[112] | 2857 | msgbox_uvmat('ERROR',['input image ' filecell.ima2.civ2{ifile,indexj} ' not found']) |
---|
| 2858 | filecell=[]; |
---|
| 2859 | return |
---|
[2] | 2860 | end |
---|
| 2861 | end |
---|
| 2862 | end |
---|
| 2863 | end |
---|
| 2864 | if (box_test(5)==1 || box_test(6)==1 ) && box_test(4)==0 % need to read an existing netcdf civ2 file |
---|
| 2865 | if ~testdiff |
---|
| 2866 | filecell.nc.civ2=filecell.nc.civ1;% file already checked |
---|
[112] | 2867 | else % check the civ2 files |
---|
[2] | 2868 | for ifile=1:nbfield |
---|
| 2869 | for j=1:nbslice |
---|
| 2870 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
[112] | 2871 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
[2] | 2872 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 2873 | if ~exist(filename,'file') |
---|
| 2874 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
[12] | 2875 | filecell=[]; |
---|
[2] | 2876 | return |
---|
| 2877 | else |
---|
[248] | 2878 | Data=nc2struct(filename,'ListGlobalAttribute','CivStage','civ2'); |
---|
| 2879 | if ~isempty(Data.CivStage) && Data.CivStage<4 %test for civ files |
---|
| 2880 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
| 2881 | filecell=[]; |
---|
| 2882 | return |
---|
| 2883 | elseif isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
[2] | 2884 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
[12] | 2885 | filecell=[]; |
---|
[2] | 2886 | return |
---|
| 2887 | end |
---|
| 2888 | end |
---|
| 2889 | end |
---|
| 2890 | end |
---|
| 2891 | end |
---|
| 2892 | end |
---|
| 2893 | |
---|
| 2894 | %%%%%%%%%%%%% if stereo fields are calculated by PATCH %%%%%%%%%%%%% |
---|
| 2895 | if strcmp(compare,'stereo PIV') |
---|
[127] | 2896 | if box_test(3)==1 && isequal(get(handles.test_stereo1,'Value'),1) |
---|
[2] | 2897 | for ifile=1:nbfield |
---|
| 2898 | for j=1:nbslice |
---|
| 2899 | filename=name_generator(filebase_AB,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 2900 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 2901 | filecell.st(ifile,j)={filename}; |
---|
| 2902 | end |
---|
| 2903 | end |
---|
| 2904 | end |
---|
[127] | 2905 | if box_test(6)==1 && isequal(get(handles.test_stereo2,'Value'),1) |
---|
[2] | 2906 | for ifile=1:nbfield |
---|
| 2907 | for j=1:nbslice |
---|
| 2908 | filename=name_generator(filebase_AB,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 2909 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 2910 | filecell.st(ifile,j)={filename}; |
---|
| 2911 | end |
---|
| 2912 | end |
---|
[112] | 2913 | end |
---|
[2] | 2914 | end |
---|
| 2915 | set(handles.subdir_civ1,'String',subdir_civ1);%update the edit box |
---|
| 2916 | set(handles.subdir_civ2,'String',subdir_civ2);%update the edit box |
---|
| 2917 | browse.nom_type_nc=nom_type_nc; |
---|
| 2918 | set(handles.browse_root,'UserData',browse); %update the nomenclature type for uvmat |
---|
| 2919 | |
---|
| 2920 | |
---|
| 2921 | %COPY IMAGES TO THE FORMAT .png IF NEEDED |
---|
[45] | 2922 | if isequal(nom_type_ima1,'*')%case of movie files |
---|
| 2923 | nom_type_imanew1='_i'; |
---|
[2] | 2924 | else |
---|
| 2925 | nom_type_imanew1=nom_type_ima1; |
---|
| 2926 | end |
---|
[45] | 2927 | if isequal(nom_type_ima2,'*')%case of movie files |
---|
| 2928 | nom_type_imanew2='_i'; |
---|
[2] | 2929 | else |
---|
| 2930 | nom_type_imanew2=nom_type_ima2; |
---|
| 2931 | end |
---|
| 2932 | if ~isequal(ext_ima,'.png') |
---|
[45] | 2933 | %%type of image file |
---|
| 2934 | type_ima1='none';%default |
---|
| 2935 | movieobject1=[];%default |
---|
[133] | 2936 | if strcmpi(ext_ima,'.avi') |
---|
[45] | 2937 | hhh=which('mmreader'); |
---|
| 2938 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
---|
| 2939 | type_ima1='movie'; |
---|
| 2940 | movieobject1=mmreader([filebase_ima2 ext_ima]); |
---|
| 2941 | else |
---|
| 2942 | type_ima1='avi'; |
---|
| 2943 | end |
---|
[133] | 2944 | elseif ischar(ext_ima) && ~isempty(ext_ima(2:end)) |
---|
[112] | 2945 | form=imformats(ext_ima(2:end)); |
---|
| 2946 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 2947 | if isequal(nom_type_ima1,'*'); |
---|
| 2948 | type_ima1='multimage';%image series in a single image file |
---|
| 2949 | else |
---|
| 2950 | type_ima1='image'; |
---|
| 2951 | end |
---|
| 2952 | end |
---|
[45] | 2953 | end |
---|
| 2954 | type_ima2='none';%default |
---|
| 2955 | movieobject2=[]; |
---|
[133] | 2956 | if strcmpi(ext_ima,'.avi') |
---|
[45] | 2957 | hhh=which('mmreader'); |
---|
| 2958 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
---|
| 2959 | type_ima2='movie'; |
---|
| 2960 | movieobject2=mmreader([filebase_ima2 ext_ima]); |
---|
| 2961 | else |
---|
| 2962 | type_ima2='avi'; |
---|
| 2963 | end |
---|
[133] | 2964 | elseif ischar(ext_ima) && ~isempty(ext_ima(2:end)) |
---|
[112] | 2965 | form=imformats(ext_ima(2:end)); |
---|
| 2966 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 2967 | if isequal(nom_type_ima1,'*'); |
---|
| 2968 | type_ima2='multimage';%image series in a single image file |
---|
| 2969 | else |
---|
| 2970 | type_ima2='image'; |
---|
| 2971 | end |
---|
| 2972 | end |
---|
[45] | 2973 | end |
---|
[71] | 2974 | %npxy=get(handles.ImaExt,'UserData'); |
---|
[112] | 2975 | % % if numel(npxy)<2 |
---|
| 2976 | % |
---|
| 2977 | % filename=name_generator(filebase_ima1,num1_civ1(1),num_a_civ1(1),ImaExt,nom_type_ima1); |
---|
| 2978 | % A=imread(filename); |
---|
| 2979 | % npxy=size(A); |
---|
| 2980 | % % end |
---|
| 2981 | % npy=npxy(1); |
---|
| 2982 | % npx=npxy(2); |
---|
[2] | 2983 | if box_test(1)==1 %if civ1 is performed |
---|
[224] | 2984 | h = waitbar(0,'copy images to the .png format for civ1');% display a wait bar |
---|
[112] | 2985 | for ifile=1:nbfield |
---|
[2] | 2986 | waitbar(ifile/nbfield); |
---|
| 2987 | for j=1:nbslice |
---|
[112] | 2988 | filename=name_generator(filebase_ima1,num1_civ1(ifile),num_a_civ1(j),'.png',nom_type_imanew1); |
---|
| 2989 | if ~exist(filename,'file') |
---|
| 2990 | A=read_image(filecell.ima1.civ1{ifile,j},type_ima1,num1_civ1(ifile),movieobject1); |
---|
| 2991 | imwrite(A,filename,'BitDepth',16); |
---|
| 2992 | end |
---|
| 2993 | filecell.ima1.civ1(ifile,j)={filename}; |
---|
| 2994 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),'.png',nom_type_imanew2); |
---|
| 2995 | if ~exist(filename,'file') |
---|
| 2996 | A=read_image(filecell.ima2.civ1{ifile,j},type_ima2,num2_civ1(ifile),movieobject2); |
---|
| 2997 | imwrite(A,filename,'BitDepth',16); |
---|
| 2998 | end |
---|
| 2999 | filecell.ima2.civ1(ifile,j)={filename}; |
---|
[2] | 3000 | end |
---|
| 3001 | end |
---|
| 3002 | close(h) |
---|
| 3003 | end |
---|
| 3004 | if box_test(4)==1 %if civ2 is performed |
---|
[229] | 3005 | h = waitbar(0,'copy images to the .png format for civ2');% display a wait bar |
---|
[2] | 3006 | for ifile=1:nbfield |
---|
| 3007 | waitbar(ifile/nbfield); |
---|
| 3008 | for j=1:nbslice |
---|
[112] | 3009 | filename=name_generator(filebase_ima1,num1_civ2(ifile),num_a_civ2(j),'.png',nom_type_imanew1); |
---|
| 3010 | if ~exist(filename,'file') |
---|
| 3011 | A=read_image(cell2mat(filecell.ima1.civ2(ifile,j)),type_ima2,num1_civ2(ifile)); |
---|
| 3012 | imwrite(A,filename,'BitDepth',16); |
---|
| 3013 | end |
---|
| 3014 | filecell.ima1.civ2(ifile,j)={filename}; |
---|
| 3015 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),'.png',nom_type_imanew2); |
---|
| 3016 | if ~exist(filename,'file') |
---|
| 3017 | A=read_image(cell2mat(filecell.ima2.civ2(ifile,j)),type_ima2,num2_civ2(ifile)); |
---|
| 3018 | imwrite(A,filename,'BitDepth',16); |
---|
| 3019 | end |
---|
| 3020 | filecell.ima2.civ2(ifile,j)={filename}; |
---|
[2] | 3021 | end |
---|
| 3022 | end |
---|
| 3023 | close(h); |
---|
| 3024 | end |
---|
| 3025 | end |
---|
| 3026 | |
---|
[12] | 3027 | %------------------------------------------------------------------------ |
---|
[227] | 3028 | % --- determine the list of index pairs of processing file |
---|
| 3029 | function [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
| 3030 | find_pair_indices(handles,ref_i,ref_j,mode) |
---|
| 3031 | %------------------------------------------------------------------------ |
---|
| 3032 | |
---|
| 3033 | list_civ1=get(handles.list_pair_civ1,'String'); |
---|
| 3034 | index_civ1=get(handles.list_pair_civ1,'Value'); |
---|
| 3035 | str_civ1=list_civ1{index_civ1};%string defining the image pairs for civ1 |
---|
| 3036 | if isempty(str_civ1)||isequal(str_civ1,'') |
---|
| 3037 | msgbox_uvmat('ERROR','no image pair selected for civ1') |
---|
| 3038 | return |
---|
| 3039 | end |
---|
| 3040 | list_civ2=get(handles.list_pair_civ2,'String'); |
---|
| 3041 | index_civ2=get(handles.list_pair_civ2,'Value'); |
---|
| 3042 | if index_civ2>length(list_civ2) |
---|
| 3043 | list_civ2=list_civ1; |
---|
| 3044 | index_civ2=index_civ1; |
---|
| 3045 | end |
---|
| 3046 | str_civ2=list_civ2{index_civ2};%string defining the image pairs for civ2 |
---|
| 3047 | |
---|
| 3048 | if isequal (mode,'series(Di)') |
---|
| 3049 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 3050 | num1_civ1=ref_i-floor(index_civ1/2)*ones(size(ref_i));% set of first image numbers |
---|
| 3051 | num2_civ1=ref_i+ceil(index_civ1/2)*ones(size(ref_i)); |
---|
| 3052 | num_a_civ1=ref_j; |
---|
| 3053 | num_b_civ1=ref_j; |
---|
[229] | 3054 | num1_civ2=ref_i-floor(index_civ2/2)*ones(size(ref_i)); |
---|
[227] | 3055 | num2_civ2=ref_i+ceil(index_civ2/2)*ones(size(ref_i)); |
---|
| 3056 | num_a_civ2=ref_j; |
---|
| 3057 | num_b_civ2=ref_j; |
---|
| 3058 | |
---|
| 3059 | % adjust the first and last field number |
---|
| 3060 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 3061 | if isnan(lastfield) |
---|
| 3062 | indsel=find((num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
| 3063 | else |
---|
| 3064 | indsel=find((num2_civ1 <= lastfield)&(num2_civ2 <= lastfield)&(num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
| 3065 | end |
---|
| 3066 | if length(indsel)>=1 |
---|
| 3067 | firstind=indsel(1); |
---|
| 3068 | lastind=indsel(end); |
---|
| 3069 | set(handles.first_i,'String',num2str(ref_i(firstind)))%update the display of first and last fields |
---|
| 3070 | set(handles.last_i,'String',num2str(ref_i(lastind))) |
---|
| 3071 | ref_i=ref_i(indsel); |
---|
| 3072 | num1_civ1=num1_civ1(indsel); |
---|
| 3073 | num1_civ2=num1_civ2(indsel); |
---|
| 3074 | num2_civ1=num2_civ1(indsel); |
---|
| 3075 | num2_civ2=num2_civ2(indsel); |
---|
| 3076 | end |
---|
| 3077 | elseif isequal (mode,'series(Dj)') |
---|
| 3078 | lastfield_j=str2double(get(handles.nb_field2,'String')); |
---|
| 3079 | num1_civ1=ref_i;% set of first image numbers |
---|
| 3080 | num2_civ1=ref_i; |
---|
| 3081 | num_a_civ1=ref_j-floor(index_civ1/2)*ones(size(ref_j)); |
---|
| 3082 | num_b_civ1=ref_j+ceil(index_civ1/2)*ones(size(ref_j)); |
---|
| 3083 | num1_civ2=ref_i; |
---|
| 3084 | num2_civ2=ref_i; |
---|
| 3085 | num_a_civ2=ref_j-floor(index_civ2/2)*ones(size(ref_j)); |
---|
| 3086 | num_b_civ2=ref_j+ceil(index_civ2/2)*ones(size(ref_j)); |
---|
| 3087 | % adjust the first and last field number |
---|
| 3088 | if isnan(lastfield_j) |
---|
| 3089 | indsel=find((num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
| 3090 | else |
---|
| 3091 | indsel=find((num_b_civ1 <= lastfield_j)&(num_b_civ2 <= lastfield_j)&(num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
| 3092 | end |
---|
| 3093 | if length(indsel)>=1 |
---|
| 3094 | firstind=indsel(1); |
---|
| 3095 | lastind=indsel(end); |
---|
| 3096 | set(handles.first_j,'String',num2str(ref_j(firstind)))%update the display of first and last fields |
---|
| 3097 | set(handles.last_j,'String',num2str(ref_j(lastind))) |
---|
| 3098 | ref_j=ref_j(indsel); |
---|
| 3099 | num_a_civ1=num_a_civ1(indsel); |
---|
| 3100 | num_b_civ1=num_b_civ1(indsel); |
---|
| 3101 | num_a_civ2=num_a_civ2(indsel); |
---|
| 3102 | num_b_civ2=num_b_civ2(indsel); |
---|
| 3103 | end |
---|
| 3104 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
| 3105 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 3106 | num1_civ1=ref_i; |
---|
| 3107 | num2_civ1=ref_i; |
---|
| 3108 | num_a_civ1=displ_num(1,index_civ1); |
---|
| 3109 | num_b_civ1=displ_num(2,index_civ1); |
---|
| 3110 | num1_civ2=ref_i; |
---|
| 3111 | num2_civ2=ref_i; |
---|
| 3112 | num_a_civ2=displ_num(1,index_civ2); |
---|
| 3113 | num_b_civ2=displ_num(2,index_civ2); |
---|
| 3114 | elseif isequal(mode,'displacement') |
---|
| 3115 | num1_civ1=ref_i; |
---|
| 3116 | num2_civ1=ref_i; |
---|
| 3117 | num_a_civ1=ref_j; |
---|
| 3118 | num_b_civ1=ref_j; |
---|
| 3119 | num1_civ2=ref_i; |
---|
| 3120 | num2_civ2=ref_i; |
---|
| 3121 | num_a_civ2=ref_j; |
---|
| 3122 | num_b_civ2=ref_j; |
---|
| 3123 | end |
---|
| 3124 | |
---|
| 3125 | |
---|
| 3126 | %------------------------------------------------------------------------ |
---|
[12] | 3127 | % --- PATCH |
---|
[94] | 3128 | function cmd_PATCH=PATCH_CMD(filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,test_interp,PatchBin) |
---|
[12] | 3129 | %------------------------------------------------------------------------ |
---|
[224] | 3130 | namelog=[filename_nc(1:end-3) '_patch.log']; |
---|
[112] | 3131 | if test_interp==0 |
---|
[163] | 3132 | if isunix |
---|
[112] | 3133 | cmd_PATCH=[PatchBin ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ... |
---|
| 3134 | ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
[163] | 3135 | else |
---|
| 3136 | cmd_PATCH=['"' PatchBin '" -f "' filename_nc '" -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ... |
---|
| 3137 | ' > "' namelog '" 2>&1']; % redirect standard output to the log file |
---|
| 3138 | end |
---|
[112] | 3139 | else %nouveau programme patch |
---|
| 3140 | cmd_PATCH=[PatchBin ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ... |
---|
| 3141 | ' -max ' thresh_value ' -nopt ' subdomain_patch ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
| 3142 | end |
---|
[163] | 3143 | cmd_PATCH=regexprep(cmd_PATCH,'\\','\\\\'); |
---|
[12] | 3144 | %------------------------------------------------------------------------ |
---|
| 3145 | % --- STEREO Interp |
---|
[67] | 3146 | 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] | 3147 | %------------------------------------------------------------------------ |
---|
[224] | 3148 | namelog=[filename_nc(1:end-3) '_stinterp.log']; |
---|
[67] | 3149 | cmd=[stinterpBin ' -f1 ' filename_A_nc ' -f2 ' filename_B_nc ' -f ' filename_nc ... |
---|
[2] | 3150 | ' -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 |
---|
| 3151 | |
---|
[12] | 3152 | %------------------------------------------------------------------------ |
---|
[2] | 3153 | % --- Executes on button press in CIV1. |
---|
| 3154 | function CIV1_Callback(hObject, eventdata, handles) |
---|
[12] | 3155 | %------------------------------------------------------------------------ |
---|
[2] | 3156 | val=get(handles.CIV1,'Value'); |
---|
| 3157 | if isequal(val,1) |
---|
| 3158 | enable_civ1(handles,'on') |
---|
| 3159 | enable_pair1(handles,'on') |
---|
| 3160 | else |
---|
| 3161 | enable_civ1(handles,'off') |
---|
| 3162 | end |
---|
| 3163 | find_netcpair_civ1(hObject, eventdata, handles); |
---|
| 3164 | |
---|
[12] | 3165 | %------------------------------------------------------------------------ |
---|
[2] | 3166 | % --- Executes on button press in FIX1. |
---|
| 3167 | function FIX1_Callback(hObject, eventdata, handles) |
---|
[12] | 3168 | %------------------------------------------------------------------------ |
---|
[2] | 3169 | enable_fix1(handles,get(handles.FIX1,'Value')) |
---|
| 3170 | |
---|
[12] | 3171 | %------------------------------------------------------------------------ |
---|
[2] | 3172 | % --- Executes on button press in PATCH1. |
---|
| 3173 | function PATCH1_Callback(hObject, eventdata, handles) |
---|
[12] | 3174 | %------------------------------------------------------------------------ |
---|
[2] | 3175 | if get(handles.PATCH1,'Value')==1 |
---|
[12] | 3176 | enable_patch1(handles) |
---|
[2] | 3177 | else |
---|
[12] | 3178 | desable_patch1(handles) |
---|
[2] | 3179 | end |
---|
| 3180 | |
---|
[12] | 3181 | %------------------------------------------------------------------------ |
---|
[2] | 3182 | % --- Executes on button press in CIV2. |
---|
| 3183 | function CIV2_Callback(hObject, eventdata, handles) |
---|
[12] | 3184 | %------------------------------------------------------------------------ |
---|
[2] | 3185 | state=get(handles.CIV2,'Value'); |
---|
| 3186 | enable_civ2(handles,state) |
---|
| 3187 | if state |
---|
| 3188 | find_netcpair_civ2(hObject, eventdata, handles) |
---|
| 3189 | enable_pair1(handles,'on') |
---|
| 3190 | end |
---|
| 3191 | |
---|
[12] | 3192 | %------------------------------------------------------------------------ |
---|
[2] | 3193 | % --- Executes on button press in FIX2. |
---|
| 3194 | function FIX2_Callback(hObject, eventdata, handles) |
---|
[12] | 3195 | %------------------------------------------------------------------------ |
---|
[2] | 3196 | if get(handles.FIX2,'Value')==1 |
---|
| 3197 | enable_fix2(handles) |
---|
| 3198 | if get(handles.CIV2,'Value')==0 |
---|
| 3199 | find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files |
---|
| 3200 | end |
---|
| 3201 | else |
---|
| 3202 | desable_fix2(handles) |
---|
| 3203 | end |
---|
| 3204 | |
---|
[12] | 3205 | %------------------------------------------------------------------------ |
---|
[2] | 3206 | % --- Executes on button press in PATCH2. |
---|
| 3207 | function PATCH2_Callback(hObject, eventdata, handles) |
---|
[12] | 3208 | %------------------------------------------------------------------------ |
---|
[2] | 3209 | if get(handles.PATCH2,'Value')==1 |
---|
| 3210 | enable_patch2(handles) |
---|
| 3211 | if get(handles.CIV2,'Value')==0 |
---|
| 3212 | find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files |
---|
| 3213 | end |
---|
| 3214 | else |
---|
| 3215 | desable_patch2(handles) |
---|
| 3216 | end |
---|
| 3217 | |
---|
[12] | 3218 | %------------------------------------------------------------------------ |
---|
| 3219 | function first_i_Callback(hObject, eventdata, handles) |
---|
| 3220 | %------------------------------------------------------------------------ |
---|
| 3221 | % last_i_Callback(hObject, eventdata, handles) |
---|
[137] | 3222 | first_i=str2double(get(handles.first_i,'String')); |
---|
[12] | 3223 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 3224 | % ref_i=ceil((first_i+last_i)/2); |
---|
| 3225 | set(handles.ref_i,'String', num2str(first_i))% reference index for pair dt = first index |
---|
[71] | 3226 | set(handles.ref_i_civ2,'String', num2str(first_i))% reference index for pair dt = first index |
---|
[12] | 3227 | ref_i_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3228 | |
---|
[12] | 3229 | %------------------------------------------------------------------------ |
---|
| 3230 | function first_j_Callback(hObject, eventdata, handles) |
---|
| 3231 | %------------------------------------------------------------------------ |
---|
| 3232 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 3233 | set(handles.ref_j,'String', num2str(first_j))% reference index for pair dt = first index |
---|
| 3234 | ref_j_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3235 | |
---|
[12] | 3236 | %------------------------------------------------------------------------ |
---|
[2] | 3237 | % --- Executes on button press in calcul_search: determine the search range isx,isy |
---|
| 3238 | function calcul_search_Callback(hObject, eventdata, handles) |
---|
[12] | 3239 | %------------------------------------------------------------------------ |
---|
[2] | 3240 | %determine pair numbers |
---|
| 3241 | list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs |
---|
| 3242 | index=get(handles.list_pair_civ1,'Value'); |
---|
| 3243 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
[71] | 3244 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
[2] | 3245 | pxcm_xy=get(handles.calcul_search,'UserData'); |
---|
| 3246 | pxcmx=pxcm_xy(1); |
---|
| 3247 | pxcmy=pxcm_xy(2); |
---|
| 3248 | mode_list=get(handles.mode,'String'); |
---|
| 3249 | mode_value=get(handles.mode,'Value'); |
---|
| 3250 | mode=mode_list{mode_value}; |
---|
| 3251 | if isequal (mode, 'series(Di)' ) |
---|
[137] | 3252 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[2] | 3253 | num1=ref_i-floor(index/2);% first image numbers |
---|
| 3254 | num2=ref_i+ceil(index/2); |
---|
| 3255 | num_a=1; |
---|
| 3256 | num_b=1; |
---|
[112] | 3257 | elseif isequal (mode, 'series(Dj)') |
---|
[2] | 3258 | num1=1; |
---|
| 3259 | num2=1; |
---|
[137] | 3260 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
[2] | 3261 | num_a=ref_j-floor(index/2);% first image numbers |
---|
| 3262 | num_b=ref_j+ceil(index/2); |
---|
| 3263 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
[137] | 3264 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[2] | 3265 | num1=ref_i; |
---|
| 3266 | num2=ref_i; |
---|
| 3267 | num_a=displ_num(1,index); |
---|
| 3268 | num_b=displ_num(2,index); |
---|
| 3269 | end |
---|
| 3270 | dt=time(num2,num_b)-time(num1,num_a); |
---|
[137] | 3271 | ibx=str2double(get(handles.ibx,'String')); |
---|
| 3272 | iby=str2double(get(handles.iby,'String')); |
---|
| 3273 | umin=dt*pxcmx*str2double(get(handles.umin,'String')); |
---|
| 3274 | umax=dt*pxcmx*str2double(get(handles.umax,'String')); |
---|
| 3275 | vmin=dt*pxcmy*str2double(get(handles.vmin,'String')); |
---|
| 3276 | vmax=dt*pxcmy*str2double(get(handles.vmax,'String')); |
---|
[2] | 3277 | shiftx=round((umin+umax)/2); |
---|
| 3278 | shifty=round((vmin+vmax)/2); |
---|
| 3279 | isx=(umax+2-shiftx)*2+ibx; |
---|
| 3280 | isx=2*ceil(isx/2)+1; |
---|
| 3281 | isy=(vmax+2-shifty)*2+iby; |
---|
| 3282 | isy=2*ceil(isy/2)+1; |
---|
| 3283 | set(handles.shiftx,'String',num2str(shiftx)); |
---|
| 3284 | set(handles.shifty,'String',num2str(shifty)); |
---|
| 3285 | set(handles.isx,'String',num2str(isx)); |
---|
| 3286 | set(handles.isy,'String',num2str(isy)); |
---|
| 3287 | |
---|
[12] | 3288 | %------------------------------------------------------------------------ |
---|
| 3289 | % --- Executes on carriage return on the subdir civ1 edit window |
---|
[2] | 3290 | function subdir_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 3291 | %------------------------------------------------------------------------ |
---|
[2] | 3292 | subdir=get(handles.subdir_civ1,'String'); |
---|
| 3293 | set(handles.subdir_civ2,'String',subdir); |
---|
[112] | 3294 | if get(handles.CIV1,'Value')==0 |
---|
[2] | 3295 | find_netcpair_civ1(hObject, eventdata, handles); %update the list of available pairs from netcdf files in the new directory |
---|
| 3296 | end |
---|
| 3297 | |
---|
[12] | 3298 | %------------------------------------------------------------------------ |
---|
| 3299 | % --- Executes on carriage return on the subdir civ1 edit window |
---|
[2] | 3300 | function subdir_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 3301 | %------------------------------------------------------------------------ |
---|
[2] | 3302 | %update the list of available pairs from netcdf files in the new directory |
---|
| 3303 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0 |
---|
| 3304 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 3305 | end |
---|
| 3306 | |
---|
[12] | 3307 | %------------------------------------------------------------------------ |
---|
[133] | 3308 | % --- Executes on button press in get_mask_civ1: select box for mask option |
---|
[2] | 3309 | function get_mask_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 3310 | %------------------------------------------------------------------------ |
---|
[252] | 3311 | maskval=get(handles.get_mask_civ1,'Value') |
---|
[2] | 3312 | if isequal(maskval,0) |
---|
| 3313 | set(handles.mask_civ1,'String','') |
---|
| 3314 | else |
---|
| 3315 | mask_displ='no mask'; %default |
---|
[71] | 3316 | filebase=get(handles.RootName,'String'); |
---|
[2] | 3317 | [ nbslice_mask, flag_mask]=get_mask(filebase,handles); |
---|
| 3318 | if isequal(flag_mask,1) |
---|
[112] | 3319 | mask_displ=[num2str(nbslice_mask) 'mask']; |
---|
[2] | 3320 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[112] | 3321 | common_path=fileparts(filebase); |
---|
| 3322 | filebase_a=fullfile(common_path,get(handles.RootName_1,'String')); |
---|
| 3323 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
| 3324 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice_mask) |
---|
| 3325 | mask_displ='no mask'; |
---|
| 3326 | end |
---|
[2] | 3327 | end |
---|
| 3328 | if isequal(mask_displ,'no mask') |
---|
[12] | 3329 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3330 | {'*.png', ' (*.png)'; |
---|
| 3331 | '*.png', '.png files '; ... |
---|
| 3332 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3333 | 'Pick a mask file *.png',filebase); |
---|
| 3334 | mask_displ=fullfile(PathName,FileName); |
---|
[12] | 3335 | if ~exist(mask_displ,'file') |
---|
| 3336 | mask_displ='no mask'; |
---|
| 3337 | end |
---|
| 3338 | end |
---|
| 3339 | if isequal(mask_displ,'no mask') |
---|
[2] | 3340 | set(handles.get_mask_civ1,'Value',0) |
---|
| 3341 | set(handles.get_mask_fix1,'Value',0) |
---|
| 3342 | set(handles.get_mask_civ2,'Value',0) |
---|
| 3343 | set(handles.get_mask_fix2,'Value',0) |
---|
| 3344 | else |
---|
| 3345 | set(handles.get_mask_fix1,'Value',1) |
---|
| 3346 | set(handles.get_mask_fix2,'Value',1) |
---|
| 3347 | end |
---|
| 3348 | set(handles.mask_civ1,'String',mask_displ) |
---|
| 3349 | set(handles.mask_fix1,'String',mask_displ) |
---|
| 3350 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 3351 | set(handles.mask_fix2,'String',mask_displ) |
---|
| 3352 | end |
---|
[133] | 3353 | set(handles.get_mask_civ2,'Value',maskval)%update the civ2 mask with the same option as civ1 |
---|
[2] | 3354 | |
---|
[12] | 3355 | %------------------------------------------------------------------------ |
---|
[2] | 3356 | % --- Executes on button press in get_mask_fix1. |
---|
| 3357 | function get_mask_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 3358 | %------------------------------------------------------------------------ |
---|
[2] | 3359 | maskval=get(handles.get_mask_fix1,'Value'); |
---|
| 3360 | if isequal(maskval,0) |
---|
| 3361 | set(handles.mask_fix1,'String','') |
---|
| 3362 | else |
---|
[112] | 3363 | mask_displ='no mask'; %default |
---|
| 3364 | filebase=get(handles.RootName,'String'); |
---|
| 3365 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3366 | if isequal(flag_mask,1) |
---|
| 3367 | mask_displ=[num2str(nbslice) 'mask']; |
---|
| 3368 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[71] | 3369 | filebase_a=get(handles.RootName_1,'String'); |
---|
[2] | 3370 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[229] | 3371 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
[2] | 3372 | mask_displ='no mask'; |
---|
| 3373 | end |
---|
[112] | 3374 | end |
---|
| 3375 | if isequal(mask_displ,'no mask') |
---|
| 3376 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3377 | {'*.png', ' (*.png)'; |
---|
[12] | 3378 | '*.png', '.png files '; ... |
---|
| 3379 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3380 | 'Pick a mask file *.png',filebase); |
---|
[112] | 3381 | mask_displ=fullfile(PathName,FileName); |
---|
| 3382 | if ~exist(mask_displ,'file') |
---|
| 3383 | mask_displ='no mask'; |
---|
| 3384 | end |
---|
[12] | 3385 | end |
---|
[112] | 3386 | if isequal(mask_displ,'no mask') |
---|
| 3387 | set(handles.get_mask_fix1,'Value',0) |
---|
| 3388 | set(handles.get_mask_civ2,'Value',0) |
---|
| 3389 | set(handles.get_mask_fix2,'Value',0) |
---|
| 3390 | else |
---|
| 3391 | %set(handles.get_mask_civ2,'Value',1) |
---|
| 3392 | set(handles.get_mask_fix2,'Value',1) |
---|
| 3393 | end |
---|
| 3394 | set(handles.mask_fix1,'String',mask_displ) |
---|
| 3395 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 3396 | set(handles.mask_fix2,'String',mask_displ) |
---|
[12] | 3397 | end |
---|
| 3398 | |
---|
| 3399 | %------------------------------------------------------------------------ |
---|
[133] | 3400 | % --- Executes on button press in get_mask_civ2: select box for mask option |
---|
[2] | 3401 | function get_mask_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 3402 | %------------------------------------------------------------------------ |
---|
[2] | 3403 | maskval=get(handles.get_mask_civ2,'Value'); |
---|
| 3404 | if isequal(maskval,0) |
---|
| 3405 | set(handles.mask_civ2,'String','') |
---|
| 3406 | else |
---|
[112] | 3407 | mask_displ='no mask'; %default |
---|
| 3408 | filebase=get(handles.RootName,'String'); |
---|
| 3409 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3410 | if isequal(flag_mask,1) |
---|
| 3411 | mask_displ=[num2str(nbslice) 'mask']; |
---|
| 3412 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[71] | 3413 | filebase_a=get(handles.RootName_1,'String'); |
---|
[2] | 3414 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[229] | 3415 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
[2] | 3416 | mask_displ='no mask'; |
---|
| 3417 | end |
---|
[112] | 3418 | end |
---|
| 3419 | if isequal(mask_displ,'no mask') |
---|
| 3420 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3421 | {'*.png', ' (*.png)'; |
---|
[12] | 3422 | '*.png', '.png files '; ... |
---|
| 3423 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3424 | 'Pick a mask file *.png',filebase); |
---|
[112] | 3425 | mask_displ=fullfile(PathName,FileName); |
---|
| 3426 | if ~exist(mask_displ,'file') |
---|
| 3427 | mask_displ='no mask'; |
---|
| 3428 | end |
---|
[12] | 3429 | end |
---|
[112] | 3430 | if isequal(mask_displ,'no mask') |
---|
| 3431 | set(handles.get_mask_civ2,'Value',0) |
---|
| 3432 | set(handles.get_mask_fix2,'Value',0) |
---|
| 3433 | else |
---|
| 3434 | set(handles.get_mask_fix2,'Value',1) |
---|
| 3435 | end |
---|
| 3436 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 3437 | set(handles.mask_fix2,'String',mask_displ) |
---|
[12] | 3438 | end |
---|
| 3439 | |
---|
| 3440 | %------------------------------------------------------------------------ |
---|
[2] | 3441 | % --- Executes on button press in get_mask_fix2. |
---|
| 3442 | function get_mask_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 3443 | %------------------------------------------------------------------------ |
---|
[2] | 3444 | maskval=get(handles.get_mask_fix2,'Value'); |
---|
| 3445 | if isequal(maskval,0) |
---|
| 3446 | set(handles.mask_fix2,'String','') |
---|
| 3447 | else |
---|
[12] | 3448 | mask_displ='no mask'; %default |
---|
[71] | 3449 | filebase=get(handles.RootName,'String'); |
---|
[12] | 3450 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3451 | if isequal(flag_mask,1) |
---|
[112] | 3452 | mask_displ=[num2str(nbslice) 'mask']; |
---|
[12] | 3453 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[112] | 3454 | filebase_a=get(handles.RootName_1,'String'); |
---|
| 3455 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[229] | 3456 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
[112] | 3457 | mask_displ='no mask'; |
---|
| 3458 | end |
---|
[12] | 3459 | end |
---|
| 3460 | if isequal(mask_displ,'no mask') |
---|
| 3461 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3462 | {'*.png', ' (*.png)'; |
---|
| 3463 | '*.png', '.png files '; ... |
---|
| 3464 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3465 | 'Pick a mask file *.png',filebase); |
---|
| 3466 | mask_displ=fullfile(PathName,FileName); |
---|
[12] | 3467 | if ~exist(mask_displ,'file') |
---|
[2] | 3468 | mask_displ='no mask'; |
---|
| 3469 | end |
---|
[12] | 3470 | end |
---|
| 3471 | if isequal(mask_displ,'no mask') |
---|
| 3472 | set(handles.get_mask_fix2,'Value',0) |
---|
[112] | 3473 | end |
---|
[12] | 3474 | set(handles.mask_fix2,'String',mask_displ) |
---|
[2] | 3475 | end |
---|
| 3476 | |
---|
[12] | 3477 | %------------------------------------------------------------------------ |
---|
| 3478 | % --- function called to look for mask files |
---|
[2] | 3479 | function [nbslice, flag_mask]=get_mask(filebase,handles) |
---|
[12] | 3480 | %------------------------------------------------------------------------ |
---|
[112] | 3481 | %detect mask files, images with appropriate file base |
---|
[2] | 3482 | %[filebase '_' xx 'mask'], xx=nbslice |
---|
| 3483 | %flag_mask=1 indicates detection |
---|
| 3484 | |
---|
| 3485 | flag_mask=0;%default |
---|
| 3486 | nbslice=1; |
---|
| 3487 | |
---|
| 3488 | % subdir=get(handles.subdir_civ1,'String'); |
---|
| 3489 | [Path,Name]=fileparts(filebase); |
---|
[12] | 3490 | if ~isdir(Path) |
---|
| 3491 | msgbox_uvmat('ERROR','no path for input files') |
---|
| 3492 | return |
---|
| 3493 | end |
---|
[2] | 3494 | currentdir=pwd; |
---|
| 3495 | cd(Path);%move in the dir of the root name filebase |
---|
| 3496 | maskfiles=dir([Name '_*mask_*.png']);%look for mask files |
---|
| 3497 | cd(currentdir);%come back to the current working directory |
---|
[12] | 3498 | if ~isempty(maskfiles) |
---|
[112] | 3499 | % msgbox_uvmat('ERROR','no mask available, to create it use Tools/Make mask in the upper menu bar of uvmat') |
---|
| 3500 | % else |
---|
[2] | 3501 | flag_mask=1; |
---|
| 3502 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 3503 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 3504 | Namedouble=double(Name); |
---|
| 3505 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 3506 | ind_mask=findstr('mask',Name); |
---|
| 3507 | i=ind_mask-1; |
---|
[137] | 3508 | while val(i)==0 && i>0 |
---|
[112] | 3509 | i=i-1; |
---|
[2] | 3510 | end |
---|
[137] | 3511 | nbslice=str2double(Name(i+1:ind_mask-1)); |
---|
| 3512 | if ~isnan(nbslice) && Name(i)=='_' |
---|
[112] | 3513 | flag_mask=1; |
---|
[2] | 3514 | else |
---|
[112] | 3515 | msgbox_uvmat('ERROR',['bad mask file ' Name ext ' found in ' Path2]) |
---|
| 3516 | return |
---|
| 3517 | nbslice=1; |
---|
[2] | 3518 | end |
---|
[112] | 3519 | end |
---|
[2] | 3520 | |
---|
[12] | 3521 | %------------------------------------------------------------------------ |
---|
| 3522 | % --- function called to look for grid files |
---|
[2] | 3523 | function [nbslice, flag_mask]=get_grid(filebase,handles) |
---|
[12] | 3524 | %------------------------------------------------------------------------ |
---|
[2] | 3525 | flag_mask=0;%default |
---|
| 3526 | nbslice=1; |
---|
| 3527 | [Path,Name]=fileparts(filebase); |
---|
| 3528 | currentdir=pwd; |
---|
| 3529 | cd(Path);%move in the dir of the root name filebase |
---|
| 3530 | maskfiles=dir([Name '_*grid_*.grid']);%look for mask files |
---|
| 3531 | cd(currentdir);%come back to the current working directory |
---|
| 3532 | if ~isempty(maskfiles) |
---|
| 3533 | flag_mask=1; |
---|
| 3534 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 3535 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 3536 | Namedouble=double(Name); |
---|
| 3537 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 3538 | ind_mask=findstr('grid',Name); |
---|
| 3539 | i=ind_mask-1; |
---|
[137] | 3540 | while val(i)==0 && i>0 |
---|
[112] | 3541 | i=i-1; |
---|
[2] | 3542 | end |
---|
[137] | 3543 | nbslice=str2double(Name(i+1:ind_mask-1)); |
---|
| 3544 | if ~isnan(nbslice) && Name(i)=='_' |
---|
[112] | 3545 | flag_mask=1; |
---|
[2] | 3546 | else |
---|
[112] | 3547 | msgbox_uvmat('ERROR',['bad grid file ' Name ext ' found in ' Path2]) |
---|
| 3548 | return |
---|
| 3549 | nbslice=1; |
---|
[2] | 3550 | end |
---|
[12] | 3551 | end |
---|
[2] | 3552 | |
---|
[12] | 3553 | %------------------------------------------------------------------------ |
---|
| 3554 | % --- transform numbers to letters |
---|
[122] | 3555 | function str=num2stra(num,nom_type) |
---|
[12] | 3556 | %------------------------------------------------------------------------ |
---|
[122] | 3557 | if isempty(nom_type) |
---|
| 3558 | str=''; |
---|
| 3559 | elseif strcmp(nom_type(end),'a') |
---|
[2] | 3560 | str=char(96+num); |
---|
[122] | 3561 | elseif strcmp(nom_type(end),'A') |
---|
| 3562 | str=char(96+num); |
---|
| 3563 | elseif isempty(nom_type(2:end))%a single index |
---|
[2] | 3564 | str=''; |
---|
| 3565 | else |
---|
| 3566 | str=num2str(num); |
---|
| 3567 | end |
---|
[12] | 3568 | |
---|
| 3569 | %------------------------------------------------------------------------ |
---|
[2] | 3570 | % --- Executes on button press in list_subdir_civ1. |
---|
| 3571 | function list_subdir_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 3572 | %------------------------------------------------------------------------ |
---|
[2] | 3573 | list_subdir_civ1=get(handles.list_subdir_civ1,'String'); |
---|
| 3574 | val=get(handles.list_subdir_civ1,'Value'); |
---|
| 3575 | if val>1 |
---|
| 3576 | subdir=list_subdir_civ1{val}; |
---|
| 3577 | set(handles.subdir_civ1,'String',subdir); |
---|
| 3578 | set(handles.list_subdir_civ1,'Value',1); |
---|
| 3579 | end |
---|
| 3580 | |
---|
[12] | 3581 | %------------------------------------------------------------------------ |
---|
[2] | 3582 | % --- Executes on button press in list_subdir_civ2. |
---|
| 3583 | function list_subdir_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 3584 | %------------------------------------------------------------------------ |
---|
[2] | 3585 | list_subdir_civ2=get(handles.list_subdir_civ2,'String'); |
---|
| 3586 | val=get(handles.list_subdir_civ2,'Value'); |
---|
| 3587 | if val>1 |
---|
| 3588 | subdir=list_subdir_civ2{val}; |
---|
| 3589 | set(handles.subdir_civ2,'String',subdir); |
---|
| 3590 | set(handles.list_subdir_civ2,'Value',1); |
---|
| 3591 | end |
---|
| 3592 | |
---|
[12] | 3593 | %------------------------------------------------------------------------ |
---|
[2] | 3594 | % --- Executes on button press in browse_gridciv1. |
---|
| 3595 | function browse_gridciv1_Callback(hObject, eventdata, handles) |
---|
[12] | 3596 | %------------------------------------------------------------------------ |
---|
[2] | 3597 | value=get(handles.browse_gridciv1,'Value'); |
---|
| 3598 | testgrid=0; |
---|
| 3599 | if value |
---|
[112] | 3600 | filebase=get(handles.RootName,'String'); |
---|
[39] | 3601 | [nbslice, flag_grid]=get_grid(filebase,handles); |
---|
[2] | 3602 | if isequal(flag_grid,1) |
---|
[112] | 3603 | filegrid=[num2str(nbslice) 'grid']; |
---|
| 3604 | testgrid=1; |
---|
| 3605 | else |
---|
[2] | 3606 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3607 | {'*.grid', ' (*.grid)'; |
---|
| 3608 | '*.grid', '.grid files '; ... |
---|
| 3609 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3610 | 'Pick a file',filebase); |
---|
[2] | 3611 | filegrid=fullfile(PathName,FileName); |
---|
| 3612 | if ~(isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file')) |
---|
| 3613 | testgrid=1; |
---|
| 3614 | end |
---|
[112] | 3615 | end |
---|
[2] | 3616 | end |
---|
| 3617 | if testgrid |
---|
[112] | 3618 | set(handles.browse_gridciv2,'Value',1) |
---|
| 3619 | set(handles.get_gridpatch1,'Value',1) |
---|
| 3620 | set(handles.get_gridpatch2,'Value',1) |
---|
| 3621 | set(handles.dx_civ1,'Visible','off'); |
---|
| 3622 | set(handles.dy_civ1,'Visible','off'); |
---|
| 3623 | set(handles.dx_civ2,'Visible','off'); |
---|
| 3624 | set(handles.dy_civ2,'Visible','off'); |
---|
| 3625 | set(handles.grid_civ1,'String',filegrid) |
---|
| 3626 | set(handles.grid_patch1,'String',filegrid) |
---|
| 3627 | set(handles.grid_civ2,'String',filegrid) |
---|
| 3628 | set(handles.grid_patch2,'String',filegrid) |
---|
| 3629 | else |
---|
| 3630 | set(handles.browse_gridciv1,'Value',0); |
---|
| 3631 | set(handles.browse_gridciv2,'Value',0); |
---|
| 3632 | set(handles.get_gridpatch1,'Value',0) |
---|
| 3633 | set(handles.get_gridpatch2,'Value',0) |
---|
| 3634 | set(handles.dx_civ1,'Visible','on'); |
---|
| 3635 | set(handles.dy_civ1,'Visible','on'); |
---|
| 3636 | set(handles.dx_civ2,'Visible','on'); |
---|
| 3637 | set(handles.dy_civ2,'Visible','on'); |
---|
| 3638 | set(handles.grid_civ1,'String','') |
---|
| 3639 | set(handles.grid_patch1,'String','') |
---|
| 3640 | set(handles.grid_civ2,'String','') |
---|
| 3641 | set(handles.grid_patch2,'String','') |
---|
[2] | 3642 | end |
---|
| 3643 | |
---|
[12] | 3644 | %------------------------------------------------------------------------ |
---|
[2] | 3645 | % --- Executes on button press in browse_gridciv1. |
---|
| 3646 | function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
[12] | 3647 | %------------------------------------------------------------------------ |
---|
[2] | 3648 | value=get(handles.browse_gridciv2,'Value'); |
---|
| 3649 | if value |
---|
[112] | 3650 | filebase=get(handles.RootName,'String'); |
---|
[39] | 3651 | [nbslice, flag_grid]=get_grid(filebase,handles); |
---|
[2] | 3652 | if isequal(flag_grid,1) |
---|
| 3653 | mask_displ=[num2str(nbslice) 'grid']; |
---|
| 3654 | set(handles.grid_civ2,'String',mask_displ) |
---|
| 3655 | set(handles.dx_civ2,'Visible','off'); |
---|
| 3656 | set(handles.dy_civ2,'Visible','off'); |
---|
[112] | 3657 | else |
---|
[2] | 3658 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3659 | {'*.grid', ' (*.grid)'; |
---|
| 3660 | '*.grid', '.grid files '; ... |
---|
| 3661 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3662 | 'Pick a file',filebase); |
---|
[2] | 3663 | filegrid=fullfile(PathName,FileName); |
---|
[229] | 3664 | if isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file') |
---|
[2] | 3665 | set(handles.browse_gridciv2,'Value',0); |
---|
| 3666 | set(handles.grid_civ2,'string',''); |
---|
| 3667 | set(handles.dx_civ2,'Visible','on'); |
---|
| 3668 | set(handles.dy_civ2,'Visible','on'); |
---|
| 3669 | set(handles.grid_civ2,'string',''); |
---|
| 3670 | else |
---|
| 3671 | set(handles.grid_civ2,'string',filegrid); |
---|
| 3672 | set(handles.dx_civ2,'Visible','off'); |
---|
| 3673 | set(handles.dy_civ2,'Visible','off'); |
---|
| 3674 | set(handles.grid_civ2,'string',filegrid); |
---|
| 3675 | end |
---|
| 3676 | end |
---|
| 3677 | else |
---|
| 3678 | set(handles.grid_civ2,'string',''); |
---|
[112] | 3679 | set(handles.dx_civ2,'Visible','on'); |
---|
| 3680 | set(handles.dy_civ2,'Visible','on'); |
---|
| 3681 | set(handles.grid_civ2,'string',''); |
---|
[2] | 3682 | end |
---|
| 3683 | |
---|
| 3684 | % % --- Executes on button press in browse_gridciv2. |
---|
| 3685 | % function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
[112] | 3686 | % |
---|
[71] | 3687 | % filebase=get(handles.RootName,'String'); |
---|
[2] | 3688 | % [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3689 | % {'*.grid', ' (*.grid)'; |
---|
| 3690 | % '*.grid', '.grid files '; ... |
---|
| 3691 | % '*.*', 'All Files (*.*)'}, ... |
---|
| 3692 | % 'Pick a file',filebase); |
---|
| 3693 | % filegrid=fullfile(PathName,FileName); |
---|
| 3694 | % set(handles.grid_civ2,'string',filegrid); |
---|
| 3695 | % set(handles.dx_civ2,'String',' '); |
---|
| 3696 | % set(handles.dy_civ2,'String',' '); |
---|
| 3697 | % % set(handles.grid_patch2,'string',filegrid); |
---|
| 3698 | |
---|
| 3699 | % --- Executes on button press in get_gridpatch1. |
---|
| 3700 | function get_gridpatch1_Callback(hObject, eventdata, handles) |
---|
| 3701 | % hObject handle to get_gridpatch1 (see GCBO) |
---|
| 3702 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 3703 | % handles structure with handles and user data (see GUIDATA) |
---|
| 3704 | |
---|
[71] | 3705 | filebase=get(handles.RootName,'String'); |
---|
[2] | 3706 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3707 | {'*.grid', ' (*.grid)'; |
---|
| 3708 | '*.grid', '.grid files '; ... |
---|
| 3709 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3710 | 'Pick a file',filebase); |
---|
[2] | 3711 | filegrid=fullfile(PathName,FileName); |
---|
| 3712 | set(handles.grid_patch1,'string',filegrid); |
---|
| 3713 | % set(handles.grid_patch2,'string',filegrid |
---|
| 3714 | |
---|
[12] | 3715 | %------------------------------------------------------------------------ |
---|
[2] | 3716 | % --- Executes on button press in get_gridpatch2. |
---|
| 3717 | function get_gridpatch2_Callback(hObject, eventdata, handles) |
---|
[12] | 3718 | %------------------------------------------------------------------------ |
---|
[2] | 3719 | |
---|
[12] | 3720 | %------------------------------------------------------------------------ |
---|
[2] | 3721 | function enable_civ1(handles,state) |
---|
[12] | 3722 | %------------------------------------------------------------------------ |
---|
[2] | 3723 | if isequal(state,'on') |
---|
| 3724 | set(handles.frame_civ1,'BackgroundColor',[1 1 0]) |
---|
| 3725 | set(handles.frame_para_civ1,'BackgroundColor',[1 1 0]) |
---|
| 3726 | set(handles.frame_grid_civ1,'BackgroundColor',[1 1 0]) |
---|
| 3727 | else |
---|
| 3728 | set(handles.frame_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3729 | set(handles.frame_para_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3730 | set(handles.frame_grid_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3731 | end |
---|
| 3732 | set(handles.ibx,'Visible',state) |
---|
| 3733 | set(handles.iby,'Visible',state) |
---|
| 3734 | set(handles.isx,'Visible',state) |
---|
| 3735 | set(handles.isy,'Visible',state) |
---|
| 3736 | set(handles.shiftx,'Visible',state) |
---|
| 3737 | set(handles.shifty,'Visible',state) |
---|
| 3738 | set(handles.rho,'Visible',state) |
---|
| 3739 | set(handles.dx_civ1,'Visible',state) |
---|
| 3740 | set(handles.dy_civ1,'Visible',state) |
---|
| 3741 | set(handles.calcul_search,'Visible',state) |
---|
| 3742 | set(handles.u_text,'Visible',state) |
---|
| 3743 | set(handles.v_text,'Visible',state) |
---|
| 3744 | set(handles.min,'Visible',state) |
---|
| 3745 | set(handles.max,'Visible',state) |
---|
| 3746 | set(handles.umin,'Visible',state) |
---|
| 3747 | set(handles.umax,'Visible',state) |
---|
| 3748 | set(handles.vmin,'Visible',state) |
---|
| 3749 | set(handles.vmax,'Visible',state) |
---|
| 3750 | set(handles.grid_civ1,'Visible',state) |
---|
| 3751 | set(handles.mask_civ1,'Visible',state) |
---|
| 3752 | set(handles.browse_gridciv1,'Visible',state) |
---|
| 3753 | set(handles.get_mask_civ1,'Visible',state) |
---|
| 3754 | set(handles.parameters,'Visible',state) |
---|
| 3755 | set(handles.grid,'Visible',state) |
---|
| 3756 | set(handles.dx_civ1,'Visible',state) |
---|
| 3757 | set(handles.dy_civ1,'Visible',state) |
---|
| 3758 | set(handles.ImaThreshold,'Visible',state) |
---|
| 3759 | if isequal(state,'off') |
---|
| 3760 | set(handles.MinIma,'Visible','off') |
---|
| 3761 | set(handles.MaxIma,'Visible','off') |
---|
| 3762 | set(handles.ImaThreshold,'Value',0) |
---|
| 3763 | end |
---|
| 3764 | set(handles.dx_civ1_title,'Visible',state) |
---|
| 3765 | set(handles.dy_civ1_title,'Visible',state) |
---|
| 3766 | set(handles.ImaThreshold_title,'Visible',state) |
---|
| 3767 | set(handles.ib_title,'Visible',state) |
---|
| 3768 | set(handles.is_title,'Visible',state) |
---|
| 3769 | set(handles.shift_title,'Visible',state) |
---|
| 3770 | set(handles.rho_title,'Visible',state) |
---|
[224] | 3771 | set(handles.TestCiv1,'Visible',state) |
---|
[257] | 3772 | %set(handles.CivMode,'Visible',state) |
---|
[2] | 3773 | |
---|
[12] | 3774 | %------------------------------------------------------------------------ |
---|
[2] | 3775 | function enable_fix1(handles,state) |
---|
[12] | 3776 | %------------------------------------------------------------------------ |
---|
[2] | 3777 | if isequal(state,0) |
---|
| 3778 | state='off'; |
---|
| 3779 | end |
---|
| 3780 | if isequal(state,1) |
---|
| 3781 | state='on'; |
---|
| 3782 | end |
---|
| 3783 | if isequal(state,'on') |
---|
| 3784 | set(handles.frame_fix1,'BackgroundColor',[1 1 0]) |
---|
| 3785 | else |
---|
| 3786 | set(handles.frame_fix1,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3787 | end |
---|
| 3788 | set(handles.REMOVE,'Visible',state) |
---|
| 3789 | set(handles.vec_Fmin2,'Visible',state) |
---|
| 3790 | set(handles.vec_F2,'Visible',state) |
---|
| 3791 | set(handles.vec_F3,'Visible',state) |
---|
| 3792 | set(handles.thresh_vecC,'Visible',state) |
---|
| 3793 | set(handles.thresh_vecC_title,'Visible',state) |
---|
| 3794 | set(handles.thresh_vel,'Visible',state) |
---|
| 3795 | set(handles.thresh_vel_text,'Visible',state) |
---|
| 3796 | set(handles.mask_fix1,'Visible',state) |
---|
| 3797 | set(handles.get_mask_fix1,'Visible',state) |
---|
| 3798 | set(handles.get_ref_fix1,'Visible',state) |
---|
| 3799 | set(handles.ref_fix1,'Visible',state) |
---|
| 3800 | set(handles.inf_sup1,'Visible',state) |
---|
| 3801 | set(handles.field_ref1,'Visible',state) |
---|
| 3802 | |
---|
[12] | 3803 | %------------------------------------------------------------------------ |
---|
[2] | 3804 | function enable_patch1(handles) |
---|
[12] | 3805 | %------------------------------------------------------------------------ |
---|
[2] | 3806 | set(handles.frame_patch1,'BackgroundColor',[1 1 0]) |
---|
| 3807 | set(handles.rho_patch1,'Visible','on') |
---|
| 3808 | set(handles.rho_text1,'Visible','on') |
---|
[257] | 3809 | if get(handles.CivMode,'Value')==2 |
---|
[224] | 3810 | set(handles.thresh_patch1,'Visible','on') |
---|
| 3811 | set(handles.thresh_text1,'Visible','on') |
---|
| 3812 | end |
---|
[2] | 3813 | set(handles.subdomain_patch1,'Visible','on') |
---|
| 3814 | set(handles.subdomain_text1,'Visible','on') |
---|
| 3815 | set(handles.nx_patch1,'Visible','on') |
---|
| 3816 | set(handles.ny_patch1,'Visible','on') |
---|
| 3817 | set(handles.nx_patch1_title,'Visible','on') |
---|
| 3818 | set(handles.ny_patch1_title,'Visible','on') |
---|
[112] | 3819 | % if ~isempty(patch_newBin) |
---|
[224] | 3820 | set(handles.test_interp,'Visible','off'); |
---|
[252] | 3821 | stereo_test=get(handles.compare,'Value'); |
---|
| 3822 | if stereo_test==3 |
---|
| 3823 | set(handles.test_stereo1,'Visible','on') |
---|
| 3824 | end |
---|
[100] | 3825 | % end |
---|
[252] | 3826 | %set(handles.get_gridpatch1,'Visible','on') |
---|
| 3827 | %set(handles.grid_patch1,'string','none'); |
---|
| 3828 | %set(handles.grid_patch1,'Visible','on') |
---|
[2] | 3829 | |
---|
[12] | 3830 | %------------------------------------------------------------------------ |
---|
[2] | 3831 | function desable_patch1(handles) |
---|
[12] | 3832 | %------------------------------------------------------------------------ |
---|
[2] | 3833 | set(handles.frame_patch1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3834 | set(handles.rho_patch1,'Visible','off') |
---|
| 3835 | set(handles.rho_text1,'Visible','off') |
---|
| 3836 | set(handles.thresh_patch1,'Visible','off') |
---|
| 3837 | set(handles.thresh_text1,'Visible','off') |
---|
| 3838 | set(handles.subdomain_patch1,'Visible','off') |
---|
| 3839 | set(handles.subdomain_text1,'Visible','off') |
---|
| 3840 | set(handles.nx_patch1,'Visible','off') |
---|
| 3841 | set(handles.ny_patch1,'Visible','off') |
---|
| 3842 | set(handles.nx_patch1_title,'Visible','off') |
---|
| 3843 | set(handles.ny_patch1_title,'Visible','off') |
---|
[252] | 3844 | set(handles.test_stereo1,'Visible','off') |
---|
[100] | 3845 | %set(handles.test_interp,'Visible','off') |
---|
[252] | 3846 | %set(handles.get_gridpatch1,'Visible','off') |
---|
| 3847 | %set(handles.grid_patch1,'Visible','off') |
---|
[2] | 3848 | |
---|
[12] | 3849 | %------------------------------------------------------------------------ |
---|
[2] | 3850 | function enable_civ2(handles,state) |
---|
[12] | 3851 | %------------------------------------------------------------------------ |
---|
[2] | 3852 | if isequal(state,0) |
---|
| 3853 | state='off'; |
---|
| 3854 | end |
---|
| 3855 | if isequal(state,1) |
---|
| 3856 | state='on'; |
---|
| 3857 | end |
---|
| 3858 | if isequal(state,'on') |
---|
| 3859 | set(handles.frame_civ2,'BackgroundColor',[1 1 0]) |
---|
| 3860 | set(handles.frame_para_civ2,'BackgroundColor',[1 1 0]) |
---|
| 3861 | set(handles.frame_grid_civ2,'BackgroundColor',[1 1 0]) |
---|
| 3862 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 3863 | else |
---|
| 3864 | set(handles.frame_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3865 | set(handles.frame_para_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3866 | set(handles.frame_grid_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3867 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3868 | end |
---|
| 3869 | set(handles.ibx_civ2,'Visible',state) |
---|
| 3870 | set(handles.iby_civ2,'Visible',state) |
---|
| 3871 | set(handles.decimal,'Visible',state) |
---|
| 3872 | set(handles.deformation,'Visible',state) |
---|
| 3873 | set(handles.rho_civ2,'Visible',state) |
---|
| 3874 | set(handles.dx_civ2,'Visible',state) |
---|
| 3875 | set(handles.dy_civ2,'Visible',state) |
---|
| 3876 | set(handles.browse_gridciv2,'Visible',state) |
---|
| 3877 | set(handles.get_mask_civ2,'Visible',state) |
---|
| 3878 | set(handles.parameters,'Visible',state) |
---|
| 3879 | set(handles.grid,'Visible',state) |
---|
| 3880 | set(handles.parameters_text,'Visible',state) |
---|
| 3881 | set(handles.grid_text,'Visible',state) |
---|
| 3882 | set(handles.grid_civ2,'Visible',state) |
---|
| 3883 | set(handles.mask_civ2,'Visible',state) |
---|
| 3884 | set(handles.dx_civ2_title,'Visible',state) |
---|
| 3885 | set(handles.dy_civ2_title,'Visible',state) |
---|
| 3886 | set(handles.ibx_civ2_text,'Visible',state) |
---|
| 3887 | set(handles.rho_civ2_title,'Visible',state) |
---|
| 3888 | set(handles.ImaThreshold2,'Visible',state) |
---|
| 3889 | set(handles.ImaThreshold_title2,'Visible',state) |
---|
| 3890 | if isequal(state,'off') |
---|
| 3891 | set(handles.MinIma2,'Visible','off') |
---|
| 3892 | set(handles.MaxIma2,'Visible','off') |
---|
| 3893 | set(handles.ImaThreshold2,'Value',0) |
---|
[112] | 3894 | if isequal(get(handles.FIX2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) |
---|
[2] | 3895 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 3896 | set(handles.subdir_civ2,'Visible','off') |
---|
| 3897 | set(handles.subdir_civ2_text,'Visible','off') |
---|
[71] | 3898 | set(handles.dt_unit_civ2,'Visible','off') |
---|
| 3899 | set(handles.ref_i_civ2,'Visible','off') |
---|
| 3900 | set(handles.i_ref_civ2_title,'Visible','off') |
---|
| 3901 | set(handles.j_ref_civ2_title,'Visible','off') |
---|
| 3902 | set(handles.ref_j_civ2,'Visible','off') |
---|
[2] | 3903 | end |
---|
| 3904 | else |
---|
| 3905 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 3906 | set(handles.subdir_civ2,'Visible','on') |
---|
| 3907 | set(handles.subdir_civ2_text,'Visible','on') |
---|
[71] | 3908 | set(handles.dt_unit_civ2,'Visible','on') |
---|
| 3909 | set(handles.ref_i_civ2,'Visible','on') |
---|
| 3910 | set(handles.i_ref_civ2_title,'Visible','on') |
---|
| 3911 | set(handles.j_ref_civ2_title,'Visible','on') |
---|
| 3912 | set(handles.ref_j_civ2,'Visible','on') |
---|
[2] | 3913 | end |
---|
[71] | 3914 | set(handles.rho_civ2_title,'Visible',state) |
---|
[2] | 3915 | |
---|
[12] | 3916 | %------------------------------------------------------------------------ |
---|
[2] | 3917 | function enable_fix2(handles) |
---|
[12] | 3918 | %------------------------------------------------------------------------ |
---|
[2] | 3919 | set(handles.frame_fix2,'BackgroundColor',[1 1 0]) |
---|
| 3920 | set(handles.REMOVE2,'Visible','on') |
---|
| 3921 | set(handles.vec_Fmin2_2,'Visible','on') |
---|
| 3922 | set(handles.vec_F4,'Visible','on') |
---|
| 3923 | set(handles.vec_F3_2,'Visible','on') |
---|
| 3924 | set(handles.thresh_vec2C,'Visible','on') |
---|
| 3925 | set(handles.thresh_vec2C_text,'Visible','on') |
---|
| 3926 | set(handles.thresh_vel2,'Visible','on') |
---|
| 3927 | set(handles.thresh_vel2_text,'Visible','on') |
---|
| 3928 | set(handles.mask_fix2,'Visible','on') |
---|
| 3929 | set(handles.get_mask_fix2,'Visible','on') |
---|
| 3930 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 3931 | set(handles.subdir_civ2,'Visible','on') |
---|
| 3932 | set(handles.subdir_civ2_text,'Visible','on') |
---|
| 3933 | set(handles.get_ref_fix2,'Visible','on') |
---|
| 3934 | set(handles.ref_fix2,'Visible','on') |
---|
| 3935 | set(handles.inf_sup2,'Visible','on') |
---|
| 3936 | set(handles.field_ref2,'Visible','on') |
---|
| 3937 | |
---|
[12] | 3938 | %------------------------------------------------------------------------ |
---|
[2] | 3939 | function desable_fix2(handles) |
---|
[12] | 3940 | %------------------------------------------------------------------------ |
---|
[2] | 3941 | set(handles.frame_fix2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3942 | set(handles.REMOVE2,'Visible','off') |
---|
| 3943 | set(handles.vec_Fmin2_2,'Visible','off') |
---|
| 3944 | set(handles.vec_F4,'Visible','off') |
---|
| 3945 | set(handles.vec_F3_2,'Visible','off') |
---|
| 3946 | set(handles.thresh_vec2C,'Visible','off') |
---|
| 3947 | set(handles.thresh_vec2C_text,'Visible','off') |
---|
| 3948 | set(handles.thresh_vel2,'Visible','off') |
---|
| 3949 | set(handles.thresh_vel2_text,'Visible','off') |
---|
| 3950 | set(handles.mask_fix2,'Visible','off') |
---|
| 3951 | set(handles.get_mask_fix2,'Visible','off') |
---|
| 3952 | set(handles.get_ref_fix2,'Visible','off') |
---|
| 3953 | set(handles.ref_fix2,'Visible','off') |
---|
| 3954 | set(handles.inf_sup2,'Visible','off') |
---|
| 3955 | set(handles.field_ref2,'Visible','off') |
---|
[112] | 3956 | if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) |
---|
[2] | 3957 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 3958 | set(handles.subdir_civ2,'Visible','off') |
---|
| 3959 | set(handles.subdir_civ2_text,'Visible','off') |
---|
| 3960 | end |
---|
| 3961 | |
---|
[12] | 3962 | %------------------------------------------------------------------------ |
---|
[2] | 3963 | function enable_patch2(handles) |
---|
[12] | 3964 | %------------------------------------------------------------------------ |
---|
[2] | 3965 | set(handles.frame_patch2,'BackgroundColor',[1 1 0]) |
---|
[119] | 3966 | set(handles.rho_patch2,'Visible','on') |
---|
[2] | 3967 | set(handles.rho_text2,'Visible','on') |
---|
| 3968 | set(handles.thresh_patch2,'Visible','on') |
---|
| 3969 | set(handles.thresh_text2,'Visible','on') |
---|
| 3970 | set(handles.subdomain_patch2,'Visible','on') |
---|
| 3971 | set(handles.subdomain_text2,'Visible','on') |
---|
| 3972 | set(handles.nx_patch2,'Visible','on') |
---|
| 3973 | set(handles.ny_patch2,'Visible','on') |
---|
| 3974 | set(handles.nx_patch2_title,'Visible','on') |
---|
| 3975 | set(handles.ny_patch2_title,'Visible','on') |
---|
[252] | 3976 | % set(handles.get_gridpatch2,'Visible','on') |
---|
| 3977 | % set(handles.grid_patch2,'Visible','on') |
---|
[2] | 3978 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 3979 | set(handles.subdir_civ2,'Visible','on') |
---|
| 3980 | set(handles.subdir_civ2_text,'Visible','on') |
---|
[252] | 3981 | stereo_test=get(handles.compare,'Value'); |
---|
| 3982 | if stereo_test==3 |
---|
| 3983 | set(handles.test_stereo2,'Visible','on') |
---|
| 3984 | end |
---|
[2] | 3985 | |
---|
[12] | 3986 | %------------------------------------------------------------------------ |
---|
[2] | 3987 | function desable_patch2(handles) |
---|
[12] | 3988 | %------------------------------------------------------------------------ |
---|
[2] | 3989 | set(handles.frame_patch2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3990 | set(handles.rho_patch2,'Visible','off') |
---|
| 3991 | set(handles.rho_text2,'Visible','off') |
---|
| 3992 | set(handles.thresh_patch2,'Visible','off') |
---|
| 3993 | set(handles.thresh_text2,'Visible','off') |
---|
| 3994 | set(handles.subdomain_patch2,'Visible','off') |
---|
| 3995 | set(handles.subdomain_text2,'Visible','off') |
---|
| 3996 | set(handles.nx_patch2,'Visible','off') |
---|
| 3997 | set(handles.ny_patch2,'Visible','off') |
---|
| 3998 | set(handles.nx_patch2_title,'Visible','off') |
---|
| 3999 | set(handles.ny_patch2_title,'Visible','off') |
---|
[252] | 4000 | % set(handles.get_gridpatch2,'Visible','off') |
---|
| 4001 | % set(handles.grid_patch2,'Visible','off') |
---|
[112] | 4002 | if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.FIX2,'Value'),0) |
---|
[2] | 4003 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 4004 | set(handles.subdir_civ2,'Visible','off') |
---|
| 4005 | set(handles.subdir_civ2_text,'Visible','off') |
---|
| 4006 | end |
---|
[252] | 4007 | set(handles.test_stereo2,'Visible','off') |
---|
[12] | 4008 | %------------------------------------------------------------------------ |
---|
[2] | 4009 | function enable_pair1(handles,state) |
---|
[12] | 4010 | %------------------------------------------------------------------------ |
---|
[2] | 4011 | set(handles.subdir_civ1,'Visible',state) |
---|
| 4012 | set(handles.list_subdir_civ1,'Visible',state) |
---|
| 4013 | set(handles.SUBDIR_CIV1_txt,'Visible',state) |
---|
| 4014 | set(handles.frame_subdirciv1,'Visible',state) |
---|
| 4015 | set(handles.list_pair_civ1,'Visible',state) |
---|
| 4016 | set(handles.PAIR_txt,'Visible',state) |
---|
[71] | 4017 | %set(handles.dt_unit,'Visible',state) |
---|
[2] | 4018 | set(handles.PAIR_frame,'Visible',state) |
---|
| 4019 | |
---|
[12] | 4020 | %------------------------------------------------------------------------ |
---|
| 4021 | % --- Read the parameters for civ1 on the interface |
---|
[2] | 4022 | function par=read_param_civ1(handles,file_ima) |
---|
[12] | 4023 | %------------------------------------------------------------------------ |
---|
[127] | 4024 | ibx_val=str2double(get(handles.ibx,'String')); |
---|
[2] | 4025 | par.ibx=num2str(ibx_val); |
---|
[127] | 4026 | iby_val=str2double(get(handles.iby,'String')); |
---|
[2] | 4027 | par.iby=num2str(iby_val); |
---|
| 4028 | isx=get(handles.isx,'String'); |
---|
[127] | 4029 | if isnan(str2double(isx)), isx='41'; set(handles.isx,'String','41'), end; %default |
---|
| 4030 | if str2double(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.isx,'String',num2str(ibx_val+8)); end |
---|
[2] | 4031 | isy=get(handles.isy,'String'); |
---|
[127] | 4032 | if isnan(str2double(isy)), isy='41'; set(handles.isy,'String','41'), end;%default |
---|
| 4033 | if str2double(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.isy,'String',num2str(iby_val+8)); end |
---|
[2] | 4034 | par.isx=get(handles.isx,'String'); |
---|
| 4035 | par.isy=get(handles.isy,'String'); |
---|
| 4036 | par.shiftx=get(handles.shiftx,'String'); |
---|
| 4037 | par.shifty=get(handles.shifty,'String'); |
---|
[127] | 4038 | if isnan(str2double(par.isx)) |
---|
[112] | 4039 | par.isx='41';%default |
---|
| 4040 | set(handles.isx,'String','41'); |
---|
[2] | 4041 | end |
---|
[127] | 4042 | if isnan(str2double(par.isy)) |
---|
[112] | 4043 | par.isy='41'; %default |
---|
| 4044 | set(handles.isy,'String','41'); |
---|
[12] | 4045 | end |
---|
[127] | 4046 | if isnan(str2double(par.shiftx)) |
---|
[112] | 4047 | par.shiftx='0';%default |
---|
| 4048 | set(handles.shiftx,'String','0'); |
---|
| 4049 | end |
---|
[127] | 4050 | if isnan(str2double(par.shifty)) |
---|
[112] | 4051 | par.shifty='0'; %default |
---|
| 4052 | set(handles.shifty,'String','0'); |
---|
[12] | 4053 | end |
---|
[112] | 4054 | par.rho=get(handles.rho,'String'); |
---|
[238] | 4055 | if isequal(get(handles.rho,'Style'),'popupmenu') |
---|
| 4056 | index=get(handles.rho,'Value'); |
---|
| 4057 | par.rho=par.rho{index}; |
---|
| 4058 | end |
---|
[112] | 4059 | par.dx=get(handles.dx_civ1,'String'); |
---|
| 4060 | par.dy=get(handles.dy_civ1,'String'); |
---|
[127] | 4061 | if isnan(str2double(par.dx)) |
---|
[112] | 4062 | if isempty(get(handles.grid_civ1,'String')); |
---|
| 4063 | par.dx='0'; %just read by civ program, not used |
---|
| 4064 | else |
---|
[12] | 4065 | par.dx='20';%default |
---|
| 4066 | set(handles.dx_civ1,'String','20'); |
---|
[112] | 4067 | end |
---|
| 4068 | end |
---|
[127] | 4069 | if isnan(str2double(par.dy)) |
---|
[112] | 4070 | if isempty(get(handles.grid_civ1,'String')); |
---|
| 4071 | par.dy='0';%just read by civ program, not used |
---|
| 4072 | else |
---|
[12] | 4073 | par.dy='20';%default |
---|
| 4074 | set(handles.dy_civ1_title,'String','20'); |
---|
[112] | 4075 | end |
---|
| 4076 | end |
---|
| 4077 | par.pxcmx='1'; %velocities are expressed in pixel dispalcement |
---|
| 4078 | par.pxcmy='1'; |
---|
[150] | 4079 | if exist('file_ima','var') |
---|
[112] | 4080 | A=imread(file_ima);%read the first image to get the size |
---|
| 4081 | sizim=size(A); |
---|
| 4082 | par.npx=num2str(sizim(2)); |
---|
| 4083 | par.npy=num2str(sizim(1)); |
---|
[150] | 4084 | end |
---|
[127] | 4085 | %time=get(handles.RootName,'UserData'); %get the set of times |
---|
[112] | 4086 | par.gridname=get(handles.grid_civ1,'String'); |
---|
| 4087 | par.gridflag='y'; |
---|
[127] | 4088 | if strcmp(par.gridname,'')|| isempty(par.gridname) |
---|
[112] | 4089 | par.gridname='nogrid'; |
---|
| 4090 | par.gridflag='n'; |
---|
| 4091 | end |
---|
[12] | 4092 | |
---|
| 4093 | %------------------------------------------------------------------------ |
---|
[2] | 4094 | function par=read_param_civ2(handles,file_ima) |
---|
[12] | 4095 | %------------------------------------------------------------------------ |
---|
| 4096 | par.ibx=get(handles.ibx_civ2,'String'); |
---|
| 4097 | par.iby=get(handles.iby_civ2,'String'); |
---|
| 4098 | par.rho=get(handles.rho_civ2,'String'); |
---|
| 4099 | par.decimal=int2str(get(handles.decimal,'Value')); |
---|
| 4100 | par.deformation=int2str(get(handles.deformation,'Value')); |
---|
| 4101 | par.dx=get(handles.dx_civ2,'String'); |
---|
| 4102 | par.dy=get(handles.dy_civ2,'String'); |
---|
[127] | 4103 | if isnan(str2double(par.dx)) |
---|
[112] | 4104 | if isempty(get(handles.grid_civ2,'String')); |
---|
| 4105 | par.dx='0'; %just read by civ program, not used |
---|
| 4106 | else |
---|
[12] | 4107 | par.dx='20';%default |
---|
| 4108 | set(handles.dx_civ2,'String','20'); |
---|
[112] | 4109 | end |
---|
| 4110 | end |
---|
[127] | 4111 | if isnan(str2double(par.dy)) |
---|
[112] | 4112 | if isempty(get(handles.grid_civ2,'String')); |
---|
| 4113 | par.dy='0';%just read by civ program, not used |
---|
| 4114 | else |
---|
[12] | 4115 | par.dy='20';%default |
---|
| 4116 | set(handles.dy_civ2,'String','20'); |
---|
[112] | 4117 | end |
---|
| 4118 | end |
---|
| 4119 | par.pxcmx='1'; |
---|
| 4120 | par.pxcmy='1'; |
---|
[12] | 4121 | A=imread(file_ima);%read the first image to get the size |
---|
| 4122 | sizim=size(A); |
---|
| 4123 | par.npx=num2str(sizim(2)); |
---|
| 4124 | par.npy=num2str(sizim(1)); |
---|
[127] | 4125 | %time=get(handles.RootName,'UserData'); %get the set of times |
---|
[12] | 4126 | par.gridname=get(handles.grid_civ2,'String'); |
---|
| 4127 | par.gridflag='y'; |
---|
[127] | 4128 | if strcmp(par.gridname,'')|| isempty(par.gridname) |
---|
[12] | 4129 | par.gridname='nogrid'; |
---|
| 4130 | par.gridflag='n'; |
---|
| 4131 | end |
---|
[2] | 4132 | |
---|
[12] | 4133 | %------------------------------------------------------------------------ |
---|
| 4134 | % --- CIV1 CIV1 CIV1 CIV1 |
---|
[94] | 4135 | function cmd_CIV1=CIV1_CMD(filename,namelog,par,handles,sparam) |
---|
[12] | 4136 | %------------------------------------------------------------------------ |
---|
[2] | 4137 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 4138 | |
---|
| 4139 | %changes : filename_cmx -> filename ( no extension ) |
---|
[174] | 4140 | % input namelog not used |
---|
[112] | 4141 | if isequal(par.Dt,'0') |
---|
| 4142 | par.Dt='1' ;%case of 'displacement' mode |
---|
| 4143 | end |
---|
[90] | 4144 | par.filename_ima_a=regexprep(par.filename_ima_a,'.png',''); |
---|
[94] | 4145 | par.filename_ima_b=regexprep(par.filename_ima_b,'.png',''); |
---|
[230] | 4146 | fid=fopen([filename '.civ1.cmx'],'w'); |
---|
[12] | 4147 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
[112] | 4148 | fprintf(fid, ['FirstImage ' regexprep(par.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4149 | fprintf(fid, ['LastImage ' regexprep(par.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4150 | fprintf(fid, ['XX' '\n' ]); |
---|
| 4151 | fprintf(fid, ['Mask ' par.maskflag '\n' ]); |
---|
| 4152 | fprintf(fid, ['MaskName ' regexprep(par.maskname,'\\','\\\\') '\n' ]); |
---|
| 4153 | fprintf(fid, ['ImageSize ' par.npx ' ' par.npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 4154 | fprintf(fid, ['CorrelationBoxesSize ' par.ibx ' ' par.iby '\n' ]); |
---|
| 4155 | fprintf(fid, ['SearchBoxeSize ' par.isx ' ' par.isy '\n' ]); |
---|
| 4156 | fprintf(fid, ['RO ' par.rho '\n' ]); |
---|
| 4157 | fprintf(fid, ['GridSpacing ' par.dx ' ' par.dy '\n' ]); |
---|
| 4158 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4159 | fprintf(fid, ['Dt_TO ' par.Dt ' ' par.T0 '\n' ]); |
---|
| 4160 | fprintf(fid, ['PixCmXY ' par.pxcmx ' ' par.pxcmy '\n' ]); |
---|
| 4161 | fprintf(fid, ['XX 1' '\n' ]); |
---|
| 4162 | fprintf(fid, ['ShiftXY ' par.shiftx ' ' par.shifty '\n' ]); |
---|
| 4163 | fprintf(fid, ['Grid ' par.gridflag '\n' ]); |
---|
| 4164 | fprintf(fid, ['GridName ' regexprep(par.gridname,'\\','\\\\') '\n' ]); |
---|
| 4165 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 4166 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4167 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4168 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
| 4169 | fprintf(fid, [ 'DecimalShift 0' '\n' ]); |
---|
| 4170 | fprintf(fid, ['Deformation 0' '\n' ]); |
---|
| 4171 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 4172 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 4173 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 4174 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
| 4175 | fprintf(fid, ['ImageToUse ' par.term_a ' ' par.term_b '\n' ]); % VERIFIER ? |
---|
| 4176 | fprintf(fid, ['ImageUsedBefore null null' '\n' ]); |
---|
[12] | 4177 | fclose(fid); |
---|
[112] | 4178 | |
---|
[163] | 4179 | % cmd_CIV1=[sparam.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file |
---|
| 4180 | % cmd_CIV1=regexprep(cmd_CIV1,'\\','\\\\'); |
---|
| 4181 | % namelog=regexprep(namelog,'\\','\\\\'); |
---|
[12] | 4182 | if(isunix) |
---|
[230] | 4183 | cmd_CIV1=['cp -f ' filename '.civ1.cmx ' filename '.cmx\n']; |
---|
| 4184 | 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] | 4185 | 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] | 4186 | % cmd_CIV1=[cmd_CIV1 '\n' 'mv ' filename '.cmx' ' ' filename '.civ1.cmx' '\n'];%rename .cmx as .civ1.cmx |
---|
[163] | 4187 | else %Windows system |
---|
[230] | 4188 | flname=regexprep(flname,'\\','\\\\'); |
---|
| 4189 | % cmd=[cmd 'copy /Y "' flname '.civ1.cmx" "' flname '.cmx"\n']; |
---|
[174] | 4190 | filename=regexprep(filename,'\\','\\\\'); |
---|
[230] | 4191 | cmd_CIV1=['copy /Y "' filename '.civ1.cmx" "' filename '.cmx"\n'];% copy the .civ1.cmx parameter file to .cmx |
---|
[163] | 4192 | cmd_CIV1=['"' sparam.Civ1Bin '" -f "' filename '.cmx" >"' filename '.log"' ]; % redirect standard output to the log file |
---|
| 4193 | cmd_CIV1=regexprep(cmd_CIV1,'\\','\\\\'); |
---|
| 4194 | namelog=regexprep(namelog,'\\','\\\\'); |
---|
[230] | 4195 | cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y "' filename '.log' '" "' filename '.civ1.log"']; %preserve the log file as .civ1.log |
---|
| 4196 | % cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y "' filename '.cmx' '" "' filename '.civ1.cmx"']; |
---|
[12] | 4197 | end |
---|
[2] | 4198 | |
---|
[12] | 4199 | %------------------------------------------------------------------------ |
---|
| 4200 | % --- CIV1 Unified |
---|
[94] | 4201 | function xml_civ1_parameters=CIV1_CMD_Unified(filename,namelog,par) |
---|
[12] | 4202 | %------------------------------------------------------------------------ |
---|
[2] | 4203 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
[73] | 4204 | %global CivBin%name of the executable for civ1 calculation |
---|
[2] | 4205 | |
---|
[112] | 4206 | civ1.image1=par.filename_ima_a; |
---|
| 4207 | civ1.image2=par.filename_ima_b; |
---|
| 4208 | civ1.imageSize_X=par.npx; |
---|
| 4209 | civ1.imageSize_Y=par.npy; |
---|
| 4210 | civ1.outputFileName=[filename '.nc']; |
---|
| 4211 | civ1.correlationBoxesSize_X=par.ibx; |
---|
| 4212 | civ1.correlationBoxesSize_Y=par.iby; |
---|
| 4213 | civ1.searchBoxesSize_X=par.isx; |
---|
| 4214 | civ1.searchBoxesSize_Y=par.isy; |
---|
| 4215 | civ1.globalShift_X=par.shiftx; |
---|
| 4216 | civ1.globalShift_Y=par.shifty; |
---|
| 4217 | civ1.ro=par.rho; |
---|
| 4218 | civ1.hart='y'; |
---|
| 4219 | if isequal(par.gridflag,'y') |
---|
| 4220 | civ1.grid=par.gridname; |
---|
| 4221 | else |
---|
| 4222 | civ1.grid='n'; |
---|
| 4223 | civ1.gridSpacing_X=par.dx; |
---|
| 4224 | civ1.gridSpacing_Y=par.dy; |
---|
| 4225 | end |
---|
| 4226 | if isequal(par.maskflag,'y') |
---|
| 4227 | civ1.mask=par.maskname; |
---|
| 4228 | end |
---|
[229] | 4229 | civ1.dt=par.Dt; |
---|
[112] | 4230 | civ1.unit='pixel'; |
---|
| 4231 | civ1.absolut_time_T0=par.T0; |
---|
| 4232 | civ1.pixcmx=par.pxcmx; |
---|
| 4233 | civ1.pixcmy=par.pxcmy; |
---|
| 4234 | civ1.convectFlow='n'; |
---|
[12] | 4235 | |
---|
[112] | 4236 | xml_civ1_parameters=civ1; |
---|
| 4237 | |
---|
[12] | 4238 | %------------------------------------------------------------------------ |
---|
| 4239 | % --- CIV2 Unified |
---|
[94] | 4240 | function civ2=CIV2_CMD_Unified(filename,namelog,par) |
---|
[12] | 4241 | %------------------------------------------------------------------------ |
---|
[2] | 4242 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
[73] | 4243 | %global CivBin%name of the executable for civ1 calculation |
---|
[2] | 4244 | |
---|
| 4245 | civ2.image1=par.filename_ima_a; |
---|
| 4246 | civ2.image2=par.filename_ima_b; |
---|
|
---|