[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); |
---|
| 64 | |
---|
| 65 | %default initial parameters |
---|
| 66 | filebase=''; % root file name ('filebase'.civ) |
---|
| 67 | ext=[]; |
---|
[112] | 68 | testall=0; |
---|
[71] | 69 | %default input parameters: |
---|
[153] | 70 | num_i1=1; % set of field i numbers |
---|
| 71 | num_i2=1; % set of field i numbers |
---|
| 72 | num_j1=1; % set of field j numbers (fields a) |
---|
| 73 | num_j2=1; % second set of field j numbers (fields b) |
---|
[71] | 74 | subdir='A'; % subdir for the netcdf result files |
---|
[112] | 75 | ind_opening=1; % proposed operation number (1=civ1,2=fix1,3=patch1,4=civ2,5=fix2,6=patch2) |
---|
| 76 | %load the initial parameters if the interface is started from uvmat |
---|
[71] | 77 | if exist('param','var')&&isstruct(param)% the interface is opened from uvmat |
---|
| 78 | filebase=param.RootName; |
---|
| 79 | nom_type_read=param.NomType; |
---|
[153] | 80 | num_i1=param.num1; |
---|
| 81 | if isnan(num_i1),num_i1=1;end |
---|
| 82 | num_i2=param.num2; |
---|
| 83 | if isnan(num_i2),num_i2=num_i1;end |
---|
| 84 | num_j1=param.num_a; |
---|
| 85 | if isnan(num_j1),num_j1=1;end |
---|
| 86 | num_j2=param.num_b; |
---|
| 87 | if isnan(num_j2),num_j2=num_j1;end |
---|
[71] | 88 | subdir=param.SubDir; |
---|
| 89 | ind_opening=param.IndOpening; |
---|
| 90 | ext=param.ImaExt; |
---|
[2] | 91 | end |
---|
[153] | 92 | browse.num_i1=num_i1; |
---|
| 93 | browse.num_i2=num_i2; |
---|
| 94 | browse.num_j1=num_j1; |
---|
| 95 | browse.num_j2=num_j2; |
---|
[122] | 96 | if ~isempty(ext) && (~isempty(imformats(ext(2:end)))||strcmpi(ext,'.avi'));%if an image file has been opened by uvmat |
---|
[112] | 97 | set(handles.ImaExt,'String',ext) |
---|
[128] | 98 | browse.ext_ima=ext; |
---|
[112] | 99 | if exist('nom_type_read','var') |
---|
| 100 | browse.nom_type_ima=nom_type_read; % the image nomenclature is stored |
---|
| 101 | end |
---|
[2] | 102 | elseif isequal(ext,'.nc') |
---|
| 103 | if exist('nom_type_read','var') |
---|
| 104 | browse.nom_type_nc=nom_type_read;% the netcdf nomenclature is stored |
---|
| 105 | end |
---|
| 106 | end |
---|
[71] | 107 | set(handles.RootName,'String',filebase); |
---|
[2] | 108 | set(handles.ImaDoc,'UserData',testall); |
---|
| 109 | set(handles.ImaDoc,'String',ext) |
---|
| 110 | |
---|
[122] | 111 | %read names of the .exe file to adjust the interface according to available binaries |
---|
[2] | 112 | path_uvmat=which('uvmat');% check the path detected for source file uvmat |
---|
| 113 | path_UVMAT=fileparts(path_uvmat); %path to UVMAT |
---|
[45] | 114 | errormsg=[];%default error message |
---|
[111] | 115 | % xmlfile=fullfile(path_UVMAT,'PARAM.xml'); |
---|
| 116 | % if ~exist(xmlfile,'file') |
---|
[112] | 117 | xmlfile='PARAM.xml'; |
---|
[111] | 118 | % end |
---|
[54] | 119 | if exist(xmlfile,'file') |
---|
| 120 | try |
---|
[112] | 121 | t=xmltree(xmlfile); |
---|
| 122 | sparam=convert(t); |
---|
[54] | 123 | catch |
---|
[112] | 124 | errormsg={' Unable to read the file PARAM.xml defining the civx binaries:'; lasterr}; |
---|
[227] | 125 | return |
---|
[2] | 126 | end |
---|
[54] | 127 | else |
---|
| 128 | errormsg=[xmlfile ' not found: path to civx binaries undefined']; |
---|
[227] | 129 | return |
---|
[2] | 130 | end |
---|
[71] | 131 | |
---|
[110] | 132 | |
---|
[45] | 133 | if ~isempty(errormsg) |
---|
[112] | 134 | msgbox_uvmat('ERROR',errormsg); |
---|
[45] | 135 | end |
---|
[71] | 136 | % patch_newBin=''; |
---|
| 137 | test_batch=0;%default: ,no batch mode available |
---|
| 138 | if isfield(sparam,'BatchParam') && isfield(sparam.BatchParam,'BatchMode') |
---|
| 139 | test_batch=strcmp(sparam.BatchParam.BatchMode,'sge'); %sge is currently the only implemented batch mod |
---|
[2] | 140 | end |
---|
| 141 | if test_batch==0 |
---|
[84] | 142 | set(handles.BATCH,'Enable','off')% put the BATCH button in grey (unactivated) |
---|
[2] | 143 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784])% put the BATCH button in grey (unactivated) |
---|
| 144 | end |
---|
[94] | 145 | if isfield(sparam.RunParam,'CivBin') |
---|
| 146 | if ~exist(sparam.RunParam.CivBin,'file') |
---|
[112] | 147 | sparam.RunParam.CivBin=fullfile(path_UVMAT,sparam.RunParam.CivBin); |
---|
[94] | 148 | end |
---|
[97] | 149 | else |
---|
| 150 | sparam.RunParam.CivBin=''; |
---|
[94] | 151 | end |
---|
[96] | 152 | patch_newBin=exist(sparam.RunParam.CivBin,'file'); |
---|
[2] | 153 | set(handles.subdir_civ1,'String',subdir)%default subdir on which uvmat was working |
---|
| 154 | set(handles.subdir_civ2,'String',subdir)%default subdir on which uvmat was working |
---|
| 155 | |
---|
| 156 | %initiate advised operations |
---|
| 157 | if isequal(ind_opening,[]) |
---|
| 158 | ind_opening=1; % default |
---|
| 159 | end |
---|
| 160 | % set default operation options |
---|
[112] | 161 | enable_civ1(handles,'off') |
---|
| 162 | enable_civ2(handles,'off') |
---|
| 163 | enable_pair1(handles,'on') |
---|
| 164 | enable_fix1(handles,'off') |
---|
| 165 | desable_patch1(handles) |
---|
| 166 | desable_fix2(handles) |
---|
| 167 | desable_patch2(handles) |
---|
| 168 | set(handles.CIV1,'Value',0) |
---|
| 169 | set(handles.FIX1,'Value',0) |
---|
| 170 | set(handles.PATCH1,'Value',0) |
---|
| 171 | set(handles.CIV2,'Value',0) |
---|
| 172 | set(handles.FIX2,'Value',0) |
---|
| 173 | set(handles.PATCH2,'Value',0) |
---|
| 174 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[2] | 175 | if isequal(ind_opening,1) |
---|
| 176 | set(handles.CIV1,'Value',1) |
---|
| 177 | enable_civ1(handles,'on') |
---|
| 178 | elseif isequal(ind_opening,2) |
---|
| 179 | set(handles.FIX1,'Value',1) |
---|
| 180 | enable_fix1(handles,'on') |
---|
| 181 | elseif isequal(ind_opening,3) |
---|
| 182 | set(handles.PATCH1,'Value',1) |
---|
| 183 | enable_patch1(handles) |
---|
| 184 | elseif isequal(ind_opening,4) |
---|
| 185 | set(handles.CIV2,'Value',1) |
---|
[224] | 186 | enable_civ2(handles,'on') |
---|
[2] | 187 | elseif isequal(ind_opening,5) |
---|
| 188 | set(handles.FIX2,'Value',1) |
---|
| 189 | enable_fix2(handles) |
---|
[112] | 190 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 191 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 192 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 193 | enable_pair1(handles,'off') |
---|
[2] | 194 | elseif isequal(ind_opening,6) |
---|
| 195 | set(handles.PATCH2,'Value',1) |
---|
| 196 | enable_patch2(handles) |
---|
| 197 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 198 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 199 | enable_pair1(handles,'off') |
---|
| 200 | end |
---|
| 201 | |
---|
| 202 | % set the range of fields (1:1 by default) and selected pair |
---|
[153] | 203 | if isequal(num_i2,num_i1) |
---|
| 204 | num_ref_i=num_i1; |
---|
[2] | 205 | else |
---|
[153] | 206 | num_ref_i=floor((num_i1+num_i2)/2); |
---|
| 207 | browse.incr_pair(1)=num_i2-num_i1; |
---|
[2] | 208 | browse.incr_pair(2)=0; |
---|
| 209 | end |
---|
[153] | 210 | if isequal(num_j1,num_j2) |
---|
| 211 | if isnan(num_j1) |
---|
[2] | 212 | num_ref_j=1; |
---|
| 213 | else |
---|
[153] | 214 | num_ref_j=num_j1; |
---|
[2] | 215 | end |
---|
| 216 | else |
---|
[153] | 217 | num_ref_j=floor((num_j1+num_j2)/2); |
---|
| 218 | browse.incr_pair(2)=num_j2-num_j1; |
---|
[2] | 219 | end |
---|
| 220 | set(handles.first_i,'String',num2str(num_ref_i)); |
---|
| 221 | set(handles.last_i,'String',num2str(num_ref_i)); |
---|
| 222 | set(handles.first_j,'String',num2str(num_ref_j)); |
---|
| 223 | set(handles.last_j,'String',num2str(num_ref_j)); |
---|
| 224 | set(handles.ref_i,'String',num2str(num_ref_i)); |
---|
| 225 | set(handles.ref_j,'String',num2str(num_ref_j)); |
---|
[71] | 226 | set(handles.ref_i_civ2,'String',num2str(num_ref_i)); |
---|
| 227 | set(handles.ref_j_civ2,'String',num2str(num_ref_j)); |
---|
[2] | 228 | set(handles.browse_root,'UserData',browse); |
---|
[220] | 229 | if exist('param','var') && isfield(param,'RootName') && ~isempty(param.RootName)%varargin the interface is opened from uvmat |
---|
[112] | 230 | RootName_Callback(hObject, eventdata, handles); |
---|
[2] | 231 | end |
---|
| 232 | |
---|
[150] | 233 | % set(handles.waitbar_1,'Position',[0.946 0.877 0.03 0.001]) |
---|
| 234 | % set(handles.waitbar_patch1,'Position',[0.946 0.626 0.03 0.001]) |
---|
| 235 | % set(handles.waitbar_civ2,'Position',[0.946 0.406 0.03 0.001]) |
---|
| 236 | % set(handles.waitbar_patch2,'Position',[0.946 0.187 0.03 0.001]) |
---|
[2] | 237 | |
---|
[12] | 238 | %------------------------------------------------------------------------ |
---|
[2] | 239 | % --- Outputs from this function are returned to the command line. |
---|
| 240 | function varargout = civ_OutputFcn(hObject, eventdata, handles) |
---|
[12] | 241 | %------------------------------------------------------------------------ |
---|
[2] | 242 | % varargout cell array for returning output args (see VARARGOUT); |
---|
| 243 | % hObject handle to figure |
---|
| 244 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 245 | % handles structure with handles and user data (see GUIDATA) |
---|
| 246 | % Get default command line output from handles structure |
---|
| 247 | varargout{1} = handles.output; |
---|
| 248 | |
---|
[12] | 249 | %------------------------------------------------------------------------ |
---|
[2] | 250 | % --- Executes on button press in browse_root. |
---|
| 251 | function browse_root_Callback(hObject, eventdata, handles) |
---|
[12] | 252 | %------------------------------------------------------------------------ |
---|
[2] | 253 | %get the input file properties |
---|
[71] | 254 | filebase=get(handles.RootName,'String'); |
---|
[2] | 255 | oldfile=''; %default |
---|
[39] | 256 | if isempty(filebase)|| isequal(filebase,'')%loads the previously stored file name and set it as default in the file_input box |
---|
[112] | 257 | dir_perso=prefdir; |
---|
| 258 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 259 | if exist(profil_perso,'file') |
---|
| 260 | h=load (profil_perso); |
---|
| 261 | if isfield(h,'filebase')&& ischar(h.filebase) |
---|
| 262 | oldfile=h.filebase; |
---|
| 263 | end |
---|
| 264 | if isfield(h,'RootPath') && ischar(h.RootPath) |
---|
| 265 | oldfile=h.RootPath; |
---|
| 266 | end |
---|
| 267 | end |
---|
| 268 | else |
---|
| 269 | oldfile=filebase; |
---|
| 270 | end |
---|
[174] | 271 | % testall=get(handles.ImaDoc,'UserData'); |
---|
[2] | 272 | ind_opening=1;%default |
---|
| 273 | browse.incr_pair=[0 0]; %default |
---|
[174] | 274 | % if testall |
---|
| 275 | % menu={'*.*', 'All Files (*.*)'; '*.xml; *.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ... |
---|
| 276 | % '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc','.nc files'}; |
---|
| 277 | % else % menu selecting only .civ or .avi files |
---|
| 278 | menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)'; |
---|
| 279 | '*.xml', '.xml files '; ... |
---|
| 280 | '*.civ', '.civ files '; ... |
---|
| 281 | '*.png','.png image files'; ... |
---|
| 282 | '*.jpg',' jpeg image files'; ... |
---|
| 283 | '*.tif','.tif image files'; ... |
---|
| 284 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 285 | '*.nc','.netcdf files'; ... |
---|
| 286 | '*.*', 'All Files (*.*)'}; |
---|
| 287 | % menu={'*.xml;*.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ... |
---|
| 288 | % '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc', '.nc files';... |
---|
| 289 | % '*.*', 'All Files (*.*)'}; |
---|
| 290 | % end |
---|
[2] | 291 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile); |
---|
[112] | 292 | fileinput=[PathName FileName];%complete file name |
---|
[2] | 293 | sizf=size(fileinput); |
---|
| 294 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
| 295 | [path,name,ext]=fileparts(fileinput); |
---|
| 296 | testeditxml=0; |
---|
| 297 | if isequal(ext,'.xml') |
---|
| 298 | testeditxml=1; |
---|
| 299 | t_browse=xmltree(fileinput); |
---|
| 300 | head_element=get(t_browse,1); |
---|
[45] | 301 | if isfield(head_element,'name')&& isequal(head_element.name,'ImaDoc') |
---|
[2] | 302 | testeditxml=0; |
---|
| 303 | end |
---|
| 304 | end |
---|
[45] | 305 | if testeditxml==1 || isequal(ext,'.xls') |
---|
[112] | 306 | heditxml=editxml({fileinput}); |
---|
| 307 | set(heditxml,'Tag','browser') |
---|
| 308 | waitfor(heditxml,'Tag','idle') |
---|
| 309 | if ~ishandle(heditxml) |
---|
| 310 | return |
---|
| 311 | end |
---|
| 312 | attr=findobj(get(heditxml,'children'),'Tag','CurrentAttributes'); |
---|
| 313 | set(handles.browse,'UserData',fileinput)% store for future opening with browser |
---|
| 314 | fileinput=get(attr,'UserData'); |
---|
| 315 | if ~exist(fileinput,'file') |
---|
| 316 | return |
---|
| 317 | end |
---|
[2] | 318 | end |
---|
[82] | 319 | [RootPath,RootFile,str1,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput); |
---|
[2] | 320 | filebase=fullfile(RootPath,RootFile); |
---|
[89] | 321 | num_i1=str2double(str1); |
---|
| 322 | if isnan(num_i1),num_i1=1;end |
---|
| 323 | num_i2=str2double(str2); |
---|
| 324 | if isnan(num_i2),num_i2=num_i1;end |
---|
[54] | 325 | num_j1=stra2num(str_a); |
---|
[89] | 326 | if isnan(num_j1),num_j1=1;end |
---|
[54] | 327 | num_j2=stra2num(str_b); |
---|
[112] | 328 | if isnan(num_j2),num_j2=num_j1;end |
---|
[2] | 329 | if isequal(get(handles.compare,'Value'),1) |
---|
| 330 | browse=[];%initialisation |
---|
| 331 | else |
---|
| 332 | browse=get(handles.browse_root,'UserData'); |
---|
| 333 | end |
---|
[122] | 334 | browse.num_i1=num_i1; |
---|
| 335 | browse.num_i2=num_i2; |
---|
| 336 | browse.num_j1=num_j1; |
---|
| 337 | browse.num_j2=num_j2; |
---|
| 338 | if length(ext)>1 && (~isempty(imformats(ext(2:end)))||strcmpi(ext,'.avi'));%if an image file has been opened by uvmat |
---|
[2] | 339 | browse.nom_type_ima=nom_type; |
---|
[122] | 340 | browse.ext_ima=ext; |
---|
[177] | 341 | set(handles.ImaExt,'String',ext) |
---|
[2] | 342 | end |
---|
| 343 | set(handles.ImaDoc,'String',ext); |
---|
| 344 | |
---|
| 345 | %%%%% read the state of the selected netcdf file to advise default operation |
---|
| 346 | if isequal(ext,'.nc') |
---|
| 347 | browse.nom_type_nc=nom_type; |
---|
[112] | 348 | ind_opening=2;% propose 'fix' as the default option |
---|
[2] | 349 | Data=nc2struct(fileinput,[]); |
---|
[112] | 350 | if isfield(Data,'absolut_time_T0')%test for civx files |
---|
[2] | 351 | if isfield(Data,'fix') && isequal(Data.fix,1) |
---|
| 352 | ind_opening=3; |
---|
| 353 | end |
---|
| 354 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
| 355 | ind_opening=4; |
---|
| 356 | end |
---|
| 357 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
| 358 | ind_opening=5; |
---|
| 359 | end |
---|
| 360 | if isfield(Data,'fix2') && isequal(Data.fix2,1) |
---|
| 361 | ind_opening=6; |
---|
| 362 | end |
---|
| 363 | testciv=1; %TO SUPPRESS WITH NEW VERSION OF CIVX |
---|
| 364 | else |
---|
[112] | 365 | ind_opening=3; %GUI used only for patch |
---|
[2] | 366 | testciv=0; |
---|
| 367 | end |
---|
| 368 | set(handles.subdir_civ1,'String',subdir);%set the default subdir directories for installing the .nc results |
---|
| 369 | set(handles.subdir_civ2,'String',subdir); |
---|
| 370 | browse.testciv=testciv; |
---|
| 371 | browse.ind_opening=ind_opening; |
---|
| 372 | end |
---|
[71] | 373 | set(handles.RootName,'String',filebase); |
---|
[2] | 374 | set(handles.ImaDoc,'String',ext); |
---|
[45] | 375 | if ~isempty(num_i1) |
---|
[82] | 376 | ref_i=num_i1; |
---|
[45] | 377 | if ~isempty(num_i2) |
---|
| 378 | ref_i=floor((ref_i+num_i2)/2);% reference image number corresponding to the file |
---|
| 379 | browse.incr_pair(1)=num_i2-num_i1; |
---|
[2] | 380 | browse.incr_pair(2)=0; |
---|
| 381 | end |
---|
| 382 | set(handles.first_i,'String',num2str(ref_i)); |
---|
| 383 | set(handles.last_i,'String',num2str(ref_i)); |
---|
[71] | 384 | set(handles.ref_i,'String',num2str(ref_i)); |
---|
| 385 | set(handles.ref_i_civ2,'String',num2str(ref_i)) |
---|
[2] | 386 | end |
---|
[45] | 387 | if isempty(num_j1) |
---|
[2] | 388 | set(handles.ref_j,'String','1'); |
---|
[71] | 389 | set(handles.ref_j_civ2,'String','1'); |
---|
[2] | 390 | else |
---|
[45] | 391 | ref_j=num_j1; |
---|
| 392 | if ~isempty(num_j2) |
---|
| 393 | ref_j=floor((num_j1+num_j2)/2); |
---|
[112] | 394 | browse.incr_pair(2)=num_j2-num_j1; |
---|
[2] | 395 | end |
---|
| 396 | set(handles.first_j,'String',num2str(ref_j)); |
---|
| 397 | set(handles.last_j,'String',num2str(ref_j)); |
---|
[112] | 398 | set(handles.ref_j,'String',num2str(ref_j)); |
---|
[71] | 399 | set(handles.ref_j_civ2,'String',num2str(ref_j)); |
---|
[2] | 400 | end |
---|
| 401 | |
---|
| 402 | % set default operation options |
---|
| 403 | enable_civ1(handles,'off') |
---|
| 404 | enable_civ2(handles,'off') |
---|
| 405 | enable_pair1(handles,'on') |
---|
| 406 | enable_fix1(handles,'off') |
---|
| 407 | desable_patch1(handles) |
---|
| 408 | desable_fix2(handles) |
---|
| 409 | desable_patch2(handles) |
---|
| 410 | set(handles.CIV1,'Value',0) |
---|
| 411 | set(handles.FIX1,'Value',0) |
---|
| 412 | set(handles.PATCH1,'Value',0) |
---|
| 413 | set(handles.CIV2,'Value',0) |
---|
| 414 | set(handles.FIX2,'Value',0) |
---|
| 415 | set(handles.PATCH2,'Value',0) |
---|
| 416 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 417 | if isequal(ind_opening,1) |
---|
| 418 | set(handles.CIV1,'Value',1) |
---|
| 419 | enable_civ1(handles,'on') |
---|
| 420 | elseif isequal(ind_opening,2) |
---|
| 421 | set(handles.FIX1,'Value',1) |
---|
| 422 | enable_fix1(handles,'on') |
---|
| 423 | elseif isequal(ind_opening,3) |
---|
| 424 | set(handles.PATCH1,'Value',1) |
---|
| 425 | enable_patch1(handles) |
---|
| 426 | elseif isequal(ind_opening,4) |
---|
| 427 | set(handles.CIV2,'Value',1) |
---|
[224] | 428 | enable_civ2(handles,'on') |
---|
[2] | 429 | elseif isequal(ind_opening,5) |
---|
| 430 | enable_pair1(handles,'off') |
---|
| 431 | set(handles.FIX2,'Value',1) |
---|
| 432 | enable_fix2(handles) |
---|
[112] | 433 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 434 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 435 | set(handles.list_pair_civ2,'Enable','On') |
---|
[2] | 436 | elseif isequal(ind_opening,6) |
---|
| 437 | enable_pair1(handles,'off') |
---|
| 438 | set(handles.PATCH2,'Value',1) |
---|
| 439 | enable_patch2(handles) |
---|
| 440 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 441 | set(handles.list_pair_civ2,'Enable','On') |
---|
| 442 | end |
---|
| 443 | set(handles.browse_root,'UserData',browse);% store information from browser |
---|
[174] | 444 | % testall=isequal(menu(filtindex,1),{'*.*'}); |
---|
| 445 | % set(handles.ImaDoc,'UserData',testall); |
---|
[2] | 446 | |
---|
[71] | 447 | RootName_Callback(hObject, eventdata, handles); |
---|
[2] | 448 | |
---|
[12] | 449 | %------------------------------------------------------------------------ |
---|
[2] | 450 | function ImaDoc_Callback(hObject, eventdata, handles) |
---|
[12] | 451 | %------------------------------------------------------------------------ |
---|
[71] | 452 | RootName_Callback(hObject, eventdata, handles) |
---|
[2] | 453 | |
---|
[12] | 454 | %------------------------------------------------------------------------ |
---|
[54] | 455 | % --- function activated when a new filebase (image series) is introduced |
---|
[71] | 456 | function RootName_Callback(hObject, eventdata, handles) |
---|
[12] | 457 | %------------------------------------------------------------------------ |
---|
[2] | 458 | set(handles.compare,'Visible','on') |
---|
[122] | 459 | %ext_ima=get(handles.ImaExt,'String'); |
---|
| 460 | ext_ima='';%default |
---|
[2] | 461 | nom_type_ima=[];%default |
---|
| 462 | field_count=1;%default |
---|
| 463 | nom_type_nc=[]; |
---|
| 464 | time=[]; |
---|
[71] | 465 | TimeUnit='frame'; %default |
---|
| 466 | CoordUnit='px';%default |
---|
[2] | 467 | pxcmx_search=[];%default |
---|
| 468 | pxcmy_search=[];%default |
---|
[71] | 469 | filebase=get(handles.RootName,'String'); |
---|
[128] | 470 | ext_imadoc=get(handles.ImaDoc,'String'); |
---|
[135] | 471 | browse=get(handles.browse_root,'UserData');%default |
---|
[122] | 472 | if isfield(browse,'nom_type_ima') |
---|
| 473 | nom_type_ima=browse.nom_type_ima;% get an image nomenclature type already determined by an input image name |
---|
[133] | 474 | end |
---|
| 475 | if isfield(browse,'ext_ima') |
---|
[122] | 476 | ext_ima=browse.ext_ima; |
---|
[2] | 477 | end |
---|
[122] | 478 | if isfield(browse,'nom_type_nc') |
---|
| 479 | nom_type_nc=browse.nom_type_nc;% get an image nomenclature type already determined by an input image name |
---|
| 480 | end |
---|
| 481 | if isfield(browse,'num_i1') |
---|
| 482 | field_count=browse.num_i1;% get an image index type already determined by an input file |
---|
| 483 | end |
---|
[2] | 484 | |
---|
| 485 | %default first_i and j and increments |
---|
[137] | 486 | first_i=str2double(get(handles.first_i,'String'));%value possibly set by uvmat_Opening |
---|
| 487 | if isnan(first_i)|| first_i < 1 |
---|
[2] | 488 | first_i=1; %default first_i |
---|
| 489 | end |
---|
[137] | 490 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 491 | if isnan(last_i)|| last_i < first_i |
---|
[2] | 492 | last_i=first_i; %default last_i |
---|
| 493 | end |
---|
[137] | 494 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 495 | if isnan(first_j)|| first_j < 1 |
---|
[2] | 496 | first_j=1; %default first_j |
---|
| 497 | end |
---|
[137] | 498 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 499 | if isnan(last_j)|| last_j < first_j |
---|
[2] | 500 | last_j=first_j; %default last_j |
---|
| 501 | end |
---|
[137] | 502 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 503 | if isnan(incr_i) || incr_i < 1; |
---|
[2] | 504 | set(handles.incr_i,'String','1') %default incr_i |
---|
| 505 | end |
---|
[137] | 506 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
| 507 | if isnan(incr_j) || incr_j < 1; |
---|
[2] | 508 | set(handles.incr_j,'String','1') %default incr_j |
---|
| 509 | end |
---|
| 510 | dt=[];%default |
---|
| 511 | testmode=0;%default |
---|
| 512 | nbfield=[]; %default |
---|
| 513 | nburst=[];%default |
---|
| 514 | pxcmx=1; |
---|
[112] | 515 | pxcmy=1; |
---|
[2] | 516 | |
---|
[112] | 517 | %look for an image documentation file |
---|
[128] | 518 | if ~strcmp(ext_imadoc,'.xml') && ~strcmp(ext_imadoc,'.civ')&& ~strcmpi(ext_imadoc,'.avi') |
---|
[2] | 519 | if exist([filebase '.xml'],'file') |
---|
[128] | 520 | ext_imadoc='.xml'; |
---|
[2] | 521 | elseif exist([filebase '.civxml'],'file') |
---|
[128] | 522 | ext_imadoc='.civxml'; |
---|
[2] | 523 | elseif exist([filebase '.civ'],'file') |
---|
[128] | 524 | ext_imadoc='.civ'; |
---|
[112] | 525 | elseif exist([filebase '.avi'],'file') |
---|
[128] | 526 | ext_imadoc='.avi'; |
---|
[2] | 527 | elseif exist([filebase '.AVI'],'file') |
---|
[128] | 528 | ext_imadoc='.AVI'; |
---|
[2] | 529 | end |
---|
[128] | 530 | set(handles.ImaDoc,'String',ext_imadoc) |
---|
[2] | 531 | end |
---|
| 532 | |
---|
| 533 | %%%%%%%% read image documentation file %%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[84] | 534 | mode=''; %default |
---|
| 535 | set(handles.ImaDoc,'BackgroundColor',[1 1 0]) |
---|
| 536 | drawnow |
---|
[128] | 537 | if isequal(ext_imadoc,'.civxml') || isequal(ext_imadoc,'.xml')|| isequal(ext_imadoc,'.civ') |
---|
[2] | 538 | set(handles.ref_i,'Visible','On')%use a reference index |
---|
| 539 | set(handles.ref_j,'Visible','On') |
---|
[128] | 540 | elseif isequal(ext_imadoc,'.avi') || isequal(ext_imadoc,'.AVI') |
---|
[2] | 541 | set(handles.ref_j,'Visible','Off') |
---|
| 542 | else |
---|
| 543 | set(handles.ref_i,'Visible','Off') |
---|
| 544 | set(handles.ref_j,'Visible','Off') |
---|
| 545 | end |
---|
[12] | 546 | testima_xml=0; |
---|
[128] | 547 | if isequal(ext_imadoc,'.civxml')%TO ABANDON |
---|
[122] | 548 | [nbfield,nbfield2,time]=read_civxml([filebase '.civxml']); |
---|
[2] | 549 | mode='pair j1-j2'; |
---|
| 550 | if isempty(nom_type_ima)% dtermine types by default if not already selected by browser or uvmat |
---|
[112] | 551 | nom_type_ima='_i_j'; |
---|
[2] | 552 | end |
---|
[128] | 553 | elseif isequal(ext_imadoc,'.xml') |
---|
[73] | 554 | [XmlData,warntext]=imadoc2struct([filebase '.xml']); |
---|
[2] | 555 | ext_ima_read=[]; |
---|
| 556 | nom_type_read=[]; |
---|
[12] | 557 | if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')&&ischar(XmlData.Heading.ImageName)% get image nom type and extension from the xml file |
---|
[2] | 558 | [PP,FF,fc,str2,str_a,str_b,ext_ima_read,nom_type_read]=name2display(XmlData.Heading.ImageName); |
---|
[112] | 559 | fullname=fullfile(fileparts(filebase),XmlData.Heading.ImageName); %full name (including path) of the first image defined by the xmle file, |
---|
[45] | 560 | if ~exist(fullname,'file') |
---|
[12] | 561 | msgbox_uvmat('WARNING',['FirstImage ' fullname ' defined in the xml file does not exist']) |
---|
| 562 | end |
---|
[2] | 563 | end |
---|
[84] | 564 | if isfield(XmlData,'Time') |
---|
[85] | 565 | time=XmlData.Time; |
---|
[84] | 566 | nbfield=size(time,1); |
---|
[122] | 567 | nbfield2=size(time,2); |
---|
[127] | 568 | %transform .Time to a column vector if it is a line vector thenomenclature uses a single index: correct possible bug in xml |
---|
[122] | 569 | if isequal(nbfield,1) && ~isequal(nbfield2,1)% .Time is a line vector |
---|
[127] | 570 | if numel(nom_type_read)>=2 && isempty(regexp(nom_type_read(2:end),'\D')) |
---|
[84] | 571 | time=time'; |
---|
[122] | 572 | nbfield=nbfield2; |
---|
| 573 | nbfield2=1; |
---|
[84] | 574 | end |
---|
| 575 | end |
---|
| 576 | end |
---|
[71] | 577 | if isfield(XmlData,'TimeUnit') |
---|
| 578 | TimeUnit=XmlData.TimeUnit; |
---|
[2] | 579 | end |
---|
[71] | 580 | if isfield(XmlData,'Npx') |
---|
| 581 | npx=XmlData.Npx; |
---|
| 582 | npy=XmlData.Npy; |
---|
| 583 | end |
---|
[2] | 584 | pxcmx_search=1; |
---|
| 585 | pxcmy_search=1; |
---|
| 586 | if isfield(XmlData,'GeometryCalib') |
---|
| 587 | tsai=XmlData.GeometryCalib; |
---|
[112] | 588 | if isfield(tsai,'f') && isfield(tsai,'Tz') && isfield(tsai,'dpx') && isfield(tsai,'dpy')&& isfield(tsai,'R') |
---|
| 589 | rot2D=tsai.R(1:2,[1,2]); |
---|
| 590 | pxcmx_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpx); |
---|
| 591 | pxcmy_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpy); |
---|
[2] | 592 | end |
---|
[112] | 593 | if isfield(tsai,'CoordUnit') |
---|
| 594 | CoordUnit=tsai.CoordUnit; |
---|
[2] | 595 | end |
---|
[112] | 596 | end |
---|
[128] | 597 | elseif strcmp(ext_imadoc,'.civ')% case of .civ image documentation file |
---|
[112] | 598 | [error,time,TimeUnit,mode,npx,npy]=read_imatext([filebase '.civ']); |
---|
| 599 | if error==2, msgbox_uvmat('WARNING',['no file ' filebase '.civ']); |
---|
| 600 | elseif error==1, msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file'); |
---|
| 601 | end |
---|
[128] | 602 | nom_type_ima='001a'; |
---|
| 603 | elseif strcmpi(ext_imadoc,'.avi') |
---|
[112] | 604 | nom_type_ima='*'; |
---|
[128] | 605 | ext_ima=ext_imadoc; |
---|
[177] | 606 | set(handles.mode,'Value',1); |
---|
[112] | 607 | set(handles.mode,'String',{'series(Di)'}) |
---|
| 608 | dt=0.04;%default |
---|
[128] | 609 | if exist([filebase ext_imadoc],'file')==2 |
---|
| 610 | info=aviinfo([filebase ext_imadoc]);%read infos on the avi movie |
---|
[112] | 611 | dt=1/info.FramesPerSecond;%time interval between successive frames |
---|
| 612 | nbfield=info.NumFrames;%number of frames |
---|
| 613 | end |
---|
| 614 | time=(dt*(0:nbfield-1))';%list of image times |
---|
[2] | 615 | end |
---|
| 616 | if isempty(time) |
---|
| 617 | set(handles.ImaDoc,'String',''); %xml file not used for timing |
---|
| 618 | end |
---|
| 619 | set(handles.ImaDoc,'BackgroundColor',[1 1 1]) |
---|
| 620 | |
---|
[122] | 621 | %get the imabe nomenclature type if not defined by the input file nor by the xml file |
---|
| 622 | dirima=[];%default |
---|
[12] | 623 | if isempty(nom_type_ima) |
---|
| 624 | %look for double image series '_i_j' |
---|
| 625 | dirima=dir([filebase '_' num2str(first_i) '_' num2str(first_j) '.*']); |
---|
| 626 | if isempty(dirima) |
---|
[112] | 627 | % look for images series with sub marker '_' |
---|
| 628 | dirima=dir([filebase '_*' num2str(first_i) '.*']); |
---|
| 629 | if isempty(dirima) |
---|
| 630 | % look for other images series |
---|
| 631 | dirima=dir([filebase '*' num2str(first_i) '.*']); |
---|
[122] | 632 | if isempty(dirima) |
---|
| 633 | % look for other images series witth letter appendix |
---|
| 634 | appendix=char(96+first_j); |
---|
| 635 | dirima=dir([filebase '*' num2str(first_i) appendix '.*']); |
---|
[112] | 636 | end |
---|
| 637 | end |
---|
[12] | 638 | end |
---|
[112] | 639 | end |
---|
[122] | 640 | for ilist=1:numel(dirima) |
---|
| 641 | [pp,ff,fc,str2,str_a,str_b,ext_list,nom_type_list]=name2display(dirima(ilist).name); |
---|
| 642 | form=imformats(ext_list(2:end)); |
---|
| 643 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 644 | ext_ima=ext_list; |
---|
| 645 | nom_type_ima=nom_type_list; |
---|
| 646 | break |
---|
| 647 | end |
---|
| 648 | end |
---|
| 649 | % no image documentation file found: look for a series of existing files,images by priority or .nc files |
---|
| 650 | if isempty(nom_type_ima) |
---|
[128] | 651 | ext_search=ext_imadoc; |
---|
[122] | 652 | nom_type_search=nom_type_nc; |
---|
| 653 | else |
---|
| 654 | ext_search=ext_ima; |
---|
| 655 | nom_type_search=nom_type_ima; |
---|
| 656 | end |
---|
| 657 | if isempty(time) && ~strcmp(nom_type_search,'none') && ~strcmp(nom_type_search,'') && ~strcmp(nom_type_search,'*') |
---|
[12] | 658 | subdir=get(handles.subdir_civ1,'String'); |
---|
| 659 | incr_pair=[0 0];%default |
---|
| 660 | if isfield(browse,'incr_pair') |
---|
[112] | 661 | incr_pair=browse.incr_pair; |
---|
[12] | 662 | end |
---|
[112] | 663 | % nbdetect=0;%test of detected images |
---|
[122] | 664 | field_i=browse.num_i2; |
---|
[153] | 665 | imagename=name_generator(filebase,field_i,1,ext_search,nom_type_search); |
---|
| 666 | imagename_plus=''; |
---|
[12] | 667 | idetect=1; |
---|
[153] | 668 | while idetect %look for the maximum file number in the series |
---|
| 669 | imagename_plus=name_generator(filebase,field_i+1,1,ext_search,nom_type_search); |
---|
| 670 | idetect=(exist(imagename_plus,'file')==2)&& ~strcmp(imagename,imagename_plus); |
---|
[81] | 671 | if idetect |
---|
[12] | 672 | field_i=field_i+1; |
---|
[81] | 673 | end |
---|
[112] | 674 | %SEE CASE OF NETCDF FILES |
---|
| 675 | % nbdetect=nbdetect+(exist(imagename,'file')==2); |
---|
[12] | 676 | end |
---|
[122] | 677 | nbfield=field_i;% last detected field number |
---|
| 678 | field_i=browse.num_i1;%look for the minimum file number in the series |
---|
[153] | 679 | imagename_min=''; |
---|
[12] | 680 | idetect=1; |
---|
[112] | 681 | while idetect==1 |
---|
[153] | 682 | imagename_min=name_generator(filebase,field_i-1,1,ext_search,nom_type_search); |
---|
| 683 | idetect=(exist(imagename_min,'file')==2)&& ~strcmp(imagename,imagename_min); |
---|
[81] | 684 | if idetect |
---|
[112] | 685 | field_i=field_i-1; |
---|
[81] | 686 | end |
---|
[12] | 687 | end |
---|
[122] | 688 | first_i=max(field_i,1); |
---|
| 689 | if numel(regexp(nom_type_search,'\D'))>=1%two indices i and j |
---|
| 690 | field_i=browse.num_i1; |
---|
| 691 | field_j=browse.num_j2; |
---|
[177] | 692 | imagename=name_generator(filebase,field_i,field_j,ext_search,nom_type_search); |
---|
[153] | 693 | imagename_plus=''; |
---|
[89] | 694 | jdetect=1; |
---|
| 695 | while jdetect==1 %look for the maximum file number in the series |
---|
[153] | 696 | imagename_plus=name_generator(filebase,field_i,field_j+1,ext_search,nom_type_search); |
---|
| 697 | jdetect=(exist(imagename_plus,'file')==2)&& ~strcmp(imagename,imagename_plus); |
---|
[89] | 698 | if jdetect |
---|
| 699 | field_j=field_j+1; |
---|
| 700 | end |
---|
| 701 | %SEE CASE OF NETCDF FILES |
---|
| 702 | % nbdetect=nbdetect+(exist(imagename,'file')==2); |
---|
| 703 | end |
---|
[122] | 704 | nbfield2=field_j;% last detected field number |
---|
[120] | 705 | end |
---|
[122] | 706 | |
---|
[89] | 707 | %determine the set of times and possible intervals for CIV |
---|
[137] | 708 | % dt=(1/1000)*str2double(get(handles.dt,'String')); |
---|
[122] | 709 | time=(0:nbfield-1)';% time=file index -1 by default |
---|
| 710 | if numel(regexp(nom_type_search,'\D'))>=1%two indices i and j |
---|
| 711 | [x,y]=meshgrid(0:nbfield2-1,0:nbfield-1); |
---|
[120] | 712 | time=x+y; |
---|
[89] | 713 | end |
---|
[2] | 714 | end |
---|
[120] | 715 | |
---|
[2] | 716 | if exist('time','var') |
---|
| 717 | if size(time,1)+size(time,2)>=3 % if there are at least two time values to define dt |
---|
| 718 | nbfield=size(time,1); |
---|
| 719 | nbfield2=size(time,2); |
---|
[71] | 720 | set(handles.RootName,'UserData',time); %store the set of times |
---|
| 721 | set(handles.dt_unit,'String',['dt in m' TimeUnit]); |
---|
| 722 | set(handles.dt_unit_civ2,'String',['dt in m' TimeUnit]); |
---|
| 723 | set(handles.TimeUnit,'String',TimeUnit); |
---|
[2] | 724 | set(handles.nb_field,'String',num2str(nbfield)); |
---|
| 725 | set(handles.nb_field2,'String',num2str(nbfield2)); |
---|
| 726 | end |
---|
| 727 | end |
---|
[71] | 728 | set(handles.CoordUnit,'String',CoordUnit) |
---|
[2] | 729 | set(handles.calcul_search,'UserData',[pxcmx_search pxcmy_search]); |
---|
| 730 | % npxy=[npy npx]; |
---|
[71] | 731 | set(handles.ImaExt,'String',ext_ima) |
---|
[2] | 732 | set(handles.first_i,'String',num2str(first_i)); |
---|
| 733 | set(handles.last_i,'String',num2str(last_i));% |
---|
| 734 | set(handles.first_j,'String',num2str(first_j)); |
---|
| 735 | set(handles.last_j,'String',num2str(last_j));% |
---|
| 736 | browse.nom_type_ima=nom_type_ima; |
---|
| 737 | set(handles.browse_root,'UserData',browse)% store the nomenclature type |
---|
| 738 | |
---|
[112] | 739 | %%%%%%%%%%% set the menus of image pairs and default selection for civ %%%%%%%%%%%%%%%%%%% |
---|
[177] | 740 | test_ima_i=numel(nom_type_ima)>1 && isempty(regexp(nom_type_ima(2:end),'\D','once'));%images with single indexing |
---|
[122] | 741 | if test_ima_i || isequal(nom_type_nc,'_i1-i2')||~(exist('nbfield2','var')&&(nbfield2~=1)) |
---|
[2] | 742 | set(handles.mode,'Value',1) |
---|
[177] | 743 | set(handles.mode,'String',{'series(Di)'}) |
---|
[2] | 744 | elseif (nbfield==1)% simple series in j |
---|
[177] | 745 | set(handles.mode,'Value',1) |
---|
[2] | 746 | set(handles.mode,'String',{'series(Dj)'}) |
---|
| 747 | else |
---|
| 748 | set(handles.mode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice |
---|
[122] | 749 | if nbfield2 <= 10 |
---|
[112] | 750 | set(handles.mode,'Value',1)% advice 'pair j1-j2' for small burst |
---|
[2] | 751 | end |
---|
| 752 | end |
---|
| 753 | |
---|
[112] | 754 | %update the subdir |
---|
[2] | 755 | pathdir=fileparts(filebase);%path to the current xml file |
---|
| 756 | listot=dir(pathdir); |
---|
| 757 | idir=0; |
---|
| 758 | listdir={''};%default |
---|
| 759 | for ilist=1:length(listot) |
---|
| 760 | if listot(ilist).isdir |
---|
| 761 | name=listot(ilist).name; |
---|
| 762 | if ~isequal(name,'.') && ~isequal(name,'..') |
---|
| 763 | idir=idir+1; |
---|
| 764 | listdir{idir,1}=listot(ilist).name; |
---|
| 765 | end |
---|
| 766 | end |
---|
| 767 | end |
---|
[112] | 768 | set(handles.list_subdir_civ1,'Value',1) |
---|
[2] | 769 | set(handles.list_subdir_civ2,'Value',1) |
---|
[107] | 770 | set(handles.list_subdir_civ1,'String',[{'browse...'};listdir]) |
---|
| 771 | set(handles.list_subdir_civ2,'String',[{'browse...'};listdir]) |
---|
[2] | 772 | %check wether the current subdir exists: |
---|
| 773 | subdir_civ1=get(handles.subdir_civ1,'String'); |
---|
| 774 | subdir_civ2=get(handles.subdir_civ2,'String'); |
---|
| 775 | |
---|
[112] | 776 | mode_Callback(hObject, eventdata, handles) |
---|
[2] | 777 | |
---|
[177] | 778 | %% desable status and RUN button |
---|
[150] | 779 | % set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001]) |
---|
| 780 | % set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001]) |
---|
| 781 | % set(handles.waitbar_civ2,'Position',[0.946 0.219 0.03 0.001]) |
---|
| 782 | % set(handles.waitbar_patch2,'Position',[0.946 0.0 0.03 0.001]) |
---|
[2] | 783 | set(handles.RUN, 'Enable','On') |
---|
| 784 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
[122] | 785 | set(handles.BATCH,'Enable','On') |
---|
| 786 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
[178] | 787 | if isfield(handles,'status') |
---|
[177] | 788 | set(handles.status,'Value',0);%suppress status display |
---|
| 789 | status_Callback(hObject, eventdata, handles) |
---|
[178] | 790 | end |
---|
[112] | 791 | |
---|
[177] | 792 | %% store the root input filename for future opening |
---|
[2] | 793 | dir_perso=prefdir; |
---|
| 794 | profil_perso=fullfile(prefdir,'uvmat_perso.mat'); |
---|
| 795 | RootPath=fileparts(filebase); |
---|
| 796 | if exist(profil_perso,'file') |
---|
| 797 | save (profil_perso,'RootPath','-append'); %store the root name for future opening of uvmat |
---|
| 798 | else |
---|
[147] | 799 | txt=ver('MATLAB'); |
---|
| 800 | Release=txt.Release; |
---|
[137] | 801 | relnumb=str2double(Release(3:4)); |
---|
[2] | 802 | if relnumb >= 14 |
---|
[112] | 803 | save (profil_perso,'RootPath','-V6'); %store the root name for future opening of uvmat |
---|
[2] | 804 | else |
---|
| 805 | save (profil_perso,'RootPath'); %store the root name for future opening of uvmat |
---|
| 806 | end |
---|
| 807 | end |
---|
| 808 | |
---|
[12] | 809 | %------------------------------------------------------------------------ |
---|
[2] | 810 | % --- Executes on button press in mode. |
---|
| 811 | function mode_Callback(hObject, eventdata, handles) |
---|
[12] | 812 | %------------------------------------------------------------------------ |
---|
[2] | 813 | browse=get(handles.browse_root,'UserData'); |
---|
| 814 | compare_list=get(handles.compare,'String'); |
---|
| 815 | val=get(handles.compare,'Value'); |
---|
| 816 | compare=compare_list{val}; |
---|
| 817 | if strcmp(compare,'displacement') |
---|
| 818 | mode='displacement'; |
---|
| 819 | else |
---|
| 820 | mode_list=get(handles.mode,'String'); |
---|
| 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 |
---|
| 1170 | mode_list=get(handles.mode,'String'); |
---|
| 1171 | mode_value=get(handles.mode,'Value'); |
---|
| 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) |
---|
| 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; |
---|
| 1537 | if ~ismember(sparam.BatchMode,{'sge'}) |
---|
[229] | 1538 | errormsg=['batch mode ' sparam.BatchMode ' not supported by UVMAT']; |
---|
| 1539 | return |
---|
[67] | 1540 | end |
---|
| 1541 | else |
---|
[229] | 1542 | errormsg='no batch civ binaries defined in PARAM.xml'; |
---|
[67] | 1543 | return |
---|
| 1544 | end |
---|
[225] | 1545 | if isfield(sparam,'BatchMode') |
---|
| 1546 | batch_mode=sparam.BatchMode; |
---|
| 1547 | end |
---|
| 1548 | % choice of batch priority: |
---|
| 1549 | ind_answer=2; |
---|
| 1550 | [s,w]=unix('qstat -q civ.q|grep job_| wc -l'); %check the waiting list (command unix) |
---|
| 1551 | if isequal(s,0) |
---|
| 1552 | w(end)=[]; |
---|
| 1553 | str_displ={[w ' jobs in the waiting list'];'Select a priority:'}; |
---|
| 1554 | str={'urgent';'normal';'low'}; |
---|
| 1555 | [ind_answer,v] = listdlg('PromptString',str_displ,... |
---|
| 1556 | 'SelectionMode','single',... |
---|
| 1557 | 'ListString',str,'ListSize',[200 200],'Name','job priority','InitialValue',3); |
---|
| 1558 | if isequal(v,0) % to handle Cancel button and figure close, |
---|
[229] | 1559 | errormsg='job cancelled'; |
---|
[225] | 1560 | return % a better way should be create |
---|
| 1561 | end |
---|
| 1562 | else |
---|
| 1563 | msgbox_uvmat('ERROR','sge batch system not available') |
---|
| 1564 | return |
---|
| 1565 | end |
---|
[67] | 1566 | else |
---|
| 1567 | if isfield(s,'RunParam') |
---|
| 1568 | sparam=s.RunParam; |
---|
| 1569 | else |
---|
[225] | 1570 | msgbox_uvmat('ERROR','no run civ binaries defined in PARAM.xml') |
---|
[67] | 1571 | return |
---|
| 1572 | end |
---|
[225] | 1573 | end |
---|
| 1574 | civAll=isequal(get(handles.CivAll,'Value'),2); % Boolean for new civ programs |
---|
| 1575 | if civAll && isfield(sparam,'CivBin') |
---|
| 1576 | CivBin=sparam.CivBin; |
---|
| 1577 | if ~exist(CivBin,'file') || ~isempty(which(CivBin))% if path defined as relative to uvmat |
---|
| 1578 | sparam.CivBin=fullfile(path_UVMAT,CivBin); |
---|
| 1579 | if ~exist(sparam.CivBin,'file') |
---|
| 1580 | msgbox_uvmat('ERROR',['CIVx binary ' CivBin ' defined in PARAM.xm does not exist']) |
---|
| 1581 | return |
---|
[112] | 1582 | end |
---|
[94] | 1583 | end |
---|
[225] | 1584 | end |
---|
| 1585 | if isfield(sparam,'Civ1Bin') |
---|
| 1586 | Civ1Bin=sparam.Civ1Bin; |
---|
| 1587 | if ~exist(Civ1Bin,'file')||~isempty(which(Civ1Bin))% if path defined as relative to uvmat |
---|
| 1588 | sparam.Civ1Bin=fullfile(path_UVMAT,Civ1Bin); |
---|
| 1589 | if ~exist(sparam.Civ1Bin,'file') |
---|
| 1590 | msgbox_uvmat('ERROR',['civ1 binary ' Civ1Bin ' defined in PARAM.xm does not exist']) |
---|
| 1591 | return |
---|
[112] | 1592 | end |
---|
[94] | 1593 | end |
---|
[225] | 1594 | end |
---|
| 1595 | if isfield(sparam,'Civ2Bin') |
---|
| 1596 | Civ2Bin=sparam.Civ2Bin; |
---|
| 1597 | if ~exist(Civ2Bin,'file')||~isempty(which(Civ2Bin))% if path defined as relative to uvmat |
---|
| 1598 | sparam.Civ2Bin=fullfile(path_UVMAT,Civ2Bin); |
---|
| 1599 | if ~exist(sparam.Civ2Bin,'file') |
---|
| 1600 | msgbox_uvmat('ERROR',['civ2 binary ' Civ2Bin ' defined in PARAM.xm does not exist']) |
---|
| 1601 | return |
---|
[112] | 1602 | end |
---|
[94] | 1603 | end |
---|
[225] | 1604 | end |
---|
| 1605 | if isfield(sparam,'PatchBin') |
---|
| 1606 | if ~exist(sparam.PatchBin,'file')||~isempty(which(sparam.PatchBin))% if path defined as relative to uvmat |
---|
| 1607 | sparam.PatchBin=fullfile(path_UVMAT,sparam.PatchBin); |
---|
[94] | 1608 | end |
---|
[73] | 1609 | end |
---|
[225] | 1610 | if isfield(sparam,'FixBin') |
---|
| 1611 | if ~exist(sparam.FixBin,'file')||~isempty(which(sparam.FixBin))% if path defined as relative to uvmat |
---|
| 1612 | sparam.FixBin=fullfile(path_UVMAT,sparam.FixBin); |
---|
[2] | 1613 | end |
---|
| 1614 | end |
---|
| 1615 | |
---|
| 1616 | |
---|
[225] | 1617 | |
---|
[133] | 1618 | %% get civ1 parameters: |
---|
[112] | 1619 | display('files OK, processing...') |
---|
[2] | 1620 | if box_test(1)==1 |
---|
| 1621 | par_civ1=read_param_civ1(handles,filecell.ima1.civ1{1,1}); |
---|
[112] | 1622 | end |
---|
[2] | 1623 | |
---|
[133] | 1624 | %% get fix1 parameters |
---|
[112] | 1625 | if box_test(2)==1 |
---|
[2] | 1626 | flagindex1(1)=get(handles.vec_Fmin2, 'Value'); |
---|
| 1627 | flagindex1(2)=get(handles.vec_F3, 'Value'); |
---|
| 1628 | flagindex1(3)=get(handles.vec_F2, 'Value'); |
---|
[127] | 1629 | thresh_vecC1=str2double(get(handles.thresh_vecC,'String'));%threshold on image correlation vec_C |
---|
| 1630 | thresh_vel1=str2double(get(handles.thresh_vel,'String'));%threshold on velocity modulus |
---|
[2] | 1631 | test_mask=get(handles.get_mask_fix1,'Value'); |
---|
| 1632 | nbslice_mask=get(handles.mask_fix1,'UserData'); % get the number of slices (= number of masks) |
---|
| 1633 | %%%%%%%%%%%%%COMPLETER LE PROGRAMME FIX |
---|
[112] | 1634 | % inf_sup=get(handles.inf_sup1,'Value');80 |
---|
| 1635 | % fileref=get(handles.ref_fix1,'String'); |
---|
| 1636 | % refpath=get(handles.ref_fix1,'UserData'); |
---|
| 1637 | % fileref=fullfile(refpath,fileref); |
---|
[2] | 1638 | menu=get(handles.field_ref1,'String'); |
---|
| 1639 | index=get(handles.field_ref1,'Value'); |
---|
| 1640 | if isempty(menu) |
---|
| 1641 | fieldchoice=''; |
---|
| 1642 | else |
---|
| 1643 | fieldchoice=menu{index}; |
---|
[112] | 1644 | msgbox_uvmat('WARNING','reference field is not used presently with batch, use RUN option') |
---|
| 1645 | end |
---|
[2] | 1646 | end |
---|
[112] | 1647 | |
---|
[133] | 1648 | %% get patch1 parameters |
---|
[67] | 1649 | if box_test(3)==1 |
---|
[127] | 1650 | rho_patch1=str2double(get(handles.rho_patch1,'String')); |
---|
| 1651 | if isnan(rho_patch1) |
---|
[112] | 1652 | rho_patch1='1000'; |
---|
| 1653 | set(handles.rho_patch1,'String','1') |
---|
| 1654 | else |
---|
| 1655 | rho_patch1=num2str(1000*rho_patch1); |
---|
| 1656 | end |
---|
| 1657 | nx_patch1=get(handles.nx_patch1,'String'); |
---|
| 1658 | ny_patch1=get(handles.ny_patch1,'String'); |
---|
[127] | 1659 | if isnan(str2double(nx_patch1)) |
---|
[112] | 1660 | nx_patch1='50' ;%default |
---|
| 1661 | set(handles.nx_patch1,'String','50'); |
---|
| 1662 | end |
---|
[127] | 1663 | if isnan(str2double(ny_patch1)) |
---|
[112] | 1664 | ny_patch1='50' ;%default |
---|
| 1665 | set(handles.ny_patch1,'String','50'); |
---|
| 1666 | end |
---|
| 1667 | subdomain_patch1=get(handles.subdomain_patch1,'String'); |
---|
| 1668 | thresh_patch1=get(handles.thresh_patch1,'String'); |
---|
| 1669 | end |
---|
| 1670 | |
---|
[133] | 1671 | %% get civ2 parameters: |
---|
[2] | 1672 | if box_test(4)==1 |
---|
| 1673 | par_civ2=read_param_civ2(handles,cell2mat(filecell.ima1.civ2(1,1))); |
---|
| 1674 | end |
---|
| 1675 | |
---|
[133] | 1676 | %% get fix2 parameters |
---|
[112] | 1677 | if box_test(5)==1 |
---|
[2] | 1678 | flagindex2(1)=get(handles.vec_Fmin2_2, 'Value'); |
---|
| 1679 | flagindex2(2)=get(handles.vec_F3_2, 'Value'); |
---|
| 1680 | flagindex2(3)=get(handles.vec_F4, 'Value'); |
---|
[127] | 1681 | thresh_vec2C=str2double(get(handles.thresh_vec2C,'String'));%threshold on image correlation vec_C |
---|
| 1682 | thresh_vel2=str2double(get(handles.thresh_vel2,'String'));%threshold on velocity modulus |
---|
[2] | 1683 | test_mask=get(handles.get_mask_fix2,'Value'); |
---|
| 1684 | nbslice_mask=get(handles.mask_fix2,'UserData'); % get the number of slices (= number of masks) |
---|
[112] | 1685 | %%%%%%%%%%%%%COMPLETER LE PROGRAMME FIX AVEC REF FILE ET OPTION inf_sup=2 |
---|
| 1686 | % inf_sup=get(handles.inf_sup2,'Value'); |
---|
| 1687 | % ref=get(handles.ref_fix2,'UserData'); |
---|
| 1688 | |
---|
[2] | 1689 | %%%%%%%%%%%%%%%%%%% |
---|
| 1690 | end |
---|
| 1691 | |
---|
[133] | 1692 | %% get patch2 parameters |
---|
[2] | 1693 | if box_test(6)==1 |
---|
[127] | 1694 | rho_patch2=str2double(get(handles.rho_patch2,'String')); |
---|
| 1695 | if isnan(rho_patch2) |
---|
[2] | 1696 | rho_patch2='1000'; |
---|
| 1697 | set(handles.rho_patch2,'String','1') |
---|
| 1698 | else |
---|
| 1699 | rho_patch2=num2str(1000*rho_patch2); |
---|
| 1700 | end |
---|
| 1701 | nx_patch2=get(handles.nx_patch2,'String'); |
---|
| 1702 | ny_patch2=get(handles.ny_patch2,'String'); |
---|
[127] | 1703 | if isnan(str2double(nx_patch2)) |
---|
[2] | 1704 | nx_patch2='50' ;%default |
---|
| 1705 | set(handles.nx_patch2,'String','50'); |
---|
| 1706 | end |
---|
[127] | 1707 | if isnan(str2double(ny_patch2)) |
---|
[2] | 1708 | ny_patch2='50' ;%default |
---|
| 1709 | set(handles.ny_patch2,'String','50'); |
---|
| 1710 | end |
---|
| 1711 | subdomain_patch2=get(handles.subdomain_patch2,'String'); |
---|
| 1712 | thresh_patch2=get(handles.thresh_patch2,'String'); |
---|
[112] | 1713 | % test_interp=get(handles.test_interp,'Value'); |
---|
[2] | 1714 | end |
---|
| 1715 | |
---|
[133] | 1716 | %% MAIN LOOP |
---|
[71] | 1717 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
[134] | 1718 | super_cmd=[]; |
---|
| 1719 | |
---|
[2] | 1720 | for ifile=1:nbfield |
---|
| 1721 | for j=1:nbslice |
---|
[112] | 1722 | i_cmd=0; |
---|
[2] | 1723 | cmd=''; |
---|
[73] | 1724 | if isunix % check: necessaire aussi en RUN? |
---|
[112] | 1725 | cmd='#!/bin/bash \n'; |
---|
| 1726 | cmd=[cmd '#$ -cwd \n']; |
---|
| 1727 | cmd=[cmd 'hostname && date \n']; |
---|
[220] | 1728 | cmd=[cmd 'umask 002 \n'];%allow writting access to created files for user group |
---|
[2] | 1729 | end |
---|
| 1730 | if civAll |
---|
| 1731 | civAllxml=xmltree;% xml contents, all parameters |
---|
[73] | 1732 | civAllCmd=''; |
---|
[2] | 1733 | civAllxml=set(civAllxml,1,'name','CivDoc'); |
---|
| 1734 | end |
---|
[174] | 1735 | [Rootbat,Filebat]=fileparts(filecell.nc.civ1{ifile,j});%output netcdf file (without extention) |
---|
[177] | 1736 | flname=fullfile(Rootbat,Filebat); |
---|
[159] | 1737 | if batch |
---|
[174] | 1738 | filename_bat=fullfile(Rootbat,['job_' Filebat]); |
---|
[159] | 1739 | else |
---|
[177] | 1740 | filename_bat=flname; |
---|
[159] | 1741 | end |
---|
[174] | 1742 | filename_bat=[filename_bat '.bat']; |
---|
[2] | 1743 | |
---|
[112] | 1744 | %CIV1 |
---|
[2] | 1745 | if box_test(1)==1 |
---|
[41] | 1746 | par_civ1.filename_ima_a=filecell.ima1.civ1{ifile,j}; |
---|
[112] | 1747 | par_civ1.filename_ima_b=filecell.ima2.civ1{ifile,j}; |
---|
[2] | 1748 | par_civ1.Dt=num2str(time(num2_civ1(ifile),num_b_civ1(j))-time(num1_civ1(ifile),num_a_civ1(j))); |
---|
[112] | 1749 | par_civ1.T0=num2str((time(num2_civ1(ifile),num_b_civ1(j))+time(num1_civ1(ifile),num_a_civ1(j)))/2); |
---|
[2] | 1750 | par_civ1.term_a=num2stra(num_a_civ1(j),nom_type_nc);%UTILITE? |
---|
[112] | 1751 | par_civ1.term_b=num2stra(num_b_civ1(j),nom_type_nc);% |
---|
[2] | 1752 | test_mask=get(handles.get_mask_civ1,'Value'); |
---|
[112] | 1753 | if test_mask==0 |
---|
[2] | 1754 | par_civ1.maskname='noFile use default'; |
---|
| 1755 | par_civ1.maskflag='n'; |
---|
| 1756 | else |
---|
| 1757 | maskdispl=get(handles.mask_civ1,'String'); |
---|
[12] | 1758 | if exist(maskdispl,'file') |
---|
| 1759 | par_civ1.maskname=maskdispl; |
---|
[112] | 1760 | par_civ1.maskflag='y'; |
---|
[2] | 1761 | else |
---|
[136] | 1762 | maskbase=[filecell.filebase '_' maskdispl]; % |
---|
[137] | 1763 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
[12] | 1764 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
| 1765 | par_civ1.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 1766 | if exist(par_civ1.maskname,'file') |
---|
[82] | 1767 | par_civ1.maskflag='y'; |
---|
[12] | 1768 | else |
---|
| 1769 | par_civ1.maskname='noFile use default'; |
---|
[112] | 1770 | par_civ1.maskflag='n'; |
---|
[12] | 1771 | end |
---|
[2] | 1772 | end |
---|
| 1773 | end |
---|
| 1774 | |
---|
| 1775 | test_grid=get(handles.browse_gridciv1,'Value'); |
---|
| 1776 | if test_grid |
---|
| 1777 | par_civ1.gridflag='y'; |
---|
| 1778 | gridname=get(handles.grid_civ1,'String'); |
---|
| 1779 | if isequal(gridname(end-3:end),'grid') |
---|
[137] | 1780 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 1781 | if ~isnan(nbslice_grid) |
---|
[2] | 1782 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
[136] | 1783 | par_civ1.gridname=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
[2] | 1784 | if ~exist(par_civ1.gridname,'file') |
---|
[112] | 1785 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
[2] | 1786 | end |
---|
| 1787 | elseif exist(gridname,'file') |
---|
[112] | 1788 | par_civ1.gridname=gridname; |
---|
[2] | 1789 | else |
---|
| 1790 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
| 1791 | end |
---|
| 1792 | end |
---|
| 1793 | else |
---|
[112] | 1794 | par_civ1.gridname='noFile use default'; |
---|
| 1795 | par_civ1.gridflag='n'; |
---|
[2] | 1796 | end |
---|
[112] | 1797 | % |
---|
[2] | 1798 | i_cmd=i_cmd+1; |
---|
| 1799 | if isequal(civAll,0) |
---|
[230] | 1800 | 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] | 1801 | % if(isunix) |
---|
| 1802 | % cmd=[cmd 'cp -f ' flname '.civ1.cmx ' flname '.cmx\n']; |
---|
| 1803 | % else |
---|
| 1804 | % flname=regexprep(flname,'\\','\\\\'); |
---|
| 1805 | % cmd=[cmd 'copy /Y "' flname '.civ1.cmx" "' flname '.cmx"\n']; |
---|
| 1806 | % end |
---|
[230] | 1807 | cmd=[cmd civ1_exe '\n']; |
---|
[2] | 1808 | else |
---|
[112] | 1809 | civAllCmd=[civAllCmd ' civ1 ']; |
---|
[174] | 1810 | str=CIV1_CMD_Unified(fullfile(Rootbat,Filebat),'',par_civ1); |
---|
[112] | 1811 | fieldnames=fields(str); |
---|
[2] | 1812 | [civAllxml,uid_civ1]=add(civAllxml,1,'element','civ1'); |
---|
| 1813 | for ilist=1:length(fieldnames) |
---|
[112] | 1814 | val=eval(['str.' fieldnames{ilist}]); |
---|
| 1815 | if ischar(val) |
---|
| 1816 | [civAllxml,uid_t]=add(civAllxml,uid_civ1,'element',fieldnames{ilist}); |
---|
| 1817 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 1818 | end |
---|
| 1819 | end |
---|
[2] | 1820 | end |
---|
| 1821 | end |
---|
| 1822 | |
---|
[112] | 1823 | % FIX1 |
---|
| 1824 | if box_test(2)==1 |
---|
| 1825 | test_mask=get(handles.get_mask_fix1,'Value'); |
---|
| 1826 | if test_mask==0 |
---|
[2] | 1827 | maskname=''; |
---|
[112] | 1828 | else |
---|
[2] | 1829 | maskdispl=get(handles.mask_fix1,'String'); |
---|
[137] | 1830 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
[2] | 1831 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
[136] | 1832 | maskbase=[filecell.filebase '_' maskdispl]; |
---|
[2] | 1833 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
[112] | 1834 | end |
---|
| 1835 | if isequal(civAll,0) |
---|
[163] | 1836 | if isunix %unix system |
---|
[94] | 1837 | cmd_FIX=[sparam.FixBin ' -f ' filecell.nc.civ1{ifile,j} ' -fi1 ' num2str(flagindex1(1)) ... |
---|
[112] | 1838 | ' -fi2 ' num2str(flagindex1(2)) ' -fi3 ' num2str(flagindex1(3)) ... |
---|
| 1839 | ' -threshC ' num2str(thresh_vecC1) ' -threshV ' num2str(thresh_vel1) ' -maskName ' maskname]; |
---|
[163] | 1840 | else %windows system |
---|
| 1841 | cmd_FIX=['"' sparam.FixBin '" -f "' filecell.nc.civ1{ifile,j} '" -fi1 ' num2str(flagindex1(1)) ... |
---|
| 1842 | ' -fi2 ' num2str(flagindex1(2)) ' -fi3 ' num2str(flagindex1(3)) ... |
---|
| 1843 | ' -threshC ' num2str(thresh_vecC1) ' -threshV ' num2str(thresh_vel1) ' -maskName "' maskname '"']; |
---|
| 1844 | cmd_FIX=regexprep(cmd_FIX,'\\','\\\\'); |
---|
| 1845 | end |
---|
[94] | 1846 | cmd=[cmd cmd_FIX '\n']; |
---|
[112] | 1847 | else |
---|
[2] | 1848 | fix1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 1849 | fix1.fi1=num2str(flagindex1(1)); |
---|
| 1850 | fix1.fi2=num2str(flagindex1(2)); |
---|
| 1851 | fix1.fi3=num2str(flagindex1(3)); |
---|
| 1852 | fix1.threshC=num2str(thresh_vecC1); |
---|
[112] | 1853 | fix1.threshV=num2str(thresh_vel1); |
---|
[2] | 1854 | fieldnames=fields(fix1); |
---|
| 1855 | [civAllxml,uid_fix1]=add(civAllxml,1,'element','fix1'); |
---|
| 1856 | for ilist=1:length(fieldnames) |
---|
[112] | 1857 | val=eval(['fix1.' fieldnames{ilist}]); |
---|
| 1858 | if ischar(val) |
---|
| 1859 | [civAllxml,uid_t]=add(civAllxml,uid_fix1,'element',fieldnames{ilist}); |
---|
| 1860 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 1861 | end |
---|
| 1862 | end |
---|
| 1863 | civAllCmd=[civAllCmd ' fix1 ']; |
---|
| 1864 | end |
---|
| 1865 | end |
---|
| 1866 | |
---|
| 1867 | %PATCH1 |
---|
| 1868 | if box_test(3)==1 |
---|
| 1869 | if isequal(civAll,0) |
---|
| 1870 | cmd_PATCH=PATCH_CMD(filecell.nc.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp,sparam.PatchBin); |
---|
| 1871 | cmd=[cmd cmd_PATCH '\n']; |
---|
| 1872 | else |
---|
| 1873 | patch1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 1874 | patch1.nopt=subdomain_patch1; |
---|
| 1875 | patch1.maxdiff=thresh_patch1; |
---|
| 1876 | patch1.ro=rho_patch1; |
---|
| 1877 | test_grid=get(handles.get_gridpatch1,'Value'); |
---|
| 1878 | if test_grid |
---|
| 1879 | patch1.gridflag='y'; |
---|
| 1880 | gridname=get(handles.grid_patch1,'String'); |
---|
| 1881 | if isequal(gridname(end-3:end),'grid') |
---|
[137] | 1882 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 1883 | if ~isnan(nbslice_grid) |
---|
[112] | 1884 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
[136] | 1885 | patch1.gridPatch=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
[112] | 1886 | if ~exist(patch1.gridPatch,'file') |
---|
| 1887 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
| 1888 | end |
---|
| 1889 | elseif exist(gridname,'file') |
---|
| 1890 | patch1.gridPatch=gridname; |
---|
| 1891 | else |
---|
| 1892 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
[2] | 1893 | end |
---|
| 1894 | end |
---|
[112] | 1895 | else |
---|
| 1896 | patch1.gridPatch='none'; |
---|
| 1897 | patch1.gridflag='n'; |
---|
| 1898 | patch1.m=nx_patch1; |
---|
| 1899 | patch1.n=ny_patch1; |
---|
[2] | 1900 | end |
---|
[112] | 1901 | patch1.convectFlow='n'; |
---|
| 1902 | fieldnames=fields(patch1); |
---|
[2] | 1903 | [civAllxml,uid_patch1]=add(civAllxml,1,'element','patch1'); |
---|
| 1904 | for ilist=1:length(fieldnames) |
---|
[112] | 1905 | val=eval(['patch1.' fieldnames{ilist}]); |
---|
| 1906 | if ischar(val) |
---|
| 1907 | [civAllxml,uid_t]=add(civAllxml,uid_patch1,'element',fieldnames{ilist}); |
---|
| 1908 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 1909 | end |
---|
| 1910 | end |
---|
| 1911 | civAllCmd=[civAllCmd ' patch1 ']; |
---|
| 1912 | end |
---|
[2] | 1913 | end |
---|
[112] | 1914 | |
---|
[127] | 1915 | if box_test(4)==1 || box_test(5)==1 || box_test(6)==1 |
---|
[112] | 1916 | filename_cmx=filecell.nc.civ2{ifile,j};%output netcdf file |
---|
[229] | 1917 | filename_cmx(end-1:end+1)='cmx';%name of cmx file |
---|
[112] | 1918 | end |
---|
| 1919 | |
---|
| 1920 | if box_test(4)==1 |
---|
[2] | 1921 | par_civ2.filename_ima_a=filecell.ima1.civ2{ifile,j}; |
---|
| 1922 | par_civ2.filename_ima_b=filecell.ima2.civ2{ifile,j}; |
---|
[174] | 1923 | [Rootbat,Filebat]=fileparts(filecell.nc.civ2{ifile,j});%output netcdf file (without extention) |
---|
[2] | 1924 | par_civ2.Dt=num2str(time(num2_civ2(ifile),num_b_civ2(j))-time(num1_civ2(ifile),num_a_civ2(j))); |
---|
[112] | 1925 | par_civ2.T0=num2str((time(num2_civ1(ifile),num_b_civ2(j))+time(num1_civ2(ifile),num_a_civ2(j)))/2); |
---|
[2] | 1926 | par_civ2.term_a=num2stra(num_a_civ2(j),nom_type_nc); |
---|
[112] | 1927 | par_civ2.term_b=num2stra(num_b_civ2(j),nom_type_nc); |
---|
[2] | 1928 | par_civ2.filename_nc1=filecell.nc.civ1{ifile,j}; |
---|
[229] | 1929 | par_civ2.filename_nc1(end-2:end)=[]; % remove '.nc' |
---|
[2] | 1930 | test_mask=get(handles.get_mask_civ2,'Value'); |
---|
[112] | 1931 | if test_mask==0 |
---|
[2] | 1932 | par_civ2.maskname='noFile use default'; |
---|
| 1933 | par_civ2.maskflag='n'; |
---|
| 1934 | else |
---|
| 1935 | maskdispl=get(handles.mask_civ2,'String'); |
---|
[12] | 1936 | if exist(maskdispl,'file') |
---|
| 1937 | par_civ2.maskname=maskdispl; |
---|
| 1938 | par_civ2.maskflag='y'; |
---|
[2] | 1939 | else |
---|
[136] | 1940 | maskbase=[filecell.filebase '_' maskdispl]; % |
---|
[137] | 1941 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
[12] | 1942 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
| 1943 | par_civ2.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 1944 | if exist(par_civ2.maskname,'file') |
---|
[112] | 1945 | par_civ2.maskflag='y'; |
---|
[12] | 1946 | else |
---|
| 1947 | par_civ2.maskname='noFile use default'; |
---|
[112] | 1948 | par_civ2.maskflag='n'; |
---|
[12] | 1949 | end |
---|
[2] | 1950 | end |
---|
| 1951 | end |
---|
| 1952 | %TESTgrid |
---|
[137] | 1953 | %test_grid=get(handles.browse_gridciv2,'Value'); |
---|
[2] | 1954 | gridname=get(handles.grid_civ2,'String'); |
---|
[137] | 1955 | %gridflag='y'; |
---|
[2] | 1956 | if numel(gridname)>=4 && isequal(gridname(end-3:end),'grid') |
---|
[137] | 1957 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 1958 | if ~isnan(nbslice_grid) |
---|
[2] | 1959 | par_civ2.gridflag='y'; |
---|
| 1960 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
[136] | 1961 | par_civ2.gridname=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
[2] | 1962 | if exist(par_civ2.gridname,'file') |
---|
[112] | 1963 | par_civ2.gridflag='y'; |
---|
[2] | 1964 | else |
---|
| 1965 | par_civ2.gridname='noFile use default'; |
---|
[112] | 1966 | par_civ2.gridflag='n'; |
---|
[2] | 1967 | end |
---|
| 1968 | elseif exist(gridname,'file') |
---|
[112] | 1969 | par_civ2.gridflag='y'; |
---|
[2] | 1970 | else |
---|
| 1971 | par_civ2.gridname='noFile use default'; |
---|
[112] | 1972 | par_civ2.gridflag='n'; |
---|
[2] | 1973 | end |
---|
| 1974 | end |
---|
| 1975 | i_cmd=i_cmd+1; |
---|
[177] | 1976 | flname=fullfile(Rootbat,Filebat); |
---|
[230] | 1977 | |
---|
[2] | 1978 | if isequal(civAll,0) |
---|
[230] | 1979 | cmd_CIV2=CIV2_CMD(flname,[],par_civ2,sparam);%creates the cmx file [fullfile(Rootbat,Filebat) '.civ2.cmx] |
---|
| 1980 | % if(isunix) |
---|
| 1981 | cmd=[cmd cmd_CIV2 '\n']; |
---|
| 1982 | % else |
---|
| 1983 | % flname=regexprep(flname,'\\','\\\\'); |
---|
| 1984 | % cmd=[cmd 'copy /Y "' flname '.civ2.cmx" "' flname '.cmx"\n' cmd_CIV2 '\n']; |
---|
| 1985 | % end |
---|
[2] | 1986 | else |
---|
[112] | 1987 | civAllCmd=[civAllCmd ' civ2 ']; |
---|
[220] | 1988 | str=CIV2_CMD_Unified(flname,'',par_civ2); |
---|
[112] | 1989 | fieldnames=fields(str); |
---|
[2] | 1990 | [civAllxml,uid_civ2]=add(civAllxml,1,'element','civ2'); |
---|
| 1991 | for ilist=1:length(fieldnames) |
---|
| 1992 | val=eval(['str.' fieldnames{ilist}]); |
---|
| 1993 | if ischar(val) |
---|
[112] | 1994 | [civAllxml,uid_t]=add(civAllxml,uid_civ2,'element',fieldnames{ilist}); |
---|
| 1995 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
[2] | 1996 | end |
---|
[112] | 1997 | end |
---|
[2] | 1998 | end |
---|
[112] | 1999 | end |
---|
| 2000 | |
---|
| 2001 | % FIX2 |
---|
| 2002 | if box_test(5)==1 |
---|
| 2003 | test_mask=get(handles.get_mask_fix2,'Value'); |
---|
| 2004 | if test_mask==0 |
---|
| 2005 | maskname=''; %no mask used |
---|
[2] | 2006 | else |
---|
| 2007 | maskdispl=get(handles.mask_fix2,'String'); |
---|
[136] | 2008 | maskbase=[filecell.filebase '_' maskdispl]; % |
---|
[137] | 2009 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
[2] | 2010 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
| 2011 | maskname =name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
[112] | 2012 | end |
---|
| 2013 | if isequal(civAll,0) |
---|
[163] | 2014 | if isunix |
---|
[94] | 2015 | cmd_FIX=[sparam.FixBin ' -f ' filecell.nc.civ2{ifile,j} ' -fi1 ' num2str(flagindex2(1)) ... |
---|
[112] | 2016 | ' -fi2 ' num2str(flagindex2(2)) ' -fi3 ' num2str(flagindex2(3)) ... |
---|
| 2017 | ' -threshC ' num2str(thresh_vec2C) ' -threshV ' num2str(thresh_vel2) ' -maskName ' maskname]; |
---|
[163] | 2018 | else |
---|
| 2019 | cmd_FIX=['"' sparam.FixBin '" -f "' filecell.nc.civ2{ifile,j} '" -fi1 ' num2str(flagindex2(1)) ... |
---|
| 2020 | ' -fi2 ' num2str(flagindex2(2)) ' -fi3 ' num2str(flagindex2(3)) ... |
---|
| 2021 | ' -threshC ' num2str(thresh_vec2C) ' -threshV ' num2str(thresh_vel2) ' -maskName "' maskname '"']; |
---|
| 2022 | cmd_FIX=regexprep(cmd_FIX,'\\','\\\\'); |
---|
| 2023 | end |
---|
[112] | 2024 | cmd=[cmd cmd_FIX '\n']; |
---|
| 2025 | else |
---|
[2] | 2026 | fix2.inputFileName=filecell.nc.civ2{ifile,j} ; |
---|
| 2027 | fix2.fi1=num2str(flagindex2(1)); |
---|
| 2028 | fix2.fi2=num2str(flagindex2(2)); |
---|
| 2029 | fix2.fi3=num2str(flagindex2(3)); |
---|
| 2030 | fix2.threshC=num2str(thresh_vec2C); |
---|
[112] | 2031 | fix2.threshV=num2str(thresh_vel2); |
---|
[2] | 2032 | fieldnames=fields(fix2); |
---|
| 2033 | [civAllxml,uid_fix2]=add(civAllxml,1,'element','fix2'); |
---|
| 2034 | for ilist=1:length(fieldnames) |
---|
[112] | 2035 | val=eval(['fix2.' fieldnames{ilist}]); |
---|
| 2036 | if ischar(val) |
---|
| 2037 | [civAllxml,uid_t]=add(civAllxml,uid_fix2,'element',fieldnames{ilist}); |
---|
| 2038 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2039 | end |
---|
| 2040 | end |
---|
| 2041 | civAllCmd=[civAllCmd ' fix2 ']; |
---|
| 2042 | end |
---|
| 2043 | end |
---|
| 2044 | |
---|
| 2045 | %PATCH2 |
---|
| 2046 | if box_test(6)==1 |
---|
[12] | 2047 | if isequal(civAll,0) |
---|
[94] | 2048 | cmd_PATCH=PATCH_CMD(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,test_interp,sparam.PatchBin); |
---|
[90] | 2049 | cmd=[cmd cmd_PATCH '\n']; |
---|
[12] | 2050 | else |
---|
| 2051 | patch2.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
[220] | 2052 | patch2.nopt=subdomain_patch2; |
---|
| 2053 | patch2.maxdiff=thresh_patch2; |
---|
| 2054 | patch2.ro=rho_patch2; |
---|
[12] | 2055 | test_grid=get(handles.get_gridpatch2,'Value'); |
---|
| 2056 | if test_grid |
---|
| 2057 | patch2.gridflag='y'; |
---|
| 2058 | gridname=get(handles.grid_patch2,'String'); |
---|
| 2059 | if isequal(gridname(end-3:end),'grid') |
---|
[137] | 2060 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 2061 | if ~isnan(nbslice_grid) |
---|
[12] | 2062 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
[136] | 2063 | patch2.gridPatch=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
[12] | 2064 | if ~exist(patch2.gridPatch,'file') |
---|
[112] | 2065 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
[12] | 2066 | end |
---|
| 2067 | elseif exist(gridname,'file') |
---|
[112] | 2068 | patch2.gridPatch=gridname; |
---|
[12] | 2069 | else |
---|
| 2070 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
[2] | 2071 | end |
---|
| 2072 | end |
---|
[12] | 2073 | else |
---|
[112] | 2074 | patch2.gridPatch='none'; |
---|
| 2075 | patch2.gridflag='n'; |
---|
| 2076 | patch2.m=nx_patch2; |
---|
| 2077 | patch2.n=ny_patch2; |
---|
[2] | 2078 | end |
---|
[12] | 2079 | patch2.convectFlow='n'; |
---|
| 2080 | fieldnames=fields(patch2); |
---|
| 2081 | [civAllxml,uid_patch2]=add(civAllxml,1,'element','patch2'); |
---|
| 2082 | for ilist=1:length(fieldnames) |
---|
[112] | 2083 | val=eval(['patch2.' fieldnames{ilist}]); |
---|
| 2084 | if ischar(val) |
---|
| 2085 | [civAllxml,uid_t]=add(civAllxml,uid_patch2,'element',fieldnames{ilist}); |
---|
| 2086 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
| 2087 | end |
---|
| 2088 | end |
---|
[12] | 2089 | civAllCmd=[civAllCmd ' patch2 ']; |
---|
[112] | 2090 | end |
---|
[12] | 2091 | end |
---|
| 2092 | if isequal(civAll,1) |
---|
[220] | 2093 | save(civAllxml,[flname '.xml']); |
---|
[225] | 2094 | cmd=[cmd sparam.CivBin ' -f ' flname '.xml ' civAllCmd ' >' flname '.log' '\n']; |
---|
[12] | 2095 | end |
---|
[112] | 2096 | % create the .bat file: |
---|
[159] | 2097 | [fid,message]=fopen(filename_bat,'w'); |
---|
| 2098 | if isequal(fid,-1) |
---|
| 2099 | msgbox_uvmat('ERROR', ['creation of .bat file: ' message]) |
---|
| 2100 | return |
---|
[12] | 2101 | end |
---|
[39] | 2102 | fprintf(fid,cmd); |
---|
| 2103 | fclose(fid); |
---|
[67] | 2104 | if batch |
---|
| 2105 | switch batch_mode |
---|
| 2106 | case 'sge' |
---|
| 2107 | pvalue=num2str((1-ind_answer)*500); |
---|
[177] | 2108 | display(['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]); |
---|
| 2109 | eval( ['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]); |
---|
[67] | 2110 | end |
---|
[225] | 2111 | elseif ~isequal(get(handles.CivAll,'Value'),3) |
---|
[112] | 2112 | %% to lauch the jobs locally : |
---|
[12] | 2113 | if(isunix) |
---|
[135] | 2114 | cmd_str=['. ' filename_bat]; |
---|
[133] | 2115 | else %case of Windows |
---|
[163] | 2116 | cmd_str=['@call "' regexprep(filename_bat,'\\','\\\\') '"']; |
---|
[2] | 2117 | end |
---|
[135] | 2118 | super_cmd=[super_cmd cmd_str '\n']; |
---|
| 2119 | disp(cmd_str); |
---|
[225] | 2120 | else %run PIVlab if selected |
---|
[231] | 2121 | Data=civ_uvmat(par_civ1); |
---|
| 2122 | % image1=imread(par_civ1.filename_ima_a); |
---|
| 2123 | % image2=imread(par_civ1.filename_ima_b); |
---|
| 2124 | % stepx=str2num(par_civ1.dx); |
---|
| 2125 | % stepy=str2num(par_civ1.dy); |
---|
| 2126 | % ibx2=ceil(str2num(par_civ1.ibx)/2); |
---|
| 2127 | % iby2=ceil(str2num(par_civ1.iby)/2); |
---|
| 2128 | % isx2=ceil(str2num(par_civ1.isx)/2); |
---|
| 2129 | % isy2=ceil(str2num(par_civ1.isy)/2); |
---|
| 2130 | % shiftx=str2num(par_civ1.shiftx); |
---|
| 2131 | % shifty=str2num(par_civ1.shifty); |
---|
| 2132 | % % ibx=2*ibx2-1;%ibx and iby odd, reduced by 1 if even |
---|
| 2133 | % % iby=2*iby2-1; |
---|
| 2134 | % miniy=max(1+isy2-shifty,1+iby2); |
---|
| 2135 | % minix=max(1+isx2-shiftx,1+ibx2); |
---|
| 2136 | % maxiy=min(size(image1,1)-isy2-shifty,size(image1,1)-iby2); |
---|
| 2137 | % maxix=min(size(image1,2)-isx2-shiftx,size(image1,2)-ibx2); |
---|
| 2138 | % [GridX,GridY]=meshgrid(minix:stepx:maxix,miniy:stepy:maxiy); |
---|
| 2139 | % PointCoord(:,1)=reshape(GridX,[],1); |
---|
| 2140 | % PointCoord(:,2)=reshape(GridY,[],1); |
---|
| 2141 | % % caluclate velocity data (y and v in indices, reverse to y component) |
---|
| 2142 | % [xtable ytable utable vtable ctable typevector] = pivlab (image1,image2,ibx2,iby2,isx2,isy2,shiftx,shifty,PointCoord, 1, []); |
---|
| 2143 | % Data.ListGlobalAttribute={'title','Time','Dt'}; |
---|
| 2144 | % Data.title='PIVlab'; |
---|
| 2145 | % Data.Time=str2double(par_civ1.T0); |
---|
| 2146 | % Data.Dt=str2double(par_civ1.Dt); |
---|
| 2147 | % Data.ListVarName={'X','Y','U','V','C','FF'};% cell array containing the names of the fields to record |
---|
| 2148 | % Data.VarDimName={'nbvec','nbvec','nbvec','nbvec','nbvec','nbvec'}; |
---|
| 2149 | % Data.VarAttribute{1}.Role='coord_x'; |
---|
| 2150 | % Data.VarAttribute{2}.Role='coord_y'; |
---|
| 2151 | % Data.VarAttribute{3}.Role='vector_x'; |
---|
| 2152 | % Data.VarAttribute{4}.Role='vector_y'; |
---|
| 2153 | % Data.VarAttribute{5}.Role='errorflag'; |
---|
| 2154 | % Data.X=reshape(xtable,[],1); |
---|
| 2155 | % Data.Y=reshape(size(image1,1)-ytable+1,[],1); |
---|
| 2156 | % Data.U=reshape(utable,[],1); |
---|
| 2157 | % Data.V=reshape(-vtable,[],1); |
---|
| 2158 | % Data.C=reshape(ctable,[],1); |
---|
| 2159 | % Data.FF=reshape(~typevector,[],1); |
---|
[225] | 2160 | errormsg=struct2nc(filecell.nc.civ1{ifile,j},Data); |
---|
| 2161 | if isempty(errormsg) |
---|
| 2162 | display([filecell.nc.civ1{ifile,j} ' written']) |
---|
| 2163 | else |
---|
| 2164 | msgbox_uvmat('ERROR',errormsg) |
---|
| 2165 | end |
---|
| 2166 | end |
---|
[112] | 2167 | end |
---|
[2] | 2168 | end |
---|
[134] | 2169 | |
---|
[225] | 2170 | if ~batch && ~isequal(get(handles.CivAll,'Value'),3) |
---|
[159] | 2171 | [Rootbat,Filebat,extbat]=fileparts(filename_bat); |
---|
[229] | 2172 | filename_superbat=fullfile(Rootbat,'job_list.bat'); |
---|
[134] | 2173 | fid=fopen(filename_superbat,'w'); |
---|
| 2174 | fprintf(fid,super_cmd'); |
---|
| 2175 | fclose(fid); |
---|
[219] | 2176 | if(isunix) |
---|
| 2177 | system(['chmod +x ' filename_superbat]) |
---|
| 2178 | end |
---|
[192] | 2179 | system([filename_superbat ' &'])% execute main commmand |
---|
[133] | 2180 | end |
---|
[2] | 2181 | |
---|
[137] | 2182 | %% save interface state |
---|
[2] | 2183 | if isfield(filecell,'nc') |
---|
| 2184 | if isfield(filecell.nc,'civ2') |
---|
| 2185 | fileresu=filecell.nc.civ2{1,1}; |
---|
| 2186 | else |
---|
| 2187 | fileresu=filecell.nc.civ1{1,1}; |
---|
| 2188 | end |
---|
| 2189 | end |
---|
| 2190 | [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileresu); |
---|
| 2191 | namedoc=fullfile(RootPath,subdir,RootFile); |
---|
[112] | 2192 | detect=1; |
---|
[2] | 2193 | while detect==1 |
---|
| 2194 | namefigfull=[namedoc '.fig']; |
---|
| 2195 | hh=dir(namefigfull); |
---|
| 2196 | if ~isempty(hh) |
---|
| 2197 | detect=1; |
---|
| 2198 | namedoc=[namedoc '.0']; |
---|
| 2199 | else |
---|
| 2200 | detect=0; |
---|
| 2201 | end |
---|
| 2202 | end |
---|
| 2203 | saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) |
---|
| 2204 | |
---|
[227] | 2205 | %------------------------------------------------------------------------ |
---|
| 2206 | % --- determine the list of reference indices of processing file |
---|
| 2207 | function [ref_i,ref_j,errormsg]=find_ref_indices(handles) |
---|
| 2208 | %------------------------------------------------------------------------ |
---|
| 2209 | errormsg=''; %default error message |
---|
| 2210 | first_i=str2double(get(handles.first_i,'String'));%first index i |
---|
| 2211 | last_i=str2double(get(handles.last_i,'String'));%last index i |
---|
| 2212 | incr_i=str2double(get(handles.incr_i,'String'));% increment |
---|
| 2213 | if isequal(get(handles.first_j,'Visible'),'on') |
---|
| 2214 | first_j=str2double(get(handles.first_j,'String'));%first index j |
---|
| 2215 | last_j=str2double(get(handles.last_j,'String'));%last index j |
---|
| 2216 | incr_j=str2double(get(handles.incr_j,'String'));% increment |
---|
| 2217 | else |
---|
| 2218 | first_j=1; |
---|
| 2219 | last_j=1; |
---|
| 2220 | incr_j=1; |
---|
| 2221 | end |
---|
| 2222 | ref_i=first_i:incr_i:last_i;% list of i indices (reference values for each pair) |
---|
| 2223 | ref_j=first_j:incr_j:last_j;% list of j indices (reference values for each pair) |
---|
| 2224 | if isnan(first_i)||isnan(first_j) |
---|
| 2225 | errormsg='first field number not defined'; |
---|
| 2226 | elseif isnan(last_i)||isnan(last_j) |
---|
| 2227 | errormsg='last field number not defined'; |
---|
| 2228 | elseif isnan(incr_i)||isnan(incr_j) |
---|
| 2229 | errormsg='increment in field number not defined'; |
---|
| 2230 | elseif last_i < first_i || last_j < first_j |
---|
| 2231 | errormsg='last field number must be larger than the first one'; |
---|
| 2232 | end |
---|
[134] | 2233 | |
---|
[227] | 2234 | %------------------------------------------------------------------------ |
---|
| 2235 | % --- determine the list of filenames and indices needed for launch_job |
---|
[2] | 2236 | 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] | 2237 | set_civ_filenames(handles,ref_i,ref_j,box_test) |
---|
[12] | 2238 | %------------------------------------------------------------------------ |
---|
[85] | 2239 | filecell=[];%default |
---|
[136] | 2240 | |
---|
| 2241 | %% get the root names nomenclature and numbers |
---|
[71] | 2242 | filebase=get(handles.RootName,'String'); |
---|
[136] | 2243 | |
---|
| 2244 | if isempty(filebase)||isequal(filebase,'') |
---|
| 2245 | msgbox_uvmat('ERROR','no input files') |
---|
| 2246 | return |
---|
| 2247 | end |
---|
| 2248 | |
---|
[137] | 2249 | %filebase=regexprep(filebase,'\.fsnet','fsnet');% temporary fix for cluster Coriolis |
---|
[136] | 2250 | filecell.filebase=filebase; |
---|
| 2251 | |
---|
[2] | 2252 | browse=get(handles.browse_root,'UserData'); |
---|
| 2253 | compare_list=get(handles.compare,'String'); |
---|
| 2254 | val=get(handles.compare,'Value'); |
---|
| 2255 | compare=compare_list{val}; |
---|
| 2256 | if strcmp(compare,'displacement') |
---|
| 2257 | mode='displacement'; |
---|
| 2258 | else |
---|
| 2259 | mode_list=get(handles.mode,'String'); |
---|
| 2260 | mode_value=get(handles.mode,'Value'); |
---|
| 2261 | mode=mode_list{mode_value}; |
---|
| 2262 | end |
---|
[137] | 2263 | %time=get(handles.RootName,'UserData'); %get the set of times |
---|
[71] | 2264 | ext_ima=get(handles.ImaExt,'String'); |
---|
[2] | 2265 | nom_type_nc=browse.nom_type_nc; |
---|
[122] | 2266 | if isfield(browse,'nom_type_ima') |
---|
| 2267 | nom_type_ima2=browse.nom_type_ima; |
---|
| 2268 | end |
---|
| 2269 | if isempty(nom_type_ima2),nom_type_ima2='1';end; %default |
---|
| 2270 | if isempty(nom_type_nc),nom_type_nc='_i1-i2';end; %default |
---|
[2] | 2271 | [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
[227] | 2272 | find_pair_indices(handles,ref_i,ref_j,mode); |
---|
[2] | 2273 | %determine the new filebase for 'displacement' mode (comparison of two series) |
---|
| 2274 | filebase_B=filebase;% root name of the second field series for stereo |
---|
| 2275 | if strcmp(compare,'displacement') || strcmp(compare,'stereo PIV') |
---|
[127] | 2276 | % test_disp=1; |
---|
[2] | 2277 | nom_type_ima1=browse.nom_type_ima_1; %nomenclature type of the second file series |
---|
| 2278 | [Path2,Name2]=fileparts(filebase_B); |
---|
| 2279 | Path1=Path2; |
---|
[71] | 2280 | Name1=get(handles.RootName_1,'String');% root name of the first field series for stereo |
---|
[2] | 2281 | filebase_A=fullfile(Path1,Name1); |
---|
| 2282 | if length(Name1)>6 |
---|
| 2283 | Name1=Name1(end-5:end); |
---|
| 2284 | end |
---|
| 2285 | if length(Name2)>6 |
---|
| 2286 | Name2=Name2(end-5:end); |
---|
| 2287 | end |
---|
| 2288 | filebase_AB=fullfile(Path2,[Name2 '-' Name1]); |
---|
| 2289 | else |
---|
[127] | 2290 | % test_disp=0; |
---|
[2] | 2291 | filebase_A=filebase; |
---|
| 2292 | nom_type_ima1=nom_type_ima2; |
---|
| 2293 | filebase_AB=filebase; |
---|
| 2294 | end |
---|
| 2295 | if strcmp(compare,'displacement') |
---|
[112] | 2296 | filebase_ima1=filebase_A; |
---|
| 2297 | filebase_ima2=filebase_B; |
---|
| 2298 | filebase_nc=filebase_AB; %root name for the result of civ2 |
---|
[2] | 2299 | else |
---|
[112] | 2300 | filebase_ima1=filebase_B; |
---|
| 2301 | filebase_ima2=filebase_B; |
---|
| 2302 | filebase_nc=filebase_B; |
---|
| 2303 | end |
---|
[2] | 2304 | |
---|
| 2305 | %determine reference files for fix: |
---|
| 2306 | file_ref_fix1={};%default |
---|
| 2307 | file_ref_fix2={}; |
---|
| 2308 | nbfield=length(num1_civ1); |
---|
| 2309 | nbslice=length(num_a_civ1); |
---|
| 2310 | if box_test(2)==1% fix1 performed |
---|
| 2311 | ref=get(handles.ref_fix1,'UserData');%read data on the ref file stored by get_ref_fix1_Callback |
---|
| 2312 | if ~isempty(ref) |
---|
[137] | 2313 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 2314 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 2315 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 2316 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 2317 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 2318 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[127] | 2319 | num_i_ref=first_i:incr_i:last_i; |
---|
| 2320 | num_j_ref=first_j:incr_j:last_j; |
---|
[2] | 2321 | if isequal(mode,'displacement') |
---|
| 2322 | num_i1=num_i_ref; |
---|
| 2323 | num_i2=num_i_ref; |
---|
| 2324 | num_j1=num_j_ref; |
---|
| 2325 | num_j2=num_j_ref; |
---|
| 2326 | elseif isequal(mode,'pair j1-j2')% isequal(mode,'st_pair j1-j2') |
---|
| 2327 | num_i1=num_i_ref; |
---|
| 2328 | num_i2=num_i1; |
---|
| 2329 | num_j1=ref.num_a*ones(size(num_i_ref)); |
---|
| 2330 | num_j2=ref.num_b*ones(size(num_i_ref)); |
---|
| 2331 | elseif isequal(mode,'series(Di)') % isequal(mode,'st_series(Di)') |
---|
| 2332 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 2333 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 2334 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 2335 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 2336 | if isempty(ref.num_a) |
---|
| 2337 | ref.num_a=1; |
---|
| 2338 | end |
---|
| 2339 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 2340 | num_j2=num_j1; |
---|
| 2341 | elseif isequal(mode,'series(Dj)')%| isequal(mode,'st_series(Dj)') |
---|
| 2342 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 2343 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 2344 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 2345 | num_i2=num_i1; |
---|
| 2346 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 2347 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 2348 | end |
---|
| 2349 | for ifile=1:nbfield |
---|
| 2350 | for j=1:nbslice |
---|
| 2351 | 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);% |
---|
| 2352 | file_ref_fix1(ifile,j)={file_ref}; |
---|
| 2353 | if ~exist(file_ref,'file') |
---|
| 2354 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix1']) |
---|
[12] | 2355 | filecell=[]; |
---|
[2] | 2356 | return |
---|
| 2357 | end |
---|
| 2358 | end |
---|
| 2359 | end |
---|
| 2360 | end |
---|
| 2361 | end |
---|
| 2362 | |
---|
| 2363 | %determine reference files for fix2: |
---|
| 2364 | if box_test(5)==1% fix2 performed |
---|
| 2365 | ref=get(handles.ref_fix2,'UserData'); |
---|
| 2366 | if ~isempty(ref) |
---|
[127] | 2367 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 2368 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 2369 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 2370 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 2371 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 2372 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[229] | 2373 | num_i_ref=first_i:incr_i:last_i; |
---|
| 2374 | num_j_ref=first_j:incr_j:last_j; |
---|
[2] | 2375 | if isequal(mode,'displacement') |
---|
| 2376 | num_i1=num_i_ref; |
---|
| 2377 | num_i2=num_i_ref; |
---|
| 2378 | num_j1=num_j_ref; |
---|
| 2379 | num_j2=num_j_ref; |
---|
| 2380 | elseif isequal(mode,'pair j1-j2') |
---|
| 2381 | num_i1=num_i_ref; |
---|
| 2382 | num_i2=num_i1; |
---|
| 2383 | num_j1=ref.num_a; |
---|
| 2384 | num_j2=ref.num_b; |
---|
| 2385 | elseif isequal(mode,'series(Di)') |
---|
| 2386 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 2387 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 2388 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 2389 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 2390 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 2391 | num_j2=num_j1; |
---|
| 2392 | elseif isequal(mode,'series(Dj)') |
---|
| 2393 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 2394 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 2395 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 2396 | num_i2=num_i1; |
---|
| 2397 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 2398 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 2399 | end |
---|
| 2400 | for ifile=1:nbfield |
---|
| 2401 | for j=1:nbslice |
---|
| 2402 | 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);% |
---|
| 2403 | file_ref_fix2(ifile,j)={file_ref}; |
---|
| 2404 | if ~exist(file_ref,'file') |
---|
| 2405 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix2']) |
---|
[122] | 2406 | filecell={}; |
---|
[2] | 2407 | return |
---|
| 2408 | end |
---|
| 2409 | end |
---|
| 2410 | end |
---|
| 2411 | end |
---|
| 2412 | end |
---|
| 2413 | |
---|
| 2414 | %check dir |
---|
| 2415 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf output data |
---|
| 2416 | subdir_civ2=get(handles.subdir_civ2,'String'); |
---|
[174] | 2417 | if isequal(subdir_civ1,''),subdir_civ1='CIV'; end% put default subdir |
---|
[2] | 2418 | if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end% put default subdir |
---|
[135] | 2419 | currentdir=pwd;%store the current working directory |
---|
[2] | 2420 | [Path_ima,Name]=fileparts(filebase);%Path of the image files (.civ) |
---|
| 2421 | if ~exist(Path_ima,'dir') |
---|
[12] | 2422 | msgbox_uvmat('ERROR',['path to images ' Path_ima ' not found']) |
---|
[122] | 2423 | filecell={}; |
---|
[2] | 2424 | return |
---|
| 2425 | end |
---|
[127] | 2426 | [xx,message]=fileattrib(Path_ima); |
---|
[122] | 2427 | if ~isempty(message) && ~isequal(message.UserWrite,1) |
---|
[112] | 2428 | msgbox_uvmat('ERROR',['No writting access to ' Path_ima]) |
---|
[122] | 2429 | filecell={}; |
---|
[112] | 2430 | cd(currentdir); |
---|
| 2431 | return |
---|
[2] | 2432 | end |
---|
| 2433 | |
---|
| 2434 | %check the existence of the netcdf and image files involved |
---|
| 2435 | % %%%%%%%%%%%% case CIV1 activated %%%%%%%%%%%%% |
---|
| 2436 | if box_test(1)==1; |
---|
[112] | 2437 | detect=1; |
---|
[127] | 2438 | vers=0; |
---|
| 2439 | subdir_civ1_new=subdir_civ1; |
---|
[153] | 2440 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
[122] | 2441 | for ifile=1:nbfield |
---|
[112] | 2442 | for j=1:nbslice |
---|
[122] | 2443 | 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] | 2444 | detect=exist(filename,'file')==2; |
---|
| 2445 | if detect% if a netcdf file already exists |
---|
[137] | 2446 | indstr=regexp(subdir_civ1_new,'\D'); |
---|
| 2447 | if indstr(end)<length(subdir_civ1_new) %subdir_civ1 ends by a number |
---|
| 2448 | vers=str2double(subdir_civ1_new(indstr(end)+1:end))+1; |
---|
| 2449 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) num2str(vers)]; |
---|
[127] | 2450 | else |
---|
| 2451 | vers=vers+1; |
---|
[137] | 2452 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) '_' num2str(vers)]; |
---|
[127] | 2453 | end |
---|
[137] | 2454 | subdir_civ2=subdir_civ1_new; |
---|
[112] | 2455 | break |
---|
| 2456 | end |
---|
| 2457 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 2458 | end |
---|
| 2459 | if detect% if a netcdf file already exists |
---|
| 2460 | break |
---|
| 2461 | end |
---|
| 2462 | end |
---|
[134] | 2463 | |
---|
[112] | 2464 | %create the new subdir_civ1 |
---|
[127] | 2465 | if ~exist(fullfile(Path_ima,subdir_civ1_new),'dir') |
---|
[134] | 2466 | cd(Path_ima); |
---|
[128] | 2467 | [xx,msg1]=mkdir(subdir_civ1_new); |
---|
[134] | 2468 | |
---|
[128] | 2469 | if ~strcmp(msg1,'') |
---|
| 2470 | msgbox_uvmat('ERROR',['cannot create ' subdir_civ1_new ': ' msg1])%error message for directory creation |
---|
[122] | 2471 | filecell={}; |
---|
| 2472 | return |
---|
[163] | 2473 | elseif isunix |
---|
[128] | 2474 | [xx,msg2] = fileattrib(subdir_civ1_new,'+w','g'); %yield writing access (+w) to user group (g) |
---|
| 2475 | if ~strcmp(msg2,'') |
---|
[134] | 2476 | msgbox_uvmat('ERROR',['pb of permission for ' subdir_civ1_new ': ' msg2])%error message for directory creation |
---|
[128] | 2477 | filecell={}; |
---|
| 2478 | return |
---|
| 2479 | end |
---|
[112] | 2480 | end |
---|
[134] | 2481 | cd(currentdir); |
---|
[112] | 2482 | end |
---|
| 2483 | if strcmp(compare,'stereo PIV')&&(strcmp(mode,'pair j1-j2')||strcmp(mode,'series(Dj)')||strcmp(mode,'series(Di)'))%check second nc series |
---|
| 2484 | for ifile=1:nbfield |
---|
| 2485 | for j=1:nbslice |
---|
[122] | 2486 | 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] | 2487 | detect=exist(filename,'file')==2; |
---|
[2] | 2488 | if detect% if a netcdf file already exists |
---|
[137] | 2489 | indstr=regexp(subdir_civ1_new,'\D'); |
---|
| 2490 | if indstr(end)<length(subdir_civ1_new) %subdir_civ1 ends by a number |
---|
| 2491 | vers=str2double(subdir_civ1_new(indstr(end)+1:end))+1; |
---|
| 2492 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) num2str(vers)]; |
---|
[127] | 2493 | else |
---|
| 2494 | vers=vers+1; |
---|
[137] | 2495 | subdir_civ1_new=[subdir_civ1_new '_' num2str(vers)]; |
---|
[127] | 2496 | end |
---|
| 2497 | subdir_civ2=subdir_civ1; |
---|
| 2498 | break |
---|
[2] | 2499 | end |
---|
[112] | 2500 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
| 2501 | end |
---|
| 2502 | if detect% if a netcdf file already exists |
---|
| 2503 | break |
---|
| 2504 | end |
---|
| 2505 | end |
---|
| 2506 | %create the new subdir_civ1 |
---|
[134] | 2507 | if exist(fullfile(Path_ima,subdir_civ1_new),'dir') |
---|
| 2508 | cd(Path_ima); |
---|
[128] | 2509 | [xx,msg1]=mkdir(subdir_civ1_new); |
---|
[134] | 2510 | cd(currentdir); |
---|
[128] | 2511 | if ~strcmpl(msg1,'') |
---|
| 2512 | msgbox_uvmat('ERROR',['cannot create ' subdir_civ1_new ': ' msg1]) |
---|
[122] | 2513 | cd(currentdir) |
---|
| 2514 | filecell={}; |
---|
| 2515 | return |
---|
[128] | 2516 | else |
---|
| 2517 | [xx,msg2] = fileattrib(subdir_civ1_new,'+w','g'); %yield writing access (+w) to user group (g) |
---|
| 2518 | if ~strcmp(msg2,'') |
---|
| 2519 | msgbox_uvmat('ERROR',['pb of permission for ' subdir_civ1_new ': ' msg2])%error message for directory creation |
---|
| 2520 | cd(currentdir) |
---|
| 2521 | filecell={}; |
---|
| 2522 | return |
---|
| 2523 | end |
---|
[112] | 2524 | end |
---|
| 2525 | end |
---|
| 2526 | end |
---|
| 2527 | end |
---|
[127] | 2528 | subdir_civ1=subdir_civ1_new; |
---|
[2] | 2529 | % get image names |
---|
| 2530 | for ifile=1:nbfield |
---|
[112] | 2531 | for j=1:nbslice |
---|
[2] | 2532 | filename=name_generator(filebase_ima1, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
| 2533 | idetect(j)=exist(filename,'file')==2; |
---|
| 2534 | filecell.ima1.civ1(ifile,j)={filename}; %first image |
---|
| 2535 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
| 2536 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 2537 | filecell.ima2.civ1(ifile,j)={filename};%second image |
---|
[112] | 2538 | end |
---|
| 2539 | [idetectmin,indexj]=min(idetect); |
---|
| 2540 | if idetectmin==0, |
---|
| 2541 | msgbox_uvmat('ERROR',[filecell.ima1.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2542 | filecell={}; |
---|
| 2543 | cd(currentdir) |
---|
[112] | 2544 | return |
---|
| 2545 | end |
---|
| 2546 | [idetectmin,indexj]=min(idetect_1); |
---|
| 2547 | if idetectmin==0, |
---|
| 2548 | msgbox_uvmat('ERROR',[filecell.ima2.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2549 | filecell={}; |
---|
[112] | 2550 | cd(currentdir) |
---|
| 2551 | return |
---|
| 2552 | end |
---|
| 2553 | end |
---|
| 2554 | if strcmp(compare,'stereo PIV') && (strcmp(mode,'pair j1-j2') || strcmp(mode,'series(Dj)') || strcmp(mode,'series(Di)')) |
---|
| 2555 | for ifile=1:nbfield |
---|
| 2556 | for j=1:nbslice |
---|
| 2557 | filename=name_generator(filebase_A, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
| 2558 | idetect(j)=exist(filename,'file')==2; |
---|
| 2559 | filecell.imaA1.civ1(ifile,j)={filename} ;%first image |
---|
| 2560 | filename=name_generator(filebase_A, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
| 2561 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 2562 | filecell.imaA2.civ1(ifile,j)={filename};%second image |
---|
| 2563 | end |
---|
[2] | 2564 | [idetectmin,indexj]=min(idetect); |
---|
[112] | 2565 | if idetectmin==0, |
---|
| 2566 | msgbox_uvmat('ERROR',[filecell.imaA1.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2567 | filecell={}; |
---|
[112] | 2568 | cd(currentdir) |
---|
[2] | 2569 | return |
---|
[112] | 2570 | end |
---|
[2] | 2571 | [idetectmin,indexj]=min(idetect_1); |
---|
[112] | 2572 | if idetectmin==0, |
---|
| 2573 | msgbox_uvmat('ERROR',[filecell.imaA2.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2574 | filecell={}; |
---|
[2] | 2575 | cd(currentdir) |
---|
| 2576 | return |
---|
[112] | 2577 | end |
---|
| 2578 | end |
---|
[2] | 2579 | end |
---|
[112] | 2580 | |
---|
| 2581 | %%%%%%%%%%%%% fix1 or patch1 activated but no civ1 %%%%%%%%%%%%% |
---|
| 2582 | elseif (box_test(2)==1 || box_test(3)==1); |
---|
[2] | 2583 | for ifile=1:nbfield |
---|
| 2584 | for j=1:nbslice |
---|
| 2585 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
[112] | 2586 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 2587 | detect=exist(filename,'file')==2; |
---|
[122] | 2588 | if detect==0 |
---|
| 2589 | msgbox_uvmat('ERROR',[filename ' not found']) |
---|
| 2590 | filecell={}; |
---|
| 2591 | cd(currentdir) |
---|
| 2592 | return |
---|
| 2593 | end |
---|
[2] | 2594 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 2595 | end |
---|
| 2596 | end |
---|
| 2597 | if strcmp(compare,'stereo PIV') |
---|
[112] | 2598 | for ifile=1:nbfield |
---|
| 2599 | for j=1:nbslice |
---|
| 2600 | 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);% |
---|
| 2601 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
| 2602 | if ~exist(filename,'file') |
---|
| 2603 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
| 2604 | set(handles.RUN, 'Enable','On') |
---|
| 2605 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
[122] | 2606 | filecell={}; |
---|
[112] | 2607 | cd(currentdir) |
---|
| 2608 | return |
---|
[2] | 2609 | end |
---|
| 2610 | end |
---|
[112] | 2611 | end |
---|
[2] | 2612 | end |
---|
| 2613 | end |
---|
| 2614 | |
---|
| 2615 | %%%%%%%%%%%%% if civ2 performed with pairs different than civ1 %%%%%%%%%%%%% |
---|
| 2616 | testdiff=0; |
---|
| 2617 | if (box_test(4)==1)&&... |
---|
[127] | 2618 | ((get(handles.list_pair_civ1,'Value')~=get(handles.list_pair_civ2,'Value'))||~strcmp(subdir_civ2,subdir_civ1)) |
---|
[2] | 2619 | testdiff=1; |
---|
[112] | 2620 | detect=1; |
---|
[127] | 2621 | vers=0; |
---|
| 2622 | subdir_civ2_new=subdir_civ2; |
---|
[2] | 2623 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
[112] | 2624 | for ifile=1:nbfield |
---|
| 2625 | for j=1:nbslice |
---|
[127] | 2626 | 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] | 2627 | detect=exist(filename,'file')==2; |
---|
| 2628 | if detect% if a netcdf file already exists |
---|
[127] | 2629 | indstr=regexp(subdir_civ2,'\D'); |
---|
| 2630 | if indstr(end)<length(subdir_civ2) %subdir_civ1 ends by a number |
---|
| 2631 | vers=str2double(subdir_civ2(indstr(end)+1:end))+1; |
---|
| 2632 | subdir_civ2_new=[subdir_civ2(1:indstr(end)) num2str(vers)]; |
---|
| 2633 | else |
---|
| 2634 | vers=vers+1; |
---|
| 2635 | subdir_civ2_new=[subdir_civ1 '_' num2str(vers)]; |
---|
| 2636 | end |
---|
[112] | 2637 | break |
---|
| 2638 | end |
---|
| 2639 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 2640 | end |
---|
| 2641 | if detect% if a netcdf file already exists |
---|
| 2642 | break |
---|
| 2643 | end |
---|
| 2644 | end |
---|
[128] | 2645 | %create the new subdir_civ2_new |
---|
| 2646 | if ~exist(fullfile(Path_ima,subdir_civ2_new),'dir') |
---|
[174] | 2647 | [xx,m2]=mkdir(fullfile(Path_ima,subdir_civ2_new)); |
---|
[128] | 2648 | [xx,msg2] = fileattrib(subdir_civ2_new,'+w','g'); %yield writing access (+w) to user group (g) |
---|
[112] | 2649 | if ~isequal(m2,'') |
---|
[128] | 2650 | msgbox_uvmat('ERROR',['cannot create ' subdir_civ2_new ': ' m2]) |
---|
[122] | 2651 | filecell={}; |
---|
| 2652 | cd(currentdir) |
---|
| 2653 | return |
---|
[112] | 2654 | end |
---|
| 2655 | end |
---|
| 2656 | if strcmp(compare,'stereo PIV')%check second nc series |
---|
| 2657 | for ifile=1:nbfield |
---|
| 2658 | for j=1:nbslice |
---|
| 2659 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
[122] | 2660 | nom_type_nc,1,num2_civ2(ifile),num_b_civ1(j),subdir_civ2_new);% |
---|
[112] | 2661 | detect=exist(filename,'file')==2; |
---|
[2] | 2662 | if detect% if a netcdf file already exists |
---|
[127] | 2663 | indstr=regexp(subdir_civ2,'\D'); |
---|
| 2664 | if indstr(end)<length(subdir_civ2) %subdir_civ1 ends by a number |
---|
| 2665 | vers=str2double(subdir_civ2(indstr(end)+1:end))+1; |
---|
| 2666 | subdir_civ2_new=[subdir_civ2(1:indstr(end)) num2str(vers)]; |
---|
| 2667 | else |
---|
| 2668 | vers=vers+1; |
---|
| 2669 | subdir_civ2_new=[subdir_civ1 '_' num2str(vers)]; |
---|
| 2670 | end |
---|
[112] | 2671 | break |
---|
[2] | 2672 | end |
---|
[112] | 2673 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 2674 | end |
---|
| 2675 | if detect% if a netcdf file already exists |
---|
| 2676 | break |
---|
| 2677 | end |
---|
| 2678 | end |
---|
[122] | 2679 | subdir_civ2=subdir_civ2_new; |
---|
[112] | 2680 | %create the new subdir_civ1 |
---|
[127] | 2681 | if ~exist(fullfile(Path_ima,subdir_civ2_new),'dir') |
---|
| 2682 | [xx,m2]=mkdir(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])%error message for directory creation |
---|
[122] | 2686 | cd(currentdir) |
---|
| 2687 | filecell={}; |
---|
| 2688 | return |
---|
[112] | 2689 | end |
---|
| 2690 | end |
---|
| 2691 | end |
---|
| 2692 | end |
---|
[127] | 2693 | subdir_civ2=subdir_civ2_new; |
---|
[2] | 2694 | end |
---|
| 2695 | cd(currentdir);%come back to the current working directory |
---|
| 2696 | |
---|
| 2697 | %%%%%%%%%%%%% if civ2 results are obtained or used %%%%%%%%%%%%% |
---|
| 2698 | if box_test(4)==1 || box_test(5)==1 || box_test(6)==1 %civ2 |
---|
| 2699 | %check source netcdf file of civ1 estimates |
---|
| 2700 | if box_test(1)==0; %no civ1 performed |
---|
| 2701 | for ifile=1:nbfield |
---|
| 2702 | for j=1:nbslice |
---|
| 2703 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 2704 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 2705 | filecell.nc.civ1(ifile,j)={filename};% name of the civ1 file |
---|
| 2706 | if ~exist(filename,'file') |
---|
| 2707 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
[122] | 2708 | filecell={}; |
---|
[2] | 2709 | return |
---|
| 2710 | end |
---|
| 2711 | if ~testdiff % civ2 or patch2 are written in the same file as civ1 |
---|
| 2712 | if box_test(4)==0 ; %check the existence of civ2 if it is not calculated |
---|
| 2713 | Data=nc2struct(filename,'ListGlobalAttribute','civ2'); |
---|
| 2714 | if isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
| 2715 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
[12] | 2716 | filecell=[]; |
---|
[2] | 2717 | return |
---|
[112] | 2718 | end |
---|
[2] | 2719 | elseif box_test(3)==0; %check the existence of patch if it is not calculated |
---|
| 2720 | Data=nc2struct(filename,'ListGlobalAttribute','patch'); |
---|
| 2721 | if isempty(Data.patch)||isequal(Data.patch,0) |
---|
| 2722 | msgbox_uvmat('ERROR',['no patch data in ' filename]) |
---|
[12] | 2723 | filecell=[]; |
---|
[2] | 2724 | return |
---|
| 2725 | end |
---|
[112] | 2726 | end |
---|
[2] | 2727 | end |
---|
| 2728 | end |
---|
| 2729 | end |
---|
| 2730 | if strcmp(compare,'stereo PIV') |
---|
| 2731 | for ifile=1:nbfield |
---|
| 2732 | for j=1:nbslice |
---|
| 2733 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 2734 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 2735 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 2736 | if ~exist(filename,'file') |
---|
| 2737 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
| 2738 | set(handles.RUN, 'Enable','On') |
---|
| 2739 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 2740 | return |
---|
| 2741 | end |
---|
| 2742 | end |
---|
| 2743 | end |
---|
| 2744 | end |
---|
| 2745 | end |
---|
[112] | 2746 | |
---|
| 2747 | detect=1; |
---|
| 2748 | % while detect==1%creates a new subdir if the netcdf files already contain civ2 data |
---|
| 2749 | for ifile=1:nbfield |
---|
| 2750 | for j=1:nbslice |
---|
| 2751 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
[2] | 2752 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2); |
---|
[112] | 2753 | detect=exist(filename,'file')==2; |
---|
| 2754 | filecell.nc.civ2(ifile,j)={filename}; |
---|
[2] | 2755 | end |
---|
[112] | 2756 | end |
---|
[2] | 2757 | %get first image names for civ2 |
---|
| 2758 | if box_test(1)==1 & isequal(num1_civ1,num1_civ2) & isequal(num_a_civ1,num_a_civ2) |
---|
| 2759 | filecell.ima1.civ2=filecell.ima1.civ1; |
---|
| 2760 | elseif box_test(4)==1 |
---|
| 2761 | for ifile=1:nbfield |
---|
| 2762 | for j=1:nbslice |
---|
| 2763 | filename=name_generator(filebase_ima1, num1_civ2(ifile),num_a_civ2(j),ext_ima,nom_type_ima1); |
---|
| 2764 | idetect_2(j)=exist(filename,'file')==2; |
---|
| 2765 | filecell.ima1.civ2(ifile,j)={filename};%first image |
---|
| 2766 | end |
---|
[112] | 2767 | [idetectmin,indexj]=min(idetect_2); |
---|
[2] | 2768 | if idetectmin==0, |
---|
[112] | 2769 | msgbox_uvmat('ERROR',['input image ' filecell.ima1.civ2{ifile,indexj} ' not found']) |
---|
| 2770 | filecell=[]; |
---|
| 2771 | return |
---|
[2] | 2772 | end |
---|
| 2773 | end |
---|
| 2774 | end |
---|
| 2775 | |
---|
| 2776 | %get second image names for civ2 |
---|
| 2777 | if box_test(1)==1 & isequal(num2_civ1,num2_civ2) & isequal(num_b_civ1,num_b_civ2) |
---|
| 2778 | filecell.ima2.civ2=filecell.ima2.civ1; |
---|
| 2779 | elseif box_test(4)==1 |
---|
| 2780 | for ifile=1:nbfield |
---|
| 2781 | for j=1:nbslice |
---|
| 2782 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),ext_ima,nom_type_ima2); |
---|
| 2783 | idetect_3(j)=exist(filename,'file')==2; |
---|
| 2784 | filecell.ima2.civ2(ifile,j)={filename};%first image |
---|
| 2785 | end |
---|
[112] | 2786 | [idetectmin,indexj]=min(idetect_3); |
---|
[2] | 2787 | if idetectmin==0, |
---|
[112] | 2788 | msgbox_uvmat('ERROR',['input image ' filecell.ima2.civ2{ifile,indexj} ' not found']) |
---|
| 2789 | filecell=[]; |
---|
| 2790 | return |
---|
[2] | 2791 | end |
---|
| 2792 | end |
---|
| 2793 | end |
---|
| 2794 | end |
---|
| 2795 | if (box_test(5)==1 || box_test(6)==1 ) && box_test(4)==0 % need to read an existing netcdf civ2 file |
---|
| 2796 | if ~testdiff |
---|
| 2797 | filecell.nc.civ2=filecell.nc.civ1;% file already checked |
---|
[112] | 2798 | else % check the civ2 files |
---|
[2] | 2799 | for ifile=1:nbfield |
---|
| 2800 | for j=1:nbslice |
---|
| 2801 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
[112] | 2802 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
[2] | 2803 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 2804 | if ~exist(filename,'file') |
---|
| 2805 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
[12] | 2806 | filecell=[]; |
---|
[2] | 2807 | return |
---|
| 2808 | else |
---|
| 2809 | Data=nc2struct(filename,'ListGlobalAttribute','civ2'); |
---|
[112] | 2810 | if isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
[2] | 2811 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
[12] | 2812 | filecell=[]; |
---|
[2] | 2813 | return |
---|
| 2814 | end |
---|
| 2815 | end |
---|
| 2816 | end |
---|
| 2817 | end |
---|
| 2818 | end |
---|
| 2819 | end |
---|
| 2820 | |
---|
| 2821 | %%%%%%%%%%%%% if stereo fields are calculated by PATCH %%%%%%%%%%%%% |
---|
| 2822 | if strcmp(compare,'stereo PIV') |
---|
[127] | 2823 | if box_test(3)==1 && isequal(get(handles.test_stereo1,'Value'),1) |
---|
[2] | 2824 | for ifile=1:nbfield |
---|
| 2825 | for j=1:nbslice |
---|
| 2826 | filename=name_generator(filebase_AB,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 2827 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 2828 | filecell.st(ifile,j)={filename}; |
---|
| 2829 | end |
---|
| 2830 | end |
---|
| 2831 | end |
---|
[127] | 2832 | if box_test(6)==1 && isequal(get(handles.test_stereo2,'Value'),1) |
---|
[2] | 2833 | for ifile=1:nbfield |
---|
| 2834 | for j=1:nbslice |
---|
| 2835 | filename=name_generator(filebase_AB,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 2836 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 2837 | filecell.st(ifile,j)={filename}; |
---|
| 2838 | end |
---|
| 2839 | end |
---|
[112] | 2840 | end |
---|
[2] | 2841 | end |
---|
| 2842 | set(handles.subdir_civ1,'String',subdir_civ1);%update the edit box |
---|
| 2843 | set(handles.subdir_civ2,'String',subdir_civ2);%update the edit box |
---|
| 2844 | browse.nom_type_nc=nom_type_nc; |
---|
| 2845 | set(handles.browse_root,'UserData',browse); %update the nomenclature type for uvmat |
---|
| 2846 | |
---|
| 2847 | |
---|
| 2848 | %COPY IMAGES TO THE FORMAT .png IF NEEDED |
---|
[45] | 2849 | if isequal(nom_type_ima1,'*')%case of movie files |
---|
| 2850 | nom_type_imanew1='_i'; |
---|
[2] | 2851 | else |
---|
| 2852 | nom_type_imanew1=nom_type_ima1; |
---|
| 2853 | end |
---|
[45] | 2854 | if isequal(nom_type_ima2,'*')%case of movie files |
---|
| 2855 | nom_type_imanew2='_i'; |
---|
[2] | 2856 | else |
---|
| 2857 | nom_type_imanew2=nom_type_ima2; |
---|
| 2858 | end |
---|
| 2859 | if ~isequal(ext_ima,'.png') |
---|
[45] | 2860 | %%type of image file |
---|
| 2861 | type_ima1='none';%default |
---|
| 2862 | movieobject1=[];%default |
---|
[133] | 2863 | if strcmpi(ext_ima,'.avi') |
---|
[45] | 2864 | hhh=which('mmreader'); |
---|
| 2865 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
---|
| 2866 | type_ima1='movie'; |
---|
| 2867 | movieobject1=mmreader([filebase_ima2 ext_ima]); |
---|
| 2868 | else |
---|
| 2869 | type_ima1='avi'; |
---|
| 2870 | end |
---|
[133] | 2871 | elseif ischar(ext_ima) && ~isempty(ext_ima(2:end)) |
---|
[112] | 2872 | form=imformats(ext_ima(2:end)); |
---|
| 2873 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 2874 | if isequal(nom_type_ima1,'*'); |
---|
| 2875 | type_ima1='multimage';%image series in a single image file |
---|
| 2876 | else |
---|
| 2877 | type_ima1='image'; |
---|
| 2878 | end |
---|
| 2879 | end |
---|
[45] | 2880 | end |
---|
| 2881 | type_ima2='none';%default |
---|
| 2882 | movieobject2=[]; |
---|
[133] | 2883 | if strcmpi(ext_ima,'.avi') |
---|
[45] | 2884 | hhh=which('mmreader'); |
---|
| 2885 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
---|
| 2886 | type_ima2='movie'; |
---|
| 2887 | movieobject2=mmreader([filebase_ima2 ext_ima]); |
---|
| 2888 | else |
---|
| 2889 | type_ima2='avi'; |
---|
| 2890 | end |
---|
[133] | 2891 | elseif ischar(ext_ima) && ~isempty(ext_ima(2:end)) |
---|
[112] | 2892 | form=imformats(ext_ima(2:end)); |
---|
| 2893 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 2894 | if isequal(nom_type_ima1,'*'); |
---|
| 2895 | type_ima2='multimage';%image series in a single image file |
---|
| 2896 | else |
---|
| 2897 | type_ima2='image'; |
---|
| 2898 | end |
---|
| 2899 | end |
---|
[45] | 2900 | end |
---|
[71] | 2901 | %npxy=get(handles.ImaExt,'UserData'); |
---|
[112] | 2902 | % % if numel(npxy)<2 |
---|
| 2903 | % |
---|
| 2904 | % filename=name_generator(filebase_ima1,num1_civ1(1),num_a_civ1(1),ImaExt,nom_type_ima1); |
---|
| 2905 | % A=imread(filename); |
---|
| 2906 | % npxy=size(A); |
---|
| 2907 | % % end |
---|
| 2908 | % npy=npxy(1); |
---|
| 2909 | % npx=npxy(2); |
---|
[2] | 2910 | if box_test(1)==1 %if civ1 is performed |
---|
[224] | 2911 | h = waitbar(0,'copy images to the .png format for civ1');% display a wait bar |
---|
[112] | 2912 | for ifile=1:nbfield |
---|
[2] | 2913 | waitbar(ifile/nbfield); |
---|
| 2914 | for j=1:nbslice |
---|
[112] | 2915 | filename=name_generator(filebase_ima1,num1_civ1(ifile),num_a_civ1(j),'.png',nom_type_imanew1); |
---|
| 2916 | if ~exist(filename,'file') |
---|
| 2917 | A=read_image(filecell.ima1.civ1{ifile,j},type_ima1,num1_civ1(ifile),movieobject1); |
---|
| 2918 | imwrite(A,filename,'BitDepth',16); |
---|
| 2919 | end |
---|
| 2920 | filecell.ima1.civ1(ifile,j)={filename}; |
---|
| 2921 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),'.png',nom_type_imanew2); |
---|
| 2922 | if ~exist(filename,'file') |
---|
| 2923 | A=read_image(filecell.ima2.civ1{ifile,j},type_ima2,num2_civ1(ifile),movieobject2); |
---|
| 2924 | imwrite(A,filename,'BitDepth',16); |
---|
| 2925 | end |
---|
| 2926 | filecell.ima2.civ1(ifile,j)={filename}; |
---|
[2] | 2927 | end |
---|
| 2928 | end |
---|
| 2929 | close(h) |
---|
| 2930 | end |
---|
| 2931 | if box_test(4)==1 %if civ2 is performed |
---|
[229] | 2932 | h = waitbar(0,'copy images to the .png format for civ2');% display a wait bar |
---|
[2] | 2933 | for ifile=1:nbfield |
---|
| 2934 | waitbar(ifile/nbfield); |
---|
| 2935 | for j=1:nbslice |
---|
[112] | 2936 | filename=name_generator(filebase_ima1,num1_civ2(ifile),num_a_civ2(j),'.png',nom_type_imanew1); |
---|
| 2937 | if ~exist(filename,'file') |
---|
| 2938 | A=read_image(cell2mat(filecell.ima1.civ2(ifile,j)),type_ima2,num1_civ2(ifile)); |
---|
| 2939 | imwrite(A,filename,'BitDepth',16); |
---|
| 2940 | end |
---|
| 2941 | filecell.ima1.civ2(ifile,j)={filename}; |
---|
| 2942 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),'.png',nom_type_imanew2); |
---|
| 2943 | if ~exist(filename,'file') |
---|
| 2944 | A=read_image(cell2mat(filecell.ima2.civ2(ifile,j)),type_ima2,num2_civ2(ifile)); |
---|
| 2945 | imwrite(A,filename,'BitDepth',16); |
---|
| 2946 | end |
---|
| 2947 | filecell.ima2.civ2(ifile,j)={filename}; |
---|
[2] | 2948 | end |
---|
| 2949 | end |
---|
| 2950 | close(h); |
---|
| 2951 | end |
---|
| 2952 | end |
---|
| 2953 | |
---|
[12] | 2954 | %------------------------------------------------------------------------ |
---|
[227] | 2955 | % --- determine the list of index pairs of processing file |
---|
| 2956 | function [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
| 2957 | find_pair_indices(handles,ref_i,ref_j,mode) |
---|
| 2958 | %------------------------------------------------------------------------ |
---|
| 2959 | |
---|
| 2960 | list_civ1=get(handles.list_pair_civ1,'String'); |
---|
| 2961 | index_civ1=get(handles.list_pair_civ1,'Value'); |
---|
| 2962 | str_civ1=list_civ1{index_civ1};%string defining the image pairs for civ1 |
---|
| 2963 | if isempty(str_civ1)||isequal(str_civ1,'') |
---|
| 2964 | msgbox_uvmat('ERROR','no image pair selected for civ1') |
---|
| 2965 | return |
---|
| 2966 | end |
---|
| 2967 | list_civ2=get(handles.list_pair_civ2,'String'); |
---|
| 2968 | index_civ2=get(handles.list_pair_civ2,'Value'); |
---|
| 2969 | if index_civ2>length(list_civ2) |
---|
| 2970 | list_civ2=list_civ1; |
---|
| 2971 | index_civ2=index_civ1; |
---|
| 2972 | end |
---|
| 2973 | str_civ2=list_civ2{index_civ2};%string defining the image pairs for civ2 |
---|
| 2974 | |
---|
| 2975 | if isequal (mode,'series(Di)') |
---|
| 2976 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 2977 | num1_civ1=ref_i-floor(index_civ1/2)*ones(size(ref_i));% set of first image numbers |
---|
| 2978 | num2_civ1=ref_i+ceil(index_civ1/2)*ones(size(ref_i)); |
---|
| 2979 | num_a_civ1=ref_j; |
---|
| 2980 | num_b_civ1=ref_j; |
---|
[229] | 2981 | num1_civ2=ref_i-floor(index_civ2/2)*ones(size(ref_i)); |
---|
[227] | 2982 | num2_civ2=ref_i+ceil(index_civ2/2)*ones(size(ref_i)); |
---|
| 2983 | num_a_civ2=ref_j; |
---|
| 2984 | num_b_civ2=ref_j; |
---|
| 2985 | |
---|
| 2986 | % adjust the first and last field number |
---|
| 2987 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 2988 | if isnan(lastfield) |
---|
| 2989 | indsel=find((num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
| 2990 | else |
---|
| 2991 | indsel=find((num2_civ1 <= lastfield)&(num2_civ2 <= lastfield)&(num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
| 2992 | end |
---|
| 2993 | if length(indsel)>=1 |
---|
| 2994 | firstind=indsel(1); |
---|
| 2995 | lastind=indsel(end); |
---|
| 2996 | set(handles.first_i,'String',num2str(ref_i(firstind)))%update the display of first and last fields |
---|
| 2997 | set(handles.last_i,'String',num2str(ref_i(lastind))) |
---|
| 2998 | ref_i=ref_i(indsel); |
---|
| 2999 | num1_civ1=num1_civ1(indsel); |
---|
| 3000 | num1_civ2=num1_civ2(indsel); |
---|
| 3001 | num2_civ1=num2_civ1(indsel); |
---|
| 3002 | num2_civ2=num2_civ2(indsel); |
---|
| 3003 | end |
---|
| 3004 | elseif isequal (mode,'series(Dj)') |
---|
| 3005 | lastfield_j=str2double(get(handles.nb_field2,'String')); |
---|
| 3006 | num1_civ1=ref_i;% set of first image numbers |
---|
| 3007 | num2_civ1=ref_i; |
---|
| 3008 | num_a_civ1=ref_j-floor(index_civ1/2)*ones(size(ref_j)); |
---|
| 3009 | num_b_civ1=ref_j+ceil(index_civ1/2)*ones(size(ref_j)); |
---|
| 3010 | num1_civ2=ref_i; |
---|
| 3011 | num2_civ2=ref_i; |
---|
| 3012 | num_a_civ2=ref_j-floor(index_civ2/2)*ones(size(ref_j)); |
---|
| 3013 | num_b_civ2=ref_j+ceil(index_civ2/2)*ones(size(ref_j)); |
---|
| 3014 | % adjust the first and last field number |
---|
| 3015 | if isnan(lastfield_j) |
---|
| 3016 | indsel=find((num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
| 3017 | else |
---|
| 3018 | indsel=find((num_b_civ1 <= lastfield_j)&(num_b_civ2 <= lastfield_j)&(num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
| 3019 | end |
---|
| 3020 | if length(indsel)>=1 |
---|
| 3021 | firstind=indsel(1); |
---|
| 3022 | lastind=indsel(end); |
---|
| 3023 | set(handles.first_j,'String',num2str(ref_j(firstind)))%update the display of first and last fields |
---|
| 3024 | set(handles.last_j,'String',num2str(ref_j(lastind))) |
---|
| 3025 | ref_j=ref_j(indsel); |
---|
| 3026 | num_a_civ1=num_a_civ1(indsel); |
---|
| 3027 | num_b_civ1=num_b_civ1(indsel); |
---|
| 3028 | num_a_civ2=num_a_civ2(indsel); |
---|
| 3029 | num_b_civ2=num_b_civ2(indsel); |
---|
| 3030 | end |
---|
| 3031 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
| 3032 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
| 3033 | num1_civ1=ref_i; |
---|
| 3034 | num2_civ1=ref_i; |
---|
| 3035 | num_a_civ1=displ_num(1,index_civ1); |
---|
| 3036 | num_b_civ1=displ_num(2,index_civ1); |
---|
| 3037 | num1_civ2=ref_i; |
---|
| 3038 | num2_civ2=ref_i; |
---|
| 3039 | num_a_civ2=displ_num(1,index_civ2); |
---|
| 3040 | num_b_civ2=displ_num(2,index_civ2); |
---|
| 3041 | elseif isequal(mode,'displacement') |
---|
| 3042 | num1_civ1=ref_i; |
---|
| 3043 | num2_civ1=ref_i; |
---|
| 3044 | num_a_civ1=ref_j; |
---|
| 3045 | num_b_civ1=ref_j; |
---|
| 3046 | num1_civ2=ref_i; |
---|
| 3047 | num2_civ2=ref_i; |
---|
| 3048 | num_a_civ2=ref_j; |
---|
| 3049 | num_b_civ2=ref_j; |
---|
| 3050 | end |
---|
| 3051 | |
---|
| 3052 | |
---|
| 3053 | %------------------------------------------------------------------------ |
---|
[12] | 3054 | % --- PATCH |
---|
[94] | 3055 | function cmd_PATCH=PATCH_CMD(filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,test_interp,PatchBin) |
---|
[12] | 3056 | %------------------------------------------------------------------------ |
---|
[224] | 3057 | namelog=[filename_nc(1:end-3) '_patch.log']; |
---|
[112] | 3058 | if test_interp==0 |
---|
[163] | 3059 | if isunix |
---|
[112] | 3060 | cmd_PATCH=[PatchBin ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ... |
---|
| 3061 | ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
[163] | 3062 | else |
---|
| 3063 | cmd_PATCH=['"' PatchBin '" -f "' filename_nc '" -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ... |
---|
| 3064 | ' > "' namelog '" 2>&1']; % redirect standard output to the log file |
---|
| 3065 | end |
---|
[112] | 3066 | else %nouveau programme patch |
---|
| 3067 | cmd_PATCH=[PatchBin ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ... |
---|
| 3068 | ' -max ' thresh_value ' -nopt ' subdomain_patch ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
| 3069 | end |
---|
[163] | 3070 | cmd_PATCH=regexprep(cmd_PATCH,'\\','\\\\'); |
---|
[12] | 3071 | %------------------------------------------------------------------------ |
---|
| 3072 | % --- STEREO Interp |
---|
[67] | 3073 | 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] | 3074 | %------------------------------------------------------------------------ |
---|
[224] | 3075 | namelog=[filename_nc(1:end-3) '_stinterp.log']; |
---|
[67] | 3076 | cmd=[stinterpBin ' -f1 ' filename_A_nc ' -f2 ' filename_B_nc ' -f ' filename_nc ... |
---|
[2] | 3077 | ' -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 |
---|
| 3078 | |
---|
[12] | 3079 | %------------------------------------------------------------------------ |
---|
[2] | 3080 | % --- Executes on button press in CIV1. |
---|
| 3081 | function CIV1_Callback(hObject, eventdata, handles) |
---|
[12] | 3082 | %------------------------------------------------------------------------ |
---|
[2] | 3083 | val=get(handles.CIV1,'Value'); |
---|
| 3084 | if isequal(val,1) |
---|
| 3085 | enable_civ1(handles,'on') |
---|
| 3086 | enable_pair1(handles,'on') |
---|
| 3087 | else |
---|
| 3088 | enable_civ1(handles,'off') |
---|
| 3089 | end |
---|
| 3090 | find_netcpair_civ1(hObject, eventdata, handles); |
---|
| 3091 | |
---|
[12] | 3092 | %------------------------------------------------------------------------ |
---|
[2] | 3093 | % --- Executes on button press in FIX1. |
---|
| 3094 | function FIX1_Callback(hObject, eventdata, handles) |
---|
[12] | 3095 | %------------------------------------------------------------------------ |
---|
[2] | 3096 | enable_fix1(handles,get(handles.FIX1,'Value')) |
---|
| 3097 | |
---|
[12] | 3098 | %------------------------------------------------------------------------ |
---|
[2] | 3099 | % --- Executes on button press in PATCH1. |
---|
| 3100 | function PATCH1_Callback(hObject, eventdata, handles) |
---|
[12] | 3101 | %------------------------------------------------------------------------ |
---|
[2] | 3102 | if get(handles.PATCH1,'Value')==1 |
---|
[12] | 3103 | enable_patch1(handles) |
---|
[2] | 3104 | else |
---|
[12] | 3105 | desable_patch1(handles) |
---|
[2] | 3106 | end |
---|
| 3107 | |
---|
[12] | 3108 | %------------------------------------------------------------------------ |
---|
[2] | 3109 | % --- Executes on button press in CIV2. |
---|
| 3110 | function CIV2_Callback(hObject, eventdata, handles) |
---|
[12] | 3111 | %------------------------------------------------------------------------ |
---|
[2] | 3112 | state=get(handles.CIV2,'Value'); |
---|
| 3113 | enable_civ2(handles,state) |
---|
| 3114 | if state |
---|
| 3115 | find_netcpair_civ2(hObject, eventdata, handles) |
---|
| 3116 | enable_pair1(handles,'on') |
---|
| 3117 | end |
---|
| 3118 | |
---|
[12] | 3119 | %------------------------------------------------------------------------ |
---|
[2] | 3120 | % --- Executes on button press in FIX2. |
---|
| 3121 | function FIX2_Callback(hObject, eventdata, handles) |
---|
[12] | 3122 | %------------------------------------------------------------------------ |
---|
[2] | 3123 | if get(handles.FIX2,'Value')==1 |
---|
| 3124 | enable_fix2(handles) |
---|
| 3125 | if get(handles.CIV2,'Value')==0 |
---|
| 3126 | find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files |
---|
| 3127 | end |
---|
| 3128 | else |
---|
| 3129 | desable_fix2(handles) |
---|
| 3130 | end |
---|
| 3131 | |
---|
[12] | 3132 | %------------------------------------------------------------------------ |
---|
[2] | 3133 | % --- Executes on button press in PATCH2. |
---|
| 3134 | function PATCH2_Callback(hObject, eventdata, handles) |
---|
[12] | 3135 | %------------------------------------------------------------------------ |
---|
[2] | 3136 | if get(handles.PATCH2,'Value')==1 |
---|
| 3137 | enable_patch2(handles) |
---|
| 3138 | if get(handles.CIV2,'Value')==0 |
---|
| 3139 | find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files |
---|
| 3140 | end |
---|
| 3141 | else |
---|
| 3142 | desable_patch2(handles) |
---|
| 3143 | end |
---|
| 3144 | |
---|
[12] | 3145 | %------------------------------------------------------------------------ |
---|
| 3146 | function first_i_Callback(hObject, eventdata, handles) |
---|
| 3147 | %------------------------------------------------------------------------ |
---|
| 3148 | % last_i_Callback(hObject, eventdata, handles) |
---|
[137] | 3149 | first_i=str2double(get(handles.first_i,'String')); |
---|
[12] | 3150 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 3151 | % ref_i=ceil((first_i+last_i)/2); |
---|
| 3152 | set(handles.ref_i,'String', num2str(first_i))% reference index for pair dt = first index |
---|
[71] | 3153 | set(handles.ref_i_civ2,'String', num2str(first_i))% reference index for pair dt = first index |
---|
[12] | 3154 | ref_i_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3155 | |
---|
[12] | 3156 | %------------------------------------------------------------------------ |
---|
| 3157 | function first_j_Callback(hObject, eventdata, handles) |
---|
| 3158 | %------------------------------------------------------------------------ |
---|
| 3159 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 3160 | set(handles.ref_j,'String', num2str(first_j))% reference index for pair dt = first index |
---|
| 3161 | ref_j_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3162 | |
---|
[12] | 3163 | %------------------------------------------------------------------------ |
---|
[2] | 3164 | % --- Executes on button press in calcul_search: determine the search range isx,isy |
---|
| 3165 | function calcul_search_Callback(hObject, eventdata, handles) |
---|
[12] | 3166 | %------------------------------------------------------------------------ |
---|
[2] | 3167 | %determine pair numbers |
---|
| 3168 | list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs |
---|
| 3169 | index=get(handles.list_pair_civ1,'Value'); |
---|
| 3170 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
[71] | 3171 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
[2] | 3172 | pxcm_xy=get(handles.calcul_search,'UserData'); |
---|
| 3173 | pxcmx=pxcm_xy(1); |
---|
| 3174 | pxcmy=pxcm_xy(2); |
---|
| 3175 | mode_list=get(handles.mode,'String'); |
---|
| 3176 | mode_value=get(handles.mode,'Value'); |
---|
| 3177 | mode=mode_list{mode_value}; |
---|
| 3178 | if isequal (mode, 'series(Di)' ) |
---|
[137] | 3179 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[2] | 3180 | num1=ref_i-floor(index/2);% first image numbers |
---|
| 3181 | num2=ref_i+ceil(index/2); |
---|
| 3182 | num_a=1; |
---|
| 3183 | num_b=1; |
---|
[112] | 3184 | elseif isequal (mode, 'series(Dj)') |
---|
[2] | 3185 | num1=1; |
---|
| 3186 | num2=1; |
---|
[137] | 3187 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
[2] | 3188 | num_a=ref_j-floor(index/2);% first image numbers |
---|
| 3189 | num_b=ref_j+ceil(index/2); |
---|
| 3190 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
[137] | 3191 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[2] | 3192 | num1=ref_i; |
---|
| 3193 | num2=ref_i; |
---|
| 3194 | num_a=displ_num(1,index); |
---|
| 3195 | num_b=displ_num(2,index); |
---|
| 3196 | end |
---|
| 3197 | dt=time(num2,num_b)-time(num1,num_a); |
---|
[137] | 3198 | ibx=str2double(get(handles.ibx,'String')); |
---|
| 3199 | iby=str2double(get(handles.iby,'String')); |
---|
| 3200 | umin=dt*pxcmx*str2double(get(handles.umin,'String')); |
---|
| 3201 | umax=dt*pxcmx*str2double(get(handles.umax,'String')); |
---|
| 3202 | vmin=dt*pxcmy*str2double(get(handles.vmin,'String')); |
---|
| 3203 | vmax=dt*pxcmy*str2double(get(handles.vmax,'String')); |
---|
[2] | 3204 | shiftx=round((umin+umax)/2); |
---|
| 3205 | shifty=round((vmin+vmax)/2); |
---|
| 3206 | isx=(umax+2-shiftx)*2+ibx; |
---|
| 3207 | isx=2*ceil(isx/2)+1; |
---|
| 3208 | isy=(vmax+2-shifty)*2+iby; |
---|
| 3209 | isy=2*ceil(isy/2)+1; |
---|
| 3210 | set(handles.shiftx,'String',num2str(shiftx)); |
---|
| 3211 | set(handles.shifty,'String',num2str(shifty)); |
---|
| 3212 | set(handles.isx,'String',num2str(isx)); |
---|
| 3213 | set(handles.isy,'String',num2str(isy)); |
---|
| 3214 | |
---|
[12] | 3215 | %------------------------------------------------------------------------ |
---|
| 3216 | % --- Executes on carriage return on the subdir civ1 edit window |
---|
[2] | 3217 | function subdir_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 3218 | %------------------------------------------------------------------------ |
---|
[2] | 3219 | subdir=get(handles.subdir_civ1,'String'); |
---|
| 3220 | set(handles.subdir_civ2,'String',subdir); |
---|
[112] | 3221 | if get(handles.CIV1,'Value')==0 |
---|
[2] | 3222 | find_netcpair_civ1(hObject, eventdata, handles); %update the list of available pairs from netcdf files in the new directory |
---|
| 3223 | end |
---|
| 3224 | |
---|
[12] | 3225 | %------------------------------------------------------------------------ |
---|
| 3226 | % --- Executes on carriage return on the subdir civ1 edit window |
---|
[2] | 3227 | function subdir_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 3228 | %------------------------------------------------------------------------ |
---|
[2] | 3229 | %update the list of available pairs from netcdf files in the new directory |
---|
| 3230 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0 |
---|
| 3231 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 3232 | end |
---|
| 3233 | |
---|
[12] | 3234 | %------------------------------------------------------------------------ |
---|
[133] | 3235 | % --- Executes on button press in get_mask_civ1: select box for mask option |
---|
[2] | 3236 | function get_mask_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 3237 | %------------------------------------------------------------------------ |
---|
[2] | 3238 | maskval=get(handles.get_mask_civ1,'Value'); |
---|
| 3239 | if isequal(maskval,0) |
---|
| 3240 | set(handles.mask_civ1,'String','') |
---|
| 3241 | else |
---|
| 3242 | mask_displ='no mask'; %default |
---|
[71] | 3243 | filebase=get(handles.RootName,'String'); |
---|
[2] | 3244 | [ nbslice_mask, flag_mask]=get_mask(filebase,handles); |
---|
| 3245 | if isequal(flag_mask,1) |
---|
[112] | 3246 | mask_displ=[num2str(nbslice_mask) 'mask']; |
---|
[2] | 3247 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[112] | 3248 | common_path=fileparts(filebase); |
---|
| 3249 | filebase_a=fullfile(common_path,get(handles.RootName_1,'String')); |
---|
| 3250 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
| 3251 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice_mask) |
---|
| 3252 | mask_displ='no mask'; |
---|
| 3253 | end |
---|
[2] | 3254 | end |
---|
| 3255 | if isequal(mask_displ,'no mask') |
---|
[12] | 3256 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3257 | {'*.png', ' (*.png)'; |
---|
| 3258 | '*.png', '.png files '; ... |
---|
| 3259 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3260 | 'Pick a mask file *.png',filebase); |
---|
| 3261 | mask_displ=fullfile(PathName,FileName); |
---|
[12] | 3262 | if ~exist(mask_displ,'file') |
---|
| 3263 | mask_displ='no mask'; |
---|
| 3264 | end |
---|
| 3265 | end |
---|
| 3266 | if isequal(mask_displ,'no mask') |
---|
[2] | 3267 | set(handles.get_mask_civ1,'Value',0) |
---|
| 3268 | set(handles.get_mask_fix1,'Value',0) |
---|
| 3269 | set(handles.get_mask_civ2,'Value',0) |
---|
| 3270 | set(handles.get_mask_fix2,'Value',0) |
---|
| 3271 | else |
---|
| 3272 | set(handles.get_mask_fix1,'Value',1) |
---|
| 3273 | set(handles.get_mask_fix2,'Value',1) |
---|
| 3274 | end |
---|
| 3275 | set(handles.mask_civ1,'String',mask_displ) |
---|
| 3276 | set(handles.mask_fix1,'String',mask_displ) |
---|
| 3277 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 3278 | set(handles.mask_fix2,'String',mask_displ) |
---|
| 3279 | end |
---|
[133] | 3280 | set(handles.get_mask_civ2,'Value',maskval)%update the civ2 mask with the same option as civ1 |
---|
[2] | 3281 | |
---|
[12] | 3282 | %------------------------------------------------------------------------ |
---|
[2] | 3283 | % --- Executes on button press in get_mask_fix1. |
---|
| 3284 | function get_mask_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 3285 | %------------------------------------------------------------------------ |
---|
[2] | 3286 | maskval=get(handles.get_mask_fix1,'Value'); |
---|
| 3287 | if isequal(maskval,0) |
---|
| 3288 | set(handles.mask_fix1,'String','') |
---|
| 3289 | else |
---|
[112] | 3290 | mask_displ='no mask'; %default |
---|
| 3291 | filebase=get(handles.RootName,'String'); |
---|
| 3292 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3293 | if isequal(flag_mask,1) |
---|
| 3294 | mask_displ=[num2str(nbslice) 'mask']; |
---|
| 3295 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[71] | 3296 | filebase_a=get(handles.RootName_1,'String'); |
---|
[2] | 3297 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[229] | 3298 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
[2] | 3299 | mask_displ='no mask'; |
---|
| 3300 | end |
---|
[112] | 3301 | end |
---|
| 3302 | if isequal(mask_displ,'no mask') |
---|
| 3303 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3304 | {'*.png', ' (*.png)'; |
---|
[12] | 3305 | '*.png', '.png files '; ... |
---|
| 3306 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3307 | 'Pick a mask file *.png',filebase); |
---|
[112] | 3308 | mask_displ=fullfile(PathName,FileName); |
---|
| 3309 | if ~exist(mask_displ,'file') |
---|
| 3310 | mask_displ='no mask'; |
---|
| 3311 | end |
---|
[12] | 3312 | end |
---|
[112] | 3313 | if isequal(mask_displ,'no mask') |
---|
| 3314 | set(handles.get_mask_fix1,'Value',0) |
---|
| 3315 | set(handles.get_mask_civ2,'Value',0) |
---|
| 3316 | set(handles.get_mask_fix2,'Value',0) |
---|
| 3317 | else |
---|
| 3318 | %set(handles.get_mask_civ2,'Value',1) |
---|
| 3319 | set(handles.get_mask_fix2,'Value',1) |
---|
| 3320 | end |
---|
| 3321 | set(handles.mask_fix1,'String',mask_displ) |
---|
| 3322 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 3323 | set(handles.mask_fix2,'String',mask_displ) |
---|
[12] | 3324 | end |
---|
| 3325 | |
---|
| 3326 | %------------------------------------------------------------------------ |
---|
[133] | 3327 | % --- Executes on button press in get_mask_civ2: select box for mask option |
---|
[2] | 3328 | function get_mask_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 3329 | %------------------------------------------------------------------------ |
---|
[2] | 3330 | maskval=get(handles.get_mask_civ2,'Value'); |
---|
| 3331 | if isequal(maskval,0) |
---|
| 3332 | set(handles.mask_civ2,'String','') |
---|
| 3333 | else |
---|
[112] | 3334 | mask_displ='no mask'; %default |
---|
| 3335 | filebase=get(handles.RootName,'String'); |
---|
| 3336 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3337 | if isequal(flag_mask,1) |
---|
| 3338 | mask_displ=[num2str(nbslice) 'mask']; |
---|
| 3339 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[71] | 3340 | filebase_a=get(handles.RootName_1,'String'); |
---|
[2] | 3341 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[229] | 3342 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
[2] | 3343 | mask_displ='no mask'; |
---|
| 3344 | end |
---|
[112] | 3345 | end |
---|
| 3346 | if isequal(mask_displ,'no mask') |
---|
| 3347 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3348 | {'*.png', ' (*.png)'; |
---|
[12] | 3349 | '*.png', '.png files '; ... |
---|
| 3350 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3351 | 'Pick a mask file *.png',filebase); |
---|
[112] | 3352 | mask_displ=fullfile(PathName,FileName); |
---|
| 3353 | if ~exist(mask_displ,'file') |
---|
| 3354 | mask_displ='no mask'; |
---|
| 3355 | end |
---|
[12] | 3356 | end |
---|
[112] | 3357 | if isequal(mask_displ,'no mask') |
---|
| 3358 | set(handles.get_mask_civ2,'Value',0) |
---|
| 3359 | set(handles.get_mask_fix2,'Value',0) |
---|
| 3360 | else |
---|
| 3361 | set(handles.get_mask_fix2,'Value',1) |
---|
| 3362 | end |
---|
| 3363 | set(handles.mask_civ2,'String',mask_displ) |
---|
| 3364 | set(handles.mask_fix2,'String',mask_displ) |
---|
[12] | 3365 | end |
---|
| 3366 | |
---|
| 3367 | %------------------------------------------------------------------------ |
---|
[2] | 3368 | % --- Executes on button press in get_mask_fix2. |
---|
| 3369 | function get_mask_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 3370 | %------------------------------------------------------------------------ |
---|
[2] | 3371 | maskval=get(handles.get_mask_fix2,'Value'); |
---|
| 3372 | if isequal(maskval,0) |
---|
| 3373 | set(handles.mask_fix2,'String','') |
---|
| 3374 | else |
---|
[12] | 3375 | mask_displ='no mask'; %default |
---|
[71] | 3376 | filebase=get(handles.RootName,'String'); |
---|
[12] | 3377 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3378 | if isequal(flag_mask,1) |
---|
[112] | 3379 | mask_displ=[num2str(nbslice) 'mask']; |
---|
[12] | 3380 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[112] | 3381 | filebase_a=get(handles.RootName_1,'String'); |
---|
| 3382 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[229] | 3383 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
[112] | 3384 | mask_displ='no mask'; |
---|
| 3385 | end |
---|
[12] | 3386 | end |
---|
| 3387 | if isequal(mask_displ,'no mask') |
---|
| 3388 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3389 | {'*.png', ' (*.png)'; |
---|
| 3390 | '*.png', '.png files '; ... |
---|
| 3391 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3392 | 'Pick a mask file *.png',filebase); |
---|
| 3393 | mask_displ=fullfile(PathName,FileName); |
---|
[12] | 3394 | if ~exist(mask_displ,'file') |
---|
[2] | 3395 | mask_displ='no mask'; |
---|
| 3396 | end |
---|
[12] | 3397 | end |
---|
| 3398 | if isequal(mask_displ,'no mask') |
---|
| 3399 | set(handles.get_mask_fix2,'Value',0) |
---|
[112] | 3400 | end |
---|
[12] | 3401 | set(handles.mask_fix2,'String',mask_displ) |
---|
[2] | 3402 | end |
---|
| 3403 | |
---|
[12] | 3404 | %------------------------------------------------------------------------ |
---|
| 3405 | % --- function called to look for mask files |
---|
[2] | 3406 | function [nbslice, flag_mask]=get_mask(filebase,handles) |
---|
[12] | 3407 | %------------------------------------------------------------------------ |
---|
[112] | 3408 | %detect mask files, images with appropriate file base |
---|
[2] | 3409 | %[filebase '_' xx 'mask'], xx=nbslice |
---|
| 3410 | %flag_mask=1 indicates detection |
---|
| 3411 | |
---|
| 3412 | flag_mask=0;%default |
---|
| 3413 | nbslice=1; |
---|
| 3414 | |
---|
| 3415 | % subdir=get(handles.subdir_civ1,'String'); |
---|
| 3416 | [Path,Name]=fileparts(filebase); |
---|
[12] | 3417 | if ~isdir(Path) |
---|
| 3418 | msgbox_uvmat('ERROR','no path for input files') |
---|
| 3419 | return |
---|
| 3420 | end |
---|
[2] | 3421 | currentdir=pwd; |
---|
| 3422 | cd(Path);%move in the dir of the root name filebase |
---|
| 3423 | maskfiles=dir([Name '_*mask_*.png']);%look for mask files |
---|
| 3424 | cd(currentdir);%come back to the current working directory |
---|
[12] | 3425 | if ~isempty(maskfiles) |
---|
[112] | 3426 | % msgbox_uvmat('ERROR','no mask available, to create it use Tools/Make mask in the upper menu bar of uvmat') |
---|
| 3427 | % else |
---|
[2] | 3428 | flag_mask=1; |
---|
| 3429 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 3430 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 3431 | Namedouble=double(Name); |
---|
| 3432 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 3433 | ind_mask=findstr('mask',Name); |
---|
| 3434 | i=ind_mask-1; |
---|
[137] | 3435 | while val(i)==0 && i>0 |
---|
[112] | 3436 | i=i-1; |
---|
[2] | 3437 | end |
---|
[137] | 3438 | nbslice=str2double(Name(i+1:ind_mask-1)); |
---|
| 3439 | if ~isnan(nbslice) && Name(i)=='_' |
---|
[112] | 3440 | flag_mask=1; |
---|
[2] | 3441 | else |
---|
[112] | 3442 | msgbox_uvmat('ERROR',['bad mask file ' Name ext ' found in ' Path2]) |
---|
| 3443 | return |
---|
| 3444 | nbslice=1; |
---|
[2] | 3445 | end |
---|
[112] | 3446 | end |
---|
[2] | 3447 | |
---|
[12] | 3448 | %------------------------------------------------------------------------ |
---|
| 3449 | % --- function called to look for grid files |
---|
[2] | 3450 | function [nbslice, flag_mask]=get_grid(filebase,handles) |
---|
[12] | 3451 | %------------------------------------------------------------------------ |
---|
[2] | 3452 | flag_mask=0;%default |
---|
| 3453 | nbslice=1; |
---|
| 3454 | [Path,Name]=fileparts(filebase); |
---|
| 3455 | currentdir=pwd; |
---|
| 3456 | cd(Path);%move in the dir of the root name filebase |
---|
| 3457 | maskfiles=dir([Name '_*grid_*.grid']);%look for mask files |
---|
| 3458 | cd(currentdir);%come back to the current working directory |
---|
| 3459 | if ~isempty(maskfiles) |
---|
| 3460 | flag_mask=1; |
---|
| 3461 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 3462 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 3463 | Namedouble=double(Name); |
---|
| 3464 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 3465 | ind_mask=findstr('grid',Name); |
---|
| 3466 | i=ind_mask-1; |
---|
[137] | 3467 | while val(i)==0 && i>0 |
---|
[112] | 3468 | i=i-1; |
---|
[2] | 3469 | end |
---|
[137] | 3470 | nbslice=str2double(Name(i+1:ind_mask-1)); |
---|
| 3471 | if ~isnan(nbslice) && Name(i)=='_' |
---|
[112] | 3472 | flag_mask=1; |
---|
[2] | 3473 | else |
---|
[112] | 3474 | msgbox_uvmat('ERROR',['bad grid file ' Name ext ' found in ' Path2]) |
---|
| 3475 | return |
---|
| 3476 | nbslice=1; |
---|
[2] | 3477 | end |
---|
[12] | 3478 | end |
---|
[2] | 3479 | |
---|
[12] | 3480 | %------------------------------------------------------------------------ |
---|
| 3481 | % --- transform numbers to letters |
---|
[122] | 3482 | function str=num2stra(num,nom_type) |
---|
[12] | 3483 | %------------------------------------------------------------------------ |
---|
[122] | 3484 | if isempty(nom_type) |
---|
| 3485 | str=''; |
---|
| 3486 | elseif strcmp(nom_type(end),'a') |
---|
[2] | 3487 | str=char(96+num); |
---|
[122] | 3488 | elseif strcmp(nom_type(end),'A') |
---|
| 3489 | str=char(96+num); |
---|
| 3490 | elseif isempty(nom_type(2:end))%a single index |
---|
[2] | 3491 | str=''; |
---|
| 3492 | else |
---|
| 3493 | str=num2str(num); |
---|
| 3494 | end |
---|
[12] | 3495 | |
---|
[173] | 3496 | % %------------------------------------------------------------------------ |
---|
| 3497 | % function mask_civ1_Callback(hObject, eventdata, handles) |
---|
| 3498 | % %------------------------------------------------------------------------ |
---|
| 3499 | % set(handles.mask_civ1,'UserData',[]) |
---|
| 3500 | % set(handles.mask_civ1,'String','') |
---|
| 3501 | % |
---|
| 3502 | % %------------------------------------------------------------------------ |
---|
| 3503 | % function mask_civ2_Callback(hObject, eventdata, handles) |
---|
| 3504 | % %------------------------------------------------------------------------ |
---|
| 3505 | % set(handles.mask_civ2,'UserData',[]) |
---|
| 3506 | % set(handles.mask_civ2,'String','') |
---|
| 3507 | % |
---|
| 3508 | % %------------------------------------------------------------------------ |
---|
| 3509 | % function mask_fix1_Callback(hObject, eventdata, handles) |
---|
| 3510 | % %------------------------------------------------------------------------ |
---|
| 3511 | % set(handles.mask_fix1,'UserData',[]) |
---|
| 3512 | % set(handles.mask_fix1,'String','') |
---|
| 3513 | % |
---|
| 3514 | % %------------------------------------------------------------------------ |
---|
| 3515 | % function mask_fix2_Callback(hObject, eventdata, handles) |
---|
| 3516 | % %------------------------------------------------------------------------ |
---|
| 3517 | % set(handles.mask_fix2,'UserData',[]) |
---|
| 3518 | % set(handles.mask_fix2,'String','') |
---|
[12] | 3519 | |
---|
| 3520 | %------------------------------------------------------------------------ |
---|
[2] | 3521 | % --- Executes on button press in list_subdir_civ1. |
---|
| 3522 | function list_subdir_civ1_Callback(hObject, eventdata, handles) |
---|
[12] | 3523 | %------------------------------------------------------------------------ |
---|
[2] | 3524 | list_subdir_civ1=get(handles.list_subdir_civ1,'String'); |
---|
| 3525 | val=get(handles.list_subdir_civ1,'Value'); |
---|
| 3526 | if val>1 |
---|
| 3527 | subdir=list_subdir_civ1{val}; |
---|
| 3528 | set(handles.subdir_civ1,'String',subdir); |
---|
| 3529 | set(handles.list_subdir_civ1,'Value',1); |
---|
| 3530 | end |
---|
| 3531 | |
---|
[12] | 3532 | %------------------------------------------------------------------------ |
---|
[2] | 3533 | % --- Executes on button press in list_subdir_civ2. |
---|
| 3534 | function list_subdir_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 3535 | %------------------------------------------------------------------------ |
---|
[2] | 3536 | list_subdir_civ2=get(handles.list_subdir_civ2,'String'); |
---|
| 3537 | val=get(handles.list_subdir_civ2,'Value'); |
---|
| 3538 | if val>1 |
---|
| 3539 | subdir=list_subdir_civ2{val}; |
---|
| 3540 | set(handles.subdir_civ2,'String',subdir); |
---|
| 3541 | set(handles.list_subdir_civ2,'Value',1); |
---|
| 3542 | end |
---|
| 3543 | |
---|
[12] | 3544 | %------------------------------------------------------------------------ |
---|
[2] | 3545 | % --- Executes on button press in browse_gridciv1. |
---|
| 3546 | function browse_gridciv1_Callback(hObject, eventdata, handles) |
---|
[12] | 3547 | %------------------------------------------------------------------------ |
---|
[2] | 3548 | value=get(handles.browse_gridciv1,'Value'); |
---|
| 3549 | testgrid=0; |
---|
| 3550 | if value |
---|
[112] | 3551 | filebase=get(handles.RootName,'String'); |
---|
[39] | 3552 | [nbslice, flag_grid]=get_grid(filebase,handles); |
---|
[2] | 3553 | if isequal(flag_grid,1) |
---|
[112] | 3554 | filegrid=[num2str(nbslice) 'grid']; |
---|
| 3555 | testgrid=1; |
---|
| 3556 | else |
---|
[2] | 3557 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3558 | {'*.grid', ' (*.grid)'; |
---|
| 3559 | '*.grid', '.grid files '; ... |
---|
| 3560 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3561 | 'Pick a file',filebase); |
---|
[2] | 3562 | filegrid=fullfile(PathName,FileName); |
---|
| 3563 | if ~(isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file')) |
---|
| 3564 | testgrid=1; |
---|
| 3565 | end |
---|
[112] | 3566 | end |
---|
[2] | 3567 | end |
---|
| 3568 | if testgrid |
---|
[112] | 3569 | set(handles.browse_gridciv2,'Value',1) |
---|
| 3570 | set(handles.get_gridpatch1,'Value',1) |
---|
| 3571 | set(handles.get_gridpatch2,'Value',1) |
---|
| 3572 | set(handles.dx_civ1,'Visible','off'); |
---|
| 3573 | set(handles.dy_civ1,'Visible','off'); |
---|
| 3574 | set(handles.dx_civ2,'Visible','off'); |
---|
| 3575 | set(handles.dy_civ2,'Visible','off'); |
---|
| 3576 | set(handles.grid_civ1,'String',filegrid) |
---|
| 3577 | set(handles.grid_patch1,'String',filegrid) |
---|
| 3578 | set(handles.grid_civ2,'String',filegrid) |
---|
| 3579 | set(handles.grid_patch2,'String',filegrid) |
---|
| 3580 | else |
---|
| 3581 | set(handles.browse_gridciv1,'Value',0); |
---|
| 3582 | set(handles.browse_gridciv2,'Value',0); |
---|
| 3583 | set(handles.get_gridpatch1,'Value',0) |
---|
| 3584 | set(handles.get_gridpatch2,'Value',0) |
---|
| 3585 | set(handles.dx_civ1,'Visible','on'); |
---|
| 3586 | set(handles.dy_civ1,'Visible','on'); |
---|
| 3587 | set(handles.dx_civ2,'Visible','on'); |
---|
| 3588 | set(handles.dy_civ2,'Visible','on'); |
---|
| 3589 | set(handles.grid_civ1,'String','') |
---|
| 3590 | set(handles.grid_patch1,'String','') |
---|
| 3591 | set(handles.grid_civ2,'String','') |
---|
| 3592 | set(handles.grid_patch2,'String','') |
---|
[2] | 3593 | end |
---|
| 3594 | |
---|
[12] | 3595 | %------------------------------------------------------------------------ |
---|
[2] | 3596 | % --- Executes on button press in browse_gridciv1. |
---|
| 3597 | function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
[12] | 3598 | %------------------------------------------------------------------------ |
---|
[2] | 3599 | value=get(handles.browse_gridciv2,'Value'); |
---|
| 3600 | if value |
---|
[112] | 3601 | filebase=get(handles.RootName,'String'); |
---|
[39] | 3602 | [nbslice, flag_grid]=get_grid(filebase,handles); |
---|
[2] | 3603 | if isequal(flag_grid,1) |
---|
| 3604 | mask_displ=[num2str(nbslice) 'grid']; |
---|
| 3605 | set(handles.grid_civ2,'String',mask_displ) |
---|
| 3606 | set(handles.dx_civ2,'Visible','off'); |
---|
| 3607 | set(handles.dy_civ2,'Visible','off'); |
---|
[112] | 3608 | else |
---|
[2] | 3609 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3610 | {'*.grid', ' (*.grid)'; |
---|
| 3611 | '*.grid', '.grid files '; ... |
---|
| 3612 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3613 | 'Pick a file',filebase); |
---|
[2] | 3614 | filegrid=fullfile(PathName,FileName); |
---|
[229] | 3615 | if isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file') |
---|
[2] | 3616 | set(handles.browse_gridciv2,'Value',0); |
---|
| 3617 | set(handles.grid_civ2,'string',''); |
---|
| 3618 | set(handles.dx_civ2,'Visible','on'); |
---|
| 3619 | set(handles.dy_civ2,'Visible','on'); |
---|
| 3620 | set(handles.grid_civ2,'string',''); |
---|
| 3621 | else |
---|
| 3622 | set(handles.grid_civ2,'string',filegrid); |
---|
| 3623 | set(handles.dx_civ2,'Visible','off'); |
---|
| 3624 | set(handles.dy_civ2,'Visible','off'); |
---|
| 3625 | set(handles.grid_civ2,'string',filegrid); |
---|
| 3626 | end |
---|
| 3627 | end |
---|
| 3628 | else |
---|
| 3629 | set(handles.grid_civ2,'string',''); |
---|
[112] | 3630 | set(handles.dx_civ2,'Visible','on'); |
---|
| 3631 | set(handles.dy_civ2,'Visible','on'); |
---|
| 3632 | set(handles.grid_civ2,'string',''); |
---|
[2] | 3633 | end |
---|
| 3634 | |
---|
| 3635 | % % --- Executes on button press in browse_gridciv2. |
---|
| 3636 | % function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
[112] | 3637 | % |
---|
[71] | 3638 | % filebase=get(handles.RootName,'String'); |
---|
[2] | 3639 | % [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3640 | % {'*.grid', ' (*.grid)'; |
---|
| 3641 | % '*.grid', '.grid files '; ... |
---|
| 3642 | % '*.*', 'All Files (*.*)'}, ... |
---|
| 3643 | % 'Pick a file',filebase); |
---|
| 3644 | % filegrid=fullfile(PathName,FileName); |
---|
| 3645 | % set(handles.grid_civ2,'string',filegrid); |
---|
| 3646 | % set(handles.dx_civ2,'String',' '); |
---|
| 3647 | % set(handles.dy_civ2,'String',' '); |
---|
| 3648 | % % set(handles.grid_patch2,'string',filegrid); |
---|
| 3649 | |
---|
| 3650 | % --- Executes on button press in get_gridpatch1. |
---|
| 3651 | function get_gridpatch1_Callback(hObject, eventdata, handles) |
---|
| 3652 | % hObject handle to get_gridpatch1 (see GCBO) |
---|
| 3653 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 3654 | % handles structure with handles and user data (see GUIDATA) |
---|
| 3655 | |
---|
[71] | 3656 | filebase=get(handles.RootName,'String'); |
---|
[2] | 3657 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3658 | {'*.grid', ' (*.grid)'; |
---|
| 3659 | '*.grid', '.grid files '; ... |
---|
| 3660 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3661 | 'Pick a file',filebase); |
---|
[2] | 3662 | filegrid=fullfile(PathName,FileName); |
---|
| 3663 | set(handles.grid_patch1,'string',filegrid); |
---|
| 3664 | % set(handles.grid_patch2,'string',filegrid |
---|
| 3665 | |
---|
[12] | 3666 | %------------------------------------------------------------------------ |
---|
[2] | 3667 | % --- Executes on button press in get_gridpatch2. |
---|
| 3668 | function get_gridpatch2_Callback(hObject, eventdata, handles) |
---|
[12] | 3669 | %------------------------------------------------------------------------ |
---|
[2] | 3670 | |
---|
[12] | 3671 | %------------------------------------------------------------------------ |
---|
[2] | 3672 | function enable_civ1(handles,state) |
---|
[12] | 3673 | %------------------------------------------------------------------------ |
---|
[2] | 3674 | if isequal(state,'on') |
---|
| 3675 | set(handles.frame_civ1,'BackgroundColor',[1 1 0]) |
---|
| 3676 | set(handles.frame_para_civ1,'BackgroundColor',[1 1 0]) |
---|
| 3677 | set(handles.frame_grid_civ1,'BackgroundColor',[1 1 0]) |
---|
| 3678 | else |
---|
| 3679 | set(handles.frame_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3680 | set(handles.frame_para_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3681 | set(handles.frame_grid_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3682 | end |
---|
| 3683 | set(handles.ibx,'Visible',state) |
---|
| 3684 | set(handles.iby,'Visible',state) |
---|
| 3685 | set(handles.isx,'Visible',state) |
---|
| 3686 | set(handles.isy,'Visible',state) |
---|
| 3687 | set(handles.shiftx,'Visible',state) |
---|
| 3688 | set(handles.shifty,'Visible',state) |
---|
| 3689 | set(handles.rho,'Visible',state) |
---|
| 3690 | set(handles.dx_civ1,'Visible',state) |
---|
| 3691 | set(handles.dy_civ1,'Visible',state) |
---|
| 3692 | set(handles.calcul_search,'Visible',state) |
---|
| 3693 | set(handles.u_text,'Visible',state) |
---|
| 3694 | set(handles.v_text,'Visible',state) |
---|
| 3695 | set(handles.min,'Visible',state) |
---|
| 3696 | set(handles.max,'Visible',state) |
---|
| 3697 | set(handles.umin,'Visible',state) |
---|
| 3698 | set(handles.umax,'Visible',state) |
---|
| 3699 | set(handles.vmin,'Visible',state) |
---|
| 3700 | set(handles.vmax,'Visible',state) |
---|
| 3701 | set(handles.grid_civ1,'Visible',state) |
---|
| 3702 | set(handles.mask_civ1,'Visible',state) |
---|
| 3703 | set(handles.browse_gridciv1,'Visible',state) |
---|
| 3704 | set(handles.get_mask_civ1,'Visible',state) |
---|
| 3705 | set(handles.parameters,'Visible',state) |
---|
| 3706 | set(handles.grid,'Visible',state) |
---|
| 3707 | set(handles.dx_civ1,'Visible',state) |
---|
| 3708 | set(handles.dy_civ1,'Visible',state) |
---|
| 3709 | set(handles.ImaThreshold,'Visible',state) |
---|
| 3710 | if isequal(state,'off') |
---|
| 3711 | set(handles.MinIma,'Visible','off') |
---|
| 3712 | set(handles.MaxIma,'Visible','off') |
---|
| 3713 | set(handles.ImaThreshold,'Value',0) |
---|
| 3714 | end |
---|
| 3715 | set(handles.dx_civ1_title,'Visible',state) |
---|
| 3716 | set(handles.dy_civ1_title,'Visible',state) |
---|
| 3717 | set(handles.ImaThreshold_title,'Visible',state) |
---|
| 3718 | set(handles.ib_title,'Visible',state) |
---|
| 3719 | set(handles.is_title,'Visible',state) |
---|
| 3720 | set(handles.shift_title,'Visible',state) |
---|
| 3721 | set(handles.rho_title,'Visible',state) |
---|
[224] | 3722 | set(handles.TestCiv1,'Visible',state) |
---|
| 3723 | %set(handles.CivAll,'Visible',state) |
---|
[2] | 3724 | |
---|
[12] | 3725 | %------------------------------------------------------------------------ |
---|
[2] | 3726 | function enable_fix1(handles,state) |
---|
[12] | 3727 | %------------------------------------------------------------------------ |
---|
[2] | 3728 | if isequal(state,0) |
---|
| 3729 | state='off'; |
---|
| 3730 | end |
---|
| 3731 | if isequal(state,1) |
---|
| 3732 | state='on'; |
---|
| 3733 | end |
---|
| 3734 | if isequal(state,'on') |
---|
| 3735 | set(handles.frame_fix1,'BackgroundColor',[1 1 0]) |
---|
| 3736 | else |
---|
| 3737 | set(handles.frame_fix1,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3738 | end |
---|
| 3739 | set(handles.REMOVE,'Visible',state) |
---|
| 3740 | set(handles.vec_Fmin2,'Visible',state) |
---|
| 3741 | set(handles.vec_F2,'Visible',state) |
---|
| 3742 | set(handles.vec_F3,'Visible',state) |
---|
| 3743 | set(handles.thresh_vecC,'Visible',state) |
---|
| 3744 | set(handles.thresh_vecC_title,'Visible',state) |
---|
| 3745 | set(handles.thresh_vel,'Visible',state) |
---|
| 3746 | set(handles.thresh_vel_text,'Visible',state) |
---|
| 3747 | set(handles.mask_fix1,'Visible',state) |
---|
| 3748 | set(handles.get_mask_fix1,'Visible',state) |
---|
| 3749 | set(handles.get_ref_fix1,'Visible',state) |
---|
| 3750 | set(handles.ref_fix1,'Visible',state) |
---|
| 3751 | set(handles.inf_sup1,'Visible',state) |
---|
| 3752 | set(handles.field_ref1,'Visible',state) |
---|
| 3753 | |
---|
[12] | 3754 | %------------------------------------------------------------------------ |
---|
[2] | 3755 | function enable_patch1(handles) |
---|
[12] | 3756 | %------------------------------------------------------------------------ |
---|
[2] | 3757 | set(handles.frame_patch1,'BackgroundColor',[1 1 0]) |
---|
| 3758 | set(handles.rho_patch1,'Visible','on') |
---|
| 3759 | set(handles.rho_text1,'Visible','on') |
---|
[225] | 3760 | if get(handles.CivAll,'Value')==2 |
---|
[224] | 3761 | set(handles.thresh_patch1,'Visible','on') |
---|
| 3762 | set(handles.thresh_text1,'Visible','on') |
---|
| 3763 | end |
---|
[2] | 3764 | set(handles.subdomain_patch1,'Visible','on') |
---|
| 3765 | set(handles.subdomain_text1,'Visible','on') |
---|
| 3766 | set(handles.nx_patch1,'Visible','on') |
---|
| 3767 | set(handles.ny_patch1,'Visible','on') |
---|
| 3768 | set(handles.nx_patch1_title,'Visible','on') |
---|
| 3769 | set(handles.ny_patch1_title,'Visible','on') |
---|
[112] | 3770 | % if ~isempty(patch_newBin) |
---|
[224] | 3771 | set(handles.test_interp,'Visible','off'); |
---|
[100] | 3772 | % end |
---|
[2] | 3773 | set(handles.get_gridpatch1,'Visible','on') |
---|
| 3774 | set(handles.grid_patch1,'string','none'); |
---|
| 3775 | set(handles.grid_patch1,'Visible','on') |
---|
| 3776 | |
---|
[12] | 3777 | %------------------------------------------------------------------------ |
---|
[2] | 3778 | function desable_patch1(handles) |
---|
[12] | 3779 | %------------------------------------------------------------------------ |
---|
[2] | 3780 | set(handles.frame_patch1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3781 | set(handles.rho_patch1,'Visible','off') |
---|
| 3782 | set(handles.rho_text1,'Visible','off') |
---|
| 3783 | set(handles.thresh_patch1,'Visible','off') |
---|
| 3784 | set(handles.thresh_text1,'Visible','off') |
---|
| 3785 | set(handles.subdomain_patch1,'Visible','off') |
---|
| 3786 | set(handles.subdomain_text1,'Visible','off') |
---|
| 3787 | set(handles.nx_patch1,'Visible','off') |
---|
| 3788 | set(handles.ny_patch1,'Visible','off') |
---|
| 3789 | set(handles.nx_patch1_title,'Visible','off') |
---|
| 3790 | set(handles.ny_patch1_title,'Visible','off') |
---|
[100] | 3791 | %set(handles.test_interp,'Visible','off') |
---|
[2] | 3792 | set(handles.get_gridpatch1,'Visible','off') |
---|
| 3793 | set(handles.grid_patch1,'Visible','off') |
---|
| 3794 | |
---|
[12] | 3795 | %------------------------------------------------------------------------ |
---|
[2] | 3796 | function enable_civ2(handles,state) |
---|
[12] | 3797 | %------------------------------------------------------------------------ |
---|
[2] | 3798 | if isequal(state,0) |
---|
| 3799 | state='off'; |
---|
| 3800 | end |
---|
| 3801 | if isequal(state,1) |
---|
| 3802 | state='on'; |
---|
| 3803 | end |
---|
| 3804 | if isequal(state,'on') |
---|
| 3805 | set(handles.frame_civ2,'BackgroundColor',[1 1 0]) |
---|
| 3806 | set(handles.frame_para_civ2,'BackgroundColor',[1 1 0]) |
---|
| 3807 | set(handles.frame_grid_civ2,'BackgroundColor',[1 1 0]) |
---|
| 3808 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 3809 | else |
---|
| 3810 | set(handles.frame_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3811 | set(handles.frame_para_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3812 | set(handles.frame_grid_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3813 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3814 | end |
---|
| 3815 | set(handles.ibx_civ2,'Visible',state) |
---|
| 3816 | set(handles.iby_civ2,'Visible',state) |
---|
| 3817 | set(handles.decimal,'Visible',state) |
---|
| 3818 | set(handles.deformation,'Visible',state) |
---|
| 3819 | set(handles.rho_civ2,'Visible',state) |
---|
| 3820 | set(handles.dx_civ2,'Visible',state) |
---|
| 3821 | set(handles.dy_civ2,'Visible',state) |
---|
| 3822 | set(handles.browse_gridciv2,'Visible',state) |
---|
| 3823 | set(handles.get_mask_civ2,'Visible',state) |
---|
| 3824 | set(handles.parameters,'Visible',state) |
---|
| 3825 | set(handles.grid,'Visible',state) |
---|
| 3826 | set(handles.parameters_text,'Visible',state) |
---|
| 3827 | set(handles.grid_text,'Visible',state) |
---|
| 3828 | set(handles.grid_civ2,'Visible',state) |
---|
| 3829 | set(handles.mask_civ2,'Visible',state) |
---|
| 3830 | set(handles.dx_civ2_title,'Visible',state) |
---|
| 3831 | set(handles.dy_civ2_title,'Visible',state) |
---|
| 3832 | set(handles.ibx_civ2_text,'Visible',state) |
---|
| 3833 | set(handles.rho_civ2_title,'Visible',state) |
---|
| 3834 | set(handles.ImaThreshold2,'Visible',state) |
---|
| 3835 | set(handles.ImaThreshold_title2,'Visible',state) |
---|
| 3836 | if isequal(state,'off') |
---|
| 3837 | set(handles.MinIma2,'Visible','off') |
---|
| 3838 | set(handles.MaxIma2,'Visible','off') |
---|
| 3839 | set(handles.ImaThreshold2,'Value',0) |
---|
[112] | 3840 | if isequal(get(handles.FIX2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) |
---|
[2] | 3841 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 3842 | set(handles.subdir_civ2,'Visible','off') |
---|
| 3843 | set(handles.subdir_civ2_text,'Visible','off') |
---|
[71] | 3844 | set(handles.dt_unit_civ2,'Visible','off') |
---|
| 3845 | set(handles.ref_i_civ2,'Visible','off') |
---|
| 3846 | set(handles.i_ref_civ2_title,'Visible','off') |
---|
| 3847 | set(handles.j_ref_civ2_title,'Visible','off') |
---|
| 3848 | set(handles.ref_j_civ2,'Visible','off') |
---|
[2] | 3849 | end |
---|
| 3850 | else |
---|
| 3851 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 3852 | set(handles.subdir_civ2,'Visible','on') |
---|
| 3853 | set(handles.subdir_civ2_text,'Visible','on') |
---|
[71] | 3854 | set(handles.dt_unit_civ2,'Visible','on') |
---|
| 3855 | set(handles.ref_i_civ2,'Visible','on') |
---|
| 3856 | set(handles.i_ref_civ2_title,'Visible','on') |
---|
| 3857 | set(handles.j_ref_civ2_title,'Visible','on') |
---|
| 3858 | set(handles.ref_j_civ2,'Visible','on') |
---|
[2] | 3859 | end |
---|
[71] | 3860 | set(handles.rho_civ2_title,'Visible',state) |
---|
[2] | 3861 | |
---|
[12] | 3862 | %------------------------------------------------------------------------ |
---|
[2] | 3863 | function enable_fix2(handles) |
---|
[12] | 3864 | %------------------------------------------------------------------------ |
---|
[2] | 3865 | set(handles.frame_fix2,'BackgroundColor',[1 1 0]) |
---|
| 3866 | set(handles.REMOVE2,'Visible','on') |
---|
| 3867 | set(handles.vec_Fmin2_2,'Visible','on') |
---|
| 3868 | set(handles.vec_F4,'Visible','on') |
---|
| 3869 | set(handles.vec_F3_2,'Visible','on') |
---|
| 3870 | set(handles.thresh_vec2C,'Visible','on') |
---|
| 3871 | set(handles.thresh_vec2C_text,'Visible','on') |
---|
| 3872 | set(handles.thresh_vel2,'Visible','on') |
---|
| 3873 | set(handles.thresh_vel2_text,'Visible','on') |
---|
| 3874 | set(handles.mask_fix2,'Visible','on') |
---|
| 3875 | set(handles.get_mask_fix2,'Visible','on') |
---|
| 3876 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 3877 | set(handles.subdir_civ2,'Visible','on') |
---|
| 3878 | set(handles.subdir_civ2_text,'Visible','on') |
---|
| 3879 | set(handles.get_ref_fix2,'Visible','on') |
---|
| 3880 | set(handles.ref_fix2,'Visible','on') |
---|
| 3881 | set(handles.inf_sup2,'Visible','on') |
---|
| 3882 | set(handles.field_ref2,'Visible','on') |
---|
| 3883 | |
---|
[12] | 3884 | %------------------------------------------------------------------------ |
---|
[2] | 3885 | function desable_fix2(handles) |
---|
[12] | 3886 | %------------------------------------------------------------------------ |
---|
[2] | 3887 | set(handles.frame_fix2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3888 | set(handles.REMOVE2,'Visible','off') |
---|
| 3889 | set(handles.vec_Fmin2_2,'Visible','off') |
---|
| 3890 | set(handles.vec_F4,'Visible','off') |
---|
| 3891 | set(handles.vec_F3_2,'Visible','off') |
---|
| 3892 | set(handles.thresh_vec2C,'Visible','off') |
---|
| 3893 | set(handles.thresh_vec2C_text,'Visible','off') |
---|
| 3894 | set(handles.thresh_vel2,'Visible','off') |
---|
| 3895 | set(handles.thresh_vel2_text,'Visible','off') |
---|
| 3896 | set(handles.mask_fix2,'Visible','off') |
---|
| 3897 | set(handles.get_mask_fix2,'Visible','off') |
---|
| 3898 | set(handles.get_ref_fix2,'Visible','off') |
---|
| 3899 | set(handles.ref_fix2,'Visible','off') |
---|
| 3900 | set(handles.inf_sup2,'Visible','off') |
---|
| 3901 | set(handles.field_ref2,'Visible','off') |
---|
[112] | 3902 | if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) |
---|
[2] | 3903 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 3904 | set(handles.subdir_civ2,'Visible','off') |
---|
| 3905 | set(handles.subdir_civ2_text,'Visible','off') |
---|
| 3906 | end |
---|
| 3907 | |
---|
[12] | 3908 | %------------------------------------------------------------------------ |
---|
[2] | 3909 | function enable_patch2(handles) |
---|
[12] | 3910 | %------------------------------------------------------------------------ |
---|
[2] | 3911 | set(handles.frame_patch2,'BackgroundColor',[1 1 0]) |
---|
[119] | 3912 | set(handles.rho_patch2,'Visible','on') |
---|
[2] | 3913 | set(handles.rho_text2,'Visible','on') |
---|
| 3914 | set(handles.thresh_patch2,'Visible','on') |
---|
| 3915 | set(handles.thresh_text2,'Visible','on') |
---|
| 3916 | set(handles.subdomain_patch2,'Visible','on') |
---|
| 3917 | set(handles.subdomain_text2,'Visible','on') |
---|
| 3918 | set(handles.nx_patch2,'Visible','on') |
---|
| 3919 | set(handles.ny_patch2,'Visible','on') |
---|
| 3920 | set(handles.nx_patch2_title,'Visible','on') |
---|
| 3921 | set(handles.ny_patch2_title,'Visible','on') |
---|
| 3922 | set(handles.get_gridpatch2,'Visible','on') |
---|
| 3923 | set(handles.grid_patch2,'Visible','on') |
---|
| 3924 | set(handles.list_pair_civ2,'Visible','on') |
---|
| 3925 | set(handles.subdir_civ2,'Visible','on') |
---|
| 3926 | set(handles.subdir_civ2_text,'Visible','on') |
---|
| 3927 | |
---|
[12] | 3928 | %------------------------------------------------------------------------ |
---|
[2] | 3929 | function desable_patch2(handles) |
---|
[12] | 3930 | %------------------------------------------------------------------------ |
---|
[2] | 3931 | set(handles.frame_patch2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3932 | set(handles.rho_patch2,'Visible','off') |
---|
| 3933 | set(handles.rho_text2,'Visible','off') |
---|
| 3934 | set(handles.thresh_patch2,'Visible','off') |
---|
| 3935 | set(handles.thresh_text2,'Visible','off') |
---|
| 3936 | set(handles.subdomain_patch2,'Visible','off') |
---|
| 3937 | set(handles.subdomain_text2,'Visible','off') |
---|
| 3938 | set(handles.nx_patch2,'Visible','off') |
---|
| 3939 | set(handles.ny_patch2,'Visible','off') |
---|
| 3940 | set(handles.nx_patch2_title,'Visible','off') |
---|
| 3941 | set(handles.ny_patch2_title,'Visible','off') |
---|
| 3942 | set(handles.get_gridpatch2,'Visible','off') |
---|
| 3943 | set(handles.grid_patch2,'Visible','off') |
---|
[112] | 3944 | if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.FIX2,'Value'),0) |
---|
[2] | 3945 | set(handles.list_pair_civ2,'Visible','off') |
---|
| 3946 | set(handles.subdir_civ2,'Visible','off') |
---|
| 3947 | set(handles.subdir_civ2_text,'Visible','off') |
---|
| 3948 | end |
---|
| 3949 | |
---|
[12] | 3950 | %------------------------------------------------------------------------ |
---|
[2] | 3951 | function enable_pair1(handles,state) |
---|
[12] | 3952 | %------------------------------------------------------------------------ |
---|
[2] | 3953 | set(handles.subdir_civ1,'Visible',state) |
---|
| 3954 | set(handles.list_subdir_civ1,'Visible',state) |
---|
| 3955 | set(handles.SUBDIR_CIV1_txt,'Visible',state) |
---|
| 3956 | set(handles.frame_subdirciv1,'Visible',state) |
---|
| 3957 | set(handles.list_pair_civ1,'Visible',state) |
---|
| 3958 | set(handles.PAIR_txt,'Visible',state) |
---|
[71] | 3959 | %set(handles.dt_unit,'Visible',state) |
---|
[2] | 3960 | set(handles.PAIR_frame,'Visible',state) |
---|
| 3961 | |
---|
[12] | 3962 | %------------------------------------------------------------------------ |
---|
| 3963 | % --- Read the parameters for civ1 on the interface |
---|
[2] | 3964 | function par=read_param_civ1(handles,file_ima) |
---|
[12] | 3965 | %------------------------------------------------------------------------ |
---|
[127] | 3966 | ibx_val=str2double(get(handles.ibx,'String')); |
---|
[2] | 3967 | par.ibx=num2str(ibx_val); |
---|
[127] | 3968 | iby_val=str2double(get(handles.iby,'String')); |
---|
[2] | 3969 | par.iby=num2str(iby_val); |
---|
| 3970 | isx=get(handles.isx,'String'); |
---|
[127] | 3971 | if isnan(str2double(isx)), isx='41'; set(handles.isx,'String','41'), end; %default |
---|
| 3972 | if str2double(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.isx,'String',num2str(ibx_val+8)); end |
---|
[2] | 3973 | isy=get(handles.isy,'String'); |
---|
[127] | 3974 | if isnan(str2double(isy)), isy='41'; set(handles.isy,'String','41'), end;%default |
---|
| 3975 | if str2double(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.isy,'String',num2str(iby_val+8)); end |
---|
[2] | 3976 | par.isx=get(handles.isx,'String'); |
---|
| 3977 | par.isy=get(handles.isy,'String'); |
---|
| 3978 | par.shiftx=get(handles.shiftx,'String'); |
---|
| 3979 | par.shifty=get(handles.shifty,'String'); |
---|
[127] | 3980 | if isnan(str2double(par.isx)) |
---|
[112] | 3981 | par.isx='41';%default |
---|
| 3982 | set(handles.isx,'String','41'); |
---|
[2] | 3983 | end |
---|
[127] | 3984 | if isnan(str2double(par.isy)) |
---|
[112] | 3985 | par.isy='41'; %default |
---|
| 3986 | set(handles.isy,'String','41'); |
---|
[12] | 3987 | end |
---|
[127] | 3988 | if isnan(str2double(par.shiftx)) |
---|
[112] | 3989 | par.shiftx='0';%default |
---|
| 3990 | set(handles.shiftx,'String','0'); |
---|
| 3991 | end |
---|
[127] | 3992 | if isnan(str2double(par.shifty)) |
---|
[112] | 3993 | par.shifty='0'; %default |
---|
| 3994 | set(handles.shifty,'String','0'); |
---|
[12] | 3995 | end |
---|
[112] | 3996 | par.rho=get(handles.rho,'String'); |
---|
| 3997 | par.dx=get(handles.dx_civ1,'String'); |
---|
| 3998 | par.dy=get(handles.dy_civ1,'String'); |
---|
[127] | 3999 | if isnan(str2double(par.dx)) |
---|
[112] | 4000 | if isempty(get(handles.grid_civ1,'String')); |
---|
| 4001 | par.dx='0'; %just read by civ program, not used |
---|
| 4002 | else |
---|
[12] | 4003 | par.dx='20';%default |
---|
| 4004 | set(handles.dx_civ1,'String','20'); |
---|
[112] | 4005 | end |
---|
| 4006 | end |
---|
[127] | 4007 | if isnan(str2double(par.dy)) |
---|
[112] | 4008 | if isempty(get(handles.grid_civ1,'String')); |
---|
| 4009 | par.dy='0';%just read by civ program, not used |
---|
| 4010 | else |
---|
[12] | 4011 | par.dy='20';%default |
---|
| 4012 | set(handles.dy_civ1_title,'String','20'); |
---|
[112] | 4013 | end |
---|
| 4014 | end |
---|
| 4015 | par.pxcmx='1'; %velocities are expressed in pixel dispalcement |
---|
| 4016 | par.pxcmy='1'; |
---|
[150] | 4017 | if exist('file_ima','var') |
---|
[112] | 4018 | A=imread(file_ima);%read the first image to get the size |
---|
| 4019 | sizim=size(A); |
---|
| 4020 | par.npx=num2str(sizim(2)); |
---|
| 4021 | par.npy=num2str(sizim(1)); |
---|
[150] | 4022 | end |
---|
[127] | 4023 | %time=get(handles.RootName,'UserData'); %get the set of times |
---|
[112] | 4024 | par.gridname=get(handles.grid_civ1,'String'); |
---|
| 4025 | par.gridflag='y'; |
---|
[127] | 4026 | if strcmp(par.gridname,'')|| isempty(par.gridname) |
---|
[112] | 4027 | par.gridname='nogrid'; |
---|
| 4028 | par.gridflag='n'; |
---|
| 4029 | end |
---|
[12] | 4030 | |
---|
| 4031 | %------------------------------------------------------------------------ |
---|
[2] | 4032 | function par=read_param_civ2(handles,file_ima) |
---|
[12] | 4033 | %------------------------------------------------------------------------ |
---|
| 4034 | par.ibx=get(handles.ibx_civ2,'String'); |
---|
| 4035 | par.iby=get(handles.iby_civ2,'String'); |
---|
| 4036 | par.rho=get(handles.rho_civ2,'String'); |
---|
| 4037 | par.decimal=int2str(get(handles.decimal,'Value')); |
---|
| 4038 | par.deformation=int2str(get(handles.deformation,'Value')); |
---|
| 4039 | par.dx=get(handles.dx_civ2,'String'); |
---|
| 4040 | par.dy=get(handles.dy_civ2,'String'); |
---|
[127] | 4041 | if isnan(str2double(par.dx)) |
---|
[112] | 4042 | if isempty(get(handles.grid_civ2,'String')); |
---|
| 4043 | par.dx='0'; %just read by civ program, not used |
---|
| 4044 | else |
---|
[12] | 4045 | par.dx='20';%default |
---|
| 4046 | set(handles.dx_civ2,'String','20'); |
---|
[112] | 4047 | end |
---|
| 4048 | end |
---|
[127] | 4049 | if isnan(str2double(par.dy)) |
---|
[112] | 4050 | if isempty(get(handles.grid_civ2,'String')); |
---|
| 4051 | par.dy='0';%just read by civ program, not used |
---|
| 4052 | else |
---|
[12] | 4053 | par.dy='20';%default |
---|
| 4054 | set(handles.dy_civ2,'String','20'); |
---|
[112] | 4055 | end |
---|
| 4056 | end |
---|
| 4057 | par.pxcmx='1'; |
---|
| 4058 | par.pxcmy='1'; |
---|
[12] | 4059 | A=imread(file_ima);%read the first image to get the size |
---|
| 4060 | sizim=size(A); |
---|
| 4061 | par.npx=num2str(sizim(2)); |
---|
| 4062 | par.npy=num2str(sizim(1)); |
---|
[127] | 4063 | %time=get(handles.RootName,'UserData'); %get the set of times |
---|
[12] | 4064 | par.gridname=get(handles.grid_civ2,'String'); |
---|
| 4065 | par.gridflag='y'; |
---|
[127] | 4066 | if strcmp(par.gridname,'')|| isempty(par.gridname) |
---|
[12] | 4067 | par.gridname='nogrid'; |
---|
| 4068 | par.gridflag='n'; |
---|
| 4069 | end |
---|
[2] | 4070 | |
---|
[12] | 4071 | %------------------------------------------------------------------------ |
---|
| 4072 | % --- CIV1 CIV1 CIV1 CIV1 |
---|
[94] | 4073 | function cmd_CIV1=CIV1_CMD(filename,namelog,par,handles,sparam) |
---|
[12] | 4074 | %------------------------------------------------------------------------ |
---|
[2] | 4075 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 4076 | |
---|
| 4077 | %changes : filename_cmx -> filename ( no extension ) |
---|
[174] | 4078 | % input namelog not used |
---|
[112] | 4079 | if isequal(par.Dt,'0') |
---|
| 4080 | par.Dt='1' ;%case of 'displacement' mode |
---|
| 4081 | end |
---|
[90] | 4082 | par.filename_ima_a=regexprep(par.filename_ima_a,'.png',''); |
---|
[94] | 4083 | par.filename_ima_b=regexprep(par.filename_ima_b,'.png',''); |
---|
[230] | 4084 | fid=fopen([filename '.civ1.cmx'],'w'); |
---|
[12] | 4085 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
[112] | 4086 | fprintf(fid, ['FirstImage ' regexprep(par.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4087 | fprintf(fid, ['LastImage ' regexprep(par.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4088 | fprintf(fid, ['XX' '\n' ]); |
---|
| 4089 | fprintf(fid, ['Mask ' par.maskflag '\n' ]); |
---|
| 4090 | fprintf(fid, ['MaskName ' regexprep(par.maskname,'\\','\\\\') '\n' ]); |
---|
| 4091 | fprintf(fid, ['ImageSize ' par.npx ' ' par.npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 4092 | fprintf(fid, ['CorrelationBoxesSize ' par.ibx ' ' par.iby '\n' ]); |
---|
| 4093 | fprintf(fid, ['SearchBoxeSize ' par.isx ' ' par.isy '\n' ]); |
---|
| 4094 | fprintf(fid, ['RO ' par.rho '\n' ]); |
---|
| 4095 | fprintf(fid, ['GridSpacing ' par.dx ' ' par.dy '\n' ]); |
---|
| 4096 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4097 | fprintf(fid, ['Dt_TO ' par.Dt ' ' par.T0 '\n' ]); |
---|
| 4098 | fprintf(fid, ['PixCmXY ' par.pxcmx ' ' par.pxcmy '\n' ]); |
---|
| 4099 | fprintf(fid, ['XX 1' '\n' ]); |
---|
| 4100 | fprintf(fid, ['ShiftXY ' par.shiftx ' ' par.shifty '\n' ]); |
---|
| 4101 | fprintf(fid, ['Grid ' par.gridflag '\n' ]); |
---|
| 4102 | fprintf(fid, ['GridName ' regexprep(par.gridname,'\\','\\\\') '\n' ]); |
---|
| 4103 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 4104 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4105 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4106 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
| 4107 | fprintf(fid, [ 'DecimalShift 0' '\n' ]); |
---|
| 4108 | fprintf(fid, ['Deformation 0' '\n' ]); |
---|
| 4109 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 4110 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 4111 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 4112 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
| 4113 | fprintf(fid, ['ImageToUse ' par.term_a ' ' par.term_b '\n' ]); % VERIFIER ? |
---|
| 4114 | fprintf(fid, ['ImageUsedBefore null null' '\n' ]); |
---|
[12] | 4115 | fclose(fid); |
---|
[112] | 4116 | |
---|
[163] | 4117 | % cmd_CIV1=[sparam.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file |
---|
| 4118 | % cmd_CIV1=regexprep(cmd_CIV1,'\\','\\\\'); |
---|
| 4119 | % namelog=regexprep(namelog,'\\','\\\\'); |
---|
[12] | 4120 | if(isunix) |
---|
[230] | 4121 | cmd_CIV1=['cp -f ' filename '.civ1.cmx ' filename '.cmx\n']; |
---|
| 4122 | 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] | 4123 | 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] | 4124 | % cmd_CIV1=[cmd_CIV1 '\n' 'mv ' filename '.cmx' ' ' filename '.civ1.cmx' '\n'];%rename .cmx as .civ1.cmx |
---|
[163] | 4125 | else %Windows system |
---|
[230] | 4126 | flname=regexprep(flname,'\\','\\\\'); |
---|
| 4127 | % cmd=[cmd 'copy /Y "' flname '.civ1.cmx" "' flname '.cmx"\n']; |
---|
[174] | 4128 | filename=regexprep(filename,'\\','\\\\'); |
---|
[230] | 4129 | cmd_CIV1=['copy /Y "' filename '.civ1.cmx" "' filename '.cmx"\n'];% copy the .civ1.cmx parameter file to .cmx |
---|
[163] | 4130 | cmd_CIV1=['"' sparam.Civ1Bin '" -f "' filename '.cmx" >"' filename '.log"' ]; % redirect standard output to the log file |
---|
| 4131 | cmd_CIV1=regexprep(cmd_CIV1,'\\','\\\\'); |
---|
| 4132 | namelog=regexprep(namelog,'\\','\\\\'); |
---|
[230] | 4133 | cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y "' filename '.log' '" "' filename '.civ1.log"']; %preserve the log file as .civ1.log |
---|
| 4134 | % cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y "' filename '.cmx' '" "' filename '.civ1.cmx"']; |
---|
[12] | 4135 | end |
---|
[2] | 4136 | |
---|
[12] | 4137 | %------------------------------------------------------------------------ |
---|
| 4138 | % --- CIV1 Unified |
---|
[94] | 4139 | function xml_civ1_parameters=CIV1_CMD_Unified(filename,namelog,par) |
---|
[12] | 4140 | %------------------------------------------------------------------------ |
---|
[2] | 4141 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
[73] | 4142 | %global CivBin%name of the executable for civ1 calculation |
---|
[2] | 4143 | |
---|
[112] | 4144 | civ1.image1=par.filename_ima_a; |
---|
| 4145 | civ1.image2=par.filename_ima_b; |
---|
| 4146 | civ1.imageSize_X=par.npx; |
---|
| 4147 | civ1.imageSize_Y=par.npy; |
---|
| 4148 | civ1.outputFileName=[filename '.nc']; |
---|
| 4149 | civ1.correlationBoxesSize_X=par.ibx; |
---|
| 4150 | civ1.correlationBoxesSize_Y=par.iby; |
---|
| 4151 | civ1.searchBoxesSize_X=par.isx; |
---|
| 4152 | civ1.searchBoxesSize_Y=par.isy; |
---|
| 4153 | civ1.globalShift_X=par.shiftx; |
---|
| 4154 | civ1.globalShift_Y=par.shifty; |
---|
| 4155 | civ1.ro=par.rho; |
---|
| 4156 | civ1.hart='y'; |
---|
| 4157 | if isequal(par.gridflag,'y') |
---|
| 4158 | civ1.grid=par.gridname; |
---|
| 4159 | else |
---|
| 4160 | civ1.grid='n'; |
---|
| 4161 | civ1.gridSpacing_X=par.dx; |
---|
| 4162 | civ1.gridSpacing_Y=par.dy; |
---|
| 4163 | end |
---|
| 4164 | if isequal(par.maskflag,'y') |
---|
| 4165 | civ1.mask=par.maskname; |
---|
| 4166 | end |
---|
[229] | 4167 | civ1.dt=par.Dt; |
---|
[112] | 4168 | civ1.unit='pixel'; |
---|
| 4169 | civ1.absolut_time_T0=par.T0; |
---|
| 4170 | civ1.pixcmx=par.pxcmx; |
---|
| 4171 | civ1.pixcmy=par.pxcmy; |
---|
| 4172 | civ1.convectFlow='n'; |
---|
[12] | 4173 | |
---|
[112] | 4174 | xml_civ1_parameters=civ1; |
---|
| 4175 | |
---|
[12] | 4176 | %------------------------------------------------------------------------ |
---|
| 4177 | % --- CIV2 Unified |
---|
[94] | 4178 | function civ2=CIV2_CMD_Unified(filename,namelog,par) |
---|
[12] | 4179 | %------------------------------------------------------------------------ |
---|
[2] | 4180 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
[73] | 4181 | %global CivBin%name of the executable for civ1 calculation |
---|
[2] | 4182 | |
---|
| 4183 | civ2.image1=par.filename_ima_a; |
---|
| 4184 | civ2.image2=par.filename_ima_b; |
---|
[112] | 4185 | civ2.imageSize_X=par.npx; |
---|
[2] | 4186 | civ2.imageSize_Y=par.npy; |
---|
| 4187 | civ2.inputFileName=[par.filename_nc1 '.nc']; |
---|
| 4188 | civ2.outputFileName=[filename '.nc']; |
---|
| 4189 | civ2.correlationBoxesSize_X=par.ibx; |
---|
| 4190 | civ2.correlationBoxesSize_Y=par.iby; |
---|
| 4191 | civ2.ro=par.rho; |
---|
| 4192 | %civ2.decimalShift=par.decimal; |
---|
| 4193 | %civ2.deformation=par.deformation; |
---|
| 4194 | if isequal(par.decimal,'1') |
---|
| 4195 | civ2.decimalShift='y'; |
---|
| 4196 | else |
---|
| 4197 | civ2.decimalShift='n'; |
---|
| 4198 | end |
---|
| 4199 | if isequal(par.deformation,'1') |
---|
| 4200 | civ2.deformation='y'; |
---|
| 4201 | else |
---|
| 4202 | civ2.deformation='n'; |
---|
| 4203 | end |
---|
| 4204 | if isequal(par.gridflag,'y') |
---|
| 4205 | civ2.grid=par.gridname; |
---|
| 4206 | else |
---|
| 4207 | civ2.grid='n'; |
---|
| 4208 | civ2.gridSpacing_X=par.dx; |
---|
| 4209 | civ2.gridSpacing_Y=par.dy; |
---|
| 4210 | end |
---|
| 4211 | civ2.gridSpacing_X='10'; |
---|
| 4212 | civ2.gridSpacing_Y='10';%NOTE: faut mettre gridSpacing pourque ca tourne, meme si c'est la grille qui est utilisee |
---|
| 4213 | if isequal(par.maskflag,'y') |
---|
| 4214 | civ2.mask=par.maskname; |
---|
| 4215 | else |
---|
| 4216 | civ2.mask='n'; |
---|
| 4217 | end |
---|
| 4218 | civ2.dt=par.Dt; |
---|
| 4219 | civ2.unit='pixel'; |
---|
| 4220 | civ2.absolut_time_T0=par.T0; |
---|
| 4221 | civ2.pixcmx=par.pxcmx; |
---|
| 4222 | civ2.pixcmy=par.pxcmy; |
---|
| 4223 | civ2.convectFlow='n'; |
---|
| 4224 | civ2.pixcmx=par.pxcmx; |
---|
| 4225 | civ2.pixcmy=par.pxcmy; |
---|
| 4226 | civ2.convectFlow='n'; |
---|
| 4227 | |
---|
[12] | 4228 | %------------------------------------------------------------------------ |
---|
| 4229 | % --- CIV2 CIV2 CIV2 CIV2 |
---|
[134] | 4230 | function cmd_CIV2=CIV2_CMD(filename,namelog,par,sparam) |
---|
[12] | 4231 | %------------------------------------------------------------------------ |
---|
[2] | 4232 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
[67] | 4233 | % global civ2Bin sge%name of the executable for civ1 calculation |
---|
[112] | 4234 | if isequal(par.Dt,'0') |
---|
| 4235 | par.Dt='1' ;%case of 'displacement' mode |
---|
| 4236 | end |
---|
[94] | 4237 | par.filename_ima_a=regexprep(par.filename_ima_a,'.png',''); |
---|
| 4238 | par.filename_ima_b=regexprep(par.filename_ima_b,'.png','');% bug : .png appears two times ? |
---|
[174] | 4239 | [fid,errormsg]=fopen([filename '.civ2.cmx'],'w'); |
---|
| 4240 | if isequal(fid,-1) |
---|
| 4241 | msgbox_uvmat('ERROR',errormsg) |
---|
| 4242 | cmd_CIV2=''; |
---|
| 4243 | return |
---|
| 4244 | end |
---|
[94] | 4245 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
| 4246 | fprintf(fid, ['FirstImage ' regexprep(par.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4247 | fprintf(fid, ['LastImage ' regexprep(par.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4248 | fprintf(fid, ['XX' '\n' ]); |
---|
| 4249 | fprintf(fid, ['Mask ' par.maskflag '\n' ]); |
---|
| 4250 | fprintf(fid, ['MaskName ' regexprep(par.maskname,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4251 | fprintf(fid, ['ImageSize ' par.npx ' ' par.npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 4252 | fprintf(fid, ['CorrelationBoxesSize ' par.ibx ' ' par.iby '\n' ]); |
---|
| 4253 | fprintf(fid, ['SearchBoxeSize ' par.ibx ' ' par.iby '\n']); |
---|
| 4254 | fprintf(fid, ['RO ' par.rho '\n']); |
---|
| 4255 | fprintf(fid, ['GridSpacing ' par.dx ' ' par.dy '\n']); |
---|
| 4256 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4257 | fprintf(fid, ['Dt_TO ' par.Dt ' ' par.T0 '\n' ]); |
---|
| 4258 | fprintf(fid, ['PixCmXY ' par.pxcmx ' ' par.pxcmy '\n' ]); |
---|
| 4259 | fprintf(fid, ['XX 1' '\n' ]); |
---|
[122] | 4260 | fprintf(fid, 'ShiftXY 0 0\n'); |
---|
[94] | 4261 | fprintf(fid, ['Grid ' par.gridflag '\n' ]); |
---|
| 4262 | fprintf(fid, ['GridName ' regexprep(par.gridname,'\\','\\\\') '\n']); |
---|
| 4263 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 4264 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4265 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4266 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
| 4267 | fprintf(fid, ['DecimalShift ' par.decimal '\n']); |
---|
| 4268 | fprintf(fid, ['Deformation ' par.deformation '\n']); |
---|
| 4269 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 4270 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 4271 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 4272 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
| 4273 | fprintf(fid, ['ImageToUse ' par.term_a ' ' par.term_b '\n' ]); % VERIFIER ? |
---|
| 4274 | fprintf(fid, ['ImageUsedBefore ' regexprep(par.filename_nc1,'\\','\\\\') '\n']); |
---|
| 4275 | fclose(fid); |
---|
| 4276 | |
---|
[134] | 4277 | if(isunix) |
---|
[230] | 4278 | cmd_CIV2=['cp -f ' filename '.civ2.cmx ' filename '.cmx\n']; |
---|
| 4279 | cmd_CIV2=[cmd_CIV2 sparam.Civ2Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx |
---|
| 4280 | cmd_CIV2=[cmd_CIV2 '\n' 'mv ' filename '.log' ' ' filename '.civ2.log' '\n' 'chmod g+w ' filename '.nc'];%preserve the log file as .civ2.log |
---|
| 4281 | % cmd_CIV2=[cmd_CIV2 '\n' 'mv ' filename '.cmx' ' ' filename '.civ2.cmx' '\n'];%rename .cmx as .civ2.cmx, the result file is named [filename '.nc'] by CIVx |
---|
| 4282 | |
---|
[163] | 4283 | else |
---|
[174] | 4284 | filename=regexprep(filename,'\\','\\\\'); |
---|
[230] | 4285 | cmd_CIV2=['copy /Y "' filename '.civ2.cmx" "' filename '.cmx"\n']; |
---|
| 4286 | cmd_CIV2=[cmd_CIV2 '"' sparam.Civ2Bin '" -f "' filename '.cmx" >"' filename '.log"' ]; % redirect standard output to the log file |
---|
[163] | 4287 | cmd_CIV2=regexprep(cmd_CIV2,'\\','\\\\'); |
---|
[174] | 4288 | cmd_CIV2=[cmd_CIV2 '\n' 'copy /Y "' filename '.log' '" "' filename '.civ2.log"']; |
---|
[230] | 4289 | % cmd_CIV2=[cmd_CIV2 '\n' 'copy /Y "' filename '.cmx' '" "' filename '.civ2.cmx"']; |
---|
[134] | 4290 | end |
---|
| 4291 | |
---|
[231] | 4292 | %------------------------------------------------------------------------ |
---|
| 4293 | % --- civ using pivlab |
---|
| 4294 | function Data=civ_uvmat(par_civ1) |
---|
| 4295 | %------------------------------------------------------------------------ |
---|
| 4296 | image1=imread(par_civ1.filename_ima_a); |
---|
| 4297 | image2=imread(par_civ1.filename_ima_b); |
---|
| 4298 | stepx=str2num(par_civ1.dx); |
---|
| 4299 | stepy=str2num(par_civ1.dy); |
---|
| 4300 | ibx2=ceil(str2num(par_civ1.ibx)/2); |
---|
| 4301 | iby2=ceil(str2num(par_civ1.iby)/2); |
---|
| 4302 | isx2=ceil(str2num(par_civ1.isx)/2); |
---|
| 4303 | isy2=ceil(str2num(par_civ1.isy)/2); |
---|
| 4304 | shiftx=str2num(par_civ1.shiftx); |
---|
| 4305 | shifty=str2num(par_civ1.shifty); |
---|
| 4306 | miniy=max(1+isy2-shifty,1+iby2); |
---|
| 4307 | minix=max(1+isx2-shiftx,1+ibx2); |
---|
| 4308 | maxiy=min(size(image1,1)-isy2-shifty,size(image1,1)-iby2); |
---|
| 4309 | maxix=min(size(image1,2)-isx2-shiftx,size(image1,2)-ibx2); |
---|
| 4310 | [GridX,GridY]=meshgrid(minix:stepx:maxix,miniy:stepy:maxiy); |
---|
| 4311 | PointCoord(:,1)=reshape(GridX,[],1); |
---|
| 4312 | PointCoord(:,2)=reshape(GridY,[],1); |
---|
[134] | 4313 | |
---|
[231] | 4314 | % caluclate velocity data (y and v in indices, reverse to y component) |
---|
| 4315 | [xtable ytable utable vtable ctable typevector] = pivlab (image1,image2,ibx2,iby2,isx2,isy2,shiftx,shifty,PointCoord, 1, []); |
---|
| 4316 | Data.ListGlobalAttribute={'title','Time','Dt'}; |
---|
| 4317 | Data.title='PIVlab'; |
---|
| 4318 | Data.Time=str2double(par_civ1.T0); |
---|
| 4319 | Data.Dt=str2double(par_civ1.Dt); |
---|
| 4320 | Data.ListVarName={'X','Y','U','V','C','FF'};% cell array containing the names of the fields to record |
---|
| 4321 | Data.VarDimName={'nbvec','nbvec','nbvec','nbvec','nbvec','nbvec'}; |
---|
| 4322 | Data.VarAttribute{1}.Role='coord_x'; |
---|
| 4323 | Data.VarAttribute{2}.Role='coord_y'; |
---|
| 4324 | Data.VarAttribute{3}.Role='vector_x'; |
---|
| 4325 | Data.VarAttribute{4}.Role='vector_y'; |
---|
| 4326 | Data.VarAttribute{5}.Role='errorflag'; |
---|
| 4327 | Data.X=reshape(xtable,[],1); |
---|
| 4328 | Data.Y=reshape(size(image1,1)-ytable+1,[],1); |
---|
| 4329 | Data.U=reshape(utable,[],1); |
---|
| 4330 | Data.V=reshape(-vtable,[],1); |
---|
| 4331 | Data.C=reshape(ctable,[],1); |
---|
| 4332 | Data.FF=reshape(~typevector,[],1); |
---|
[134] | 4333 | |
---|
[12] | 4334 | %------------------------------------------------------------------------ |
---|
[2] | 4335 | % --- Executes on button press in HELP. |
---|
| 4336 | function HELP_Callback(hObject, eventdata, handles) |
---|
[12] | 4337 | %------------------------------------------------------------------------ |
---|
[2] | 4338 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
| 4339 | pathelp=fileparts(path_to_uvmat); |
---|
[85] | 4340 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html'); |
---|
[36] | 4341 | if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package') |
---|
[2] | 4342 | else |
---|
[36] | 4343 | addpath (fullfile(pathelp,'uvmat_doc')) |
---|
[112] | 4344 | web([helpfile '#civ']) |
---|
[2] | 4345 | end |
---|
| 4346 | |
---|
[12] | 4347 | %------------------------------------------------------------------------ |
---|
[2] | 4348 | %--read images and convert them to the uint16 format used for PIV |
---|
[45] | 4349 | function A=read_image(filename,type_ima,num,movieobject) |
---|
[12] | 4350 | %------------------------------------------------------------------------ |
---|
[2] | 4351 | %num is the view number needed for an avi movie |
---|
[45] | 4352 | switch type_ima |
---|
| 4353 | case 'movie' |
---|
| 4354 | A=read(movieobject,num); |
---|
| 4355 | case 'avi' |
---|
[112] | 4356 | mov=aviread(filename,num); |
---|
| 4357 | A=frame2im(mov(1)); |
---|
[45] | 4358 | case 'multimage' |
---|
| 4359 | A=imread(filename,num); |
---|
[112] | 4360 | case 'image' |
---|
[45] | 4361 | A=imread(filename); |
---|
| 4362 | end |
---|
| 4363 | siz=size(A); |
---|
| 4364 | if length(siz)==3;%color images |
---|
[2] | 4365 | A=sum(double(A),3); |
---|
| 4366 | A=uint16(A); |
---|
| 4367 | end |
---|
| 4368 | |
---|
[12] | 4369 | %------------------------------------------------------------------------ |
---|
[2] | 4370 | function ref_i_Callback(hObject, eventdata, handles) |
---|
[12] | 4371 | %------------------------------------------------------------------------ |
---|
[2] | 4372 | mode_list=get(handles.mode,'String'); |
---|
| 4373 | mode_value=get(handles.mode,'Value'); |
---|
| 4374 | mode=mode_list{mode_value}; |
---|
[45] | 4375 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
[12] | 4376 | if isequal(mode,'series(Di)') || ...% we do patch2 only |
---|
[112] | 4377 | (get(handles.CIV2,'Value')==0 && get(handles.CIV1,'Value')==0 && get(handles.FIX1,'Value')==0 && get(handles.PATCH1,'Value')==0) |
---|
[2] | 4378 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 4379 | end |
---|
| 4380 | |
---|
[12] | 4381 | %------------------------------------------------------------------------ |
---|
[2] | 4382 | function ref_j_Callback(hObject, eventdata, handles) |
---|
[12] | 4383 | %------------------------------------------------------------------------ |
---|
[2] | 4384 | mode_list=get(handles.mode,'String'); |
---|
| 4385 | mode_value=get(handles.mode,'Value'); |
---|
| 4386 | mode=mode_list{mode_value}; |
---|
[112] | 4387 | if isequal(get(handles.CIV1,'Value'),0)|| isequal(mode,'series(Dj)') |
---|
[2] | 4388 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
| 4389 | end |
---|
[45] | 4390 | if isequal(mode,'series(Dj)') || ... |
---|
[112] | 4391 | (get(handles.CIV2,'Value')==0 && get(handles.CIV1,'Value')==0 && get(handles.FIX1,'Value')==0 && get(handles.PATCH1,'Value')==0) |
---|
[2] | 4392 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 4393 | end |
---|
[12] | 4394 | |
---|
| 4395 | %------------------------------------------------------------------------ |
---|
[71] | 4396 | function ref_i_civ2_Callback(hObject, eventdata, handles) |
---|
| 4397 | %------------------------------------------------------------------------ |
---|
| 4398 | mode_list=get(handles.mode,'String'); |
---|
| 4399 | mode_value=get(handles.mode,'Value'); |
---|
| 4400 | mode=mode_list{mode_value}; |
---|
| 4401 | find_netcpair_civ2(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
| 4402 | |
---|
| 4403 | %------------------------------------------------------------------------ |
---|
| 4404 | function ref_j_civ2_Callback(hObject, eventdata, handles) |
---|
| 4405 | %------------------------------------------------------------------------ |
---|
| 4406 | mode_list=get(handles.mode,'String'); |
---|
| 4407 | mode_value=get(handles.mode,'Value'); |
---|
| 4408 | mode=mode_list{mode_value}; |
---|
[112] | 4409 | if isequal(mode,'series(Dj)') |
---|
[71] | 4410 | find_netcpair_civ2(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
| 4411 | end |
---|
| 4412 | |
---|
| 4413 | %------------------------------------------------------------------------ |
---|
[2] | 4414 | % --- Executes on button press in compare. |
---|
| 4415 | function compare_Callback(hObject, eventdata, handles) |
---|
[12] | 4416 | %------------------------------------------------------------------------ |
---|
[2] | 4417 | test=get(handles.compare,'Value'); |
---|
[112] | 4418 | if test==2 || test==3 |
---|
[71] | 4419 | filebase=get(handles.RootName,'String'); |
---|
[2] | 4420 | browse=get(handles.browse_root,'Userdata'); |
---|
| 4421 | browse.nom_type_ima1=browse.nom_type_ima; |
---|
| 4422 | set(handles.browse_root,'UserData',browse); |
---|
| 4423 | set(handles.sub_txt,'Visible','on') |
---|
[112] | 4424 | set(handles.RootName_1,'Visible','On');%mkes the second file input window visible |
---|
[2] | 4425 | mode_store=get(handles.mode,'String');%get the present 'mode' |
---|
[112] | 4426 | set(handles.compare,'UserData',mode_store);%store the mode display |
---|
[2] | 4427 | set(handles.mode,'Visible','off') |
---|
| 4428 | if test==2 |
---|
[112] | 4429 | set(handles.mode,'Visible','off') |
---|
[2] | 4430 | else |
---|
| 4431 | set(handles.mode,'Visible','on') |
---|
| 4432 | end |
---|
| 4433 | |
---|
[229] | 4434 | %% open an image file with the browser |
---|
[2] | 4435 | ind_opening=1;%default |
---|
| 4436 | browse.incr_pair=[0 0]; %default |
---|
[71] | 4437 | oldfile=get(handles.RootName,'String'); |
---|
[229] | 4438 | menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)'; |
---|
| 4439 | '*.xml', '.xml files '; ... |
---|
| 4440 | '*.civ', '.civ files '; ... |
---|
| 4441 | '*.png','.png image files'; ... |
---|
| 4442 | '*.jpg',' jpeg image files'; ... |
---|
| 4443 | '*.tif','.tif image files'; ... |
---|
| 4444 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 4445 | '*.nc','.netcdf files'; ... |
---|
| 4446 | '*.*', 'All Files (*.*)'}; |
---|
| 4447 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file of the second series',oldfile); |
---|
[112] | 4448 | fileinput=[PathName FileName];%complete file name |
---|
[2] | 4449 | sizf=size(fileinput); |
---|
[229] | 4450 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
[2] | 4451 | [path,name,ext]=fileparts(fileinput); |
---|
| 4452 | [path1]=fileparts(filebase); |
---|
[229] | 4453 | % if isunix |
---|
| 4454 | % ['readlink ' path] |
---|
| 4455 | % [status,path]=system(['readlink ' path]) |
---|
| 4456 | % [status,path1]=system(['readlink ' path1])% look for the true path in case of symbolic paths |
---|
| 4457 | % end |
---|
[2] | 4458 | if ~strcmp(path1,path) |
---|
[112] | 4459 | msgbox_uvmat('ERROR','The two input image series must be in the same directory') |
---|
[2] | 4460 | return |
---|
| 4461 | end |
---|
[71] | 4462 | set(handles.RootName_1,'String',name); |
---|
[2] | 4463 | [RootPath,RootFile,field_count,str2,str_a,str_b,xx,nom_type,subdir]=name2display(name); |
---|
| 4464 | browse=get(handles.browse_root,'UserData'); |
---|
| 4465 | browse.nom_type_ima_1=nom_type; |
---|
[112] | 4466 | set(handles.browse_root,'UserData',browse) |
---|
[2] | 4467 | |
---|
| 4468 | %check image extension |
---|
[71] | 4469 | if ~strcmp(ext,get(handles.ImaExt,'String')) |
---|
[229] | 4470 | msgbox_uvmat('ERROR','The two input image series must have the same extension name') |
---|
[2] | 4471 | return |
---|
| 4472 | end |
---|
| 4473 | |
---|
[229] | 4474 | %% check coincidence of image sizes |
---|
| 4475 | ref_i=get(handles.ref_i,'string'); |
---|
| 4476 | ref_j=get(handles.ref_j,'string'); |
---|
| 4477 | [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc]=set_civ_filenames(handles,ref_i,ref_j,[1 0 0 0 0 0]); |
---|
| 4478 | A=imread(filecell.ima1.civ1{1}); |
---|
| 4479 | A_1=imread(fileinput); |
---|
| 4480 | npxy=size(A); |
---|
| 4481 | npxy_1=size(A_1); |
---|
| 4482 | if ~isequal(size(A),size(A_1)) |
---|
| 4483 | msgbox_uvmat('ERROR','The two input image series do not have the same size') |
---|
[2] | 4484 | return |
---|
| 4485 | end |
---|
| 4486 | else |
---|
| 4487 | set(handles.mode,'Visible','on') |
---|
[71] | 4488 | set(handles.RootName_1,'Visible','Off'); |
---|
[2] | 4489 | set(handles.sub_txt,'Visible','off') |
---|
[71] | 4490 | set(handles.RootName_1,'String',[]); |
---|
[2] | 4491 | mode_store=get(handles.compare,'UserData'); |
---|
[177] | 4492 | set(handles.mode,'Value',1) |
---|
[2] | 4493 | set(handles.mode,'String',mode_store) |
---|
| 4494 | set(handles.test_stereo1,'Value',0) |
---|
| 4495 | set(handles.test_stereo2,'Value',0) |
---|
| 4496 | end |
---|
| 4497 | mode_Callback(hObject, eventdata, handles) |
---|
| 4498 | |
---|
[12] | 4499 | %------------------------------------------------------------------------ |
---|
[2] | 4500 | % --- Executes on button press in get_ref_fix1. |
---|
| 4501 | function get_ref_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 4502 | %------------------------------------------------------------------------ |
---|
[71] | 4503 | filebase=get(handles.RootName,'String'); |
---|
[2] | 4504 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 4505 | {'*.nc', ' (*.nc)'; |
---|
| 4506 | '*.nc', 'netcdf files '; ... |
---|
| 4507 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4508 | 'Pick a file',filebase); |
---|
| 4509 | |
---|
[2] | 4510 | fileinput=[PathName FileName]; |
---|
| 4511 | sizf=size(fileinput); |
---|
[122] | 4512 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
[2] | 4513 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 4514 | ref.filebase=fullfile(Path,File); |
---|
| 4515 | ref.num_a=stra2num(str_a); |
---|
| 4516 | ref.num_b=stra2num(str_b); |
---|
[89] | 4517 | ref.num1=str2double(field_count); |
---|
| 4518 | ref.num2=str2double(str2); |
---|
[2] | 4519 | browse=[];%initialisation |
---|
| 4520 | if ~isequal(ref.ext,'.nc') |
---|
| 4521 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
| 4522 | return |
---|
| 4523 | end |
---|
| 4524 | set(handles.ref_fix1,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
| 4525 | set(handles.ref_fix1,'UserData',ref) |
---|
| 4526 | menu_field{1}='civ1'; |
---|
| 4527 | Data=nc2struct(fileinput,[]); |
---|
[45] | 4528 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
[2] | 4529 | menu_field{2}='filter1'; |
---|
| 4530 | end |
---|
[45] | 4531 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
[2] | 4532 | menu_field{3}='civ2'; |
---|
| 4533 | end |
---|
[45] | 4534 | if isfield(Data,'patch2') && isequal(Data.patch2,1) |
---|
[2] | 4535 | menu_field{4}='filter2'; |
---|
| 4536 | end |
---|
| 4537 | set(handles.field_ref1,'String',menu_field); |
---|
| 4538 | set(handles.field_ref1,'Value',length(menu_field)); |
---|
| 4539 | set(handles.inf_sup1,'Value',2); |
---|
| 4540 | set(handles.thresh_vel,'String','1');%default threshold |
---|
| 4541 | set(handles.ref_fix1,'Enable','on') |
---|
[12] | 4542 | |
---|
| 4543 | %------------------------------------------------------------------------ |
---|
[2] | 4544 | % --- Executes on button press in get_ref_fix2. |
---|
| 4545 | function get_ref_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 4546 | %------------------------------------------------------------------------ |
---|
[2] | 4547 | if isequal(get(handles.get_ref_fix2,'Value'),1) |
---|
[71] | 4548 | filebase=get(handles.RootName,'String'); |
---|
[2] | 4549 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 4550 | {'*.nc', ' (*.nc)'; |
---|
| 4551 | '*.nc', 'netcdf files '; ... |
---|
| 4552 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4553 | 'Pick a file',filebase); |
---|
[2] | 4554 | fileinput=[PathName FileName]; |
---|
| 4555 | sizf=size(fileinput); |
---|
[45] | 4556 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
[2] | 4557 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 4558 | ref.filebase=fullfile(Path,File); |
---|
| 4559 | ref.num_a=stra2num(str_a); |
---|
| 4560 | ref.num_b=stra2num(str_b); |
---|
| 4561 | ref.num1=str2num(field_count); |
---|
| 4562 | ref.num2=str2num(str2); |
---|
| 4563 | browse=[];%initialisation |
---|
| 4564 | if ~isequal(ref.ext,'.nc') |
---|
| 4565 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
| 4566 | return |
---|
| 4567 | end |
---|
| 4568 | set(handles.ref_fix2,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
[112] | 4569 | set(handles.ref_fix2,'UserData',ref) |
---|
[2] | 4570 | menu_field{1}='civ1'; |
---|
| 4571 | Data=nc2struct(fileinput,[]); |
---|
| 4572 | if isfield(Data,'patch') & isequal(Data.patch,1) |
---|
| 4573 | menu_field{2}='filter1'; |
---|
| 4574 | end |
---|
| 4575 | if isfield(Data,'civ2') & isequal(Data.civ2,1) |
---|
| 4576 | menu_field{3}='civ2'; |
---|
| 4577 | end |
---|
| 4578 | if isfield(Data,'patch2') & isequal(Data.patch2,1) |
---|
| 4579 | menu_field{4}='filter2'; |
---|
| 4580 | end |
---|
| 4581 | set(handles.field_ref2,'String',menu_field); |
---|
| 4582 | set(handles.field_ref2,'Value',length(menu_field)); |
---|
| 4583 | set(handles.inf_sup2,'Value',2); |
---|
| 4584 | set(handles.thresh_vel2,'String','1');%default threshold |
---|
| 4585 | set(handles.ref_fix2,'Enable','on') |
---|
| 4586 | set(handles.ref_fix2,'Visible','on') |
---|
| 4587 | set(handles.field_ref2,'Visible','on') |
---|
| 4588 | else |
---|
| 4589 | set(handles.ref_fix2,'Visible','off') |
---|
| 4590 | set(handles.field_ref2,'Visible','off') |
---|
| 4591 | end |
---|
| 4592 | |
---|
[12] | 4593 | %------------------------------------------------------------------------ |
---|
[2] | 4594 | function ref_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 4595 | %------------------------------------------------------------------------ |
---|
| 4596 | set(handles.inf_sup1,'Value',1); |
---|
| 4597 | set(handles.field_ref1,'Value',1) |
---|
| 4598 | set(handles.field_ref1,'String',{' '}) |
---|
| 4599 | set(handles.ref_fix1,'UserData',[]); |
---|
| 4600 | set(handles.ref_fix1,'String',''); |
---|
| 4601 | set(handles.thresh_vel1,'String','0'); |
---|
[112] | 4602 | |
---|
[12] | 4603 | %------------------------------------------------------------------------ |
---|
[2] | 4604 | function ref_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 4605 | %------------------------------------------------------------------------ |
---|
| 4606 | set(handles.inf_sup2,'Value',1); |
---|
| 4607 | set(handles.field_ref2,'Value',1) |
---|
| 4608 | set(handles.field_ref2,'String',{' '}) |
---|
| 4609 | set(handles.ref_fix2,'UserData',[]); |
---|
| 4610 | set(handles.ref_fix2,'String',''); |
---|
| 4611 | set(handles.thresh_vel2,'String','0'); |
---|
[2] | 4612 | |
---|
[12] | 4613 | %------------------------------------------------------------------------ |
---|
[2] | 4614 | % --- Executes on button press in test_stereo1. |
---|
| 4615 | function test_stereo1_Callback(hObject, eventdata, handles) |
---|
[12] | 4616 | %------------------------------------------------------------------------ |
---|
[2] | 4617 | if isequal(get(handles.test_stereo1,'Value'),0) |
---|
| 4618 | set(handles.subdomain_patch1,'Visible','on') |
---|
| 4619 | set(handles.rho_patch1,'Visible','on') |
---|
| 4620 | else |
---|
| 4621 | set(handles.subdomain_patch1,'Visible','off') |
---|
| 4622 | set(handles.rho_patch1,'Visible','off') |
---|
| 4623 | end |
---|
| 4624 | |
---|
[12] | 4625 | %------------------------------------------------------------------------ |
---|
[2] | 4626 | % --- Executes on button press in test_stereo2. |
---|
| 4627 | function test_stereo2_Callback(hObject, eventdata, handles) |
---|
[12] | 4628 | %------------------------------------------------------------------------ |
---|
[2] | 4629 | if isequal(get(handles.test_stereo2,'Value'),0) |
---|
| 4630 | set(handles.subdomain_patch2,'Visible','on') |
---|
| 4631 | set(handles.rho_patch2,'Visible','on') |
---|
| 4632 | else |
---|
| 4633 | set(handles.subdomain_patch2,'Visible','off') |
---|
| 4634 | set(handles.rho_patch2,'Visible','off') |
---|
| 4635 | end |
---|
| 4636 | |
---|
[12] | 4637 | %------------------------------------------------------------------------ |
---|
[2] | 4638 | % --- Executes on button press in ImaThreshold. |
---|
| 4639 | function ImaThreshold_Callback(hObject, eventdata, handles) |
---|
[12] | 4640 | %------------------------------------------------------------------------ |
---|
[2] | 4641 | if isequal(get(handles.ImaThreshold,'Value'),1) |
---|
| 4642 | set(handles.MinIma,'Visible','on') |
---|
| 4643 | set(handles.MaxIma,'Visible','on') |
---|
| 4644 | else |
---|
| 4645 | set(handles.MinIma,'Visible','off') |
---|
| 4646 | set(handles.MaxIma,'Visible','off') |
---|
| 4647 | end |
---|
| 4648 | |
---|
[12] | 4649 | %------------------------------------------------------------------------ |
---|
[2] | 4650 | % --- Executes on button press in ImaThreshold2. |
---|
| 4651 | function ImaThreshold2_Callback(hObject, eventdata, handles) |
---|
[12] | 4652 | %------------------------------------------------------------------------ |
---|
[2] | 4653 | if isequal(get(handles.ImaThreshold2,'Value'),1) |
---|
| 4654 | set(handles.MinIma2,'Visible','on') |
---|
| 4655 | set(handles.MaxIma2,'Visible','on') |
---|
| 4656 | else |
---|
| 4657 | set(handles.MinIma2,'Visible','off') |
---|
| 4658 | set(handles.MaxIma2,'Visible','off') |
---|
| 4659 | end |
---|
| 4660 | |
---|
[224] | 4661 | %------------------------------------------------------------------------ |
---|
[225] | 4662 | % --- Executes on button press in TestCiv1: display image correlation function |
---|
[150] | 4663 | function TestCiv1_Callback(hObject, eventdata, handles) |
---|
[224] | 4664 | %------------------------------------------------------------------------ |
---|
[150] | 4665 | test_civ1=get(handles.TestCiv1,'Value'); |
---|
| 4666 | if test_civ1 |
---|
[227] | 4667 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
| 4668 | if strcmp(get(handles.ref_j,'Visible'),'on') |
---|
| 4669 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
| 4670 | else |
---|
| 4671 | ref_j=1;%default |
---|
| 4672 | end |
---|
[224] | 4673 | [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] | 4674 | set_civ_filenames(handles,ref_i,ref_j,[1 0 0 0 0 0]); |
---|
[224] | 4675 | Data.ListVarName={'ny','nx','A'}; |
---|
| 4676 | Data.VarDimName={'ny','nx',{'ny','nx'}}; |
---|
| 4677 | Data.A=imread(filecell.ima1.civ1{1}); |
---|
| 4678 | Data.ny=[size(Data.A,1) 1]; |
---|
| 4679 | Data.nx=[1 size(Data.A,2)]; |
---|
[227] | 4680 | par_civ1=read_param_civ1(handles,filecell.ima1.civ1{1}); |
---|
[231] | 4681 | par_civ1.filename_ima_a=filecell.ima1.civ1{1}; |
---|
| 4682 | par_civ1.filename_ima_b=filecell.ima2.civ1{1}; |
---|
| 4683 | par_civ1.T0=0; |
---|
| 4684 | par_civ1.Dt=1; |
---|
| 4685 | Data=civ_uvmat(par_civ1); |
---|
| 4686 | % stepx=str2num(par_civ1.dx); |
---|
| 4687 | % stepy=str2num(par_civ1.dy); |
---|
| 4688 | % ibx2=ceil(str2num(par_civ1.ibx)/2); |
---|
| 4689 | % iby2=ceil(str2num(par_civ1.iby)/2); |
---|
| 4690 | % isx2=ceil(str2num(par_civ1.isx)/2); |
---|
| 4691 | % isy2=ceil(str2num(par_civ1.isy)/2); |
---|
| 4692 | % shiftx=str2num(par_civ1.shiftx); |
---|
| 4693 | % shifty=str2num(par_civ1.shifty); |
---|
| 4694 | % % ibx=2*ibx2-1;%ibx and iby odd, reduced by 1 if even |
---|
| 4695 | % % iby=2*iby2-1; |
---|
| 4696 | % miniy=max(1+isy2-shifty,1+iby2) |
---|
| 4697 | % minix=max(1+isx2-shiftx,1+ibx2) |
---|
| 4698 | % maxiy=min(size(Data.A,1)-isy2-shifty,size(Data.A,1)-iby2) |
---|
| 4699 | % maxix=min(size(Data.A,2)-isx2-shiftx,size(Data.A,2)-ibx2) |
---|
| 4700 | % % maxix=stepx*(floor(size(image1_roi,2)/stepx))-(2*ibx2-2)+ibx2; |
---|
| 4701 | % [GridX,GridY]=meshgrid(minix:stepx:maxix,miniy:stepy:maxiy); |
---|
| 4702 | % PointCoord(:,1)=reshape(GridX,[],1); |
---|
| 4703 | % PointCoord(:,2)=reshape(GridY,[],1); |
---|
| 4704 | Data.ListVarName=[Data.ListVarName {'ny','nx','A'}]; |
---|
| 4705 | Data.VarDimName=[Data.VarDimName {'ny','nx',{'ny','nx'}}]; |
---|
| 4706 | Data.A=imread(filecell.ima1.civ1{1}); |
---|
| 4707 | Data.ny=[size(Data.A,1) 1]; |
---|
| 4708 | Data.nx=[1 size(Data.A,2)]; |
---|
| 4709 | hview_field=view_field(Data); |
---|
| 4710 | set(0,'CurrentFigure',hview_field) |
---|
| 4711 | hhview_field=guihandles(hview_field); |
---|
| 4712 | set(hview_field,'CurrentAxes',hhview_field.axes3) |
---|
| 4713 | %hpoints=line(PointCoord(:,1),PointCoord(:,2),'Color','y','LineStyle','.','Marker','*','LineWidth',4,'Tag','grid_points'); |
---|
| 4714 | ViewData=get(hview_field,'UserData'); |
---|
| 4715 | ViewData.CivHandle=handles.civ;% indicate the handle of the civ GUI in view_field |
---|
[224] | 4716 | ViewData.axes3.B=imread(filecell.ima2.civ1{1});%store the second image in the UserData of the GUI view_field |
---|
[231] | 4717 | ViewData.axes3.X=Data.X; %keep the set of points in memeory |
---|
| 4718 | ViewData.axes3.Y=Data.Y; |
---|
| 4719 | set(hview_field,'UserData',ViewData) |
---|
[224] | 4720 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
| 4721 | if isempty(corrfig) |
---|
| 4722 | corrfig=figure; |
---|
| 4723 | set(corrfig,'tag','corrfig') |
---|
| 4724 | set(corrfig,'name','image correlation') |
---|
| 4725 | set(corrfig,'DeleteFcn',{@closeview_field})% |
---|
| 4726 | end |
---|
| 4727 | else |
---|
| 4728 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
| 4729 | if ~isempty(corrfig) |
---|
| 4730 | delete(corrfig) |
---|
| 4731 | end |
---|
| 4732 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
| 4733 | if ~isempty(hview_field) |
---|
| 4734 | delete(hview_field) |
---|
| 4735 | end |
---|
[150] | 4736 | end |
---|
[71] | 4737 | |
---|
[224] | 4738 | function closeview_field(gcbo,eventdata) |
---|
| 4739 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
| 4740 | if ~isempty(hview_field) |
---|
| 4741 | delete(hview_field) |
---|
| 4742 | end |
---|
[177] | 4743 | %------------------------------------------------------------------- |
---|
| 4744 | % --- Executes on button press in status. |
---|
| 4745 | function status_Callback(hObject, eventdata, handles) |
---|
| 4746 | %------------------------------------------------------------------- |
---|
| 4747 | val=get(handles.status,'Value'); |
---|
| 4748 | if val==0 |
---|
| 4749 | hfig=findobj(allchild(0),'name','civ_status'); |
---|
| 4750 | if ~isempty(hfig) |
---|
| 4751 | delete(hfig) |
---|
| 4752 | end |
---|
| 4753 | return |
---|
| 4754 | end |
---|
| 4755 | listtype={'civ1','fix1','patch1','civ2','fix2','patch2'}; |
---|
| 4756 | box_test(1)=get(handles.CIV1,'Value'); |
---|
| 4757 | box_test(2)=get(handles.FIX1,'Value'); |
---|
| 4758 | box_test(3)=get(handles.PATCH1,'Value'); |
---|
| 4759 | box_test(4)=get(handles.CIV2,'Value'); |
---|
| 4760 | box_test(5)=get(handles.FIX2,'Value'); |
---|
[180] | 4761 | box_test(6)=get(handles.PATCH2,'Value'); |
---|
| 4762 | option_civ=find(box_test,1,'last');%last selected option (non-zero index of box_test) |
---|
[177] | 4763 | filecell=get(handles.civ,'UserData'); |
---|
| 4764 | if ~isfield(filecell,'nc') |
---|
[227] | 4765 | [ref_i,ref_j,errormsg]=find_ref_indices(handles); |
---|
| 4766 | if ~isempty(errormsg) |
---|
| 4767 | msgbox_uvmat('ERROR',errormsg) |
---|
| 4768 | return |
---|
| 4769 | end |
---|
| 4770 | filecell=set_civ_filenames(handles,ref_i,ref_j,box_test);%determine the list of output files expected from the GUI status |
---|
[177] | 4771 | end |
---|
[71] | 4772 | |
---|
[177] | 4773 | if ~isequal(box_test(4:6),[0 0 0]) |
---|
| 4774 | civ_files=filecell.nc.civ2; |
---|
| 4775 | else |
---|
| 4776 | civ_files=filecell.nc.civ1; |
---|
| 4777 | end |
---|
| 4778 | [root,filename,ext]=fileparts(civ_files{1}); |
---|
| 4779 | [rootroot,subdir,extdir]=fileparts(root); |
---|
| 4780 | hfig=findobj(allchild(0),'name','civ_status'); |
---|
| 4781 | if isempty(hfig) |
---|
| 4782 | hfig=figure; |
---|
| 4783 | set(hfig,'name','civ_status') |
---|
[182] | 4784 | hlist=uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', @open_view_field,'tag','list'); |
---|
[177] | 4785 | uicontrol('Style','listbox','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','msgbox'); |
---|
| 4786 | uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]); |
---|
[182] | 4787 | uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'String','OK','FontWeight','bold','FontUnits','normalized','FontSize',0.9,'Callback',@close_GUI); |
---|
[177] | 4788 | BarPosition=[0.05 0.81 0.01 0.05]; |
---|
| 4789 | hwaitbar=uicontrol('Style','frame','Units','normalized', 'Position',BarPosition ,'BackgroundColor',[1 0 0],'tag','waitbar'); |
---|
| 4790 | end |
---|
[188] | 4791 | % datnum=[]; |
---|
[177] | 4792 | Tabchar={}; |
---|
| 4793 | nbfiles=numel(civ_files); |
---|
| 4794 | count=0; |
---|
[188] | 4795 | testrecent=0; |
---|
[177] | 4796 | while count<nbfiles |
---|
| 4797 | count=0; |
---|
[188] | 4798 | datnum=zeros(1,nbfiles); |
---|
[177] | 4799 | for ifile=1:nbfiles |
---|
| 4800 | detect=exist(civ_files{ifile},'file'); % check the existence of the file |
---|
[179] | 4801 | option=0; |
---|
[177] | 4802 | if detect==0 |
---|
[179] | 4803 | option_str='not created'; |
---|
[177] | 4804 | else |
---|
[219] | 4805 | datfile=dir(civ_files{ifile}); |
---|
[188] | 4806 | if isfield(datfile,'datenum') |
---|
| 4807 | datnum(ifile)=datfile.datenum;%only available in recent matlab versions |
---|
| 4808 | testrecent=1; |
---|
| 4809 | end |
---|
[177] | 4810 | filefound(ifile)={datfile.name}; |
---|
| 4811 | lastfield=''; |
---|
| 4812 | % check the content netcdf file |
---|
| 4813 | Data=nc2struct(civ_files{ifile},'ListGlobalAttribute','patch2','fix2','civ2','patch','fix'); |
---|
| 4814 | if ~isempty(Data.patch2) && isequal(Data.patch2,1) |
---|
[179] | 4815 | option=6; |
---|
| 4816 | option_str='patch2'; |
---|
[177] | 4817 | elseif ~isempty(Data.fix2) && isequal(Data.fix2,1) |
---|
[179] | 4818 | option=5; |
---|
| 4819 | option_str='fix2'; |
---|
[177] | 4820 | elseif ~isempty(Data.civ2) && isequal(Data.civ2,1); |
---|
[179] | 4821 | option=4; |
---|
| 4822 | option_str='civ2'; |
---|
[177] | 4823 | elseif ~isempty(Data.patch) && isequal(Data.patch,1); |
---|
[179] | 4824 | option=3; |
---|
| 4825 | option_str='patch1'; |
---|
[177] | 4826 | elseif ~isempty(Data.fix) && isequal(Data.fix,1); |
---|
[179] | 4827 | option=2; |
---|
| 4828 | option_str='fix1'; |
---|
[177] | 4829 | else |
---|
[179] | 4830 | option=1; |
---|
| 4831 | option_str='civ1'; |
---|
[177] | 4832 | end |
---|
| 4833 | end |
---|
[179] | 4834 | if option >= option_civ |
---|
[177] | 4835 | count=count+1; |
---|
| 4836 | end |
---|
| 4837 | [rr,filename,ext]=fileparts(civ_files{ifile}); |
---|
[179] | 4838 | Tabchar{ifile,1}=[fullfile([subdir extdir],filename) ext '...' option_str]; |
---|
[177] | 4839 | end |
---|
[219] | 4840 | datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files |
---|
[188] | 4841 | if isempty(datnum) |
---|
| 4842 | if testrecent |
---|
| 4843 | message='no civ result created yet'; |
---|
| 4844 | else |
---|
| 4845 | message=''; |
---|
| 4846 | end |
---|
[177] | 4847 | else |
---|
[219] | 4848 | datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files |
---|
[177] | 4849 | [first,ind]=min(datnum); |
---|
| 4850 | [last,indlast]=max(datnum); |
---|
| 4851 | message={[num2str(count) ' file(s) done over ' num2str(nbfiles)] ;['oldest modification: ' cell2mat(filefound(ind)) ' : ' datestr(first)];... |
---|
| 4852 | ['latest modification: ' cell2mat(filefound(indlast)) ' : ' datestr(last)]}; |
---|
| 4853 | end |
---|
| 4854 | hfig=findobj(allchild(0),'name','civ_status'); |
---|
| 4855 | if isempty(hfig) |
---|
| 4856 | set(handles.status,'Value',0)%stop program if the figure has been suppressed |
---|
| 4857 | return |
---|
| 4858 | else |
---|
| 4859 | hlist=findobj(hfig,'tag','list'); |
---|
| 4860 | hmsgbox=findobj(hfig,'tag','msgbox'); |
---|
| 4861 | hwaitbar=findobj(hfig,'tag','waitbar'); |
---|
| 4862 | set(hlist,'String',Tabchar) |
---|
| 4863 | set(hmsgbox,'String', message) |
---|
| 4864 | if count>0 |
---|
| 4865 | BarPosition(3)=0.9*count/nbfiles; |
---|
| 4866 | set(hwaitbar,'Position',BarPosition) |
---|
| 4867 | end |
---|
| 4868 | end |
---|
| 4869 | set(hlist,'UserData',rootroot) |
---|
| 4870 | pause(5)% wait 5 seconds for next check |
---|
| 4871 | end |
---|
[150] | 4872 | |
---|
[177] | 4873 | |
---|
| 4874 | %------------------------------------------------------------------- |
---|
| 4875 | % call 'view_field.fig' to display the selected field |
---|
| 4876 | function open_view_field(hObject, eventdata) |
---|
| 4877 | %------------------------------------------------------------------- |
---|
| 4878 | list=get(gcbo,'String'); |
---|
| 4879 | index=get(gcbo,'Value'); |
---|
| 4880 | rootroot=get(gcbo,'UserData'); |
---|
| 4881 | filename=list{index}; |
---|
| 4882 | ind_dot=findstr(filename,'...'); |
---|
| 4883 | filename=filename(1:ind_dot-1); |
---|
[188] | 4884 | filename=fullfile(rootroot,filename); |
---|
[177] | 4885 | if exist(filename,'file')%visualise the vel field if it exists |
---|
[178] | 4886 | %[Field,VelTypeOut]=read_civxdata(filename); |
---|
| 4887 | %view_field(Field) |
---|
| 4888 | uvmat(filename) |
---|
| 4889 | set(gcbo,'Value',1) |
---|
[177] | 4890 | end |
---|
[150] | 4891 | |
---|
[182] | 4892 | %------------------------------------------------------------------- |
---|
| 4893 | % call 'view_field.fig' to display the selected field |
---|
| 4894 | function close_GUI(hObject, eventdata) |
---|
| 4895 | %------------------------------------------------------------------- |
---|
[220] | 4896 | delete(gcbf) |
---|
| 4897 | |
---|
| 4898 | |
---|
| 4899 | % --- Executes on button press in CivAll. |
---|
| 4900 | function CivAll_Callback(hObject, eventdata, handles) |
---|
[225] | 4901 | if get(handles.CivAll,'Value')==2 |
---|
[224] | 4902 | if get(handles.PATCH1,'Value') |
---|
| 4903 | set(handles.thresh_patch1,'Visible','on') |
---|
| 4904 | set(handles.thresh_text1,'Visible','on') |
---|
| 4905 | end |
---|
| 4906 | else |
---|
| 4907 | set(handles.thresh_patch1,'Visible','off') |
---|
| 4908 | set(handles.thresh_text1,'Visible','off') |
---|
| 4909 | end |
---|
[220] | 4910 | |
---|