[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 | |
---|
[220] | 24 | % Last Modified by GUIDE v2.5 11-Mar-2011 08:21:21 |
---|
[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=[]; |
---|
[238] | 68 | set(handles.CivAll,'String',{'CivX';'CivAll';'CivUvmat'}) |
---|
[252] | 69 | set(handles.subdomain_patch1,'String','1500')% default values |
---|
| 70 | set(handles.subdomain_patch2,'String','1500') |
---|
| 71 | delete(handles.grid_patch1) |
---|
| 72 | delete(handles.get_gridpatch1) |
---|
| 73 | delete(handles.grid_patch2) |
---|
| 74 | delete(handles.get_gridpatch2) |
---|
| 75 | |
---|
[71] | 76 | %default input parameters: |
---|
[153] | 77 | num_i1=1; % set of field i numbers |
---|
| 78 | num_i2=1; % set of field i numbers |
---|
| 79 | num_j1=1; % set of field j numbers (fields a) |
---|
| 80 | num_j2=1; % second set of field j numbers (fields b) |
---|
[71] | 81 | subdir='A'; % subdir for the netcdf result files |
---|
[112] | 82 | ind_opening=1; % proposed operation number (1=civ1,2=fix1,3=patch1,4=civ2,5=fix2,6=patch2) |
---|
| 83 | %load the initial parameters if the interface is started from uvmat |
---|
[71] | 84 | if exist('param','var')&&isstruct(param)% the interface is opened from uvmat |
---|
| 85 | filebase=param.RootName; |
---|
| 86 | nom_type_read=param.NomType; |
---|
[153] | 87 | num_i1=param.num1; |
---|
| 88 | if isnan(num_i1),num_i1=1;end |
---|
| 89 | num_i2=param.num2; |
---|
| 90 | if isnan(num_i2),num_i2=num_i1;end |
---|
| 91 | num_j1=param.num_a; |
---|
| 92 | if isnan(num_j1),num_j1=1;end |
---|
| 93 | num_j2=param.num_b; |
---|
| 94 | if isnan(num_j2),num_j2=num_j1;end |
---|
[71] | 95 | subdir=param.SubDir; |
---|
| 96 | ind_opening=param.IndOpening; |
---|
| 97 | ext=param.ImaExt; |
---|
[2] | 98 | end |
---|
[153] | 99 | browse.num_i1=num_i1; |
---|
| 100 | browse.num_i2=num_i2; |
---|
| 101 | browse.num_j1=num_j1; |
---|
| 102 | browse.num_j2=num_j2; |
---|
[122] | 103 | if ~isempty(ext) && (~isempty(imformats(ext(2:end)))||strcmpi(ext,'.avi'));%if an image file has been opened by uvmat |
---|
[112] | 104 | set(handles.ImaExt,'String',ext) |
---|
[128] | 105 | browse.ext_ima=ext; |
---|
[112] | 106 | if exist('nom_type_read','var') |
---|
| 107 | browse.nom_type_ima=nom_type_read; % the image nomenclature is stored |
---|
| 108 | end |
---|
[2] | 109 | elseif isequal(ext,'.nc') |
---|
| 110 | if exist('nom_type_read','var') |
---|
| 111 | browse.nom_type_nc=nom_type_read;% the netcdf nomenclature is stored |
---|
| 112 | end |
---|
| 113 | end |
---|
[71] | 114 | set(handles.RootName,'String',filebase); |
---|
[2] | 115 | set(handles.ImaDoc,'String',ext) |
---|
| 116 | |
---|
[122] | 117 | %read names of the .exe file to adjust the interface according to available binaries |
---|
[2] | 118 | path_uvmat=which('uvmat');% check the path detected for source file uvmat |
---|
| 119 | path_UVMAT=fileparts(path_uvmat); %path to UVMAT |
---|
[45] | 120 | errormsg=[];%default error message |
---|
[112] | 121 | xmlfile='PARAM.xml'; |
---|
[54] | 122 | if exist(xmlfile,'file') |
---|
| 123 | try |
---|
[112] | 124 | t=xmltree(xmlfile); |
---|
| 125 | sparam=convert(t); |
---|
[54] | 126 | catch |
---|
[112] | 127 | errormsg={' Unable to read the file PARAM.xml defining the civx binaries:'; lasterr}; |
---|
[227] | 128 | return |
---|
[2] | 129 | end |
---|
[54] | 130 | else |
---|
| 131 | errormsg=[xmlfile ' not found: path to civx binaries undefined']; |
---|
[227] | 132 | return |
---|
[2] | 133 | end |
---|
[71] | 134 | |
---|
[110] | 135 | |
---|
[45] | 136 | if ~isempty(errormsg) |
---|
[112] | 137 | msgbox_uvmat('ERROR',errormsg); |
---|
[45] | 138 | end |
---|
[71] | 139 | % patch_newBin=''; |
---|
| 140 | test_batch=0;%default: ,no batch mode available |
---|
| 141 | if isfield(sparam,'BatchParam') && isfield(sparam.BatchParam,'BatchMode') |
---|
| 142 | test_batch=strcmp(sparam.BatchParam.BatchMode,'sge'); %sge is currently the only implemented batch mod |
---|
[2] | 143 | end |
---|
| 144 | if test_batch==0 |
---|
[84] | 145 | set(handles.BATCH,'Enable','off')% put the BATCH button in grey (unactivated) |
---|
[2] | 146 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784])% put the BATCH button in grey (unactivated) |
---|
| 147 | end |
---|
[94] | 148 | if isfield(sparam.RunParam,'CivBin') |
---|
| 149 | if ~exist(sparam.RunParam.CivBin,'file') |
---|
[112] | 150 | sparam.RunParam.CivBin=fullfile(path_UVMAT,sparam.RunParam.CivBin); |
---|
[94] | 151 | end |
---|
[97] | 152 | else |
---|
| 153 | sparam.RunParam.CivBin=''; |
---|
[94] | 154 | end |
---|
[96] | 155 | patch_newBin=exist(sparam.RunParam.CivBin,'file'); |
---|
[2] | 156 | set(handles.subdir_civ1,'String',subdir)%default subdir on which uvmat was working |
---|
| 157 | set(handles.subdir_civ2,'String',subdir)%default subdir on which uvmat was working |
---|
| 158 | |
---|
| 159 | %initiate advised operations |
---|
| 160 | if isequal(ind_opening,[]) |
---|
| 161 | ind_opening=1; % default |
---|
| 162 | end |
---|
| 163 | % set default operation options |
---|
[112] | 164 | enable_civ1(handles,'off') |
---|
| 165 | enable_civ2(handles,'off') |
---|
| 166 | enable_pair1(handles,'on') |
---|
| 167 | enable_fix1(handles,'off') |
---|
| 168 | desable_patch1(handles) |
---|
| 169 | desable_fix2(handles) |
---|
| 170 | desable_patch2(handles) |
---|
| 171 | set(handles.CIV1,'Value',0) |
---|
| 172 | set(handles.FIX1,'Value',0) |
---|
| 173 | set(handles.PATCH1,'Value',0) |
---|
| 174 | set(handles.CIV2,'Value',0) |
---|
| 175 | set(handles.FIX2,'Value',0) |
---|
| 176 | set(handles.PATCH2,'Value',0) |
---|
| 177 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[2] | 178 | if isequal(ind_opening,1) |
---|
| 179 | set(handles.CIV1,'Value',1) |
---|
| 180 | enable_civ1(handles,'on') |
---|
| 181 | elseif isequal(ind_opening,2) |
---|
| 182 | set(handles.FIX1,'Value',1) |
---|
| 183 | enable_fix1(handles,'on') |
---|
| 184 | elseif isequal(ind_opening,3) |
---|
| 185 | set(handles.PATCH1,'Value',1) |
---|
| 186 | enable_patch1(handles) |
---|
| 187 | elseif isequal(ind_opening,4) |
---|
| 188 | set(handles.CIV2,'Value',1) |
---|
[224] | 189 | enable_civ2(handles,'on') |
---|
[2] | 190 | elseif isequal(ind_opening,5) |
---|
| 191 | set(handles.FIX2,'Value',1) |
---|
| 192 | enable_fix2(handles) |
---|
[112] | 193 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 194 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 195 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 196 | enable_pair1(handles,'off') |
---|
[2] | 197 | elseif isequal(ind_opening,6) |
---|
| 198 | set(handles.PATCH2,'Value',1) |
---|
| 199 | enable_patch2(handles) |
---|
| 200 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 201 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 202 | enable_pair1(handles,'off') |
---|
| 203 | end |
---|
| 204 | |
---|
| 205 | % set the range of fields (1:1 by default) and selected pair |
---|
[153] | 206 | if isequal(num_i2,num_i1) |
---|
| 207 | num_ref_i=num_i1; |
---|
[2] | 208 | else |
---|
[153] | 209 | num_ref_i=floor((num_i1+num_i2)/2); |
---|
| 210 | browse.incr_pair(1)=num_i2-num_i1; |
---|
[2] | 211 | browse.incr_pair(2)=0; |
---|
| 212 | end |
---|
[153] | 213 | if isequal(num_j1,num_j2) |
---|
| 214 | if isnan(num_j1) |
---|
[2] | 215 | num_ref_j=1; |
---|
| 216 | else |
---|
[153] | 217 | num_ref_j=num_j1; |
---|
[2] | 218 | end |
---|
| 219 | else |
---|
[153] | 220 | num_ref_j=floor((num_j1+num_j2)/2); |
---|
| 221 | browse.incr_pair(2)=num_j2-num_j1; |
---|
[2] | 222 | end |
---|
| 223 | set(handles.first_i,'String',num2str(num_ref_i)); |
---|
| 224 | set(handles.last_i,'String',num2str(num_ref_i)); |
---|
| 225 | set(handles.first_j,'String',num2str(num_ref_j)); |
---|
| 226 | set(handles.last_j,'String',num2str(num_ref_j)); |
---|
| 227 | set(handles.ref_i,'String',num2str(num_ref_i)); |
---|
| 228 | set(handles.ref_j,'String',num2str(num_ref_j)); |
---|
[71] | 229 | set(handles.ref_i_civ2,'String',num2str(num_ref_i)); |
---|
| 230 | set(handles.ref_j_civ2,'String',num2str(num_ref_j)); |
---|
[2] | 231 | set(handles.browse_root,'UserData',browse); |
---|
[220] | 232 | if exist('param','var') && isfield(param,'RootName') && ~isempty(param.RootName)%varargin the interface is opened from uvmat |
---|
[112] | 233 | RootName_Callback(hObject, eventdata, handles); |
---|
[2] | 234 | end |
---|
| 235 | |
---|
[150] | 236 | % set(handles.waitbar_1,'Position',[0.946 0.877 0.03 0.001]) |
---|
| 237 | % set(handles.waitbar_patch1,'Position',[0.946 0.626 0.03 0.001]) |
---|
| 238 | % set(handles.waitbar_civ2,'Position',[0.946 0.406 0.03 0.001]) |
---|
| 239 | % set(handles.waitbar_patch2,'Position',[0.946 0.187 0.03 0.001]) |
---|
[2] | 240 | |
---|
[12] | 241 | %------------------------------------------------------------------------ |
---|
[2] | 242 | % --- Outputs from this function are returned to the command line. |
---|
| 243 | function varargout = civ_OutputFcn(hObject, eventdata, handles) |
---|
[12] | 244 | %------------------------------------------------------------------------ |
---|
[2] | 245 | % varargout cell array for returning output args (see VARARGOUT); |
---|
| 246 | % hObject handle to figure |
---|
| 247 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 248 | % handles structure with handles and user data (see GUIDATA) |
---|
| 249 | % Get default command line output from handles structure |
---|
| 250 | varargout{1} = handles.output; |
---|
| 251 | |
---|
[12] | 252 | %------------------------------------------------------------------------ |
---|
[2] | 253 | % --- Executes on button press in browse_root. |
---|
| 254 | function browse_root_Callback(hObject, eventdata, handles) |
---|
[12] | 255 | %------------------------------------------------------------------------ |
---|
[2] | 256 | %get the input file properties |
---|
[71] | 257 | filebase=get(handles.RootName,'String'); |
---|
[2] | 258 | oldfile=''; %default |
---|
[39] | 259 | if isempty(filebase)|| isequal(filebase,'')%loads the previously stored file name and set it as default in the file_input box |
---|
[112] | 260 | dir_perso=prefdir; |
---|
| 261 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 262 | if exist(profil_perso,'file') |
---|
| 263 | h=load (profil_perso); |
---|
| 264 | if isfield(h,'filebase')&& ischar(h.filebase) |
---|
| 265 | oldfile=h.filebase; |
---|
| 266 | end |
---|
| 267 | if isfield(h,'RootPath') && ischar(h.RootPath) |
---|
| 268 | oldfile=h.RootPath; |
---|
| 269 | end |
---|
| 270 | end |
---|
| 271 | else |
---|
| 272 | oldfile=filebase; |
---|
| 273 | end |
---|
[2] | 274 | ind_opening=1;%default |
---|
| 275 | browse.incr_pair=[0 0]; %default |
---|
[238] | 276 | menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)'; |
---|
[174] | 277 | '*.xml', '.xml files '; ... |
---|
| 278 | '*.civ', '.civ files '; ... |
---|
| 279 | '*.png','.png image files'; ... |
---|
| 280 | '*.jpg',' jpeg image files'; ... |
---|
| 281 | '*.tif','.tif image files'; ... |
---|
| 282 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 283 | '*.nc','.netcdf files'; ... |
---|
| 284 | '*.*', 'All Files (*.*)'}; |
---|
[2] | 285 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile); |
---|
[112] | 286 | fileinput=[PathName FileName];%complete file name |
---|
[2] | 287 | sizf=size(fileinput); |
---|
| 288 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
| 289 | [path,name,ext]=fileparts(fileinput); |
---|
| 290 | testeditxml=0; |
---|
| 291 | if isequal(ext,'.xml') |
---|
| 292 | testeditxml=1; |
---|
| 293 | t_browse=xmltree(fileinput); |
---|
| 294 | head_element=get(t_browse,1); |
---|
[45] | 295 | if isfield(head_element,'name')&& isequal(head_element.name,'ImaDoc') |
---|
[2] | 296 | testeditxml=0; |
---|
| 297 | end |
---|
| 298 | end |
---|
[45] | 299 | if testeditxml==1 || isequal(ext,'.xls') |
---|
[112] | 300 | heditxml=editxml({fileinput}); |
---|
| 301 | set(heditxml,'Tag','browser') |
---|
| 302 | waitfor(heditxml,'Tag','idle') |
---|
| 303 | if ~ishandle(heditxml) |
---|
| 304 | return |
---|
| 305 | end |
---|
| 306 | attr=findobj(get(heditxml,'children'),'Tag','CurrentAttributes'); |
---|
| 307 | set(handles.browse,'UserData',fileinput)% store for future opening with browser |
---|
| 308 | fileinput=get(attr,'UserData'); |
---|
| 309 | if ~exist(fileinput,'file') |
---|
| 310 | return |
---|
| 311 | end |
---|
[2] | 312 | end |
---|
[82] | 313 | [RootPath,RootFile,str1,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput); |
---|
[2] | 314 | filebase=fullfile(RootPath,RootFile); |
---|
[89] | 315 | num_i1=str2double(str1); |
---|
| 316 | if isnan(num_i1),num_i1=1;end |
---|
| 317 | num_i2=str2double(str2); |
---|
| 318 | if isnan(num_i2),num_i2=num_i1;end |
---|
[54] | 319 | num_j1=stra2num(str_a); |
---|
[89] | 320 | if isnan(num_j1),num_j1=1;end |
---|
[54] | 321 | num_j2=stra2num(str_b); |
---|
[112] | 322 | if isnan(num_j2),num_j2=num_j1;end |
---|
[2] | 323 | if isequal(get(handles.compare,'Value'),1) |
---|
| 324 | browse=[];%initialisation |
---|
| 325 | else |
---|
| 326 | browse=get(handles.browse_root,'UserData'); |
---|
| 327 | end |
---|
[122] | 328 | browse.num_i1=num_i1; |
---|
| 329 | browse.num_i2=num_i2; |
---|
| 330 | browse.num_j1=num_j1; |
---|
| 331 | browse.num_j2=num_j2; |
---|
| 332 | if length(ext)>1 && (~isempty(imformats(ext(2:end)))||strcmpi(ext,'.avi'));%if an image file has been opened by uvmat |
---|
[2] | 333 | browse.nom_type_ima=nom_type; |
---|
[122] | 334 | browse.ext_ima=ext; |
---|
[177] | 335 | set(handles.ImaExt,'String',ext) |
---|
[2] | 336 | end |
---|
| 337 | set(handles.ImaDoc,'String',ext); |
---|
| 338 | |
---|
| 339 | %%%%% read the state of the selected netcdf file to advise default operation |
---|
| 340 | if isequal(ext,'.nc') |
---|
| 341 | browse.nom_type_nc=nom_type; |
---|
[112] | 342 | ind_opening=2;% propose 'fix' as the default option |
---|
[246] | 343 | Data=nc2struct(fileinput,'ListGlobalAttribute','CivStage','absolut_time_T0','fix','patch','civ2','fix2'); |
---|
| 344 | if ~isempty(Data.CivStage)%test for civ files |
---|
| 345 | ind_opening=Data.CivStage; |
---|
| 346 | set(handles.CivAll,'Value',3) |
---|
| 347 | end |
---|
| 348 | if ~isempty(Data.absolut_time_T0)%test for civx files |
---|
| 349 | set(handles.CivAll,'Value',1) |
---|
[2] | 350 | if isfield(Data,'fix') && isequal(Data.fix,1) |
---|
| 351 | ind_opening=3; |
---|
| 352 | end |
---|
[246] | 353 | if isequal(Data.patch,1) |
---|
[2] | 354 | ind_opening=4; |
---|
| 355 | end |
---|
[246] | 356 | if isequal(Data.civ2,1) |
---|
[2] | 357 | ind_opening=5; |
---|
| 358 | end |
---|
[246] | 359 | if isequal(Data.fix2,1) |
---|
[2] | 360 | ind_opening=6; |
---|
| 361 | end |
---|
| 362 | testciv=1; %TO SUPPRESS WITH NEW VERSION OF CIVX |
---|
| 363 | else |
---|
[112] | 364 | ind_opening=3; %GUI used only for patch |
---|
[2] | 365 | testciv=0; |
---|
| 366 | end |
---|
| 367 | set(handles.subdir_civ1,'String',subdir);%set the default subdir directories for installing the .nc results |
---|
| 368 | set(handles.subdir_civ2,'String',subdir); |
---|
| 369 | browse.testciv=testciv; |
---|
| 370 | browse.ind_opening=ind_opening; |
---|
| 371 | end |
---|
[71] | 372 | set(handles.RootName,'String',filebase); |
---|
[2] | 373 | set(handles.ImaDoc,'String',ext); |
---|
[45] | 374 | if ~isempty(num_i1) |
---|
[82] | 375 | ref_i=num_i1; |
---|
[45] | 376 | if ~isempty(num_i2) |
---|
| 377 | ref_i=floor((ref_i+num_i2)/2);% reference image number corresponding to the file |
---|
| 378 | browse.incr_pair(1)=num_i2-num_i1; |
---|
[2] | 379 | browse.incr_pair(2)=0; |
---|
| 380 | end |
---|
| 381 | set(handles.first_i,'String',num2str(ref_i)); |
---|
| 382 | set(handles.last_i,'String',num2str(ref_i)); |
---|
[71] | 383 | set(handles.ref_i,'String',num2str(ref_i)); |
---|
| 384 | set(handles.ref_i_civ2,'String',num2str(ref_i)) |
---|
[2] | 385 | end |
---|
[45] | 386 | if isempty(num_j1) |
---|
[2] | 387 | set(handles.ref_j,'String','1'); |
---|
[71] | 388 | set(handles.ref_j_civ2,'String','1'); |
---|
[2] | 389 | else |
---|
[45] | 390 | ref_j=num_j1; |
---|
| 391 | if ~isempty(num_j2) |
---|
| 392 | ref_j=floor((num_j1+num_j2)/2); |
---|
[112] | 393 | browse.incr_pair(2)=num_j2-num_j1; |
---|
[2] | 394 | end |
---|
| 395 | set(handles.first_j,'String',num2str(ref_j)); |
---|
| 396 | set(handles.last_j,'String',num2str(ref_j)); |
---|
[112] | 397 | set(handles.ref_j,'String',num2str(ref_j)); |
---|
[71] | 398 | set(handles.ref_j_civ2,'String',num2str(ref_j)); |
---|
[2] | 399 | end |
---|
| 400 | |
---|
| 401 | % set default operation options |
---|
| 402 | enable_civ1(handles,'off') |
---|
| 403 | enable_civ2(handles,'off') |
---|
| 404 | enable_pair1(handles,'on') |
---|
| 405 | enable_fix1(handles,'off') |
---|
| 406 | desable_patch1(handles) |
---|
| 407 | desable_fix2(handles) |
---|
| 408 | desable_patch2(handles) |
---|
| 409 | set(handles.CIV1,'Value',0) |
---|
| 410 | set(handles.FIX1,'Value',0) |
---|
| 411 | set(handles.PATCH1,'Value',0) |
---|
| 412 | set(handles.CIV2,'Value',0) |
---|
| 413 | set(handles.FIX2,'Value',0) |
---|
| 414 | set(handles.PATCH2,'Value',0) |
---|
| 415 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 416 | if isequal(ind_opening,1) |
---|
| 417 | set(handles.CIV1,'Value',1) |
---|
| 418 | enable_civ1(handles,'on') |
---|
| 419 | elseif isequal(ind_opening,2) |
---|
| 420 | set(handles.FIX1,'Value',1) |
---|
| 421 | enable_fix1(handles,'on') |
---|
| 422 | elseif isequal(ind_opening,3) |
---|
| 423 | set(handles.PATCH1,'Value',1) |
---|
| 424 | enable_patch1(handles) |
---|
| 425 | elseif isequal(ind_opening,4) |
---|
| 426 | set(handles.CIV2,'Value',1) |
---|
[224] | 427 | enable_civ2(handles,'on') |
---|
[2] | 428 | elseif isequal(ind_opening,5) |
---|
| 429 | enable_pair1(handles,'off') |
---|
| 430 | set(handles.FIX2,'Value',1) |
---|
| 431 | enable_fix2(handles) |
---|
[112] | 432 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 433 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 434 | set(handles.list_pair_civ2,'Enable','On') |
---|
[2] | 435 | elseif isequal(ind_opening,6) |
---|
| 436 | enable_pair1(handles,'off') |
---|
| 437 | set(handles.PATCH2,'Value',1) |
---|
| 438 | enable_patch2(handles) |
---|
| 439 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 440 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 441 | end |
---|
| 442 | set(handles.browse_root,'UserData',browse);% store information from browser |
---|
| 443 | |
---|
[71] | 444 | RootName_Callback(hObject, eventdata, handles); |
---|
[2] | 445 | |
---|
[12] | 446 | %------------------------------------------------------------------------ |
---|
[2] | 447 | function ImaDoc_Callback(hObject, eventdata, handles) |
---|
[12] | 448 | %------------------------------------------------------------------------ |
---|
[71] | 449 | RootName_Callback(hObject, eventdata, handles) |
---|
[2] | 450 | |
---|
[12] | 451 | %------------------------------------------------------------------------ |
---|
[54] | 452 | % --- function activated when a new filebase (image series) is introduced |
---|
[71] | 453 | function RootName_Callback(hObject, eventdata, handles) |
---|
[12] | 454 | %------------------------------------------------------------------------ |
---|
[2] | 455 | set(handles.compare,'Visible','on') |
---|
[122] | 456 | ext_ima='';%default |
---|
[2] | 457 | nom_type_ima=[];%default |
---|
| 458 | field_count=1;%default |
---|
| 459 | nom_type_nc=[]; |
---|
| 460 | time=[]; |
---|
[71] | 461 | TimeUnit='frame'; %default |
---|
| 462 | CoordUnit='px';%default |
---|
[2] | 463 | pxcmx_search=[];%default |
---|
| 464 | pxcmy_search=[];%default |
---|
[71] | 465 | filebase=get(handles.RootName,'String'); |
---|
[128] | 466 | ext_imadoc=get(handles.ImaDoc,'String'); |
---|
[135] | 467 | browse=get(handles.browse_root,'UserData');%default |
---|
[122] | 468 | if isfield(browse,'nom_type_ima') |
---|
| 469 | nom_type_ima=browse.nom_type_ima;% get an image nomenclature type already determined by an input image name |
---|
[133] | 470 | end |
---|
| 471 | if isfield(browse,'ext_ima') |
---|
[122] | 472 | ext_ima=browse.ext_ima; |
---|
[2] | 473 | end |
---|
[122] | 474 | if isfield(browse,'nom_type_nc') |
---|
| 475 | nom_type_nc=browse.nom_type_nc;% get an image nomenclature type already determined by an input image name |
---|
| 476 | end |
---|
| 477 | if isfield(browse,'num_i1') |
---|
| 478 | field_count=browse.num_i1;% get an image index type already determined by an input file |
---|
| 479 | end |
---|
[252] | 480 | set(handles.civ,'UserData',[]); %refresh list of previous civ files (for STATUS) |
---|
[2] | 481 | |
---|
| 482 | %default first_i and j and increments |
---|
[137] | 483 | first_i=str2double(get(handles.first_i,'String'));%value possibly set by uvmat_Opening |
---|
| 484 | if isnan(first_i)|| first_i < 1 |
---|
[2] | 485 | first_i=1; %default first_i |
---|
| 486 | end |
---|
[137] | 487 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 488 | if isnan(last_i)|| last_i < first_i |
---|
[2] | 489 | last_i=first_i; %default last_i |
---|
| 490 | end |
---|
[137] | 491 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 492 | if isnan(first_j)|| first_j < 1 |
---|
[2] | 493 | first_j=1; %default first_j |
---|
| 494 | end |
---|
[137] | 495 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 496 | if isnan(last_j)|| last_j < first_j |
---|
[2] | 497 | last_j=first_j; %default last_j |
---|
| 498 | end |
---|
[137] | 499 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 500 | if isnan(incr_i) || incr_i < 1; |
---|
[2] | 501 | set(handles.incr_i,'String','1') %default incr_i |
---|
| 502 | end |
---|
[137] | 503 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
| 504 | if isnan(incr_j) || incr_j < 1; |
---|
[2] | 505 | set(handles.incr_j,'String','1') %default incr_j |
---|
| 506 | end |
---|
| 507 | dt=[];%default |
---|
| 508 | testmode=0;%default |
---|
| 509 | nbfield=[]; %default |
---|
| 510 | nburst=[];%default |
---|
| 511 | pxcmx=1; |
---|
[112] | 512 | pxcmy=1; |
---|
[2] | 513 | |
---|
[112] | 514 | %look for an image documentation file |
---|
[128] | 515 | if ~strcmp(ext_imadoc,'.xml') && ~strcmp(ext_imadoc,'.civ')&& ~strcmpi(ext_imadoc,'.avi') |
---|
[2] | 516 | if exist([filebase '.xml'],'file') |
---|
[128] | 517 | ext_imadoc='.xml'; |
---|
[2] | 518 | elseif exist([filebase '.civxml'],'file') |
---|
[128] | 519 | ext_imadoc='.civxml'; |
---|
[2] | 520 | elseif exist([filebase '.civ'],'file') |
---|
[128] | 521 | ext_imadoc='.civ'; |
---|
[112] | 522 | elseif exist([filebase '.avi'],'file') |
---|
[128] | 523 | ext_imadoc='.avi'; |
---|
[2] | 524 | elseif exist([filebase '.AVI'],'file') |
---|
[128] | 525 | ext_imadoc='.AVI'; |
---|
[2] | 526 | end |
---|
[128] | 527 | set(handles.ImaDoc,'String',ext_imadoc) |
---|
[2] | 528 | end |
---|
| 529 | |
---|
| 530 | %%%%%%%% read image documentation file %%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[84] | 531 | mode=''; %default |
---|
| 532 | set(handles.ImaDoc,'BackgroundColor',[1 1 0]) |
---|
| 533 | drawnow |
---|
[128] | 534 | if isequal(ext_imadoc,'.civxml') || isequal(ext_imadoc,'.xml')|| isequal(ext_imadoc,'.civ') |
---|
[2] | 535 | set(handles.ref_i,'Visible','On')%use a reference index |
---|
| 536 | set(handles.ref_j,'Visible','On') |
---|
[128] | 537 | elseif isequal(ext_imadoc,'.avi') || isequal(ext_imadoc,'.AVI') |
---|
[2] | 538 | set(handles.ref_j,'Visible','Off') |
---|
| 539 | else |
---|
| 540 | set(handles.ref_i,'Visible','Off') |
---|
| 541 | set(handles.ref_j,'Visible','Off') |
---|
| 542 | end |
---|
[12] | 543 | testima_xml=0; |
---|
[128] | 544 | if isequal(ext_imadoc,'.civxml')%TO ABANDON |
---|
[122] | 545 | [nbfield,nbfield2,time]=read_civxml([filebase '.civxml']); |
---|
[2] | 546 | mode='pair j1-j2'; |
---|
| 547 | if isempty(nom_type_ima)% dtermine types by default if not already selected by browser or uvmat |
---|
[112] | 548 | nom_type_ima='_i_j'; |
---|
[2] | 549 | end |
---|
[128] | 550 | elseif isequal(ext_imadoc,'.xml') |
---|
[73] | 551 | [XmlData,warntext]=imadoc2struct([filebase '.xml']); |
---|
[2] | 552 | ext_ima_read=[]; |
---|
| 553 | nom_type_read=[]; |
---|
[12] | 554 | if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')&&ischar(XmlData.Heading.ImageName)% get image nom type and extension from the xml file |
---|
[2] | 555 | [PP,FF,fc,str2,str_a,str_b,ext_ima_read,nom_type_read]=name2display(XmlData.Heading.ImageName); |
---|
[112] | 556 | fullname=fullfile(fileparts(filebase),XmlData.Heading.ImageName); %full name (including path) of the first image defined by the xmle file, |
---|
[45] | 557 | if ~exist(fullname,'file') |
---|
[12] | 558 | msgbox_uvmat('WARNING',['FirstImage ' fullname ' defined in the xml file does not exist']) |
---|
| 559 | end |
---|
[2] | 560 | end |
---|
[84] | 561 | if isfield(XmlData,'Time') |
---|
[85] | 562 | time=XmlData.Time; |
---|
[84] | 563 | nbfield=size(time,1); |
---|
[122] | 564 | nbfield2=size(time,2); |
---|
[127] | 565 | %transform .Time to a column vector if it is a line vector thenomenclature uses a single index: correct possible bug in xml |
---|
[122] | 566 | if isequal(nbfield,1) && ~isequal(nbfield2,1)% .Time is a line vector |
---|
[127] | 567 | if numel(nom_type_read)>=2 && isempty(regexp(nom_type_read(2:end),'\D')) |
---|
[84] | 568 | time=time'; |
---|
[122] | 569 | nbfield=nbfield2; |
---|
| 570 | nbfield2=1; |
---|
[84] | 571 | end |
---|
| 572 | end |
---|
| 573 | end |
---|
[71] | 574 | if isfield(XmlData,'TimeUnit') |
---|
| 575 | TimeUnit=XmlData.TimeUnit; |
---|
[2] | 576 | end |
---|
[71] | 577 | if isfield(XmlData,'Npx') |
---|
| 578 | npx=XmlData.Npx; |
---|
| 579 | npy=XmlData.Npy; |
---|
| 580 | end |
---|
[2] | 581 | pxcmx_search=1; |
---|
| 582 | pxcmy_search=1; |
---|
| 583 | if isfield(XmlData,'GeometryCalib') |
---|
| 584 | tsai=XmlData.GeometryCalib; |
---|
[112] | 585 | if isfield(tsai,'f') && isfield(tsai,'Tz') && isfield(tsai,'dpx') && isfield(tsai,'dpy')&& isfield(tsai,'R') |
---|
| 586 | rot2D=tsai.R(1:2,[1,2]); |
---|
| 587 | pxcmx_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpx); |
---|
| 588 | pxcmy_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpy); |
---|
[2] | 589 | end |
---|
[112] | 590 | if isfield(tsai,'CoordUnit') |
---|
| 591 | CoordUnit=tsai.CoordUnit; |
---|
[2] | 592 | end |
---|
[112] | 593 | end |
---|
[128] | 594 | elseif strcmp(ext_imadoc,'.civ')% case of .civ image documentation file |
---|
[112] | 595 | [error,time,TimeUnit,mode,npx,npy]=read_imatext([filebase '.civ']); |
---|
| 596 | if error==2, msgbox_uvmat('WARNING',['no file ' filebase '.civ']); |
---|
| 597 | elseif error==1, msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file'); |
---|
| 598 | end |
---|
[128] | 599 | nom_type_ima='001a'; |
---|
| 600 | elseif strcmpi(ext_imadoc,'.avi') |
---|
[112] | 601 | nom_type_ima='*'; |
---|
[128] | 602 | ext_ima=ext_imadoc; |
---|
[177] | 603 | set(handles.mode,'Value',1); |
---|
[112] | 604 | set(handles.mode,'String',{'series(Di)'}) |
---|
| 605 | dt=0.04;%default |
---|
[128] | 606 | if exist([filebase ext_imadoc],'file')==2 |
---|
| 607 | info=aviinfo([filebase ext_imadoc]);%read infos on the avi movie |
---|
[112] | 608 | dt=1/info.FramesPerSecond;%time interval between successive frames |
---|
| 609 | nbfield=info.NumFrames;%number of frames |
---|
| 610 | end |
---|
| 611 | time=(dt*(0:nbfield-1))';%list of image times |
---|
[2] | 612 | end |
---|
| 613 | if isempty(time) |
---|
| 614 | set(handles.ImaDoc,'String',''); %xml file not used for timing |
---|
| 615 | end |
---|
| 616 | set(handles.ImaDoc,'BackgroundColor',[1 1 1]) |
---|
| 617 | |
---|
[122] | 618 | %get the imabe nomenclature type if not defined by the input file nor by the xml file |
---|
| 619 | dirima=[];%default |
---|
[12] | 620 | if isempty(nom_type_ima) |
---|
| 621 | %look for double image series '_i_j' |
---|
| 622 | dirima=dir([filebase '_' num2str(first_i) '_' num2str(first_j) '.*']); |
---|
| 623 | if isempty(dirima) |
---|
[112] | 624 | % look for images series with sub marker '_' |
---|
| 625 | dirima=dir([filebase '_*' num2str(first_i) '.*']); |
---|
| 626 | if isempty(dirima) |
---|
| 627 | % look for other images series |
---|
| 628 | dirima=dir([filebase '*' num2str(first_i) '.*']); |
---|
[122] | 629 | if isempty(dirima) |
---|
| 630 | % look for other images series witth letter appendix |
---|
| 631 | appendix=char(96+first_j); |
---|
| 632 | dirima=dir([filebase '*' num2str(first_i) appendix '.*']); |
---|
[112] | 633 | end |
---|
| 634 | end |
---|
[12] | 635 | end |
---|
[112] | 636 | end |
---|
[122] | 637 | for ilist=1:numel(dirima) |
---|
| 638 | [pp,ff,fc,str2,str_a,str_b,ext_list,nom_type_list]=name2display(dirima(ilist).name); |
---|
| 639 | form=imformats(ext_list(2:end)); |
---|
| 640 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 641 | ext_ima=ext_list; |
---|
| 642 | nom_type_ima=nom_type_list; |
---|
| 643 | break |
---|
| 644 | end |
---|
| 645 | end |
---|
| 646 | % no image documentation file found: look for a series of existing files,images by priority or .nc files |
---|
| 647 | if isempty(nom_type_ima) |
---|
[128] | 648 | ext_search=ext_imadoc; |
---|
[122] | 649 | nom_type_search=nom_type_nc; |
---|
| 650 | else |
---|
| 651 | ext_search=ext_ima; |
---|
| 652 | nom_type_search=nom_type_ima; |
---|
| 653 | end |
---|
| 654 | if isempty(time) && ~strcmp(nom_type_search,'none') && ~strcmp(nom_type_search,'') && ~strcmp(nom_type_search,'*') |
---|
[12] | 655 | subdir=get(handles.subdir_civ1,'String'); |
---|
| 656 | incr_pair=[0 0];%default |
---|
| 657 | if isfield(browse,'incr_pair') |
---|
[112] | 658 | incr_pair=browse.incr_pair; |
---|
[12] | 659 | end |
---|
[112] | 660 | % nbdetect=0;%test of detected images |
---|
[122] | 661 | field_i=browse.num_i2; |
---|
[153] | 662 | imagename=name_generator(filebase,field_i,1,ext_search,nom_type_search); |
---|
| 663 | imagename_plus=''; |
---|
[12] | 664 | idetect=1; |
---|
[153] | 665 | while idetect %look for the maximum file number in the series |
---|
| 666 | imagename_plus=name_generator(filebase,field_i+1,1,ext_search,nom_type_search); |
---|
| 667 | idetect=(exist(imagename_plus,'file')==2)&& ~strcmp(imagename,imagename_plus); |
---|
[81] | 668 | if idetect |
---|
[12] | 669 | field_i=field_i+1; |
---|
[81] | 670 | end |
---|
[112] | 671 | %SEE CASE OF NETCDF FILES |
---|
| 672 | % nbdetect=nbdetect+(exist(imagename,'file')==2); |
---|
[12] | 673 | end |
---|
[122] | 674 | nbfield=field_i;% last detected field number |
---|
| 675 | field_i=browse.num_i1;%look for the minimum file number in the series |
---|
[153] | 676 | imagename_min=''; |
---|
[12] | 677 | idetect=1; |
---|
[112] | 678 | while idetect==1 |
---|
[153] | 679 | imagename_min=name_generator(filebase,field_i-1,1,ext_search,nom_type_search); |
---|
| 680 | idetect=(exist(imagename_min,'file')==2)&& ~strcmp(imagename,imagename_min); |
---|
[81] | 681 | if idetect |
---|
[112] | 682 | field_i=field_i-1; |
---|
[81] | 683 | end |
---|
[12] | 684 | end |
---|
[122] | 685 | first_i=max(field_i,1); |
---|
| 686 | if numel(regexp(nom_type_search,'\D'))>=1%two indices i and j |
---|
| 687 | field_i=browse.num_i1; |
---|
| 688 | field_j=browse.num_j2; |
---|
[177] | 689 | imagename=name_generator(filebase,field_i,field_j,ext_search,nom_type_search); |
---|
[153] | 690 | imagename_plus=''; |
---|
[89] | 691 | jdetect=1; |
---|
| 692 | while jdetect==1 %look for the maximum file number in the series |
---|
[153] | 693 | imagename_plus=name_generator(filebase,field_i,field_j+1,ext_search,nom_type_search); |
---|
| 694 | jdetect=(exist(imagename_plus,'file')==2)&& ~strcmp(imagename,imagename_plus); |
---|
[89] | 695 | if jdetect |
---|
| 696 | field_j=field_j+1; |
---|
| 697 | end |
---|
| 698 | %SEE CASE OF NETCDF FILES |
---|
| 699 | % nbdetect=nbdetect+(exist(imagename,'file')==2); |
---|
| 700 | end |
---|
[122] | 701 | nbfield2=field_j;% last detected field number |
---|
[120] | 702 | end |
---|
[122] | 703 | |
---|
[89] | 704 | %determine the set of times and possible intervals for CIV |
---|
[137] | 705 | % dt=(1/1000)*str2double(get(handles.dt,'String')); |
---|
[122] | 706 | time=(0:nbfield-1)';% time=file index -1 by default |
---|
| 707 | if numel(regexp(nom_type_search,'\D'))>=1%two indices i and j |
---|
| 708 | [x,y]=meshgrid(0:nbfield2-1,0:nbfield-1); |
---|
[120] | 709 | time=x+y; |
---|
[89] | 710 | end |
---|
[2] | 711 | end |
---|
[120] | 712 | |
---|
[2] | 713 | if exist('time','var') |
---|
| 714 | if size(time,1)+size(time,2)>=3 % if there are at least two time values to define dt |
---|
| 715 | nbfield=size(time,1); |
---|
| 716 | nbfield2=size(time,2); |
---|
[71] | 717 | set(handles.RootName,'UserData',time); %store the set of times |
---|
| 718 | set(handles.dt_unit,'String',['dt in m' TimeUnit]); |
---|
| 719 | set(handles.dt_unit_civ2,'String',['dt in m' TimeUnit]); |
---|
| 720 | set(handles.TimeUnit,'String',TimeUnit); |
---|
[2] | 721 | set(handles.nb_field,'String',num2str(nbfield)); |
---|
| 722 | set(handles.nb_field2,'String',num2str(nbfield2)); |
---|
| 723 | end |
---|
| 724 | end |
---|
[71] | 725 | set(handles.CoordUnit,'String',CoordUnit) |
---|
[2] | 726 | set(handles.calcul_search,'UserData',[pxcmx_search pxcmy_search]); |
---|
| 727 | % npxy=[npy npx]; |
---|
[71] | 728 | set(handles.ImaExt,'String',ext_ima) |
---|
[2] | 729 | set(handles.first_i,'String',num2str(first_i)); |
---|
| 730 | set(handles.last_i,'String',num2str(last_i));% |
---|
| 731 | set(handles.first_j,'String',num2str(first_j)); |
---|
| 732 | set(handles.last_j,'String',num2str(last_j));% |
---|
| 733 | browse.nom_type_ima=nom_type_ima; |
---|
| 734 | set(handles.browse_root,'UserData',browse)% store the nomenclature type |
---|
| 735 | |
---|
[112] | 736 | %%%%%%%%%%% set the menus of image pairs and default selection for civ %%%%%%%%%%%%%%%%%%% |
---|
[177] | 737 | test_ima_i=numel(nom_type_ima)>1 && isempty(regexp(nom_type_ima(2:end),'\D','once'));%images with single indexing |
---|
[122] | 738 | if test_ima_i || isequal(nom_type_nc,'_i1-i2')||~(exist('nbfield2','var')&&(nbfield2~=1)) |
---|
[2] | 739 | set(handles.mode,'Value',1) |
---|
[177] | 740 | set(handles.mode,'String',{'series(Di)'}) |
---|
[2] | 741 | elseif (nbfield==1)% simple series in j |
---|
[177] | 742 | set(handles.mode,'Value',1) |
---|
[2] | 743 | set(handles.mode,'String',{'series(Dj)'}) |
---|
| 744 | else |
---|
| 745 | set(handles.mode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice |
---|
[122] | 746 | if nbfield2 <= 10 |
---|
[112] | 747 | set(handles.mode,'Value',1)% advice 'pair j1-j2' for small burst |
---|
[2] | 748 | end |
---|
| 749 | end |
---|
| 750 | |
---|
[112] | 751 | %update the subdir |
---|
[2] | 752 | pathdir=fileparts(filebase);%path to the current xml file |
---|
| 753 | listot=dir(pathdir); |
---|
| 754 | idir=0; |
---|
| 755 | listdir={''};%default |
---|
| 756 | for ilist=1:length(listot) |
---|
| 757 | if listot(ilist).isdir |
---|
| 758 | name=listot(ilist).name; |
---|
| 759 | if ~isequal(name,'.') && ~isequal(name,'..') |
---|
| 760 | idir=idir+1; |
---|
| 761 | listdir{idir,1}=listot(ilist).name; |
---|
| 762 | end |
---|
| 763 | end |
---|
| 764 | end |
---|
[112] | 765 | set(handles.list_subdir_civ1,'Value',1) |
---|
[2] | 766 | set(handles.list_subdir_civ2,'Value',1) |
---|
[107] | 767 | set(handles.list_subdir_civ1,'String',[{'browse...'};listdir]) |
---|
| 768 | set(handles.list_subdir_civ2,'String',[{'browse...'};listdir]) |
---|
[2] | 769 | %check wether the current subdir exists: |
---|
| 770 | subdir_civ1=get(handles.subdir_civ1,'String'); |
---|
| 771 | subdir_civ2=get(handles.subdir_civ2,'String'); |
---|
| 772 | |
---|
[112] | 773 | mode_Callback(hObject, eventdata, handles) |
---|
[2] | 774 | |
---|
[177] | 775 | %% desable status and RUN button |
---|
[150] | 776 | % set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001]) |
---|
| 777 | % set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001]) |
---|
| 778 | % set(handles.waitbar_civ2,'Position',[0.946 0.219 0.03 0.001]) |
---|
| 779 | % set(handles.waitbar_patch2,'Position',[0.946 0.0 0.03 0.001]) |
---|
[2] | 780 | set(handles.RUN, 'Enable','On') |
---|
| 781 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
[122] | 782 | set(handles.BATCH,'Enable','On') |
---|
| 783 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
[178] | 784 | if isfield(handles,'status') |
---|
[177] | 785 | set(handles.status,'Value',0);%suppress status display |
---|
| 786 | status_Callback(hObject, eventdata, handles) |
---|
[178] | 787 | end |
---|
[112] | 788 | |
---|
[177] | 789 | %% store the root input filename for future opening |
---|
[2] | 790 | dir_perso=prefdir; |
---|
| 791 | profil_perso=fullfile(prefdir,'uvmat_perso.mat'); |
---|
| 792 | RootPath=fileparts(filebase); |
---|
| 793 | if exist(profil_perso,'file') |
---|
| 794 | save (profil_perso,'RootPath','-append'); %store the root name for future opening of uvmat |
---|
| 795 | else |
---|
[147] | 796 | txt=ver('MATLAB'); |
---|
| 797 | Release=txt.Release; |
---|
[137] | 798 | relnumb=str2double(Release(3:4)); |
---|
[2] | 799 | if relnumb >= 14 |
---|
[112] | 800 | save (profil_perso,'RootPath','-V6'); %store the root name for future opening of uvmat |
---|
[2] | 801 | else |
---|
| 802 | save (profil_perso,'RootPath'); %store the root name for future opening of uvmat |
---|
| 803 | end |
---|
| 804 | end |
---|
| 805 | |
---|
[12] | 806 | %------------------------------------------------------------------------ |
---|
[2] | 807 | % --- Executes on button press in mode. |
---|
| 808 | function mode_Callback(hObject, eventdata, handles) |
---|
[12] | 809 | %------------------------------------------------------------------------ |
---|
[2] | 810 | browse=get(handles.browse_root,'UserData'); |
---|
| 811 | compare_list=get(handles.compare,'String'); |
---|
| 812 | val=get(handles.compare,'Value'); |
---|
| 813 | compare=compare_list{val}; |
---|
| 814 | if strcmp(compare,'displacement') |
---|
| 815 | mode='displacement'; |
---|
| 816 | else |
---|
| 817 | mode_list=get(handles.mode,'String'); |
---|
[236] | 818 | if ischar(mode_list) |
---|
| 819 | mode_list={mode_list}; |
---|
| 820 | end |
---|
[2] | 821 | mode_value=get(handles.mode,'Value'); |
---|
| 822 | mode=mode_list{mode_value}; |
---|
| 823 | end |
---|
| 824 | displ_num=[];%default |
---|
[137] | 825 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[2] | 826 | % last_i=str2num(get(handles.last_i,'String')); |
---|
[71] | 827 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
[2] | 828 | siztime=size(time); |
---|
| 829 | nbfield=siztime(1); |
---|
| 830 | nbfield2=siztime(2); |
---|
| 831 | indchosen=1; %%first pair selected by default |
---|
| 832 | if isequal(mode,'pair j1-j2')%| isequal(mode,'st_pair j1-j2') |
---|
| 833 | dt=1; |
---|
| 834 | displ=''; |
---|
| 835 | index=0; |
---|
| 836 | numlist_a=[]; |
---|
| 837 | numlist_B=[]; |
---|
| 838 | %get all the time intervals in bursts |
---|
| 839 | displ_dt=1;%default |
---|
| 840 | nbfield2=min(nbfield2,10);%limitate the number of pairs to 10x10 |
---|
| 841 | for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'pair j1-j2' mode |
---|
| 842 | for numod_b=(numod_a+1):nbfield2 |
---|
[112] | 843 | index=index+1; |
---|
| 844 | numlist_a(index)=numod_a; |
---|
| 845 | numlist_b(index)=numod_b; |
---|
| 846 | if ~isempty(time) |
---|
[54] | 847 | dt(numod_a,numod_b)=time(ref_i,numod_b)-time(ref_i,numod_a);%first time interval dt |
---|
[2] | 848 | displ_dt(index)=dt(numod_a,numod_b); |
---|
[112] | 849 | else |
---|
| 850 | displ_dt(index)=1; |
---|
| 851 | end |
---|
| 852 | end |
---|
| 853 | end |
---|
| 854 | [dtsort,indsort]=sort(displ_dt); |
---|
| 855 | if ~isempty(numlist_a) |
---|
| 856 | displ_num(1,:)=numlist_a(indsort); |
---|
| 857 | displ_num(2,:)=numlist_b(indsort); |
---|
| 858 | end |
---|
| 859 | displ_num(3,:)=0; |
---|
| 860 | displ_num(4,:)=0; |
---|
| 861 | set(handles.jtext,'Visible','Off') |
---|
[2] | 862 | set(handles.first_j,'Visible','Off') |
---|
| 863 | set(handles.last_j,'Visible','Off') |
---|
| 864 | set(handles.incr_j,'Visible','Off') |
---|
| 865 | set(handles.nb_field2,'Visible','Off') |
---|
| 866 | set(handles.ref_j,'Visible','Off') |
---|
| 867 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') |
---|
[112] | 868 | for index=1:min(nbfield2-1,200) |
---|
| 869 | displ_num(1,index)=-floor(index/2); |
---|
| 870 | displ_num(2,index)=ceil(index/2); |
---|
| 871 | displ_num(3,index)=0; |
---|
| 872 | displ_num(4,index)=0; |
---|
| 873 | end |
---|
| 874 | set(handles.jtext,'Visible','On') |
---|
| 875 | set(handles.first_j,'Visible','On') |
---|
| 876 | set(handles.last_j,'Visible','On') |
---|
| 877 | set(handles.incr_j,'Visible','On') |
---|
| 878 | set(handles.nb_field2,'Visible','On') |
---|
| 879 | set(handles.ref_j,'Visible','On') |
---|
| 880 | if nbfield > 1 |
---|
[2] | 881 | set(handles.itext,'Visible','On') |
---|
| 882 | set(handles.first_i,'Visible','On') |
---|
| 883 | set(handles.last_i,'Visible','On') |
---|
| 884 | set(handles.incr_i,'Visible','On') |
---|
| 885 | set(handles.nb_field,'Visible','On') |
---|
| 886 | set(handles.ref_i,'Visible','On') |
---|
| 887 | else |
---|
| 888 | set(handles.itext,'Visible','Off') |
---|
| 889 | set(handles.first_i,'Visible','Off') |
---|
| 890 | set(handles.last_i,'Visible','Off') |
---|
| 891 | set(handles.incr_i,'Visible','Off') |
---|
| 892 | set(handles.nb_field,'Visible','Off') |
---|
| 893 | set(handles.ref_i,'Visible','Off') |
---|
| 894 | end |
---|
[112] | 895 | elseif isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 896 | for index=1:200%min(nbfield-1,200) |
---|
| 897 | displ_num(1,index)=0; |
---|
| 898 | displ_num(2,index)=0; |
---|
| 899 | displ_num(3,index)=-floor(index/2); |
---|
| 900 | displ_num(4,index)=ceil(index/2); |
---|
| 901 | end |
---|
| 902 | set(handles.itext,'Visible','On') |
---|
| 903 | set(handles.first_i,'Visible','On') |
---|
| 904 | set(handles.last_i,'Visible','On') |
---|
| 905 | set(handles.incr_i,'Visible','On') |
---|
| 906 | set(handles.nb_field,'Visible','On') |
---|
| 907 | set(handles.ref_i,'Visible','On') |
---|
| 908 | if nbfield2 > 1 |
---|
[2] | 909 | set(handles.jtext,'Visible','On') |
---|
| 910 | set(handles.first_j,'Visible','On') |
---|
| 911 | set(handles.last_j,'Visible','On') |
---|
| 912 | set(handles.incr_j,'Visible','On') |
---|
| 913 | set(handles.nb_field2,'Visible','On') |
---|
| 914 | set(handles.ref_j,'Visible','On') |
---|
[112] | 915 | else |
---|
[2] | 916 | set(handles.jtext,'Visible','Off') |
---|
| 917 | set(handles.first_j,'Visible','Off') |
---|
| 918 | set(handles.last_j,'Visible','Off') |
---|
| 919 | set(handles.incr_j,'Visible','Off') |
---|
| 920 | set(handles.nb_field2,'Visible','Off') |
---|
| 921 | set(handles.ref_j,'Visible','Off') |
---|
| 922 | end |
---|
| 923 | elseif isequal(mode,'displacement')%the pairs have the same indices |
---|
[112] | 924 | displ_num(1,1)=0; |
---|
| 925 | displ_num(2,1)=0; |
---|
| 926 | displ_num(3,1)=0; |
---|
| 927 | displ_num(4,1)=0; |
---|
| 928 | if nbfield > 1 |
---|
[2] | 929 | set(handles.itext,'Visible','On') |
---|
| 930 | set(handles.first_i,'Visible','On') |
---|
| 931 | set(handles.last_i,'Visible','On') |
---|
| 932 | set(handles.incr_i,'Visible','On') |
---|
| 933 | set(handles.nb_field,'Visible','On') |
---|
| 934 | set(handles.ref_i,'Visible','On') |
---|
| 935 | else |
---|
| 936 | set(handles.itext,'Visible','Off') |
---|
| 937 | set(handles.first_i,'Visible','Off') |
---|
| 938 | set(handles.last_i,'Visible','Off') |
---|
| 939 | set(handles.incr_i,'Visible','Off') |
---|
| 940 | set(handles.nb_field,'Visible','Off') |
---|
| 941 | set(handles.ref_i,'Visible','Off') |
---|
| 942 | end |
---|
| 943 | if nbfield2 > 1 |
---|
[112] | 944 | set(handles.jtext,'Visible','On') |
---|
| 945 | set(handles.first_j,'Visible','On') |
---|
| 946 | set(handles.last_j,'Visible','On') |
---|
| 947 | set(handles.incr_j,'Visible','On') |
---|
| 948 | set(handles.nb_field2,'Visible','On') |
---|
| 949 | set(handles.ref_j,'Visible','On') |
---|
[2] | 950 | else |
---|
| 951 | set(handles.jtext,'Visible','Off') |
---|
| 952 | set(handles.first_j,'Visible','Off') |
---|
| 953 | set(handles.last_j,'Visible','Off') |
---|
| 954 | set(handles.incr_j,'Visible','Off') |
---|
| 955 | set(handles.nb_field2,'Visible','Off') |
---|
| 956 | set(handles.ref_j,'Visible','Off') |
---|
| 957 | end |
---|
[112] | 958 | end |
---|
[2] | 959 | set(handles.list_pair_civ1,'UserData',displ_num); |
---|
| 960 | find_netcpair_civ1(hObject, eventdata, handles) |
---|
| 961 | find_netcpair_civ2(hObject, eventdata, handles) |
---|
| 962 | |
---|
[12] | 963 | %------------------------------------------------------------------------ |
---|
[2] | 964 | % determine the menu for civ1 pairs depending on existing netcdf file at the middle of |
---|
| 965 | % the field series set by first_i, incr, last_i |
---|
| 966 | function find_netcpair_civ1(hObject, eventdata, handles) |
---|
[12] | 967 | %------------------------------------------------------------------------ |
---|
[2] | 968 | set(gcf,'Pointer','watch') |
---|
| 969 | %nomenclature types |
---|
[71] | 970 | filebase=get(handles.RootName,'String'); |
---|
[2] | 971 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
| 972 | browse=get(handles.browse_root,'UserData'); |
---|
| 973 | compare_list=get(handles.compare,'String'); |
---|
| 974 | val=get(handles.compare,'Value'); |
---|
| 975 | compare=compare_list{val}; |
---|
| 976 | if strcmp(compare,'displacement') |
---|
| 977 | mode='displacement'; |
---|
| 978 | else |
---|
| 979 | mode_list=get(handles.mode,'String'); |
---|
| 980 | mode_value=get(handles.mode,'Value'); |
---|
| 981 | mode=mode_list{mode_value}; |
---|
| 982 | end |
---|
| 983 | |
---|
| 984 | % nomenclature type of the .nc files |
---|
| 985 | nom_type_ima=[];%default |
---|
| 986 | if isfield(browse,'nom_type_ima') |
---|
| 987 | nom_type_ima=browse.nom_type_ima; |
---|
| 988 | end |
---|
| 989 | |
---|
[112] | 990 | %determine nom_type_nc: |
---|
[2] | 991 | nom_type_nc=[];%default |
---|
| 992 | if isfield(browse,'nom_type_nc') |
---|
| 993 | nom_type_nc=browse.nom_type_nc; |
---|
| 994 | end |
---|
| 995 | if isempty(nom_type_nc) |
---|
[112] | 996 | [nom_type_nc]=nomtype2pair(nom_type_ima,isequal(mode,'series(Di)'),isequal(mode,'series(Dj)')); |
---|
[2] | 997 | end |
---|
| 998 | browse.nom_type_nc=nom_type_nc; |
---|
| 999 | set(handles.browse_root,'UserData',browse) |
---|
| 1000 | |
---|
| 1001 | %reads .nc subdirectoy and image numbers from the interface |
---|
| 1002 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
[45] | 1003 | % first_i=str2num(get(handles.first_i,'String')); |
---|
| 1004 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 1005 | % incr=str2num(get(handles.incr_i,'String')); |
---|
| 1006 | % num1=first_i:incr:last_i; |
---|
| 1007 | % if isempty(num1) |
---|
| 1008 | % set(handles.list_pair_civ1,'String',{''}); |
---|
| 1009 | % return |
---|
| 1010 | % end |
---|
| 1011 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[2] | 1012 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
| 1013 | ref_j=0; |
---|
| 1014 | else |
---|
[45] | 1015 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
[2] | 1016 | end |
---|
[71] | 1017 | time=get(handles.RootName,'UserData');%get the set of times |
---|
[2] | 1018 | if isempty(time) |
---|
| 1019 | time=[0 1]; |
---|
[112] | 1020 | end |
---|
[71] | 1021 | %dt_unit=str2double(get(handles.dt,'String'));% used when there is no image documentation file |
---|
| 1022 | dt_unit=1000;%default |
---|
[2] | 1023 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 1024 | |
---|
[112] | 1025 | %eliminate the first pairs inconsistent with the position |
---|
| 1026 | if isempty(displ_num) |
---|
| 1027 | nbpair=0; |
---|
| 1028 | else |
---|
[2] | 1029 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
| 1030 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 1031 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1032 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 1033 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1034 | end |
---|
[112] | 1035 | end |
---|
[2] | 1036 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
| 1037 | |
---|
[112] | 1038 | %look for existing processed pairs involving the field at the middle of the series if civ1 will not |
---|
[2] | 1039 | % be performed, while the result is needed for next steps. |
---|
| 1040 | displ_pair={''}; |
---|
| 1041 | select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs |
---|
| 1042 | testpair=0; |
---|
| 1043 | if get(handles.CIV1,'Value')==0 % |
---|
[112] | 1044 | if ~exist(fullfile(filepath,subdir_civ1,ext_dir),'dir') |
---|
| 1045 | msgbox_uvmat('ERROR',['no civ1 file available: subdirectory ' subdir_civ1 ' does not exist']); |
---|
| 1046 | set(handles.list_pair_civ1,'String',{}); |
---|
| 1047 | return |
---|
[2] | 1048 | end |
---|
[112] | 1049 | for ipair=1:nbpair |
---|
[2] | 1050 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
[112] | 1051 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
[2] | 1052 | select(ipair)=exist(filename,'file')==2; |
---|
| 1053 | end |
---|
| 1054 | if ~exist('select','var') || isequal(select,zeros(size(1:nbpair))) |
---|
[112] | 1055 | if isfield(browse,'incr_pair') |
---|
[2] | 1056 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
| 1057 | num_i2=ref_i+ceil(browse.incr_pair(1)/2); |
---|
| 1058 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
| 1059 | num_j2=ref_j+ceil(browse.incr_pair(2)/2); |
---|
| 1060 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ1); |
---|
| 1061 | select(1)=exist(filename,'file')==2; |
---|
| 1062 | testpair=1; |
---|
| 1063 | else |
---|
[112] | 1064 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
[2] | 1065 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1]); |
---|
| 1066 | else |
---|
| 1067 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ1]); |
---|
| 1068 | end |
---|
[112] | 1069 | set(handles.list_pair_civ1,'String',{''}); |
---|
| 1070 | %COMPLETER CAS STEREO |
---|
[2] | 1071 | return |
---|
| 1072 | end |
---|
| 1073 | end |
---|
| 1074 | end |
---|
| 1075 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 1076 | if testpair |
---|
[73] | 1077 | displ_pair{1}=['Di= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
| 1078 | % elseif ~isequal(get(handles.root_txt,'String'),'dt(ms)=') |
---|
| 1079 | % for ipair=1:nbpair |
---|
| 1080 | % if select(ipair) |
---|
| 1081 | % if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1082 | % 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 |
---|
| 1083 | % displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1084 | % end |
---|
| 1085 | % else |
---|
| 1086 | % displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1087 | % end |
---|
| 1088 | % end |
---|
[2] | 1089 | else |
---|
[73] | 1090 | for ipair=1:nbpair |
---|
| 1091 | if select(ipair) |
---|
| 1092 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1093 | 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 |
---|
| 1094 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1095 | else |
---|
| 1096 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1097 | end |
---|
| 1098 | end |
---|
| 1099 | end |
---|
[2] | 1100 | end |
---|
| 1101 | elseif isequal(mode,'series(Dj)')%|isequal(mode,'st_series(Dj)')% series on the j index |
---|
| 1102 | if testpair |
---|
[112] | 1103 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
[2] | 1104 | else |
---|
[112] | 1105 | for ipair=1:nbpair |
---|
| 1106 | if select(ipair) |
---|
| 1107 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1108 | 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 |
---|
| 1109 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1110 | end |
---|
| 1111 | elseif testpair |
---|
| 1112 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(2)/2)) '|' num2str(ceil(browse.incr_pair(2)/2))]; |
---|
| 1113 | else |
---|
| 1114 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1115 | end |
---|
| 1116 | end |
---|
| 1117 | end |
---|
[2] | 1118 | elseif isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2')%case of pairs |
---|
| 1119 | for ipair=1:nbpair |
---|
| 1120 | if select(ipair) |
---|
[112] | 1121 | 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 |
---|
| 1122 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
| 1123 | ' :dt= ' num2str(dt*1000)]; |
---|
| 1124 | else |
---|
| 1125 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1126 | end |
---|
| 1127 | end |
---|
[2] | 1128 | elseif isequal(mode,'displacement') |
---|
[112] | 1129 | displ_pair={'Di=Dj=0'}; |
---|
| 1130 | end |
---|
[2] | 1131 | set(handles.list_pair_civ1,'String',displ_pair'); |
---|
[229] | 1132 | ichoice=find(select,1); |
---|
[45] | 1133 | if (isempty(ichoice) || ichoice < 1); ichoice=1; end; |
---|
| 1134 | initial=get(handles.list_pair_civ1,'Value');%initial choice of pair |
---|
[112] | 1135 | if initial>nbpair |
---|
| 1136 | set(handles.list_pair_civ1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
[45] | 1137 | end |
---|
| 1138 | if numel(select)>=initial && ~isequal(select(initial),1) |
---|
[2] | 1139 | set(handles.list_pair_civ1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
| 1140 | end |
---|
[45] | 1141 | |
---|
[2] | 1142 | %set(handles.list_pair_civ2,'String',displ_pair'); |
---|
| 1143 | initial=get(handles.list_pair_civ2,'Value'); |
---|
| 1144 | if initial>length(displ_pair')%|~isequal(select(initial),1) |
---|
| 1145 | if ichoice <= length(displ_pair') |
---|
| 1146 | set(handles.list_pair_civ2,'Value',ichoice);% same pair proposed by default for civ2 |
---|
| 1147 | else |
---|
| 1148 | set(handles.list_pair_civ2,'Value',1);% same pair proposed by default for civ2 |
---|
| 1149 | end |
---|
| 1150 | end |
---|
| 1151 | set(handles.list_pair_civ2,'String',displ_pair'); |
---|
| 1152 | set(gcf,'Pointer','arrow') |
---|
[12] | 1153 | |
---|
| 1154 | %------------------------------------------------------------------------ |
---|
[112] | 1155 | % determine the menu for civ2 pairs depending on the existing netcdf file at the |
---|
| 1156 | %middle of the series set by first_i, incr, last_i |
---|
[2] | 1157 | function find_netcpair_civ2(hObject, eventdata, handles) |
---|
[12] | 1158 | %------------------------------------------------------------------------ |
---|
[2] | 1159 | set(gcf,'Pointer','watch') |
---|
| 1160 | %nomenclature types |
---|
[71] | 1161 | filebase=get(handles.RootName,'String'); |
---|
[2] | 1162 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
| 1163 | browse=get(handles.browse_root,'UserData'); |
---|
| 1164 | compare_list=get(handles.compare,'String'); |
---|
| 1165 | val=get(handles.compare,'Value'); |
---|
| 1166 | compare=compare_list{val}; |
---|
| 1167 | if strcmp(compare,'displacement') |
---|
| 1168 | mode='displacement'; |
---|
| 1169 | else |
---|
[252] | 1170 | mode_list=get(handles.mode,'String') |
---|
| 1171 | mode_value=get(handles.mode,'Value') |
---|
[2] | 1172 | mode=mode_list{mode_value}; |
---|
| 1173 | end |
---|
| 1174 | |
---|
| 1175 | % nomenclature type of the .nc files |
---|
| 1176 | nom_type_ima='ima_num';%default |
---|
| 1177 | if isfield(browse,'nom_type_ima') |
---|
| 1178 | nom_type_ima=browse.nom_type_ima; |
---|
| 1179 | end |
---|
| 1180 | nom_type_nc='_i1-i2';%default |
---|
| 1181 | if isfield(browse,'nom_type_nc') |
---|
| 1182 | nom_type_nc=browse.nom_type_nc; |
---|
| 1183 | end |
---|
[94] | 1184 | 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] | 1185 | nom_type_nc='netc_old';%nom_type for the netcdf files |
---|
[94] | 1186 | elseif isequal(nom_type_ima,'none')||isequal(nom_type_nc,'none') |
---|
[2] | 1187 | nom_type_nc='none'; |
---|
[94] | 1188 | elseif isequal(nom_type_ima,'avi')||isequal(nom_type_ima,'_i')||isequal(nom_type_ima,'ima_num')||isequal(nom_type_nc,'_i1-i2') |
---|
[112] | 1189 | nom_type_nc='_i1-i2'; |
---|
[2] | 1190 | else |
---|
| 1191 | if isequal(mode,'series(Di)')%|isequal(mode,'st_series(Di)') |
---|
| 1192 | nom_type_nc='_i1-i2_j'; % PIV in volume |
---|
| 1193 | else |
---|
| 1194 | nom_type_nc='_i_j1-j2'; |
---|
[112] | 1195 | end |
---|
[2] | 1196 | end |
---|
| 1197 | browse.nom_type_nc=nom_type_nc; |
---|
| 1198 | set(handles.browse_root,'UserData',browse) |
---|
| 1199 | |
---|
| 1200 | %reads .nc subdirectory and image numbers from the interface |
---|
| 1201 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
| 1202 | subdir_civ2=get(handles.subdir_civ2,'String');%subdirectory subdir_civ2 for the netcdf data |
---|
[45] | 1203 | % first_i=str2num(get(handles.first_i,'String')); |
---|
| 1204 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 1205 | % incr=str2num(get(handles.incr_i,'String')); |
---|
| 1206 | % num1=first_i:incr:last_i; |
---|
| 1207 | % if isempty(num1) |
---|
| 1208 | % set(handles.list_pair_civ2,'Value',1); |
---|
| 1209 | % set(handles.list_pair_civ2,'String',{''}); |
---|
| 1210 | % return |
---|
| 1211 | % end |
---|
[137] | 1212 | ref_i=str2double(get(handles.ref_i_civ2,'String')); |
---|
[2] | 1213 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
| 1214 | ref_j=0; |
---|
| 1215 | else |
---|
[137] | 1216 | ref_j=str2double(get(handles.ref_j_civ2,'String')); |
---|
[2] | 1217 | end |
---|
[71] | 1218 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
[2] | 1219 | if isempty(time) |
---|
| 1220 | time=[0 1];%default |
---|
| 1221 | end |
---|
[71] | 1222 | %dt_unit=str2num(get(handles.dt,'String'));% used when there is no image documentation file |
---|
[73] | 1223 | %dt_unit=1000; |
---|
[2] | 1224 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 1225 | |
---|
| 1226 | |
---|
[112] | 1227 | %eliminate the first pairs inconsistent with the position |
---|
[2] | 1228 | if isempty(displ_num) |
---|
| 1229 | nbpair=0; |
---|
| 1230 | else |
---|
| 1231 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
[112] | 1232 | if isequal(mode,'series(Di)')% | isequal(mode,'st_series(Di)') |
---|
[2] | 1233 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
[112] | 1234 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
[2] | 1235 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1236 | end |
---|
| 1237 | end |
---|
| 1238 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
| 1239 | |
---|
[112] | 1240 | %look for existing processed pairs involving the field at the middle of the series if civ1 will not |
---|
[2] | 1241 | % be performed, while the result is needed for next steps. |
---|
| 1242 | displ_pair={''}; %default |
---|
| 1243 | select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs |
---|
| 1244 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0%&... |
---|
[112] | 1245 | if ~exist(fullfile(filepath,subdir_civ2,ext_dir),'dir') |
---|
| 1246 | errordlg(['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist']) |
---|
| 1247 | set(handles.list_pair_civ2,'Value',1); |
---|
| 1248 | set(handles.list_pair_civ2,'String',{''}); |
---|
| 1249 | return |
---|
[2] | 1250 | end |
---|
[112] | 1251 | for ipair=1:nbpair |
---|
[2] | 1252 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
[112] | 1253 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
[2] | 1254 | select(ipair)=exist(filename,'file')==2; |
---|
| 1255 | end |
---|
| 1256 | if isequal(select,zeros(size(1:nbpair))) |
---|
[112] | 1257 | if isfield(browse,'incr_pair') |
---|
[2] | 1258 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
| 1259 | num_i2=ref_i+floor((browse.incr_pair(1)+1)/2); |
---|
| 1260 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
| 1261 | num_j2=ref_j+floor((browse.incr_pair(2)+1)/2); |
---|
| 1262 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ2); |
---|
| 1263 | select(1)=exist(filename,'file')==2; |
---|
| 1264 | else |
---|
[112] | 1265 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
[2] | 1266 | errordlg(['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2]) |
---|
| 1267 | else |
---|
| 1268 | errordlg(['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2]) |
---|
| 1269 | end |
---|
[112] | 1270 | set(handles.list_pair_civ2,'Value',1); |
---|
| 1271 | set(handles.list_pair_civ2,'String',{''}); |
---|
[2] | 1272 | return |
---|
| 1273 | end |
---|
| 1274 | end |
---|
| 1275 | end |
---|
[112] | 1276 | if isequal(mode,'series(Di)') % | isequal(mode,'st_series(Di)') |
---|
| 1277 | for ipair=1:nbpair |
---|
| 1278 | if select(ipair) |
---|
| 1279 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
[2] | 1280 | 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 |
---|
| 1281 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
[112] | 1282 | end |
---|
| 1283 | else |
---|
| 1284 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1285 | end |
---|
| 1286 | end |
---|
[2] | 1287 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') % series on the j index |
---|
[112] | 1288 | for ipair=1:nbpair |
---|
| 1289 | if select(ipair) |
---|
| 1290 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1291 | 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 |
---|
| 1292 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1293 | end |
---|
| 1294 | else |
---|
| 1295 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1296 | end |
---|
| 1297 | end |
---|
[2] | 1298 | elseif isequal(mode,'pair j1-j2')% | isequal(mode,'st_pair j1-j2') %case of pairs |
---|
| 1299 | for ipair=1:nbpair |
---|
| 1300 | if select(ipair) |
---|
[112] | 1301 | 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 |
---|
| 1302 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
| 1303 | ' :dt= ' num2str(dt*1000)]; |
---|
| 1304 | else |
---|
| 1305 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1306 | end |
---|
| 1307 | end |
---|
[2] | 1308 | elseif isequal(mode,'displacement') |
---|
[112] | 1309 | displ_pair={'Di=Dj=0'}; |
---|
| 1310 | end |
---|
[2] | 1311 | val=get(handles.list_pair_civ2,'Value'); |
---|
[229] | 1312 | ichoice=find(select,1); |
---|
[137] | 1313 | if (isempty(ichoice) || ichoice < 1); ichoice=1; end; |
---|
| 1314 | if get(handles.CIV2,'Value')==0 && get(handles.CIV1,'Value')==0 && get(handles.FIX1,'Value')==0 && get(handles.PATCH1,'Value')==0 |
---|
[2] | 1315 | val=ichoice;% first valid pair proposed by default in the menu |
---|
| 1316 | end |
---|
| 1317 | if val>length(displ_pair') |
---|
| 1318 | set(handles.list_pair_civ2,'Value',1);% first valid pair proposed by default in the menu |
---|
| 1319 | else |
---|
| 1320 | set(handles.list_pair_civ2,'Value',val); |
---|
| 1321 | end |
---|
| 1322 | set(handles.list_pair_civ2,'String',displ_pair'); |
---|
[12] | 1323 | set(gcf,'Pointer','arrow') |
---|
[2] | 1324 | |
---|
| 1325 | |
---|
[41] | 1326 | |
---|
[227] | 1327 | |
---|
[12] | 1328 | %------------------------------------------------------------------------ |
---|
[2] | 1329 | % --- Executes on selection change in list_pair_civ1. |
---|
| 1330 | function list_pair_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 1331 | %------------------------------------------------------------------------ |
---|
[2] | 1332 | %reproduce by default the chosen pair in the civ2 menu |
---|
| 1333 | list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs |
---|
| 1334 | index_pair=get(handles.list_pair_civ1,'Value'); |
---|
| 1335 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
[137] | 1336 | % num_a=displ_num(1,index_pair); |
---|
| 1337 | % num_b=displ_num(2,index_pair); |
---|
[2] | 1338 | list_pair2=get(handles.list_pair_civ2,'String');%get the menu of image pairs |
---|
| 1339 | if index_pair<=length(list_pair2) |
---|
| 1340 | set(handles.list_pair_civ2,'Value',index_pair); |
---|
| 1341 | end |
---|
| 1342 | |
---|
[112] | 1343 | %update first_i and last_i according to the chosen image pairs |
---|
[2] | 1344 | mode_list=get(handles.mode,'String'); |
---|
| 1345 | mode_value=get(handles.mode,'Value'); |
---|
| 1346 | mode=mode_list{mode_value}; |
---|
| 1347 | if isequal(mode,'series(Di)') |
---|
[137] | 1348 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 1349 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 1350 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
[2] | 1351 | num1=first_i:incr_i:last_i; |
---|
[137] | 1352 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 1353 | if ~isnan(lastfield) |
---|
[229] | 1354 | test_find=(num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
| 1355 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield); |
---|
| 1356 | num1=num1(test_find); |
---|
[2] | 1357 | end |
---|
| 1358 | set(handles.first_i,'String',num2str(num1(1))); |
---|
| 1359 | set(handles.last_i,'String',num2str(num1(end))); |
---|
| 1360 | elseif isequal(mode,'series(Dj)') |
---|
[137] | 1361 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 1362 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 1363 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[2] | 1364 | num_j=first_j:incr_j:last_j; |
---|
[137] | 1365 | lastfield2=str2double(get(handles.nb_field2,'String')); |
---|
| 1366 | if ~isnan(lastfield2) |
---|
[229] | 1367 | test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 1368 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2); |
---|
| 1369 | num1=num_j(test_find); |
---|
[2] | 1370 | end |
---|
| 1371 | set(handles.first_j,'String',num2str(num1(1))); |
---|
| 1372 | set(handles.last_j,'String',num2str(num1(end))); |
---|
[112] | 1373 | end |
---|
[2] | 1374 | |
---|
[12] | 1375 | %------------------------------------------------------------------------ |
---|
[2] | 1376 | % --- Executes on selection change in list_pair_civ2. |
---|
| 1377 | function list_pair_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 1378 | %------------------------------------------------------------------------ |
---|
[112] | 1379 | index_pair=get(handles.list_pair_civ2,'Value');%get the selected position index in the menu |
---|
[2] | 1380 | |
---|
[112] | 1381 | %update first_i and last_i according to the chosen image pairs |
---|
[2] | 1382 | mode_list=get(handles.mode,'String'); |
---|
| 1383 | mode_value=get(handles.mode,'Value'); |
---|
| 1384 | mode=mode_list{mode_value}; |
---|
| 1385 | if isequal(mode,'series(Di)') |
---|
[137] | 1386 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 1387 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 1388 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
[2] | 1389 | num1=first_i:incr_i:last_i; |
---|
[137] | 1390 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 1391 | if ~isnan(lastfield) |
---|
[229] | 1392 | test_find=(num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
| 1393 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield); |
---|
| 1394 | num1=num1(test_find); |
---|
[2] | 1395 | end |
---|
| 1396 | set(handles.first_i,'String',num2str(num1(1))); |
---|
| 1397 | set(handles.last_i,'String',num2str(num1(end))); |
---|
| 1398 | elseif isequal(mode,'series(Dj)') |
---|
[137] | 1399 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 1400 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 1401 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[2] | 1402 | num_j=first_j:incr_j:last_j; |
---|
[137] | 1403 | lastfield2=str2double(get(handles.nb_field2,'String')); |
---|
| 1404 | if ~isnan(lastfield2) |
---|
[229] | 1405 | test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 1406 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2); |
---|
| 1407 | num1=num_j(test_find); |
---|
[2] | 1408 | end |
---|
| 1409 | set(handles.first_j,'String',num2str(num1(1))); |
---|
| 1410 | set(handles.last_j,'String',num2str(num1(end))); |
---|
[112] | 1411 | end |
---|
[2] | 1412 | |
---|
[177] | 1413 | %------------------------------------------------------------------------ |
---|
| 1414 | % --- Executes on button press in RUN: processing on local computer |
---|
[67] | 1415 | function RUN_Callback(hObject, eventdata, handles) |
---|
| 1416 | %------------------------------------------------------------------------ |
---|
[73] | 1417 | set(handles.RUN, 'Enable','Off') |
---|
| 1418 | set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[67] | 1419 | batch=0; |
---|
[229] | 1420 | errormsg=launch_jobs(hObject, eventdata, handles,batch); |
---|
[73] | 1421 | set(handles.RUN, 'Enable','On') |
---|
| 1422 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
[36] | 1423 | |
---|
[177] | 1424 | % start status callback to visualise results |
---|
[229] | 1425 | if ~isempty(errormsg) |
---|
| 1426 | display(errormsg) |
---|
| 1427 | msgbox_uvmat('ERROR',errormsg) |
---|
[236] | 1428 | elseif isfield(handles,'status') %&& ~isequal(get(handles.CivAll,'Value'),3) |
---|
[225] | 1429 | set(handles.status,'Value',1);%suppress status display |
---|
| 1430 | status_Callback(hObject, eventdata, handles) |
---|
[178] | 1431 | end |
---|
[177] | 1432 | |
---|
[12] | 1433 | %------------------------------------------------------------------------ |
---|
[2] | 1434 | % --- Executes on button press in BATCH: remote processing |
---|
| 1435 | function BATCH_Callback(hObject, eventdata, handles) |
---|
[177] | 1436 | % ----------------------------------------------------------------------- |
---|
[73] | 1437 | set(handles.BATCH, 'Enable','Off') |
---|
| 1438 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[67] | 1439 | batch=1; |
---|
[229] | 1440 | errormsg=launch_jobs(hObject, eventdata, handles, batch); |
---|
[73] | 1441 | set(handles.BATCH, 'Enable','On') |
---|
| 1442 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
[67] | 1443 | |
---|
[177] | 1444 | % start status callback to visualise results |
---|
[229] | 1445 | if ~isempty(errormsg) |
---|
| 1446 | display(errormsg) |
---|
| 1447 | msgbox_uvmat('ERROR',errormsg) |
---|
| 1448 | elseif isfield(handles,'status') |
---|
| 1449 | set(handles.status,'Value',1);%suppress status display |
---|
| 1450 | status_Callback(hObject, eventdata, handles) |
---|
[178] | 1451 | end |
---|
[227] | 1452 | |
---|
[67] | 1453 | %------------------------------------------------------------------------ |
---|
[133] | 1454 | % --- Lauch command called by RUN and BATCH: remote processing |
---|
[229] | 1455 | function errormsg=launch_jobs(hObject, eventdata, handles, batch) |
---|
[67] | 1456 | %----------------------------------------------------------------------- |
---|
[229] | 1457 | errormsg='';%default |
---|
[133] | 1458 | %% check the selected list of operations: |
---|
[2] | 1459 | operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'}; |
---|
| 1460 | box_test(1)=get(handles.CIV1,'Value'); |
---|
| 1461 | box_test(2)=get(handles.FIX1,'Value'); |
---|
| 1462 | box_test(3)=get(handles.PATCH1,'Value'); |
---|
| 1463 | box_test(4)=get(handles.CIV2,'Value'); |
---|
| 1464 | box_test(5)=get(handles.FIX2,'Value'); |
---|
| 1465 | box_test(6)=get(handles.PATCH2,'Value'); |
---|
[180] | 1466 | index_first=find(box_test==1,1); |
---|
| 1467 | if isempty(index_first) |
---|
[229] | 1468 | errormsg='no selected operation'; |
---|
[2] | 1469 | return |
---|
| 1470 | end |
---|
[180] | 1471 | index_last=find(box_test==1,1,'last'); |
---|
[159] | 1472 | box_used=box_test(index_first : index_last); |
---|
[2] | 1473 | [box_missing,ind_missing]=min(box_used); |
---|
[180] | 1474 | if isequal(box_missing,0); %there is a missing step in the sequence of operations |
---|
[229] | 1475 | errormsg=['missing' cell2mat(operations(ind_missing))]; |
---|
[2] | 1476 | return |
---|
| 1477 | end |
---|
| 1478 | |
---|
[177] | 1479 | %% check mask if selecetd |
---|
[2] | 1480 | if isequal(get(handles.get_mask_civ1,'Value'),1) |
---|
[12] | 1481 | maskname=get(handles.mask_civ1,'String'); |
---|
| 1482 | if ~exist(maskname,'file') |
---|
| 1483 | get_mask_civ1_Callback(hObject, eventdata, handles); |
---|
| 1484 | end |
---|
[2] | 1485 | end |
---|
| 1486 | if isequal(get(handles.get_mask_fix1,'Value'),1) |
---|
[12] | 1487 | maskname=get(handles.mask_fix1,'String'); |
---|
| 1488 | if ~exist(maskname,'file') |
---|
| 1489 | get_mask_fix1_Callback(hObject, eventdata, handles); |
---|
| 1490 | end |
---|
[2] | 1491 | end |
---|
| 1492 | if isequal(get(handles.get_mask_civ2,'Value'),1) |
---|
[12] | 1493 | maskname=get(handles.mask_civ2,'String'); |
---|
| 1494 | if ~exist(maskname,'file') |
---|
[112] | 1495 | get_mask_civ2_Callback(hObject, eventdata, handles); |
---|
[12] | 1496 | end |
---|
[2] | 1497 | end |
---|
| 1498 | if isequal(get(handles.get_mask_fix2,'Value'),1) |
---|
[12] | 1499 | maskname=get(handles.mask_fix2,'String'); |
---|
| 1500 | if ~exist(maskname,'file') |
---|
[112] | 1501 | get_mask_fix2_Callback(hObject, eventdata, handles); |
---|
[12] | 1502 | end |
---|
[2] | 1503 | end |
---|
| 1504 | |
---|
[177] | 1505 | %% reinitialise status callback |
---|
[178] | 1506 | if isfield(handles,'status') |
---|
[180] | 1507 | set(handles.status,'Value',0);%suppress status display |
---|
| 1508 | status_Callback(hObject, eventdata, handles) |
---|
[178] | 1509 | end |
---|
[133] | 1510 | |
---|
| 1511 | %% set the list of files and check them |
---|
| 1512 | display('checking the files...') |
---|
[227] | 1513 | [ref_i,ref_j,errormsg]=find_ref_indices(handles); |
---|
| 1514 | if ~isempty(errormsg) |
---|
| 1515 | return |
---|
| 1516 | end |
---|
[133] | 1517 | [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc]=... |
---|
[227] | 1518 | set_civ_filenames(handles,ref_i,ref_j,box_test); |
---|
[177] | 1519 | set(handles.civ,'UserData',filecell);%store for futur use of status callback |
---|
[137] | 1520 | if isempty(filecell)% (error message displayed in fct set_civ_filenames) |
---|
[133] | 1521 | return |
---|
| 1522 | end |
---|
| 1523 | nbfield=numel(num1_civ1); |
---|
| 1524 | nbslice=numel(num_a_civ1); |
---|
| 1525 | |
---|
| 1526 | %% read names of the .exe files for PIV and patch |
---|
| 1527 | path_UVMAT=fileparts(which('uvmat')); %path to the source directory of uvmat |
---|
[112] | 1528 | xmlfile='PARAM.xml'; |
---|
[133] | 1529 | if exist(xmlfile,'file')% search parameter xml file in the whole matlab path |
---|
[54] | 1530 | t=xmltree(xmlfile); |
---|
[67] | 1531 | s=convert(t); |
---|
[2] | 1532 | end |
---|
[127] | 1533 | test_interp=0; |
---|
| 1534 | if batch |
---|
[67] | 1535 | if isfield(s,'BatchParam') |
---|
| 1536 | sparam=s.BatchParam; |
---|
[256] | 1537 | |
---|
| 1538 | if ~ismember(sparam.BatchMode,{'sge','oar'}) |
---|
[229] | 1539 | errormsg=['batch mode ' sparam.BatchMode ' not supported by UVMAT']; |
---|
| 1540 | return |
---|
[67] | 1541 | end |
---|
| 1542 | else |
---|
[229] | 1543 | errormsg='no batch civ binaries defined in PARAM.xml'; |
---|
[67] | 1544 | return |
---|
| 1545 | end |
---|
[225] | 1546 | if isfield(sparam,'BatchMode') |
---|
| 1547 | batch_mode=sparam.BatchMode; |
---|
| 1548 | end |
---|
| 1549 | % choice of batch priority: |
---|
| 1550 | ind_answer=2; |
---|
| 1551 | [s,w]=unix('qstat -q civ.q|grep job_| wc -l'); %check the waiting list (command unix) |
---|
| 1552 | if isequal(s,0) |
---|
| 1553 | w(end)=[]; |
---|
[232] | 1554 | str_displ={[w ' jobs in the waiting list'];... |
---|
| 1555 | '***********************';... |
---|
| 1556 | 'JOBS PRIORITY POLICY';... |
---|
| 1557 | '- urgent = less than 100 images pairs';... |
---|
| 1558 | '- normal = during the experiments';... |
---|
| 1559 | '- low = post processing';... |
---|
| 1560 | '***********************';... |
---|
| 1561 | 'Select a priority:'}; |
---|
| 1562 | ' ';... |
---|
| 1563 | str={'urgent';'normal';'low'}; |
---|
[225] | 1564 | [ind_answer,v] = listdlg('PromptString',str_displ,... |
---|
| 1565 | 'SelectionMode','single',... |
---|
[232] | 1566 | 'ListString',str,'ListSize',[200 100],'Name','job priority','InitialValue',3); |
---|
[225] | 1567 | if isequal(v,0) % to handle Cancel button and figure close, |
---|
[229] | 1568 | errormsg='job cancelled'; |
---|
[225] | 1569 | return % a better way should be create |
---|
| 1570 | end |
---|
| 1571 | else |
---|
| 1572 | msgbox_uvmat('ERROR','sge batch system not available') |
---|
| 1573 | return |
---|
| 1574 | end |
---|
[67] | 1575 | else |
---|
| 1576 | if isfield(s,'RunParam') |
---|
| 1577 | sparam=s.RunParam; |
---|
| 1578 | else |
---|
[225] | 1579 | msgbox_uvmat('ERROR','no run civ binaries defined in PARAM.xml') |
---|
[67] | 1580 | return |
---|
| 1581 | end |
---|
[225] | 1582 | end |
---|
[238] | 1583 | |
---|
| 1584 | %% choose the civ program |
---|
| 1585 | ProgList=get(handles.CivAll,'String'); |
---|
| 1586 | index=get(handles.CivAll,'Value'); |
---|
| 1587 | CivX=isequal(ProgList{index},'CivX'); |
---|
| 1588 | CivAll=isequal(ProgList{index},'CivAll'); |
---|
| 1589 | CivUvmat=isequal(ProgList{index},'CivUvmat'); |
---|
| 1590 | %CivAll=isequal(get(handles.CivAll,'Value'),2); % Boolean for new civ programs |
---|
| 1591 | if CivAll && isfield(sparam,'CivBin') |
---|
[225] | 1592 | CivBin=sparam.CivBin; |
---|
| 1593 | if ~exist(CivBin,'file') || ~isempty(which(CivBin))% if path defined as relative to uvmat |
---|
| 1594 | sparam.CivBin=fullfile(path_UVMAT,CivBin); |
---|
| 1595 | if ~exist(sparam.CivBin,'file') |
---|
| 1596 | msgbox_uvmat('ERROR',['CIVx binary ' CivBin ' defined in PARAM.xm does not exist']) |
---|
| 1597 | return |
---|
[112] | 1598 | end |
---|
[94] | 1599 | end |
---|
[225] | 1600 | end |
---|
| 1601 | if isfield(sparam,'Civ1Bin') |
---|
| 1602 | Civ1Bin=sparam.Civ1Bin; |
---|
| 1603 | if ~exist(Civ1Bin,'file')||~isempty(which(Civ1Bin))% if path defined as relative to uvmat |
---|
| 1604 | sparam.Civ1Bin=fullfile(path_UVMAT,Civ1Bin); |
---|
| 1605 | if ~exist(sparam.Civ1Bin,'file') |
---|
| 1606 | msgbox_uvmat('ERROR',['civ1 binary ' Civ1Bin ' defined in PARAM.xm does not exist']) |
---|
| 1607 | return |
---|
[112] | 1608 | end |
---|
[94] | 1609 | end |
---|
[225] | 1610 | end |
---|
| 1611 | if isfield(sparam,'Civ2Bin') |
---|
| 1612 | Civ2Bin=sparam.Civ2Bin; |
---|
| 1613 | if ~exist(Civ2Bin,'file')||~isempty(which(Civ2Bin))% if path defined as relative to uvmat |
---|
| 1614 | sparam.Civ2Bin=fullfile(path_UVMAT,Civ2Bin); |
---|
| 1615 | if ~exist(sparam.Civ2Bin,'file') |
---|
| 1616 | msgbox_uvmat('ERROR',['civ2 binary ' Civ2Bin ' defined in PARAM.xm does not exist']) |
---|
| 1617 | return |
---|
[112] | 1618 | end |
---|
[94] | 1619 | end |
---|
[225] | 1620 | end |
---|
| 1621 | if isfield(sparam,'PatchBin') |
---|
| 1622 | if ~exist(sparam.PatchBin,'file')||~isempty(which(sparam.PatchBin))% if path defined as relative to uvmat |
---|
| 1623 | sparam.PatchBin=fullfile(path_UVMAT,sparam.PatchBin); |
---|
[94] | 1624 | end |
---|
[73] | 1625 | end |
---|
[225] | 1626 | if isfield(sparam,'FixBin') |
---|
| 1627 | if ~exist(sparam.FixBin,'file')||~isempty(which(sparam.FixBin))% if path defined as relative to uvmat |
---|
| 1628 | sparam.FixBin=fullfile(path_UVMAT,sparam.FixBin); |
---|
[2] | 1629 | end |
---|
| 1630 | end |
---|
| 1631 | |
---|
| 1632 | |
---|
[225] | 1633 | |
---|
[133] | 1634 | %% get civ1 parameters: |
---|
[112] | 1635 | display('files OK, processing...') |
---|
[2] | 1636 | if box_test(1)==1 |
---|
| 1637 | par_civ1=read_param_civ1(handles,filecell.ima1.civ1{1,1}); |
---|
[112] | 1638 | end |
---|
[2] | 1639 | |
---|
[133] | 1640 | %% get fix1 parameters |
---|
[112] | 1641 | if box_test(2)==1 |
---|
[2] | 1642 | flagindex1(1)=get(handles.vec_Fmin2, 'Value'); |
---|
| 1643 | flagindex1(2)=get(handles.vec_F3, 'Value'); |
---|
| 1644 | flagindex1(3)=get(handles.vec_F2, 'Value'); |
---|
[127] | 1645 | thresh_vecC1=str2double(get(handles.thresh_vecC,'String'));%threshold on image correlation vec_C |
---|
| 1646 | thresh_vel1=str2double(get(handles.thresh_vel,'String'));%threshold on velocity modulus |
---|
[2] | 1647 | test_mask=get(handles.get_mask_fix1,'Value'); |
---|
| 1648 | nbslice_mask=get(handles.mask_fix1,'UserData'); % get the number of slices (= number of masks) |
---|
| 1649 | %%%%%%%%%%%%%COMPLETER LE PROGRAMME FIX |
---|
[112] | 1650 | % inf_sup=get(handles.inf_sup1,'Value');80 |
---|
| 1651 | % fileref=get(handles.ref_fix1,'String'); |
---|
| 1652 | % refpath=get(handles.ref_fix1,'UserData'); |
---|
| 1653 | % fileref=fullfile(refpath,fileref); |
---|
[2] | 1654 | menu=get(handles.field_ref1,'String'); |
---|
| 1655 | index=get(handles.field_ref1,'Value'); |
---|
| 1656 | if isempty(menu) |
---|
| 1657 | fieldchoice=''; |
---|
| 1658 | else |
---|
| 1659 | fieldchoice=menu{index}; |
---|
[112] | 1660 | msgbox_uvmat('WARNING','reference field is not used presently with batch, use RUN option') |
---|
| 1661 | end |
---|
[2] | 1662 | end |
---|
[112] | 1663 | |
---|
[133] | 1664 | %% get patch1 parameters |
---|
[67] | 1665 | if box_test(3)==1 |
---|
[127] | 1666 | rho_patch1=str2double(get(handles.rho_patch1,'String')); |
---|
| 1667 | if isnan(rho_patch1) |
---|
[112] | 1668 | rho_patch1='1000'; |
---|
| 1669 | set(handles.rho_patch1,'String','1') |
---|
| 1670 | else |
---|
| 1671 | rho_patch1=num2str(1000*rho_patch1); |
---|
| 1672 | end |
---|
| 1673 | nx_patch1=get(handles.nx_patch1,'String'); |
---|
| 1674 | ny_patch1=get(handles.ny_patch1,'String'); |
---|
[127] | 1675 | if isnan(str2double(nx_patch1)) |
---|
[112] | 1676 | nx_patch1='50' ;%default |
---|
| 1677 | set(handles.nx_patch1,'String','50'); |
---|
| 1678 | end |
---|
[127] | 1679 | if isnan(str2double(ny_patch1)) |
---|
[112] | 1680 | ny_patch1='50' ;%default |
---|
| 1681 | set(handles.ny_patch1,'String','50'); |
---|
| 1682 | end |
---|
| 1683 | subdomain_patch1=get(handles.subdomain_patch1,'String'); |
---|
| 1684 | thresh_patch1=get(handles.thresh_patch1,'String'); |
---|
| 1685 | end |
---|
| 1686 | |
---|
[133] | 1687 | %% get civ2 parameters: |
---|
[2] | 1688 | if box_test(4)==1 |
---|
| 1689 | par_civ2=read_param_civ2(handles,cell2mat(filecell.ima1.civ2(1,1))); |
---|
| 1690 | end |
---|
| 1691 | |
---|
[133] | 1692 | %% get fix2 parameters |
---|
[112] | 1693 | if box_test(5)==1 |
---|
[2] | 1694 | flagindex2(1)=get(handles.vec_Fmin2_2, 'Value'); |
---|
| 1695 | flagindex2(2)=get(handles.vec_F3_2, 'Value'); |
---|
| 1696 | flagindex2(3)=get(handles.vec_F4, 'Value'); |
---|
[127] | 1697 | thresh_vec2C=str2double(get(handles.thresh_vec2C,'String'));%threshold on image correlation vec_C |
---|
| 1698 | thresh_vel2=str2double(get(handles.thresh_vel2,'String'));%threshold on velocity modulus |
---|
[2] | 1699 | test_mask=get(handles.get_mask_fix2,'Value'); |
---|
| 1700 | nbslice_mask=get(handles.mask_fix2,'UserData'); % get the number of slices (= number of masks) |
---|
[112] | 1701 | %%%%%%%%%%%%%COMPLETER LE PROGRAMME FIX AVEC REF FILE ET OPTION inf_sup=2 |
---|
| 1702 | % inf_sup=get(handles.inf_sup2,'Value'); |
---|
| 1703 | % ref=get(handles.ref_fix2,'UserData'); |
---|
| 1704 | |
---|
[2] | 1705 | %%%%%%%%%%%%%%%%%%% |
---|
| 1706 | end |
---|
| 1707 | |
---|
[133] | 1708 | %% get patch2 parameters |
---|
[2] | 1709 | if box_test(6)==1 |
---|
[127] | 1710 | rho_patch2=str2double(get(handles.rho_patch2,'String')); |
---|
| 1711 | if isnan(rho_patch2) |
---|
[2] | 1712 | rho_patch2='1000'; |
---|
| 1713 | set(handles.rho_patch2,'String','1') |
---|
| 1714 | else |
---|
| 1715 | rho_patch2=num2str(1000*rho_patch2); |
---|
| 1716 | end |
---|
| 1717 | nx_patch2=get(handles.nx_patch2,'String'); |
---|
| 1718 | ny_patch2=get(handles.ny_patch2,'String'); |
---|
[127] | 1719 | if isnan(str2double(nx_patch2)) |
---|
[2] | 1720 | nx_patch2='50' ;%default |
---|
| 1721 | set(handles.nx_patch2,'String','50'); |
---|
| 1722 | end |
---|
[127] | 1723 | if isnan(str2double(ny_patch2)) |
---|
[2] | 1724 | ny_patch2='50' ;%default |
---|
| 1725 | set(handles.ny_patch2,'String','50'); |
---|
| 1726 | end |
---|
| 1727 | subdomain_patch2=get(handles.subdomain_patch2,'String'); |
---|
| 1728 | thresh_patch2=get(handles.thresh_patch2,'String'); |
---|
[112] | 1729 | % test_interp=get(handles.test_interp,'Value'); |
---|
[2] | 1730 | end |
---|
| 1731 | |
---|
[133] | 1732 | %% MAIN LOOP |
---|
[71] | 1733 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
[134] | 1734 | super_cmd=[]; |
---|
| 1735 | |
---|
[2] | 1736 | for ifile=1:nbfield |
---|
| 1737 | for j=1:nbslice |
---|
[112] | 1738 | i_cmd=0; |
---|
[2] | 1739 | cmd=''; |
---|
[73] | 1740 | if isunix % check: necessaire aussi en RUN? |
---|
[112] | 1741 | cmd='#!/bin/bash \n'; |
---|
| 1742 | cmd=[cmd '#$ -cwd \n']; |
---|
| 1743 | cmd=[cmd 'hostname && date \n']; |
---|
[220] | 1744 | cmd=[cmd 'umask 002 \n'];%allow writting access to created files for user group |
---|
[2] | 1745 | end |
---|
[238] | 1746 | if CivAll |
---|
| 1747 | CivAllxml=xmltree;% xml contents, all parameters |
---|
| 1748 | CivAllCmd=''; |
---|
| 1749 | CivAllxml=set(CivAllxml,1,'name','CivDoc'); |
---|
[2] | 1750 | end |
---|
[174] | 1751 | [Rootbat,Filebat]=fileparts(filecell.nc.civ1{ifile,j});%output netcdf file (without extention) |
---|
[177] | 1752 | flname=fullfile(Rootbat,Filebat); |
---|
[159] | 1753 | if batch |
---|
[174] | 1754 | filename_bat=fullfile(Rootbat,['job_' Filebat]); |
---|
[159] | 1755 | else |
---|
[177] | 1756 | filename_bat=flname; |
---|
[159] | 1757 | end |
---|
[174] | 1758 | filename_bat=[filename_bat '.bat']; |
---|
[2] | 1759 | |
---|
[112] | 1760 | %CIV1 |
---|
[2] | 1761 | if box_test(1)==1 |
---|
[41] | 1762 | par_civ1.filename_ima_a=filecell.ima1.civ1{ifile,j}; |
---|
[112] | 1763 | par_civ1.filename_ima_b=filecell.ima2.civ1{ifile,j}; |
---|
[2] | 1764 | par_civ1.Dt=num2str(time(num2_civ1(ifile),num_b_civ1(j))-time(num1_civ1(ifile),num_a_civ1(j))); |
---|
[112] | 1765 | par_civ1.T0=num2str((time(num2_civ1(ifile),num_b_civ1(j))+time(num1_civ1(ifile),num_a_civ1(j)))/2); |
---|
[2] | 1766 | par_civ1.term_a=num2stra(num_a_civ1(j),nom_type_nc);%UTILITE? |
---|
[112] | 1767 | par_civ1.term_b=num2stra(num_b_civ1(j),nom_type_nc);% |
---|
[2] | 1768 | test_mask=get(handles.get_mask_civ1,'Value'); |
---|
[112] | 1769 | if test_mask==0 |
---|
[2] | 1770 | par_civ1.maskname='noFile use default'; |
---|
| 1771 | par_civ1.maskflag='n'; |
---|
| 1772 | else |
---|
| 1773 | maskdispl=get(handles.mask_civ1,'String'); |
---|
[12] | 1774 | if exist(maskdispl,'file') |
---|
| 1775 | par_civ1.maskname=maskdispl; |
---|
[112] | 1776 | par_civ1.maskflag='y'; |
---|
[2] | 1777 | else |
---|
[136] | 1778 | maskbase=[filecell.filebase '_' maskdispl]; % |
---|
[137] | 1779 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
[12] | 1780 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
| 1781 | par_civ1.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 1782 | if exist(par_civ1.maskname,'file') |
---|
[82] | 1783 | par_civ1.maskflag='y'; |
---|
[12] | 1784 | else |
---|
| 1785 | par_civ1.maskname='noFile use default'; |
---|
[112] | 1786 | par_civ1.maskflag='n'; |
---|
[12] | 1787 | end |
---|
[2] | 1788 | end |
---|
| 1789 | end |
---|
| 1790 | |
---|
| 1791 | test_grid=get(handles.browse_gridciv1,'Value'); |
---|
| 1792 | if test_grid |
---|
| 1793 | par_civ1.gridflag='y'; |
---|
| 1794 | gridname=get(handles.grid_civ1,'String'); |
---|
| 1795 | if isequal(gridname(end-3:end),'grid') |
---|
[137] | 1796 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 1797 | if ~isnan(nbslice_grid) |
---|
[2] | 1798 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
[136] | 1799 | par_civ1.gridname=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
[2] | 1800 | if ~exist(par_civ1.gridname,'file') |
---|
[112] | 1801 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
[2] | 1802 | end |
---|
| 1803 | elseif exist(gridname,'file') |
---|
[112] | 1804 | par_civ1.gridname=gridname; |
---|
[2] | 1805 | else |
---|
| 1806 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
| 1807 | end |
---|
| 1808 | end |
---|
| 1809 | else |
---|
[112] | 1810 | par_civ1.gridname='noFile use default'; |
---|
| 1811 | par_civ1.gridflag='n'; |
---|
[2] | 1812 | end |
---|
[112] | 1813 | % |
---|
[2] | 1814 | i_cmd=i_cmd+1; |
---|
[238] | 1815 | if isequal(CivAll,0) |
---|
[230] | 1816 | civ1_exe=CIV1_CMD(fullfile(Rootbat,Filebat),'',par_civ1,handles,sparam);%create the parameter file .civ1.cmx and set the execution string civ1_exe |
---|
[229] | 1817 | % if(isunix) |
---|
| 1818 | % cmd=[cmd 'cp -f ' flname '.civ1.cmx ' flname '.cmx\n']; |
---|
| 1819 | % else |
---|
| 1820 | % flname=regexprep(flname,'\\','\\\\'); |
---|
| 1821 | % cmd=[cmd 'copy /Y "' flname '.civ1.cmx" "' flname '.cmx"\n']; |
---|
| 1822 | % end |
---|
[230] | 1823 | cmd=[cmd civ1_exe '\n']; |
---|
[2] | 1824 | else |
---|
[238] | 1825 | CivAllCmd=[CivAllCmd ' civ1 ']; |
---|
[174] | 1826 | str=CIV1_CMD_Unified(fullfile(Rootbat,Filebat),'',par_civ1); |
---|
[112] | 1827 | fieldnames=fields(str); |
---|
[238] | 1828 | [CivAllxml,uid_civ1]=add(CivAllxml,1,'element','civ1'); |
---|
[2] | 1829 | for ilist=1:length(fieldnames) |
---|
[112] | 1830 | val=eval(['str.' fieldnames{ilist}]); |
---|
| 1831 | if ischar(val) |
---|
[238] | 1832 | [CivAllxml,uid_t]=add(CivAllxml,uid_civ1,'element',fieldnames{ilist}); |
---|
| 1833 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
[112] | 1834 | end |
---|
| 1835 | end |
---|
[2] | 1836 | end |
---|
| 1837 | end |
---|
| 1838 | |
---|
[112] | 1839 | % FIX1 |
---|
| 1840 | if box_test(2)==1 |
---|
| 1841 | test_mask=get(handles.get_mask_fix1,'Value'); |
---|
| 1842 | if test_mask==0 |
---|
[2] | 1843 | maskname=''; |
---|
[112] | 1844 | else |
---|
[2] | 1845 | maskdispl=get(handles.mask_fix1,'String'); |
---|
[137] | 1846 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
[2] | 1847 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
[136] | 1848 | maskbase=[filecell.filebase '_' maskdispl]; |
---|
[2] | 1849 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
[112] | 1850 | end |
---|
[238] | 1851 | if CivX |
---|
[163] | 1852 | if isunix %unix system |
---|
[94] | 1853 | cmd_FIX=[sparam.FixBin ' -f ' filecell.nc.civ1{ifile,j} ' -fi1 ' num2str(flagindex1(1)) ... |
---|
[112] | 1854 | ' -fi2 ' num2str(flagindex1(2)) ' -fi3 ' num2str(flagindex1(3)) ... |
---|
| 1855 | ' -threshC ' num2str(thresh_vecC1) ' -threshV ' num2str(thresh_vel1) ' -maskName ' maskname]; |
---|
[163] | 1856 | else %windows system |
---|
| 1857 | cmd_FIX=['"' sparam.FixBin '" -f "' filecell.nc.civ1{ifile,j} '" -fi1 ' num2str(flagindex1(1)) ... |
---|
| 1858 | ' -fi2 ' num2str(flagindex1(2)) ' -fi3 ' num2str(flagindex1(3)) ... |
---|
| 1859 | ' -threshC ' num2str(thresh_vecC1) ' -threshV ' num2str(thresh_vel1) ' -maskName "' maskname '"']; |
---|
| 1860 | cmd_FIX=regexprep(cmd_FIX,'\\','\\\\'); |
---|
| 1861 | end |
---|
[94] | 1862 | cmd=[cmd cmd_FIX '\n']; |
---|
[238] | 1863 | elseif CivAll |
---|
[2] | 1864 | fix1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 1865 | fix1.fi1=num2str(flagindex1(1)); |
---|
| 1866 | fix1.fi2=num2str(flagindex1(2)); |
---|
| 1867 | fix1.fi3=num2str(flagindex1(3)); |
---|
| 1868 | fix1.threshC=num2str(thresh_vecC1); |
---|
[112] | 1869 | fix1.threshV=num2str(thresh_vel1); |
---|
[2] | 1870 | fieldnames=fields(fix1); |
---|
[238] | 1871 | [CivAllxml,uid_fix1]=add(CivAllxml,1,'element','fix1'); |
---|
[2] | 1872 | for ilist=1:length(fieldnames) |
---|
[112] | 1873 | val=eval(['fix1.' fieldnames{ilist}]); |
---|
| 1874 | if ischar(val) |
---|
[238] | 1875 | [CivAllxml,uid_t]=add(CivAllxml,uid_fix1,'element',fieldnames{ilist}); |
---|
| 1876 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
[112] | 1877 | end |
---|
| 1878 | end |
---|
[238] | 1879 | CivAllCmd=[CivAllCmd ' fix1 ']; |
---|
[112] | 1880 | end |
---|
| 1881 | end |
---|
| 1882 | |
---|
| 1883 | %PATCH1 |
---|
| 1884 | if box_test(3)==1 |
---|
[238] | 1885 | if isequal(CivAll,0) |
---|
[112] | 1886 | cmd_PATCH=PATCH_CMD(filecell.nc.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp,sparam.PatchBin); |
---|
| 1887 | cmd=[cmd cmd_PATCH '\n']; |
---|
| 1888 | else |
---|
| 1889 | patch1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 1890 | patch1.nopt=subdomain_patch1; |
---|
| 1891 | patch1.maxdiff=thresh_patch1; |
---|
| 1892 | patch1.ro=rho_patch1; |
---|
| 1893 | test_grid=get(handles.get_gridpatch1,'Value'); |
---|
| 1894 | if test_grid |
---|
| 1895 | patch1.gridflag='y'; |
---|
| 1896 | gridname=get(handles.grid_patch1,'String'); |
---|
| 1897 | if isequal(gridname(end-3:end),'grid') |
---|
[137] | 1898 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 1899 | if ~isnan(nbslice_grid) |
---|
[112] | 1900 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
[136] | 1901 | patch1.gridPatch=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
[112] | 1902 | if ~exist(patch1.gridPatch,'file') |
---|
| 1903 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
| 1904 | end |
---|
| 1905 | elseif exist(gridname,'file') |
---|
| 1906 | patch1.gridPatch=gridname; |
---|
| 1907 | else |
---|
| 1908 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
[2] | 1909 | end |
---|
| 1910 | end |
---|
[112] | 1911 | else |
---|
| 1912 | patch1.gridPatch='none'; |
---|
| 1913 | patch1.gridflag='n'; |
---|
| 1914 | patch1.m=nx_patch1; |
---|
| 1915 | patch1.n=ny_patch1; |
---|
[2] | 1916 | end |
---|
[112] | 1917 | patch1.convectFlow='n'; |
---|
| 1918 | fieldnames=fields(patch1); |
---|
[238] | 1919 | [CivAllxml,uid_patch1]=add(CivAllxml,1,'element','patch1'); |
---|
[2] | 1920 | for ilist=1:length(fieldnames) |
---|
[112] | 1921 | val=eval(['patch1.' fieldnames{ilist}]); |
---|
| 1922 | if ischar(val) |
---|
[238] | 1923 | [CivAllxml,uid_t]=add(CivAllxml,uid_patch1,'element',fieldnames{ilist}); |
---|
| 1924 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
[112] | 1925 | end |
---|
| 1926 | end |
---|
[238] | 1927 | CivAllCmd=[CivAllCmd ' patch1 ']; |
---|
[112] | 1928 | end |
---|
[2] | 1929 | end |
---|
[112] | 1930 | |
---|
[127] | 1931 | if box_test(4)==1 || box_test(5)==1 || box_test(6)==1 |
---|
[112] | 1932 | filename_cmx=filecell.nc.civ2{ifile,j};%output netcdf file |
---|
[229] | 1933 | filename_cmx(end-1:end+1)='cmx';%name of cmx file |
---|
[112] | 1934 | end |
---|
| 1935 | |
---|
| 1936 | if box_test(4)==1 |
---|
[2] | 1937 | par_civ2.filename_ima_a=filecell.ima1.civ2{ifile,j}; |
---|
| 1938 | par_civ2.filename_ima_b=filecell.ima2.civ2{ifile,j}; |
---|
[174] | 1939 | [Rootbat,Filebat]=fileparts(filecell.nc.civ2{ifile,j});%output netcdf file (without extention) |
---|
[2] | 1940 | par_civ2.Dt=num2str(time(num2_civ2(ifile),num_b_civ2(j))-time(num1_civ2(ifile),num_a_civ2(j))); |
---|
[112] | 1941 | par_civ2.T0=num2str((time(num2_civ1(ifile),num_b_civ2(j))+time(num1_civ2(ifile),num_a_civ2(j)))/2); |
---|
[2] | 1942 | par_civ2.term_a=num2stra(num_a_civ2(j),nom_type_nc); |
---|
[112] | 1943 | par_civ2.term_b=num2stra(num_b_civ2(j),nom_type_nc); |
---|
[2] | 1944 | par_civ2.filename_nc1=filecell.nc.civ1{ifile,j}; |
---|
[229] | 1945 | par_civ2.filename_nc1(end-2:end)=[]; % remove '.nc' |
---|
[2] | 1946 | test_mask=get(handles.get_mask_civ2,'Value'); |
---|
[112] | 1947 | if test_mask==0 |
---|
[2] | 1948 | par_civ2.maskname='noFile use default'; |
---|
| 1949 | par_civ2.maskflag='n'; |
---|
| 1950 | else |
---|
| 1951 | maskdispl=get(handles.mask_civ2,'String'); |
---|
[12] | 1952 | if exist(maskdispl,'file') |
---|
| 1953 | par_civ2.maskname=maskdispl; |
---|
| 1954 | par_civ2.maskflag='y'; |
---|
[2] | 1955 | else |
---|
[136] | 1956 | maskbase=[filecell.filebase '_' maskdispl]; % |
---|
[137] | 1957 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
[12] | 1958 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
| 1959 | par_civ2.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 1960 | if exist(par_civ2.maskname,'file') |
---|
[112] | 1961 | par_civ2.maskflag='y'; |
---|
[12] | 1962 | else |
---|
| 1963 | par_civ2.maskname='noFile use default'; |
---|
[112] | 1964 | par_civ2.maskflag='n'; |
---|
[12] | 1965 | end |
---|
[2] | 1966 | end |
---|
| 1967 | end |
---|
| 1968 | %TESTgrid |
---|
[137] | 1969 | %test_grid=get(handles.browse_gridciv2,'Value'); |
---|
[2] | 1970 | gridname=get(handles.grid_civ2,'String'); |
---|
[137] | 1971 | %gridflag='y'; |
---|
[2] | 1972 | if numel(gridname)>=4 && isequal(gridname(end-3:end),'grid') |
---|
[137] | 1973 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 1974 | if ~isnan(nbslice_grid) |
---|
[2] | 1975 | par_civ2.gridflag='y'; |
---|
| 1976 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
[136] | 1977 | par_civ2.gridname=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
[2] | 1978 | if exist(par_civ2.gridname,'file') |
---|
[112] | 1979 | par_civ2.gridflag='y'; |
---|
[2] | 1980 | else |
---|
| 1981 | par_civ2.gridname='noFile use default'; |
---|
[112] | 1982 | par_civ2.gridflag='n'; |
---|
[2] | 1983 | end |
---|
| 1984 | elseif exist(gridname,'file') |
---|
[112] | 1985 | par_civ2.gridflag='y'; |
---|
[2] | 1986 | else |
---|
| 1987 | par_civ2.gridname='noFile use default'; |
---|
[112] | 1988 | par_civ2.gridflag='n'; |
---|
[2] | 1989 | end |
---|
| 1990 | end |
---|
| 1991 | i_cmd=i_cmd+1; |
---|
[177] | 1992 | flname=fullfile(Rootbat,Filebat); |
---|
[230] | 1993 | |
---|
[238] | 1994 | if isequal(CivAll,0) |
---|
[230] | 1995 | cmd_CIV2=CIV2_CMD(flname,[],par_civ2,sparam);%creates the cmx file [fullfile(Rootbat,Filebat) '.civ2.cmx] |
---|
| 1996 | % if(isunix) |
---|
| 1997 | cmd=[cmd cmd_CIV2 '\n']; |
---|
| 1998 | % else |
---|
| 1999 | % flname=regexprep(flname,'\\','\\\\'); |
---|
| 2000 | % cmd=[cmd 'copy /Y "' flname '.civ2.cmx" "' flname '.cmx"\n' cmd_CIV2 '\n']; |
---|
| 2001 | % end |
---|
[2] | 2002 | else |
---|
[238] | 2003 | CivAllCmd=[CivAllCmd ' civ2 ']; |
---|
[220] | 2004 | str=CIV2_CMD_Unified(flname,'',par_civ2); |
---|
[112] | 2005 | fieldnames=fields(str); |
---|
[238] | 2006 | [CivAllxml,uid_civ2]=add(CivAllxml,1,'element','civ2'); |
---|
[2] | 2007 | for ilist=1:length(fieldnames) |
---|
| 2008 | val=eval(['str.' fieldnames{ilist}]); |
---|
| 2009 | if ischar(val) |
---|
[238] | 2010 | [CivAllxml,uid_t]=add(CivAllxml,uid_civ2,'element',fieldnames{ilist}); |
---|
| 2011 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
[2] | 2012 | end |
---|
[112] | 2013 | end |
---|
[2] | 2014 | end |
---|
[112] | 2015 | end |
---|
| 2016 | |
---|
| 2017 | % FIX2 |
---|
| 2018 | if box_test(5)==1 |
---|
| 2019 | test_mask=get(handles.get_mask_fix2,'Value'); |
---|
| 2020 | if test_mask==0 |
---|
| 2021 | maskname=''; %no mask used |
---|
[2] | 2022 | else |
---|
| 2023 | maskdispl=get(handles.mask_fix2,'String'); |
---|
[136] | 2024 | maskbase=[filecell.filebase '_' maskdispl]; % |
---|
[137] | 2025 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
[2] | 2026 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
| 2027 | maskname =name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
[112] | 2028 | end |
---|
[238] | 2029 | if isequal(CivAll,0) |
---|
[163] | 2030 | if isunix |
---|
[94] | 2031 | cmd_FIX=[sparam.FixBin ' -f ' filecell.nc.civ2{ifile,j} ' -fi1 ' num2str(flagindex2(1)) ... |
---|
[112] | 2032 | ' -fi2 ' num2str(flagindex2(2)) ' -fi3 ' num2str(flagindex2(3)) ... |
---|
| 2033 | ' -threshC ' num2str(thresh_vec2C) ' -threshV ' num2str(thresh_vel2) ' -maskName ' maskname]; |
---|
[163] | 2034 | else |
---|
| 2035 | cmd_FIX=['"' sparam.FixBin '" -f "' filecell.nc.civ2{ifile,j} '" -fi1 ' num2str(flagindex2(1)) ... |
---|
| 2036 | ' -fi2 ' num2str(flagindex2(2)) ' -fi3 ' num2str(flagindex2(3)) ... |
---|
| 2037 | ' -threshC ' num2str(thresh_vec2C) ' -threshV ' num2str(thresh_vel2) ' -maskName "' maskname '"']; |
---|
| 2038 | cmd_FIX=regexprep(cmd_FIX,'\\','\\\\'); |
---|
| 2039 | end |
---|
[112] | 2040 | cmd=[cmd cmd_FIX '\n']; |
---|
| 2041 | else |
---|
[2] | 2042 | fix2.inputFileName=filecell.nc.civ2{ifile,j} ; |
---|
| 2043 | fix2.fi1=num2str(flagindex2(1)); |
---|
| 2044 | fix2.fi2=num2str(flagindex2(2)); |
---|
| 2045 | fix2.fi3=num2str(flagindex2(3)); |
---|
| 2046 | fix2.threshC=num2str(thresh_vec2C); |
---|
[112] | 2047 | fix2.threshV=num2str(thresh_vel2); |
---|
[2] | 2048 | fieldnames=fields(fix2); |
---|
[238] | 2049 | [CivAllxml,uid_fix2]=add(CivAllxml,1,'element','fix2'); |
---|
[2] | 2050 | for ilist=1:length(fieldnames) |
---|
[112] | 2051 | val=eval(['fix2.' fieldnames{ilist}]); |
---|
| 2052 | if ischar(val) |
---|
[238] | 2053 | [CivAllxml,uid_t]=add(CivAllxml,uid_fix2,'element',fieldnames{ilist}); |
---|
| 2054 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
[112] | 2055 | end |
---|
| 2056 | end |
---|
[238] | 2057 | CivAllCmd=[CivAllCmd ' fix2 ']; |
---|
[112] | 2058 | end |
---|
| 2059 | end |
---|
| 2060 | |
---|
| 2061 | %PATCH2 |
---|
| 2062 | if box_test(6)==1 |
---|
[238] | 2063 | if isequal(CivAll,0) |
---|
[94] | 2064 | cmd_PATCH=PATCH_CMD(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,test_interp,sparam.PatchBin); |
---|
[90] | 2065 | cmd=[cmd cmd_PATCH '\n']; |
---|
[12] | 2066 | else |
---|
| 2067 | patch2.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
[220] | 2068 | patch2.nopt=subdomain_patch2; |
---|
| 2069 | patch2.maxdiff=thresh_patch2; |
---|
| 2070 | patch2.ro=rho_patch2; |
---|
[12] | 2071 | test_grid=get(handles.get_gridpatch2,'Value'); |
---|
| 2072 | if test_grid |
---|
| 2073 | patch2.gridflag='y'; |
---|
| 2074 | gridname=get(handles.grid_patch2,'String'); |
---|
| 2075 | if isequal(gridname(end-3:end),'grid') |
---|
[137] | 2076 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 2077 | if ~isnan(nbslice_grid) |
---|
[12] | 2078 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
[136] | 2079 | patch2.gridPatch=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
[12] | 2080 | if ~exist(patch2.gridPatch,'file') |
---|
[112] | 2081 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
[12] | 2082 | end |
---|
| 2083 | elseif exist(gridname,'file') |
---|
[112] | 2084 | patch2.gridPatch=gridname; |
---|
[12] | 2085 | else |
---|
| 2086 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
[2] | 2087 | end |
---|
| 2088 | end |
---|
[12] | 2089 | else |
---|
[112] | 2090 | patch2.gridPatch='none'; |
---|
| 2091 | patch2.gridflag='n'; |
---|
| 2092 | patch2.m=nx_patch2; |
---|
| 2093 | patch2.n=ny_patch2; |
---|
[2] | 2094 | end |
---|
[12] | 2095 | patch2.convectFlow='n'; |
---|
| 2096 | fieldnames=fields(patch2); |
---|
[238] | 2097 | [CivAllxml,uid_patch2]=add(CivAllxml,1,'element','patch2'); |
---|
[12] | 2098 | for ilist=1:length(fieldnames) |
---|
[112] | 2099 | val=eval(['patch2.' fieldnames{ilist}]); |
---|
| 2100 | if ischar(val) |
---|
[238] | 2101 | [CivAllxml,uid_t]=add(CivAllxml,uid_patch2,'element',fieldnames{ilist}); |
---|
| 2102 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
[112] | 2103 | end |
---|
| 2104 | end |
---|
[238] | 2105 | CivAllCmd=[CivAllCmd ' patch2 ']; |
---|
[112] | 2106 | end |
---|
[12] | 2107 | end |
---|
[238] | 2108 | if CivAll |
---|
| 2109 | save(CivAllxml,[flname '.xml']); |
---|
| 2110 | cmd=[cmd sparam.CivBin ' -f ' flname '.xml ' CivAllCmd ' >' flname '.log' '\n']; |
---|
[12] | 2111 | end |
---|
[112] | 2112 | % create the .bat file: |
---|
[159] | 2113 | [fid,message]=fopen(filename_bat,'w'); |
---|
| 2114 | if isequal(fid,-1) |
---|
| 2115 | msgbox_uvmat('ERROR', ['creation of .bat file: ' message]) |
---|
| 2116 | return |
---|
[12] | 2117 | end |
---|
[39] | 2118 | fprintf(fid,cmd); |
---|
| 2119 | fclose(fid); |
---|
[67] | 2120 | if batch |
---|
| 2121 | switch batch_mode |
---|
| 2122 | case 'sge' |
---|
| 2123 | pvalue=num2str((1-ind_answer)*500); |
---|
[177] | 2124 | display(['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]); |
---|
| 2125 | eval( ['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]); |
---|
[256] | 2126 | case 'oar' |
---|
| 2127 | % pvalue=num2str((1-ind_answer)*500); |
---|
| 2128 | % display(['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]); |
---|
| 2129 | eval( ['!chmod +x ' filename_bat]); |
---|
| 2130 | eval( ['!oarsub -l /nodes=1/cpu=1,walltime=00:10:00 ' filename_bat]); |
---|
[67] | 2131 | end |
---|
[238] | 2132 | elseif ~CivUvmat |
---|
[112] | 2133 | %% to lauch the jobs locally : |
---|
[12] | 2134 | if(isunix) |
---|
[135] | 2135 | cmd_str=['. ' filename_bat]; |
---|
[133] | 2136 | else %case of Windows |
---|
[163] | 2137 | cmd_str=['@call "' regexprep(filename_bat,'\\','\\\\') '"']; |
---|
[2] | 2138 | end |
---|
[135] | 2139 | super_cmd=[super_cmd cmd_str '\n']; |
---|
| 2140 | disp(cmd_str); |
---|
[225] | 2141 | else %run PIVlab if selected |
---|
[244] | 2142 | drawnow |
---|
[238] | 2143 | if box_test(1)==1 |
---|
| 2144 | Param.Civ1=par_civ1; |
---|
| 2145 | end |
---|
| 2146 | if box_test(2)==1 |
---|
| 2147 | fix1.WarnFlags=[]; |
---|
| 2148 | if get(handles.vec_Fmin2,'Value') |
---|
| 2149 | fix1.WarnFlags=[fix1.WarnFlags -2]; |
---|
| 2150 | end |
---|
| 2151 | if get(handles.vec_F3,'Value') |
---|
| 2152 | fix1.WarnFlags=[fix1.WarnFlags 3]; |
---|
| 2153 | end |
---|
| 2154 | fix1.LowerBoundCorr=thresh_vecC1; |
---|
| 2155 | if get(handles.inf_sup1,'Value') |
---|
| 2156 | fix1.UppperBoundVel=thresh_vel1; |
---|
| 2157 | else |
---|
| 2158 | fix1.LowerBoundVel=thresh_vel1; |
---|
[251] | 2159 | end |
---|
| 2160 | if get(handles.get_mask_fix1,'Value') |
---|
| 2161 | fix1.MaskName=maskname; |
---|
| 2162 | end |
---|
[238] | 2163 | Param.Fix1=fix1; |
---|
| 2164 | end |
---|
| 2165 | if box_test(3)==1 |
---|
| 2166 | Param.Patch1.Rho=rho_patch1; |
---|
| 2167 | Param.Patch1.Threshold=thresh_patch1; |
---|
| 2168 | Param.Patch1.SubDomain=subdomain_patch1; |
---|
| 2169 | end |
---|
[248] | 2170 | if box_test(4)==1 |
---|
| 2171 | Param.Civ2=par_civ2; |
---|
| 2172 | end |
---|
[252] | 2173 | if box_test(5)==1 |
---|
| 2174 | fix2.WarnFlags=[]; |
---|
| 2175 | if get(handles.vec_Fmin2_2,'Value') |
---|
| 2176 | fix2.WarnFlags=[fix2.WarnFlags -2]; |
---|
| 2177 | end |
---|
| 2178 | if get(handles.vec_F4,'Value') |
---|
| 2179 | fix2.WarnFlags=[fix2.WarnFlags 4]; |
---|
| 2180 | end |
---|
| 2181 | if get(handles.vec_F3_2,'Value') |
---|
| 2182 | fix2.WarnFlags=[fix2.WarnFlags 3]; |
---|
| 2183 | end |
---|
| 2184 | fix2.LowerBoundCorr=thresh_vec2C; |
---|
| 2185 | if get(handles.inf_sup2,'Value') |
---|
| 2186 | fix2.UppperBoundVel=thresh_vel2; |
---|
| 2187 | else |
---|
| 2188 | fix2.LowerBoundVel=thresh_vel2; |
---|
| 2189 | end |
---|
| 2190 | if get(handles.get_mask_fix2,'Value') |
---|
| 2191 | fix2.MaskName=maskname; |
---|
| 2192 | end |
---|
| 2193 | Param.Fix2=fix2; |
---|
| 2194 | end |
---|
[238] | 2195 | [Data,erromsg]=civ_uvmat(Param,filecell.nc.civ1{ifile,j}); |
---|
[225] | 2196 | if isempty(errormsg) |
---|
| 2197 | display([filecell.nc.civ1{ifile,j} ' written']) |
---|
| 2198 | else |
---|
| 2199 | msgbox_uvmat('ERROR',errormsg) |
---|
| 2200 | end |
---|
| 2201 | end |
---|
[112] | 2202 | end |
---|
[2] | 2203 | end |
---|
[134] | 2204 | |
---|
[238] | 2205 | if ~batch && ~CivUvmat |
---|
[159] | 2206 | [Rootbat,Filebat,extbat]=fileparts(filename_bat); |
---|
[229] | 2207 | filename_superbat=fullfile(Rootbat,'job_list.bat'); |
---|
[134] | 2208 | fid=fopen(filename_superbat,'w'); |
---|
| 2209 | fprintf(fid,super_cmd'); |
---|
| 2210 | fclose(fid); |
---|
[219] | 2211 | if(isunix) |
---|
| 2212 | system(['chmod +x ' filename_superbat]) |
---|
| 2213 | end |
---|
[192] | 2214 | system([filename_superbat ' &'])% execute main commmand |
---|
[133] | 2215 | end |
---|
[2] | 2216 | |
---|
[137] | 2217 | %% save interface state |
---|
[2] | 2218 | if isfield(filecell,'nc') |
---|
| 2219 | if isfield(filecell.nc,'civ2') |
---|
| 2220 | fileresu=filecell.nc.civ2{1,1}; |
---|
| 2221 | else |
---|
| 2222 | fileresu=filecell.nc.civ1{1,1}; |
---|
| 2223 | end |
---|
| 2224 | end |
---|
| 2225 | [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileresu); |
---|
| 2226 | namedoc=fullfile(RootPath,subdir,RootFile); |
---|
[112] | 2227 | detect=1; |
---|
[2] | 2228 | while detect==1 |
---|
| 2229 | namefigfull=[namedoc '.fig']; |
---|
| 2230 | hh=dir(namefigfull); |
---|
| 2231 | if ~isempty(hh) |
---|
| 2232 | detect=1; |
---|
| 2233 | namedoc=[namedoc '.0']; |
---|
| 2234 | else |
---|
| 2235 | detect=0; |
---|
| 2236 | end |
---|
| 2237 | end |
---|
| 2238 | saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) |
---|
| 2239 | |
---|
[227] | 2240 | %------------------------------------------------------------------------ |
---|
| 2241 | % --- determine the list of reference indices of processing file |
---|
| 2242 | function [ref_i,ref_j,errormsg]=find_ref_indices(handles) |
---|
| 2243 | %------------------------------------------------------------------------ |
---|
| 2244 | errormsg=''; %default error message |
---|
| 2245 | first_i=str2double(get(handles.first_i,'String'));%first index i |
---|
| 2246 | last_i=str2double(get(handles.last_i,'String'));%last index i |
---|
| 2247 | incr_i=str2double(get(handles.incr_i,'String'));% increment |
---|
| 2248 | if isequal(get(handles.first_j,'Visible'),'on') |
---|
| 2249 | first_j=str2double(get(handles.first_j,'String'));%first index j |
---|
| 2250 | last_j=str2double(get(handles.last_j,'String'));%last index j |
---|
| 2251 | incr_j=str2double(get(handles.incr_j,'String'));% increment |
---|
| 2252 | else |
---|
| 2253 | first_j=1; |
---|
| 2254 | last_j=1; |
---|
| 2255 | incr_j=1; |
---|
| 2256 | end |
---|
| 2257 | ref_i=first_i:incr_i:last_i;% list of i indices (reference values for each pair) |
---|
| 2258 | ref_j=first_j:incr_j:last_j;% list of j indices (reference values for each pair) |
---|
| 2259 | if isnan(first_i)||isnan(first_j) |
---|
| 2260 | errormsg='first field number not defined'; |
---|
| 2261 | elseif isnan(last_i)||isnan(last_j) |
---|
| 2262 | errormsg='last field number not defined'; |
---|
| 2263 | elseif isnan(incr_i)||isnan(incr_j) |
---|
| 2264 | errormsg='increment in field number not defined'; |
---|
| 2265 | elseif last_i < first_i || last_j < first_j |
---|
| 2266 | errormsg='last field number must be larger than the first one'; |
---|
| 2267 | end |
---|
[134] | 2268 | |
---|
[227] | 2269 | %------------------------------------------------------------------------ |
---|
| 2270 | % --- determine the list of filenames and indices needed for launch_job |
---|
[2] | 2271 | 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]=... |
---|
[227] | 2272 | set_civ_filenames(handles,ref_i,ref_j,box_test) |
---|
[12] | 2273 | %------------------------------------------------------------------------ |
---|
[85] | 2274 | filecell=[];%default |
---|
[136] | 2275 | |
---|
| 2276 | %% get the root names nomenclature and numbers |
---|
[71] | 2277 | filebase=get(handles.RootName,'String'); |
---|
[136] | 2278 | |
---|
| 2279 | if isempty(filebase)||isequal(filebase,'') |
---|
| 2280 | msgbox_uvmat('ERROR','no input files') |
---|
| 2281 | return |
---|
| 2282 | end |
---|
| 2283 | |
---|
[137] | 2284 | %filebase=regexprep(filebase,'\.fsnet','fsnet');% temporary fix for cluster Coriolis |
---|
[136] | 2285 | filecell.filebase=filebase; |
---|
| 2286 | |
---|
[2] | 2287 | browse=get(handles.browse_root,'UserData'); |
---|
| 2288 | compare_list=get(handles.compare,'String'); |
---|
| 2289 | val=get(handles.compare,'Value'); |
---|
| 2290 | compare=compare_list{val}; |
---|
| 2291 | if strcmp(compare,'displacement') |
---|
| 2292 | mode='displacement'; |
---|
| 2293 | else |
---|
| 2294 | mode_list=get(handles.mode,'String'); |
---|
| 2295 | mode_value=get(handles.mode,'Value'); |
---|
| 2296 | mode=mode_list{mode_value}; |
---|
| 2297 | end |
---|
[137] | 2298 | %time=get(handles.RootName,'UserData'); %get the set of times |
---|
[71] | 2299 | ext_ima=get(handles.ImaExt,'String'); |
---|
[2] | 2300 | nom_type_nc=browse.nom_type_nc; |
---|
[122] | 2301 | if isfield(browse,'nom_type_ima') |
---|
| 2302 | nom_type_ima2=browse.nom_type_ima; |
---|
| 2303 | end |
---|
| 2304 | if isempty(nom_type_ima2),nom_type_ima2='1';end; %default |
---|
| 2305 | if isempty(nom_type_nc),nom_type_nc='_i1-i2';end; %default |
---|
[2] | 2306 | [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
[227] | 2307 | find_pair_indices(handles,ref_i,ref_j,mode); |
---|
[2] | 2308 | %determine the new filebase for 'displacement' mode (comparison of two series) |
---|
| 2309 | filebase_B=filebase;% root name of the second field series for stereo |
---|
| 2310 | if strcmp(compare,'displacement') || strcmp(compare,'stereo PIV') |
---|
[127] | 2311 | % test_disp=1; |
---|
[2] | 2312 | nom_type_ima1=browse.nom_type_ima_1; %nomenclature type of the second file series |
---|
| 2313 | [Path2,Name2]=fileparts(filebase_B); |
---|
| 2314 | Path1=Path2; |
---|
[71] | 2315 | Name1=get(handles.RootName_1,'String');% root name of the first field series for stereo |
---|
[2] | 2316 | filebase_A=fullfile(Path1,Name1); |
---|
| 2317 | if length(Name1)>6 |
---|
| 2318 | Name1=Name1(end-5:end); |
---|
| 2319 | end |
---|
| 2320 | if length(Name2)>6 |
---|
| 2321 | Name2=Name2(end-5:end); |
---|
| 2322 | end |
---|
| 2323 | filebase_AB=fullfile(Path2,[Name2 '-' Name1]); |
---|
| 2324 | else |
---|
[127] | 2325 | % test_disp=0; |
---|
[2] | 2326 | filebase_A=filebase; |
---|
| 2327 | nom_type_ima1=nom_type_ima2; |
---|
| 2328 | filebase_AB=filebase; |
---|
| 2329 | end |
---|
| 2330 | if strcmp(compare,'displacement') |
---|
[112] | 2331 | filebase_ima1=filebase_A; |
---|
| 2332 | filebase_ima2=filebase_B; |
---|
| 2333 | filebase_nc=filebase_AB; %root name for the result of civ2 |
---|
[2] | 2334 | else |
---|
[112] | 2335 | filebase_ima1=filebase_B; |
---|
| 2336 | filebase_ima2=filebase_B; |
---|
| 2337 | filebase_nc=filebase_B; |
---|
| 2338 | end |
---|
[2] | 2339 | |
---|
| 2340 | %determine reference files for fix: |
---|
| 2341 | file_ref_fix1={};%default |
---|
| 2342 | file_ref_fix2={}; |
---|
| 2343 | nbfield=length(num1_civ1); |
---|
| 2344 | nbslice=length(num_a_civ1); |
---|
| 2345 | if box_test(2)==1% fix1 performed |
---|
| 2346 | ref=get(handles.ref_fix1,'UserData');%read data on the ref file stored by get_ref_fix1_Callback |
---|
| 2347 | if ~isempty(ref) |
---|
[137] | 2348 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 2349 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 2350 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 2351 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 2352 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 2353 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[127] | 2354 | num_i_ref=first_i:incr_i:last_i; |
---|
| 2355 | num_j_ref=first_j:incr_j:last_j; |
---|
[2] | 2356 | if isequal(mode,'displacement') |
---|
| 2357 | num_i1=num_i_ref; |
---|
| 2358 | num_i2=num_i_ref; |
---|
| 2359 | num_j1=num_j_ref; |
---|
| 2360 | num_j2=num_j_ref; |
---|
| 2361 | elseif isequal(mode,'pair j1-j2')% isequal(mode,'st_pair j1-j2') |
---|
| 2362 | num_i1=num_i_ref; |
---|
| 2363 | num_i2=num_i1; |
---|
| 2364 | num_j1=ref.num_a*ones(size(num_i_ref)); |
---|
| 2365 | num_j2=ref.num_b*ones(size(num_i_ref)); |
---|
| 2366 | elseif isequal(mode,'series(Di)') % isequal(mode,'st_series(Di)') |
---|
| 2367 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 2368 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 2369 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 2370 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 2371 | if isempty(ref.num_a) |
---|
| 2372 | ref.num_a=1; |
---|
| 2373 | end |
---|
| 2374 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 2375 | num_j2=num_j1; |
---|
| 2376 | elseif isequal(mode,'series(Dj)')%| isequal(mode,'st_series(Dj)') |
---|
| 2377 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 2378 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 2379 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 2380 | num_i2=num_i1; |
---|
| 2381 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 2382 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 2383 | end |
---|
| 2384 | for ifile=1:nbfield |
---|
| 2385 | for j=1:nbslice |
---|
| 2386 | 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);% |
---|
| 2387 | file_ref_fix1(ifile,j)={file_ref}; |
---|
| 2388 | if ~exist(file_ref,'file') |
---|
| 2389 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix1']) |
---|
[12] | 2390 | filecell=[]; |
---|
[2] | 2391 | return |
---|
| 2392 | end |
---|
| 2393 | end |
---|
| 2394 | end |
---|
| 2395 | end |
---|
| 2396 | end |
---|
| 2397 | |
---|
| 2398 | %determine reference files for fix2: |
---|
| 2399 | if box_test(5)==1% fix2 performed |
---|
| 2400 | ref=get(handles.ref_fix2,'UserData'); |
---|
| 2401 | if ~isempty(ref) |
---|
[127] | 2402 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 2403 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 2404 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 2405 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 2406 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 2407 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[229] | 2408 | num_i_ref=first_i:incr_i:last_i; |
---|
| 2409 | num_j_ref=first_j:incr_j:last_j; |
---|
[2] | 2410 | if isequal(mode,'displacement') |
---|
| 2411 | num_i1=num_i_ref; |
---|
| 2412 | num_i2=num_i_ref; |
---|
| 2413 | num_j1=num_j_ref; |
---|
| 2414 | num_j2=num_j_ref; |
---|
| 2415 | elseif isequal(mode,'pair j1-j2') |
---|
| 2416 | num_i1=num_i_ref; |
---|
| 2417 | num_i2=num_i1; |
---|
| 2418 | num_j1=ref.num_a; |
---|
| 2419 | num_j2=ref.num_b; |
---|
| 2420 | elseif isequal(mode,'series(Di)') |
---|
| 2421 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 2422 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 2423 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 2424 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 2425 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 2426 | num_j2=num_j1; |
---|
| 2427 | elseif isequal(mode,'series(Dj)') |
---|
| 2428 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 2429 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 2430 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 2431 | num_i2=num_i1; |
---|
| 2432 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 2433 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 2434 | end |
---|
| 2435 | for ifile=1:nbfield |
---|
| 2436 | for j=1:nbslice |
---|
| 2437 | 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);% |
---|
| 2438 | file_ref_fix2(ifile,j)={file_ref}; |
---|
| 2439 | if ~exist(file_ref,'file') |
---|
| 2440 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix2']) |
---|
[122] | 2441 | filecell={}; |
---|
[2] | 2442 | return |
---|
| 2443 | end |
---|
| 2444 | end |
---|
| 2445 | end |
---|
| 2446 | end |
---|
| 2447 | end |
---|
| 2448 | |
---|
| 2449 | %check dir |
---|
| 2450 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf output data |
---|
| 2451 | subdir_civ2=get(handles.subdir_civ2,'String'); |
---|
[174] | 2452 | if isequal(subdir_civ1,''),subdir_civ1='CIV'; end% put default subdir |
---|
[2] | 2453 | if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end% put default subdir |
---|
[135] | 2454 | currentdir=pwd;%store the current working directory |
---|
[2] | 2455 | [Path_ima,Name]=fileparts(filebase);%Path of the image files (.civ) |
---|
| 2456 | if ~exist(Path_ima,'dir') |
---|
[12] | 2457 | msgbox_uvmat('ERROR',['path to images ' Path_ima ' not found']) |
---|
[122] | 2458 | filecell={}; |
---|
[2] | 2459 | return |
---|
| 2460 | end |
---|
[127] | 2461 | [xx,message]=fileattrib(Path_ima); |
---|
[122] | 2462 | if ~isempty(message) && ~isequal(message.UserWrite,1) |
---|
[112] | 2463 | msgbox_uvmat('ERROR',['No writting access to ' Path_ima]) |
---|
[122] | 2464 | filecell={}; |
---|
[112] | 2465 | cd(currentdir); |
---|
| 2466 | return |
---|
[2] | 2467 | end |
---|
| 2468 | |
---|
| 2469 | %check the existence of the netcdf and image files involved |
---|
| 2470 | % %%%%%%%%%%%% case CIV1 activated %%%%%%%%%%%%% |
---|
| 2471 | if box_test(1)==1; |
---|
[112] | 2472 | detect=1; |
---|
[127] | 2473 | vers=0; |
---|
| 2474 | subdir_civ1_new=subdir_civ1; |
---|
[153] | 2475 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
[122] | 2476 | for ifile=1:nbfield |
---|
[112] | 2477 | for j=1:nbslice |
---|
[122] | 2478 | 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] | 2479 | detect=exist(filename,'file')==2; |
---|
| 2480 | if detect% if a netcdf file already exists |
---|
[137] | 2481 | indstr=regexp(subdir_civ1_new,'\D'); |
---|
| 2482 | if indstr(end)<length(subdir_civ1_new) %subdir_civ1 ends by a number |
---|
| 2483 | vers=str2double(subdir_civ1_new(indstr(end)+1:end))+1; |
---|
| 2484 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) num2str(vers)]; |
---|
[127] | 2485 | else |
---|
| 2486 | vers=vers+1; |
---|
[137] | 2487 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) '_' num2str(vers)]; |
---|
[127] | 2488 | end |
---|
[137] | 2489 | subdir_civ2=subdir_civ1_new; |
---|
[112] | 2490 | break |
---|
| 2491 | end |
---|
| 2492 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 2493 | end |
---|
| 2494 | if detect% if a netcdf file already exists |
---|
| 2495 | break |
---|
| 2496 | end |
---|
| 2497 | end |
---|
[134] | 2498 | |
---|
[112] | 2499 | %create the new subdir_civ1 |
---|
[127] | 2500 | if ~exist(fullfile(Path_ima,subdir_civ1_new),'dir') |
---|
[134] | 2501 | cd(Path_ima); |
---|
[128] | 2502 | [xx,msg1]=mkdir(subdir_civ1_new); |
---|
[134] | 2503 | |
---|
[128] | 2504 | if ~strcmp(msg1,'') |
---|
| 2505 | msgbox_uvmat('ERROR',['cannot create ' subdir_civ1_new ': ' msg1])%error message for directory creation |
---|
[122] | 2506 | filecell={}; |
---|
| 2507 | return |
---|
[163] | 2508 | elseif isunix |
---|
[128] | 2509 | [xx,msg2] = fileattrib(subdir_civ1_new,'+w','g'); %yield writing access (+w) to user group (g) |
---|
| 2510 | if ~strcmp(msg2,'') |
---|
[134] | 2511 | msgbox_uvmat('ERROR',['pb of permission for ' subdir_civ1_new ': ' msg2])%error message for directory creation |
---|
[128] | 2512 | filecell={}; |
---|
| 2513 | return |
---|
| 2514 | end |
---|
[112] | 2515 | end |
---|
[134] | 2516 | cd(currentdir); |
---|
[112] | 2517 | end |
---|
| 2518 | if strcmp(compare,'stereo PIV')&&(strcmp(mode,'pair j1-j2')||strcmp(mode,'series(Dj)')||strcmp(mode,'series(Di)'))%check second nc series |
---|
| 2519 | for ifile=1:nbfield |
---|
| 2520 | for j=1:nbslice |
---|
[122] | 2521 | 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] | 2522 | detect=exist(filename,'file')==2; |
---|
[2] | 2523 | if detect% if a netcdf file already exists |
---|
[137] | 2524 | indstr=regexp(subdir_civ1_new,'\D'); |
---|
| 2525 | if indstr(end)<length(subdir_civ1_new) %subdir_civ1 ends by a number |
---|
| 2526 | vers=str2double(subdir_civ1_new(indstr(end)+1:end))+1; |
---|
| 2527 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) num2str(vers)]; |
---|
[127] | 2528 | else |
---|
| 2529 | vers=vers+1; |
---|
[137] | 2530 | subdir_civ1_new=[subdir_civ1_new '_' num2str(vers)]; |
---|
[127] | 2531 | end |
---|
| 2532 | subdir_civ2=subdir_civ1; |
---|
| 2533 | break |
---|
[2] | 2534 | end |
---|
[112] | 2535 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
| 2536 | end |
---|
| 2537 | if detect% if a netcdf file already exists |
---|
| 2538 | break |
---|
| 2539 | end |
---|
| 2540 | end |
---|
| 2541 | %create the new subdir_civ1 |
---|
[134] | 2542 | if exist(fullfile(Path_ima,subdir_civ1_new),'dir') |
---|
| 2543 | cd(Path_ima); |
---|
[128] | 2544 | [xx,msg1]=mkdir(subdir_civ1_new); |
---|
[134] | 2545 | cd(currentdir); |
---|
[252] | 2546 | if ~strcmp(msg1,'') |
---|
[128] | 2547 | msgbox_uvmat('ERROR',['cannot create ' subdir_civ1_new ': ' msg1]) |
---|
[122] | 2548 | cd(currentdir) |
---|
| 2549 | filecell={}; |
---|
| 2550 | return |
---|
[128] | 2551 | else |
---|
| 2552 | [xx,msg2] = fileattrib(subdir_civ1_new,'+w','g'); %yield writing access (+w) to user group (g) |
---|
| 2553 | if ~strcmp(msg2,'') |
---|
| 2554 | msgbox_uvmat('ERROR',['pb of permission for ' subdir_civ1_new ': ' msg2])%error message for directory creation |
---|
| 2555 | cd(currentdir) |
---|
| 2556 | filecell={}; |
---|
| 2557 | return |
---|
| 2558 | end |
---|
[112] | 2559 | end |
---|
| 2560 | end |
---|
| 2561 | end |
---|
| 2562 | end |
---|
[127] | 2563 | subdir_civ1=subdir_civ1_new; |
---|
[2] | 2564 | % get image names |
---|
| 2565 | for ifile=1:nbfield |
---|
[112] | 2566 | for j=1:nbslice |
---|
[2] | 2567 | filename=name_generator(filebase_ima1, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
| 2568 | idetect(j)=exist(filename,'file')==2; |
---|
| 2569 | filecell.ima1.civ1(ifile,j)={filename}; %first image |
---|
| 2570 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
| 2571 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 2572 | filecell.ima2.civ1(ifile,j)={filename};%second image |
---|
[112] | 2573 | end |
---|
| 2574 | [idetectmin,indexj]=min(idetect); |
---|
| 2575 | if idetectmin==0, |
---|
| 2576 | msgbox_uvmat('ERROR',[filecell.ima1.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2577 | filecell={}; |
---|
| 2578 | cd(currentdir) |
---|
[112] | 2579 | return |
---|
| 2580 | end |
---|
| 2581 | [idetectmin,indexj]=min(idetect_1); |
---|
| 2582 | if idetectmin==0, |
---|
| 2583 | msgbox_uvmat('ERROR',[filecell.ima2.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2584 | filecell={}; |
---|
[112] | 2585 | cd(currentdir) |
---|
| 2586 | return |
---|
| 2587 | end |
---|
| 2588 | end |
---|
| 2589 | if strcmp(compare,'stereo PIV') && (strcmp(mode,'pair j1-j2') || strcmp(mode,'series(Dj)') || strcmp(mode,'series(Di)')) |
---|
| 2590 | for ifile=1:nbfield |
---|
| 2591 | for j=1:nbslice |
---|
| 2592 | filename=name_generator(filebase_A, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
| 2593 | idetect(j)=exist(filename,'file')==2; |
---|
| 2594 | filecell.imaA1.civ1(ifile,j)={filename} ;%first image |
---|
| 2595 | filename=name_generator(filebase_A, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
| 2596 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 2597 | filecell.imaA2.civ1(ifile,j)={filename};%second image |
---|
| 2598 | end |
---|
[2] | 2599 | [idetectmin,indexj]=min(idetect); |
---|
[112] | 2600 | if idetectmin==0, |
---|
| 2601 | msgbox_uvmat('ERROR',[filecell.imaA1.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2602 | filecell={}; |
---|
[112] | 2603 | cd(currentdir) |
---|
[2] | 2604 | return |
---|
[112] | 2605 | end |
---|
[2] | 2606 | [idetectmin,indexj]=min(idetect_1); |
---|
[112] | 2607 | if idetectmin==0, |
---|
| 2608 | msgbox_uvmat('ERROR',[filecell.imaA2.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2609 | filecell={}; |
---|
[2] | 2610 | cd(currentdir) |
---|
| 2611 | return |
---|
[112] | 2612 | end |
---|
| 2613 | end |
---|
[2] | 2614 | end |
---|
[112] | 2615 | |
---|
| 2616 | %%%%%%%%%%%%% fix1 or patch1 activated but no civ1 %%%%%%%%%%%%% |
---|
| 2617 | elseif (box_test(2)==1 || box_test(3)==1); |
---|
[2] | 2618 | for ifile=1:nbfield |
---|
| 2619 | for j=1:nbslice |
---|
| 2620 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
[112] | 2621 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 2622 | detect=exist(filename,'file')==2; |
---|
[122] | 2623 | if detect==0 |
---|
| 2624 | msgbox_uvmat('ERROR',[filename ' not found']) |
---|
| 2625 | filecell={}; |
---|
| 2626 | cd(currentdir) |
---|
| 2627 | return |
---|
| 2628 | end |
---|
[2] | 2629 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 2630 | end |
---|
| 2631 | end |
---|
| 2632 | if strcmp(compare,'stereo PIV') |
---|
[112] | 2633 | for ifile=1:nbfield |
---|
| 2634 | for j=1:nbslice |
---|
| 2635 | 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);% |
---|
| 2636 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
| 2637 | if ~exist(filename,'file') |
---|
| 2638 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
| 2639 | set(handles.RUN, 'Enable','On') |
---|
| 2640 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
[122] | 2641 | filecell={}; |
---|
[112] | 2642 | cd(currentdir) |
---|
| 2643 | return |
---|
[2] | 2644 | end |
---|
| 2645 | end |
---|
[112] | 2646 | end |
---|
[2] | 2647 | end |
---|
| 2648 | end |
---|
| 2649 | |
---|
| 2650 | %%%%%%%%%%%%% if civ2 performed with pairs different than civ1 %%%%%%%%%%%%% |
---|
| 2651 | testdiff=0; |
---|
| 2652 | if (box_test(4)==1)&&... |
---|
[127] | 2653 | ((get(handles.list_pair_civ1,'Value')~=get(handles.list_pair_civ2,'Value'))||~strcmp(subdir_civ2,subdir_civ1)) |
---|
[2] | 2654 | testdiff=1; |
---|
[112] | 2655 | detect=1; |
---|
[127] | 2656 | vers=0; |
---|
| 2657 | subdir_civ2_new=subdir_civ2; |
---|
[2] | 2658 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
[112] | 2659 | for ifile=1:nbfield |
---|
| 2660 | for j=1:nbslice |
---|
[127] | 2661 | 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] | 2662 | detect=exist(filename,'file')==2; |
---|
| 2663 | if detect% if a netcdf file already exists |
---|
[127] | 2664 | indstr=regexp(subdir_civ2,'\D'); |
---|
| 2665 | if indstr(end)<length(subdir_civ2) %subdir_civ1 ends by a number |
---|
| 2666 | vers=str2double(subdir_civ2(indstr(end)+1:end))+1; |
---|
| 2667 | subdir_civ2_new=[subdir_civ2(1:indstr(end)) num2str(vers)]; |
---|
| 2668 | else |
---|
| 2669 | vers=vers+1; |
---|
| 2670 | subdir_civ2_new=[subdir_civ1 '_' num2str(vers)]; |
---|
| 2671 | end |
---|
[112] | 2672 | break |
---|
| 2673 | end |
---|
| 2674 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 2675 | end |
---|
| 2676 | if detect% if a netcdf file already exists |
---|
| 2677 | break |
---|
| 2678 | end |
---|
| 2679 | end |
---|
[128] | 2680 | %create the new subdir_civ2_new |
---|
| 2681 | if ~exist(fullfile(Path_ima,subdir_civ2_new),'dir') |
---|
[174] | 2682 | [xx,m2]=mkdir(fullfile(Path_ima,subdir_civ2_new)); |
---|
[128] | 2683 | [xx,msg2] = fileattrib(subdir_civ2_new,'+w','g'); %yield writing access (+w) to user group (g) |
---|
[112] | 2684 | if ~isequal(m2,'') |
---|
[128] | 2685 | msgbox_uvmat('ERROR',['cannot create ' subdir_civ2_new ': ' m2]) |
---|
[122] | 2686 | filecell={}; |
---|
| 2687 | cd(currentdir) |
---|
| 2688 | return |
---|
[112] | 2689 | end |
---|
| 2690 | end |
---|
| 2691 | if strcmp(compare,'stereo PIV')%check second nc series |
---|
| 2692 | for ifile=1:nbfield |
---|
| 2693 | for j=1:nbslice |
---|
| 2694 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
[122] | 2695 | nom_type_nc,1,num2_civ2(ifile),num_b_civ1(j),subdir_civ2_new);% |
---|
[112] | 2696 | detect=exist(filename,'file')==2; |
---|
[2] | 2697 | if detect% if a netcdf file already exists |
---|
[127] | 2698 | indstr=regexp(subdir_civ2,'\D'); |
---|
| 2699 | if indstr(end)<length(subdir_civ2) %subdir_civ1 ends by a number |
---|
| 2700 | vers=str2double(subdir_civ2(indstr(end)+1:end))+1; |
---|
| 2701 | subdir_civ2_new=[subdir_civ2(1:indstr(end)) num2str(vers)]; |
---|
| 2702 | else |
---|
| 2703 | vers=vers+1; |
---|
| 2704 | subdir_civ2_new=[subdir_civ1 '_' num2str(vers)]; |
---|
| 2705 | end |
---|
[112] | 2706 | break |
---|
[2] | 2707 | end |
---|
[112] | 2708 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 2709 | end |
---|
| 2710 | if detect% if a netcdf file already exists |
---|
| 2711 | break |
---|
| 2712 | end |
---|
| 2713 | end |
---|
[122] | 2714 | subdir_civ2=subdir_civ2_new; |
---|
[112] | 2715 | %create the new subdir_civ1 |
---|
[127] | 2716 | if ~exist(fullfile(Path_ima,subdir_civ2_new),'dir') |
---|
| 2717 | [xx,m2]=mkdir(subdir_civ2_new); |
---|
[128] | 2718 | [xx,msg2] = fileattrib(subdir_civ2_new,'+w','g'); %yield writing access (+w) to user group (g) |
---|
[112] | 2719 | if ~isequal(m2,'') |
---|
[128] | 2720 | msgbox_uvmat('ERROR', ['cannot create ' subdir_civ2_new ': ' m2])%error message for directory creation |
---|
[122] | 2721 | cd(currentdir) |
---|
| 2722 | filecell={}; |
---|
| 2723 | return |
---|
[112] | 2724 | end |
---|
| 2725 | end |
---|
| 2726 | end |
---|
| 2727 | end |
---|
[127] | 2728 | subdir_civ2=subdir_civ2_new; |
---|
[2] | 2729 | end |
---|
| 2730 | cd(currentdir);%come back to the current working directory |
---|
| 2731 | |
---|
| 2732 | %%%%%%%%%%%%% if civ2 results are obtained or used %%%%%%%%%%%%% |
---|
| 2733 | if box_test(4)==1 || box_test(5)==1 || box_test(6)==1 %civ2 |
---|
| 2734 | %check source netcdf file of civ1 estimates |
---|
| 2735 | if box_test(1)==0; %no civ1 performed |
---|
| 2736 | for ifile=1:nbfield |
---|
| 2737 | for j=1:nbslice |
---|
| 2738 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 2739 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 2740 | filecell.nc.civ1(ifile,j)={filename};% name of the civ1 file |
---|
| 2741 | if ~exist(filename,'file') |
---|
| 2742 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
[122] | 2743 | filecell={}; |
---|
[2] | 2744 | return |
---|
| 2745 | end |
---|
| 2746 | if ~testdiff % civ2 or patch2 are written in the same file as civ1 |
---|
| 2747 | if box_test(4)==0 ; %check the existence of civ2 if it is not calculated |
---|
[248] | 2748 | Data=nc2struct(filename,'ListGlobalAttribute','CivStage','civ2'); |
---|
| 2749 | if ~isempty(Data.CivStage) && Data.CivStage<4 %test for civ files |
---|
[2] | 2750 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
[12] | 2751 | filecell=[]; |
---|
[2] | 2752 | return |
---|
[248] | 2753 | elseif isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
| 2754 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
| 2755 | filecell=[]; |
---|
| 2756 | return |
---|
[112] | 2757 | end |
---|
[2] | 2758 | elseif box_test(3)==0; %check the existence of patch if it is not calculated |
---|
[248] | 2759 | Data=nc2struct(filename,'ListGlobalAttribute','CivStage','patch') |
---|
| 2760 | if ~isempty(Data.CivStage) |
---|
| 2761 | if Data.CivStage<3 %test for civ files |
---|
| 2762 | msgbox_uvmat('ERROR',['no patch data in ' filename]) |
---|
| 2763 | filecell=[]; |
---|
| 2764 | return |
---|
| 2765 | end |
---|
| 2766 | elseif isempty(Data.patch)||isequal(Data.patch,0) |
---|
[2] | 2767 | msgbox_uvmat('ERROR',['no patch data in ' filename]) |
---|
[12] | 2768 | filecell=[]; |
---|
[2] | 2769 | return |
---|
| 2770 | end |
---|
[112] | 2771 | end |
---|
[2] | 2772 | end |
---|
| 2773 | end |
---|
| 2774 | end |
---|
| 2775 | if strcmp(compare,'stereo PIV') |
---|
| 2776 | for ifile=1:nbfield |
---|
| 2777 | for j=1:nbslice |
---|
| 2778 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 2779 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 2780 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 2781 | if ~exist(filename,'file') |
---|
| 2782 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
| 2783 | set(handles.RUN, 'Enable','On') |
---|
| 2784 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 2785 | return |
---|
| 2786 | end |
---|
| 2787 | end |
---|
| 2788 | end |
---|
| 2789 | end |
---|
| 2790 | end |
---|
[112] | 2791 | |
---|
| 2792 | detect=1; |
---|
| 2793 | % while detect==1%creates a new subdir if the netcdf files already contain civ2 data |
---|
| 2794 | for ifile=1:nbfield |
---|
| 2795 | for j=1:nbslice |
---|
| 2796 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
[2] | 2797 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2); |
---|
[112] | 2798 | detect=exist(filename,'file')==2; |
---|
| 2799 | filecell.nc.civ2(ifile,j)={filename}; |
---|
[2] | 2800 | end |
---|
[112] | 2801 | end |
---|
[2] | 2802 | %get first image names for civ2 |
---|
| 2803 | if box_test(1)==1 & isequal(num1_civ1,num1_civ2) & isequal(num_a_civ1,num_a_civ2) |
---|
| 2804 | filecell.ima1.civ2=filecell.ima1.civ1; |
---|
| 2805 | elseif box_test(4)==1 |
---|
| 2806 | for ifile=1:nbfield |
---|
| 2807 | for j=1:nbslice |
---|
| 2808 | filename=name_generator(filebase_ima1, num1_civ2(ifile),num_a_civ2(j),ext_ima,nom_type_ima1); |
---|
| 2809 | idetect_2(j)=exist(filename,'file')==2; |
---|
| 2810 | filecell.ima1.civ2(ifile,j)={filename};%first image |
---|
| 2811 | end |
---|
[112] | 2812 | [idetectmin,indexj]=min(idetect_2); |
---|
[2] | 2813 | if idetectmin==0, |
---|
[112] | 2814 | msgbox_uvmat('ERROR',['input image ' filecell.ima1.civ2{ifile,indexj} ' not found']) |
---|
| 2815 | filecell=[]; |
---|
| 2816 | return |
---|
[2] | 2817 | end |
---|
| 2818 | end |
---|
| 2819 | end |
---|
| 2820 | |
---|
| 2821 | %get second image names for civ2 |
---|
| 2822 | if box_test(1)==1 & isequal(num2_civ1,num2_civ2) & isequal(num_b_civ1,num_b_civ2) |
---|
| 2823 | filecell.ima2.civ2=filecell.ima2.civ1; |
---|
| 2824 | elseif box_test(4)==1 |
---|
| 2825 | for ifile=1:nbfield |
---|
| 2826 | for j=1:nbslice |
---|
| 2827 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),ext_ima,nom_type_ima2); |
---|
| 2828 | idetect_3(j)=exist(filename,'file')==2; |
---|
| 2829 | filecell.ima2.civ2(ifile,j)={filename};%first image |
---|
| 2830 | end |
---|
[112] | 2831 | [idetectmin,indexj]=min(idetect_3); |
---|
[2] | 2832 | if idetectmin==0, |
---|
[112] | 2833 | msgbox_uvmat('ERROR',['input image ' filecell.ima2.civ2{ifile,indexj} ' not found']) |
---|
| 2834 | filecell=[]; |
---|
| 2835 | return |
---|
[2] | 2836 | end |
---|
| 2837 | end |
---|
| 2838 | end |
---|
| 2839 | end |
---|
| 2840 | if (box_test(5)==1 || box_test(6)==1 ) && box_test(4)==0 % need to read an existing netcdf civ2 file |
---|
| 2841 | if ~testdiff |
---|
| 2842 | filecell.nc.civ2=filecell.nc.civ1;% file already checked |
---|
[112] | 2843 | else % check the civ2 files |
---|
[2] | 2844 | for ifile=1:nbfield |
---|
| 2845 | for j=1:nbslice |
---|
| 2846 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
[112] | 2847 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
[2] | 2848 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 2849 | if ~exist(filename,'file') |
---|
| 2850 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
[12] | 2851 | filecell=[]; |
---|
[2] | 2852 | return |
---|
| 2853 | else |
---|
[248] | 2854 | Data=nc2struct(filename,'ListGlobalAttribute','CivStage','civ2'); |
---|
| 2855 | if ~isempty(Data.CivStage) && Data.CivStage<4 %test for civ files |
---|
| 2856 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
| 2857 | filecell=[]; |
---|
| 2858 | return |
---|
| 2859 | elseif isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
[2] | 2860 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
[12] | 2861 | filecell=[]; |
---|
[2] | 2862 | return |
---|
| 2863 | end |
---|
| 2864 | end |
---|
| 2865 | end |
---|
| 2866 | end |
---|
| 2867 | end |
---|
| 2868 | end |
---|
| 2869 | |
---|
| 2870 | %%%%%%%%%%%%% if stereo fields are calculated by PATCH %%%%%%%%%%%%% |
---|
| 2871 | if strcmp(compare,'stereo PIV') |
---|
[127] | 2872 | if box_test(3)==1 && isequal(get(handles.test_stereo1,'Value'),1) |
---|
[2] | 2873 | for ifile=1:nbfield |
---|
| 2874 | for j=1:nbslice |
---|
| 2875 | filename=name_generator(filebase_AB,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 2876 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 2877 | filecell.st(ifile,j)={filename}; |
---|
| 2878 | end |
---|
| 2879 | end |
---|
| 2880 | end |
---|
[127] | 2881 | if box_test(6)==1 && isequal(get(handles.test_stereo2,'Value'),1) |
---|
[2] | 2882 | for ifile=1:nbfield |
---|
| 2883 | for j=1:nbslice |
---|
| 2884 | filename=name_generator(filebase_AB,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 2885 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 2886 | filecell.st(ifile,j)={filename}; |
---|
| 2887 | end |
---|
| 2888 | end |
---|
[112] | 2889 | end |
---|
[2] | 2890 | end |
---|
| 2891 | set(handles.subdir_civ1,'String',subdir_civ1);%update the edit box |
---|
| 2892 | set(handles.subdir_civ2,'String',subdir_civ2);%update the edit box |
---|
| 2893 | browse.nom_type_nc=nom_type_nc; |
---|
| 2894 | set(handles.browse_root,'UserData',browse); %update the nomenclature type for uvmat |
---|
| 2895 | |
---|
| 2896 | |
---|
| 2897 | %COPY IMAGES TO THE FORMAT .png IF NEEDED |
---|
[45] | 2898 | if isequal(nom_type_ima1,'*')%case of movie files |
---|
| 2899 | nom_type_imanew1='_i'; |
---|
[2] | 2900 | else |
---|
| 2901 | nom_type_imanew1=nom_type_ima1; |
---|
| 2902 | end |
---|
[45] | 2903 | if isequal(nom_type_ima2,'*')%case of movie files |
---|
| 2904 | nom_type_imanew2='_i'; |
---|
[2] | 2905 | else |
---|
| 2906 | nom_type_imanew2=nom_type_ima2; |
---|
| 2907 | end |
---|
| 2908 | if ~isequal(ext_ima,'.png') |
---|
[45] | 2909 | %%type of image file |
---|
| 2910 | type_ima1='none';%default |
---|
| 2911 | movieobject1=[];%default |
---|
[133] | 2912 | if strcmpi(ext_ima,'.avi') |
---|
[45] | 2913 | hhh=which('mmreader'); |
---|
| 2914 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
---|
| 2915 | type_ima1='movie'; |
---|
| 2916 | movieobject1=mmreader([filebase_ima2 ext_ima]); |
---|
| 2917 | else |
---|
| 2918 | type_ima1='avi'; |
---|
| 2919 | end |
---|
[133] | 2920 | elseif ischar(ext_ima) && ~isempty(ext_ima(2:end)) |
---|
[112] | 2921 | form=imformats(ext_ima(2:end)); |
---|
| 2922 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 2923 | if isequal(nom_type_ima1,'*'); |
---|
| 2924 | type_ima1='multimage';%image series in a single image file |
---|
| 2925 | else |
---|
| 2926 | type_ima1='image'; |
---|
| 2927 | end |
---|
| 2928 | end |
---|
[45] | 2929 | end |
---|
| 2930 | type_ima2='none';%default |
---|
| 2931 | movieobject2=[]; |
---|
[133] | 2932 | if strcmpi(ext_ima,'.avi') |
---|
[45] | 2933 | hhh=which('mmreader'); |
---|
| 2934 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
---|
| 2935 | type_ima2='movie'; |
---|
| 2936 | movieobject2=mmreader([filebase_ima2 ext_ima]); |
---|
| 2937 | else |
---|
| 2938 | type_ima2='avi'; |
---|
| 2939 | end |
---|
[133] | 2940 | elseif ischar(ext_ima) && ~isempty(ext_ima(2:end)) |
---|
[112] | 2941 | form=imformats(ext_ima(2:end)); |
---|
| 2942 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 2943 | if isequal(nom_type_ima1,'*'); |
---|
| 2944 | type_ima2='multimage';%image series in a single image file |
---|
| 2945 | else |
---|
| 2946 | type_ima2='image'; |
---|
| 2947 | end |
---|
| 2948 | end |
---|
[45] | 2949 | end |
---|
[71] | 2950 | %npxy=get(handles.ImaExt,'UserData'); |
---|
[112] | 2951 | % % if numel(npxy)<2 |
---|
| 2952 | % |
---|
| 2953 | % filename=name_generator(filebase_ima1,num1_civ1(1),num_a_civ1(1),ImaExt,nom_type_ima1); |
---|
| 2954 | % A=imread(filename); |
---|
| 2955 | % npxy=size(A); |
---|
| 2956 | % % end |
---|
| 2957 | % npy=npxy(1); |
---|
| 2958 | % npx=npxy(2); |
---|
[2] | 2959 | if box_test(1)==1 %if civ1 is performed |
---|
[224] | 2960 | h = waitbar(0,'copy images to the .png format for civ1');% display a wait bar |
---|
[112] | 2961 | for ifile=1:nbfield |
---|
[2] | 2962 | waitbar(ifile/nbfield); |
---|
| 2963 | for j=1:nbslice |
---|
[112] | 2964 | filename=name_generator(filebase_ima1,num1_civ1(ifile),num_a_civ1(j),'.png',nom_type_imanew1); |
---|
| 2965 | if ~exist(filename,'file') |
---|
| 2966 | A=read_image(filecell.ima1.civ1{ifile,j},type_ima1,num1_civ1(ifile),movieobject1); |
---|
| 2967 | imwrite(A,filename,'BitDepth',16); |
---|
| 2968 | end |
---|
| 2969 | filecell.ima1.civ1(ifile,j)={filename}; |
---|
| 2970 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),'.png',nom_type_imanew2); |
---|
| 2971 | if ~exist(filename,'file') |
---|
| 2972 | A=read_image(filecell.ima2.civ1{ifile,j},type_ima2,num2_civ1(ifile),movieobject2); |
---|
| 2973 | imwrite(A,filename,'BitDepth',16); |
---|
| 2974 | end |
---|
| 2975 | filecell.ima2.civ1(ifile,j)={filename}; |
---|
[2] | 2976 | end |
---|
| 2977 | end |
---|
| 2978 | close(h) |
---|
| 2979 | end |
---|
| 2980 | if box_test(4)==1 %if civ2 is performed |
---|
[229] | 2981 | h = waitbar(0,'copy images to the .png format for civ2');% display a wait bar |
---|
[2] | 2982 | for ifile=1:nbfield |
---|
| 2983 | waitbar(ifile/nbfield); |
---|
| 2984 | for j=1:nbslice |
---|
[112] | 2985 | filename=name_generator(filebase_ima1,num1_civ2(ifile),num_a_civ2(j),'.png',nom_type_imanew1); |
---|
| 2986 | if ~exist(filename,'file') |
---|
| 2987 | A=read_image(cell2mat(filecell.ima1.civ2(ifile,j)),type_ima2,num1_civ2(ifile)); |
---|
| 2988 | imwrite(A,filename,'BitDepth',16); |
---|
| 2989 | end |
---|
| 2990 | filecell.ima1.civ2(ifile,j)={filename}; |
---|
| 2991 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),'.png',nom_type_imanew2); |
---|
| 2992 | if ~exist(filename,'file') |
---|
| 2993 | A=read_image(cell2mat(filecell.ima2.civ2(ifile,j)),type_ima2,num2_civ2(ifile)); |
---|
| 2994 | imwrite(A,filename,'BitDepth',16); |
---|
| 2995 | end |
---|
| 2996 | filecell.ima2.civ2(ifile,j)={filename}; |
---|
[2] | 2997 | end |
---|
| 2998 | end |
---|
| 2999 | close(h); |
---|
| 3000 | end |
---|
| 3001 | end |
---|
| 3002 | |
---|
[12] | 3003 | %------------------------------------------------------------------------ |
---|
[227] | 3004 | % --- determine the list of index pairs of processing file |
---|
| 3005 | function [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
| 3006 | find_pair_indices(handles,ref_i,ref_j,mode) |
---|
| 3007 | %------------------------------------------------------------------------ |
---|
| 3008 | |
---|
| 3009 | list_civ1=get(handles.list_pair_civ1,'String'); |
---|
| 3010 | index_civ1=get(handles.list_pair_civ1,'Value'); |
---|
| 3011 | str_civ1=list_civ1{index_civ1};%string defining the image pairs for civ1 |
---|
| 3012 | if isempty(str_civ1)||isequal(str_civ1,'') |
---|
| 3013 | msgbox_uvmat('ERROR','no image pair selected for civ1') |
---|
| 3014 | return |
---|
| 3015 | end |
---|
| 3016 | list_civ2=get(handles.list_pair_civ2,'String'); |
---|
| 3017 | index_civ2=get(handles.list_pair_civ2,'Value'); |
---|
| 3018 | if index_civ2>length(list_civ2) |
---|
| 3019 | list_civ2=list_civ1; |
---|
| 3020 | index_civ2=index_civ1; |
---|
| 3021 | end |
---|
| 3022 | str_civ2=list_civ2{index_civ2};%string defining the image pairs for civ2 |
---|
| 3023 | |
---|
| 3024 | if isequal (mode,'series(Di)') |
---|
| 3025 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 3026 | num1_civ1=ref_i-floor(index_civ1/2)*ones(size(ref_i));% set of first image numbers |
---|
| 3027 | num2_civ1=ref_i+ceil(index_civ1/2)*ones(size(ref_i)); |
---|
| 3028 | num_a_civ1=ref_j; |
---|
| 3029 | num_b_civ1=ref_j; |
---|
[229] | 3030 | num1_civ2=ref_i-floor(index_civ2/2)*ones(size(ref_i)); |
---|
[227] | 3031 | num2_civ2=ref_i+ceil(index_civ2/2)*ones(size(ref_i)); |
---|
| 3032 | num_a_civ2=ref_j; |
---|
| 3033 | num_b_civ2=ref_j; |
---|
| 3034 | |
---|
| 3035 | % adjust the first and last field number |
---|
| 3036 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 3037 | if isnan(lastfield) |
---|
| 3038 | indsel=find((num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
| 3039 | else |
---|
| 3040 | indsel=find((num2_civ1 <= lastfield)&(num2_civ2 <= lastfield)&(num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
| 3041 | end |
---|
| 3042 | if length(indsel)>=1 |
---|
| 3043 | firstind=indsel(1); |
---|
| 3044 | lastind=indsel(end); |
---|
| 3045 | set(handles.first_i,'String',num2str(ref_i(firstind)))%update the display of first and last fields |
---|
| 3046 | set(handles.last_i,'String',num2str(ref_i(lastind))) |
---|
| 3047 | ref_i=ref_i(indsel); |
---|
| 3048 | num1_civ1=num1_civ1(indsel); |
---|
| 3049 | num1_civ2=num1_civ2(indsel); |
---|
| 3050 | num2_civ1=num2_civ1(indsel); |
---|
| 3051 | num2_civ2=num2_civ2(indsel); |
---|
| 3052 | end |
---|
| 3053 | elseif isequal (mode,'series(Dj)') |
---|
| 3054 | lastfield_j=str2double(get(handles.nb_field2,'String')); |
---|
| 3055 | num1_civ1=ref_i;% set of first image numbers |
---|
| 3056 | num2_civ1=ref_i; |
---|
| 3057 | num_a_civ1=ref_j-floor(index_civ1/2)*ones(size(ref_j)); |
---|
| 3058 | num_b_civ1=ref_j+ceil(index_civ1/2)*ones(size(ref_j)); |
---|
| 3059 | num1_civ2=ref_i; |
---|
| 3060 | num2_civ2=ref_i; |
---|
| 3061 | num_a_civ2=ref_j-floor(index_civ2/2)*ones(size(ref_j)); |
---|
| 3062 | num_b_civ2=ref_j+ceil(index_civ2/2)*ones(size(ref_j)); |
---|
| 3063 | % adjust the first and last field number |
---|
| 3064 | if isnan(lastfield_j) |
---|
| 3065 | indsel=find((num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
| 3066 | else |
---|
| 3067 | indsel=find((num_b_civ1 <= lastfield_j)&(num_b_civ2 <= lastfield_j)&(num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
| 3068 | end |
---|
| 3069 | if length(indsel)>=1 |
---|
| 3070 | firstind=indsel(1); |
---|
| 3071 | lastind=indsel(end); |
---|
| 3072 | set(handles.first_j,'String',num2str(ref_j(firstind)))%update the display of first and last fields |
---|
| 3073 | set(handles.last_j,'String',num2str(ref_j(lastind))) |
---|
| 3074 | ref_j=ref_j(indsel); |
---|
| 3075 | num_a_civ1=num_a_civ1(indsel); |
---|
| 3076 | num_b_civ1=num_b_civ1(indsel); |
---|
| 3077 | num_a_civ2=num_a_civ2(indsel); |
---|
| 3078 | num_b_civ2=num_b_civ2(indsel); |
---|
| 3079 | end |
---|
| 3080 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
| 3081 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 3082 | num1_civ1=ref_i; |
---|
| 3083 | num2_civ1=ref_i; |
---|
| 3084 | num_a_civ1=displ_num(1,index_civ1); |
---|
| 3085 | num_b_civ1=displ_num(2,index_civ1); |
---|
| 3086 | num1_civ2=ref_i; |
---|
| 3087 | num2_civ2=ref_i; |
---|
| 3088 | num_a_civ2=displ_num(1,index_civ2); |
---|
| 3089 | num_b_civ2=displ_num(2,index_civ2); |
---|
| 3090 | elseif isequal(mode,'displacement') |
---|
| 3091 | num1_civ1=ref_i; |
---|
| 3092 | num2_civ1=ref_i; |
---|
| 3093 | num_a_civ1=ref_j; |
---|
| 3094 | num_b_civ1=ref_j; |
---|
| 3095 | num1_civ2=ref_i; |
---|
| 3096 | num2_civ2=ref_i; |
---|
| 3097 | num_a_civ2=ref_j; |
---|
| 3098 | num_b_civ2=ref_j; |
---|
| 3099 | end |
---|
| 3100 | |
---|
| 3101 | |
---|
| 3102 | %------------------------------------------------------------------------ |
---|
[12] | 3103 | % --- PATCH |
---|
[94] | 3104 | function cmd_PATCH=PATCH_CMD(filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,test_interp,PatchBin) |
---|
[12] | 3105 | %------------------------------------------------------------------------ |
---|
[224] | 3106 | namelog=[filename_nc(1:end-3) '_patch.log']; |
---|
[112] | 3107 | if test_interp==0 |
---|
[163] | 3108 | if isunix |
---|
[112] | 3109 | cmd_PATCH=[PatchBin ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ... |
---|
| 3110 | ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
[163] | 3111 | else |
---|
| 3112 | cmd_PATCH=['"' PatchBin '" -f "' filename_nc '" -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ... |
---|
| 3113 | ' > "' namelog '" 2>&1']; % redirect standard output to the log file |
---|
| 3114 | end |
---|
[112] | 3115 | else %nouveau programme patch |
---|
| 3116 | cmd_PATCH=[PatchBin ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ... |
---|
| 3117 | ' -max ' thresh_value ' -nopt ' subdomain_patch ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
| 3118 | end |
---|
[163] | 3119 | cmd_PATCH=regexprep(cmd_PATCH,'\\','\\\\'); |
---|
[12] | 3120 | %------------------------------------------------------------------------ |
---|
| 3121 | % --- STEREO Interp |
---|
[67] | 3122 | 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] | 3123 | %------------------------------------------------------------------------ |
---|
[224] | 3124 | namelog=[filename_nc(1:end-3) '_stinterp.log']; |
---|
[67] | 3125 | cmd=[stinterpBin ' -f1 ' filename_A_nc ' -f2 ' filename_B_nc ' -f ' filename_nc ... |
---|
[2] | 3126 | ' -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 |
---|
| 3127 | |
---|
[12] | 3128 | %------------------------------------------------------------------------ |
---|
[2] | 3129 | % --- Executes on button press in CIV1. |
---|
| 3130 | function CIV1_Callback(hObject, eventdata, handles) |
---|
[12] | 3131 | %------------------------------------------------------------------------ |
---|
[2] | 3132 | val=get(handles.CIV1,'Value'); |
---|
| 3133 | if isequal(val,1) |
---|
| 3134 | enable_civ1(handles,'on') |
---|
| 3135 | enable_pair1(handles,'on') |
---|
| 3136 | else |
---|
| 3137 | enable_civ1(handles,'off') |
---|
| 3138 | end |
---|
| 3139 | find_netcpair_civ1(hObject, eventdata, handles); |
---|
| 3140 | |
---|
[12] | 3141 | %------------------------------------------------------------------------ |
---|
[2] | 3142 | % --- Executes on button press in FIX1. |
---|
| 3143 | function FIX1_Callback(hObject, eventdata, handles) |
---|
[12] | 3144 | %------------------------------------------------------------------------ |
---|
[2] | 3145 | enable_fix1(handles,get(handles.FIX1,'Value')) |
---|
| 3146 | |
---|
[12] | 3147 | %------------------------------------------------------------------------ |
---|
[2] | 3148 | % --- Executes on button press in PATCH1. |
---|
| 3149 | function PATCH1_Callback(hObject, eventdata, handles) |
---|
[12] | 3150 | %------------------------------------------------------------------------ |
---|
[2] | 3151 | if get(handles.PATCH1,'Value')==1 |
---|
[12] | 3152 | enable_patch1(handles) |
---|
[2] | 3153 | else |
---|
[12] | 3154 | desable_patch1(handles) |
---|
[2] | 3155 | end |
---|
| 3156 | |
---|
[12] | 3157 | %------------------------------------------------------------------------ |
---|
[2] | 3158 | % --- Executes on button press in CIV2. |
---|
| 3159 | function CIV2_Callback(hObject, eventdata, handles) |
---|
[12] | 3160 | %------------------------------------------------------------------------ |
---|
[2] | 3161 | state=get(handles.CIV2,'Value'); |
---|
| 3162 | enable_civ2(handles,state) |
---|
| 3163 | if state |
---|
| 3164 | find_netcpair_civ2(hObject, eventdata, handles) |
---|
| 3165 | enable_pair1(handles,'on') |
---|
| 3166 | end |
---|
| 3167 | |
---|
[12] | 3168 | %------------------------------------------------------------------------ |
---|
[2] | 3169 | % --- Executes on button press in FIX2. |
---|
| 3170 | function FIX2_Callback(hObject, eventdata, handles) |
---|
[12] | 3171 | %------------------------------------------------------------------------ |
---|
[2] | 3172 | if get(handles.FIX2,'Value')==1 |
---|
| 3173 | enable_fix2(handles) |
---|
| 3174 | if get(handles.CIV2,'Value')==0 |
---|
| 3175 | find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files |
---|
| 3176 | end |
---|
| 3177 | else |
---|
| 3178 | desable_fix2(handles) |
---|
| 3179 | end |
---|
| 3180 | |
---|
[12] | 3181 | %------------------------------------------------------------------------ |
---|
[2] | 3182 | % --- Executes on button press in PATCH2. |
---|
| 3183 | function PATCH2_Callback(hObject, eventdata, handles) |
---|
[12] | 3184 | %------------------------------------------------------------------------ |
---|
[2] | 3185 | if get(handles.PATCH2,'Value')==1 |
---|
| 3186 | enable_patch2(handles) |
---|
| 3187 | if get(handles.CIV2,'Value')==0 |
---|
| 3188 | find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files |
---|
| 3189 | end |
---|
| 3190 | else |
---|
| 3191 | desable_patch2(handles) |
---|
| 3192 | end |
---|
| 3193 | |
---|
[12] | 3194 | %------------------------------------------------------------------------ |
---|
| 3195 | function first_i_Callback(hObject, eventdata, handles) |
---|
| 3196 | %------------------------------------------------------------------------ |
---|
| 3197 | % last_i_Callback(hObject, eventdata, handles) |
---|
[137] | 3198 | first_i=str2double(get(handles.first_i,'String')); |
---|
[12] | 3199 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 3200 | % ref_i=ceil((first_i+last_i)/2); |
---|
| 3201 | set(handles.ref_i,'String', num2str(first_i))% reference index for pair dt = first index |
---|
[71] | 3202 | set(handles.ref_i_civ2,'String', num2str(first_i))% reference index for pair dt = first index |
---|
[12] | 3203 | ref_i_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3204 | |
---|
[12] | 3205 | %------------------------------------------------------------------------ |
---|
| 3206 | function first_j_Callback(hObject, eventdata, handles) |
---|
| 3207 | %------------------------------------------------------------------------ |
---|
| 3208 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 3209 | set(handles.ref_j,'String', num2str(first_j))% reference index for pair dt = first index |
---|
| 3210 | ref_j_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3211 | |
---|
[12] | 3212 | %------------------------------------------------------------------------ |
---|
[2] | 3213 | % --- Executes on button press in calcul_search: determine the search range isx,isy |
---|
| 3214 | function calcul_search_Callback(hObject, eventdata, handles) |
---|
[12] | 3215 | %------------------------------------------------------------------------ |
---|
[2] | 3216 | %determine pair numbers |
---|
| 3217 | list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs |
---|
| 3218 | index=get(handles.list_pair_civ1,'Value'); |
---|
| 3219 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
[71] | 3220 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
[2] | 3221 | pxcm_xy=get(handles.calcul_search,'UserData'); |
---|
| 3222 | pxcmx=pxcm_xy(1); |
---|
| 3223 | pxcmy=pxcm_xy(2); |
---|
| 3224 | mode_list=get(handles.mode,'String'); |
---|
| 3225 | mode_value=get(handles.mode,'Value'); |
---|
| 3226 | mode=mode_list{mode_value}; |
---|
| 3227 | if isequal (mode, 'series(Di)' ) |
---|
[137] | 3228 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[2] | 3229 | num1=ref_i-floor(index/2);% first image numbers |
---|
| 3230 | num2=ref_i+ceil(index/2); |
---|
| 3231 | num_a=1; |
---|
| 3232 | num_b=1; |
---|
[112] | 3233 | elseif isequal (mode, 'series(Dj)') |
---|
[2] | 3234 | num1=1; |
---|
| 3235 | num2=1; |
---|
[137] | 3236 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
[2] | 3237 | num_a=ref_j-floor(index/2);% first image numbers |
---|
| 3238 | num_b=ref_j+ceil(index/2); |
---|
| 3239 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
[137] | 3240 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[2] | 3241 | num1=ref_i; |
---|
| 3242 | num2=ref_i; |
---|
| 3243 | num_a=displ_num(1,index); |
---|
| 3244 | num_b=displ_num(2,index); |
---|
| 3245 | end |
---|
| 3246 | dt=time(num2,num_b)-time(num1,num_a); |
---|
[137] | 3247 | ibx=str2double(get(handles.ibx,'String')); |
---|
| 3248 | iby=str2double(get(handles.iby,'String')); |
---|
| 3249 | umin=dt*pxcmx*str2double(get(handles.umin,'String')); |
---|
| 3250 | umax=dt*pxcmx*str2double(get(handles.umax,'String')); |
---|
| 3251 | vmin=dt*pxcmy*str2double(get(handles.vmin,'String')); |
---|
| 3252 | vmax=dt*pxcmy*str2double(get(handles.vmax,'String')); |
---|
[2] | 3253 | shiftx=round((umin+umax)/2); |
---|
| 3254 | shifty=round((vmin+vmax)/2); |
---|
| 3255 | isx=(umax+2-shiftx)*2+ibx; |
---|
| 3256 | isx=2*ceil(isx/2)+1; |
---|
| 3257 | isy=(vmax+2-shifty)*2+iby; |
---|
| 3258 | isy=2*ceil(isy/2)+1; |
---|
| 3259 | set(handles.shiftx,'String',num2str(shiftx)); |
---|
| 3260 | set(handles.shifty,'String',num2str(shifty)); |
---|
| 3261 | set(handles.isx,'String',num2str(isx)); |
---|
| 3262 | set(handles.isy,'String',num2str(isy)); |
---|
| 3263 | |
---|
[12] | 3264 | %------------------------------------------------------------------------ |
---|
| 3265 | % --- Executes on carriage return on the subdir civ1 edit window |
---|
[2] | 3266 | function subdir_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 3267 | %------------------------------------------------------------------------ |
---|
[2] | 3268 | subdir=get(handles.subdir_civ1,'String'); |
---|
| 3269 | set(handles.subdir_civ2,'String',subdir); |
---|
[112] | 3270 | if get(handles.CIV1,'Value')==0 |
---|
[2] | 3271 | find_netcpair_civ1(hObject, eventdata, handles); %update the list of available pairs from netcdf files in the new directory |
---|
| 3272 | end |
---|
| 3273 | |
---|
[12] | 3274 | %------------------------------------------------------------------------ |
---|
| 3275 | % --- Executes on carriage return on the subdir civ1 edit window |
---|
[2] | 3276 | function subdir_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 3277 | %------------------------------------------------------------------------ |
---|
[2] | 3278 | %update the list of available pairs from netcdf files in the new directory |
---|
| 3279 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0 |
---|
| 3280 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 3281 | end |
---|
| 3282 | |
---|
[12] | 3283 | %------------------------------------------------------------------------ |
---|
[133] | 3284 | % --- Executes on button press in get_mask_civ1: select box for mask option |
---|
[2] | 3285 | function get_mask_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 3286 | %------------------------------------------------------------------------ |
---|
[252] | 3287 | maskval=get(handles.get_mask_civ1,'Value') |
---|
[2] | 3288 | if isequal(maskval,0) |
---|
| 3289 | set(handles.mask_civ1,'String','') |
---|
| 3290 | else |
---|
| 3291 | mask_displ='no mask'; %default |
---|
[71] | 3292 | filebase=get(handles.RootName,'String'); |
---|
[2] | 3293 | [ nbslice_mask, flag_mask]=get_mask(filebase,handles); |
---|
| 3294 | if isequal(flag_mask,1) |
---|
[112] | 3295 | mask_displ=[num2str(nbslice_mask) 'mask']; |
---|
[2] | 3296 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[112] | 3297 | common_path=fileparts(filebase); |
---|
| 3298 | filebase_a=fullfile(common_path,get(handles.RootName_1,'String')); |
---|
| 3299 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
| 3300 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice_mask) |
---|
| 3301 | mask_displ='no mask'; |
---|
| 3302 | end |
---|
[2] | 3303 | end |
---|
| 3304 | if isequal(mask_displ,'no mask') |
---|
[12] | 3305 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3306 | {'*.png', ' (*.png)'; |
---|
| 3307 | '*.png', '.png files '; ... |
---|
| 3308 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3309 | 'Pick a mask file *.png',filebase); |
---|
| 3310 | mask_displ=fullfile(PathName,FileName); |
---|
[12] | 3311 | if ~exist(mask_displ,'file') |
---|
| 3312 | mask_displ='no mask'; |
---|
| 3313 | end |
---|
| 3314 | end |
---|
| 3315 | if isequal(mask_displ,'no mask') |
---|
[2] | 3316 | set(handles.get_mask_civ1,'Value',0) |
---|
| 3317 | set(handles.get_mask_fix1,'Value',0) |
---|
| 3318 | set(handles.get_mask_civ2,'Value',0) |
---|
| 3319 | set(handles.get_mask_fix2,'Value',0) |
---|
| 3320 | else |
---|
| 3321 | set(handles.get_mask_fix1,'Value',1) |
---|
| 3322 | set(handles.get_mask_fix2,'Value',1) |
---|
| 3323 | end |
---|
| 3324 | set(handles.mask_civ1,'String',mask_displ) |
---|
| 3325 | set(handles.mask_fix1,'String',mask_displ) |
---|
| 3326 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 3327 | set(handles.mask_fix2,'String',mask_displ) |
---|
| 3328 | end |
---|
[133] | 3329 | set(handles.get_mask_civ2,'Value',maskval)%update the civ2 mask with the same option as civ1 |
---|
[2] | 3330 | |
---|
[12] | 3331 | %------------------------------------------------------------------------ |
---|
[2] | 3332 | % --- Executes on button press in get_mask_fix1. |
---|
| 3333 | function get_mask_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 3334 | %------------------------------------------------------------------------ |
---|
[2] | 3335 | maskval=get(handles.get_mask_fix1,'Value'); |
---|
| 3336 | if isequal(maskval,0) |
---|
| 3337 | set(handles.mask_fix1,'String','') |
---|
| 3338 | else |
---|
[112] | 3339 | mask_displ='no mask'; %default |
---|
| 3340 | filebase=get(handles.RootName,'String'); |
---|
| 3341 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3342 | if isequal(flag_mask,1) |
---|
| 3343 | mask_displ=[num2str(nbslice) 'mask']; |
---|
| 3344 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[71] | 3345 | filebase_a=get(handles.RootName_1,'String'); |
---|
[2] | 3346 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[229] | 3347 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
[2] | 3348 | mask_displ='no mask'; |
---|
| 3349 | end |
---|
[112] | 3350 | end |
---|
| 3351 | if isequal(mask_displ,'no mask') |
---|
| 3352 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3353 | {'*.png', ' (*.png)'; |
---|
[12] | 3354 | '*.png', '.png files '; ... |
---|
| 3355 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3356 | 'Pick a mask file *.png',filebase); |
---|
[112] | 3357 | mask_displ=fullfile(PathName,FileName); |
---|
| 3358 | if ~exist(mask_displ,'file') |
---|
| 3359 | mask_displ='no mask'; |
---|
| 3360 | end |
---|
[12] | 3361 | end |
---|
[112] | 3362 | if isequal(mask_displ,'no mask') |
---|
| 3363 | set(handles.get_mask_fix1,'Value',0) |
---|
| 3364 | set(handles.get_mask_civ2,'Value',0) |
---|
| 3365 | set(handles.get_mask_fix2,'Value',0) |
---|
| 3366 | else |
---|
| 3367 | %set(handles.get_mask_civ2,'Value',1) |
---|
| 3368 | set(handles.get_mask_fix2,'Value',1) |
---|
| 3369 | end |
---|
| 3370 | set(handles.mask_fix1,'String',mask_displ) |
---|
| 3371 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 3372 | set(handles.mask_fix2,'String',mask_displ) |
---|
[12] | 3373 | end |
---|
| 3374 | |
---|
| 3375 | %------------------------------------------------------------------------ |
---|
[133] | 3376 | % --- Executes on button press in get_mask_civ2: select box for mask option |
---|
[2] | 3377 | function get_mask_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 3378 | %------------------------------------------------------------------------ |
---|
[2] | 3379 | maskval=get(handles.get_mask_civ2,'Value'); |
---|
| 3380 | if isequal(maskval,0) |
---|
| 3381 | set(handles.mask_civ2,'String','') |
---|
| 3382 | else |
---|
[112] | 3383 | mask_displ='no mask'; %default |
---|
| 3384 | filebase=get(handles.RootName,'String'); |
---|
| 3385 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3386 | if isequal(flag_mask,1) |
---|
| 3387 | mask_displ=[num2str(nbslice) 'mask']; |
---|
| 3388 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[71] | 3389 | filebase_a=get(handles.RootName_1,'String'); |
---|
[2] | 3390 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[229] | 3391 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
[2] | 3392 | mask_displ='no mask'; |
---|
| 3393 | end |
---|
[112] | 3394 | end |
---|
| 3395 | if isequal(mask_displ,'no mask') |
---|
| 3396 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3397 | {'*.png', ' (*.png)'; |
---|
[12] | 3398 | '*.png', '.png files '; ... |
---|
| 3399 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3400 | 'Pick a mask file *.png',filebase); |
---|
[112] | 3401 | mask_displ=fullfile(PathName,FileName); |
---|
| 3402 | if ~exist(mask_displ,'file') |
---|
| 3403 | mask_displ='no mask'; |
---|
| 3404 | end |
---|
[12] | 3405 | end |
---|
[112] | 3406 | if isequal(mask_displ,'no mask') |
---|
| 3407 | set(handles.get_mask_civ2,'Value',0) |
---|
| 3408 | set(handles.get_mask_fix2,'Value',0) |
---|
| 3409 | else |
---|
| 3410 | set(handles.get_mask_fix2,'Value',1) |
---|
| 3411 | end |
---|
| 3412 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 3413 | set(handles.mask_fix2,'String',mask_displ) |
---|
[12] | 3414 | end |
---|
| 3415 | |
---|
| 3416 | %------------------------------------------------------------------------ |
---|
[2] | 3417 | % --- Executes on button press in get_mask_fix2. |
---|
| 3418 | function get_mask_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 3419 | %------------------------------------------------------------------------ |
---|
[2] | 3420 | maskval=get(handles.get_mask_fix2,'Value'); |
---|
| 3421 | if isequal(maskval,0) |
---|
| 3422 | set(handles.mask_fix2,'String','') |
---|
| 3423 | else |
---|
[12] | 3424 | mask_displ='no mask'; %default |
---|
[71] | 3425 | filebase=get(handles.RootName,'String'); |
---|
[12] | 3426 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3427 | if isequal(flag_mask,1) |
---|
[112] | 3428 | mask_displ=[num2str(nbslice) 'mask']; |
---|
[12] | 3429 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[112] | 3430 | filebase_a=get(handles.RootName_1,'String'); |
---|
| 3431 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[229] | 3432 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
[112] | 3433 | mask_displ='no mask'; |
---|
| 3434 | end |
---|
[12] | 3435 | end |
---|
| 3436 | if isequal(mask_displ,'no mask') |
---|
| 3437 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3438 | {'*.png', ' (*.png)'; |
---|
| 3439 | '*.png', '.png files '; ... |
---|
| 3440 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3441 | 'Pick a mask file *.png',filebase); |
---|
| 3442 | mask_displ=fullfile(PathName,FileName); |
---|
[12] | 3443 | if ~exist(mask_displ,'file') |
---|
[2] | 3444 | mask_displ='no mask'; |
---|
| 3445 | end |
---|
[12] | 3446 | end |
---|
| 3447 | if isequal(mask_displ,'no mask') |
---|
| 3448 | set(handles.get_mask_fix2,'Value',0) |
---|
[112] | 3449 | end |
---|
[12] | 3450 | set(handles.mask_fix2,'String',mask_displ) |
---|
[2] | 3451 | end |
---|
| 3452 | |
---|
[12] | 3453 | %------------------------------------------------------------------------ |
---|
| 3454 | % --- function called to look for mask files |
---|
[2] | 3455 | function [nbslice, flag_mask]=get_mask(filebase,handles) |
---|
[12] | 3456 | %------------------------------------------------------------------------ |
---|
[112] | 3457 | %detect mask files, images with appropriate file base |
---|
[2] | 3458 | %[filebase '_' xx 'mask'], xx=nbslice |
---|
| 3459 | %flag_mask=1 indicates detection |
---|
| 3460 | |
---|
| 3461 | flag_mask=0;%default |
---|
| 3462 | nbslice=1; |
---|
| 3463 | |
---|
| 3464 | % subdir=get(handles.subdir_civ1,'String'); |
---|
| 3465 | [Path,Name]=fileparts(filebase); |
---|
[12] | 3466 | if ~isdir(Path) |
---|
| 3467 | msgbox_uvmat('ERROR','no path for input files') |
---|
| 3468 | return |
---|
| 3469 | end |
---|
[2] | 3470 | currentdir=pwd; |
---|
| 3471 | cd(Path);%move in the dir of the root name filebase |
---|
| 3472 | maskfiles=dir([Name '_*mask_*.png']);%look for mask files |
---|
| 3473 | cd(currentdir);%come back to the current working directory |
---|
[12] | 3474 | if ~isempty(maskfiles) |
---|
[112] | 3475 | % msgbox_uvmat('ERROR','no mask available, to create it use Tools/Make mask in the upper menu bar of uvmat') |
---|
| 3476 | % else |
---|
[2] | 3477 | flag_mask=1; |
---|
| 3478 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 3479 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 3480 | Namedouble=double(Name); |
---|
| 3481 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 3482 | ind_mask=findstr('mask',Name); |
---|
| 3483 | i=ind_mask-1; |
---|
[137] | 3484 | while val(i)==0 && i>0 |
---|
[112] | 3485 | i=i-1; |
---|
[2] | 3486 | end |
---|
[137] | 3487 | nbslice=str2double(Name(i+1:ind_mask-1)); |
---|
| 3488 | if ~isnan(nbslice) && Name(i)=='_' |
---|
[112] | 3489 | flag_mask=1; |
---|
[2] | 3490 | else |
---|
[112] | 3491 | msgbox_uvmat('ERROR',['bad mask file ' Name ext ' found in ' Path2]) |
---|
| 3492 | return |
---|
| 3493 | nbslice=1; |
---|
[2] | 3494 | end |
---|
[112] | 3495 | end |
---|
[2] | 3496 | |
---|
[12] | 3497 | %------------------------------------------------------------------------ |
---|
| 3498 | % --- function called to look for grid files |
---|
[2] | 3499 | function [nbslice, flag_mask]=get_grid(filebase,handles) |
---|
[12] | 3500 | %------------------------------------------------------------------------ |
---|
[2] | 3501 | flag_mask=0;%default |
---|
| 3502 | nbslice=1; |
---|
| 3503 | [Path,Name]=fileparts(filebase); |
---|
| 3504 | currentdir=pwd; |
---|
| 3505 | cd(Path);%move in the dir of the root name filebase |
---|
| 3506 | maskfiles=dir([Name '_*grid_*.grid']);%look for mask files |
---|
| 3507 | cd(currentdir);%come back to the current working directory |
---|
| 3508 | if ~isempty(maskfiles) |
---|
| 3509 | flag_mask=1; |
---|
| 3510 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 3511 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 3512 | Namedouble=double(Name); |
---|
| 3513 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 3514 | ind_mask=findstr('grid',Name); |
---|
| 3515 | i=ind_mask-1; |
---|
[137] | 3516 | while val(i)==0 && i>0 |
---|
[112] | 3517 | i=i-1; |
---|
[2] | 3518 | end |
---|
[137] | 3519 | nbslice=str2double(Name(i+1:ind_mask-1)); |
---|
| 3520 | if ~isnan(nbslice) && Name(i)=='_' |
---|
[112] | 3521 | flag_mask=1; |
---|
[2] | 3522 | else |
---|
[112] | 3523 | msgbox_uvmat('ERROR',['bad grid file ' Name ext ' found in ' Path2]) |
---|
| 3524 | return |
---|
| 3525 | nbslice=1; |
---|
[2] | 3526 | end |
---|
[12] | 3527 | end |
---|
[2] | 3528 | |
---|
[12] | 3529 | %------------------------------------------------------------------------ |
---|
| 3530 | % --- transform numbers to letters |
---|
[122] | 3531 | function str=num2stra(num,nom_type) |
---|
[12] | 3532 | %------------------------------------------------------------------------ |
---|
[122] | 3533 | if isempty(nom_type) |
---|
| 3534 | str=''; |
---|
| 3535 | elseif strcmp(nom_type(end),'a') |
---|
[2] | 3536 | str=char(96+num); |
---|
[122] | 3537 | elseif strcmp(nom_type(end),'A') |
---|
| 3538 | str=char(96+num); |
---|
| 3539 | elseif isempty(nom_type(2:end))%a single index |
---|
[2] | 3540 | str=''; |
---|
| 3541 | else |
---|
| 3542 | str=num2str(num); |
---|
| 3543 | end |
---|
[12] | 3544 | |
---|
| 3545 | %------------------------------------------------------------------------ |
---|
[2] | 3546 | % --- Executes on button press in list_subdir_civ1. |
---|
| 3547 | function list_subdir_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 3548 | %------------------------------------------------------------------------ |
---|
[2] | 3549 | list_subdir_civ1=get(handles.list_subdir_civ1,'String'); |
---|
| 3550 | val=get(handles.list_subdir_civ1,'Value'); |
---|
| 3551 | if val>1 |
---|
| 3552 | subdir=list_subdir_civ1{val}; |
---|
| 3553 | set(handles.subdir_civ1,'String',subdir); |
---|
| 3554 | set(handles.list_subdir_civ1,'Value',1); |
---|
| 3555 | end |
---|
| 3556 | |
---|
[12] | 3557 | %------------------------------------------------------------------------ |
---|
[2] | 3558 | % --- Executes on button press in list_subdir_civ2. |
---|
| 3559 | function list_subdir_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 3560 | %------------------------------------------------------------------------ |
---|
[2] | 3561 | list_subdir_civ2=get(handles.list_subdir_civ2,'String'); |
---|
| 3562 | val=get(handles.list_subdir_civ2,'Value'); |
---|
| 3563 | if val>1 |
---|
| 3564 | subdir=list_subdir_civ2{val}; |
---|
| 3565 | set(handles.subdir_civ2,'String',subdir); |
---|
| 3566 | set(handles.list_subdir_civ2,'Value',1); |
---|
| 3567 | end |
---|
| 3568 | |
---|
[12] | 3569 | %------------------------------------------------------------------------ |
---|
[2] | 3570 | % --- Executes on button press in browse_gridciv1. |
---|
| 3571 | function browse_gridciv1_Callback(hObject, eventdata, handles) |
---|
[12] | 3572 | %------------------------------------------------------------------------ |
---|
[2] | 3573 | value=get(handles.browse_gridciv1,'Value'); |
---|
| 3574 | testgrid=0; |
---|
| 3575 | if value |
---|
[112] | 3576 | filebase=get(handles.RootName,'String'); |
---|
[39] | 3577 | [nbslice, flag_grid]=get_grid(filebase,handles); |
---|
[2] | 3578 | if isequal(flag_grid,1) |
---|
[112] | 3579 | filegrid=[num2str(nbslice) 'grid']; |
---|
| 3580 | testgrid=1; |
---|
| 3581 | else |
---|
[2] | 3582 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3583 | {'*.grid', ' (*.grid)'; |
---|
| 3584 | '*.grid', '.grid files '; ... |
---|
| 3585 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3586 | 'Pick a file',filebase); |
---|
[2] | 3587 | filegrid=fullfile(PathName,FileName); |
---|
| 3588 | if ~(isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file')) |
---|
| 3589 | testgrid=1; |
---|
| 3590 | end |
---|
[112] | 3591 | end |
---|
[2] | 3592 | end |
---|
| 3593 | if testgrid |
---|
[112] | 3594 | set(handles.browse_gridciv2,'Value',1) |
---|
| 3595 | set(handles.get_gridpatch1,'Value',1) |
---|
| 3596 | set(handles.get_gridpatch2,'Value',1) |
---|
| 3597 | set(handles.dx_civ1,'Visible','off'); |
---|
| 3598 | set(handles.dy_civ1,'Visible','off'); |
---|
| 3599 | set(handles.dx_civ2,'Visible','off'); |
---|
| 3600 | set(handles.dy_civ2,'Visible','off'); |
---|
| 3601 | set(handles.grid_civ1,'String',filegrid) |
---|
| 3602 | set(handles.grid_patch1,'String',filegrid) |
---|
| 3603 | set(handles.grid_civ2,'String',filegrid) |
---|
| 3604 | set(handles.grid_patch2,'String',filegrid) |
---|
| 3605 | else |
---|
| 3606 | set(handles.browse_gridciv1,'Value',0); |
---|
| 3607 | set(handles.browse_gridciv2,'Value',0); |
---|
| 3608 | set(handles.get_gridpatch1,'Value',0) |
---|
| 3609 | set(handles.get_gridpatch2,'Value',0) |
---|
| 3610 | set(handles.dx_civ1,'Visible','on'); |
---|
| 3611 | set(handles.dy_civ1,'Visible','on'); |
---|
| 3612 | set(handles.dx_civ2,'Visible','on'); |
---|
| 3613 | set(handles.dy_civ2,'Visible','on'); |
---|
| 3614 | set(handles.grid_civ1,'String','') |
---|
| 3615 | set(handles.grid_patch1,'String','') |
---|
| 3616 | set(handles.grid_civ2,'String','') |
---|
| 3617 | set(handles.grid_patch2,'String','') |
---|
[2] | 3618 | end |
---|
| 3619 | |
---|
[12] | 3620 | %------------------------------------------------------------------------ |
---|
[2] | 3621 | % --- Executes on button press in browse_gridciv1. |
---|
| 3622 | function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
[12] | 3623 | %------------------------------------------------------------------------ |
---|
[2] | 3624 | value=get(handles.browse_gridciv2,'Value'); |
---|
| 3625 | if value |
---|
[112] | 3626 | filebase=get(handles.RootName,'String'); |
---|
[39] | 3627 | [nbslice, flag_grid]=get_grid(filebase,handles); |
---|
[2] | 3628 | if isequal(flag_grid,1) |
---|
| 3629 | mask_displ=[num2str(nbslice) 'grid']; |
---|
| 3630 | set(handles.grid_civ2,'String',mask_displ) |
---|
| 3631 | set(handles.dx_civ2,'Visible','off'); |
---|
| 3632 | set(handles.dy_civ2,'Visible','off'); |
---|
[112] | 3633 | else |
---|
[2] | 3634 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3635 | {'*.grid', ' (*.grid)'; |
---|
| 3636 | '*.grid', '.grid files '; ... |
---|
| 3637 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3638 | 'Pick a file',filebase); |
---|
[2] | 3639 | filegrid=fullfile(PathName,FileName); |
---|
[229] | 3640 | if isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file') |
---|
[2] | 3641 | set(handles.browse_gridciv2,'Value',0); |
---|
| 3642 | set(handles.grid_civ2,'string',''); |
---|
| 3643 | set(handles.dx_civ2,'Visible','on'); |
---|
| 3644 | set(handles.dy_civ2,'Visible','on'); |
---|
| 3645 | set(handles.grid_civ2,'string',''); |
---|
| 3646 | else |
---|
| 3647 | set(handles.grid_civ2,'string',filegrid); |
---|
| 3648 | set(handles.dx_civ2,'Visible','off'); |
---|
| 3649 | set(handles.dy_civ2,'Visible','off'); |
---|
| 3650 | set(handles.grid_civ2,'string',filegrid); |
---|
| 3651 | end |
---|
| 3652 | end |
---|
| 3653 | else |
---|
| 3654 | set(handles.grid_civ2,'string',''); |
---|
[112] | 3655 | set(handles.dx_civ2,'Visible','on'); |
---|
| 3656 | set(handles.dy_civ2,'Visible','on'); |
---|
| 3657 | set(handles.grid_civ2,'string',''); |
---|
[2] | 3658 | end |
---|
| 3659 | |
---|
| 3660 | % % --- Executes on button press in browse_gridciv2. |
---|
| 3661 | % function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
[112] | 3662 | % |
---|
[71] | 3663 | % filebase=get(handles.RootName,'String'); |
---|
[2] | 3664 | % [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3665 | % {'*.grid', ' (*.grid)'; |
---|
| 3666 | % '*.grid', '.grid files '; ... |
---|
| 3667 | % '*.*', 'All Files (*.*)'}, ... |
---|
| 3668 | % 'Pick a file',filebase); |
---|
| 3669 | % filegrid=fullfile(PathName,FileName); |
---|
| 3670 | % set(handles.grid_civ2,'string',filegrid); |
---|
| 3671 | % set(handles.dx_civ2,'String',' '); |
---|
| 3672 | % set(handles.dy_civ2,'String',' '); |
---|
| 3673 | % % set(handles.grid_patch2,'string',filegrid); |
---|
| 3674 | |
---|
| 3675 | % --- Executes on button press in get_gridpatch1. |
---|
| 3676 | function get_gridpatch1_Callback(hObject, eventdata, handles) |
---|
| 3677 | % hObject handle to get_gridpatch1 (see GCBO) |
---|
| 3678 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 3679 | % handles structure with handles and user data (see GUIDATA) |
---|
| 3680 | |
---|
[71] | 3681 | filebase=get(handles.RootName,'String'); |
---|
[2] | 3682 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3683 | {'*.grid', ' (*.grid)'; |
---|
| 3684 | '*.grid', '.grid files '; ... |
---|
| 3685 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3686 | 'Pick a file',filebase); |
---|
[2] | 3687 | filegrid=fullfile(PathName,FileName); |
---|
| 3688 | set(handles.grid_patch1,'string',filegrid); |
---|
| 3689 | % set(handles.grid_patch2,'string',filegrid |
---|
| 3690 | |
---|
[12] | 3691 | %------------------------------------------------------------------------ |
---|
[2] | 3692 | % --- Executes on button press in get_gridpatch2. |
---|
| 3693 | function get_gridpatch2_Callback(hObject, eventdata, handles) |
---|
[12] | 3694 | %------------------------------------------------------------------------ |
---|
[2] | 3695 | |
---|
[12] | 3696 | %------------------------------------------------------------------------ |
---|
[2] | 3697 | function enable_civ1(handles,state) |
---|
[12] | 3698 | %------------------------------------------------------------------------ |
---|
[2] | 3699 | if isequal(state,'on') |
---|
| 3700 | set(handles.frame_civ1,'BackgroundColor',[1 1 0]) |
---|
| 3701 | set(handles.frame_para_civ1,'BackgroundColor',[1 1 0]) |
---|
| 3702 | set(handles.frame_grid_civ1,'BackgroundColor',[1 1 0]) |
---|
| 3703 | else |
---|
| 3704 | set(handles.frame_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3705 | set(handles.frame_para_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3706 | set(handles.frame_grid_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3707 | end |
---|
| 3708 | set(handles.ibx,'Visible',state) |
---|
| 3709 | set(handles.iby,'Visible',state) |
---|
| 3710 | set(handles.isx,'Visible',state) |
---|
| 3711 | set(handles.isy,'Visible',state) |
---|
| 3712 | set(handles.shiftx,'Visible',state) |
---|
| 3713 | set(handles.shifty,'Visible',state) |
---|
| 3714 | set(handles.rho,'Visible',state) |
---|
| 3715 | set(handles.dx_civ1,'Visible',state) |
---|
| 3716 | set(handles.dy_civ1,'Visible',state) |
---|
| 3717 | set(handles.calcul_search,'Visible',state) |
---|
| 3718 | set(handles.u_text,'Visible',state) |
---|
| 3719 | set(handles.v_text,'Visible',state) |
---|
| 3720 | set(handles.min,'Visible',state) |
---|
| 3721 | set(handles.max,'Visible',state) |
---|
| 3722 | set(handles.umin,'Visible',state) |
---|
| 3723 | set(handles.umax,'Visible',state) |
---|
| 3724 | set(handles.vmin,'Visible',state) |
---|
| 3725 | set(handles.vmax,'Visible',state) |
---|
| 3726 | set(handles.grid_civ1,'Visible',state) |
---|
| 3727 | set(handles.mask_civ1,'Visible',state) |
---|
| 3728 | set(handles.browse_gridciv1,'Visible',state) |
---|
| 3729 | set(handles.get_mask_civ1,'Visible',state) |
---|
| 3730 | set(handles.parameters,'Visible',state) |
---|
| 3731 | set(handles.grid,'Visible',state) |
---|
| 3732 | set(handles.dx_civ1,'Visible',state) |
---|
| 3733 | set(handles.dy_civ1,'Visible',state) |
---|
| 3734 | set(handles.ImaThreshold,'Visible',state) |
---|
| 3735 | if isequal(state,'off') |
---|
| 3736 | set(handles.MinIma,'Visible','off') |
---|
| 3737 | set(handles.MaxIma,'Visible','off') |
---|
| 3738 | set(handles.ImaThreshold,'Value',0) |
---|
| 3739 | end |
---|
| 3740 | set(handles.dx_civ1_title,'Visible',state) |
---|
| 3741 | set(handles.dy_civ1_title,'Visible',state) |
---|
| 3742 | set(handles.ImaThreshold_title,'Visible',state) |
---|
| 3743 | set(handles.ib_title,'Visible',state) |
---|
| 3744 | set(handles.is_title,'Visible',state) |
---|
| 3745 | set(handles.shift_title,'Visible',state) |
---|
| 3746 | set(handles.rho_title,'Visible',state) |
---|
[224] | 3747 | set(handles.TestCiv1,'Visible',state) |
---|
| 3748 | %set(handles.CivAll,'Visible',state) |
---|
[2] | 3749 | |
---|
[12] | 3750 | %------------------------------------------------------------------------ |
---|
[2] | 3751 | function enable_fix1(handles,state) |
---|
[12] | 3752 | %------------------------------------------------------------------------ |
---|
[2] | 3753 | if isequal(state,0) |
---|
| 3754 | state='off'; |
---|
| 3755 | end |
---|
| 3756 | if isequal(state,1) |
---|
| 3757 | state='on'; |
---|
| 3758 | end |
---|
| 3759 | if isequal(state,'on') |
---|
| 3760 | set(handles.frame_fix1,'BackgroundColor',[1 1 0]) |
---|
| 3761 | else |
---|
| 3762 | set(handles.frame_fix1,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3763 | end |
---|
| 3764 | set(handles.REMOVE,'Visible',state) |
---|
| 3765 | set(handles.vec_Fmin2,'Visible',state) |
---|
| 3766 | set(handles.vec_F2,'Visible',state) |
---|
| 3767 | set(handles.vec_F3,'Visible',state) |
---|
| 3768 | set(handles.thresh_vecC,'Visible',state) |
---|
| 3769 | set(handles.thresh_vecC_title,'Visible',state) |
---|
| 3770 | set(handles.thresh_vel,'Visible',state) |
---|
| 3771 | set(handles.thresh_vel_text,'Visible',state) |
---|
| 3772 | set(handles.mask_fix1,'Visible',state) |
---|
| 3773 | set(handles.get_mask_fix1,'Visible',state) |
---|
| 3774 | set(handles.get_ref_fix1,'Visible',state) |
---|
| 3775 | set(handles.ref_fix1,'Visible',state) |
---|
| 3776 | set(handles.inf_sup1,'Visible',state) |
---|
| 3777 | set(handles.field_ref1,'Visible',state) |
---|
| 3778 | |
---|
[12] | 3779 | %------------------------------------------------------------------------ |
---|
[2] | 3780 | function enable_patch1(handles) |
---|
[12] | 3781 | %------------------------------------------------------------------------ |
---|
[2] | 3782 | set(handles.frame_patch1,'BackgroundColor',[1 1 0]) |
---|
| 3783 | set(handles.rho_patch1,'Visible','on') |
---|
| 3784 | set(handles.rho_text1,'Visible','on') |
---|
[225] | 3785 | if get(handles.CivAll,'Value')==2 |
---|
[224] | 3786 | set(handles.thresh_patch1,'Visible','on') |
---|
| 3787 | set(handles.thresh_text1,'Visible','on') |
---|
| 3788 | end |
---|
[2] | 3789 | set(handles.subdomain_patch1,'Visible','on') |
---|
| 3790 | set(handles.subdomain_text1,'Visible','on') |
---|
| 3791 | set(handles.nx_patch1,'Visible','on') |
---|
| 3792 | set(handles.ny_patch1,'Visible','on') |
---|
| 3793 | set(handles.nx_patch1_title,'Visible','on') |
---|
| 3794 | set(handles.ny_patch1_title,'Visible','on') |
---|
[112] | 3795 | % if ~isempty(patch_newBin) |
---|
[224] | 3796 | set(handles.test_interp,'Visible','off'); |
---|
[252] | 3797 | stereo_test=get(handles.compare,'Value'); |
---|
| 3798 | if stereo_test==3 |
---|
| 3799 | set(handles.test_stereo1,'Visible','on') |
---|
| 3800 | end |
---|
[100] | 3801 | % end |
---|
[252] | 3802 | %set(handles.get_gridpatch1,'Visible','on') |
---|
| 3803 | %set(handles.grid_patch1,'string','none'); |
---|
| 3804 | %set(handles.grid_patch1,'Visible','on') |
---|
[2] | 3805 | |
---|
[12] | 3806 | %------------------------------------------------------------------------ |
---|
[2] | 3807 | function desable_patch1(handles) |
---|
[12] | 3808 | %------------------------------------------------------------------------ |
---|
[2] | 3809 | set(handles.frame_patch1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3810 | set(handles.rho_patch1,'Visible','off') |
---|
| 3811 | set(handles.rho_text1,'Visible','off') |
---|
| 3812 | set(handles.thresh_patch1,'Visible','off') |
---|
| 3813 | set(handles.thresh_text1,'Visible','off') |
---|
| 3814 | set(handles.subdomain_patch1,'Visible','off') |
---|
| 3815 | set(handles.subdomain_text1,'Visible','off') |
---|
| 3816 | set(handles.nx_patch1,'Visible','off') |
---|
| 3817 | set(handles.ny_patch1,'Visible','off') |
---|
| 3818 | set(handles.nx_patch1_title,'Visible','off') |
---|
| 3819 | set(handles.ny_patch1_title,'Visible','off') |
---|
[252] | 3820 | set(handles.test_stereo1,'Visible','off') |
---|
[100] | 3821 | %set(handles.test_interp,'Visible','off') |
---|
[252] | 3822 | %set(handles.get_gridpatch1,'Visible','off') |
---|
| 3823 | %set(handles.grid_patch1,'Visible','off') |
---|
[2] | 3824 | |
---|
[12] | 3825 | %------------------------------------------------------------------------ |
---|
[2] | 3826 | function enable_civ2(handles,state) |
---|
[12] | 3827 | %------------------------------------------------------------------------ |
---|
[2] | 3828 | if isequal(state,0) |
---|
| 3829 | state='off'; |
---|
| 3830 | end |
---|
| 3831 | if isequal(state,1) |
---|
| 3832 | state='on'; |
---|
| 3833 | end |
---|
| 3834 | if isequal(state,'on') |
---|
| 3835 | set(handles.frame_civ2,'BackgroundColor',[1 1 0]) |
---|
| 3836 | set(handles.frame_para_civ2,'BackgroundColor',[1 1 0]) |
---|
| 3837 | set(handles.frame_grid_civ2,'BackgroundColor',[1 1 0]) |
---|
| 3838 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 3839 | else |
---|
| 3840 | set(handles.frame_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3841 | set(handles.frame_para_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3842 | set(handles.frame_grid_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3843 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3844 | end |
---|
| 3845 | set(handles.ibx_civ2,'Visible',state) |
---|
| 3846 | set(handles.iby_civ2,'Visible',state) |
---|
| 3847 | set(handles.decimal,'Visible',state) |
---|
| 3848 | set(handles.deformation,'Visible',state) |
---|
| 3849 | set(handles.rho_civ2,'Visible',state) |
---|
| 3850 | set(handles.dx_civ2,'Visible',state) |
---|
| 3851 | set(handles.dy_civ2,'Visible',state) |
---|
| 3852 | set(handles.browse_gridciv2,'Visible',state) |
---|
| 3853 | set(handles.get_mask_civ2,'Visible',state) |
---|
| 3854 | set(handles.parameters,'Visible',state) |
---|
| 3855 | set(handles.grid,'Visible',state) |
---|
| 3856 | set(handles.parameters_text,'Visible',state) |
---|
| 3857 | set(handles.grid_text,'Visible',state) |
---|
| 3858 | set(handles.grid_civ2,'Visible',state) |
---|
| 3859 | set(handles.mask_civ2,'Visible',state) |
---|
| 3860 | set(handles.dx_civ2_title,'Visible',state) |
---|
| 3861 | set(handles.dy_civ2_title,'Visible',state) |
---|
| 3862 | set(handles.ibx_civ2_text,'Visible',state) |
---|
| 3863 | set(handles.rho_civ2_title,'Visible',state) |
---|
| 3864 | set(handles.ImaThreshold2,'Visible',state) |
---|
| 3865 | set(handles.ImaThreshold_title2,'Visible',state) |
---|
| 3866 | if isequal(state,'off') |
---|
| 3867 | set(handles.MinIma2,'Visible','off') |
---|
| 3868 | set(handles.MaxIma2,'Visible','off') |
---|
| 3869 | set(handles.ImaThreshold2,'Value',0) |
---|
[112] | 3870 | if isequal(get(handles.FIX2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) |
---|
[2] | 3871 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 3872 | set(handles.subdir_civ2,'Visible','off') |
---|
| 3873 | set(handles.subdir_civ2_text,'Visible','off') |
---|
[71] | 3874 | set(handles.dt_unit_civ2,'Visible','off') |
---|
| 3875 | set(handles.ref_i_civ2,'Visible','off') |
---|
| 3876 | set(handles.i_ref_civ2_title,'Visible','off') |
---|
| 3877 | set(handles.j_ref_civ2_title,'Visible','off') |
---|
| 3878 | set(handles.ref_j_civ2,'Visible','off') |
---|
[2] | 3879 | end |
---|
| 3880 | else |
---|
| 3881 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 3882 | set(handles.subdir_civ2,'Visible','on') |
---|
| 3883 | set(handles.subdir_civ2_text,'Visible','on') |
---|
[71] | 3884 | set(handles.dt_unit_civ2,'Visible','on') |
---|
| 3885 | set(handles.ref_i_civ2,'Visible','on') |
---|
| 3886 | set(handles.i_ref_civ2_title,'Visible','on') |
---|
| 3887 | set(handles.j_ref_civ2_title,'Visible','on') |
---|
| 3888 | set(handles.ref_j_civ2,'Visible','on') |
---|
[2] | 3889 | end |
---|
[71] | 3890 | set(handles.rho_civ2_title,'Visible',state) |
---|
[2] | 3891 | |
---|
[12] | 3892 | %------------------------------------------------------------------------ |
---|
[2] | 3893 | function enable_fix2(handles) |
---|
[12] | 3894 | %------------------------------------------------------------------------ |
---|
[2] | 3895 | set(handles.frame_fix2,'BackgroundColor',[1 1 0]) |
---|
| 3896 | set(handles.REMOVE2,'Visible','on') |
---|
| 3897 | set(handles.vec_Fmin2_2,'Visible','on') |
---|
| 3898 | set(handles.vec_F4,'Visible','on') |
---|
| 3899 | set(handles.vec_F3_2,'Visible','on') |
---|
| 3900 | set(handles.thresh_vec2C,'Visible','on') |
---|
| 3901 | set(handles.thresh_vec2C_text,'Visible','on') |
---|
| 3902 | set(handles.thresh_vel2,'Visible','on') |
---|
| 3903 | set(handles.thresh_vel2_text,'Visible','on') |
---|
| 3904 | set(handles.mask_fix2,'Visible','on') |
---|
| 3905 | set(handles.get_mask_fix2,'Visible','on') |
---|
| 3906 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 3907 | set(handles.subdir_civ2,'Visible','on') |
---|
| 3908 | set(handles.subdir_civ2_text,'Visible','on') |
---|
| 3909 | set(handles.get_ref_fix2,'Visible','on') |
---|
| 3910 | set(handles.ref_fix2,'Visible','on') |
---|
| 3911 | set(handles.inf_sup2,'Visible','on') |
---|
| 3912 | set(handles.field_ref2,'Visible','on') |
---|
| 3913 | |
---|
[12] | 3914 | %------------------------------------------------------------------------ |
---|
[2] | 3915 | function desable_fix2(handles) |
---|
[12] | 3916 | %------------------------------------------------------------------------ |
---|
[2] | 3917 | set(handles.frame_fix2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3918 | set(handles.REMOVE2,'Visible','off') |
---|
| 3919 | set(handles.vec_Fmin2_2,'Visible','off') |
---|
| 3920 | set(handles.vec_F4,'Visible','off') |
---|
| 3921 | set(handles.vec_F3_2,'Visible','off') |
---|
| 3922 | set(handles.thresh_vec2C,'Visible','off') |
---|
| 3923 | set(handles.thresh_vec2C_text,'Visible','off') |
---|
| 3924 | set(handles.thresh_vel2,'Visible','off') |
---|
| 3925 | set(handles.thresh_vel2_text,'Visible','off') |
---|
| 3926 | set(handles.mask_fix2,'Visible','off') |
---|
| 3927 | set(handles.get_mask_fix2,'Visible','off') |
---|
| 3928 | set(handles.get_ref_fix2,'Visible','off') |
---|
| 3929 | set(handles.ref_fix2,'Visible','off') |
---|
| 3930 | set(handles.inf_sup2,'Visible','off') |
---|
| 3931 | set(handles.field_ref2,'Visible','off') |
---|
[112] | 3932 | if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) |
---|
[2] | 3933 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 3934 | set(handles.subdir_civ2,'Visible','off') |
---|
| 3935 | set(handles.subdir_civ2_text,'Visible','off') |
---|
| 3936 | end |
---|
| 3937 | |
---|
[12] | 3938 | %------------------------------------------------------------------------ |
---|
[2] | 3939 | function enable_patch2(handles) |
---|
[12] | 3940 | %------------------------------------------------------------------------ |
---|
[2] | 3941 | set(handles.frame_patch2,'BackgroundColor',[1 1 0]) |
---|
[119] | 3942 | set(handles.rho_patch2,'Visible','on') |
---|
[2] | 3943 | set(handles.rho_text2,'Visible','on') |
---|
| 3944 | set(handles.thresh_patch2,'Visible','on') |
---|
| 3945 | set(handles.thresh_text2,'Visible','on') |
---|
| 3946 | set(handles.subdomain_patch2,'Visible','on') |
---|
| 3947 | set(handles.subdomain_text2,'Visible','on') |
---|
| 3948 | set(handles.nx_patch2,'Visible','on') |
---|
| 3949 | set(handles.ny_patch2,'Visible','on') |
---|
| 3950 | set(handles.nx_patch2_title,'Visible','on') |
---|
| 3951 | set(handles.ny_patch2_title,'Visible','on') |
---|
[252] | 3952 | % set(handles.get_gridpatch2,'Visible','on') |
---|
| 3953 | % set(handles.grid_patch2,'Visible','on') |
---|
[2] | 3954 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 3955 | set(handles.subdir_civ2,'Visible','on') |
---|
| 3956 | set(handles.subdir_civ2_text,'Visible','on') |
---|
[252] | 3957 | stereo_test=get(handles.compare,'Value'); |
---|
| 3958 | if stereo_test==3 |
---|
| 3959 | set(handles.test_stereo2,'Visible','on') |
---|
| 3960 | end |
---|
[2] | 3961 | |
---|
[12] | 3962 | %------------------------------------------------------------------------ |
---|
[2] | 3963 | function desable_patch2(handles) |
---|
[12] | 3964 | %------------------------------------------------------------------------ |
---|
[2] | 3965 | set(handles.frame_patch2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3966 | set(handles.rho_patch2,'Visible','off') |
---|
| 3967 | set(handles.rho_text2,'Visible','off') |
---|
| 3968 | set(handles.thresh_patch2,'Visible','off') |
---|
| 3969 | set(handles.thresh_text2,'Visible','off') |
---|
| 3970 | set(handles.subdomain_patch2,'Visible','off') |
---|
| 3971 | set(handles.subdomain_text2,'Visible','off') |
---|
| 3972 | set(handles.nx_patch2,'Visible','off') |
---|
| 3973 | set(handles.ny_patch2,'Visible','off') |
---|
| 3974 | set(handles.nx_patch2_title,'Visible','off') |
---|
| 3975 | set(handles.ny_patch2_title,'Visible','off') |
---|
[252] | 3976 | % set(handles.get_gridpatch2,'Visible','off') |
---|
| 3977 | % set(handles.grid_patch2,'Visible','off') |
---|
[112] | 3978 | if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.FIX2,'Value'),0) |
---|
[2] | 3979 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 3980 | set(handles.subdir_civ2,'Visible','off') |
---|
| 3981 | set(handles.subdir_civ2_text,'Visible','off') |
---|
| 3982 | end |
---|
[252] | 3983 | set(handles.test_stereo2,'Visible','off') |
---|
[12] | 3984 | %------------------------------------------------------------------------ |
---|
[2] | 3985 | function enable_pair1(handles,state) |
---|
[12] | 3986 | %------------------------------------------------------------------------ |
---|
[2] | 3987 | set(handles.subdir_civ1,'Visible',state) |
---|
| 3988 | set(handles.list_subdir_civ1,'Visible',state) |
---|
| 3989 | set(handles.SUBDIR_CIV1_txt,'Visible',state) |
---|
| 3990 | set(handles.frame_subdirciv1,'Visible',state) |
---|
| 3991 | set(handles.list_pair_civ1,'Visible',state) |
---|
| 3992 | set(handles.PAIR_txt,'Visible',state) |
---|
[71] | 3993 | %set(handles.dt_unit,'Visible',state) |
---|
[2] | 3994 | set(handles.PAIR_frame,'Visible',state) |
---|
| 3995 | |
---|
[12] | 3996 | %------------------------------------------------------------------------ |
---|
| 3997 | % --- Read the parameters for civ1 on the interface |
---|
[2] | 3998 | function par=read_param_civ1(handles,file_ima) |
---|
[12] | 3999 | %------------------------------------------------------------------------ |
---|
[127] | 4000 | ibx_val=str2double(get(handles.ibx,'String')); |
---|
[2] | 4001 | par.ibx=num2str(ibx_val); |
---|
[127] | 4002 | iby_val=str2double(get(handles.iby,'String')); |
---|
[2] | 4003 | par.iby=num2str(iby_val); |
---|
| 4004 | isx=get(handles.isx,'String'); |
---|
[127] | 4005 | if isnan(str2double(isx)), isx='41'; set(handles.isx,'String','41'), end; %default |
---|
| 4006 | if str2double(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.isx,'String',num2str(ibx_val+8)); end |
---|
[2] | 4007 | isy=get(handles.isy,'String'); |
---|
[127] | 4008 | if isnan(str2double(isy)), isy='41'; set(handles.isy,'String','41'), end;%default |
---|
| 4009 | if str2double(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.isy,'String',num2str(iby_val+8)); end |
---|
[2] | 4010 | par.isx=get(handles.isx,'String'); |
---|
| 4011 | par.isy=get(handles.isy,'String'); |
---|
| 4012 | par.shiftx=get(handles.shiftx,'String'); |
---|
| 4013 | par.shifty=get(handles.shifty,'String'); |
---|
[127] | 4014 | if isnan(str2double(par.isx)) |
---|
[112] | 4015 | par.isx='41';%default |
---|
| 4016 | set(handles.isx,'String','41'); |
---|
[2] | 4017 | end |
---|
[127] | 4018 | if isnan(str2double(par.isy)) |
---|
[112] | 4019 | par.isy='41'; %default |
---|
| 4020 | set(handles.isy,'String','41'); |
---|
[12] | 4021 | end |
---|
[127] | 4022 | if isnan(str2double(par.shiftx)) |
---|
[112] | 4023 | par.shiftx='0';%default |
---|
| 4024 | set(handles.shiftx,'String','0'); |
---|
| 4025 | end |
---|
[127] | 4026 | if isnan(str2double(par.shifty)) |
---|
[112] | 4027 | par.shifty='0'; %default |
---|
| 4028 | set(handles.shifty,'String','0'); |
---|
[12] | 4029 | end |
---|
[112] | 4030 | par.rho=get(handles.rho,'String'); |
---|
[238] | 4031 | if isequal(get(handles.rho,'Style'),'popupmenu') |
---|
| 4032 | index=get(handles.rho,'Value'); |
---|
| 4033 | par.rho=par.rho{index}; |
---|
| 4034 | end |
---|
[112] | 4035 | par.dx=get(handles.dx_civ1,'String'); |
---|
| 4036 | par.dy=get(handles.dy_civ1,'String'); |
---|
[127] | 4037 | if isnan(str2double(par.dx)) |
---|
[112] | 4038 | if isempty(get(handles.grid_civ1,'String')); |
---|
| 4039 | par.dx='0'; %just read by civ program, not used |
---|
| 4040 | else |
---|
[12] | 4041 | par.dx='20';%default |
---|
| 4042 | set(handles.dx_civ1,'String','20'); |
---|
[112] | 4043 | end |
---|
| 4044 | end |
---|
[127] | 4045 | if isnan(str2double(par.dy)) |
---|
[112] | 4046 | if isempty(get(handles.grid_civ1,'String')); |
---|
| 4047 | par.dy='0';%just read by civ program, not used |
---|
| 4048 | else |
---|
[12] | 4049 | par.dy='20';%default |
---|
| 4050 | set(handles.dy_civ1_title,'String','20'); |
---|
[112] | 4051 | end |
---|
| 4052 | end |
---|
| 4053 | par.pxcmx='1'; %velocities are expressed in pixel dispalcement |
---|
| 4054 | par.pxcmy='1'; |
---|
[150] | 4055 | if exist('file_ima','var') |
---|
[112] | 4056 | A=imread(file_ima);%read the first image to get the size |
---|
| 4057 | sizim=size(A); |
---|
| 4058 | par.npx=num2str(sizim(2)); |
---|
| 4059 | par.npy=num2str(sizim(1)); |
---|
[150] | 4060 | end |
---|
[127] | 4061 | %time=get(handles.RootName,'UserData'); %get the set of times |
---|
[112] | 4062 | par.gridname=get(handles.grid_civ1,'String'); |
---|
| 4063 | par.gridflag='y'; |
---|
[127] | 4064 | if strcmp(par.gridname,'')|| isempty(par.gridname) |
---|
[112] | 4065 | par.gridname='nogrid'; |
---|
| 4066 | par.gridflag='n'; |
---|
| 4067 | end |
---|
[12] | 4068 | |
---|
| 4069 | %------------------------------------------------------------------------ |
---|
[2] | 4070 | function par=read_param_civ2(handles,file_ima) |
---|
[12] | 4071 | %------------------------------------------------------------------------ |
---|
| 4072 | par.ibx=get(handles.ibx_civ2,'String'); |
---|
| 4073 | par.iby=get(handles.iby_civ2,'String'); |
---|
| 4074 | par.rho=get(handles.rho_civ2,'String'); |
---|
| 4075 | par.decimal=int2str(get(handles.decimal,'Value')); |
---|
| 4076 | par.deformation=int2str(get(handles.deformation,'Value')); |
---|
| 4077 | par.dx=get(handles.dx_civ2,'String'); |
---|
| 4078 | par.dy=get(handles.dy_civ2,'String'); |
---|
[127] | 4079 | if isnan(str2double(par.dx)) |
---|
[112] | 4080 | if isempty(get(handles.grid_civ2,'String')); |
---|
| 4081 | par.dx='0'; %just read by civ program, not used |
---|
| 4082 | else |
---|
[12] | 4083 | par.dx='20';%default |
---|
| 4084 | set(handles.dx_civ2,'String','20'); |
---|
[112] | 4085 | end |
---|
| 4086 | end |
---|
[127] | 4087 | if isnan(str2double(par.dy)) |
---|
[112] | 4088 | if isempty(get(handles.grid_civ2,'String')); |
---|
| 4089 | par.dy='0';%just read by civ program, not used |
---|
| 4090 | else |
---|
[12] | 4091 | par.dy='20';%default |
---|
| 4092 | set(handles.dy_civ2,'String','20'); |
---|
[112] | 4093 | end |
---|
| 4094 | end |
---|
| 4095 | par.pxcmx='1'; |
---|
| 4096 | par.pxcmy='1'; |
---|
[12] | 4097 | A=imread(file_ima);%read the first image to get the size |
---|
| 4098 | sizim=size(A); |
---|
| 4099 | par.npx=num2str(sizim(2)); |
---|
| 4100 | par.npy=num2str(sizim(1)); |
---|
[127] | 4101 | %time=get(handles.RootName,'UserData'); %get the set of times |
---|
[12] | 4102 | par.gridname=get(handles.grid_civ2,'String'); |
---|
| 4103 | par.gridflag='y'; |
---|
[127] | 4104 | if strcmp(par.gridname,'')|| isempty(par.gridname) |
---|
[12] | 4105 | par.gridname='nogrid'; |
---|
| 4106 | par.gridflag='n'; |
---|
| 4107 | end |
---|
[2] | 4108 | |
---|
[12] | 4109 | %------------------------------------------------------------------------ |
---|
| 4110 | % --- CIV1 CIV1 CIV1 CIV1 |
---|
[94] | 4111 | function cmd_CIV1=CIV1_CMD(filename,namelog,par,handles,sparam) |
---|
[12] | 4112 | %------------------------------------------------------------------------ |
---|
[2] | 4113 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 4114 | |
---|
| 4115 | %changes : filename_cmx -> filename ( no extension ) |
---|
[174] | 4116 | % input namelog not used |
---|
[112] | 4117 | if isequal(par.Dt,'0') |
---|
| 4118 | par.Dt='1' ;%case of 'displacement' mode |
---|
| 4119 | end |
---|
[90] | 4120 | par.filename_ima_a=regexprep(par.filename_ima_a,'.png',''); |
---|
[94] | 4121 | par.filename_ima_b=regexprep(par.filename_ima_b,'.png',''); |
---|
[230] | 4122 | fid=fopen([filename '.civ1.cmx'],'w'); |
---|
[12] | 4123 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
[112] | 4124 | fprintf(fid, ['FirstImage ' regexprep(par.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4125 | fprintf(fid, ['LastImage ' regexprep(par.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4126 | fprintf(fid, ['XX' '\n' ]); |
---|
| 4127 | fprintf(fid, ['Mask ' par.maskflag '\n' ]); |
---|
| 4128 | fprintf(fid, ['MaskName ' regexprep(par.maskname,'\\','\\\\') '\n' ]); |
---|
| 4129 | fprintf(fid, ['ImageSize ' par.npx ' ' par.npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 4130 | fprintf(fid, ['CorrelationBoxesSize ' par.ibx ' ' par.iby '\n' ]); |
---|
| 4131 | fprintf(fid, ['SearchBoxeSize ' par.isx ' ' par.isy '\n' ]); |
---|
| 4132 | fprintf(fid, ['RO ' par.rho '\n' ]); |
---|
| 4133 | fprintf(fid, ['GridSpacing ' par.dx ' ' par.dy '\n' ]); |
---|
| 4134 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4135 | fprintf(fid, ['Dt_TO ' par.Dt ' ' par.T0 '\n' ]); |
---|
| 4136 | fprintf(fid, ['PixCmXY ' par.pxcmx ' ' par.pxcmy '\n' ]); |
---|
| 4137 | fprintf(fid, ['XX 1' '\n' ]); |
---|
| 4138 | fprintf(fid, ['ShiftXY ' par.shiftx ' ' par.shifty '\n' ]); |
---|
| 4139 | fprintf(fid, ['Grid ' par.gridflag '\n' ]); |
---|
| 4140 | fprintf(fid, ['GridName ' regexprep(par.gridname,'\\','\\\\') '\n' ]); |
---|
| 4141 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 4142 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4143 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4144 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
| 4145 | fprintf(fid, [ 'DecimalShift 0' '\n' ]); |
---|
| 4146 | fprintf(fid, ['Deformation 0' '\n' ]); |
---|
| 4147 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 4148 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 4149 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 4150 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
| 4151 | fprintf(fid, ['ImageToUse ' par.term_a ' ' par.term_b '\n' ]); % VERIFIER ? |
---|
| 4152 | fprintf(fid, ['ImageUsedBefore null null' '\n' ]); |
---|
[12] | 4153 | fclose(fid); |
---|
[112] | 4154 | |
---|
[163] | 4155 | % cmd_CIV1=[sparam.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file |
---|
| 4156 | % cmd_CIV1=regexprep(cmd_CIV1,'\\','\\\\'); |
---|
| 4157 | % namelog=regexprep(namelog,'\\','\\\\'); |
---|
[12] | 4158 | if(isunix) |
---|
[230] | 4159 | cmd_CIV1=['cp -f ' filename '.civ1.cmx ' filename '.cmx\n']; |
---|
| 4160 | 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] | 4161 | 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] | 4162 | % cmd_CIV1=[cmd_CIV1 '\n' 'mv ' filename '.cmx' ' ' filename '.civ1.cmx' '\n'];%rename .cmx as .civ1.cmx |
---|
[163] | 4163 | else %Windows system |
---|
[230] | 4164 | flname=regexprep(flname,'\\','\\\\'); |
---|
| 4165 | % cmd=[cmd 'copy /Y "' flname '.civ1.cmx" "' flname '.cmx"\n']; |
---|
[174] | 4166 | filename=regexprep(filename,'\\','\\\\'); |
---|
[230] | 4167 | cmd_CIV1=['copy /Y "' filename '.civ1.cmx" "' filename '.cmx"\n'];% copy the .civ1.cmx parameter file to .cmx |
---|
[163] | 4168 | cmd_CIV1=['"' sparam.Civ1Bin '" -f "' filename '.cmx" >"' filename '.log"' ]; % redirect standard output to the log file |
---|
| 4169 | cmd_CIV1=regexprep(cmd_CIV1,'\\','\\\\'); |
---|
| 4170 | namelog=regexprep(namelog,'\\','\\\\'); |
---|
[230] | 4171 | cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y "' filename '.log' '" "' filename '.civ1.log"']; %preserve the log file as .civ1.log |
---|
| 4172 | % cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y "' filename '.cmx' '" "' filename '.civ1.cmx"']; |
---|
[12] | 4173 | end |
---|
[2] | 4174 | |
---|
[12] | 4175 | %------------------------------------------------------------------------ |
---|
| 4176 | % --- CIV1 Unified |
---|
[94] | 4177 | function xml_civ1_parameters=CIV1_CMD_Unified(filename,namelog,par) |
---|
[12] | 4178 | %------------------------------------------------------------------------ |
---|
[2] | 4179 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
[73] | 4180 | %global CivBin%name of the executable for civ1 calculation |
---|
[2] | 4181 | |
---|
[112] | 4182 | civ1.image1=par.filename_ima_a; |
---|
| 4183 | civ1.image2=par.filename_ima_b; |
---|
| 4184 | civ1.imageSize_X=par.npx; |
---|
| 4185 | civ1.imageSize_Y=par.npy; |
---|
| 4186 | civ1.outputFileName=[filename '.nc']; |
---|
| 4187 | civ1.correlationBoxesSize_X=par.ibx; |
---|
| 4188 | civ1.correlationBoxesSize_Y=par.iby; |
---|
| 4189 | civ1.searchBoxesSize_X=par.isx; |
---|
| 4190 | civ1.searchBoxesSize_Y=par.isy; |
---|
| 4191 | civ1.globalShift_X=par.shiftx; |
---|
| 4192 | civ1.globalShift_Y=par.shifty; |
---|
| 4193 | civ1.ro=par.rho; |
---|
| 4194 | civ1.hart='y'; |
---|
| 4195 | if isequal(par.gridflag,'y') |
---|
| 4196 | civ1.grid=par.gridname; |
---|
| 4197 | else |
---|
| 4198 | civ1.grid='n'; |
---|
| 4199 | civ1.gridSpacing_X=par.dx; |
---|
| 4200 | civ1.gridSpacing_Y=par.dy; |
---|
| 4201 | end |
---|
| 4202 | if isequal(par.maskflag,'y') |
---|
| 4203 | civ1.mask=par.maskname; |
---|
| 4204 | end |
---|
[229] | 4205 | civ1.dt=par.Dt; |
---|
[112] | 4206 | civ1.unit='pixel'; |
---|
| 4207 | civ1.absolut_time_T0=par.T0; |
---|
| 4208 | civ1.pixcmx=par.pxcmx; |
---|
| 4209 | civ1.pixcmy=par.pxcmy; |
---|
| 4210 | civ1.convectFlow='n'; |
---|
[12] | 4211 | |
---|
[112] | 4212 | xml_civ1_parameters=civ1; |
---|
| 4213 | |
---|
[12] | 4214 | %------------------------------------------------------------------------ |
---|
| 4215 | % --- CIV2 Unified |
---|
[94] | 4216 | function civ2=CIV2_CMD_Unified(filename,namelog,par) |
---|
[12] | 4217 | %--- |
---|