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