[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 |
---|
[282] | 8 | % Copyright Joel Sommeria, 2011, LEGI / CNRS-UJF-INPG, sommeria@legi.grenoble-inp.fr |
---|
[2] | 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) |
---|
[273] | 23 | %TODO: search range |
---|
[2] | 24 | |
---|
[292] | 25 | % Last Modified by GUIDE v2.5 21-Nov-2011 10:58:28 |
---|
[2] | 26 | % Begin initialization code - DO NOT EDIT |
---|
| 27 | gui_Singleton = 1; |
---|
| 28 | gui_State = struct('gui_Name', mfilename, ... |
---|
[112] | 29 | 'gui_Singleton', gui_Singleton, ... |
---|
| 30 | 'gui_OpeningFcn', @civ_OpeningFcn, ... |
---|
| 31 | 'gui_OutputFcn', @civ_OutputFcn, ... |
---|
| 32 | 'gui_LayoutFcn', [] , ... |
---|
| 33 | 'gui_Callback', []); |
---|
[2] | 34 | if nargin && ischar(varargin{1}) |
---|
| 35 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
| 36 | end |
---|
| 37 | |
---|
| 38 | if nargout |
---|
| 39 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
| 40 | else |
---|
| 41 | gui_mainfcn(gui_State, varargin{:}); |
---|
| 42 | end |
---|
| 43 | % End initialization code - DO NOT EDIT |
---|
| 44 | |
---|
[12] | 45 | %------------------------------------------------------------------------ |
---|
[2] | 46 | % --- Executes just before civ is made visible. |
---|
[71] | 47 | function civ_OpeningFcn(hObject, eventdata, handles, param) |
---|
[12] | 48 | %------------------------------------------------------------------------ |
---|
[2] | 49 | % This function has no output args, see OutputFcn. |
---|
[112] | 50 | %filebase: root name |
---|
[2] | 51 | %nom_type: nomencalture used ('png_old','_i_j'...) |
---|
| 52 | %list of field numbers to process |
---|
[112] | 53 | %subdir: subdirectory of the opened netcdf file |
---|
[282] | 54 | %ind_opening: operation number advised for beginning (1=checkciv1,2=checkfix1,3=checkpatch1,4=checkciv2,5=checkfix2,6=checkpatch2), |
---|
[2] | 55 | %ind_a_opening ind_b_opening chosen pair from the opened netcdf file |
---|
| 56 | % Choose default command line output for civ |
---|
| 57 | handles.output = hObject; |
---|
| 58 | % Update handles structure |
---|
| 59 | guidata(hObject, handles); |
---|
[252] | 60 | set(hObject,'WindowButtonDownFcn',{'mouse_alt_gui',handles}) % allows mouse action with right button (zoom for uicontrol display) |
---|
[2] | 61 | %default initial parameters |
---|
| 62 | filebase=''; % root file name ('filebase'.civ) |
---|
| 63 | ext=[]; |
---|
[252] | 64 | |
---|
[273] | 65 | %% read names of the .exe file to adjust the interface according to available binaries |
---|
[276] | 66 | %path_uvmat=which('uvmat');% check the path detected for source file uvmat |
---|
| 67 | path_civ=fileparts(which('civ')); %path to civ |
---|
| 68 | addpath (path_civ) ; %add the path to UVMAT, (useful in case of change of working directory after civ has been s opened in the working directory) |
---|
[273] | 69 | errormsg=[];%default error message |
---|
| 70 | xmlfile='PARAM.xml'; |
---|
| 71 | if exist(xmlfile,'file') |
---|
| 72 | try |
---|
| 73 | t=xmltree(xmlfile); |
---|
| 74 | sparam=convert(t); |
---|
| 75 | catch |
---|
| 76 | errormsg={' Unable to read the file PARAM.xml defining the civx binaries:'; lasterr}; |
---|
| 77 | return |
---|
| 78 | end |
---|
| 79 | else |
---|
| 80 | errormsg=[xmlfile ' not found: path to civx binaries undefined']; |
---|
| 81 | return |
---|
| 82 | end |
---|
| 83 | if ~isempty(errormsg) |
---|
| 84 | msgbox_uvmat('ERROR',errormsg); |
---|
| 85 | end |
---|
| 86 | |
---|
| 87 | test_batch=0;%default: ,no batch mode available |
---|
| 88 | if isfield(sparam,'BatchParam') && isfield(sparam.BatchParam,'BatchMode') |
---|
| 89 | test_batch=strcmp(sparam.BatchParam.BatchMode,'sge'); %sge is currently the only implemented batch mod |
---|
| 90 | end |
---|
| 91 | if test_batch==0 |
---|
| 92 | set(handles.BATCH,'Enable','off')% put the BATCH button in grey (unactivated) |
---|
| 93 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784])% put the BATCH button in grey (unactivated) |
---|
| 94 | end |
---|
| 95 | if isfield(sparam.RunParam,'CivBin') |
---|
| 96 | if ~exist(sparam.RunParam.CivBin,'file') |
---|
[276] | 97 | sparam.RunParam.CivBin=fullfile(path_civ,sparam.RunParam.CivBin); |
---|
[273] | 98 | end |
---|
| 99 | else |
---|
| 100 | sparam.RunParam.CivBin=''; |
---|
| 101 | end |
---|
| 102 | |
---|
| 103 | %% load the list of previously browsed files in menu Open |
---|
| 104 | dir_perso=prefdir; % path to the directory .matlab for personal data |
---|
| 105 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% personal data file uvmauvmat_perso.mat' in .matlab |
---|
| 106 | if exist(profil_perso,'file') |
---|
| 107 | h=load (profil_perso); |
---|
| 108 | if isfield(h,'MenuFile') |
---|
| 109 | set(handles.MenuFile_1,'Label',h.MenuFile{1}) |
---|
| 110 | %set(handles.MenuFile_1,'Label',h.MenuFile_1); |
---|
| 111 | end |
---|
| 112 | % if isfield(h,'MenuFile_2') |
---|
| 113 | % set(handles.MenuFile_2,'Label',h.MenuFile_2); |
---|
| 114 | % end |
---|
| 115 | % if isfield(h,'MenuFile_3') |
---|
| 116 | % set(handles.MenuFile_3,'Label',h.MenuFile_3); |
---|
| 117 | % end |
---|
| 118 | % if isfield(h,'MenuFile_4') |
---|
| 119 | % set(handles.MenuFile_4,'Label',h.MenuFile_4); |
---|
| 120 | % end |
---|
| 121 | % if isfield(h,'MenuFile_5') |
---|
| 122 | % set(handles.MenuFile_5,'Label',h.MenuFile_5); |
---|
| 123 | % end |
---|
| 124 | end |
---|
| 125 | |
---|
[71] | 126 | %default input parameters: |
---|
[153] | 127 | num_i1=1; % set of field i numbers |
---|
| 128 | num_i2=1; % set of field i numbers |
---|
| 129 | num_j1=1; % set of field j numbers (fields a) |
---|
| 130 | num_j2=1; % second set of field j numbers (fields b) |
---|
[273] | 131 | %subdir='A'; % subdir for the netcdf result files |
---|
| 132 | ind_opening=0; % proposed operation number (1=civ1,2=fix1,3=patch1,4=civ2,5=fix2,6=patch2) |
---|
[112] | 133 | %load the initial parameters if the interface is started from uvmat |
---|
[71] | 134 | if exist('param','var')&&isstruct(param)% the interface is opened from uvmat |
---|
| 135 | filebase=param.RootName; |
---|
| 136 | nom_type_read=param.NomType; |
---|
[153] | 137 | num_i1=param.num1; |
---|
| 138 | if isnan(num_i1),num_i1=1;end |
---|
| 139 | num_i2=param.num2; |
---|
| 140 | if isnan(num_i2),num_i2=num_i1;end |
---|
| 141 | num_j1=param.num_a; |
---|
| 142 | if isnan(num_j1),num_j1=1;end |
---|
| 143 | num_j2=param.num_b; |
---|
| 144 | if isnan(num_j2),num_j2=num_j1;end |
---|
[71] | 145 | subdir=param.SubDir; |
---|
| 146 | ind_opening=param.IndOpening; |
---|
| 147 | ext=param.ImaExt; |
---|
[2] | 148 | end |
---|
[153] | 149 | browse.num_i1=num_i1; |
---|
| 150 | browse.num_i2=num_i2; |
---|
| 151 | browse.num_j1=num_j1; |
---|
| 152 | browse.num_j2=num_j2; |
---|
[122] | 153 | if ~isempty(ext) && (~isempty(imformats(ext(2:end)))||strcmpi(ext,'.avi'));%if an image file has been opened by uvmat |
---|
[112] | 154 | set(handles.ImaExt,'String',ext) |
---|
[128] | 155 | browse.ext_ima=ext; |
---|
[112] | 156 | if exist('nom_type_read','var') |
---|
| 157 | browse.nom_type_ima=nom_type_read; % the image nomenclature is stored |
---|
| 158 | end |
---|
[2] | 159 | elseif isequal(ext,'.nc') |
---|
| 160 | if exist('nom_type_read','var') |
---|
| 161 | browse.nom_type_nc=nom_type_read;% the netcdf nomenclature is stored |
---|
| 162 | end |
---|
| 163 | end |
---|
[71] | 164 | set(handles.RootName,'String',filebase); |
---|
[2] | 165 | set(handles.ImaDoc,'String',ext) |
---|
| 166 | |
---|
| 167 | %initiate advised operations |
---|
[273] | 168 | enable_civ1(handles,0) |
---|
| 169 | enable_civ2(handles,0) |
---|
| 170 | %enable_pair1(handles,'on') |
---|
| 171 | enable_fix1(handles,0) |
---|
| 172 | enable_patch1(handles,0) |
---|
| 173 | enable_fix2(handles,0) |
---|
| 174 | enable_patch2(handles,0) |
---|
[282] | 175 | set(handles.CheckCiv1,'Value',0) |
---|
| 176 | set(handles.CheckFix1,'Value',0) |
---|
| 177 | set(handles.CheckPatch1,'Value',0) |
---|
| 178 | set(handles.CheckCiv2,'Value',0) |
---|
| 179 | set(handles.CheckFix2,'Value',0) |
---|
| 180 | set(handles.CheckPatch2,'Value',0) |
---|
[273] | 181 | %set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[2] | 182 | if isequal(ind_opening,1) |
---|
[282] | 183 | set(handles.CheckCiv1,'Value',1) |
---|
[273] | 184 | enable_civ1(handles,1) |
---|
[2] | 185 | elseif isequal(ind_opening,2) |
---|
[282] | 186 | set(handles.CheckFix1,'Value',1) |
---|
[273] | 187 | enable_fix1(handles,1) |
---|
[2] | 188 | elseif isequal(ind_opening,3) |
---|
[282] | 189 | set(handles.CheckPatch1,'Value',1) |
---|
[273] | 190 | enable_patch1(handles,1) |
---|
[2] | 191 | elseif isequal(ind_opening,4) |
---|
[282] | 192 | set(handles.CheckCiv2,'Value',1) |
---|
[273] | 193 | enable_civ2(handles,1) |
---|
[2] | 194 | elseif isequal(ind_opening,5) |
---|
[282] | 195 | set(handles.CheckFix2,'Value',1) |
---|
[273] | 196 | enable_fix2(handles,1) |
---|
[112] | 197 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
[282] | 198 | set(handles.ListPairCiv2,'Enable','On') |
---|
| 199 | set(handles.ListPairCiv2,'Enable','On') |
---|
[112] | 200 | enable_pair1(handles,'off') |
---|
[2] | 201 | elseif isequal(ind_opening,6) |
---|
[282] | 202 | set(handles.CheckPatch2,'Value',1) |
---|
[273] | 203 | enable_patch2(handles,1) |
---|
[2] | 204 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
[282] | 205 | set(handles.ListPairCiv2,'Enable','On') |
---|
[2] | 206 | enable_pair1(handles,'off') |
---|
| 207 | end |
---|
| 208 | |
---|
| 209 | % set the range of fields (1:1 by default) and selected pair |
---|
[153] | 210 | if isequal(num_i2,num_i1) |
---|
| 211 | num_ref_i=num_i1; |
---|
[2] | 212 | else |
---|
[153] | 213 | num_ref_i=floor((num_i1+num_i2)/2); |
---|
| 214 | browse.incr_pair(1)=num_i2-num_i1; |
---|
[2] | 215 | browse.incr_pair(2)=0; |
---|
| 216 | end |
---|
[153] | 217 | if isequal(num_j1,num_j2) |
---|
| 218 | if isnan(num_j1) |
---|
[2] | 219 | num_ref_j=1; |
---|
| 220 | else |
---|
[153] | 221 | num_ref_j=num_j1; |
---|
[2] | 222 | end |
---|
| 223 | else |
---|
[153] | 224 | num_ref_j=floor((num_j1+num_j2)/2); |
---|
| 225 | browse.incr_pair(2)=num_j2-num_j1; |
---|
[2] | 226 | end |
---|
| 227 | set(handles.first_i,'String',num2str(num_ref_i)); |
---|
| 228 | set(handles.last_i,'String',num2str(num_ref_i)); |
---|
| 229 | set(handles.first_j,'String',num2str(num_ref_j)); |
---|
| 230 | set(handles.last_j,'String',num2str(num_ref_j)); |
---|
| 231 | set(handles.ref_i,'String',num2str(num_ref_i)); |
---|
| 232 | set(handles.ref_j,'String',num2str(num_ref_j)); |
---|
[273] | 233 | % set(handles.ref_i_civ2,'String',num2str(num_ref_i)); |
---|
| 234 | % set(handles.ref_j_civ2,'String',num2str(num_ref_j)); |
---|
| 235 | set(handles.RootName,'UserData',browse); |
---|
[220] | 236 | if exist('param','var') && isfield(param,'RootName') && ~isempty(param.RootName)%varargin the interface is opened from uvmat |
---|
[112] | 237 | RootName_Callback(hObject, eventdata, handles); |
---|
[2] | 238 | end |
---|
| 239 | |
---|
[12] | 240 | %------------------------------------------------------------------------ |
---|
[2] | 241 | % --- Outputs from this function are returned to the command line. |
---|
| 242 | function varargout = civ_OutputFcn(hObject, eventdata, handles) |
---|
[12] | 243 | %------------------------------------------------------------------------ |
---|
[2] | 244 | % varargout cell array for returning output args (see VARARGOUT); |
---|
| 245 | % hObject handle to figure |
---|
| 246 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 247 | % handles structure with handles and user data (see GUIDATA) |
---|
| 248 | % Get default command line output from handles structure |
---|
| 249 | varargout{1} = handles.output; |
---|
| 250 | |
---|
[273] | 251 | % -------------------------------------------------------------------- |
---|
| 252 | function MenuBrowse_Callback(hObject, eventdata, handles) |
---|
| 253 | |
---|
[2] | 254 | %get the input file properties |
---|
[71] | 255 | filebase=get(handles.RootName,'String'); |
---|
[2] | 256 | oldfile=''; %default |
---|
[39] | 257 | if isempty(filebase)|| isequal(filebase,'')%loads the previously stored file name and set it as default in the file_input box |
---|
[112] | 258 | dir_perso=prefdir; |
---|
| 259 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 260 | if exist(profil_perso,'file') |
---|
| 261 | h=load (profil_perso); |
---|
| 262 | if isfield(h,'filebase')&& ischar(h.filebase) |
---|
| 263 | oldfile=h.filebase; |
---|
| 264 | end |
---|
| 265 | if isfield(h,'RootPath') && ischar(h.RootPath) |
---|
| 266 | oldfile=h.RootPath; |
---|
| 267 | end |
---|
| 268 | end |
---|
| 269 | else |
---|
| 270 | oldfile=filebase; |
---|
| 271 | end |
---|
[2] | 272 | ind_opening=1;%default |
---|
| 273 | browse.incr_pair=[0 0]; %default |
---|
[238] | 274 | menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)'; |
---|
[174] | 275 | '*.xml', '.xml files '; ... |
---|
| 276 | '*.civ', '.civ files '; ... |
---|
| 277 | '*.png','.png image files'; ... |
---|
| 278 | '*.jpg',' jpeg image files'; ... |
---|
| 279 | '*.tif','.tif image files'; ... |
---|
| 280 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 281 | '*.nc','.netcdf files'; ... |
---|
| 282 | '*.*', 'All Files (*.*)'}; |
---|
[2] | 283 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile); |
---|
[112] | 284 | fileinput=[PathName FileName];%complete file name |
---|
[2] | 285 | sizf=size(fileinput); |
---|
| 286 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
| 287 | [path,name,ext]=fileparts(fileinput); |
---|
| 288 | testeditxml=0; |
---|
| 289 | if isequal(ext,'.xml') |
---|
| 290 | testeditxml=1; |
---|
| 291 | t_browse=xmltree(fileinput); |
---|
| 292 | head_element=get(t_browse,1); |
---|
[45] | 293 | if isfield(head_element,'name')&& isequal(head_element.name,'ImaDoc') |
---|
[2] | 294 | testeditxml=0; |
---|
| 295 | end |
---|
| 296 | end |
---|
[45] | 297 | if testeditxml==1 || isequal(ext,'.xls') |
---|
[112] | 298 | heditxml=editxml({fileinput}); |
---|
| 299 | set(heditxml,'Tag','browser') |
---|
| 300 | waitfor(heditxml,'Tag','idle') |
---|
| 301 | if ~ishandle(heditxml) |
---|
| 302 | return |
---|
| 303 | end |
---|
| 304 | attr=findobj(get(heditxml,'children'),'Tag','CurrentAttributes'); |
---|
| 305 | set(handles.browse,'UserData',fileinput)% store for future opening with browser |
---|
| 306 | fileinput=get(attr,'UserData'); |
---|
| 307 | if ~exist(fileinput,'file') |
---|
| 308 | return |
---|
| 309 | end |
---|
[2] | 310 | end |
---|
[82] | 311 | [RootPath,RootFile,str1,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput); |
---|
[2] | 312 | filebase=fullfile(RootPath,RootFile); |
---|
[89] | 313 | num_i1=str2double(str1); |
---|
| 314 | if isnan(num_i1),num_i1=1;end |
---|
| 315 | num_i2=str2double(str2); |
---|
| 316 | if isnan(num_i2),num_i2=num_i1;end |
---|
[54] | 317 | num_j1=stra2num(str_a); |
---|
[89] | 318 | if isnan(num_j1),num_j1=1;end |
---|
[54] | 319 | num_j2=stra2num(str_b); |
---|
[112] | 320 | if isnan(num_j2),num_j2=num_j1;end |
---|
[282] | 321 | if isequal(get(handles.ListCompareMode,'Value'),1) |
---|
[2] | 322 | browse=[];%initialisation |
---|
| 323 | else |
---|
[273] | 324 | browse=get(handlesRootName,'UserData'); |
---|
[2] | 325 | end |
---|
[122] | 326 | browse.num_i1=num_i1; |
---|
| 327 | browse.num_i2=num_i2; |
---|
| 328 | browse.num_j1=num_j1; |
---|
| 329 | browse.num_j2=num_j2; |
---|
| 330 | if length(ext)>1 && (~isempty(imformats(ext(2:end)))||strcmpi(ext,'.avi'));%if an image file has been opened by uvmat |
---|
[2] | 331 | browse.nom_type_ima=nom_type; |
---|
[122] | 332 | browse.ext_ima=ext; |
---|
[177] | 333 | set(handles.ImaExt,'String',ext) |
---|
[2] | 334 | end |
---|
| 335 | set(handles.ImaDoc,'String',ext); |
---|
| 336 | |
---|
| 337 | %%%%% read the state of the selected netcdf file to advise default operation |
---|
| 338 | if isequal(ext,'.nc') |
---|
| 339 | browse.nom_type_nc=nom_type; |
---|
[112] | 340 | ind_opening=2;% propose 'fix' as the default option |
---|
[246] | 341 | Data=nc2struct(fileinput,'ListGlobalAttribute','CivStage','absolut_time_T0','fix','patch','civ2','fix2'); |
---|
| 342 | if ~isempty(Data.CivStage)%test for civ files |
---|
| 343 | ind_opening=Data.CivStage; |
---|
[282] | 344 | set(handles.ListPairMode,'Value',3) |
---|
[246] | 345 | end |
---|
| 346 | if ~isempty(Data.absolut_time_T0)%test for civx files |
---|
[282] | 347 | set(handles.ListPairMode,'Value',1) |
---|
[2] | 348 | if isfield(Data,'fix') && isequal(Data.fix,1) |
---|
| 349 | ind_opening=3; |
---|
| 350 | end |
---|
[246] | 351 | if isequal(Data.patch,1) |
---|
[2] | 352 | ind_opening=4; |
---|
| 353 | end |
---|
[246] | 354 | if isequal(Data.civ2,1) |
---|
[2] | 355 | ind_opening=5; |
---|
| 356 | end |
---|
[246] | 357 | if isequal(Data.fix2,1) |
---|
[2] | 358 | ind_opening=6; |
---|
| 359 | end |
---|
| 360 | testciv=1; %TO SUPPRESS WITH NEW VERSION OF CIVX |
---|
| 361 | else |
---|
[112] | 362 | ind_opening=3; %GUI used only for patch |
---|
[2] | 363 | testciv=0; |
---|
| 364 | end |
---|
[289] | 365 | set(handles.txt_SubdirCiv1,'String',subdir);%set the default subdir directories for installing the .nc results |
---|
| 366 | set(handles.txt_SubdirCiv2,'String',subdir); |
---|
[2] | 367 | browse.testciv=testciv; |
---|
| 368 | browse.ind_opening=ind_opening; |
---|
| 369 | end |
---|
[71] | 370 | set(handles.RootName,'String',filebase); |
---|
[2] | 371 | set(handles.ImaDoc,'String',ext); |
---|
[45] | 372 | if ~isempty(num_i1) |
---|
[82] | 373 | ref_i=num_i1; |
---|
[45] | 374 | if ~isempty(num_i2) |
---|
| 375 | ref_i=floor((ref_i+num_i2)/2);% reference image number corresponding to the file |
---|
| 376 | browse.incr_pair(1)=num_i2-num_i1; |
---|
[2] | 377 | browse.incr_pair(2)=0; |
---|
| 378 | end |
---|
| 379 | set(handles.first_i,'String',num2str(ref_i)); |
---|
| 380 | set(handles.last_i,'String',num2str(ref_i)); |
---|
[71] | 381 | set(handles.ref_i,'String',num2str(ref_i)); |
---|
[273] | 382 | % set(handles.ref_i_civ2,'String',num2str(ref_i)) |
---|
[2] | 383 | end |
---|
[45] | 384 | if isempty(num_j1) |
---|
[2] | 385 | set(handles.ref_j,'String','1'); |
---|
[71] | 386 | set(handles.ref_j_civ2,'String','1'); |
---|
[2] | 387 | else |
---|
[45] | 388 | ref_j=num_j1; |
---|
| 389 | if ~isempty(num_j2) |
---|
| 390 | ref_j=floor((num_j1+num_j2)/2); |
---|
[112] | 391 | browse.incr_pair(2)=num_j2-num_j1; |
---|
[2] | 392 | end |
---|
| 393 | set(handles.first_j,'String',num2str(ref_j)); |
---|
| 394 | set(handles.last_j,'String',num2str(ref_j)); |
---|
[112] | 395 | set(handles.ref_j,'String',num2str(ref_j)); |
---|
[273] | 396 | % set(handles.ref_j_civ2,'String',num2str(ref_j)); |
---|
[2] | 397 | end |
---|
| 398 | |
---|
| 399 | % set default operation options |
---|
[273] | 400 | enable_civ1(handles,0) |
---|
| 401 | enable_civ2(handles,0') |
---|
[2] | 402 | enable_pair1(handles,'on') |
---|
[273] | 403 | enable_fix1(handles,0) |
---|
| 404 | enable_patch1(handles,0) |
---|
| 405 | enable_fix2(handles,0) |
---|
| 406 | enable_patch2(handles,0) |
---|
[282] | 407 | set(handles.CheckCiv1,'Value',0) |
---|
| 408 | set(handles.CheckFix1,'Value',0) |
---|
| 409 | set(handles.CheckPatch1,'Value',0) |
---|
| 410 | set(handles.CheckCiv2,'Value',0) |
---|
| 411 | set(handles.CheckFix2,'Value',0) |
---|
| 412 | set(handles.CheckPatch2,'Value',0) |
---|
[273] | 413 | % set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[2] | 414 | if isequal(ind_opening,1) |
---|
[282] | 415 | set(handles.CheckCiv1,'Value',1) |
---|
[2] | 416 | enable_civ1(handles,'on') |
---|
| 417 | elseif isequal(ind_opening,2) |
---|
[282] | 418 | set(handles.CheckFix1,'Value',1) |
---|
[2] | 419 | enable_fix1(handles,'on') |
---|
| 420 | elseif isequal(ind_opening,3) |
---|
[282] | 421 | set(handles.CheckPatch1,'Value',1) |
---|
[2] | 422 | enable_patch1(handles) |
---|
| 423 | elseif isequal(ind_opening,4) |
---|
[282] | 424 | set(handles.CheckCiv2,'Value',1) |
---|
[224] | 425 | enable_civ2(handles,'on') |
---|
[2] | 426 | elseif isequal(ind_opening,5) |
---|
| 427 | enable_pair1(handles,'off') |
---|
[282] | 428 | set(handles.CheckFix2,'Value',1) |
---|
[2] | 429 | enable_fix2(handles) |
---|
[112] | 430 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
[282] | 431 | set(handles.ListPairCiv2,'Enable','On') |
---|
| 432 | set(handles.ListPairCiv2,'Enable','On') |
---|
[2] | 433 | elseif isequal(ind_opening,6) |
---|
| 434 | enable_pair1(handles,'off') |
---|
[282] | 435 | set(handles.CheckPatch2,'Value',1) |
---|
[2] | 436 | enable_patch2(handles) |
---|
| 437 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
[282] | 438 | set(handles.ListPairCiv2,'Enable','On') |
---|
[2] | 439 | end |
---|
[273] | 440 | set(handles.RootName,'UserData',browse);% store information from browser |
---|
[71] | 441 | RootName_Callback(hObject, eventdata, handles); |
---|
[2] | 442 | |
---|
[273] | 443 | |
---|
| 444 | % ----------------------------------------------------------------------- |
---|
| 445 | % --- Open again the file whose name has been recorded in MenuFile_1 |
---|
| 446 | function MenuFile_1_Callback(hObject, eventdata, handles) |
---|
[12] | 447 | %------------------------------------------------------------------------ |
---|
[273] | 448 | fileinput=get(handles.MenuFile_1,'Label'); |
---|
| 449 | display_file_name(hObject, eventdata, handles,fileinput) |
---|
| 450 | |
---|
| 451 | % ----------------------------------------------------------------------- |
---|
| 452 | % --- Open again the file whose name has been recorded in MenuFile_2 |
---|
| 453 | function MenuFile_2_Callback(hObject, eventdata, handles) |
---|
| 454 | %------------------------------------------------------------------------ |
---|
| 455 | fileinput=get(handles.MenuFile_2,'Label'); |
---|
| 456 | display_file_name(hObject, eventdata, handles,fileinput) |
---|
| 457 | |
---|
| 458 | % ----------------------------------------------------------------------- |
---|
| 459 | % --- Open again the file whose name has been recorded in MenuFile_3 |
---|
| 460 | function MenuFile_3_Callback(hObject, eventdata, handles) |
---|
| 461 | %------------------------------------------------------------------------ |
---|
| 462 | fileinput=get(handles.MenuFile_3,'Label'); |
---|
| 463 | display_file_name(hObject, eventdata, handles,fileinput) |
---|
| 464 | |
---|
| 465 | % ----------------------------------------------------------------------- |
---|
| 466 | % --- Open again the file whose name has been recorded in MenuFile_4 |
---|
| 467 | function MenuFile_4_Callback(hObject, eventdata, handles) |
---|
| 468 | %------------------------------------------------------------------------ |
---|
| 469 | fileinput=get(handles.MenuFile_4,'Label'); |
---|
| 470 | display_file_name(hObject, eventdata, handles,fileinput) |
---|
| 471 | |
---|
| 472 | % ----------------------------------------------------------------------- |
---|
| 473 | % --- Open again the file whose name has been recorded in MenuFile_5 |
---|
| 474 | function MenuFile_5_Callback(hObject, eventdata, handles) |
---|
| 475 | %------------------------------------------------------------------------ |
---|
| 476 | fileinput=get(handles.MenuFile_5,'Label'); |
---|
| 477 | display_file_name(hObject, eventdata, handles,fileinput) |
---|
| 478 | |
---|
| 479 | %------------------------------------------------------------------------ |
---|
[2] | 480 | function ImaDoc_Callback(hObject, eventdata, handles) |
---|
[12] | 481 | %------------------------------------------------------------------------ |
---|
[71] | 482 | RootName_Callback(hObject, eventdata, handles) |
---|
[2] | 483 | |
---|
[12] | 484 | %------------------------------------------------------------------------ |
---|
[54] | 485 | % --- function activated when a new filebase (image series) is introduced |
---|
[71] | 486 | function RootName_Callback(hObject, eventdata, handles) |
---|
[12] | 487 | %------------------------------------------------------------------------ |
---|
[273] | 488 | filebase=get(handles.RootName,'String'); |
---|
| 489 | display_file_name(hObject, eventdata, handles,filebase) |
---|
| 490 | |
---|
| 491 | %------------------------------------------------------------------------ |
---|
| 492 | function display_file_name(hObject, eventdata, handles,filebase) |
---|
| 493 | %------------------------------------------------------------------------ |
---|
[282] | 494 | set(handles.ListCompareMode,'Visible','on') |
---|
[122] | 495 | ext_ima='';%default |
---|
[2] | 496 | nom_type_ima=[];%default |
---|
| 497 | field_count=1;%default |
---|
| 498 | nom_type_nc=[]; |
---|
| 499 | time=[]; |
---|
[71] | 500 | TimeUnit='frame'; %default |
---|
| 501 | CoordUnit='px';%default |
---|
[2] | 502 | pxcmx_search=[];%default |
---|
| 503 | pxcmy_search=[];%default |
---|
[273] | 504 | |
---|
[128] | 505 | ext_imadoc=get(handles.ImaDoc,'String'); |
---|
[273] | 506 | browse=get(handles.RootName,'UserData');%default |
---|
[122] | 507 | if isfield(browse,'nom_type_ima') |
---|
| 508 | nom_type_ima=browse.nom_type_ima;% get an image nomenclature type already determined by an input image name |
---|
[133] | 509 | end |
---|
| 510 | if isfield(browse,'ext_ima') |
---|
[122] | 511 | ext_ima=browse.ext_ima; |
---|
[2] | 512 | end |
---|
[122] | 513 | if isfield(browse,'nom_type_nc') |
---|
| 514 | nom_type_nc=browse.nom_type_nc;% get an image nomenclature type already determined by an input image name |
---|
| 515 | end |
---|
| 516 | if isfield(browse,'num_i1') |
---|
| 517 | field_count=browse.num_i1;% get an image index type already determined by an input file |
---|
| 518 | end |
---|
[252] | 519 | set(handles.civ,'UserData',[]); %refresh list of previous civ files (for STATUS) |
---|
[2] | 520 | |
---|
| 521 | %default first_i and j and increments |
---|
[137] | 522 | first_i=str2double(get(handles.first_i,'String'));%value possibly set by uvmat_Opening |
---|
| 523 | if isnan(first_i)|| first_i < 1 |
---|
[2] | 524 | first_i=1; %default first_i |
---|
| 525 | end |
---|
[137] | 526 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 527 | if isnan(last_i)|| last_i < first_i |
---|
[2] | 528 | last_i=first_i; %default last_i |
---|
| 529 | end |
---|
[137] | 530 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 531 | if isnan(first_j)|| first_j < 1 |
---|
[2] | 532 | first_j=1; %default first_j |
---|
| 533 | end |
---|
[137] | 534 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 535 | if isnan(last_j)|| last_j < first_j |
---|
[2] | 536 | last_j=first_j; %default last_j |
---|
| 537 | end |
---|
[137] | 538 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 539 | if isnan(incr_i) || incr_i < 1; |
---|
[2] | 540 | set(handles.incr_i,'String','1') %default incr_i |
---|
| 541 | end |
---|
[137] | 542 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
| 543 | if isnan(incr_j) || incr_j < 1; |
---|
[2] | 544 | set(handles.incr_j,'String','1') %default incr_j |
---|
| 545 | end |
---|
| 546 | dt=[];%default |
---|
| 547 | testmode=0;%default |
---|
| 548 | nbfield=[]; %default |
---|
| 549 | nburst=[];%default |
---|
| 550 | pxcmx=1; |
---|
[112] | 551 | pxcmy=1; |
---|
[2] | 552 | |
---|
[112] | 553 | %look for an image documentation file |
---|
[128] | 554 | if ~strcmp(ext_imadoc,'.xml') && ~strcmp(ext_imadoc,'.civ')&& ~strcmpi(ext_imadoc,'.avi') |
---|
[2] | 555 | if exist([filebase '.xml'],'file') |
---|
[128] | 556 | ext_imadoc='.xml'; |
---|
[2] | 557 | elseif exist([filebase '.civxml'],'file') |
---|
[128] | 558 | ext_imadoc='.civxml'; |
---|
[2] | 559 | elseif exist([filebase '.civ'],'file') |
---|
[128] | 560 | ext_imadoc='.civ'; |
---|
[112] | 561 | elseif exist([filebase '.avi'],'file') |
---|
[128] | 562 | ext_imadoc='.avi'; |
---|
[2] | 563 | elseif exist([filebase '.AVI'],'file') |
---|
[128] | 564 | ext_imadoc='.AVI'; |
---|
[2] | 565 | end |
---|
[128] | 566 | set(handles.ImaDoc,'String',ext_imadoc) |
---|
[2] | 567 | end |
---|
| 568 | |
---|
| 569 | %%%%%%%% read image documentation file %%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[84] | 570 | mode=''; %default |
---|
| 571 | set(handles.ImaDoc,'BackgroundColor',[1 1 0]) |
---|
| 572 | drawnow |
---|
[128] | 573 | if isequal(ext_imadoc,'.civxml') || isequal(ext_imadoc,'.xml')|| isequal(ext_imadoc,'.civ') |
---|
[2] | 574 | set(handles.ref_i,'Visible','On')%use a reference index |
---|
| 575 | set(handles.ref_j,'Visible','On') |
---|
[128] | 576 | elseif isequal(ext_imadoc,'.avi') || isequal(ext_imadoc,'.AVI') |
---|
[2] | 577 | set(handles.ref_j,'Visible','Off') |
---|
| 578 | else |
---|
| 579 | set(handles.ref_i,'Visible','Off') |
---|
| 580 | set(handles.ref_j,'Visible','Off') |
---|
| 581 | end |
---|
[12] | 582 | testima_xml=0; |
---|
[128] | 583 | if isequal(ext_imadoc,'.civxml')%TO ABANDON |
---|
[122] | 584 | [nbfield,nbfield2,time]=read_civxml([filebase '.civxml']); |
---|
[2] | 585 | mode='pair j1-j2'; |
---|
| 586 | if isempty(nom_type_ima)% dtermine types by default if not already selected by browser or uvmat |
---|
[112] | 587 | nom_type_ima='_i_j'; |
---|
[2] | 588 | end |
---|
[128] | 589 | elseif isequal(ext_imadoc,'.xml') |
---|
[73] | 590 | [XmlData,warntext]=imadoc2struct([filebase '.xml']); |
---|
[2] | 591 | ext_ima_read=[]; |
---|
| 592 | nom_type_read=[]; |
---|
[12] | 593 | if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')&&ischar(XmlData.Heading.ImageName)% get image nom type and extension from the xml file |
---|
[2] | 594 | [PP,FF,fc,str2,str_a,str_b,ext_ima_read,nom_type_read]=name2display(XmlData.Heading.ImageName); |
---|
[112] | 595 | fullname=fullfile(fileparts(filebase),XmlData.Heading.ImageName); %full name (including path) of the first image defined by the xmle file, |
---|
[45] | 596 | if ~exist(fullname,'file') |
---|
[12] | 597 | msgbox_uvmat('WARNING',['FirstImage ' fullname ' defined in the xml file does not exist']) |
---|
| 598 | end |
---|
[2] | 599 | end |
---|
[84] | 600 | if isfield(XmlData,'Time') |
---|
[85] | 601 | time=XmlData.Time; |
---|
[84] | 602 | nbfield=size(time,1); |
---|
[122] | 603 | nbfield2=size(time,2); |
---|
[127] | 604 | %transform .Time to a column vector if it is a line vector thenomenclature uses a single index: correct possible bug in xml |
---|
[122] | 605 | if isequal(nbfield,1) && ~isequal(nbfield2,1)% .Time is a line vector |
---|
[127] | 606 | if numel(nom_type_read)>=2 && isempty(regexp(nom_type_read(2:end),'\D')) |
---|
[84] | 607 | time=time'; |
---|
[122] | 608 | nbfield=nbfield2; |
---|
| 609 | nbfield2=1; |
---|
[84] | 610 | end |
---|
| 611 | end |
---|
| 612 | end |
---|
[71] | 613 | if isfield(XmlData,'TimeUnit') |
---|
| 614 | TimeUnit=XmlData.TimeUnit; |
---|
[2] | 615 | end |
---|
[71] | 616 | if isfield(XmlData,'Npx') |
---|
| 617 | npx=XmlData.Npx; |
---|
| 618 | npy=XmlData.Npy; |
---|
| 619 | end |
---|
[2] | 620 | pxcmx_search=1; |
---|
| 621 | pxcmy_search=1; |
---|
| 622 | if isfield(XmlData,'GeometryCalib') |
---|
| 623 | tsai=XmlData.GeometryCalib; |
---|
[112] | 624 | if isfield(tsai,'f') && isfield(tsai,'Tz') && isfield(tsai,'dpx') && isfield(tsai,'dpy')&& isfield(tsai,'R') |
---|
| 625 | rot2D=tsai.R(1:2,[1,2]); |
---|
| 626 | pxcmx_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpx); |
---|
| 627 | pxcmy_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpy); |
---|
[2] | 628 | end |
---|
[112] | 629 | if isfield(tsai,'CoordUnit') |
---|
| 630 | CoordUnit=tsai.CoordUnit; |
---|
[2] | 631 | end |
---|
[112] | 632 | end |
---|
[128] | 633 | elseif strcmp(ext_imadoc,'.civ')% case of .civ image documentation file |
---|
[112] | 634 | [error,time,TimeUnit,mode,npx,npy]=read_imatext([filebase '.civ']); |
---|
| 635 | if error==2, msgbox_uvmat('WARNING',['no file ' filebase '.civ']); |
---|
| 636 | elseif error==1, msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file'); |
---|
| 637 | end |
---|
[128] | 638 | nom_type_ima='001a'; |
---|
| 639 | elseif strcmpi(ext_imadoc,'.avi') |
---|
[112] | 640 | nom_type_ima='*'; |
---|
[128] | 641 | ext_ima=ext_imadoc; |
---|
[282] | 642 | set(handles.ListPairMode,'Value',1); |
---|
| 643 | set(handles.ListPairMode,'String',{'series(Di)'}) |
---|
[112] | 644 | dt=0.04;%default |
---|
[128] | 645 | if exist([filebase ext_imadoc],'file')==2 |
---|
| 646 | info=aviinfo([filebase ext_imadoc]);%read infos on the avi movie |
---|
[112] | 647 | dt=1/info.FramesPerSecond;%time interval between successive frames |
---|
| 648 | nbfield=info.NumFrames;%number of frames |
---|
| 649 | end |
---|
| 650 | time=(dt*(0:nbfield-1))';%list of image times |
---|
[2] | 651 | end |
---|
| 652 | if isempty(time) |
---|
| 653 | set(handles.ImaDoc,'String',''); %xml file not used for timing |
---|
| 654 | end |
---|
| 655 | set(handles.ImaDoc,'BackgroundColor',[1 1 1]) |
---|
| 656 | |
---|
[122] | 657 | %get the imabe nomenclature type if not defined by the input file nor by the xml file |
---|
| 658 | dirima=[];%default |
---|
[12] | 659 | if isempty(nom_type_ima) |
---|
| 660 | %look for double image series '_i_j' |
---|
| 661 | dirima=dir([filebase '_' num2str(first_i) '_' num2str(first_j) '.*']); |
---|
| 662 | if isempty(dirima) |
---|
[112] | 663 | % look for images series with sub marker '_' |
---|
| 664 | dirima=dir([filebase '_*' num2str(first_i) '.*']); |
---|
| 665 | if isempty(dirima) |
---|
| 666 | % look for other images series |
---|
| 667 | dirima=dir([filebase '*' num2str(first_i) '.*']); |
---|
[122] | 668 | if isempty(dirima) |
---|
| 669 | % look for other images series witth letter appendix |
---|
| 670 | appendix=char(96+first_j); |
---|
| 671 | dirima=dir([filebase '*' num2str(first_i) appendix '.*']); |
---|
[112] | 672 | end |
---|
| 673 | end |
---|
[12] | 674 | end |
---|
[112] | 675 | end |
---|
[122] | 676 | for ilist=1:numel(dirima) |
---|
| 677 | [pp,ff,fc,str2,str_a,str_b,ext_list,nom_type_list]=name2display(dirima(ilist).name); |
---|
| 678 | form=imformats(ext_list(2:end)); |
---|
| 679 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 680 | ext_ima=ext_list; |
---|
| 681 | nom_type_ima=nom_type_list; |
---|
| 682 | break |
---|
| 683 | end |
---|
| 684 | end |
---|
| 685 | % no image documentation file found: look for a series of existing files,images by priority or .nc files |
---|
| 686 | if isempty(nom_type_ima) |
---|
[128] | 687 | ext_search=ext_imadoc; |
---|
[122] | 688 | nom_type_search=nom_type_nc; |
---|
| 689 | else |
---|
| 690 | ext_search=ext_ima; |
---|
| 691 | nom_type_search=nom_type_ima; |
---|
| 692 | end |
---|
| 693 | if isempty(time) && ~strcmp(nom_type_search,'none') && ~strcmp(nom_type_search,'') && ~strcmp(nom_type_search,'*') |
---|
[289] | 694 | subdir=get(handles.txt_SubdirCiv1,'String'); |
---|
[12] | 695 | incr_pair=[0 0];%default |
---|
| 696 | if isfield(browse,'incr_pair') |
---|
[112] | 697 | incr_pair=browse.incr_pair; |
---|
[12] | 698 | end |
---|
[112] | 699 | % nbdetect=0;%test of detected images |
---|
[122] | 700 | field_i=browse.num_i2; |
---|
[153] | 701 | imagename=name_generator(filebase,field_i,1,ext_search,nom_type_search); |
---|
| 702 | imagename_plus=''; |
---|
[12] | 703 | idetect=1; |
---|
[153] | 704 | while idetect %look for the maximum file number in the series |
---|
| 705 | imagename_plus=name_generator(filebase,field_i+1,1,ext_search,nom_type_search); |
---|
| 706 | idetect=(exist(imagename_plus,'file')==2)&& ~strcmp(imagename,imagename_plus); |
---|
[81] | 707 | if idetect |
---|
[12] | 708 | field_i=field_i+1; |
---|
[81] | 709 | end |
---|
[112] | 710 | %SEE CASE OF NETCDF FILES |
---|
| 711 | % nbdetect=nbdetect+(exist(imagename,'file')==2); |
---|
[12] | 712 | end |
---|
[122] | 713 | nbfield=field_i;% last detected field number |
---|
| 714 | field_i=browse.num_i1;%look for the minimum file number in the series |
---|
[153] | 715 | imagename_min=''; |
---|
[12] | 716 | idetect=1; |
---|
[112] | 717 | while idetect==1 |
---|
[153] | 718 | imagename_min=name_generator(filebase,field_i-1,1,ext_search,nom_type_search); |
---|
| 719 | idetect=(exist(imagename_min,'file')==2)&& ~strcmp(imagename,imagename_min); |
---|
[81] | 720 | if idetect |
---|
[112] | 721 | field_i=field_i-1; |
---|
[81] | 722 | end |
---|
[12] | 723 | end |
---|
[122] | 724 | first_i=max(field_i,1); |
---|
| 725 | if numel(regexp(nom_type_search,'\D'))>=1%two indices i and j |
---|
| 726 | field_i=browse.num_i1; |
---|
| 727 | field_j=browse.num_j2; |
---|
[177] | 728 | imagename=name_generator(filebase,field_i,field_j,ext_search,nom_type_search); |
---|
[153] | 729 | imagename_plus=''; |
---|
[89] | 730 | jdetect=1; |
---|
| 731 | while jdetect==1 %look for the maximum file number in the series |
---|
[153] | 732 | imagename_plus=name_generator(filebase,field_i,field_j+1,ext_search,nom_type_search); |
---|
| 733 | jdetect=(exist(imagename_plus,'file')==2)&& ~strcmp(imagename,imagename_plus); |
---|
[89] | 734 | if jdetect |
---|
| 735 | field_j=field_j+1; |
---|
| 736 | end |
---|
| 737 | %SEE CASE OF NETCDF FILES |
---|
| 738 | % nbdetect=nbdetect+(exist(imagename,'file')==2); |
---|
| 739 | end |
---|
[122] | 740 | nbfield2=field_j;% last detected field number |
---|
[120] | 741 | end |
---|
[122] | 742 | |
---|
[89] | 743 | %determine the set of times and possible intervals for CIV |
---|
[137] | 744 | % dt=(1/1000)*str2double(get(handles.dt,'String')); |
---|
[122] | 745 | time=(0:nbfield-1)';% time=file index -1 by default |
---|
| 746 | if numel(regexp(nom_type_search,'\D'))>=1%two indices i and j |
---|
| 747 | [x,y]=meshgrid(0:nbfield2-1,0:nbfield-1); |
---|
[120] | 748 | time=x+y; |
---|
[89] | 749 | end |
---|
[2] | 750 | end |
---|
[120] | 751 | |
---|
[2] | 752 | if exist('time','var') |
---|
| 753 | if size(time,1)+size(time,2)>=3 % if there are at least two time values to define dt |
---|
| 754 | nbfield=size(time,1); |
---|
| 755 | nbfield2=size(time,2); |
---|
[273] | 756 | set(handles.ImaDoc,'UserData',time); %store the set of times |
---|
[71] | 757 | set(handles.dt_unit,'String',['dt in m' TimeUnit]); |
---|
[273] | 758 | % set(handles.dt_unit_civ2,'String',['dt in m' TimeUnit]); |
---|
[71] | 759 | set(handles.TimeUnit,'String',TimeUnit); |
---|
[2] | 760 | set(handles.nb_field,'String',num2str(nbfield)); |
---|
| 761 | set(handles.nb_field2,'String',num2str(nbfield2)); |
---|
| 762 | end |
---|
| 763 | end |
---|
[71] | 764 | set(handles.CoordUnit,'String',CoordUnit) |
---|
[273] | 765 | set(handles.SearchRange,'UserData',[pxcmx_search pxcmy_search]); |
---|
[2] | 766 | % npxy=[npy npx]; |
---|
[71] | 767 | set(handles.ImaExt,'String',ext_ima) |
---|
[2] | 768 | set(handles.first_i,'String',num2str(first_i)); |
---|
| 769 | set(handles.last_i,'String',num2str(last_i));% |
---|
| 770 | set(handles.first_j,'String',num2str(first_j)); |
---|
| 771 | set(handles.last_j,'String',num2str(last_j));% |
---|
| 772 | browse.nom_type_ima=nom_type_ima; |
---|
[273] | 773 | set(handles.RootName,'UserData',browse)% store the nomenclature type |
---|
[2] | 774 | |
---|
[273] | 775 | %% set the menus of image pairs and default selection for civ %%%%%%%%%%%%%%%%%%% |
---|
[177] | 776 | test_ima_i=numel(nom_type_ima)>1 && isempty(regexp(nom_type_ima(2:end),'\D','once'));%images with single indexing |
---|
[122] | 777 | if test_ima_i || isequal(nom_type_nc,'_i1-i2')||~(exist('nbfield2','var')&&(nbfield2~=1)) |
---|
[282] | 778 | set(handles.ListPairMode,'Value',1) |
---|
| 779 | set(handles.ListPairMode,'String',{'series(Di)'}) |
---|
[2] | 780 | elseif (nbfield==1)% simple series in j |
---|
[282] | 781 | set(handles.ListPairMode,'Value',1) |
---|
| 782 | set(handles.ListPairMode,'String',{'series(Dj)'}) |
---|
[2] | 783 | else |
---|
[282] | 784 | set(handles.ListPairMode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice |
---|
[122] | 785 | if nbfield2 <= 10 |
---|
[282] | 786 | set(handles.ListPairMode,'Value',1)% advice 'pair j1-j2' for small burst |
---|
[2] | 787 | end |
---|
| 788 | end |
---|
| 789 | |
---|
| 790 | |
---|
[177] | 791 | %% desable status and RUN button |
---|
[2] | 792 | set(handles.RUN, 'Enable','On') |
---|
| 793 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
[122] | 794 | set(handles.BATCH,'Enable','On') |
---|
| 795 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
[178] | 796 | if isfield(handles,'status') |
---|
[177] | 797 | set(handles.status,'Value',0);%suppress status display |
---|
| 798 | status_Callback(hObject, eventdata, handles) |
---|
[178] | 799 | end |
---|
[112] | 800 | |
---|
[177] | 801 | %% store the root input filename for future opening |
---|
[2] | 802 | dir_perso=prefdir; |
---|
| 803 | profil_perso=fullfile(prefdir,'uvmat_perso.mat'); |
---|
| 804 | RootPath=fileparts(filebase); |
---|
| 805 | if exist(profil_perso,'file') |
---|
| 806 | save (profil_perso,'RootPath','-append'); %store the root name for future opening of uvmat |
---|
| 807 | else |
---|
[147] | 808 | txt=ver('MATLAB'); |
---|
| 809 | Release=txt.Release; |
---|
[137] | 810 | relnumb=str2double(Release(3:4)); |
---|
[2] | 811 | if relnumb >= 14 |
---|
[112] | 812 | save (profil_perso,'RootPath','-V6'); %store the root name for future opening of uvmat |
---|
[2] | 813 | else |
---|
| 814 | save (profil_perso,'RootPath'); %store the root name for future opening of uvmat |
---|
| 815 | end |
---|
| 816 | end |
---|
| 817 | |
---|
[273] | 818 | %% update the subdir |
---|
| 819 | pathdir=fileparts(filebase);%path to the current xml file |
---|
| 820 | listot=dir(pathdir); |
---|
| 821 | idir=0; |
---|
| 822 | listdir={''};%default |
---|
| 823 | for ilist=1:length(listot) |
---|
| 824 | if listot(ilist).isdir |
---|
| 825 | name=listot(ilist).name; |
---|
| 826 | if ~isequal(name,'.') && ~isequal(name,'..') |
---|
| 827 | idir=idir+1; |
---|
| 828 | listdir{idir,1}=listot(ilist).name; |
---|
| 829 | end |
---|
| 830 | end |
---|
| 831 | end |
---|
[282] | 832 | set(handles.ListSubdirCiv1,'Value',1) |
---|
[289] | 833 | set(handles.ListSubdirCiv2,'Value',1) |
---|
[282] | 834 | set(handles.ListSubdirCiv1,'String',[listdir;'new...']) |
---|
[289] | 835 | set(handles.ListSubdirCiv2,'String',[listdir;'new...']) |
---|
[273] | 836 | if isempty(listdir) |
---|
| 837 | dirname=listdir{1}; |
---|
| 838 | else |
---|
| 839 | dirname='CIV'; %default civ directory name |
---|
| 840 | end |
---|
[289] | 841 | set(handles.txt_SubdirCiv1,'String',dirname) |
---|
| 842 | set(handles.txt_SubdirCiv2,'String',dirname) |
---|
[273] | 843 | %check wether the current subdir exists: |
---|
[289] | 844 | % txt_SubdirCiv1=get(handles.txt_SubdirCiv1,'String'); |
---|
| 845 | % txt_SubdirCiv2=get(handles.txt_SubdirCiv2,'String'); |
---|
[273] | 846 | |
---|
[282] | 847 | ListPairMode_Callback(hObject, eventdata, handles) |
---|
[273] | 848 | |
---|
[12] | 849 | %------------------------------------------------------------------------ |
---|
[282] | 850 | % --- Executes on button press in ListPairMode. |
---|
| 851 | function ListPairMode_Callback(hObject, eventdata, handles) |
---|
[12] | 852 | %------------------------------------------------------------------------ |
---|
[273] | 853 | browse=get(handles.RootName,'UserData'); |
---|
[282] | 854 | compare_list=get(handles.ListCompareMode,'String'); |
---|
| 855 | val=get(handles.ListCompareMode,'Value'); |
---|
[2] | 856 | compare=compare_list{val}; |
---|
| 857 | if strcmp(compare,'displacement') |
---|
| 858 | mode='displacement'; |
---|
| 859 | else |
---|
[282] | 860 | mode_list=get(handles.ListPairMode,'String'); |
---|
[236] | 861 | if ischar(mode_list) |
---|
| 862 | mode_list={mode_list}; |
---|
| 863 | end |
---|
[282] | 864 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[2] | 865 | mode=mode_list{mode_value}; |
---|
| 866 | end |
---|
| 867 | displ_num=[];%default |
---|
[137] | 868 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[2] | 869 | % last_i=str2num(get(handles.last_i,'String')); |
---|
[273] | 870 | time=get(handles.ImaDoc,'UserData'); %get the set of times |
---|
[2] | 871 | siztime=size(time); |
---|
| 872 | nbfield=siztime(1); |
---|
| 873 | nbfield2=siztime(2); |
---|
| 874 | indchosen=1; %%first pair selected by default |
---|
| 875 | if isequal(mode,'pair j1-j2')%| isequal(mode,'st_pair j1-j2') |
---|
| 876 | dt=1; |
---|
| 877 | displ=''; |
---|
| 878 | index=0; |
---|
| 879 | numlist_a=[]; |
---|
| 880 | numlist_B=[]; |
---|
| 881 | %get all the time intervals in bursts |
---|
| 882 | displ_dt=1;%default |
---|
| 883 | nbfield2=min(nbfield2,10);%limitate the number of pairs to 10x10 |
---|
| 884 | for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'pair j1-j2' mode |
---|
| 885 | for numod_b=(numod_a+1):nbfield2 |
---|
[112] | 886 | index=index+1; |
---|
| 887 | numlist_a(index)=numod_a; |
---|
| 888 | numlist_b(index)=numod_b; |
---|
| 889 | if ~isempty(time) |
---|
[54] | 890 | dt(numod_a,numod_b)=time(ref_i,numod_b)-time(ref_i,numod_a);%first time interval dt |
---|
[2] | 891 | displ_dt(index)=dt(numod_a,numod_b); |
---|
[112] | 892 | else |
---|
| 893 | displ_dt(index)=1; |
---|
| 894 | end |
---|
| 895 | end |
---|
| 896 | end |
---|
| 897 | [dtsort,indsort]=sort(displ_dt); |
---|
| 898 | if ~isempty(numlist_a) |
---|
| 899 | displ_num(1,:)=numlist_a(indsort); |
---|
| 900 | displ_num(2,:)=numlist_b(indsort); |
---|
| 901 | end |
---|
| 902 | displ_num(3,:)=0; |
---|
| 903 | displ_num(4,:)=0; |
---|
| 904 | set(handles.jtext,'Visible','Off') |
---|
[2] | 905 | set(handles.first_j,'Visible','Off') |
---|
| 906 | set(handles.last_j,'Visible','Off') |
---|
| 907 | set(handles.incr_j,'Visible','Off') |
---|
| 908 | set(handles.nb_field2,'Visible','Off') |
---|
| 909 | set(handles.ref_j,'Visible','Off') |
---|
| 910 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') |
---|
[112] | 911 | for index=1:min(nbfield2-1,200) |
---|
| 912 | displ_num(1,index)=-floor(index/2); |
---|
| 913 | displ_num(2,index)=ceil(index/2); |
---|
| 914 | displ_num(3,index)=0; |
---|
| 915 | displ_num(4,index)=0; |
---|
| 916 | end |
---|
| 917 | set(handles.jtext,'Visible','On') |
---|
| 918 | set(handles.first_j,'Visible','On') |
---|
| 919 | set(handles.last_j,'Visible','On') |
---|
| 920 | set(handles.incr_j,'Visible','On') |
---|
| 921 | set(handles.nb_field2,'Visible','On') |
---|
| 922 | set(handles.ref_j,'Visible','On') |
---|
| 923 | if nbfield > 1 |
---|
[2] | 924 | set(handles.itext,'Visible','On') |
---|
| 925 | set(handles.first_i,'Visible','On') |
---|
| 926 | set(handles.last_i,'Visible','On') |
---|
| 927 | set(handles.incr_i,'Visible','On') |
---|
| 928 | set(handles.nb_field,'Visible','On') |
---|
| 929 | set(handles.ref_i,'Visible','On') |
---|
| 930 | else |
---|
| 931 | set(handles.itext,'Visible','Off') |
---|
| 932 | set(handles.first_i,'Visible','Off') |
---|
| 933 | set(handles.last_i,'Visible','Off') |
---|
| 934 | set(handles.incr_i,'Visible','Off') |
---|
| 935 | set(handles.nb_field,'Visible','Off') |
---|
| 936 | set(handles.ref_i,'Visible','Off') |
---|
| 937 | end |
---|
[112] | 938 | elseif isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 939 | for index=1:200%min(nbfield-1,200) |
---|
| 940 | displ_num(1,index)=0; |
---|
| 941 | displ_num(2,index)=0; |
---|
| 942 | displ_num(3,index)=-floor(index/2); |
---|
| 943 | displ_num(4,index)=ceil(index/2); |
---|
| 944 | end |
---|
| 945 | set(handles.itext,'Visible','On') |
---|
| 946 | set(handles.first_i,'Visible','On') |
---|
| 947 | set(handles.last_i,'Visible','On') |
---|
| 948 | set(handles.incr_i,'Visible','On') |
---|
| 949 | set(handles.nb_field,'Visible','On') |
---|
| 950 | set(handles.ref_i,'Visible','On') |
---|
| 951 | if nbfield2 > 1 |
---|
[2] | 952 | set(handles.jtext,'Visible','On') |
---|
| 953 | set(handles.first_j,'Visible','On') |
---|
| 954 | set(handles.last_j,'Visible','On') |
---|
| 955 | set(handles.incr_j,'Visible','On') |
---|
| 956 | set(handles.nb_field2,'Visible','On') |
---|
| 957 | set(handles.ref_j,'Visible','On') |
---|
[112] | 958 | else |
---|
[2] | 959 | set(handles.jtext,'Visible','Off') |
---|
| 960 | set(handles.first_j,'Visible','Off') |
---|
| 961 | set(handles.last_j,'Visible','Off') |
---|
| 962 | set(handles.incr_j,'Visible','Off') |
---|
| 963 | set(handles.nb_field2,'Visible','Off') |
---|
| 964 | set(handles.ref_j,'Visible','Off') |
---|
| 965 | end |
---|
| 966 | elseif isequal(mode,'displacement')%the pairs have the same indices |
---|
[112] | 967 | displ_num(1,1)=0; |
---|
| 968 | displ_num(2,1)=0; |
---|
| 969 | displ_num(3,1)=0; |
---|
| 970 | displ_num(4,1)=0; |
---|
| 971 | if nbfield > 1 |
---|
[2] | 972 | set(handles.itext,'Visible','On') |
---|
| 973 | set(handles.first_i,'Visible','On') |
---|
| 974 | set(handles.last_i,'Visible','On') |
---|
| 975 | set(handles.incr_i,'Visible','On') |
---|
| 976 | set(handles.nb_field,'Visible','On') |
---|
| 977 | set(handles.ref_i,'Visible','On') |
---|
| 978 | else |
---|
| 979 | set(handles.itext,'Visible','Off') |
---|
| 980 | set(handles.first_i,'Visible','Off') |
---|
| 981 | set(handles.last_i,'Visible','Off') |
---|
| 982 | set(handles.incr_i,'Visible','Off') |
---|
| 983 | set(handles.nb_field,'Visible','Off') |
---|
| 984 | set(handles.ref_i,'Visible','Off') |
---|
| 985 | end |
---|
| 986 | if nbfield2 > 1 |
---|
[112] | 987 | set(handles.jtext,'Visible','On') |
---|
| 988 | set(handles.first_j,'Visible','On') |
---|
| 989 | set(handles.last_j,'Visible','On') |
---|
| 990 | set(handles.incr_j,'Visible','On') |
---|
| 991 | set(handles.nb_field2,'Visible','On') |
---|
| 992 | set(handles.ref_j,'Visible','On') |
---|
[2] | 993 | else |
---|
| 994 | set(handles.jtext,'Visible','Off') |
---|
| 995 | set(handles.first_j,'Visible','Off') |
---|
| 996 | set(handles.last_j,'Visible','Off') |
---|
| 997 | set(handles.incr_j,'Visible','Off') |
---|
| 998 | set(handles.nb_field2,'Visible','Off') |
---|
| 999 | set(handles.ref_j,'Visible','Off') |
---|
| 1000 | end |
---|
[112] | 1001 | end |
---|
[282] | 1002 | set(handles.ListPairCiv1,'UserData',displ_num); |
---|
[2] | 1003 | find_netcpair_civ1(hObject, eventdata, handles) |
---|
| 1004 | find_netcpair_civ2(hObject, eventdata, handles) |
---|
| 1005 | |
---|
[12] | 1006 | %------------------------------------------------------------------------ |
---|
[282] | 1007 | % determine the menu for checkciv1 pairs depending on existing netcdf file at the middle of |
---|
[2] | 1008 | % the field series set by first_i, incr, last_i |
---|
[289] | 1009 | function find_netcpair_civ1(handles) |
---|
[12] | 1010 | %------------------------------------------------------------------------ |
---|
[2] | 1011 | set(gcf,'Pointer','watch') |
---|
| 1012 | %nomenclature types |
---|
[71] | 1013 | filebase=get(handles.RootName,'String'); |
---|
[2] | 1014 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
[273] | 1015 | browse=get(handles.RootName,'UserData'); |
---|
[282] | 1016 | compare_list=get(handles.ListCompareMode,'String'); |
---|
| 1017 | val=get(handles.ListCompareMode,'Value'); |
---|
[2] | 1018 | compare=compare_list{val}; |
---|
| 1019 | if strcmp(compare,'displacement') |
---|
| 1020 | mode='displacement'; |
---|
| 1021 | else |
---|
[282] | 1022 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 1023 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[273] | 1024 | if isempty(mode_list) |
---|
| 1025 | return |
---|
| 1026 | end |
---|
[2] | 1027 | mode=mode_list{mode_value}; |
---|
| 1028 | end |
---|
| 1029 | |
---|
| 1030 | % nomenclature type of the .nc files |
---|
| 1031 | nom_type_ima=[];%default |
---|
| 1032 | if isfield(browse,'nom_type_ima') |
---|
| 1033 | nom_type_ima=browse.nom_type_ima; |
---|
| 1034 | end |
---|
| 1035 | |
---|
[112] | 1036 | %determine nom_type_nc: |
---|
[2] | 1037 | nom_type_nc=[];%default |
---|
| 1038 | if isfield(browse,'nom_type_nc') |
---|
| 1039 | nom_type_nc=browse.nom_type_nc; |
---|
| 1040 | end |
---|
| 1041 | if isempty(nom_type_nc) |
---|
[112] | 1042 | [nom_type_nc]=nomtype2pair(nom_type_ima,isequal(mode,'series(Di)'),isequal(mode,'series(Dj)')); |
---|
[2] | 1043 | end |
---|
| 1044 | browse.nom_type_nc=nom_type_nc; |
---|
[273] | 1045 | set(handles.RootName,'UserData',browse) |
---|
[2] | 1046 | |
---|
| 1047 | %reads .nc subdirectoy and image numbers from the interface |
---|
[289] | 1048 | subdir_civ1=get(handles.txt_SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
[45] | 1049 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[2] | 1050 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
| 1051 | ref_j=0; |
---|
| 1052 | else |
---|
[45] | 1053 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
[2] | 1054 | end |
---|
[273] | 1055 | time=get(handles.ImaDoc,'UserData');%get the set of times |
---|
[2] | 1056 | if isempty(time) |
---|
| 1057 | time=[0 1]; |
---|
[112] | 1058 | end |
---|
[71] | 1059 | dt_unit=1000;%default |
---|
[282] | 1060 | displ_num=get(handles.ListPairCiv1,'UserData'); |
---|
[2] | 1061 | |
---|
[112] | 1062 | %eliminate the first pairs inconsistent with the position |
---|
| 1063 | if isempty(displ_num) |
---|
| 1064 | nbpair=0; |
---|
| 1065 | else |
---|
[2] | 1066 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
| 1067 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 1068 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1069 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
| 1070 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1071 | end |
---|
[112] | 1072 | end |
---|
[2] | 1073 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
| 1074 | |
---|
[282] | 1075 | %look for existing processed pairs involving the field at the middle of the series if checkciv1 will not |
---|
[2] | 1076 | % be performed, while the result is needed for next steps. |
---|
| 1077 | displ_pair={''}; |
---|
[273] | 1078 | select=ones(size(1:nbpair));%flag for displayed pairs =1 for display |
---|
[2] | 1079 | testpair=0; |
---|
[282] | 1080 | % case with no checkciv1 operation, netcdf files need to exist for reading |
---|
| 1081 | if get(handles.CheckCiv1,'Value')==0 % |
---|
[112] | 1082 | if ~exist(fullfile(filepath,subdir_civ1,ext_dir),'dir') |
---|
| 1083 | msgbox_uvmat('ERROR',['no civ1 file available: subdirectory ' subdir_civ1 ' does not exist']); |
---|
[282] | 1084 | set(handles.ListPairCiv1,'String',{}); |
---|
[112] | 1085 | return |
---|
[2] | 1086 | end |
---|
[112] | 1087 | for ipair=1:nbpair |
---|
[2] | 1088 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
[112] | 1089 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
[273] | 1090 | select(ipair)=exist(filename,'file')==2;% put flag to 0 if the file does not exist |
---|
| 1091 | end |
---|
| 1092 | % case of no displayed pair |
---|
| 1093 | if isequal(select,zeros(size(1:nbpair))) |
---|
| 1094 | if isfield(browse,'incr_pair') && ~isequal(browse.incr_pair,[0 0]) |
---|
[2] | 1095 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
| 1096 | num_i2=ref_i+ceil(browse.incr_pair(1)/2); |
---|
| 1097 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
| 1098 | num_j2=ref_j+ceil(browse.incr_pair(2)/2); |
---|
| 1099 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ1); |
---|
| 1100 | select(1)=exist(filename,'file')==2; |
---|
| 1101 | testpair=1; |
---|
| 1102 | else |
---|
[112] | 1103 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
[2] | 1104 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1]); |
---|
| 1105 | else |
---|
| 1106 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ1]); |
---|
| 1107 | end |
---|
[282] | 1108 | set(handles.ListPairCiv1,'String',{''}); |
---|
[112] | 1109 | %COMPLETER CAS STEREO |
---|
[2] | 1110 | return |
---|
| 1111 | end |
---|
| 1112 | end |
---|
| 1113 | end |
---|
| 1114 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
| 1115 | if testpair |
---|
[73] | 1116 | displ_pair{1}=['Di= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
[2] | 1117 | else |
---|
[73] | 1118 | for ipair=1:nbpair |
---|
| 1119 | if select(ipair) |
---|
| 1120 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1121 | 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 |
---|
| 1122 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1123 | else |
---|
| 1124 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1125 | end |
---|
| 1126 | end |
---|
| 1127 | end |
---|
[2] | 1128 | end |
---|
| 1129 | elseif isequal(mode,'series(Dj)')%|isequal(mode,'st_series(Dj)')% series on the j index |
---|
| 1130 | if testpair |
---|
[112] | 1131 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
[2] | 1132 | else |
---|
[112] | 1133 | for ipair=1:nbpair |
---|
| 1134 | if select(ipair) |
---|
| 1135 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1136 | 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 |
---|
| 1137 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1138 | end |
---|
| 1139 | elseif testpair |
---|
| 1140 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(2)/2)) '|' num2str(ceil(browse.incr_pair(2)/2))]; |
---|
| 1141 | else |
---|
| 1142 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1143 | end |
---|
| 1144 | end |
---|
| 1145 | end |
---|
[2] | 1146 | elseif isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2')%case of pairs |
---|
| 1147 | for ipair=1:nbpair |
---|
| 1148 | if select(ipair) |
---|
[112] | 1149 | 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 |
---|
| 1150 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
| 1151 | ' :dt= ' num2str(dt*1000)]; |
---|
| 1152 | else |
---|
| 1153 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1154 | end |
---|
| 1155 | end |
---|
[2] | 1156 | elseif isequal(mode,'displacement') |
---|
[112] | 1157 | displ_pair={'Di=Dj=0'}; |
---|
| 1158 | end |
---|
[282] | 1159 | set(handles.ListPairCiv1,'String',displ_pair'); |
---|
[229] | 1160 | ichoice=find(select,1); |
---|
[45] | 1161 | if (isempty(ichoice) || ichoice < 1); ichoice=1; end; |
---|
[282] | 1162 | initial=get(handles.ListPairCiv1,'Value');%initial choice of pair |
---|
[112] | 1163 | if initial>nbpair |
---|
[282] | 1164 | set(handles.ListPairCiv1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
[45] | 1165 | end |
---|
| 1166 | if numel(select)>=initial && ~isequal(select(initial),1) |
---|
[282] | 1167 | set(handles.ListPairCiv1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
[2] | 1168 | end |
---|
[45] | 1169 | |
---|
[282] | 1170 | %set(handles.ListPairCiv2,'String',displ_pair'); |
---|
| 1171 | initial=get(handles.ListPairCiv2,'Value'); |
---|
[2] | 1172 | if initial>length(displ_pair')%|~isequal(select(initial),1) |
---|
| 1173 | if ichoice <= length(displ_pair') |
---|
[282] | 1174 | set(handles.ListPairCiv2,'Value',ichoice);% same pair proposed by default for civ2 |
---|
[2] | 1175 | else |
---|
[282] | 1176 | set(handles.ListPairCiv2,'Value',1);% same pair proposed by default for civ2 |
---|
[2] | 1177 | end |
---|
| 1178 | end |
---|
[282] | 1179 | set(handles.ListPairCiv2,'String',displ_pair'); |
---|
[2] | 1180 | set(gcf,'Pointer','arrow') |
---|
[12] | 1181 | |
---|
| 1182 | %------------------------------------------------------------------------ |
---|
[282] | 1183 | % determine the menu for checkciv2 pairs depending on the existing netcdf file at the |
---|
[112] | 1184 | %middle of the series set by first_i, incr, last_i |
---|
[289] | 1185 | function find_netcpair_civ2(handles) |
---|
[12] | 1186 | %------------------------------------------------------------------------ |
---|
[2] | 1187 | set(gcf,'Pointer','watch') |
---|
| 1188 | %nomenclature types |
---|
[71] | 1189 | filebase=get(handles.RootName,'String'); |
---|
[2] | 1190 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
[273] | 1191 | browse=get(handles.RootName,'UserData'); |
---|
[282] | 1192 | compare_list=get(handles.ListCompareMode,'String'); |
---|
| 1193 | val=get(handles.ListCompareMode,'Value'); |
---|
[2] | 1194 | compare=compare_list{val}; |
---|
| 1195 | if strcmp(compare,'displacement') |
---|
| 1196 | mode='displacement'; |
---|
| 1197 | else |
---|
[282] | 1198 | mode_list=get(handles.ListPairMode,'String'); |
---|
[270] | 1199 | if isempty(mode_list) |
---|
| 1200 | msgbox_uvmat('ERROR','please enter an input image or netcdf file') |
---|
| 1201 | return |
---|
| 1202 | end |
---|
[282] | 1203 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[2] | 1204 | mode=mode_list{mode_value}; |
---|
| 1205 | end |
---|
| 1206 | |
---|
| 1207 | % nomenclature type of the .nc files |
---|
| 1208 | nom_type_ima='ima_num';%default |
---|
| 1209 | if isfield(browse,'nom_type_ima') |
---|
| 1210 | nom_type_ima=browse.nom_type_ima; |
---|
| 1211 | end |
---|
| 1212 | nom_type_nc='_i1-i2';%default |
---|
| 1213 | if isfield(browse,'nom_type_nc') |
---|
| 1214 | nom_type_nc=browse.nom_type_nc; |
---|
| 1215 | end |
---|
[94] | 1216 | 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] | 1217 | nom_type_nc='netc_old';%nom_type for the netcdf files |
---|
[94] | 1218 | elseif isequal(nom_type_ima,'none')||isequal(nom_type_nc,'none') |
---|
[2] | 1219 | nom_type_nc='none'; |
---|
[94] | 1220 | elseif isequal(nom_type_ima,'avi')||isequal(nom_type_ima,'_i')||isequal(nom_type_ima,'ima_num')||isequal(nom_type_nc,'_i1-i2') |
---|
[112] | 1221 | nom_type_nc='_i1-i2'; |
---|
[2] | 1222 | else |
---|
| 1223 | if isequal(mode,'series(Di)')%|isequal(mode,'st_series(Di)') |
---|
| 1224 | nom_type_nc='_i1-i2_j'; % PIV in volume |
---|
| 1225 | else |
---|
| 1226 | nom_type_nc='_i_j1-j2'; |
---|
[112] | 1227 | end |
---|
[2] | 1228 | end |
---|
| 1229 | browse.nom_type_nc=nom_type_nc; |
---|
[273] | 1230 | set(handles.RootName,'UserData',browse) |
---|
[2] | 1231 | |
---|
| 1232 | %reads .nc subdirectory and image numbers from the interface |
---|
[289] | 1233 | subdir_civ1=get(handles.txt_SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
| 1234 | subdir_civ2=get(handles.txt_SubdirCiv2,'String');%subdirectory subdir_civ2 for the netcdf data |
---|
[45] | 1235 | % first_i=str2num(get(handles.first_i,'String')); |
---|
| 1236 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 1237 | % incr=str2num(get(handles.incr_i,'String')); |
---|
| 1238 | % num1=first_i:incr:last_i; |
---|
| 1239 | % if isempty(num1) |
---|
[282] | 1240 | % set(handles.ListPairCiv2,'Value',1); |
---|
| 1241 | % set(handles.ListPairCiv2,'String',{''}); |
---|
[45] | 1242 | % return |
---|
| 1243 | % end |
---|
[273] | 1244 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[2] | 1245 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
| 1246 | ref_j=0; |
---|
| 1247 | else |
---|
[273] | 1248 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
[2] | 1249 | end |
---|
[273] | 1250 | time=get(handles.ImaDoc,'UserData'); %get the set of times |
---|
[2] | 1251 | if isempty(time) |
---|
| 1252 | time=[0 1];%default |
---|
| 1253 | end |
---|
[71] | 1254 | %dt_unit=str2num(get(handles.dt,'String'));% used when there is no image documentation file |
---|
[73] | 1255 | %dt_unit=1000; |
---|
[282] | 1256 | displ_num=get(handles.ListPairCiv1,'UserData'); |
---|
[2] | 1257 | |
---|
| 1258 | |
---|
[112] | 1259 | %eliminate the first pairs inconsistent with the position |
---|
[2] | 1260 | if isempty(displ_num) |
---|
| 1261 | nbpair=0; |
---|
| 1262 | else |
---|
| 1263 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
[112] | 1264 | if isequal(mode,'series(Di)')% | isequal(mode,'st_series(Di)') |
---|
[2] | 1265 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
[112] | 1266 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
[2] | 1267 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
| 1268 | end |
---|
| 1269 | end |
---|
| 1270 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
| 1271 | |
---|
[282] | 1272 | %look for existing processed pairs involving the field at the middle of the series if checkciv1 will not |
---|
[2] | 1273 | % be performed, while the result is needed for next steps. |
---|
| 1274 | displ_pair={''}; %default |
---|
| 1275 | select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs |
---|
[282] | 1276 | if get(handles.CheckCiv2,'Value')==0 & get(handles.CheckCiv1,'Value')==0 & get(handles.CheckFix1,'Value')==0 & get(handles.CheckPatch1,'Value')==0%&... |
---|
[112] | 1277 | if ~exist(fullfile(filepath,subdir_civ2,ext_dir),'dir') |
---|
| 1278 | errordlg(['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist']) |
---|
[282] | 1279 | set(handles.ListPairCiv2,'Value',1); |
---|
| 1280 | set(handles.ListPairCiv2,'String',{''}); |
---|
[112] | 1281 | return |
---|
[2] | 1282 | end |
---|
[112] | 1283 | for ipair=1:nbpair |
---|
[2] | 1284 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
[112] | 1285 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
[2] | 1286 | select(ipair)=exist(filename,'file')==2; |
---|
| 1287 | end |
---|
| 1288 | if isequal(select,zeros(size(1:nbpair))) |
---|
[112] | 1289 | if isfield(browse,'incr_pair') |
---|
[2] | 1290 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
| 1291 | num_i2=ref_i+floor((browse.incr_pair(1)+1)/2); |
---|
| 1292 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
| 1293 | num_j2=ref_j+floor((browse.incr_pair(2)+1)/2); |
---|
| 1294 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ2); |
---|
| 1295 | select(1)=exist(filename,'file')==2; |
---|
| 1296 | else |
---|
[112] | 1297 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
[2] | 1298 | errordlg(['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2]) |
---|
| 1299 | else |
---|
| 1300 | errordlg(['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2]) |
---|
| 1301 | end |
---|
[282] | 1302 | set(handles.ListPairCiv2,'Value',1); |
---|
| 1303 | set(handles.ListPairCiv2,'String',{''}); |
---|
[2] | 1304 | return |
---|
| 1305 | end |
---|
| 1306 | end |
---|
| 1307 | end |
---|
[112] | 1308 | if isequal(mode,'series(Di)') % | isequal(mode,'st_series(Di)') |
---|
| 1309 | for ipair=1:nbpair |
---|
| 1310 | if select(ipair) |
---|
| 1311 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
[2] | 1312 | 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 |
---|
| 1313 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
[112] | 1314 | end |
---|
| 1315 | else |
---|
| 1316 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1317 | end |
---|
| 1318 | end |
---|
[2] | 1319 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') % series on the j index |
---|
[112] | 1320 | for ipair=1:nbpair |
---|
| 1321 | if select(ipair) |
---|
| 1322 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
| 1323 | 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 |
---|
| 1324 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
| 1325 | end |
---|
| 1326 | else |
---|
| 1327 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1328 | end |
---|
| 1329 | end |
---|
[2] | 1330 | elseif isequal(mode,'pair j1-j2')% | isequal(mode,'st_pair j1-j2') %case of pairs |
---|
| 1331 | for ipair=1:nbpair |
---|
| 1332 | if select(ipair) |
---|
[112] | 1333 | 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 |
---|
| 1334 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
| 1335 | ' :dt= ' num2str(dt*1000)]; |
---|
| 1336 | else |
---|
| 1337 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
| 1338 | end |
---|
| 1339 | end |
---|
[2] | 1340 | elseif isequal(mode,'displacement') |
---|
[112] | 1341 | displ_pair={'Di=Dj=0'}; |
---|
| 1342 | end |
---|
[282] | 1343 | val=get(handles.ListPairCiv2,'Value'); |
---|
[229] | 1344 | ichoice=find(select,1); |
---|
[137] | 1345 | if (isempty(ichoice) || ichoice < 1); ichoice=1; end; |
---|
[282] | 1346 | if get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0 |
---|
[2] | 1347 | val=ichoice;% first valid pair proposed by default in the menu |
---|
| 1348 | end |
---|
| 1349 | if val>length(displ_pair') |
---|
[282] | 1350 | set(handles.ListPairCiv2,'Value',1);% first valid pair proposed by default in the menu |
---|
[2] | 1351 | else |
---|
[282] | 1352 | set(handles.ListPairCiv2,'Value',val); |
---|
[2] | 1353 | end |
---|
[282] | 1354 | set(handles.ListPairCiv2,'String',displ_pair'); |
---|
[12] | 1355 | set(gcf,'Pointer','arrow') |
---|
[2] | 1356 | |
---|
| 1357 | |
---|
[41] | 1358 | |
---|
[227] | 1359 | |
---|
[12] | 1360 | %------------------------------------------------------------------------ |
---|
[282] | 1361 | % --- Executes on selection change in ListPairCiv1. |
---|
| 1362 | function ListPairCiv1_Callback(hObject, eventdata, handles) |
---|
[12] | 1363 | %------------------------------------------------------------------------ |
---|
[282] | 1364 | %reproduce by default the chosen pair in the checkciv2 menu |
---|
| 1365 | list_pair=get(handles.ListPairCiv1,'String');%get the menu of image pairs |
---|
| 1366 | index_pair=get(handles.ListPairCiv1,'Value'); |
---|
| 1367 | displ_num=get(handles.ListPairCiv1,'UserData'); |
---|
[137] | 1368 | % num_a=displ_num(1,index_pair); |
---|
| 1369 | % num_b=displ_num(2,index_pair); |
---|
[282] | 1370 | list_pair2=get(handles.ListPairCiv2,'String');%get the menu of image pairs |
---|
[2] | 1371 | if index_pair<=length(list_pair2) |
---|
[282] | 1372 | set(handles.ListPairCiv2,'Value',index_pair); |
---|
[2] | 1373 | end |
---|
| 1374 | |
---|
[112] | 1375 | %update first_i and last_i according to the chosen image pairs |
---|
[282] | 1376 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 1377 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[2] | 1378 | mode=mode_list{mode_value}; |
---|
| 1379 | if isequal(mode,'series(Di)') |
---|
[137] | 1380 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 1381 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 1382 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
[2] | 1383 | num1=first_i:incr_i:last_i; |
---|
[137] | 1384 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 1385 | if ~isnan(lastfield) |
---|
[229] | 1386 | test_find=(num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
| 1387 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield); |
---|
| 1388 | num1=num1(test_find); |
---|
[2] | 1389 | end |
---|
| 1390 | set(handles.first_i,'String',num2str(num1(1))); |
---|
| 1391 | set(handles.last_i,'String',num2str(num1(end))); |
---|
| 1392 | elseif isequal(mode,'series(Dj)') |
---|
[137] | 1393 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 1394 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 1395 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[2] | 1396 | num_j=first_j:incr_j:last_j; |
---|
[137] | 1397 | lastfield2=str2double(get(handles.nb_field2,'String')); |
---|
| 1398 | if ~isnan(lastfield2) |
---|
[229] | 1399 | test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 1400 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2); |
---|
| 1401 | num1=num_j(test_find); |
---|
[2] | 1402 | end |
---|
| 1403 | set(handles.first_j,'String',num2str(num1(1))); |
---|
| 1404 | set(handles.last_j,'String',num2str(num1(end))); |
---|
[112] | 1405 | end |
---|
[2] | 1406 | |
---|
[12] | 1407 | %------------------------------------------------------------------------ |
---|
[282] | 1408 | % --- Executes on selection change in ListPairCiv2. |
---|
| 1409 | function ListPairCiv2_Callback(hObject, eventdata, handles) |
---|
[12] | 1410 | %------------------------------------------------------------------------ |
---|
[282] | 1411 | index_pair=get(handles.ListPairCiv2,'Value');%get the selected position index in the menu |
---|
[2] | 1412 | |
---|
[112] | 1413 | %update first_i and last_i according to the chosen image pairs |
---|
[282] | 1414 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 1415 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[2] | 1416 | mode=mode_list{mode_value}; |
---|
| 1417 | if isequal(mode,'series(Di)') |
---|
[137] | 1418 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 1419 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 1420 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
[2] | 1421 | num1=first_i:incr_i:last_i; |
---|
[137] | 1422 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 1423 | if ~isnan(lastfield) |
---|
[229] | 1424 | test_find=(num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
| 1425 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield); |
---|
| 1426 | num1=num1(test_find); |
---|
[2] | 1427 | end |
---|
| 1428 | set(handles.first_i,'String',num2str(num1(1))); |
---|
| 1429 | set(handles.last_i,'String',num2str(num1(end))); |
---|
| 1430 | elseif isequal(mode,'series(Dj)') |
---|
[137] | 1431 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 1432 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 1433 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[2] | 1434 | num_j=first_j:incr_j:last_j; |
---|
[137] | 1435 | lastfield2=str2double(get(handles.nb_field2,'String')); |
---|
| 1436 | if ~isnan(lastfield2) |
---|
[229] | 1437 | test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
| 1438 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2); |
---|
| 1439 | num1=num_j(test_find); |
---|
[2] | 1440 | end |
---|
| 1441 | set(handles.first_j,'String',num2str(num1(1))); |
---|
| 1442 | set(handles.last_j,'String',num2str(num1(end))); |
---|
[112] | 1443 | end |
---|
[2] | 1444 | |
---|
[177] | 1445 | %------------------------------------------------------------------------ |
---|
| 1446 | % --- Executes on button press in RUN: processing on local computer |
---|
[67] | 1447 | function RUN_Callback(hObject, eventdata, handles) |
---|
| 1448 | %------------------------------------------------------------------------ |
---|
[73] | 1449 | set(handles.RUN, 'Enable','Off') |
---|
| 1450 | set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[67] | 1451 | batch=0; |
---|
[229] | 1452 | errormsg=launch_jobs(hObject, eventdata, handles,batch); |
---|
[73] | 1453 | set(handles.RUN, 'Enable','On') |
---|
| 1454 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
[36] | 1455 | |
---|
[177] | 1456 | % start status callback to visualise results |
---|
[229] | 1457 | if ~isempty(errormsg) |
---|
| 1458 | display(errormsg) |
---|
| 1459 | msgbox_uvmat('ERROR',errormsg) |
---|
[282] | 1460 | elseif isfield(handles,'status') %&& ~isequal(get(handles.ListPairMode,'Value'),3) |
---|
[225] | 1461 | set(handles.status,'Value',1);%suppress status display |
---|
| 1462 | status_Callback(hObject, eventdata, handles) |
---|
[178] | 1463 | end |
---|
[177] | 1464 | |
---|
[12] | 1465 | %------------------------------------------------------------------------ |
---|
[2] | 1466 | % --- Executes on button press in BATCH: remote processing |
---|
| 1467 | function BATCH_Callback(hObject, eventdata, handles) |
---|
[177] | 1468 | % ----------------------------------------------------------------------- |
---|
[73] | 1469 | set(handles.BATCH, 'Enable','Off') |
---|
| 1470 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[67] | 1471 | batch=1; |
---|
[229] | 1472 | errormsg=launch_jobs(hObject, eventdata, handles, batch); |
---|
[73] | 1473 | set(handles.BATCH, 'Enable','On') |
---|
| 1474 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
[67] | 1475 | |
---|
[177] | 1476 | % start status callback to visualise results |
---|
[229] | 1477 | if ~isempty(errormsg) |
---|
| 1478 | display(errormsg) |
---|
| 1479 | msgbox_uvmat('ERROR',errormsg) |
---|
| 1480 | elseif isfield(handles,'status') |
---|
| 1481 | set(handles.status,'Value',1);%suppress status display |
---|
| 1482 | status_Callback(hObject, eventdata, handles) |
---|
[178] | 1483 | end |
---|
[227] | 1484 | |
---|
[67] | 1485 | %------------------------------------------------------------------------ |
---|
[133] | 1486 | % --- Lauch command called by RUN and BATCH: remote processing |
---|
[229] | 1487 | function errormsg=launch_jobs(hObject, eventdata, handles, batch) |
---|
[67] | 1488 | %----------------------------------------------------------------------- |
---|
[229] | 1489 | errormsg='';%default |
---|
[272] | 1490 | |
---|
[282] | 1491 | %%read the civ GUI |
---|
[289] | 1492 | Param=read_GUI(handles.civ); |
---|
[133] | 1493 | %% check the selected list of operations: |
---|
[289] | 1494 | operations={'Civ1','Fix1','Patch1','Civ2','Fix2','Patch2'}; |
---|
[282] | 1495 | box_test=[Param.CheckCiv1 Param.CheckFix1 Param.CheckPatch1 Param.CheckCiv2 Param.CheckFix2 Param.CheckPatch2]; |
---|
[284] | 1496 | |
---|
[180] | 1497 | index_first=find(box_test==1,1); |
---|
| 1498 | if isempty(index_first) |
---|
[229] | 1499 | errormsg='no selected operation'; |
---|
[2] | 1500 | return |
---|
| 1501 | end |
---|
[180] | 1502 | index_last=find(box_test==1,1,'last'); |
---|
[159] | 1503 | box_used=box_test(index_first : index_last); |
---|
[2] | 1504 | [box_missing,ind_missing]=min(box_used); |
---|
[180] | 1505 | if isequal(box_missing,0); %there is a missing step in the sequence of operations |
---|
[229] | 1506 | errormsg=['missing' cell2mat(operations(ind_missing))]; |
---|
[2] | 1507 | return |
---|
| 1508 | end |
---|
| 1509 | |
---|
[272] | 1510 | %% check mask if selecetd |
---|
| 1511 | %could be included in get_mask callback ? |
---|
[282] | 1512 | if isequal(get(handles.CheckMask,'Value'),1) |
---|
[276] | 1513 | maskname=get(handles.txt_MaskName,'String'); |
---|
[12] | 1514 | if ~exist(maskname,'file') |
---|
| 1515 | get_mask_civ1_Callback(hObject, eventdata, handles); |
---|
| 1516 | end |
---|
[2] | 1517 | end |
---|
[282] | 1518 | if isequal(get(handles.CheckMask,'Value'),1) |
---|
| 1519 | maskname=get(handles.txt_MaskName,'String'); |
---|
[12] | 1520 | if ~exist(maskname,'file') |
---|
| 1521 | get_mask_fix1_Callback(hObject, eventdata, handles); |
---|
| 1522 | end |
---|
[2] | 1523 | end |
---|
[282] | 1524 | if isequal(get(handles.CheckMask,'Value'),1) |
---|
[276] | 1525 | maskname=get(handles.txt_Mask,'String'); |
---|
[12] | 1526 | if ~exist(maskname,'file') |
---|
[112] | 1527 | get_mask_civ2_Callback(hObject, eventdata, handles); |
---|
[12] | 1528 | end |
---|
[2] | 1529 | end |
---|
[282] | 1530 | if isequal(get(handles.CheckMask,'Value'),1) |
---|
[287] | 1531 | maskname=get(handles.txt_MaskName,'String'); |
---|
[12] | 1532 | if ~exist(maskname,'file') |
---|
[112] | 1533 | get_mask_fix2_Callback(hObject, eventdata, handles); |
---|
[12] | 1534 | end |
---|
[2] | 1535 | end |
---|
| 1536 | |
---|
[177] | 1537 | %% reinitialise status callback |
---|
[178] | 1538 | if isfield(handles,'status') |
---|
[180] | 1539 | set(handles.status,'Value',0);%suppress status display |
---|
| 1540 | status_Callback(hObject, eventdata, handles) |
---|
[178] | 1541 | end |
---|
[133] | 1542 | |
---|
| 1543 | %% set the list of files and check them |
---|
| 1544 | display('checking the files...') |
---|
[227] | 1545 | [ref_i,ref_j,errormsg]=find_ref_indices(handles); |
---|
| 1546 | if ~isempty(errormsg) |
---|
| 1547 | return |
---|
| 1548 | end |
---|
[263] | 1549 | [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc,xx,yy,compare]=... |
---|
[273] | 1550 | set_civ_filenames(handles,ref_i,ref_j,box_test); |
---|
[274] | 1551 | % ADDED |
---|
| 1552 | [Rootbat,Filebat]=fileparts(filecell.nc.civ1{1,1});%output netcdf file (without extention) |
---|
| 1553 | %ADDED |
---|
[177] | 1554 | set(handles.civ,'UserData',filecell);%store for futur use of status callback |
---|
[137] | 1555 | if isempty(filecell)% (error message displayed in fct set_civ_filenames) |
---|
[133] | 1556 | return |
---|
| 1557 | end |
---|
| 1558 | nbfield=numel(num1_civ1); |
---|
| 1559 | nbslice=numel(num_a_civ1); |
---|
| 1560 | |
---|
[272] | 1561 | %% read the PARAM.xml file to get the binaries (and batch_mode if batch) |
---|
[276] | 1562 | path_civ=fileparts(which('civ')); %path to the source directory of uvmat |
---|
[112] | 1563 | xmlfile='PARAM.xml'; |
---|
[133] | 1564 | if exist(xmlfile,'file')% search parameter xml file in the whole matlab path |
---|
[54] | 1565 | t=xmltree(xmlfile); |
---|
[67] | 1566 | s=convert(t); |
---|
[272] | 1567 | else |
---|
| 1568 | errormsg=['no file ' xmlfile]; |
---|
| 1569 | return |
---|
[2] | 1570 | end |
---|
[272] | 1571 | |
---|
| 1572 | test_interp=0; %eviter les variables test_ (LG) |
---|
| 1573 | |
---|
[127] | 1574 | if batch |
---|
[67] | 1575 | if isfield(s,'BatchParam') |
---|
[284] | 1576 | Param.xml=s.BatchParam; |
---|
| 1577 | if isfield(Param.xml,'BatchMode') |
---|
| 1578 | batch_mode=Param.xml.BatchMode; |
---|
[257] | 1579 | if ~ismember(batch_mode,{'sge','oar'}) |
---|
| 1580 | errormsg=['batch mode ' batch_mode ' not supported by UVMAT']; |
---|
| 1581 | return |
---|
| 1582 | end |
---|
[67] | 1583 | end |
---|
| 1584 | else |
---|
[229] | 1585 | errormsg='no batch civ binaries defined in PARAM.xml'; |
---|
[67] | 1586 | return |
---|
| 1587 | end |
---|
[257] | 1588 | else % run |
---|
[67] | 1589 | if isfield(s,'RunParam') |
---|
[284] | 1590 | Param.xml=s.RunParam; |
---|
[67] | 1591 | else |
---|
[225] | 1592 | msgbox_uvmat('ERROR','no run civ binaries defined in PARAM.xml') |
---|
[67] | 1593 | return |
---|
| 1594 | end |
---|
[225] | 1595 | end |
---|
[238] | 1596 | |
---|
[272] | 1597 | %% check batch mode supported |
---|
| 1598 | if batch |
---|
| 1599 | switch batch_mode |
---|
| 1600 | case 'sge' |
---|
| 1601 | test_command='qstat'; |
---|
| 1602 | case 'oar' |
---|
[290] | 1603 | test_command='oarstat'; |
---|
[272] | 1604 | end |
---|
| 1605 | [s,w]=system(test_command); |
---|
| 1606 | if ~isequal(s,0) |
---|
| 1607 | msgbox_uvmat('ERROR',[batch_mode ' batch system not available']) |
---|
| 1608 | return |
---|
| 1609 | end |
---|
| 1610 | end |
---|
| 1611 | |
---|
| 1612 | %% check if the binaries exist |
---|
[273] | 1613 | if isequal(get(handles.Matlab,'checked'),'on') |
---|
| 1614 | CivMode='Matlab'; |
---|
| 1615 | else |
---|
| 1616 | CivMode='CivX'; |
---|
| 1617 | end |
---|
[280] | 1618 | binary_list={}; |
---|
[257] | 1619 | switch CivMode |
---|
[280] | 1620 | case 'CivX' |
---|
| 1621 | binary_list={'Civ1Bin','Civ2Bin','PatchBin','FixBin'}; |
---|
| 1622 | case 'CivAll' |
---|
[289] | 1623 | binary_list={'Civ'}; |
---|
[257] | 1624 | case 'Matlab' |
---|
| 1625 | if batch |
---|
[272] | 1626 | % vérifier Matlab installé sur le cluster |
---|
| 1627 | % difficile a faire a priori |
---|
[257] | 1628 | end |
---|
[225] | 1629 | end |
---|
[280] | 1630 | for bin_name=binary_list |
---|
[284] | 1631 | if isfield(Param.xml,bin_name{1}) |
---|
| 1632 | if ~exist(Param.xml.(bin_name{1}),'file')%look for the full path if the file name has been defined with a relative path in PARAM.xml |
---|
[289] | 1633 | fullname=fullfile(path_civ,Param.xml.(bin_name{1})); |
---|
[280] | 1634 | if exist(fullname,'file') |
---|
[284] | 1635 | Param.xml.(bin_name{1})=fullname; |
---|
[280] | 1636 | else |
---|
[284] | 1637 | msgbox_uvmat('ERROR',['Binary ' Param.xml.(bin_name{1}) ' defined in PARAM.xml does not exist']) |
---|
[280] | 1638 | return |
---|
| 1639 | end |
---|
| 1640 | else |
---|
[284] | 1641 | [path,name,ext]=fileparts(Param.xml.(bin_name{1})); |
---|
[280] | 1642 | currentdir=pwd; |
---|
| 1643 | cd(path); |
---|
| 1644 | binpath=pwd;%path of the binary |
---|
[284] | 1645 | Param.xml.(bin_name{1})=fullfile(binpath,[name ext]); |
---|
| 1646 | % display(Param.xml.(bin_name{1})); |
---|
[280] | 1647 | cd(currentdir); |
---|
| 1648 | end |
---|
| 1649 | |
---|
| 1650 | end |
---|
| 1651 | end |
---|
[2] | 1652 | |
---|
[272] | 1653 | display('files OK, processing...') |
---|
[2] | 1654 | |
---|
| 1655 | |
---|
[133] | 1656 | %% MAIN LOOP |
---|
[273] | 1657 | time=get(handles.ImaDoc,'UserData'); %get the set of times |
---|
[265] | 1658 | |
---|
[134] | 1659 | super_cmd=[]; |
---|
[269] | 1660 | batch_file_list=[]; |
---|
[265] | 1661 | |
---|
[2] | 1662 | for ifile=1:nbfield |
---|
| 1663 | for j=1:nbslice |
---|
[257] | 1664 | % initiate system command |
---|
| 1665 | switch CivMode |
---|
| 1666 | case 'CivX' |
---|
| 1667 | if isunix % check: necessaire aussi en RUN? |
---|
[272] | 1668 | cmd=['#!/bin/bash \n '... |
---|
| 1669 | '#$ -cwd \n '... |
---|
| 1670 | 'hostname && date \n '... |
---|
| 1671 | 'umask 002 \n'];%allow writting access to created files for user group |
---|
| 1672 | else |
---|
| 1673 | cmd=[]; |
---|
[257] | 1674 | end |
---|
| 1675 | case 'CivAll' |
---|
| 1676 | % if CivAll |
---|
| 1677 | CivAllxml=xmltree;% xml contents, all parameters |
---|
| 1678 | CivAllCmd=''; |
---|
| 1679 | CivAllxml=set(CivAllxml,1,'name','CivDoc'); |
---|
[2] | 1680 | end |
---|
[272] | 1681 | |
---|
| 1682 | |
---|
| 1683 | % define output file name |
---|
[282] | 1684 | if Param.CheckCiv2==1 || Param.CheckFix2==1 || Param.CheckPatch2==1 |
---|
[272] | 1685 | OutputFile=filecell.nc.civ2{ifile,j}; |
---|
| 1686 | else |
---|
| 1687 | OutputFile=filecell.nc.civ1{ifile,j}; |
---|
| 1688 | end |
---|
| 1689 | OutputFile=regexprep(OutputFile,'.nc',''); |
---|
[269] | 1690 | |
---|
[282] | 1691 | if Param.CheckCiv1 |
---|
[272] | 1692 | % read image-dependent parameters |
---|
[284] | 1693 | Param.Civ1.filename_ima_a=filecell.ima1.civ1{ifile,j}; |
---|
| 1694 | Param.Civ1.filename_ima_b=filecell.ima2.civ1{ifile,j}; |
---|
| 1695 | Param.Civ1.Dt=(time(num2_civ1(ifile),num_b_civ1(j))-time(num1_civ1(ifile),num_a_civ1(j))); |
---|
| 1696 | Param.Civ1.T0=((time(num2_civ1(ifile),num_b_civ1(j))+time(num1_civ1(ifile),num_a_civ1(j)))/2); |
---|
| 1697 | Param.Civ1.term_a=num2stra(num_a_civ1(j),nom_type_nc);%UTILITE? |
---|
| 1698 | Param.Civ1.term_b=num2stra(num_b_civ1(j),nom_type_nc);% |
---|
[285] | 1699 | Param.Civ1.pxcmx=1; %velocities are expressed in pixel dispalcement |
---|
| 1700 | Param.Civ1.pxcmy=1; |
---|
[284] | 1701 | |
---|
[285] | 1702 | A=imread(filecell.ima1.civ1{1,1});%read the first image to get the size |
---|
| 1703 | sizim=size(A); |
---|
| 1704 | Param.Civ1.npx=(sizim(2)); |
---|
| 1705 | Param.Civ1.npy=(sizim(1)); |
---|
| 1706 | %TODO : civ should not need npx and npy |
---|
[284] | 1707 | |
---|
[272] | 1708 | % read mask parameters |
---|
[284] | 1709 | if Param.Civ1.CheckMask % the lines below should be changed with the new gui |
---|
| 1710 | %matbe they when check_mask the Maskname is read |
---|
[285] | 1711 | if exist(Param.Civ1.MaskName,'file') |
---|
| 1712 | Param.Civ1.MaskFlag='y'; |
---|
[2] | 1713 | else |
---|
[285] | 1714 | maskbase=[filecell.filebase '_' Param.Civ1.MaskName]; % |
---|
[137] | 1715 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
[12] | 1716 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
[285] | 1717 | Param.Civ1.MaskName=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 1718 | if exist(Param.Civ1.MaskName,'file') |
---|
[284] | 1719 | Param.Civ1.maskflag='y'; |
---|
[12] | 1720 | else |
---|
[285] | 1721 | Param.Civ1.MaskName='noFile use default'; |
---|
| 1722 | Param.Civ1.MaskFlag='n'; |
---|
[12] | 1723 | end |
---|
[2] | 1724 | end |
---|
[272] | 1725 | else |
---|
[285] | 1726 | Param.Civ1.MaskName='noFile use default'; |
---|
| 1727 | Param.Civ1.MaskFlag='n'; |
---|
[2] | 1728 | end |
---|
[272] | 1729 | |
---|
[282] | 1730 | % read grid parameters= |
---|
[284] | 1731 | if Param.Civ1.CheckGrid |
---|
[285] | 1732 | Param.Civ1.GridFlag='y'; |
---|
| 1733 | if isequal(Param.Civ1.GridName(end-3:end),'grid') |
---|
| 1734 | nbslice_grid=str2double(Param.Civ1.GridName(1:end-4)); % |
---|
[137] | 1735 | if ~isnan(nbslice_grid) |
---|
[2] | 1736 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
[285] | 1737 | Param.Civ1.GridName=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 1738 | if ~exist(Param.Civ1.GridName,'file') |
---|
[112] | 1739 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
[2] | 1740 | end |
---|
[285] | 1741 | elseif ~exist(Param.Civ1.GridName,'file') |
---|
[2] | 1742 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
| 1743 | end |
---|
| 1744 | end |
---|
| 1745 | else |
---|
[285] | 1746 | Param.Civ1.GridName='noFile use default'; |
---|
| 1747 | Param.Civ1.GridFlag='n'; |
---|
[2] | 1748 | end |
---|
[257] | 1749 | |
---|
[285] | 1750 | % send command |
---|
[257] | 1751 | switch CivMode |
---|
| 1752 | case 'CivX' |
---|
[284] | 1753 | cmd=[cmd... |
---|
| 1754 | cmd_civ1(filecell.nc.civ1{ifile,j},Param) '\n']; |
---|
[257] | 1755 | case 'CivAll' |
---|
| 1756 | CivAllCmd=[CivAllCmd ' civ1 ']; |
---|
[284] | 1757 | str=CIV1_CMD_Unified(filecell.nc.civ1{ifile,j},'',Param.Civ1); |
---|
[257] | 1758 | fieldnames=fields(str); |
---|
| 1759 | [CivAllxml,uid_civ1]=add(CivAllxml,1,'element','civ1'); |
---|
| 1760 | for ilist=1:length(fieldnames) |
---|
| 1761 | val=eval(['str.' fieldnames{ilist}]); |
---|
| 1762 | if ischar(val) |
---|
| 1763 | [CivAllxml,uid_t]=add(CivAllxml,uid_civ1,'element',fieldnames{ilist}); |
---|
| 1764 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 1765 | end |
---|
[112] | 1766 | end |
---|
[2] | 1767 | end |
---|
| 1768 | end |
---|
| 1769 | |
---|
[282] | 1770 | if Param.CheckFix1 |
---|
[272] | 1771 | switch CivMode |
---|
[257] | 1772 | case 'CivX' |
---|
[285] | 1773 | cmd=[cmd... |
---|
| 1774 | cmd_fix(filecell.nc.civ1{ifile,j},Param,'Fix1') '\n']; |
---|
[257] | 1775 | case 'CivAll' |
---|
| 1776 | fix1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
[272] | 1777 | fix1.fi1=num2str(param.fix1.flagindex1(1)); |
---|
| 1778 | fix1.fi2=num2str(param.fix1.flagindex1(2)); |
---|
| 1779 | fix1.fi3=num2str(param.fix1.flagindex1(3)); |
---|
| 1780 | fix1.threshC=num2str(param.fix1.thresh_vecC1); |
---|
| 1781 | fix1.threshV=num2str(param.fix1.thresh_vel1); |
---|
[257] | 1782 | fieldnames=fields(fix1); |
---|
| 1783 | [CivAllxml,uid_fix1]=add(CivAllxml,1,'element','fix1'); |
---|
| 1784 | for ilist=1:length(fieldnames) |
---|
| 1785 | val=eval(['fix1.' fieldnames{ilist}]); |
---|
| 1786 | if ischar(val) |
---|
| 1787 | [CivAllxml,uid_t]=add(CivAllxml,uid_fix1,'element',fieldnames{ilist}); |
---|
| 1788 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 1789 | end |
---|
| 1790 | end |
---|
| 1791 | CivAllCmd=[CivAllCmd ' fix1 ']; |
---|
[112] | 1792 | end |
---|
| 1793 | end |
---|
| 1794 | |
---|
[282] | 1795 | %CheckPatch1 |
---|
| 1796 | if Param.CheckPatch1==1 |
---|
[257] | 1797 | switch CivMode |
---|
| 1798 | case 'CivX' |
---|
[286] | 1799 | cmd=[cmd... |
---|
| 1800 | cmd_patch(filecell.nc.civ1{ifile,j},Param,'Patch1') '\n']; |
---|
[257] | 1801 | case 'CivAll' |
---|
| 1802 | patch1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 1803 | patch1.nopt=subdomain_patch1; |
---|
| 1804 | patch1.maxdiff=thresh_patch1; |
---|
| 1805 | patch1.ro=rho_patch1; |
---|
| 1806 | test_grid=get(handles.get_gridpatch1,'Value'); |
---|
| 1807 | if test_grid |
---|
| 1808 | patch1.gridflag='y'; |
---|
| 1809 | gridname=get(handles.grid_patch1,'String'); |
---|
| 1810 | if isequal(gridname(end-3:end),'grid') |
---|
| 1811 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 1812 | if ~isnan(nbslice_grid) |
---|
| 1813 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
| 1814 | patch1.gridPatch=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 1815 | if ~exist(patch1.gridPatch,'file') |
---|
| 1816 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
| 1817 | end |
---|
| 1818 | elseif exist(gridname,'file') |
---|
| 1819 | patch1.gridPatch=gridname; |
---|
| 1820 | else |
---|
[112] | 1821 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
| 1822 | end |
---|
[2] | 1823 | end |
---|
[257] | 1824 | else |
---|
| 1825 | patch1.gridPatch='none'; |
---|
| 1826 | patch1.gridflag='n'; |
---|
| 1827 | patch1.m=nx_patch1; |
---|
| 1828 | patch1.n=ny_patch1; |
---|
[2] | 1829 | end |
---|
[257] | 1830 | patch1.convectFlow='n'; |
---|
| 1831 | fieldnames=fields(patch1); |
---|
| 1832 | [CivAllxml,uid_patch1]=add(CivAllxml,1,'element','patch1'); |
---|
| 1833 | for ilist=1:length(fieldnames) |
---|
| 1834 | val=eval(['patch1.' fieldnames{ilist}]); |
---|
| 1835 | if ischar(val) |
---|
| 1836 | [CivAllxml,uid_t]=add(CivAllxml,uid_patch1,'element',fieldnames{ilist}); |
---|
| 1837 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 1838 | end |
---|
[112] | 1839 | end |
---|
[257] | 1840 | CivAllCmd=[CivAllCmd ' patch1 ']; |
---|
[112] | 1841 | end |
---|
[2] | 1842 | end |
---|
[282] | 1843 | if Param.CheckCiv2==1 |
---|
[290] | 1844 | Param.Civ2.filename_ima_a=filecell.ima1.civ2{ifile,j}; |
---|
| 1845 | Param.Civ2.filename_ima_b=filecell.ima2.civ2{ifile,j}; |
---|
| 1846 | Param.Civ2.Dt=num2str(time(num2_civ2(ifile),num_b_civ2(j))-time(num1_civ2(ifile),num_a_civ2(j))); |
---|
| 1847 | Param.Civ2.T0=num2str((time(num2_civ1(ifile),num_b_civ2(j))+time(num1_civ2(ifile),num_a_civ2(j)))/2); |
---|
| 1848 | Param.Civ2.term_a=num2stra(num_a_civ2(j),nom_type_nc); |
---|
| 1849 | Param.Civ2.term_b=num2stra(num_b_civ2(j),nom_type_nc); |
---|
| 1850 | Param.Civ2.filename_nc1=filecell.nc.civ1{ifile,j}; |
---|
| 1851 | Param.Civ2.filename_nc1(end-2:end)=[]; % remove '.nc' |
---|
| 1852 | Param.Civ2.pxcmx=1; %velocities are expressed in pixel dispalcement |
---|
| 1853 | Param.Civ2.pxcmy=1; |
---|
[287] | 1854 | if Param.Civ2.CheckMask |
---|
[276] | 1855 | maskdispl=get(handles.txt_Mask,'String'); |
---|
[12] | 1856 | if exist(maskdispl,'file') |
---|
[290] | 1857 | Param.Civ2.MaskName=maskdispl; |
---|
| 1858 | Param.Civ2.MaskFlag='y'; |
---|
[2] | 1859 | else |
---|
[136] | 1860 | maskbase=[filecell.filebase '_' maskdispl]; % |
---|
[137] | 1861 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
[12] | 1862 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
[290] | 1863 | Param.Civ2.MaskName=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
| 1864 | if exist(Param.Civ2.MaskName,'file') |
---|
| 1865 | Param.Civ2.MaskFlag='y'; |
---|
[12] | 1866 | else |
---|
[290] | 1867 | Param.Civ2.MaskName='noFile use default'; |
---|
| 1868 | Param.Civ2.MaskFlag='n'; |
---|
[12] | 1869 | end |
---|
[2] | 1870 | end |
---|
[287] | 1871 | else |
---|
[290] | 1872 | Param.Civ2.MaskName='noFile use default'; |
---|
| 1873 | Param.Civ2.MaskFlag='n'; |
---|
[2] | 1874 | end |
---|
[276] | 1875 | gridname=get(handles.txt_GridName,'String'); |
---|
[2] | 1876 | if numel(gridname)>=4 && isequal(gridname(end-3:end),'grid') |
---|
[137] | 1877 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 1878 | if ~isnan(nbslice_grid) |
---|
[290] | 1879 | Param.Civ2.GridFlag='y'; |
---|
[2] | 1880 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
[290] | 1881 | Param.Civ2.GridName=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 1882 | if exist(Param.Civ2.GridName,'file') |
---|
| 1883 | Param.Civ2.GridFlag='y'; |
---|
[2] | 1884 | else |
---|
[290] | 1885 | Param.Civ2.GridName='noFile use default'; |
---|
| 1886 | Param.Civ2.GridFlag='n'; |
---|
[2] | 1887 | end |
---|
| 1888 | elseif exist(gridname,'file') |
---|
[290] | 1889 | Param.Civ2.GridFlag='y'; |
---|
[2] | 1890 | else |
---|
[290] | 1891 | Param.Civ2.GridName='noFile use default'; |
---|
| 1892 | Param.Civ2.GridFlag='n'; |
---|
[2] | 1893 | end |
---|
[290] | 1894 | else |
---|
| 1895 | Param.Civ2.GridName='noFile use default'; |
---|
| 1896 | Param.Civ2.GridFlag='n'; |
---|
[2] | 1897 | end |
---|
[290] | 1898 | A=imread(filecell.ima1.civ2{1,1});%read the first image to get the size |
---|
| 1899 | sizim=size(A); |
---|
| 1900 | Param.Civ2.npx=(sizim(2)); |
---|
| 1901 | Param.Civ2.npy=(sizim(1)); |
---|
| 1902 | |
---|
[257] | 1903 | switch CivMode |
---|
| 1904 | case 'CivX' |
---|
[290] | 1905 | cmd=[cmd... |
---|
| 1906 | cmd_civ2(filecell.nc.civ2{ifile,j},Param) '\n']; |
---|
[257] | 1907 | case 'CivAll' |
---|
| 1908 | CivAllCmd=[CivAllCmd ' civ2 ']; |
---|
[290] | 1909 | str=CIV2_CMD_Unified(filecell.nc.civ2{ifile,j},'',Param.Civ2); |
---|
[257] | 1910 | fieldnames=fields(str); |
---|
| 1911 | [CivAllxml,uid_civ2]=add(CivAllxml,1,'element','civ2'); |
---|
| 1912 | for ilist=1:length(fieldnames) |
---|
| 1913 | val=eval(['str.' fieldnames{ilist}]); |
---|
| 1914 | if ischar(val) |
---|
| 1915 | [CivAllxml,uid_t]=add(CivAllxml,uid_civ2,'element',fieldnames{ilist}); |
---|
| 1916 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 1917 | end |
---|
[2] | 1918 | end |
---|
| 1919 | end |
---|
[112] | 1920 | end |
---|
| 1921 | |
---|
[282] | 1922 | % CheckFix2 |
---|
| 1923 | if Param.CheckFix2==1 |
---|
[257] | 1924 | switch CivMode |
---|
| 1925 | case 'CivX' |
---|
[291] | 1926 | cmd=[cmd... |
---|
| 1927 | cmd_fix(filecell.nc.civ2{ifile,j},Param,'Fix2') '\n']; |
---|
[257] | 1928 | case 'CivAll' |
---|
| 1929 | fix2.inputFileName=filecell.nc.civ2{ifile,j} ; |
---|
| 1930 | fix2.fi1=num2str(flagindex2(1)); |
---|
| 1931 | fix2.fi2=num2str(flagindex2(2)); |
---|
| 1932 | fix2.fi3=num2str(flagindex2(3)); |
---|
| 1933 | fix2.threshC=num2str(thresh_vec2C); |
---|
| 1934 | fix2.threshV=num2str(thresh_vel2); |
---|
| 1935 | fieldnames=fields(fix2); |
---|
| 1936 | [CivAllxml,uid_fix2]=add(CivAllxml,1,'element','fix2'); |
---|
| 1937 | for ilist=1:length(fieldnames) |
---|
| 1938 | val=eval(['fix2.' fieldnames{ilist}]); |
---|
| 1939 | if ischar(val) |
---|
| 1940 | [CivAllxml,uid_t]=add(CivAllxml,uid_fix2,'element',fieldnames{ilist}); |
---|
| 1941 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 1942 | end |
---|
| 1943 | end |
---|
| 1944 | CivAllCmd=[CivAllCmd ' fix2 ']; |
---|
[112] | 1945 | end |
---|
| 1946 | end |
---|
| 1947 | |
---|
[282] | 1948 | %CheckPatch2 |
---|
| 1949 | if Param.CheckPatch2==1 |
---|
[257] | 1950 | switch CivMode |
---|
| 1951 | case 'CivX' |
---|
[291] | 1952 | cmd=[cmd... |
---|
| 1953 | cmd_patch(filecell.nc.civ1{ifile,j},Param,'Patch2') '\n']; |
---|
[257] | 1954 | case 'CivAll' |
---|
| 1955 | patch2.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
| 1956 | patch2.nopt=subdomain_patch2; |
---|
| 1957 | patch2.maxdiff=thresh_patch2; |
---|
| 1958 | patch2.ro=rho_patch2; |
---|
| 1959 | test_grid=get(handles.get_gridpatch2,'Value'); |
---|
| 1960 | if test_grid |
---|
| 1961 | patch2.gridflag='y'; |
---|
| 1962 | gridname=get(handles.grid_patch2,'String'); |
---|
| 1963 | if isequal(gridname(end-3:end),'grid') |
---|
| 1964 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
| 1965 | if ~isnan(nbslice_grid) |
---|
| 1966 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
| 1967 | patch2.gridPatch=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
| 1968 | if ~exist(patch2.gridPatch,'file') |
---|
| 1969 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
| 1970 | end |
---|
| 1971 | elseif exist(gridname,'file') |
---|
| 1972 | patch2.gridPatch=gridname; |
---|
| 1973 | else |
---|
[112] | 1974 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
[12] | 1975 | end |
---|
[2] | 1976 | end |
---|
[257] | 1977 | else |
---|
| 1978 | patch2.gridPatch='none'; |
---|
| 1979 | patch2.gridflag='n'; |
---|
| 1980 | patch2.m=nx_patch2; |
---|
| 1981 | patch2.n=ny_patch2; |
---|
[2] | 1982 | end |
---|
[257] | 1983 | patch2.convectFlow='n'; |
---|
| 1984 | fieldnames=fields(patch2); |
---|
| 1985 | [CivAllxml,uid_patch2]=add(CivAllxml,1,'element','patch2'); |
---|
| 1986 | for ilist=1:length(fieldnames) |
---|
| 1987 | val=eval(['patch2.' fieldnames{ilist}]); |
---|
| 1988 | if ischar(val) |
---|
| 1989 | [CivAllxml,uid_t]=add(CivAllxml,uid_patch2,'element',fieldnames{ilist}); |
---|
| 1990 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
| 1991 | end |
---|
[112] | 1992 | end |
---|
[257] | 1993 | CivAllCmd=[CivAllCmd ' patch2 ']; |
---|
[112] | 1994 | end |
---|
[12] | 1995 | end |
---|
[257] | 1996 | |
---|
| 1997 | switch CivMode |
---|
| 1998 | case {'CivX','CivAll'} |
---|
| 1999 | if isequal(CivMode,'CivAll') |
---|
[272] | 2000 | save(CivAllxml,[OutputFile '.xml']); |
---|
| 2001 | cmd=[cmd sparam.CivBin ' -f ' OutputFile '.xml ' CivAllCmd ' >' OutputFile '.log' '\n']; |
---|
[238] | 2002 | end |
---|
[272] | 2003 | |
---|
| 2004 | % create the .bat file used in run or batch |
---|
| 2005 | filename_bat=[OutputFile '.bat']; |
---|
[257] | 2006 | [fid,message]=fopen(filename_bat,'w'); |
---|
| 2007 | if isequal(fid,-1) |
---|
| 2008 | msgbox_uvmat('ERROR', ['creation of .bat file: ' message]) |
---|
| 2009 | return |
---|
[238] | 2010 | end |
---|
[257] | 2011 | fprintf(fid,cmd); |
---|
| 2012 | fclose(fid); |
---|
[269] | 2013 | |
---|
[279] | 2014 | if isunix |
---|
| 2015 | system(['chmod +x ' filename_bat]); |
---|
| 2016 | end |
---|
| 2017 | |
---|
[269] | 2018 | batch_file_list{length(batch_file_list)+1}=filename_bat; |
---|
| 2019 | |
---|
| 2020 | % if batch |
---|
| 2021 | % switch batch_mode |
---|
| 2022 | % case 'sge' |
---|
| 2023 | % display(['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]); |
---|
| 2024 | % eval( ['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]); |
---|
| 2025 | % case 'oar' |
---|
| 2026 | % % eval( ['!chmod +x ' filename_bat]); |
---|
| 2027 | % % %eval( ['!oarsub -n CIVX -l /core=1,walltime=00:10:00 ' filename_bat]); |
---|
| 2028 | % % eval( ['!oarsub -n CIVX -l "/core=1+{type = ''smalljob''}/licence=1,walltime=00:10:00" ' filename_bat]); |
---|
| 2029 | % |
---|
| 2030 | % cmd_str=['sh ' filename_bat]; |
---|
| 2031 | % super_cmd{length(super_cmd)+1}=cmd_str; |
---|
| 2032 | % |
---|
| 2033 | % end |
---|
| 2034 | % else |
---|
| 2035 | % %% to lauch the jobs locally : |
---|
| 2036 | % if(isunix) |
---|
| 2037 | % cmd_str=['. ' filename_bat]; |
---|
| 2038 | % else %case of Windows |
---|
| 2039 | % cmd_str=['@call "' regexprep(filename_bat,'\\','\\\\') '"']; |
---|
| 2040 | % end |
---|
| 2041 | % super_cmd=[super_cmd cmd_str '\n']; |
---|
| 2042 | % disp(cmd_str); |
---|
| 2043 | % end |
---|
[257] | 2044 | case 'Matlab' |
---|
| 2045 | drawnow |
---|
[282] | 2046 | if Param.CheckCiv1==1 |
---|
[284] | 2047 | Param.Civ1=Param.Civ1; |
---|
[252] | 2048 | end |
---|
[282] | 2049 | if Param.CheckFix1==1 |
---|
[257] | 2050 | fix1.WarnFlags=[]; |
---|
[282] | 2051 | if get(handles.CheckFmin2,'Value') |
---|
[257] | 2052 | fix1.WarnFlags=[fix1.WarnFlags -2]; |
---|
| 2053 | end |
---|
[282] | 2054 | if get(handles.CheckF3,'Value') |
---|
[257] | 2055 | fix1.WarnFlags=[fix1.WarnFlags 3]; |
---|
| 2056 | end |
---|
| 2057 | fix1.LowerBoundCorr=thresh_vecC1; |
---|
[287] | 2058 | if get(handles.num_MinVel,'Value') |
---|
[257] | 2059 | fix1.UppperBoundVel=thresh_vel1; |
---|
| 2060 | else |
---|
| 2061 | fix1.LowerBoundVel=thresh_vel1; |
---|
| 2062 | end |
---|
[282] | 2063 | if get(handles.CheckMask,'Value') |
---|
[257] | 2064 | fix1.MaskName=maskname; |
---|
| 2065 | end |
---|
| 2066 | Param.Fix1=fix1; |
---|
[252] | 2067 | end |
---|
[282] | 2068 | if Param.CheckPatch1==1 |
---|
[263] | 2069 | if strcmp(compare,'stereo PIV') |
---|
| 2070 | filebase_A=filecell.filebase; |
---|
| 2071 | [pp,ff]=fileparts(filebase_A); |
---|
| 2072 | filebase_B=fullfile(pp,get(handles.RootName_1,'String')); |
---|
| 2073 | RUN_STLIN(filecell.ncA.civ1{ifile,j},filecell.nc.civ1{ifile,j},'civ1',filecell.st{ifile,j},... |
---|
| 2074 | str2num(nx_patch1),str2num(ny_patch1),str2num(thresh_patch1),[filebase_A '.xml'],[filebase_B '.xml']) |
---|
| 2075 | else |
---|
| 2076 | Param.Patch1.Rho=rho_patch1; |
---|
| 2077 | Param.Patch1.Threshold=thresh_patch1; |
---|
| 2078 | Param.Patch1.SubDomain=subdomain_patch1; |
---|
| 2079 | end |
---|
[257] | 2080 | end |
---|
[282] | 2081 | if Param.CheckCiv2==1 |
---|
[290] | 2082 | Param.Civ2=Param.Civ2; |
---|
[257] | 2083 | end |
---|
[282] | 2084 | if Param.CheckFix2==1 |
---|
[257] | 2085 | fix2.WarnFlags=[]; |
---|
[287] | 2086 | if get(handles.CheckFmin2,'Value') |
---|
[257] | 2087 | fix2.WarnFlags=[fix2.WarnFlags -2]; |
---|
| 2088 | end |
---|
[287] | 2089 | if get(handles.CheckF4,'Value') |
---|
[257] | 2090 | fix2.WarnFlags=[fix2.WarnFlags 4]; |
---|
| 2091 | end |
---|
[287] | 2092 | if get(handles.CheckF3,'Value') |
---|
[257] | 2093 | fix2.WarnFlags=[fix2.WarnFlags 3]; |
---|
| 2094 | end |
---|
| 2095 | fix2.LowerBoundCorr=thresh_vec2C; |
---|
[287] | 2096 | if get(handles.num_MinVel,'Value') |
---|
[257] | 2097 | fix2.UppperBoundVel=thresh_vel2; |
---|
| 2098 | else |
---|
| 2099 | fix2.LowerBoundVel=thresh_vel2; |
---|
| 2100 | end |
---|
[282] | 2101 | if get(handles.CheckMask,'Value') |
---|
[257] | 2102 | fix2.MaskName=maskname; |
---|
| 2103 | end |
---|
| 2104 | Param.Fix2=fix2; |
---|
| 2105 | end |
---|
[282] | 2106 | if Param.CheckPatch2==1 |
---|
[263] | 2107 | if strcmp(compare,'stereo PIV') |
---|
| 2108 | filebase_A=filecell.filebase; |
---|
| 2109 | [pp,ff]=fileparts(filebase_A); |
---|
| 2110 | filebase_B=fullfile(pp,get(handles.RootName_1,'String')); |
---|
| 2111 | RUN_STLIN(filecell.ncA.civ2{ifile,j},filecell.nc.civ2{ifile,j},'civ2',filecell.st{ifile,j},... |
---|
| 2112 | str2num(nx_patch2),str2num(ny_patch2),str2num(thresh_patch2),[filebase_A '.xml'],[filebase_B '.xml']) |
---|
[270] | 2113 | else |
---|
| 2114 | Param.Patch2.Rho=rho_patch2; |
---|
| 2115 | Param.Patch2.Threshold=thresh_patch2; |
---|
| 2116 | Param.Patch2.SubDomain=subdomain_patch2; |
---|
[263] | 2117 | end |
---|
[257] | 2118 | end |
---|
[263] | 2119 | if ~strcmp(compare,'stereo PIV') |
---|
| 2120 | [Data,erromsg]=civ_uvmat(Param,filecell.nc.civ1{ifile,j}); |
---|
| 2121 | if isempty(errormsg) |
---|
| 2122 | display([filecell.nc.civ1{ifile,j} ' written']) |
---|
| 2123 | else |
---|
| 2124 | msgbox_uvmat('ERROR',errormsg) |
---|
| 2125 | end |
---|
[270] | 2126 | |
---|
[263] | 2127 | end |
---|
[257] | 2128 | end |
---|
[112] | 2129 | end |
---|
[2] | 2130 | end |
---|
[134] | 2131 | |
---|
[265] | 2132 | if batch |
---|
[269] | 2133 | switch batch_mode |
---|
| 2134 | case 'sge' |
---|
| 2135 | for p=1:length(batch_file_list) |
---|
| 2136 | cmd=['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' batch_file_list{p}]; |
---|
| 2137 | display(cmd);eval(cmd); |
---|
| 2138 | end |
---|
[279] | 2139 | case 'oar_old' |
---|
| 2140 | for p=1:length(batch_file_list) |
---|
| 2141 | oar_command=['!oarsub -n CIVX -q nicejob '... |
---|
| 2142 | '-E ' regexprep(batch_file_list{p},'.bat','.errors') ' -O ' regexprep(batch_file_list{p},'.bat','.log ')... |
---|
| 2143 | '-l "/core=1+{type = ''smalljob''}/licence=1,walltime=00:60:00" ' batch_file_list{p}]; |
---|
| 2144 | display(oar_command);eval(oar_command); |
---|
[290] | 2145 | end |
---|
| 2146 | case 'oar' %oar-dispatch.pl |
---|
[279] | 2147 | filename_joblist=fullfile(Rootbat,'job_list.txt'); |
---|
| 2148 | fid=fopen(filename_joblist,'w'); |
---|
| 2149 | |
---|
| 2150 | for p=1:length(batch_file_list) |
---|
| 2151 | oar_command=['oarsub -n CIVX '... |
---|
| 2152 | '-l "/core=1,walltime=00:10:00" ' batch_file_list{p}]; |
---|
| 2153 | fprintf(fid,[oar_command '\n']); |
---|
[265] | 2154 | end |
---|
[290] | 2155 | fclose(fid); |
---|
| 2156 | walltime=datestr(length(batch_file_list)*10/24/60,13); |
---|
| 2157 | oar_command=['oarsub -t container -n civx-container -l /core=24,walltime=' walltime ' "/fsnet/data/legi/calcul9/home/gostiaux/Documents/MATLAB/uvmat_dev/oar-dispatch -f '... |
---|
[279] | 2158 | filename_joblist '"']; |
---|
| 2159 | filename_oarcommand=fullfile(Rootbat,'oar_command'); |
---|
| 2160 | fid=fopen(filename_oarcommand,'w'); |
---|
| 2161 | fprintf(fid,[oar_command '\n']); |
---|
| 2162 | fclose(fid); |
---|
[290] | 2163 | display(oar_command); |
---|
| 2164 | eval(['! . ' filename_oarcommand]) |
---|
| 2165 | case 'oar_mpi' |
---|
[279] | 2166 | filename_joblist=fullfile(Rootbat,'job_list.txt'); |
---|
| 2167 | fid=fopen(filename_joblist,'w'); |
---|
| 2168 | |
---|
| 2169 | for p=1:length(batch_file_list) |
---|
| 2170 | fprintf(fid,[batch_file_list{p} '\n']); |
---|
[265] | 2171 | end |
---|
[279] | 2172 | fclose(fid) |
---|
| 2173 | |
---|
| 2174 | |
---|
| 2175 | % oarsub -S ./oar.sub |
---|
| 2176 | |
---|
| 2177 | |
---|
| 2178 | |
---|
| 2179 | |
---|
| 2180 | |
---|
[269] | 2181 | case 'oar_new' % to be develloped with Patrick Begou |
---|
| 2182 | filename_joblist=fullfile(Rootbat,'job_list.txt'); |
---|
| 2183 | fid=fopen(filename_superbat,'w'); |
---|
| 2184 | if fid==-1 |
---|
| 2185 | msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat]) |
---|
| 2186 | return |
---|
[265] | 2187 | end |
---|
[269] | 2188 | for p=1:length(batch_file_list) |
---|
| 2189 | fprintf(fid,[batch_file_list{p} '\n']); |
---|
| 2190 | end |
---|
| 2191 | fclose(fid); |
---|
| 2192 | walltime=datestr(length(super_cmd)*10/24/60,13); |
---|
| 2193 | eval( ['!oarsub -n CIVX -q nicejob -l "/core=1+{type = ''smalljob''}/licence=1,walltime=' walltime '" ' filename_superbat]); |
---|
| 2194 | end |
---|
| 2195 | else |
---|
| 2196 | if ~isequal(CivMode,'Matlab') |
---|
| 2197 | filename_superbat=fullfile(Rootbat,'job_list.bat'); |
---|
| 2198 | fid=fopen(filename_superbat,'w'); |
---|
| 2199 | if fid==-1 |
---|
| 2200 | msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat]) |
---|
| 2201 | return |
---|
| 2202 | end |
---|
| 2203 | for p=1:length(batch_file_list) |
---|
| 2204 | if isunix |
---|
| 2205 | fprintf(fid,['sh ' batch_file_list{p} '\n']); |
---|
| 2206 | else |
---|
| 2207 | fprintf(fid,['@call "' regexprep(filename_bat,'\\','\\\\') '"' '\n']); |
---|
[265] | 2208 | end |
---|
[269] | 2209 | end |
---|
| 2210 | fclose(fid); |
---|
| 2211 | if(isunix) |
---|
| 2212 | system(['chmod +x ' filename_superbat]); |
---|
| 2213 | end |
---|
| 2214 | system([filename_superbat ' &']);% execute main commmand |
---|
[265] | 2215 | end |
---|
[269] | 2216 | |
---|
[265] | 2217 | end |
---|
| 2218 | |
---|
[2] | 2219 | |
---|
[137] | 2220 | %% save interface state |
---|
[2] | 2221 | if isfield(filecell,'nc') |
---|
| 2222 | if isfield(filecell.nc,'civ2') |
---|
| 2223 | fileresu=filecell.nc.civ2{1,1}; |
---|
| 2224 | else |
---|
| 2225 | fileresu=filecell.nc.civ1{1,1}; |
---|
| 2226 | end |
---|
| 2227 | end |
---|
| 2228 | [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileresu); |
---|
| 2229 | namedoc=fullfile(RootPath,subdir,RootFile); |
---|
[112] | 2230 | detect=1; |
---|
[2] | 2231 | while detect==1 |
---|
| 2232 | namefigfull=[namedoc '.fig']; |
---|
| 2233 | hh=dir(namefigfull); |
---|
| 2234 | if ~isempty(hh) |
---|
| 2235 | detect=1; |
---|
| 2236 | namedoc=[namedoc '.0']; |
---|
| 2237 | else |
---|
| 2238 | detect=0; |
---|
| 2239 | end |
---|
| 2240 | end |
---|
| 2241 | saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) |
---|
| 2242 | |
---|
[273] | 2243 | %Save info in personal profile (initiate browser next time) TODO |
---|
| 2244 | MenuFile={}; |
---|
| 2245 | dir_perso=prefdir; |
---|
| 2246 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 2247 | if exist(profil_perso,'file') |
---|
| 2248 | hh=load (profil_perso); |
---|
| 2249 | if isfield(hh,'MenuFile') |
---|
| 2250 | MenuFile=hh.MenuFile; |
---|
| 2251 | end |
---|
[289] | 2252 | if isfield(filecell.nc,'civ2') |
---|
| 2253 | MenuFile=[filecell.nc.civ2{1,1}; MenuFile]; |
---|
| 2254 | else |
---|
| 2255 | MenuFile=[filecell.nc.civ1{1,1}; MenuFile]; |
---|
| 2256 | end |
---|
[273] | 2257 | save (profil_perso,'MenuFile','-append'); %store the file names for future opening of uvmat |
---|
| 2258 | else |
---|
| 2259 | MenuFile=filecell.ima1.civ1(1,1); |
---|
| 2260 | save (profil_perso,'MenuFile') |
---|
| 2261 | end |
---|
| 2262 | |
---|
| 2263 | |
---|
[227] | 2264 | %------------------------------------------------------------------------ |
---|
| 2265 | % --- determine the list of reference indices of processing file |
---|
| 2266 | function [ref_i,ref_j,errormsg]=find_ref_indices(handles) |
---|
| 2267 | %------------------------------------------------------------------------ |
---|
| 2268 | errormsg=''; %default error message |
---|
| 2269 | first_i=str2double(get(handles.first_i,'String'));%first index i |
---|
| 2270 | last_i=str2double(get(handles.last_i,'String'));%last index i |
---|
| 2271 | incr_i=str2double(get(handles.incr_i,'String'));% increment |
---|
| 2272 | if isequal(get(handles.first_j,'Visible'),'on') |
---|
| 2273 | first_j=str2double(get(handles.first_j,'String'));%first index j |
---|
| 2274 | last_j=str2double(get(handles.last_j,'String'));%last index j |
---|
| 2275 | incr_j=str2double(get(handles.incr_j,'String'));% increment |
---|
| 2276 | else |
---|
| 2277 | first_j=1; |
---|
| 2278 | last_j=1; |
---|
| 2279 | incr_j=1; |
---|
| 2280 | end |
---|
| 2281 | ref_i=first_i:incr_i:last_i;% list of i indices (reference values for each pair) |
---|
| 2282 | ref_j=first_j:incr_j:last_j;% list of j indices (reference values for each pair) |
---|
| 2283 | if isnan(first_i)||isnan(first_j) |
---|
| 2284 | errormsg='first field number not defined'; |
---|
| 2285 | elseif isnan(last_i)||isnan(last_j) |
---|
| 2286 | errormsg='last field number not defined'; |
---|
| 2287 | elseif isnan(incr_i)||isnan(incr_j) |
---|
| 2288 | errormsg='increment in field number not defined'; |
---|
| 2289 | elseif last_i < first_i || last_j < first_j |
---|
| 2290 | errormsg='last field number must be larger than the first one'; |
---|
| 2291 | end |
---|
[134] | 2292 | |
---|
[227] | 2293 | %------------------------------------------------------------------------ |
---|
| 2294 | % --- determine the list of filenames and indices needed for launch_job |
---|
[263] | 2295 | function [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc,file_ref_fix1,file_ref_fix2,compare]=... |
---|
[282] | 2296 | set_civ_filenames(handles,ref_i,ref_j,checkbox) |
---|
[12] | 2297 | %------------------------------------------------------------------------ |
---|
[85] | 2298 | filecell=[];%default |
---|
[136] | 2299 | |
---|
| 2300 | %% get the root names nomenclature and numbers |
---|
[71] | 2301 | filebase=get(handles.RootName,'String'); |
---|
[136] | 2302 | |
---|
| 2303 | if isempty(filebase)||isequal(filebase,'') |
---|
| 2304 | msgbox_uvmat('ERROR','no input files') |
---|
| 2305 | return |
---|
| 2306 | end |
---|
| 2307 | |
---|
[137] | 2308 | %filebase=regexprep(filebase,'\.fsnet','fsnet');% temporary fix for cluster Coriolis |
---|
[136] | 2309 | filecell.filebase=filebase; |
---|
| 2310 | |
---|
[273] | 2311 | browse=get(handles.RootName,'UserData'); |
---|
[282] | 2312 | compare_list=get(handles.ListCompareMode,'String'); |
---|
| 2313 | val=get(handles.ListCompareMode,'Value'); |
---|
[2] | 2314 | compare=compare_list{val}; |
---|
| 2315 | if strcmp(compare,'displacement') |
---|
| 2316 | mode='displacement'; |
---|
| 2317 | else |
---|
[282] | 2318 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 2319 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[2] | 2320 | mode=mode_list{mode_value}; |
---|
| 2321 | end |
---|
[137] | 2322 | %time=get(handles.RootName,'UserData'); %get the set of times |
---|
[71] | 2323 | ext_ima=get(handles.ImaExt,'String'); |
---|
[2] | 2324 | nom_type_nc=browse.nom_type_nc; |
---|
[122] | 2325 | if isfield(browse,'nom_type_ima') |
---|
| 2326 | nom_type_ima2=browse.nom_type_ima; |
---|
| 2327 | end |
---|
| 2328 | if isempty(nom_type_ima2),nom_type_ima2='1';end; %default |
---|
| 2329 | if isempty(nom_type_nc),nom_type_nc='_i1-i2';end; %default |
---|
[2] | 2330 | [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
[227] | 2331 | find_pair_indices(handles,ref_i,ref_j,mode); |
---|
[282] | 2332 | %determine the new filebase for 'displacement' ListPairMode (comparison of two series) |
---|
[2] | 2333 | filebase_B=filebase;% root name of the second field series for stereo |
---|
| 2334 | if strcmp(compare,'displacement') || strcmp(compare,'stereo PIV') |
---|
[127] | 2335 | % test_disp=1; |
---|
[2] | 2336 | nom_type_ima1=browse.nom_type_ima_1; %nomenclature type of the second file series |
---|
| 2337 | [Path2,Name2]=fileparts(filebase_B); |
---|
| 2338 | Path1=Path2; |
---|
[71] | 2339 | Name1=get(handles.RootName_1,'String');% root name of the first field series for stereo |
---|
[2] | 2340 | filebase_A=fullfile(Path1,Name1); |
---|
| 2341 | if length(Name1)>6 |
---|
| 2342 | Name1=Name1(end-5:end); |
---|
| 2343 | end |
---|
| 2344 | if length(Name2)>6 |
---|
| 2345 | Name2=Name2(end-5:end); |
---|
| 2346 | end |
---|
| 2347 | filebase_AB=fullfile(Path2,[Name2 '-' Name1]); |
---|
| 2348 | else |
---|
[127] | 2349 | % test_disp=0; |
---|
[2] | 2350 | filebase_A=filebase; |
---|
| 2351 | nom_type_ima1=nom_type_ima2; |
---|
| 2352 | filebase_AB=filebase; |
---|
| 2353 | end |
---|
| 2354 | if strcmp(compare,'displacement') |
---|
[112] | 2355 | filebase_ima1=filebase_A; |
---|
| 2356 | filebase_ima2=filebase_B; |
---|
| 2357 | filebase_nc=filebase_AB; %root name for the result of civ2 |
---|
[2] | 2358 | else |
---|
[112] | 2359 | filebase_ima1=filebase_B; |
---|
| 2360 | filebase_ima2=filebase_B; |
---|
| 2361 | filebase_nc=filebase_B; |
---|
| 2362 | end |
---|
[2] | 2363 | |
---|
| 2364 | %determine reference files for fix: |
---|
| 2365 | file_ref_fix1={};%default |
---|
| 2366 | file_ref_fix2={}; |
---|
| 2367 | nbfield=length(num1_civ1); |
---|
| 2368 | nbslice=length(num_a_civ1); |
---|
[282] | 2369 | if checkbox(2)==1% fix1 performed |
---|
[2] | 2370 | ref=get(handles.ref_fix1,'UserData');%read data on the ref file stored by get_ref_fix1_Callback |
---|
| 2371 | if ~isempty(ref) |
---|
[137] | 2372 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 2373 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 2374 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 2375 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 2376 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 2377 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[127] | 2378 | num_i_ref=first_i:incr_i:last_i; |
---|
| 2379 | num_j_ref=first_j:incr_j:last_j; |
---|
[2] | 2380 | if isequal(mode,'displacement') |
---|
| 2381 | num_i1=num_i_ref; |
---|
| 2382 | num_i2=num_i_ref; |
---|
| 2383 | num_j1=num_j_ref; |
---|
| 2384 | num_j2=num_j_ref; |
---|
| 2385 | elseif isequal(mode,'pair j1-j2')% isequal(mode,'st_pair j1-j2') |
---|
| 2386 | num_i1=num_i_ref; |
---|
| 2387 | num_i2=num_i1; |
---|
| 2388 | num_j1=ref.num_a*ones(size(num_i_ref)); |
---|
| 2389 | num_j2=ref.num_b*ones(size(num_i_ref)); |
---|
| 2390 | elseif isequal(mode,'series(Di)') % isequal(mode,'st_series(Di)') |
---|
| 2391 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 2392 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 2393 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 2394 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 2395 | if isempty(ref.num_a) |
---|
| 2396 | ref.num_a=1; |
---|
| 2397 | end |
---|
| 2398 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 2399 | num_j2=num_j1; |
---|
| 2400 | elseif isequal(mode,'series(Dj)')%| isequal(mode,'st_series(Dj)') |
---|
| 2401 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 2402 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 2403 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 2404 | num_i2=num_i1; |
---|
| 2405 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 2406 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 2407 | end |
---|
| 2408 | for ifile=1:nbfield |
---|
| 2409 | for j=1:nbslice |
---|
| 2410 | file_ref=name_generator(ref.filebase,num_i1(ifile),num_j1(j),'.nc',ref.nom_type,1,num_i2(ifile),num_j2(j),ref.subdir);% |
---|
| 2411 | file_ref_fix1(ifile,j)={file_ref}; |
---|
| 2412 | if ~exist(file_ref,'file') |
---|
| 2413 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix1']) |
---|
[12] | 2414 | filecell=[]; |
---|
[2] | 2415 | return |
---|
| 2416 | end |
---|
| 2417 | end |
---|
| 2418 | end |
---|
| 2419 | end |
---|
| 2420 | end |
---|
| 2421 | |
---|
[282] | 2422 | %determine reference files for checkfix2: |
---|
| 2423 | if checkbox(5)==1% fix2 performed |
---|
[2] | 2424 | ref=get(handles.ref_fix2,'UserData'); |
---|
| 2425 | if ~isempty(ref) |
---|
[127] | 2426 | first_i=str2double(get(handles.first_i,'String')); |
---|
| 2427 | last_i=str2double(get(handles.last_i,'String')); |
---|
| 2428 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
| 2429 | first_j=str2double(get(handles.first_j,'String')); |
---|
| 2430 | last_j=str2double(get(handles.last_j,'String')); |
---|
| 2431 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
[229] | 2432 | num_i_ref=first_i:incr_i:last_i; |
---|
| 2433 | num_j_ref=first_j:incr_j:last_j; |
---|
[2] | 2434 | if isequal(mode,'displacement') |
---|
| 2435 | num_i1=num_i_ref; |
---|
| 2436 | num_i2=num_i_ref; |
---|
| 2437 | num_j1=num_j_ref; |
---|
| 2438 | num_j2=num_j_ref; |
---|
| 2439 | elseif isequal(mode,'pair j1-j2') |
---|
| 2440 | num_i1=num_i_ref; |
---|
| 2441 | num_i2=num_i1; |
---|
| 2442 | num_j1=ref.num_a; |
---|
| 2443 | num_j2=ref.num_b; |
---|
| 2444 | elseif isequal(mode,'series(Di)') |
---|
| 2445 | delta1=floor((ref.num2-ref.num1)/2); |
---|
| 2446 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
| 2447 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
| 2448 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
| 2449 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
| 2450 | num_j2=num_j1; |
---|
| 2451 | elseif isequal(mode,'series(Dj)') |
---|
| 2452 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
| 2453 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
| 2454 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
| 2455 | num_i2=num_i1; |
---|
| 2456 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
| 2457 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
| 2458 | end |
---|
| 2459 | for ifile=1:nbfield |
---|
| 2460 | for j=1:nbslice |
---|
| 2461 | file_ref=name_generator(ref.filebase,num_i1(ifile),num_j1(j),'.nc',ref.nom_type,1,num_i2(ifile),num_j2(j),ref.subdir);% |
---|
| 2462 | file_ref_fix2(ifile,j)={file_ref}; |
---|
| 2463 | if ~exist(file_ref,'file') |
---|
| 2464 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix2']) |
---|
[122] | 2465 | filecell={}; |
---|
[2] | 2466 | return |
---|
| 2467 | end |
---|
| 2468 | end |
---|
| 2469 | end |
---|
| 2470 | end |
---|
| 2471 | end |
---|
| 2472 | |
---|
| 2473 | %check dir |
---|
[289] | 2474 | subdir_civ1=get(handles.txt_SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf output data |
---|
| 2475 | subdir_civ2=get(handles.txt_SubdirCiv2,'String'); |
---|
[174] | 2476 | if isequal(subdir_civ1,''),subdir_civ1='CIV'; end% put default subdir |
---|
[2] | 2477 | if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end% put default subdir |
---|
[266] | 2478 | % currentdir=pwd;%store the current working directory |
---|
[2] | 2479 | [Path_ima,Name]=fileparts(filebase);%Path of the image files (.civ) |
---|
| 2480 | if ~exist(Path_ima,'dir') |
---|
[12] | 2481 | msgbox_uvmat('ERROR',['path to images ' Path_ima ' not found']) |
---|
[122] | 2482 | filecell={}; |
---|
[2] | 2483 | return |
---|
| 2484 | end |
---|
[127] | 2485 | [xx,message]=fileattrib(Path_ima); |
---|
[122] | 2486 | if ~isempty(message) && ~isequal(message.UserWrite,1) |
---|
[112] | 2487 | msgbox_uvmat('ERROR',['No writting access to ' Path_ima]) |
---|
[122] | 2488 | filecell={}; |
---|
[266] | 2489 | % cd(currentdir); |
---|
[112] | 2490 | return |
---|
[2] | 2491 | end |
---|
| 2492 | |
---|
| 2493 | %check the existence of the netcdf and image files involved |
---|
[282] | 2494 | % %%%%%%%%%%%% case CheckCiv1 activated %%%%%%%%%%%%% |
---|
| 2495 | if checkbox(1)==1; |
---|
[112] | 2496 | detect=1; |
---|
[127] | 2497 | vers=0; |
---|
| 2498 | subdir_civ1_new=subdir_civ1; |
---|
[153] | 2499 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
[122] | 2500 | for ifile=1:nbfield |
---|
[112] | 2501 | for j=1:nbslice |
---|
[122] | 2502 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1_new); |
---|
[112] | 2503 | detect=exist(filename,'file')==2; |
---|
| 2504 | if detect% if a netcdf file already exists |
---|
[137] | 2505 | indstr=regexp(subdir_civ1_new,'\D'); |
---|
| 2506 | if indstr(end)<length(subdir_civ1_new) %subdir_civ1 ends by a number |
---|
| 2507 | vers=str2double(subdir_civ1_new(indstr(end)+1:end))+1; |
---|
| 2508 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) num2str(vers)]; |
---|
[127] | 2509 | else |
---|
| 2510 | vers=vers+1; |
---|
[137] | 2511 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) '_' num2str(vers)]; |
---|
[127] | 2512 | end |
---|
[137] | 2513 | subdir_civ2=subdir_civ1_new; |
---|
[112] | 2514 | break |
---|
| 2515 | end |
---|
| 2516 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 2517 | end |
---|
| 2518 | if detect% if a netcdf file already exists |
---|
| 2519 | break |
---|
| 2520 | end |
---|
| 2521 | end |
---|
[134] | 2522 | |
---|
[289] | 2523 | %create the new txt_SubdirCiv1 |
---|
[127] | 2524 | if ~exist(fullfile(Path_ima,subdir_civ1_new),'dir') |
---|
[263] | 2525 | % cd(Path_ima); |
---|
| 2526 | [xx,msg1]=mkdir(fullfile(Path_ima,subdir_civ1_new)); |
---|
[134] | 2527 | |
---|
[128] | 2528 | if ~strcmp(msg1,'') |
---|
| 2529 | msgbox_uvmat('ERROR',['cannot create ' subdir_civ1_new ': ' msg1])%error message for directory creation |
---|
[122] | 2530 | filecell={}; |
---|
| 2531 | return |
---|
[163] | 2532 | elseif isunix |
---|
[266] | 2533 | [xx,msg2] = fileattrib(fullfile(Path_ima,subdir_civ1_new),'+w','g'); %yield writing access (+w) to user group (g) |
---|
[128] | 2534 | if ~strcmp(msg2,'') |
---|
[266] | 2535 | msgbox_uvmat('ERROR',['pb of permission for ' fullfile(Path_ima,subdir_civ1_new) ': ' msg2])%error message for directory creation |
---|
[128] | 2536 | filecell={}; |
---|
| 2537 | return |
---|
| 2538 | end |
---|
[112] | 2539 | end |
---|
[263] | 2540 | % cd(currentdir); |
---|
[112] | 2541 | end |
---|
| 2542 | if strcmp(compare,'stereo PIV')&&(strcmp(mode,'pair j1-j2')||strcmp(mode,'series(Dj)')||strcmp(mode,'series(Di)'))%check second nc series |
---|
| 2543 | for ifile=1:nbfield |
---|
| 2544 | for j=1:nbslice |
---|
[122] | 2545 | filename=name_generator(filebase_A,num1_civ1(ifile),num_a_civ1(j),'.nc',nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1_new);% |
---|
[112] | 2546 | detect=exist(filename,'file')==2; |
---|
[2] | 2547 | if detect% if a netcdf file already exists |
---|
[137] | 2548 | indstr=regexp(subdir_civ1_new,'\D'); |
---|
| 2549 | if indstr(end)<length(subdir_civ1_new) %subdir_civ1 ends by a number |
---|
| 2550 | vers=str2double(subdir_civ1_new(indstr(end)+1:end))+1; |
---|
| 2551 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) num2str(vers)]; |
---|
[127] | 2552 | else |
---|
| 2553 | vers=vers+1; |
---|
[137] | 2554 | subdir_civ1_new=[subdir_civ1_new '_' num2str(vers)]; |
---|
[127] | 2555 | end |
---|
| 2556 | subdir_civ2=subdir_civ1; |
---|
| 2557 | break |
---|
[2] | 2558 | end |
---|
[112] | 2559 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
| 2560 | end |
---|
| 2561 | if detect% if a netcdf file already exists |
---|
| 2562 | break |
---|
| 2563 | end |
---|
| 2564 | end |
---|
[289] | 2565 | %create the new txt_SubdirCiv1 |
---|
[263] | 2566 | if ~exist(fullfile(Path_ima,subdir_civ1_new),'dir') |
---|
| 2567 | % cd(Path_ima); |
---|
| 2568 | [xx,msg1]=mkdir(fullfile(Path_ima,subdir_civ1_new)); |
---|
| 2569 | % cd(currentdir); |
---|
[252] | 2570 | if ~strcmp(msg1,'') |
---|
[128] | 2571 | msgbox_uvmat('ERROR',['cannot create ' subdir_civ1_new ': ' msg1]) |
---|
[263] | 2572 | % cd(currentdir) |
---|
[122] | 2573 | filecell={}; |
---|
| 2574 | return |
---|
[128] | 2575 | else |
---|
[266] | 2576 | [xx,msg2] = fileattrib(fullfile(Path_ima,subdir_civ1_new),'+w','g'); %yield writing access (+w) to user group (g) |
---|
[128] | 2577 | if ~strcmp(msg2,'') |
---|
| 2578 | msgbox_uvmat('ERROR',['pb of permission for ' subdir_civ1_new ': ' msg2])%error message for directory creation |
---|
[263] | 2579 | % cd(currentdir) |
---|
[128] | 2580 | filecell={}; |
---|
| 2581 | return |
---|
| 2582 | end |
---|
[112] | 2583 | end |
---|
| 2584 | end |
---|
| 2585 | end |
---|
| 2586 | end |
---|
[127] | 2587 | subdir_civ1=subdir_civ1_new; |
---|
[2] | 2588 | % get image names |
---|
| 2589 | for ifile=1:nbfield |
---|
[112] | 2590 | for j=1:nbslice |
---|
[2] | 2591 | filename=name_generator(filebase_ima1, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
| 2592 | idetect(j)=exist(filename,'file')==2; |
---|
| 2593 | filecell.ima1.civ1(ifile,j)={filename}; %first image |
---|
| 2594 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
| 2595 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 2596 | filecell.ima2.civ1(ifile,j)={filename};%second image |
---|
[112] | 2597 | end |
---|
| 2598 | [idetectmin,indexj]=min(idetect); |
---|
| 2599 | if idetectmin==0, |
---|
| 2600 | msgbox_uvmat('ERROR',[filecell.ima1.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2601 | filecell={}; |
---|
[266] | 2602 | % cd(currentdir) |
---|
[112] | 2603 | return |
---|
| 2604 | end |
---|
| 2605 | [idetectmin,indexj]=min(idetect_1); |
---|
| 2606 | if idetectmin==0, |
---|
| 2607 | msgbox_uvmat('ERROR',[filecell.ima2.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2608 | filecell={}; |
---|
[266] | 2609 | %cd(currentdir) |
---|
[112] | 2610 | return |
---|
| 2611 | end |
---|
| 2612 | end |
---|
| 2613 | if strcmp(compare,'stereo PIV') && (strcmp(mode,'pair j1-j2') || strcmp(mode,'series(Dj)') || strcmp(mode,'series(Di)')) |
---|
| 2614 | for ifile=1:nbfield |
---|
| 2615 | for j=1:nbslice |
---|
| 2616 | filename=name_generator(filebase_A, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
| 2617 | idetect(j)=exist(filename,'file')==2; |
---|
| 2618 | filecell.imaA1.civ1(ifile,j)={filename} ;%first image |
---|
| 2619 | filename=name_generator(filebase_A, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
| 2620 | idetect_1(j)=exist(filename,'file')==2; |
---|
| 2621 | filecell.imaA2.civ1(ifile,j)={filename};%second image |
---|
| 2622 | end |
---|
[2] | 2623 | [idetectmin,indexj]=min(idetect); |
---|
[112] | 2624 | if idetectmin==0, |
---|
| 2625 | msgbox_uvmat('ERROR',[filecell.imaA1.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2626 | filecell={}; |
---|
[266] | 2627 | % cd(currentdir) |
---|
[2] | 2628 | return |
---|
[112] | 2629 | end |
---|
[2] | 2630 | [idetectmin,indexj]=min(idetect_1); |
---|
[112] | 2631 | if idetectmin==0, |
---|
| 2632 | msgbox_uvmat('ERROR',[filecell.imaA2.civ1{ifile,indexj} ' not found']) |
---|
[122] | 2633 | filecell={}; |
---|
[266] | 2634 | % cd(currentdir) |
---|
[2] | 2635 | return |
---|
[112] | 2636 | end |
---|
| 2637 | end |
---|
[2] | 2638 | end |
---|
[112] | 2639 | |
---|
[282] | 2640 | %%%%%%%%%%%%% checkfix1 or checkpatch1 activated but no checkciv1 %%%%%%%%%%%%% |
---|
| 2641 | elseif (checkbox(2)==1 || checkbox(3)==1); |
---|
[2] | 2642 | for ifile=1:nbfield |
---|
| 2643 | for j=1:nbslice |
---|
| 2644 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
[112] | 2645 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 2646 | detect=exist(filename,'file')==2; |
---|
[122] | 2647 | if detect==0 |
---|
| 2648 | msgbox_uvmat('ERROR',[filename ' not found']) |
---|
| 2649 | filecell={}; |
---|
[266] | 2650 | % cd(currentdir) |
---|
[122] | 2651 | return |
---|
| 2652 | end |
---|
[2] | 2653 | filecell.nc.civ1(ifile,j)={filename}; |
---|
| 2654 | end |
---|
| 2655 | end |
---|
| 2656 | if strcmp(compare,'stereo PIV') |
---|
[112] | 2657 | for ifile=1:nbfield |
---|
| 2658 | for j=1:nbslice |
---|
| 2659 | filename=name_generator(filebase_A,num1_civ1(ifile),num_a_civ1(j),'.nc',nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 2660 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
| 2661 | if ~exist(filename,'file') |
---|
| 2662 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
| 2663 | set(handles.RUN, 'Enable','On') |
---|
| 2664 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
[122] | 2665 | filecell={}; |
---|
[266] | 2666 | %cd(currentdir) |
---|
[112] | 2667 | return |
---|
[2] | 2668 | end |
---|
| 2669 | end |
---|
[112] | 2670 | end |
---|
[2] | 2671 | end |
---|
| 2672 | end |
---|
| 2673 | |
---|
[282] | 2674 | %%%%%%%%%%%%% if checkciv2 performed with pairs different than checkciv1 %%%%%%%%%%%%% |
---|
[2] | 2675 | testdiff=0; |
---|
[282] | 2676 | if (checkbox(4)==1)&&... |
---|
| 2677 | ((get(handles.ListPairCiv1,'Value')~=get(handles.ListPairCiv2,'Value'))||~strcmp(subdir_civ2,subdir_civ1)) |
---|
[2] | 2678 | testdiff=1; |
---|
[112] | 2679 | detect=1; |
---|
[127] | 2680 | vers=0; |
---|
| 2681 | subdir_civ2_new=subdir_civ2; |
---|
[2] | 2682 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
[112] | 2683 | for ifile=1:nbfield |
---|
| 2684 | for j=1:nbslice |
---|
[127] | 2685 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2_new);% |
---|
[112] | 2686 | detect=exist(filename,'file')==2; |
---|
| 2687 | if detect% if a netcdf file already exists |
---|
[127] | 2688 | indstr=regexp(subdir_civ2,'\D'); |
---|
| 2689 | if indstr(end)<length(subdir_civ2) %subdir_civ1 ends by a number |
---|
| 2690 | vers=str2double(subdir_civ2(indstr(end)+1:end))+1; |
---|
| 2691 | subdir_civ2_new=[subdir_civ2(1:indstr(end)) num2str(vers)]; |
---|
| 2692 | else |
---|
| 2693 | vers=vers+1; |
---|
| 2694 | subdir_civ2_new=[subdir_civ1 '_' num2str(vers)]; |
---|
| 2695 | end |
---|
[112] | 2696 | break |
---|
| 2697 | end |
---|
| 2698 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 2699 | end |
---|
| 2700 | if detect% if a netcdf file already exists |
---|
| 2701 | break |
---|
| 2702 | end |
---|
| 2703 | end |
---|
[128] | 2704 | %create the new subdir_civ2_new |
---|
| 2705 | if ~exist(fullfile(Path_ima,subdir_civ2_new),'dir') |
---|
[174] | 2706 | [xx,m2]=mkdir(fullfile(Path_ima,subdir_civ2_new)); |
---|
[266] | 2707 | [xx,msg2] = fileattrib(fullfile(Path_ima,subdir_civ2_new),'+w','g'); %yield writing access (+w) to user group (g) |
---|
[112] | 2708 | if ~isequal(m2,'') |
---|
[266] | 2709 | msgbox_uvmat('ERROR',['cannot create ' fullfile(Path_ima,subdir_civ2_new) ': ' m2]) |
---|
[122] | 2710 | filecell={}; |
---|
[266] | 2711 | % cd(currentdir) |
---|
[122] | 2712 | return |
---|
[112] | 2713 | end |
---|
| 2714 | end |
---|
| 2715 | if strcmp(compare,'stereo PIV')%check second nc series |
---|
| 2716 | for ifile=1:nbfield |
---|
| 2717 | for j=1:nbslice |
---|
| 2718 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
[122] | 2719 | nom_type_nc,1,num2_civ2(ifile),num_b_civ1(j),subdir_civ2_new);% |
---|
[112] | 2720 | detect=exist(filename,'file')==2; |
---|
[2] | 2721 | if detect% if a netcdf file already exists |
---|
[127] | 2722 | indstr=regexp(subdir_civ2,'\D'); |
---|
| 2723 | if indstr(end)<length(subdir_civ2) %subdir_civ1 ends by a number |
---|
| 2724 | vers=str2double(subdir_civ2(indstr(end)+1:end))+1; |
---|
| 2725 | subdir_civ2_new=[subdir_civ2(1:indstr(end)) num2str(vers)]; |
---|
| 2726 | else |
---|
| 2727 | vers=vers+1; |
---|
| 2728 | subdir_civ2_new=[subdir_civ1 '_' num2str(vers)]; |
---|
| 2729 | end |
---|
[112] | 2730 | break |
---|
[2] | 2731 | end |
---|
[112] | 2732 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 2733 | end |
---|
| 2734 | if detect% if a netcdf file already exists |
---|
| 2735 | break |
---|
| 2736 | end |
---|
| 2737 | end |
---|
[122] | 2738 | subdir_civ2=subdir_civ2_new; |
---|
[289] | 2739 | %create the new txt_SubdirCiv1 |
---|
[127] | 2740 | if ~exist(fullfile(Path_ima,subdir_civ2_new),'dir') |
---|
| 2741 | [xx,m2]=mkdir(subdir_civ2_new); |
---|
[266] | 2742 | [xx,msg2] = fileattrib(fullfile(Path_ima,subdir_civ2_new),'+w','g'); %yield writing access (+w) to user group (g) |
---|
[112] | 2743 | if ~isequal(m2,'') |
---|
[266] | 2744 | msgbox_uvmat('ERROR', ['cannot create ' fullfile(Path_ima,subdir_civ2_new) ': ' m2])%error message for directory creation |
---|
| 2745 | % cd(currentdir) |
---|
[122] | 2746 | filecell={}; |
---|
| 2747 | return |
---|
[112] | 2748 | end |
---|
| 2749 | end |
---|
| 2750 | end |
---|
| 2751 | end |
---|
[127] | 2752 | subdir_civ2=subdir_civ2_new; |
---|
[2] | 2753 | end |
---|
[266] | 2754 | %cd(currentdir);%come back to the current working directory |
---|
[2] | 2755 | |
---|
[282] | 2756 | %%%%%%%%%%%%% if checkciv2 results are obtained or used %%%%%%%%%%%%% |
---|
| 2757 | if checkbox(4)==1 || checkbox(5)==1 || checkbox(6)==1 %civ2 |
---|
| 2758 | %check source netcdf file of checkciv1 estimates |
---|
| 2759 | if checkbox(1)==0; %no civ1 performed |
---|
[2] | 2760 | for ifile=1:nbfield |
---|
| 2761 | for j=1:nbslice |
---|
| 2762 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 2763 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 2764 | filecell.nc.civ1(ifile,j)={filename};% name of the civ1 file |
---|
| 2765 | if ~exist(filename,'file') |
---|
| 2766 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
[122] | 2767 | filecell={}; |
---|
[2] | 2768 | return |
---|
| 2769 | end |
---|
| 2770 | if ~testdiff % civ2 or patch2 are written in the same file as civ1 |
---|
[282] | 2771 | if checkbox(4)==0 ; %check the existence of civ2 if it is not calculated |
---|
[248] | 2772 | Data=nc2struct(filename,'ListGlobalAttribute','CivStage','civ2'); |
---|
| 2773 | if ~isempty(Data.CivStage) && Data.CivStage<4 %test for civ files |
---|
[2] | 2774 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
[12] | 2775 | filecell=[]; |
---|
[2] | 2776 | return |
---|
[248] | 2777 | elseif isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
| 2778 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
| 2779 | filecell=[]; |
---|
| 2780 | return |
---|
[112] | 2781 | end |
---|
[282] | 2782 | elseif checkbox(3)==0; %check the existence of patch if it is not calculated |
---|
[275] | 2783 | Data=nc2struct(filename,'ListGlobalAttribute','CivStage','patch'); |
---|
[248] | 2784 | if ~isempty(Data.CivStage) |
---|
| 2785 | if Data.CivStage<3 %test for civ files |
---|
| 2786 | msgbox_uvmat('ERROR',['no patch data in ' filename]) |
---|
| 2787 | filecell=[]; |
---|
| 2788 | return |
---|
| 2789 | end |
---|
| 2790 | elseif isempty(Data.patch)||isequal(Data.patch,0) |
---|
[2] | 2791 | msgbox_uvmat('ERROR',['no patch data in ' filename]) |
---|
[12] | 2792 | filecell=[]; |
---|
[2] | 2793 | return |
---|
| 2794 | end |
---|
[112] | 2795 | end |
---|
[2] | 2796 | end |
---|
| 2797 | end |
---|
| 2798 | end |
---|
| 2799 | if strcmp(compare,'stereo PIV') |
---|
| 2800 | for ifile=1:nbfield |
---|
| 2801 | for j=1:nbslice |
---|
| 2802 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 2803 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 2804 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
| 2805 | if ~exist(filename,'file') |
---|
| 2806 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
| 2807 | set(handles.RUN, 'Enable','On') |
---|
| 2808 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
| 2809 | return |
---|
| 2810 | end |
---|
| 2811 | end |
---|
| 2812 | end |
---|
| 2813 | end |
---|
| 2814 | end |
---|
[112] | 2815 | |
---|
| 2816 | detect=1; |
---|
[282] | 2817 | % while detect==1%creates a new subdir if the netcdf files already contain checkciv2 data |
---|
[112] | 2818 | for ifile=1:nbfield |
---|
| 2819 | for j=1:nbslice |
---|
| 2820 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
[2] | 2821 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2); |
---|
[112] | 2822 | detect=exist(filename,'file')==2; |
---|
| 2823 | filecell.nc.civ2(ifile,j)={filename}; |
---|
[2] | 2824 | end |
---|
[112] | 2825 | end |
---|
[282] | 2826 | %get first image names for checkciv2 |
---|
| 2827 | if checkbox(1)==1 && isequal(num1_civ1,num1_civ2) && isequal(num_a_civ1,num_a_civ2) |
---|
[2] | 2828 | filecell.ima1.civ2=filecell.ima1.civ1; |
---|
[282] | 2829 | elseif checkbox(4)==1 |
---|
[2] | 2830 | for ifile=1:nbfield |
---|
| 2831 | for j=1:nbslice |
---|
| 2832 | filename=name_generator(filebase_ima1, num1_civ2(ifile),num_a_civ2(j),ext_ima,nom_type_ima1); |
---|
| 2833 | idetect_2(j)=exist(filename,'file')==2; |
---|
| 2834 | filecell.ima1.civ2(ifile,j)={filename};%first image |
---|
| 2835 | end |
---|
[112] | 2836 | [idetectmin,indexj]=min(idetect_2); |
---|
[2] | 2837 | if idetectmin==0, |
---|
[112] | 2838 | msgbox_uvmat('ERROR',['input image ' filecell.ima1.civ2{ifile,indexj} ' not found']) |
---|
| 2839 | filecell=[]; |
---|
| 2840 | return |
---|
[2] | 2841 | end |
---|
| 2842 | end |
---|
| 2843 | end |
---|
| 2844 | |
---|
[282] | 2845 | %get second image names for checkciv2 |
---|
| 2846 | if checkbox(1)==1 && isequal(num2_civ1,num2_civ2) && isequal(num_b_civ1,num_b_civ2) |
---|
[2] | 2847 | filecell.ima2.civ2=filecell.ima2.civ1; |
---|
[282] | 2848 | elseif checkbox(4)==1 |
---|
[2] | 2849 | for ifile=1:nbfield |
---|
| 2850 | for j=1:nbslice |
---|
| 2851 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),ext_ima,nom_type_ima2); |
---|
| 2852 | idetect_3(j)=exist(filename,'file')==2; |
---|
| 2853 | filecell.ima2.civ2(ifile,j)={filename};%first image |
---|
| 2854 | end |
---|
[112] | 2855 | [idetectmin,indexj]=min(idetect_3); |
---|
[2] | 2856 | if idetectmin==0, |
---|
[112] | 2857 | msgbox_uvmat('ERROR',['input image ' filecell.ima2.civ2{ifile,indexj} ' not found']) |
---|
| 2858 | filecell=[]; |
---|
| 2859 | return |
---|
[2] | 2860 | end |
---|
| 2861 | end |
---|
| 2862 | end |
---|
| 2863 | end |
---|
[282] | 2864 | if (checkbox(5) || checkbox(6)) && ~checkbox(4) % need to read an existing netcdf civ2 file |
---|
[2] | 2865 | if ~testdiff |
---|
| 2866 | filecell.nc.civ2=filecell.nc.civ1;% file already checked |
---|
[112] | 2867 | else % check the civ2 files |
---|
[2] | 2868 | for ifile=1:nbfield |
---|
| 2869 | for j=1:nbslice |
---|
| 2870 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
[112] | 2871 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
[2] | 2872 | filecell.nc.civ2(ifile,j)={filename}; |
---|
| 2873 | if ~exist(filename,'file') |
---|
| 2874 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
[12] | 2875 | filecell=[]; |
---|
[2] | 2876 | return |
---|
| 2877 | else |
---|
[248] | 2878 | Data=nc2struct(filename,'ListGlobalAttribute','CivStage','civ2'); |
---|
| 2879 | if ~isempty(Data.CivStage) && Data.CivStage<4 %test for civ files |
---|
| 2880 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
| 2881 | filecell=[]; |
---|
| 2882 | return |
---|
| 2883 | elseif isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
[2] | 2884 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
[12] | 2885 | filecell=[]; |
---|
[2] | 2886 | return |
---|
| 2887 | end |
---|
| 2888 | end |
---|
| 2889 | end |
---|
| 2890 | end |
---|
| 2891 | end |
---|
| 2892 | end |
---|
| 2893 | |
---|
| 2894 | %%%%%%%%%%%%% if stereo fields are calculated by PATCH %%%%%%%%%%%%% |
---|
| 2895 | if strcmp(compare,'stereo PIV') |
---|
[282] | 2896 | if checkbox(3) && isequal(get(handles.test_stereo1,'Value'),1) |
---|
[2] | 2897 | for ifile=1:nbfield |
---|
| 2898 | for j=1:nbslice |
---|
| 2899 | filename=name_generator(filebase_AB,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
| 2900 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
| 2901 | filecell.st(ifile,j)={filename}; |
---|
| 2902 | end |
---|
| 2903 | end |
---|
| 2904 | end |
---|
[282] | 2905 | if checkbox(6) && isequal(get(handles.CheckStereo,'Value'),1) |
---|
[2] | 2906 | for ifile=1:nbfield |
---|
| 2907 | for j=1:nbslice |
---|
| 2908 | filename=name_generator(filebase_AB,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
| 2909 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
| 2910 | filecell.st(ifile,j)={filename}; |
---|
| 2911 | end |
---|
| 2912 | end |
---|
[112] | 2913 | end |
---|
[2] | 2914 | end |
---|
[289] | 2915 | set(handles.txt_SubdirCiv1,'String',subdir_civ1);%update the edit box |
---|
| 2916 | set(handles.txt_SubdirCiv2,'String',subdir_civ2);%update the edit box |
---|
[2] | 2917 | browse.nom_type_nc=nom_type_nc; |
---|
[273] | 2918 | set(handles.RootName,'UserData',browse); %update the nomenclature type for uvmat |
---|
[2] | 2919 | |
---|
| 2920 | |
---|
| 2921 | %COPY IMAGES TO THE FORMAT .png IF NEEDED |
---|
[45] | 2922 | if isequal(nom_type_ima1,'*')%case of movie files |
---|
| 2923 | nom_type_imanew1='_i'; |
---|
[2] | 2924 | else |
---|
| 2925 | nom_type_imanew1=nom_type_ima1; |
---|
| 2926 | end |
---|
[45] | 2927 | if isequal(nom_type_ima2,'*')%case of movie files |
---|
| 2928 | nom_type_imanew2='_i'; |
---|
[2] | 2929 | else |
---|
| 2930 | nom_type_imanew2=nom_type_ima2; |
---|
| 2931 | end |
---|
| 2932 | if ~isequal(ext_ima,'.png') |
---|
[45] | 2933 | %%type of image file |
---|
| 2934 | type_ima1='none';%default |
---|
| 2935 | movieobject1=[];%default |
---|
[133] | 2936 | if strcmpi(ext_ima,'.avi') |
---|
[45] | 2937 | hhh=which('mmreader'); |
---|
| 2938 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
---|
| 2939 | type_ima1='movie'; |
---|
| 2940 | movieobject1=mmreader([filebase_ima2 ext_ima]); |
---|
| 2941 | else |
---|
| 2942 | type_ima1='avi'; |
---|
| 2943 | end |
---|
[133] | 2944 | elseif ischar(ext_ima) && ~isempty(ext_ima(2:end)) |
---|
[112] | 2945 | form=imformats(ext_ima(2:end)); |
---|
| 2946 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 2947 | if isequal(nom_type_ima1,'*'); |
---|
| 2948 | type_ima1='multimage';%image series in a single image file |
---|
| 2949 | else |
---|
| 2950 | type_ima1='image'; |
---|
| 2951 | end |
---|
| 2952 | end |
---|
[45] | 2953 | end |
---|
| 2954 | type_ima2='none';%default |
---|
| 2955 | movieobject2=[]; |
---|
[133] | 2956 | if strcmpi(ext_ima,'.avi') |
---|
[45] | 2957 | hhh=which('mmreader'); |
---|
| 2958 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
---|
| 2959 | type_ima2='movie'; |
---|
| 2960 | movieobject2=mmreader([filebase_ima2 ext_ima]); |
---|
| 2961 | else |
---|
| 2962 | type_ima2='avi'; |
---|
| 2963 | end |
---|
[133] | 2964 | elseif ischar(ext_ima) && ~isempty(ext_ima(2:end)) |
---|
[112] | 2965 | form=imformats(ext_ima(2:end)); |
---|
| 2966 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 2967 | if isequal(nom_type_ima1,'*'); |
---|
| 2968 | type_ima2='multimage';%image series in a single image file |
---|
| 2969 | else |
---|
| 2970 | type_ima2='image'; |
---|
| 2971 | end |
---|
| 2972 | end |
---|
[45] | 2973 | end |
---|
[71] | 2974 | %npxy=get(handles.ImaExt,'UserData'); |
---|
[112] | 2975 | % % if numel(npxy)<2 |
---|
| 2976 | % |
---|
| 2977 | % filename=name_generator(filebase_ima1,num1_civ1(1),num_a_civ1(1),ImaExt,nom_type_ima1); |
---|
| 2978 | % A=imread(filename); |
---|
| 2979 | % npxy=size(A); |
---|
| 2980 | % % end |
---|
| 2981 | % npy=npxy(1); |
---|
| 2982 | % npx=npxy(2); |
---|
[282] | 2983 | if checkbox(1) %if civ1 is performed |
---|
[224] | 2984 | h = waitbar(0,'copy images to the .png format for civ1');% display a wait bar |
---|
[112] | 2985 | for ifile=1:nbfield |
---|
[2] | 2986 | waitbar(ifile/nbfield); |
---|
| 2987 | for j=1:nbslice |
---|
[112] | 2988 | filename=name_generator(filebase_ima1,num1_civ1(ifile),num_a_civ1(j),'.png',nom_type_imanew1); |
---|
| 2989 | if ~exist(filename,'file') |
---|
| 2990 | A=read_image(filecell.ima1.civ1{ifile,j},type_ima1,num1_civ1(ifile),movieobject1); |
---|
| 2991 | imwrite(A,filename,'BitDepth',16); |
---|
| 2992 | end |
---|
| 2993 | filecell.ima1.civ1(ifile,j)={filename}; |
---|
| 2994 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),'.png',nom_type_imanew2); |
---|
| 2995 | if ~exist(filename,'file') |
---|
| 2996 | A=read_image(filecell.ima2.civ1{ifile,j},type_ima2,num2_civ1(ifile),movieobject2); |
---|
| 2997 | imwrite(A,filename,'BitDepth',16); |
---|
| 2998 | end |
---|
| 2999 | filecell.ima2.civ1(ifile,j)={filename}; |
---|
[2] | 3000 | end |
---|
| 3001 | end |
---|
| 3002 | close(h) |
---|
| 3003 | end |
---|
[282] | 3004 | if checkbox(4) %if civ2 is performed |
---|
[229] | 3005 | h = waitbar(0,'copy images to the .png format for civ2');% display a wait bar |
---|
[2] | 3006 | for ifile=1:nbfield |
---|
| 3007 | waitbar(ifile/nbfield); |
---|
| 3008 | for j=1:nbslice |
---|
[112] | 3009 | filename=name_generator(filebase_ima1,num1_civ2(ifile),num_a_civ2(j),'.png',nom_type_imanew1); |
---|
| 3010 | if ~exist(filename,'file') |
---|
| 3011 | A=read_image(cell2mat(filecell.ima1.civ2(ifile,j)),type_ima2,num1_civ2(ifile)); |
---|
| 3012 | imwrite(A,filename,'BitDepth',16); |
---|
| 3013 | end |
---|
| 3014 | filecell.ima1.civ2(ifile,j)={filename}; |
---|
| 3015 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),'.png',nom_type_imanew2); |
---|
| 3016 | if ~exist(filename,'file') |
---|
| 3017 | A=read_image(cell2mat(filecell.ima2.civ2(ifile,j)),type_ima2,num2_civ2(ifile)); |
---|
| 3018 | imwrite(A,filename,'BitDepth',16); |
---|
| 3019 | end |
---|
| 3020 | filecell.ima2.civ2(ifile,j)={filename}; |
---|
[2] | 3021 | end |
---|
| 3022 | end |
---|
| 3023 | close(h); |
---|
| 3024 | end |
---|
| 3025 | end |
---|
| 3026 | |
---|
[12] | 3027 | %------------------------------------------------------------------------ |
---|
[227] | 3028 | % --- determine the list of index pairs of processing file |
---|
| 3029 | function [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
| 3030 | find_pair_indices(handles,ref_i,ref_j,mode) |
---|
| 3031 | %------------------------------------------------------------------------ |
---|
| 3032 | |
---|
[282] | 3033 | list_civ1=get(handles.ListPairCiv1,'String'); |
---|
| 3034 | index_civ1=get(handles.ListPairCiv1,'Value'); |
---|
[227] | 3035 | str_civ1=list_civ1{index_civ1};%string defining the image pairs for civ1 |
---|
| 3036 | if isempty(str_civ1)||isequal(str_civ1,'') |
---|
| 3037 | msgbox_uvmat('ERROR','no image pair selected for civ1') |
---|
| 3038 | return |
---|
| 3039 | end |
---|
[282] | 3040 | list_civ2=get(handles.ListPairCiv2,'String'); |
---|
| 3041 | index_civ2=get(handles.ListPairCiv2,'Value'); |
---|
[227] | 3042 | if index_civ2>length(list_civ2) |
---|
| 3043 | list_civ2=list_civ1; |
---|
| 3044 | index_civ2=index_civ1; |
---|
| 3045 | end |
---|
| 3046 | str_civ2=list_civ2{index_civ2};%string defining the image pairs for civ2 |
---|
| 3047 | |
---|
| 3048 | if isequal (mode,'series(Di)') |
---|
| 3049 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 3050 | num1_civ1=ref_i-floor(index_civ1/2)*ones(size(ref_i));% set of first image numbers |
---|
| 3051 | num2_civ1=ref_i+ceil(index_civ1/2)*ones(size(ref_i)); |
---|
| 3052 | num_a_civ1=ref_j; |
---|
| 3053 | num_b_civ1=ref_j; |
---|
[229] | 3054 | num1_civ2=ref_i-floor(index_civ2/2)*ones(size(ref_i)); |
---|
[227] | 3055 | num2_civ2=ref_i+ceil(index_civ2/2)*ones(size(ref_i)); |
---|
| 3056 | num_a_civ2=ref_j; |
---|
| 3057 | num_b_civ2=ref_j; |
---|
| 3058 | |
---|
| 3059 | % adjust the first and last field number |
---|
| 3060 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
| 3061 | if isnan(lastfield) |
---|
| 3062 | indsel=find((num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
| 3063 | else |
---|
| 3064 | indsel=find((num2_civ1 <= lastfield)&(num2_civ2 <= lastfield)&(num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
| 3065 | end |
---|
| 3066 | if length(indsel)>=1 |
---|
| 3067 | firstind=indsel(1); |
---|
| 3068 | lastind=indsel(end); |
---|
| 3069 | set(handles.first_i,'String',num2str(ref_i(firstind)))%update the display of first and last fields |
---|
| 3070 | set(handles.last_i,'String',num2str(ref_i(lastind))) |
---|
| 3071 | ref_i=ref_i(indsel); |
---|
| 3072 | num1_civ1=num1_civ1(indsel); |
---|
| 3073 | num1_civ2=num1_civ2(indsel); |
---|
| 3074 | num2_civ1=num2_civ1(indsel); |
---|
| 3075 | num2_civ2=num2_civ2(indsel); |
---|
| 3076 | end |
---|
| 3077 | elseif isequal (mode,'series(Dj)') |
---|
| 3078 | lastfield_j=str2double(get(handles.nb_field2,'String')); |
---|
| 3079 | num1_civ1=ref_i;% set of first image numbers |
---|
| 3080 | num2_civ1=ref_i; |
---|
| 3081 | num_a_civ1=ref_j-floor(index_civ1/2)*ones(size(ref_j)); |
---|
| 3082 | num_b_civ1=ref_j+ceil(index_civ1/2)*ones(size(ref_j)); |
---|
| 3083 | num1_civ2=ref_i; |
---|
| 3084 | num2_civ2=ref_i; |
---|
| 3085 | num_a_civ2=ref_j-floor(index_civ2/2)*ones(size(ref_j)); |
---|
| 3086 | num_b_civ2=ref_j+ceil(index_civ2/2)*ones(size(ref_j)); |
---|
| 3087 | % adjust the first and last field number |
---|
| 3088 | if isnan(lastfield_j) |
---|
| 3089 | indsel=find((num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
| 3090 | else |
---|
| 3091 | indsel=find((num_b_civ1 <= lastfield_j)&(num_b_civ2 <= lastfield_j)&(num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
| 3092 | end |
---|
| 3093 | if length(indsel)>=1 |
---|
| 3094 | firstind=indsel(1); |
---|
| 3095 | lastind=indsel(end); |
---|
| 3096 | set(handles.first_j,'String',num2str(ref_j(firstind)))%update the display of first and last fields |
---|
| 3097 | set(handles.last_j,'String',num2str(ref_j(lastind))) |
---|
| 3098 | ref_j=ref_j(indsel); |
---|
| 3099 | num_a_civ1=num_a_civ1(indsel); |
---|
| 3100 | num_b_civ1=num_b_civ1(indsel); |
---|
| 3101 | num_a_civ2=num_a_civ2(indsel); |
---|
| 3102 | num_b_civ2=num_b_civ2(indsel); |
---|
| 3103 | end |
---|
| 3104 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
[282] | 3105 | displ_num=get(handles.ListPairCiv1,'UserData'); |
---|
[227] | 3106 | num1_civ1=ref_i; |
---|
| 3107 | num2_civ1=ref_i; |
---|
| 3108 | num_a_civ1=displ_num(1,index_civ1); |
---|
| 3109 | num_b_civ1=displ_num(2,index_civ1); |
---|
| 3110 | num1_civ2=ref_i; |
---|
| 3111 | num2_civ2=ref_i; |
---|
| 3112 | num_a_civ2=displ_num(1,index_civ2); |
---|
| 3113 | num_b_civ2=displ_num(2,index_civ2); |
---|
| 3114 | elseif isequal(mode,'displacement') |
---|
| 3115 | num1_civ1=ref_i; |
---|
| 3116 | num2_civ1=ref_i; |
---|
| 3117 | num_a_civ1=ref_j; |
---|
| 3118 | num_b_civ1=ref_j; |
---|
| 3119 | num1_civ2=ref_i; |
---|
| 3120 | num2_civ2=ref_i; |
---|
| 3121 | num_a_civ2=ref_j; |
---|
| 3122 | num_b_civ2=ref_j; |
---|
| 3123 | end |
---|
| 3124 | |
---|
| 3125 | |
---|
| 3126 | %------------------------------------------------------------------------ |
---|
[12] | 3127 | % --- STEREO Interp |
---|
[67] | 3128 | 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] | 3129 | %------------------------------------------------------------------------ |
---|
[224] | 3130 | namelog=[filename_nc(1:end-3) '_stinterp.log']; |
---|
[67] | 3131 | cmd=[stinterpBin ' -f1 ' filename_A_nc ' -f2 ' filename_B_nc ' -f ' filename_nc ... |
---|
[2] | 3132 | ' -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 |
---|
| 3133 | |
---|
[12] | 3134 | %------------------------------------------------------------------------ |
---|
[282] | 3135 | % --- Executes on button press in CheckCiv1. |
---|
| 3136 | function CheckCiv1_Callback(hObject, eventdata, handles) |
---|
[12] | 3137 | %------------------------------------------------------------------------ |
---|
[289] | 3138 | update_CivOptions(handles) |
---|
[2] | 3139 | |
---|
[12] | 3140 | %------------------------------------------------------------------------ |
---|
[282] | 3141 | % --- Executes on button press in CheckFix1. |
---|
| 3142 | function CheckFix1_Callback(hObject, eventdata, handles) |
---|
[12] | 3143 | %------------------------------------------------------------------------ |
---|
[289] | 3144 | update_CivOptions(handles) |
---|
[2] | 3145 | |
---|
[12] | 3146 | %------------------------------------------------------------------------ |
---|
[282] | 3147 | % --- Executes on button press in CheckPatch1. |
---|
| 3148 | function CheckPatch1_Callback(hObject, eventdata, handles) |
---|
[12] | 3149 | %------------------------------------------------------------------------ |
---|
[289] | 3150 | update_CivOptions(handles) |
---|
[2] | 3151 | |
---|
[12] | 3152 | %------------------------------------------------------------------------ |
---|
[282] | 3153 | % --- Executes on button press in CheckCiv2. |
---|
| 3154 | function CheckCiv2_Callback(hObject, eventdata, handles) |
---|
[12] | 3155 | %------------------------------------------------------------------------ |
---|
[289] | 3156 | update_CivOptions(handles) |
---|
[2] | 3157 | |
---|
[12] | 3158 | %------------------------------------------------------------------------ |
---|
[282] | 3159 | % --- Executes on button press in CheckFix2. |
---|
| 3160 | function CheckFix2_Callback(hObject, eventdata, handles) |
---|
[12] | 3161 | %------------------------------------------------------------------------ |
---|
[289] | 3162 | update_CivOptions(handles) |
---|
[2] | 3163 | |
---|
[12] | 3164 | %------------------------------------------------------------------------ |
---|
[282] | 3165 | % --- Executes on button press in CheckPatch2. |
---|
| 3166 | function CheckPatch2_Callback(hObject, eventdata, handles) |
---|
[12] | 3167 | %------------------------------------------------------------------------ |
---|
[289] | 3168 | update_CivOptions(handles) |
---|
| 3169 | |
---|
| 3170 | %------------------------------------------------------------------------ |
---|
| 3171 | % --- activated by any checkbox controling the selection of Civ1,Fix1,Patch1,Civ2,Fix2,Patch2 |
---|
| 3172 | function update_CivOptions(handles) |
---|
| 3173 | %------------------------------------------------------------------------ |
---|
| 3174 | checkbox=zeros(1,6); |
---|
| 3175 | checkbox(1)=get(handles.CheckCiv1,'Value'); |
---|
| 3176 | checkbox(2)=get(handles.CheckFix1,'Value'); |
---|
| 3177 | checkbox(3)=get(handles.CheckPatch1,'Value'); |
---|
| 3178 | checkbox(4)=get(handles.CheckCiv2,'Value'); |
---|
| 3179 | checkbox(5)=get(handles.CheckFix2,'Value'); |
---|
| 3180 | checkbox(6)=get(handles.CheckPatch2,'Value'); |
---|
| 3181 | ind_selected=find(checkbox); |
---|
| 3182 | if ~isempty(ind_selected) |
---|
| 3183 | RootName=get(handles.RootName,'String'); |
---|
| 3184 | if isempty(RootName) |
---|
| 3185 | msgbox_uvmat('ERROR','No input file') |
---|
| 3186 | return |
---|
| 3187 | end |
---|
[2] | 3188 | end |
---|
[289] | 3189 | set(handles.PairIndices,'Visible','on') |
---|
| 3190 | set(handles.txt_SubdirCiv1,'Visible','on') |
---|
| 3191 | set(handles.ListSubdirCiv1,'Visible','on') |
---|
| 3192 | find_netcpair_civ1(handles) % select the available netcdf files |
---|
| 3193 | % check_civ2pair=ind_selected(4;6); |
---|
| 3194 | if max(checkbox(4:6))% case of civ2 pair choice needed |
---|
| 3195 | set(handles.TitlePairCiv2,'Visible','on') |
---|
| 3196 | set(handles.TitleSubdirCiv2,'Visible','on') |
---|
| 3197 | set(handles.txt_SubdirCiv2,'Visible','on') |
---|
| 3198 | set(handles.ListSubdirCiv2,'Visible','on') |
---|
| 3199 | set(handles.ListPairCiv2,'Visible','on') |
---|
| 3200 | find_netcpair_civ2(handles) % select the available netcdf files |
---|
| 3201 | else |
---|
| 3202 | set(handles.TitleSubdirCiv2,'Visible','off') |
---|
| 3203 | set(handles.txt_SubdirCiv2,'Visible','off') |
---|
| 3204 | set(handles.ListSubdirCiv2,'Visible','off') |
---|
| 3205 | set(handles.ListPairCiv2,'Visible','off') |
---|
| 3206 | end |
---|
| 3207 | %index_last=find(checkbox,1,'last');%last selected button |
---|
| 3208 | options={'Civ1','Fix1','Patch1','Civ2','Fix2','Patch2'}; |
---|
| 3209 | for ilist=1:length(options) |
---|
| 3210 | if checkbox(ilist) |
---|
| 3211 | set(handles.(options{ilist}),'Visible','on') |
---|
| 3212 | else |
---|
| 3213 | set(handles.(options{ilist}),'Visible','off') |
---|
| 3214 | end |
---|
| 3215 | end |
---|
[2] | 3216 | |
---|
[289] | 3217 | % end |
---|
| 3218 | |
---|
| 3219 | % set(handles.(operations(ind_selected)),'Visible','on') |
---|
| 3220 | % |
---|
| 3221 | % if state |
---|
| 3222 | % RootName=get(handles.RootName,'String'); |
---|
| 3223 | % if isempty(RootName) |
---|
| 3224 | % msgbox_uvmat('ERROR','No input file') |
---|
| 3225 | % return |
---|
| 3226 | % end |
---|
| 3227 | % set(handles.Civ1,'Visible','on') |
---|
| 3228 | % set(handles.PairIndices,'Visible','on') |
---|
| 3229 | % else |
---|
| 3230 | % set(handles.Civ1,'Visible','off') |
---|
| 3231 | % end |
---|
| 3232 | |
---|
| 3233 | |
---|
[12] | 3234 | %------------------------------------------------------------------------ |
---|
| 3235 | function first_i_Callback(hObject, eventdata, handles) |
---|
| 3236 | %------------------------------------------------------------------------ |
---|
| 3237 | % last_i_Callback(hObject, eventdata, handles) |
---|
[137] | 3238 | first_i=str2double(get(handles.first_i,'String')); |
---|
[12] | 3239 | % last_i=str2num(get(handles.last_i,'String')); |
---|
| 3240 | % ref_i=ceil((first_i+last_i)/2); |
---|
| 3241 | set(handles.ref_i,'String', num2str(first_i))% reference index for pair dt = first index |
---|
[273] | 3242 | %set(handles.ref_i_civ2,'String', num2str(first_i))% reference index for pair dt = first index |
---|
[12] | 3243 | ref_i_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3244 | |
---|
[12] | 3245 | %------------------------------------------------------------------------ |
---|
| 3246 | function first_j_Callback(hObject, eventdata, handles) |
---|
| 3247 | %------------------------------------------------------------------------ |
---|
| 3248 | first_j=str2num(get(handles.first_j,'String')); |
---|
| 3249 | set(handles.ref_j,'String', num2str(first_j))% reference index for pair dt = first index |
---|
| 3250 | ref_j_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[2] | 3251 | |
---|
[12] | 3252 | %------------------------------------------------------------------------ |
---|
[287] | 3253 | % --- Executes on button press in SearchRange: determine the search range num_Searchx,num_Searchy |
---|
[273] | 3254 | function SearchRange_Callback(hObject, eventdata, handles) |
---|
[12] | 3255 | %------------------------------------------------------------------------ |
---|
[2] | 3256 | %determine pair numbers |
---|
[273] | 3257 | if strcmp(get(handles.umin,'Visible'),'off') |
---|
| 3258 | set(handles.u_title,'Visible','on') |
---|
| 3259 | set(handles.v_title,'Visible','on') |
---|
| 3260 | set(handles.umin,'Visible','on') |
---|
| 3261 | set(handles.umax,'Visible','on') |
---|
| 3262 | set(handles.vmin,'Visible','on') |
---|
| 3263 | set(handles.vmax,'Visible','on') |
---|
| 3264 | set(handles.CoordUnit,'Visible','on') |
---|
| 3265 | set(handles.TimeUnit,'Visible','on') |
---|
| 3266 | set(handles.slash_title,'Visible','on') |
---|
| 3267 | set(handles.min_title,'Visible','on') |
---|
| 3268 | set(handles.max_title,'Visible','on') |
---|
| 3269 | set(handles.unit_title,'Visible','on') |
---|
| 3270 | else |
---|
| 3271 | get_search_range(hObject, eventdata, handles) |
---|
[2] | 3272 | end |
---|
| 3273 | |
---|
[12] | 3274 | %------------------------------------------------------------------------ |
---|
[287] | 3275 | % --- determine the search range num_Searchx,num_Searchy and shift |
---|
[273] | 3276 | function get_search_range(hObject, eventdata, handles) |
---|
| 3277 | umin=str2double(get(handles.umin,'String')); |
---|
| 3278 | umax=str2double(get(handles.umax,'String')); |
---|
| 3279 | vmin=str2double(get(handles.umin,'String')); |
---|
| 3280 | vmax=str2double(get(handles.vmax,'String')); |
---|
| 3281 | %switch min_title and max_title in case of error |
---|
| 3282 | if umax<=umin |
---|
| 3283 | umin_old=umin; |
---|
| 3284 | umin=umax; |
---|
| 3285 | umax=umin_old; |
---|
| 3286 | set(handles.umin,'String', num2str(umin)) |
---|
| 3287 | set(handles.umax,'String', num2str(umax)) |
---|
| 3288 | end |
---|
| 3289 | if vmax<=vmin |
---|
| 3290 | vmin_old=vmin; |
---|
| 3291 | vmin=vmax; |
---|
| 3292 | vmax=vmin_old; |
---|
| 3293 | set(handles.vmin,'String', num2str(vmin)) |
---|
| 3294 | set(handles.vmax,'String', num2str(vmax)) |
---|
| 3295 | end |
---|
| 3296 | if ~(isnan(umin)||isnan(umax)||isnan(vmin)||isnan(vmax)) |
---|
[282] | 3297 | list_pair=get(handles.ListPairCiv1,'String');%get the menu of image pairs |
---|
| 3298 | index=get(handles.ListPairCiv1,'Value'); |
---|
| 3299 | displ_num=get(handles.ListPairCiv1,'UserData'); |
---|
[273] | 3300 | time=get(handles.ImaDoc,'UserData'); %get the set of times |
---|
| 3301 | pxcm_xy=get(handles.SearchRange,'UserData'); |
---|
| 3302 | pxcmx=pxcm_xy(1); |
---|
| 3303 | pxcmy=pxcm_xy(2); |
---|
[282] | 3304 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 3305 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[273] | 3306 | mode=mode_list{mode_value}; |
---|
| 3307 | if isequal (mode, 'series(Di)' ) |
---|
| 3308 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
| 3309 | num1=ref_i-floor(index/2);% first image numbers |
---|
| 3310 | num2=ref_i+ceil(index/2); |
---|
| 3311 | num_a=1; |
---|
| 3312 | num_b=1; |
---|
| 3313 | elseif isequal (mode, 'series(Dj)') |
---|
| 3314 | num1=1; |
---|
| 3315 | num2=1; |
---|
| 3316 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
| 3317 | num_a=ref_j-floor(index/2);% first image numbers |
---|
| 3318 | num_b=ref_j+ceil(index/2); |
---|
| 3319 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
| 3320 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
| 3321 | num1=ref_i; |
---|
| 3322 | num2=ref_i; |
---|
| 3323 | num_a=displ_num(1,index); |
---|
| 3324 | num_b=displ_num(2,index); |
---|
| 3325 | end |
---|
| 3326 | dt=time(num2,num_b)-time(num1,num_a); |
---|
[282] | 3327 | ibx=str2double(get(handles.num_Bx,'String')); |
---|
| 3328 | iby=str2double(get(handles.num_By,'String')); |
---|
[273] | 3329 | umin=dt*pxcmx*umin; |
---|
| 3330 | umax=dt*pxcmx*umax; |
---|
| 3331 | vmin=dt*pxcmy*vmin; |
---|
| 3332 | vmax=dt*pxcmy*vmax; |
---|
| 3333 | shiftx=round((umin+umax)/2); |
---|
| 3334 | shifty=round((vmin+vmax)/2); |
---|
| 3335 | isx=(umax+2-shiftx)*2+ibx; |
---|
| 3336 | isx=2*ceil(isx/2)+1; |
---|
| 3337 | isy=(vmax+2-shifty)*2+iby; |
---|
| 3338 | isy=2*ceil(isy/2)+1; |
---|
[282] | 3339 | set(handles.num_Shiftx,'String',num2str(shiftx)); |
---|
| 3340 | set(handles.num_Shifty,'String',num2str(shifty)); |
---|
[287] | 3341 | set(handles.num_Searchx,'String',num2str(isx)); |
---|
| 3342 | set(handles.num_Searchy,'String',num2str(isy)); |
---|
[273] | 3343 | end |
---|
| 3344 | |
---|
| 3345 | %------------------------------------------------------------------------ |
---|
[282] | 3346 | % --- Executes on carriage return on the subdir checkciv1 edit window |
---|
[289] | 3347 | function txt_SubdirCiv1_Callback(hObject, eventdata, handles) |
---|
[12] | 3348 | %------------------------------------------------------------------------ |
---|
[289] | 3349 | subdir=get(handles.txt_SubdirCiv1,'String'); |
---|
| 3350 | set(handles.txt_SubdirCiv2,'String',subdir);% set civ2 directory the same as civ1 by default |
---|
[282] | 3351 | menu_str=get(handles.ListSubdirCiv1,'String');% read the list of subdirectories for update |
---|
[273] | 3352 | ichoice=find(strcmp(subdir,menu_str),1); |
---|
| 3353 | if isempty(ichoice) |
---|
| 3354 | ilist=numel(menu_str); %select 'new...' in the menu |
---|
| 3355 | else |
---|
| 3356 | ilist=ichoice; |
---|
| 3357 | end |
---|
[282] | 3358 | set(handles.ListSubdirCiv1,'Value',ilist)% select the selected subdir in the menu |
---|
| 3359 | if get(handles.CheckCiv1,'Value')==0 |
---|
[2] | 3360 | find_netcpair_civ1(hObject, eventdata, handles); %update the list of available pairs from netcdf files in the new directory |
---|
| 3361 | end |
---|
| 3362 | |
---|
[12] | 3363 | %------------------------------------------------------------------------ |
---|
[282] | 3364 | % --- Executes on carriage return on the subdir checkciv1 edit window |
---|
[289] | 3365 | function txt_SubdirCiv2_Callback(hObject, eventdata, handles) |
---|
[12] | 3366 | %------------------------------------------------------------------------ |
---|
[289] | 3367 | subdir=get(handles.txt_SubdirCiv1,'String'); |
---|
| 3368 | menu_str=get(handles.ListSubdirCiv2,'String');% read the list of subdirectories for update |
---|
[273] | 3369 | ichoice=find(strcmp(subdir,menu_str),1); |
---|
| 3370 | if isempty(ichoice) |
---|
| 3371 | ilist=numel(menu_str); %select 'new...' in the menu |
---|
| 3372 | else |
---|
| 3373 | ilist=ichoice; |
---|
| 3374 | end |
---|
[289] | 3375 | set(handles.ListSubdirCiv2,'Value',ilist)% select the selected subdir in the menu |
---|
[2] | 3376 | %update the list of available pairs from netcdf files in the new directory |
---|
[282] | 3377 | if ~get(handles.CheckCiv2,'Value') && ~get(handles.CheckCiv1,'Value') && ~get(handles.CheckFix1,'Value') && ~get(handles.CheckPatch1,'Value') |
---|
[2] | 3378 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 3379 | end |
---|
| 3380 | |
---|
[276] | 3381 | % %------------------------------------------------------------------------ |
---|
[282] | 3382 | % % --- Executes on button press in CheckMask: select box for mask option |
---|
[276] | 3383 | % function check_Mask_Callback(hObject, eventdata, handles) |
---|
| 3384 | % %------------------------------------------------------------------------ |
---|
[282] | 3385 | % maskval=get(handles.CheckMask,'Value'); |
---|
[276] | 3386 | % if isequal(maskval,0) |
---|
| 3387 | % set(handles.txt_MaskName,'Visible','off') |
---|
| 3388 | % % set(handles.txt_MaskName,'String','') |
---|
| 3389 | % else |
---|
| 3390 | % mask_displ='no mask'; %default |
---|
| 3391 | % filebase=get(handles.RootName,'String'); |
---|
| 3392 | % [ nbslice_mask, flag_mask]=get_mask(filebase,handles); |
---|
| 3393 | % if isequal(flag_mask,1) |
---|
| 3394 | % mask_displ=[num2str(nbslice_mask) 'mask']; |
---|
[282] | 3395 | % elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[276] | 3396 | % common_path=fileparts(filebase); |
---|
| 3397 | % filebase_a=fullfile(common_path,get(handles.RootName_1,'String')); |
---|
| 3398 | % [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
| 3399 | % if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice_mask) |
---|
| 3400 | % mask_displ='no mask'; |
---|
| 3401 | % end |
---|
| 3402 | % end |
---|
| 3403 | % if isequal(mask_displ,'no mask') |
---|
| 3404 | % [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3405 | % {'*.png', ' (*.png)'; |
---|
| 3406 | % '*.png', '.png files '; ... |
---|
| 3407 | % '*.*', 'All Files (*.*)'}, ... |
---|
| 3408 | % 'Pick a mask file *.png',filebase); |
---|
| 3409 | % mask_displ=fullfile(PathName,FileName); |
---|
| 3410 | % if exist(mask_displ,'file') |
---|
| 3411 | % set(handles.txt_MaskName,'Visible','on') |
---|
| 3412 | % set(handles.txt_MaskName,'String',mask_displ) |
---|
| 3413 | % % mask_displ='no mask'; |
---|
| 3414 | % end |
---|
| 3415 | % end |
---|
| 3416 | % if isequal(mask_displ,'no mask') |
---|
[282] | 3417 | % set(handles.CheckMask,'Value',0) |
---|
| 3418 | % set(handles.CheckMask,'Value',0) |
---|
| 3419 | % set(handles.CheckMask,'Value',0) |
---|
| 3420 | % set(handles.CheckMask,'Value',0) |
---|
[276] | 3421 | % else |
---|
[282] | 3422 | % set(handles.CheckMask,'Value',1) |
---|
| 3423 | % set(handles.CheckMask,'Value',1) |
---|
[276] | 3424 | % end |
---|
| 3425 | % set(handles.txt_MaskName,'String',mask_displ) |
---|
[282] | 3426 | % set(handles.txt_MaskName,'String',mask_displ) |
---|
[276] | 3427 | % set(handles.txt_Mask,'String',mask_displ) |
---|
[287] | 3428 | % set(handles.txt_MaskName,'String',mask_displ) |
---|
[276] | 3429 | % end |
---|
[282] | 3430 | % set(handles.CheckMask,'Value',maskval)%update the checkciv2 mask with the same option as checkciv1 |
---|
[2] | 3431 | |
---|
[12] | 3432 | %------------------------------------------------------------------------ |
---|
[282] | 3433 | % --- Executes on button press in CheckMask. |
---|
[2] | 3434 | function get_mask_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 3435 | %------------------------------------------------------------------------ |
---|
[282] | 3436 | maskval=get(handles.CheckMask,'Value'); |
---|
[2] | 3437 | if isequal(maskval,0) |
---|
[282] | 3438 | set(handles.txt_MaskName,'String','') |
---|
[2] | 3439 | else |
---|
[112] | 3440 | mask_displ='no mask'; %default |
---|
| 3441 | filebase=get(handles.RootName,'String'); |
---|
| 3442 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3443 | if isequal(flag_mask,1) |
---|
| 3444 | mask_displ=[num2str(nbslice) 'mask']; |
---|
[282] | 3445 | elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[71] | 3446 | filebase_a=get(handles.RootName_1,'String'); |
---|
[2] | 3447 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[229] | 3448 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
[2] | 3449 | mask_displ='no mask'; |
---|
| 3450 | end |
---|
[112] | 3451 | end |
---|
| 3452 | if isequal(mask_displ,'no mask') |
---|
| 3453 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3454 | {'*.png', ' (*.png)'; |
---|
[12] | 3455 | '*.png', '.png files '; ... |
---|
| 3456 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3457 | 'Pick a mask file *.png',filebase); |
---|
[112] | 3458 | mask_displ=fullfile(PathName,FileName); |
---|
| 3459 | if ~exist(mask_displ,'file') |
---|
| 3460 | mask_displ='no mask'; |
---|
| 3461 | end |
---|
[12] | 3462 | end |
---|
[112] | 3463 | if isequal(mask_displ,'no mask') |
---|
[282] | 3464 | set(handles.CheckMask,'Value',0) |
---|
| 3465 | set(handles.CheckMask,'Value',0) |
---|
| 3466 | set(handles.CheckMask,'Value',0) |
---|
[112] | 3467 | else |
---|
[282] | 3468 | %set(handles.CheckMask,'Value',1) |
---|
| 3469 | set(handles.CheckMask,'Value',1) |
---|
[112] | 3470 | end |
---|
[282] | 3471 | set(handles.txt_MaskName,'String',mask_displ) |
---|
[276] | 3472 | set(handles.txt_Mask,'String',mask_displ) |
---|
[287] | 3473 | set(handles.txt_MaskName,'String',mask_displ) |
---|
[12] | 3474 | end |
---|
| 3475 | |
---|
| 3476 | %------------------------------------------------------------------------ |
---|
[282] | 3477 | % --- Executes on button press in CheckMask: select box for mask option |
---|
[2] | 3478 | function get_mask_civ2_Callback(hObject, eventdata, handles) |
---|
[12] | 3479 | %------------------------------------------------------------------------ |
---|
[282] | 3480 | maskval=get(handles.CheckMask,'Value'); |
---|
[2] | 3481 | if isequal(maskval,0) |
---|
[276] | 3482 | set(handles.txt_Mask,'String','') |
---|
[2] | 3483 | else |
---|
[112] | 3484 | mask_displ='no mask'; %default |
---|
| 3485 | filebase=get(handles.RootName,'String'); |
---|
| 3486 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3487 | if isequal(flag_mask,1) |
---|
| 3488 | mask_displ=[num2str(nbslice) 'mask']; |
---|
[282] | 3489 | elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[71] | 3490 | filebase_a=get(handles.RootName_1,'String'); |
---|
[2] | 3491 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[229] | 3492 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
[2] | 3493 | mask_displ='no mask'; |
---|
| 3494 | end |
---|
[112] | 3495 | end |
---|
| 3496 | if isequal(mask_displ,'no mask') |
---|
| 3497 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3498 | {'*.png', ' (*.png)'; |
---|
[12] | 3499 | '*.png', '.png files '; ... |
---|
| 3500 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3501 | 'Pick a mask file *.png',filebase); |
---|
[112] | 3502 | mask_displ=fullfile(PathName,FileName); |
---|
| 3503 | if ~exist(mask_displ,'file') |
---|
| 3504 | mask_displ='no mask'; |
---|
| 3505 | end |
---|
[12] | 3506 | end |
---|
[112] | 3507 | if isequal(mask_displ,'no mask') |
---|
[282] | 3508 | set(handles.CheckMask,'Value',0) |
---|
| 3509 | set(handles.CheckMask,'Value',0) |
---|
[112] | 3510 | else |
---|
[282] | 3511 | set(handles.CheckMask,'Value',1) |
---|
[112] | 3512 | end |
---|
[276] | 3513 | set(handles.txt_Mask,'String',mask_displ) |
---|
[287] | 3514 | set(handles.txt_MaskName,'String',mask_displ) |
---|
[12] | 3515 | end |
---|
| 3516 | |
---|
| 3517 | %------------------------------------------------------------------------ |
---|
[282] | 3518 | % --- Executes on button press in CheckMask. |
---|
[2] | 3519 | function get_mask_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 3520 | %------------------------------------------------------------------------ |
---|
[282] | 3521 | maskval=get(handles.CheckMask,'Value'); |
---|
[2] | 3522 | if isequal(maskval,0) |
---|
[287] | 3523 | set(handles.txt_MaskName,'String','') |
---|
[2] | 3524 | else |
---|
[12] | 3525 | mask_displ='no mask'; %default |
---|
[71] | 3526 | filebase=get(handles.RootName,'String'); |
---|
[12] | 3527 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
| 3528 | if isequal(flag_mask,1) |
---|
[112] | 3529 | mask_displ=[num2str(nbslice) 'mask']; |
---|
[282] | 3530 | elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
[112] | 3531 | filebase_a=get(handles.RootName_1,'String'); |
---|
| 3532 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
[229] | 3533 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
[112] | 3534 | mask_displ='no mask'; |
---|
| 3535 | end |
---|
[12] | 3536 | end |
---|
| 3537 | if isequal(mask_displ,'no mask') |
---|
| 3538 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3539 | {'*.png', ' (*.png)'; |
---|
| 3540 | '*.png', '.png files '; ... |
---|
| 3541 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3542 | 'Pick a mask file *.png',filebase); |
---|
| 3543 | mask_displ=fullfile(PathName,FileName); |
---|
[12] | 3544 | if ~exist(mask_displ,'file') |
---|
[2] | 3545 | mask_displ='no mask'; |
---|
| 3546 | end |
---|
[12] | 3547 | end |
---|
| 3548 | if isequal(mask_displ,'no mask') |
---|
[282] | 3549 | set(handles.CheckMask,'Value',0) |
---|
[112] | 3550 | end |
---|
[287] | 3551 | set(handles.txt_MaskName,'String',mask_displ) |
---|
[2] | 3552 | end |
---|
| 3553 | |
---|
[12] | 3554 | %------------------------------------------------------------------------ |
---|
| 3555 | % --- function called to look for mask files |
---|
[2] | 3556 | function [nbslice, flag_mask]=get_mask(filebase,handles) |
---|
[12] | 3557 | %------------------------------------------------------------------------ |
---|
[112] | 3558 | %detect mask files, images with appropriate file base |
---|
[2] | 3559 | %[filebase '_' xx 'mask'], xx=nbslice |
---|
| 3560 | %flag_mask=1 indicates detection |
---|
| 3561 | |
---|
| 3562 | flag_mask=0;%default |
---|
| 3563 | nbslice=1; |
---|
| 3564 | |
---|
[289] | 3565 | % subdir=get(handles.txt_SubdirCiv1,'String'); |
---|
[2] | 3566 | [Path,Name]=fileparts(filebase); |
---|
[12] | 3567 | if ~isdir(Path) |
---|
| 3568 | msgbox_uvmat('ERROR','no path for input files') |
---|
| 3569 | return |
---|
| 3570 | end |
---|
[272] | 3571 | % currentdir=pwd; |
---|
| 3572 | % cd(Path);%move in the dir of the root name filebase |
---|
| 3573 | maskfiles=dir(fullfile(Path,[Name '_*mask_*.png']));%look for mask files |
---|
| 3574 | % cd(currentdir);%come back to the current working directory |
---|
[12] | 3575 | if ~isempty(maskfiles) |
---|
[112] | 3576 | % msgbox_uvmat('ERROR','no mask available, to create it use Tools/Make mask in the upper menu bar of uvmat') |
---|
| 3577 | % else |
---|
[2] | 3578 | flag_mask=1; |
---|
| 3579 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 3580 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 3581 | Namedouble=double(Name); |
---|
| 3582 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 3583 | ind_mask=findstr('mask',Name); |
---|
| 3584 | i=ind_mask-1; |
---|
[137] | 3585 | while val(i)==0 && i>0 |
---|
[112] | 3586 | i=i-1; |
---|
[2] | 3587 | end |
---|
[137] | 3588 | nbslice=str2double(Name(i+1:ind_mask-1)); |
---|
| 3589 | if ~isnan(nbslice) && Name(i)=='_' |
---|
[112] | 3590 | flag_mask=1; |
---|
[2] | 3591 | else |
---|
[112] | 3592 | msgbox_uvmat('ERROR',['bad mask file ' Name ext ' found in ' Path2]) |
---|
| 3593 | return |
---|
| 3594 | nbslice=1; |
---|
[2] | 3595 | end |
---|
[112] | 3596 | end |
---|
[2] | 3597 | |
---|
[12] | 3598 | %------------------------------------------------------------------------ |
---|
| 3599 | % --- function called to look for grid files |
---|
[2] | 3600 | function [nbslice, flag_mask]=get_grid(filebase,handles) |
---|
[12] | 3601 | %------------------------------------------------------------------------ |
---|
[2] | 3602 | flag_mask=0;%default |
---|
| 3603 | nbslice=1; |
---|
| 3604 | [Path,Name]=fileparts(filebase); |
---|
| 3605 | currentdir=pwd; |
---|
| 3606 | cd(Path);%move in the dir of the root name filebase |
---|
| 3607 | maskfiles=dir([Name '_*grid_*.grid']);%look for mask files |
---|
| 3608 | cd(currentdir);%come back to the current working directory |
---|
| 3609 | if ~isempty(maskfiles) |
---|
| 3610 | flag_mask=1; |
---|
| 3611 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
| 3612 | [Path2,Name,ext]=fileparts(maskname); |
---|
| 3613 | Namedouble=double(Name); |
---|
| 3614 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 3615 | ind_mask=findstr('grid',Name); |
---|
| 3616 | i=ind_mask-1; |
---|
[137] | 3617 | while val(i)==0 && i>0 |
---|
[112] | 3618 | i=i-1; |
---|
[2] | 3619 | end |
---|
[137] | 3620 | nbslice=str2double(Name(i+1:ind_mask-1)); |
---|
| 3621 | if ~isnan(nbslice) && Name(i)=='_' |
---|
[112] | 3622 | flag_mask=1; |
---|
[2] | 3623 | else |
---|
[112] | 3624 | msgbox_uvmat('ERROR',['bad grid file ' Name ext ' found in ' Path2]) |
---|
| 3625 | return |
---|
| 3626 | nbslice=1; |
---|
[2] | 3627 | end |
---|
[12] | 3628 | end |
---|
[2] | 3629 | |
---|
[12] | 3630 | %------------------------------------------------------------------------ |
---|
| 3631 | % --- transform numbers to letters |
---|
[122] | 3632 | function str=num2stra(num,nom_type) |
---|
[12] | 3633 | %------------------------------------------------------------------------ |
---|
[122] | 3634 | if isempty(nom_type) |
---|
| 3635 | str=''; |
---|
| 3636 | elseif strcmp(nom_type(end),'a') |
---|
[2] | 3637 | str=char(96+num); |
---|
[122] | 3638 | elseif strcmp(nom_type(end),'A') |
---|
| 3639 | str=char(96+num); |
---|
| 3640 | elseif isempty(nom_type(2:end))%a single index |
---|
[2] | 3641 | str=''; |
---|
| 3642 | else |
---|
| 3643 | str=num2str(num); |
---|
| 3644 | end |
---|
[12] | 3645 | |
---|
| 3646 | %------------------------------------------------------------------------ |
---|
[282] | 3647 | % --- Executes on button press in ListSubdirCiv1. |
---|
| 3648 | function ListSubdirCiv1_Callback(hObject, eventdata, handles) |
---|
[12] | 3649 | %------------------------------------------------------------------------ |
---|
[282] | 3650 | list_subdir_civ1=get(handles.ListSubdirCiv1,'String'); |
---|
| 3651 | val=get(handles.ListSubdirCiv1,'Value'); |
---|
[273] | 3652 | subdir=list_subdir_civ1{val}; |
---|
| 3653 | if strcmp(subdir,'new...') |
---|
| 3654 | subdir='CIV'; %default subdirectory |
---|
[2] | 3655 | end |
---|
[289] | 3656 | set(handles.txt_SubdirCiv1,'String',subdir); |
---|
[273] | 3657 | find_netcpair_civ1(hObject, eventdata, handles) |
---|
| 3658 | % end |
---|
[2] | 3659 | |
---|
[12] | 3660 | %------------------------------------------------------------------------ |
---|
[289] | 3661 | % --- Executes on button press in ListSubdirCiv2. |
---|
| 3662 | function ListSubdirCiv2_Callback(hObject, eventdata, handles) |
---|
[12] | 3663 | %------------------------------------------------------------------------ |
---|
[289] | 3664 | list_subdir_civ2=get(handles.ListSubdirCiv2,'String'); |
---|
| 3665 | val=get(handles.ListSubdirCiv2,'Value'); |
---|
[273] | 3666 | subdir=list_subdir_civ2{val}; |
---|
| 3667 | if strcmp(subdir,'new...') |
---|
| 3668 | subdir='CIV'; %default subdirectory |
---|
[2] | 3669 | end |
---|
[289] | 3670 | set(handles.txt_SubdirCiv2,'String',subdir); |
---|
| 3671 | % set(handles.ListSubdirCiv2,'Value',1); |
---|
[2] | 3672 | |
---|
[273] | 3673 | |
---|
[12] | 3674 | %------------------------------------------------------------------------ |
---|
[282] | 3675 | % --- Executes on button press in CheckGrid. |
---|
| 3676 | function CheckGrid_Callback(hObject, eventdata, handles) |
---|
[12] | 3677 | %------------------------------------------------------------------------ |
---|
[276] | 3678 | value=get(hObject,'Value'); |
---|
| 3679 | hparent=get(hObject,'parent'); |
---|
| 3680 | hchildren=get(hparent,'children'); |
---|
| 3681 | handle_txtbox=findobj(hchildren,'tag','txt_GridName'); |
---|
| 3682 | handle_dx=findobj(hchildren,'tag','num_Dx'); |
---|
| 3683 | handle_dy=findobj(hchildren,'tag','num_Dy'); |
---|
[2] | 3684 | testgrid=0; |
---|
[276] | 3685 | filegrid=''; |
---|
[2] | 3686 | if value |
---|
[112] | 3687 | filebase=get(handles.RootName,'String'); |
---|
[276] | 3688 | [nbslice, flag_grid]=get_grid(filebase,handles);% look for a grid with appropriate name |
---|
[2] | 3689 | if isequal(flag_grid,1) |
---|
[112] | 3690 | filegrid=[num2str(nbslice) 'grid']; |
---|
| 3691 | testgrid=1; |
---|
[276] | 3692 | else % browse for a grid |
---|
| 3693 | filegrid=get(hObject,'UserData');%look for previous grid name stored as UserData |
---|
| 3694 | if exist(filegrid,'file') |
---|
| 3695 | filebase=filegrid; |
---|
| 3696 | end |
---|
[2] | 3697 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3698 | {'*.grid', ' (*.grid)'; |
---|
| 3699 | '*.grid', '.grid files '; ... |
---|
| 3700 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3701 | 'Pick a file',filebase); |
---|
[2] | 3702 | filegrid=fullfile(PathName,FileName); |
---|
[276] | 3703 | set(hObject,'UserData',filegrid);%store for future use |
---|
[2] | 3704 | if ~(isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file')) |
---|
| 3705 | testgrid=1; |
---|
| 3706 | end |
---|
[112] | 3707 | end |
---|
[2] | 3708 | end |
---|
| 3709 | if testgrid |
---|
[276] | 3710 | set(handle_dx,'Visible','off'); |
---|
| 3711 | set(handle_dy,'Visible','off'); |
---|
| 3712 | set(handle_txtbox,'Visible','on') |
---|
| 3713 | set(handle_txtbox,'String',filegrid) |
---|
[112] | 3714 | else |
---|
[276] | 3715 | set(hObject,'Value',0); |
---|
| 3716 | set(handle_dx,'Visible','on'); |
---|
| 3717 | set(handle_dy,'Visible','on'); |
---|
| 3718 | set(handle_txtbox,'Visible','off') |
---|
[2] | 3719 | end |
---|
| 3720 | |
---|
[282] | 3721 | %% if hObject is on the checkciv1 frame, duplicate action for checkciv2 frame |
---|
[276] | 3722 | PanelName=get(hparent,'tag'); |
---|
| 3723 | if strcmp(PanelName,'panel_Civ1') |
---|
[282] | 3724 | hchildren=get(handles.Civ2,'children'); |
---|
[276] | 3725 | handle_checkbox=findobj(hchildren,'tag','check_Grid'); |
---|
| 3726 | handle_txtbox=findobj(hchildren,'tag','txt_GridName'); |
---|
| 3727 | handle_dx=findobj(hchildren,'tag','num_Dx'); |
---|
| 3728 | handle_dy=findobj(hchildren,'tag','num_Dy'); |
---|
| 3729 | set(handle_checkbox,'UserData',filegrid);%store for future use |
---|
| 3730 | if testgrid |
---|
| 3731 | set(handle_checkbox,'Value',1); |
---|
| 3732 | set(handle_dx,'Visible','off'); |
---|
| 3733 | set(handle_dy,'Visible','off'); |
---|
| 3734 | set(handle_txtbox,'Visible','on') |
---|
| 3735 | set(handle_txtbox,'String',filegrid) |
---|
| 3736 | else |
---|
| 3737 | set(handle_checkbox,'Value',0); |
---|
[282] | 3738 | set(handles.CheckGrid,'Value',0); |
---|
[276] | 3739 | set(handle_dx,'Visible','on'); |
---|
| 3740 | set(handle_dy,'Visible','on'); |
---|
| 3741 | set(handle_txtbox,'Visible','off') |
---|
| 3742 | end |
---|
| 3743 | end |
---|
[12] | 3744 | %------------------------------------------------------------------------ |
---|
[282] | 3745 | % --- Executes on button press in CheckMask. |
---|
| 3746 | function CheckMask_Callback(hObject, eventdata, handles) |
---|
[276] | 3747 | %------------------------------------------------------------------------ |
---|
| 3748 | value=get(hObject,'Value'); |
---|
| 3749 | testmask=0; |
---|
| 3750 | if value |
---|
| 3751 | filebase=get(handles.RootName,'String'); |
---|
| 3752 | [nbslice, flag_mask]=get_mask(filebase,handles);% look for a mask with appropriate name |
---|
| 3753 | if isequal(flag_mask,1) |
---|
| 3754 | filemask=[num2str(nbslice) 'mask']; |
---|
| 3755 | testmask=1; |
---|
| 3756 | else % browse for a mask |
---|
[282] | 3757 | filemask=get(handles.CheckMask,'UserData');%look for previous mask name stored as UserData |
---|
[276] | 3758 | if exist(filemask,'file') |
---|
| 3759 | filebase=filemask; |
---|
| 3760 | end |
---|
| 3761 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3762 | {'*.png', ' (*.png)'; |
---|
| 3763 | '*.png', '.png files '; ... |
---|
| 3764 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3765 | 'Pick a mask file *.png',filebase); |
---|
| 3766 | filemask=fullfile(PathName,FileName); |
---|
[282] | 3767 | set(handles.CheckMask,'UserData',filemask);%store for future use |
---|
[276] | 3768 | if ~(isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filemask,'file')) |
---|
| 3769 | testmask=1; |
---|
| 3770 | end |
---|
| 3771 | end |
---|
| 3772 | end |
---|
| 3773 | if testmask |
---|
| 3774 | set(handles.num_Dx,'Visible','off'); |
---|
| 3775 | set(handles.num_Dy,'Visible','off'); |
---|
| 3776 | set(handles.num_Dx,'Visible','off'); |
---|
| 3777 | set(handles.num_Dy,'Visible','off'); |
---|
| 3778 | set(handles.txt_MaskName,'Visible','on') |
---|
| 3779 | set(handles.txt_MaskName,'String',filemask) |
---|
| 3780 | else |
---|
[282] | 3781 | set(handles.CheckMask,'Value',0); |
---|
| 3782 | set(handles.CheckGrid,'Value',0); |
---|
[276] | 3783 | set(handles.num_Dx,'Visible','on'); |
---|
| 3784 | set(handles.num_Dy,'Visible','on'); |
---|
| 3785 | set(handles.num_Dx,'Visible','on'); |
---|
| 3786 | set(handles.num_Dy,'Visible','on'); |
---|
| 3787 | set(handles.txt_MaskName,'Visible','off') |
---|
| 3788 | end |
---|
| 3789 | |
---|
| 3790 | %------------------------------------------------------------------------ |
---|
[282] | 3791 | % --- Executes on button press in CheckGrid. |
---|
[2] | 3792 | function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
[12] | 3793 | %------------------------------------------------------------------------ |
---|
[282] | 3794 | value=get(handles.CheckGrid,'Value'); |
---|
[2] | 3795 | if value |
---|
[112] | 3796 | filebase=get(handles.RootName,'String'); |
---|
[39] | 3797 | [nbslice, flag_grid]=get_grid(filebase,handles); |
---|
[2] | 3798 | if isequal(flag_grid,1) |
---|
| 3799 | mask_displ=[num2str(nbslice) 'grid']; |
---|
[276] | 3800 | set(handles.txt_GridName,'String',mask_displ) |
---|
| 3801 | set(handles.num_Dx,'Visible','off'); |
---|
| 3802 | set(handles.num_Dy,'Visible','off'); |
---|
[112] | 3803 | else |
---|
[2] | 3804 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3805 | {'*.grid', ' (*.grid)'; |
---|
| 3806 | '*.grid', '.grid files '; ... |
---|
| 3807 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3808 | 'Pick a file',filebase); |
---|
[2] | 3809 | filegrid=fullfile(PathName,FileName); |
---|
[229] | 3810 | if isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file') |
---|
[282] | 3811 | set(handles.CheckGrid,'Value',0); |
---|
[276] | 3812 | set(handles.txt_GridName,'string',''); |
---|
| 3813 | set(handles.num_Dx,'Visible','on'); |
---|
| 3814 | set(handles.num_Dy,'Visible','on'); |
---|
| 3815 | set(handles.txt_GridName,'string',''); |
---|
[2] | 3816 | else |
---|
[276] | 3817 | set(handles.txt_GridName,'string',filegrid); |
---|
| 3818 | set(handles.num_Dx,'Visible','off'); |
---|
| 3819 | set(handles.num_Dy,'Visible','off'); |
---|
| 3820 | set(handles.txt_GridName,'string',filegrid); |
---|
[2] | 3821 | end |
---|
| 3822 | end |
---|
| 3823 | else |
---|
[276] | 3824 | set(handles.txt_GridName,'string',''); |
---|
| 3825 | set(handles.num_Dx,'Visible','on'); |
---|
| 3826 | set(handles.num_Dy,'Visible','on'); |
---|
| 3827 | set(handles.txt_GridName,'string',''); |
---|
[2] | 3828 | end |
---|
| 3829 | |
---|
[282] | 3830 | % % --- Executes on button press in CheckGrid. |
---|
[2] | 3831 | % function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
[112] | 3832 | % |
---|
[71] | 3833 | % filebase=get(handles.RootName,'String'); |
---|
[2] | 3834 | % [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 3835 | % {'*.grid', ' (*.grid)'; |
---|
| 3836 | % '*.grid', '.grid files '; ... |
---|
| 3837 | % '*.*', 'All Files (*.*)'}, ... |
---|
| 3838 | % 'Pick a file',filebase); |
---|
| 3839 | % filegrid=fullfile(PathName,FileName); |
---|
[276] | 3840 | % set(handles.txt_GridName,'string',filegrid); |
---|
| 3841 | % set(handles.num_Dx,'String',' '); |
---|
| 3842 | % set(handles.num_Dy,'String',' '); |
---|
[2] | 3843 | % % set(handles.grid_patch2,'string',filegrid); |
---|
| 3844 | |
---|
| 3845 | % --- Executes on button press in get_gridpatch1. |
---|
| 3846 | function get_gridpatch1_Callback(hObject, eventdata, handles) |
---|
| 3847 | % hObject handle to get_gridpatch1 (see GCBO) |
---|
| 3848 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 3849 | % handles structure with handles and user data (see GUIDATA) |
---|
| 3850 | |
---|
[71] | 3851 | filebase=get(handles.RootName,'String'); |
---|
[2] | 3852 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 3853 | {'*.grid', ' (*.grid)'; |
---|
| 3854 | '*.grid', '.grid files '; ... |
---|
| 3855 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3856 | 'Pick a file',filebase); |
---|
[2] | 3857 | filegrid=fullfile(PathName,FileName); |
---|
| 3858 | set(handles.grid_patch1,'string',filegrid); |
---|
| 3859 | % set(handles.grid_patch2,'string',filegrid |
---|
| 3860 | |
---|
[12] | 3861 | %------------------------------------------------------------------------ |
---|
[2] | 3862 | % --- Executes on button press in get_gridpatch2. |
---|
| 3863 | function get_gridpatch2_Callback(hObject, eventdata, handles) |
---|
[12] | 3864 | %------------------------------------------------------------------------ |
---|
[2] | 3865 | |
---|
[12] | 3866 | %------------------------------------------------------------------------ |
---|
[2] | 3867 | function enable_civ1(handles,state) |
---|
[12] | 3868 | %------------------------------------------------------------------------ |
---|
[273] | 3869 | if state |
---|
| 3870 | RootName=get(handles.RootName,'String'); |
---|
| 3871 | if isempty(RootName) |
---|
| 3872 | msgbox_uvmat('ERROR','No input file') |
---|
| 3873 | return |
---|
| 3874 | end |
---|
[282] | 3875 | set(handles.Civ1,'Visible','on') |
---|
| 3876 | set(handles.PairIndices,'Visible','on') |
---|
[273] | 3877 | % set(handles.frame_civ1,'BackgroundColor',[1 1 0]) |
---|
| 3878 | % set(handles.frame_para_civ1,'BackgroundColor',[1 1 0]) |
---|
| 3879 | % set(handles.frame_grid_civ1,'BackgroundColor',[1 1 0]) |
---|
[2] | 3880 | else |
---|
[282] | 3881 | set(handles.Civ1,'Visible','off') |
---|
[273] | 3882 | % set(handles.frame_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3883 | % set(handles.frame_para_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3884 | % set(handles.frame_grid_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[2] | 3885 | end |
---|
| 3886 | |
---|
[282] | 3887 | % set(handles.num_Bx,'Visible',state) |
---|
| 3888 | % set(handles.num_By,'Visible',state) |
---|
[287] | 3889 | % set(handles.num_Searchx,'Visible',state) |
---|
| 3890 | % set(handles.num_Searchy,'Visible',state) |
---|
[282] | 3891 | % set(handles.num_Shiftx,'Visible',state) |
---|
| 3892 | % set(handles.num_Shifty,'Visible',state) |
---|
| 3893 | % set(handles.num_Rho,'Visible',state) |
---|
| 3894 | % set(handles.num_Dx,'Visible',state) |
---|
| 3895 | % set(handles.num_Dy,'Visible',state) |
---|
| 3896 | % set(handles.SearchRange,'Visible',state) |
---|
| 3897 | % set(handles.u_title,'Visible',state) |
---|
| 3898 | % set(handles.v_title,'Visible',state) |
---|
| 3899 | % set(handles.min_title,'Visible',state) |
---|
| 3900 | % set(handles.max_title,'Visible',state) |
---|
| 3901 | % set(handles.umin,'Visible',state) |
---|
| 3902 | % set(handles.umax,'Visible',state) |
---|
| 3903 | % set(handles.vmin,'Visible',state) |
---|
| 3904 | % set(handles.vmax,'Visible',state) |
---|
| 3905 | % set(handles.txt_GridName,'Visible',state) |
---|
| 3906 | % set(handles.txt_MaskName,'Visible',state) |
---|
| 3907 | % set(handles.CheckGrid,'Visible',state) |
---|
| 3908 | % set(handles.CheckMask,'Visible',state) |
---|
| 3909 | % set(handles.parameters,'Visible',state) |
---|
| 3910 | % set(handles.grid,'Visible',state) |
---|
| 3911 | % set(handles.num_Dx,'Visible',state) |
---|
| 3912 | % set(handles.num_Dy,'Visible',state) |
---|
| 3913 | % set(handles.check_Threshold,'Visible',state) |
---|
| 3914 | % if isequal(state,'off') |
---|
| 3915 | % set(handles.num_MinIma,'Visible','off') |
---|
| 3916 | % set(handles.num_MaxIma,'Visible','off') |
---|
| 3917 | % set(handles.check_Threshold,'Value',0) |
---|
| 3918 | % end |
---|
| 3919 | % set(handles.dx_civ1_title,'Visible',state) |
---|
| 3920 | % set(handles.dy_civ1_title,'Visible',state) |
---|
| 3921 | % set(handles.ImaThreshold_title,'Visible',state) |
---|
| 3922 | % set(handles.ib_title,'Visible',state) |
---|
| 3923 | % set(handles.is_title,'Visible',state) |
---|
| 3924 | % set(handles.shift_title,'Visible',state) |
---|
| 3925 | % set(handles.rho_title,'Visible',state) |
---|
| 3926 | % set(handles.TestCiv1,'Visible',state) |
---|
| 3927 | %set(handles.ListPairMode,'Visible',state) |
---|
| 3928 | |
---|
[12] | 3929 | %------------------------------------------------------------------------ |
---|
[2] | 3930 | function enable_fix1(handles,state) |
---|
[12] | 3931 | %------------------------------------------------------------------------ |
---|
[273] | 3932 | |
---|
[2] | 3933 | if isequal(state,0) |
---|
| 3934 | state='off'; |
---|
| 3935 | end |
---|
| 3936 | if isequal(state,1) |
---|
| 3937 | state='on'; |
---|
[273] | 3938 | RootName=get(handles.RootName,'String'); |
---|
| 3939 | if isempty(RootName) |
---|
| 3940 | msgbox_uvmat('ERROR','No input file') |
---|
| 3941 | return |
---|
| 3942 | end |
---|
[2] | 3943 | end |
---|
| 3944 | if isequal(state,'on') |
---|
[282] | 3945 | set(handles.Fix1,'Visible','on') |
---|
[273] | 3946 | % set(handles.frame_fix1,'BackgroundColor',[1 1 0]) |
---|
[2] | 3947 | else |
---|
[282] | 3948 | set(handles.Fix1,'Visible','off') |
---|
[273] | 3949 | %set(handles.frame_fix1,'BackgroundColor',[0.7 0.7 0.7]) |
---|
[2] | 3950 | end |
---|
[282] | 3951 | % % set(handles.REMOVE,'Visible',state) |
---|
| 3952 | % set(handles.CheckFmin2,'Visible',state) |
---|
| 3953 | % set(handles.CheckF2,'Visible',state) |
---|
| 3954 | % set(handles.CheckF3,'Visible',state) |
---|
| 3955 | % set(handles.num_MinCorr,'Visible',state) |
---|
| 3956 | % set(handles.thresh_vecC_title,'Visible',state) |
---|
[287] | 3957 | % set(handles.num_MinVel,'Visible',state) |
---|
| 3958 | % set(handles.TitleMinVel,'Visible',state) |
---|
[282] | 3959 | % set(handles.txt_MaskName,'Visible',state) |
---|
| 3960 | % set(handles.CheckMask,'Visible',state) |
---|
| 3961 | % set(handles.get_ref_fix1,'Visible',state) |
---|
| 3962 | % set(handles.ref_fix1,'Visible',state) |
---|
[287] | 3963 | % set(handles.num_MinVel,'Visible',state) |
---|
[282] | 3964 | % set(handles.field_ref1,'Visible',state) |
---|
[2] | 3965 | |
---|
[12] | 3966 | %------------------------------------------------------------------------ |
---|
[273] | 3967 | function enable_patch1(handles,state) |
---|
[12] | 3968 | %------------------------------------------------------------------------ |
---|
[273] | 3969 | if state |
---|
| 3970 | RootName=get(handles.RootName,'String'); |
---|
| 3971 | if isempty(RootName) |
---|
| 3972 | msgbox_uvmat('ERROR','No input file') |
---|
| 3973 | return |
---|
| 3974 | end |
---|
[282] | 3975 | set(handles.Patch1,'Visible','on') |
---|
[273] | 3976 | else |
---|
[282] | 3977 | set(handles.Patch1,'Visible','off') |
---|
[273] | 3978 | end |
---|
| 3979 | return |
---|
[2] | 3980 | set(handles.frame_patch1,'BackgroundColor',[1 1 0]) |
---|
| 3981 | set(handles.rho_patch1,'Visible','on') |
---|
| 3982 | set(handles.rho_text1,'Visible','on') |
---|
[282] | 3983 | if get(handles.ListPairMode,'Value')==2 |
---|
[224] | 3984 | set(handles.thresh_patch1,'Visible','on') |
---|
| 3985 | set(handles.thresh_text1,'Visible','on') |
---|
| 3986 | end |
---|
[2] | 3987 | set(handles.subdomain_patch1,'Visible','on') |
---|
| 3988 | set(handles.subdomain_text1,'Visible','on') |
---|
| 3989 | set(handles.nx_patch1,'Visible','on') |
---|
[274] | 3990 | set(handles.num_Ny,'Visible','on') |
---|
[2] | 3991 | set(handles.nx_patch1_title,'Visible','on') |
---|
| 3992 | set(handles.ny_patch1_title,'Visible','on') |
---|
[112] | 3993 | % if ~isempty(patch_newBin) |
---|
[224] | 3994 | set(handles.test_interp,'Visible','off'); |
---|
[282] | 3995 | stereo_test=get(handles.ListCompareMode,'Value'); |
---|
[252] | 3996 | if stereo_test==3 |
---|
| 3997 | set(handles.test_stereo1,'Visible','on') |
---|
| 3998 | end |
---|
[100] | 3999 | % end |
---|
[252] | 4000 | %set(handles.get_gridpatch1,'Visible','on') |
---|
| 4001 | %set(handles.grid_patch1,'string','none'); |
---|
| 4002 | %set(handles.grid_patch1,'Visible','on') |
---|
[2] | 4003 | |
---|
[273] | 4004 | % %------------------------------------------------------------------------ |
---|
| 4005 | % function desable_patch1(handles) |
---|
| 4006 | % %------------------------------------------------------------------------ |
---|
| 4007 | % return |
---|
| 4008 | % set(handles.frame_patch1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4009 | % set(handles.rho_patch1,'Visible','off') |
---|
| 4010 | % set(handles.rho_text1,'Visible','off') |
---|
| 4011 | % set(handles.thresh_patch1,'Visible','off') |
---|
| 4012 | % set(handles.thresh_text1,'Visible','off') |
---|
| 4013 | % set(handles.subdomain_patch1,'Visible','off') |
---|
| 4014 | % set(handles.subdomain_text1,'Visible','off') |
---|
| 4015 | % set(handles.nx_patch1,'Visible','off') |
---|
[274] | 4016 | % set(handles.num_Ny,'Visible','off') |
---|
[273] | 4017 | % set(handles.nx_patch1_title,'Visible','off') |
---|
| 4018 | % set(handles.ny_patch1_title,'Visible','off') |
---|
| 4019 | % set(handles.test_stereo1,'Visible','off') |
---|
| 4020 | % %set(handles.test_interp,'Visible','off') |
---|
| 4021 | % %set(handles.get_gridpatch1,'Visible','off') |
---|
| 4022 | % %set(handles.grid_patch1,'Visible','off') |
---|
[2] | 4023 | |
---|
[12] | 4024 | %------------------------------------------------------------------------ |
---|
[2] | 4025 | function enable_civ2(handles,state) |
---|
[12] | 4026 | %------------------------------------------------------------------------ |
---|
[273] | 4027 | if state |
---|
| 4028 | RootName=get(handles.RootName,'String'); |
---|
| 4029 | if isempty(RootName) |
---|
| 4030 | msgbox_uvmat('ERROR','No input file') |
---|
| 4031 | return |
---|
| 4032 | end |
---|
[282] | 4033 | set(handles.Civ2,'Visible','on') |
---|
[289] | 4034 | set(handles.ListSubdirCiv2,'Visible','on') |
---|
| 4035 | set(handles.SubdirCiv2,'Visible','on') |
---|
| 4036 | set(handles.TitleSubdirCiv2,'Visible','on') |
---|
[2] | 4037 | else |
---|
[282] | 4038 | set(handles.Civ2,'Visible','off') |
---|
[2] | 4039 | end |
---|
[273] | 4040 | |
---|
[282] | 4041 | % |
---|
[287] | 4042 | % set(handles.num_Bx,'Visible',state) |
---|
| 4043 | % set(handles.num_By,'Visible',state) |
---|
| 4044 | % set(handles.CheckDecimal,'Visible',state) |
---|
| 4045 | % set(handles.CheckDeformation,'Visible',state) |
---|
| 4046 | % set(handles.num_Rho,'Visible',state) |
---|
[282] | 4047 | % set(handles.num_Dx,'Visible',state) |
---|
| 4048 | % set(handles.num_Dy,'Visible',state) |
---|
| 4049 | % set(handles.CheckGrid,'Visible',state) |
---|
| 4050 | % set(handles.CheckMask,'Visible',state) |
---|
| 4051 | % set(handles.parameters,'Visible',state) |
---|
| 4052 | % set(handles.grid,'Visible',state) |
---|
| 4053 | % set(handles.parameters_text,'Visible',state) |
---|
| 4054 | % set(handles.grid_text,'Visible',state) |
---|
| 4055 | % set(handles.txt_GridName,'Visible',state) |
---|
| 4056 | % set(handles.txt_Mask,'Visible',state) |
---|
| 4057 | % set(handles.dx_civ2_title,'Visible',state) |
---|
| 4058 | % set(handles.dy_civ2_title,'Visible',state) |
---|
| 4059 | % set(handles.ibx_civ2_text,'Visible',state) |
---|
| 4060 | % set(handles.rho_civ2_title,'Visible',state) |
---|
| 4061 | % set(handles.ImaThreshold2,'Visible',state) |
---|
| 4062 | % set(handles.ImaThreshold_title2,'Visible',state) |
---|
| 4063 | % if isequal(state,'off') |
---|
[287] | 4064 | % set(handles.num_MinIma,'Visible','off') |
---|
| 4065 | % set(handles.num_MaxIma,'Visible','off') |
---|
[282] | 4066 | % set(handles.ImaThreshold2,'Value',0) |
---|
| 4067 | % if isequal(get(handles.CheckFix2,'Value'),0) & isequal(get(handles.CheckPatch2,'Value'),0) |
---|
| 4068 | % set(handles.ListPairCiv2,'Visible','off') |
---|
[289] | 4069 | % set(handles.txt_SubdirCiv2,'Visible','off') |
---|
| 4070 | % set(handles.TitleSubdirCiv2,'Visible','off') |
---|
[282] | 4071 | % set(handles.dt_unit_civ2,'Visible','off') |
---|
| 4072 | % %set(handles.ref_i_civ2,'Visible','off') |
---|
| 4073 | % set(handles.i_ref_civ2_title,'Visible','off') |
---|
| 4074 | % set(handles.j_ref_civ2_title,'Visible','off') |
---|
| 4075 | % set(handles.ref_j_civ2,'Visible','off') |
---|
| 4076 | % end |
---|
| 4077 | % else |
---|
| 4078 | % set(handles.ListPairCiv2,'Visible','on') |
---|
[289] | 4079 | % set(handles.txt_SubdirCiv2,'Visible','on') |
---|
| 4080 | % set(handles.TitleSubdirCiv2,'Visible','on') |
---|
[282] | 4081 | % set(handles.dt_unit_civ2,'Visible','on') |
---|
| 4082 | % % set(handles.ref_i_civ2,'Visible','on') |
---|
| 4083 | % set(handles.i_ref_civ2_title,'Visible','on') |
---|
| 4084 | % set(handles.j_ref_civ2_title,'Visible','on') |
---|
| 4085 | % set(handles.ref_j_civ2,'Visible','on') |
---|
| 4086 | % end |
---|
| 4087 | % set(handles.rho_civ2_title,'Visible',state) |
---|
[2] | 4088 | |
---|
[12] | 4089 | %------------------------------------------------------------------------ |
---|
[273] | 4090 | function enable_fix2(handles,state) |
---|
[12] | 4091 | %------------------------------------------------------------------------ |
---|
[273] | 4092 | % if isequal(state,'on') |
---|
[282] | 4093 | % set(handles.Fix2,'Visible','on') |
---|
[273] | 4094 | % |
---|
| 4095 | % % set(handles.frame_civ2,'BackgroundColor',[1 1 0]) |
---|
| 4096 | % % set(handles.frame_para_civ2,'BackgroundColor',[1 1 0]) |
---|
| 4097 | % % set(handles.frame_grid_civ2,'BackgroundColor',[1 1 0]) |
---|
| 4098 | % % set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
| 4099 | % else |
---|
| 4100 | if state |
---|
| 4101 | RootName=get(handles.RootName,'String'); |
---|
| 4102 | if isempty(RootName) |
---|
| 4103 | msgbox_uvmat('ERROR','No input file') |
---|
| 4104 | return |
---|
| 4105 | end |
---|
[282] | 4106 | set(handles.Fix2,'Visible','on') |
---|
[273] | 4107 | else |
---|
[282] | 4108 | set(handles.Fix2,'Visible','off') |
---|
[273] | 4109 | end |
---|
[2] | 4110 | |
---|
[282] | 4111 | % set(handles.frame_fix2,'BackgroundColor',[1 1 0]) |
---|
| 4112 | % set(handles.REMOVE2,'Visible','on') |
---|
[287] | 4113 | % set(handles.CheckFmin2,'Visible','on') |
---|
| 4114 | % set(handles.CheckF4,'Visible','on') |
---|
| 4115 | % set(handles.CheckF3,'Visible','on') |
---|
| 4116 | % set(handles.num_MinCorr,'Visible','on') |
---|
[282] | 4117 | % set(handles.thresh_vec2C_text,'Visible','on') |
---|
[287] | 4118 | % set(handles.num_MinVel,'Visible','on') |
---|
| 4119 | % set(handles.TitleMinVel,'Visible','on') |
---|
| 4120 | % set(handles.txt_MaskName,'Visible','on') |
---|
[282] | 4121 | % set(handles.CheckMask,'Visible','on') |
---|
| 4122 | % set(handles.ListPairCiv2,'Visible','on') |
---|
[289] | 4123 | % set(handles.txt_SubdirCiv2,'Visible','on') |
---|
| 4124 | % set(handles.TitleSubdirCiv2,'Visible','on') |
---|
[282] | 4125 | % set(handles.get_ref_fix2,'Visible','on') |
---|
| 4126 | % set(handles.ref_fix2,'Visible','on') |
---|
[287] | 4127 | % set(handles.num_MinVel,'Visible','on') |
---|
[282] | 4128 | % set(handles.field_ref2,'Visible','on') |
---|
| 4129 | |
---|
[273] | 4130 | % %------------------------------------------------------------------------ |
---|
| 4131 | % function desable_fix2(handles) |
---|
| 4132 | % %------------------------------------------------------------------------ |
---|
| 4133 | % set(handles.frame_fix2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 4134 | % set(handles.REMOVE2,'Visible','off') |
---|
[287] | 4135 | % set(handles.CheckFmin2,'Visible','off') |
---|
| 4136 | % set(handles.CheckF4,'Visible','off') |
---|
| 4137 | % set(handles.CheckF3,'Visible','off') |
---|
| 4138 | % set(handles.num_MinCorr,'Visible','off') |
---|
[273] | 4139 | % set(handles.thresh_vec2C_text,'Visible','off') |
---|
[287] | 4140 | % set(handles.num_MinVel,'Visible','off') |
---|
| 4141 | % set(handles.TitleMinVel,'Visible','off') |
---|
| 4142 | % set(handles.txt_MaskName,'Visible','off') |
---|
[282] | 4143 | % set(handles.CheckMask,'Visible','off') |
---|
[273] | 4144 | % set(handles.get_ref_fix2,'Visible','off') |
---|
| 4145 | % set(handles.ref_fix2,'Visible','off') |
---|
[287] | 4146 | % set(handles.num_MinVel,'Visible','off') |
---|
[273] | 4147 | % set(handles.field_ref2,'Visible','off') |
---|
[282] | 4148 | % if isequal(get(handles.CheckCiv2,'Value'),0) & isequal(get(handles.CheckPatch2,'Value'),0) |
---|
| 4149 | % set(handles.ListPairCiv2,'Visible','off') |
---|
[289] | 4150 | % set(handles.txt_SubdirCiv2,'Visible','off') |
---|
| 4151 | % set(handles.TitleSubdirCiv2,'Visible','off') |
---|
[273] | 4152 | % end |
---|
[2] | 4153 | |
---|
[12] | 4154 | %------------------------------------------------------------------------ |
---|
[273] | 4155 | function enable_patch2(handles,state) |
---|
[12] | 4156 | %------------------------------------------------------------------------ |
---|
[273] | 4157 | if state |
---|
| 4158 | RootName=get(handles.RootName,'String'); |
---|
| 4159 | if isempty(RootName) |
---|
| 4160 | msgbox_uvmat('ERROR','No input file') |
---|
| 4161 | return |
---|
| 4162 | end |
---|
[282] | 4163 | set(handles.Patch2,'Visible','on') |
---|
[273] | 4164 | else |
---|
[282] | 4165 | set(handles.Patch2,'Visible','off') |
---|
[252] | 4166 | end |
---|
[273] | 4167 | % set(handles.frame_patch2,'BackgroundColor',[1 1 0]) |
---|
[274] | 4168 | % set(handles.num_SmoothingParam,'Visible','on') |
---|
[292] | 4169 | % set(handles.num_SmoothingParam,'Visible','on') |
---|
[274] | 4170 | % set(handles.num_MaxDiff,'Visible','on') |
---|
[273] | 4171 | % set(handles.thresh_text2,'Visible','on') |
---|
[274] | 4172 | % set(handles.num_SubdomainSize,'Visible','on') |
---|
[273] | 4173 | % set(handles.subdomain_text2,'Visible','on') |
---|
[274] | 4174 | % set(handles.num_Nx,'Visible','on') |
---|
| 4175 | % set(handles.num_Ny,'Visible','on') |
---|
[273] | 4176 | % set(handles.nx_patch2_title,'Visible','on') |
---|
| 4177 | % set(handles.ny_patch2_title,'Visible','on') |
---|
| 4178 | % % set(handles.get_gridpatch2,'Visible','on') |
---|
| 4179 | % % set(handles.grid_patch2,'Visible','on') |
---|
[282] | 4180 | % set(handles.ListPairCiv2,'Visible','on') |
---|
[289] | 4181 | % set(handles.txt_SubdirCiv2,'Visible','on') |
---|
| 4182 | % set(handles.TitleSubdirCiv2,'Visible','on') |
---|
[282] | 4183 | % stereo_test=get(handles.ListCompareMode,'Value'); |
---|
[273] | 4184 | % if stereo_test==3 |
---|
[282] | 4185 | % set(handles.CheckStereo,'Visible','on') |
---|
[273] | 4186 | % end |
---|
[2] | 4187 | |
---|
[273] | 4188 | % %------------------------------------------------------------------------ |
---|
| 4189 | % function desable_patch2(handles) |
---|
| 4190 | % %------------------------------------------------------------------------ |
---|
[282] | 4191 | % %set(handles.checkpatch2,'Visible','off') |
---|
[273] | 4192 | % return |
---|
| 4193 | % set(handles.frame_patch2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[274] | 4194 | % set(handles.num_SmoothingParam,'Visible','off') |
---|
[292] | 4195 | % set(handles.num_SmoothingParam,'Visible','off') |
---|
[274] | 4196 | % set(handles.num_MaxDiff,'Visible','off') |
---|
[273] | 4197 | % set(handles.thresh_text2,'Visible','off') |
---|
[274] | 4198 | % set(handles.num_SubdomainSize,'Visible','off') |
---|
[273] | 4199 | % set(handles.subdomain_text2,'Visible','off') |
---|
[274] | 4200 | % set(handles.num_Nx,'Visible','off') |
---|
| 4201 | % set(handles.num_Ny,'Visible','off') |
---|
[273] | 4202 | % set(handles.nx_patch2_title,'Visible','off') |
---|
| 4203 | % set(handles.ny_patch2_title,'Visible','off') |
---|
| 4204 | % % set(handles.get_gridpatch2,'Visible','off') |
---|
| 4205 | % % set(handles.grid_patch2,'Visible','off') |
---|
[282] | 4206 | % if isequal(get(handles.CheckCiv2,'Value'),0) & isequal(get(handles.CheckFix2,'Value'),0) |
---|
| 4207 | % set(handles.ListPairCiv2,'Visible','off') |
---|
[289] | 4208 | % set(handles.txt_SubdirCiv2,'Visible','off') |
---|
| 4209 | % set(handles.TitleSubdirCiv2,'Visible','off') |
---|
[273] | 4210 | % end |
---|
[282] | 4211 | % set(handles.CheckStereo,'Visible','off') |
---|
[12] | 4212 | %------------------------------------------------------------------------ |
---|
[2] | 4213 | function enable_pair1(handles,state) |
---|
[12] | 4214 | %------------------------------------------------------------------------ |
---|
[289] | 4215 | set(handles.txt_SubdirCiv1,'Visible',state) |
---|
[282] | 4216 | set(handles.ListSubdirCiv1,'Visible',state) |
---|
[289] | 4217 | set(handles.TitleSubdirCiv1,'Visible',state) |
---|
[273] | 4218 | %set(handles.frame_subdirciv1,'Visible',state) |
---|
[282] | 4219 | set(handles.ListPairCiv1,'Visible',state) |
---|
[289] | 4220 | set(handles.TitlePairCiv1,'Visible',state) |
---|
[71] | 4221 | %set(handles.dt_unit,'Visible',state) |
---|
[273] | 4222 | %set(handles.PAIR_frame,'Visible',state) |
---|
[2] | 4223 | |
---|
[12] | 4224 | %------------------------------------------------------------------------ |
---|
[282] | 4225 | % --- Read the parameters for checkciv1 on the interface |
---|
[285] | 4226 | % function par=read_param_civ1(handles,filecell) |
---|
| 4227 | % % not deeden anymore |
---|
| 4228 | % %------------------------------------------------------------------------ |
---|
| 4229 | % ibx_val=str2double(get(handles.num_Bx,'String')); |
---|
| 4230 | % par.ibx=num2str(ibx_val); |
---|
| 4231 | % iby_val=str2double(get(handles.num_By,'String')); |
---|
| 4232 | % par.iby=num2str(iby_val); |
---|
[287] | 4233 | % isx=get(handles.num_Searchx,'String'); |
---|
| 4234 | % if isnan(str2double(isx)), isx='41'; set(handles.num_Searchx,'String','41'), end; %default |
---|
| 4235 | % if str2double(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.num_Searchx,'String',num2str(ibx_val+8)); end |
---|
| 4236 | % isy=get(handles.num_Searchy,'String'); |
---|
| 4237 | % if isnan(str2double(isy)), isy='41'; set(handles.num_Searchy,'String','41'), end;%default |
---|
| 4238 | % if str2double(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.num_Searchy,'String',num2str(iby_val+8)); end |
---|
| 4239 | % par.isx=get(handles.num_Searchx,'String'); |
---|
| 4240 | % par.isy=get(handles.num_Searchy,'String'); |
---|
[285] | 4241 | % par.shiftx=get(handles.num_Shiftx,'String'); |
---|
| 4242 | % par.shifty=get(handles.num_Shifty,'String'); |
---|
| 4243 | % if isnan(str2double(par.isx)) |
---|
| 4244 | % par.isx='41';%default |
---|
[287] | 4245 | % set(handles.num_Searchx,'String','41'); |
---|
[272] | 4246 | % end |
---|
[285] | 4247 | % if isnan(str2double(par.isy)) |
---|
| 4248 | % par.isy='41'; %default |
---|
[287] | 4249 | % set(handles.num_Searchy,'String','41'); |
---|
[285] | 4250 | % end |
---|
| 4251 | % if isnan(str2double(par.shiftx)) |
---|
| 4252 | % par.shiftx='0';%default |
---|
| 4253 | % set(handles.num_Shiftx,'String','0'); |
---|
| 4254 | % end |
---|
| 4255 | % if isnan(str2double(par.shifty)) |
---|
| 4256 | % par.shifty='0'; %default |
---|
| 4257 | % set(handles.num_Shifty,'String','0'); |
---|
| 4258 | % end |
---|
| 4259 | % par.rho=get(handles.num_Rho,'String'); |
---|
| 4260 | % if isequal(get(handles.num_Rho,'Style'),'popupmenu') |
---|
| 4261 | % index=get(handles.num_Rho,'Value'); |
---|
| 4262 | % par.rho=par.rho{index}; |
---|
| 4263 | % end |
---|
| 4264 | % dummy=get(handles.num_Dx,'String'); |
---|
| 4265 | % par.dx=dummy{1}; |
---|
| 4266 | % dummy=get(handles.num_Dy,'String'); |
---|
| 4267 | % par.dy=dummy{1}; |
---|
| 4268 | % if isnan(str2double(par.dx)) |
---|
| 4269 | % if isempty(get(handles.txt_GridName,'String')); |
---|
| 4270 | % par.dx='0'; %just read by civ program, not used |
---|
| 4271 | % else |
---|
| 4272 | % par.dx='20';%default |
---|
| 4273 | % set(handles.num_Dx,'String','20'); |
---|
| 4274 | % end |
---|
| 4275 | % end |
---|
| 4276 | % if isnan(str2double(par.dy)) |
---|
| 4277 | % if isempty(get(handles.txt_GridName,'String')); |
---|
| 4278 | % par.dy='0';%just read by civ program, not used |
---|
| 4279 | % else |
---|
| 4280 | % par.dy='20';%default |
---|
| 4281 | % set(handles.dy_civ1_title,'String','20'); |
---|
| 4282 | % end |
---|
| 4283 | % end |
---|
| 4284 | % par.pxcmx='1'; %velocities are expressed in pixel dispalcement |
---|
| 4285 | % par.pxcmy='1'; |
---|
| 4286 | % % if exist('file_ima','var') |
---|
| 4287 | % A=imread(filecell.ima1.civ1{1,1});%read the first image to get the size |
---|
| 4288 | % sizim=size(A); |
---|
| 4289 | % par.npx=num2str(sizim(2)); |
---|
| 4290 | % par.npy=num2str(sizim(1)); |
---|
| 4291 | % %TODO : civ should not need npx and npy |
---|
| 4292 | % |
---|
| 4293 | % |
---|
| 4294 | % % end |
---|
| 4295 | % %time=get(handles.RootName,'UserData'); %get the set of times |
---|
| 4296 | % dummy=get(handles.txt_GridName,'String'); |
---|
| 4297 | % par.gridname=dummy{1}; |
---|
| 4298 | % par.gridflag='y'; |
---|
| 4299 | % if strcmp(par.gridname,'')|| isempty(par.gridname) |
---|
| 4300 | % par.gridname='nogrid'; |
---|
| 4301 | % par.gridflag='n'; |
---|
| 4302 | % end |
---|
| 4303 | % |
---|
[272] | 4304 | |
---|
| 4305 | |
---|
| 4306 | %------------------------------------------------------------------------ |
---|
[2] | 4307 | function par=read_param_civ2(handles,file_ima) |
---|
[12] | 4308 | %------------------------------------------------------------------------ |
---|
[287] | 4309 | par.ibx=get(handles.num_Bx,'String'); |
---|
| 4310 | par.iby=get(handles.num_By,'String'); |
---|
| 4311 | par.rho=get(handles.num_Rho,'String'); |
---|
| 4312 | par.decimal=int2str(get(handles.CheckDecimal,'Value')); |
---|
| 4313 | par.deformation=int2str(get(handles.CheckDeformation,'Value')); |
---|
[276] | 4314 | par.dx=get(handles.num_Dx,'String'); |
---|
| 4315 | par.dy=get(handles.num_Dy,'String'); |
---|
[127] | 4316 | if isnan(str2double(par.dx)) |
---|
[276] | 4317 | if isempty(get(handles.txt_GridName,'String')); |
---|
[112] | 4318 | par.dx='0'; %just read by civ program, not used |
---|
| 4319 | else |
---|
[12] | 4320 | par.dx='20';%default |
---|
[276] | 4321 | set(handles.num_Dx,'String','20'); |
---|
[112] | 4322 | end |
---|
| 4323 | end |
---|
[127] | 4324 | if isnan(str2double(par.dy)) |
---|
[276] | 4325 | if isempty(get(handles.txt_GridName,'String')); |
---|
[112] | 4326 | par.dy='0';%just read by civ program, not used |
---|
| 4327 | else |
---|
[12] | 4328 | par.dy='20';%default |
---|
[276] | 4329 | set(handles.num_Dy,'String','20'); |
---|
[112] | 4330 | end |
---|
| 4331 | end |
---|
| 4332 | par.pxcmx='1'; |
---|
| 4333 | par.pxcmy='1'; |
---|
[12] | 4334 | A=imread(file_ima);%read the first image to get the size |
---|
| 4335 | sizim=size(A); |
---|
| 4336 | par.npx=num2str(sizim(2)); |
---|
| 4337 | par.npy=num2str(sizim(1)); |
---|
[127] | 4338 | %time=get(handles.RootName,'UserData'); %get the set of times |
---|
[276] | 4339 | par.gridname=get(handles.txt_GridName,'String'); |
---|
[12] | 4340 | par.gridflag='y'; |
---|
[127] | 4341 | if strcmp(par.gridname,'')|| isempty(par.gridname) |
---|
[12] | 4342 | par.gridname='nogrid'; |
---|
| 4343 | par.gridflag='n'; |
---|
| 4344 | end |
---|
[2] | 4345 | |
---|
[272] | 4346 | function cmd_CIV1=CIV1_CMD(filename,param) |
---|
| 4347 | %TODO : include filename in par_civ1 |
---|
[12] | 4348 | %------------------------------------------------------------------------ |
---|
[2] | 4349 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 4350 | |
---|
| 4351 | %changes : filename_cmx -> filename ( no extension ) |
---|
[272] | 4352 | |
---|
[275] | 4353 | filename=regexprep(filename,'.nc',''); |
---|
[272] | 4354 | |
---|
[284] | 4355 | if isequal(Param.Civ1.Dt,'0') |
---|
| 4356 | Param.Civ1.Dt='1' ;%case of 'displacement' mode |
---|
[112] | 4357 | end |
---|
[284] | 4358 | Param.Civ1.filename_ima_a=regexprep(Param.Civ1.filename_ima_a,'.png',''); |
---|
| 4359 | Param.Civ1.filename_ima_b=regexprep(Param.Civ1.filename_ima_b,'.png',''); |
---|
[230] | 4360 | fid=fopen([filename '.civ1.cmx'],'w'); |
---|
[12] | 4361 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
[284] | 4362 | fprintf(fid, ['FirstImage ' regexprep(Param.Civ1.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4363 | fprintf(fid, ['LastImage ' regexprep(Param.Civ1.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
[112] | 4364 | fprintf(fid, ['XX' '\n' ]); |
---|
[284] | 4365 | fprintf(fid, ['Mask ' Param.Civ1.maskflag '\n' ]); |
---|
| 4366 | fprintf(fid, ['MaskName ' regexprep(Param.Civ1.maskname,'\\','\\\\') '\n' ]); |
---|
| 4367 | fprintf(fid, ['ImageSize ' Param.Civ1.npx ' ' Param.Civ1.npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 4368 | fprintf(fid, ['CorrelationBoxesSize ' Param.Civ1.ibx ' ' Param.Civ1.iby '\n' ]); |
---|
| 4369 | fprintf(fid, ['SearchBoxeSize ' Param.Civ1.isx ' ' Param.Civ1.isy '\n' ]); |
---|
| 4370 | fprintf(fid, ['RO ' Param.Civ1.rho '\n' ]); |
---|
| 4371 | fprintf(fid, ['GridSpacing ' Param.Civ1.dx ' ' Param.Civ1.dy '\n' ]); |
---|
[112] | 4372 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
[284] | 4373 | fprintf(fid, ['Dt_TO ' Param.Civ1.Dt ' ' Param.Civ1.T0 '\n' ]); |
---|
| 4374 | fprintf(fid, ['PixCmXY ' Param.Civ1.pxcmx ' ' Param.Civ1.pxcmy '\n' ]); |
---|
[112] | 4375 | fprintf(fid, ['XX 1' '\n' ]); |
---|
[284] | 4376 | fprintf(fid, ['ShiftXY ' Param.Civ1.shiftx ' ' Param.Civ1.shifty '\n' ]); |
---|
| 4377 | fprintf(fid, ['Grid ' Param.Civ1.gridflag '\n' ]); |
---|
| 4378 | fprintf(fid, ['GridName ' regexprep(Param.Civ1.gridname,'\\','\\\\') '\n' ]); |
---|
[112] | 4379 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 4380 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4381 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4382 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
| 4383 | fprintf(fid, [ 'DecimalShift 0' '\n' ]); |
---|
| 4384 | fprintf(fid, ['Deformation 0' '\n' ]); |
---|
| 4385 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 4386 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 4387 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 4388 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
[284] | 4389 | fprintf(fid, ['ImageToUse ' Param.Civ1.term_a ' ' Param.Civ1.term_b '\n' ]); % VERIFIER ? |
---|
[112] | 4390 | fprintf(fid, ['ImageUsedBefore null null' '\n' ]); |
---|
[12] | 4391 | fclose(fid); |
---|
[112] | 4392 | |
---|
[163] | 4393 | % cmd_CIV1=[sparam.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file |
---|
| 4394 | % cmd_CIV1=regexprep(cmd_CIV1,'\\','\\\\'); |
---|
| 4395 | % namelog=regexprep(namelog,'\\','\\\\'); |
---|
[12] | 4396 | if(isunix) |
---|
[272] | 4397 | cmd_CIV1=['cp -f ' filename '.civ1.cmx ' filename '.cmx']; |
---|
| 4398 | cmd_CIV1=[cmd_CIV1 '\n'... |
---|
[284] | 4399 | Param.xml.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx |
---|
[219] | 4400 | cmd_CIV1=[cmd_CIV1 '\n' 'mv ' filename '.log' ' ' filename '.civ1.log' '\n' 'chmod g+w ' filename '.civ1.log' '\n' 'chmod g+w ' filename '.nc'];%rename .log as .civ1.log and set the netcdf result file for group user writting |
---|
[282] | 4401 | % cmd_CIV1=[cmd_CIV1 '\n' 'mv ' filename '.cmx' ' ' filename '.checkciv1.cmx' '\n'];%rename .cmx as .checkciv1.cmx |
---|
[163] | 4402 | else %Windows system |
---|
[269] | 4403 | % flname=regexprep(flname,'\\','\\\\'); |
---|
[282] | 4404 | % cmd=[cmd 'copy /Y "' flname '.checkciv1.cmx" "' flname '.cmx"\n']; |
---|
[269] | 4405 | % filename=regexprep(filename,'\\','\\\\'); |
---|
[272] | 4406 | cmd_CIV1=['copy /Y "' filename '.civ1.cmx" "' filename '.cmx"'];% copy the .civ1.cmx parameter file to .cmx |
---|
[284] | 4407 | cmd_CIV1=[cmd_CIV1 '\n "' regexprep(Param.xml.Civ1Bin,'\\','\\\\') '" -f "' filename '.cmx" >"' filename '.log"' ]; % redirect standard output to the log file |
---|
[272] | 4408 | % namelog=regexprep(namelog,'\\','\\\\'); |
---|
| 4409 | cmd_CIV1=[cmd_CIV1 '\n ' 'copy /Y "' filename '.log' '" "' filename '.civ1.log"']; %preserve the log file as .civ1.log |
---|
| 4410 | |
---|
[282] | 4411 | % cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y "' filename '.cmx' '" "' filename '.checkciv1.cmx"']; |
---|
[12] | 4412 | end |
---|
[2] | 4413 | |
---|
[12] | 4414 | %------------------------------------------------------------------------ |
---|
[282] | 4415 | % --- CheckCiv1 Unified |
---|
[94] | 4416 | function xml_civ1_parameters=CIV1_CMD_Unified(filename,namelog,par) |
---|
[12] | 4417 | %------------------------------------------------------------------------ |
---|
[2] | 4418 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
[282] | 4419 | %global CivBin%name of the executable for checkciv1 calculation |
---|
[2] | 4420 | |
---|
[112] | 4421 | civ1.image1=par.filename_ima_a; |
---|
| 4422 | civ1.image2=par.filename_ima_b; |
---|
| 4423 | civ1.imageSize_X=par.npx; |
---|
| 4424 | civ1.imageSize_Y=par.npy; |
---|
| 4425 | civ1.outputFileName=[filename '.nc']; |
---|
| 4426 | civ1.correlationBoxesSize_X=par.ibx; |
---|
| 4427 | civ1.correlationBoxesSize_Y=par.iby; |
---|
| 4428 | civ1.searchBoxesSize_X=par.isx; |
---|
| 4429 | civ1.searchBoxesSize_Y=par.isy; |
---|
| 4430 | civ1.globalShift_X=par.shiftx; |
---|
| 4431 | civ1.globalShift_Y=par.shifty; |
---|
| 4432 | civ1.ro=par.rho; |
---|
| 4433 | civ1.hart='y'; |
---|
| 4434 | if isequal(par.gridflag,'y') |
---|
| 4435 | civ1.grid=par.gridname; |
---|
| 4436 | else |
---|
| 4437 | civ1.grid='n'; |
---|
| 4438 | civ1.gridSpacing_X=par.dx; |
---|
| 4439 | civ1.gridSpacing_Y=par.dy; |
---|
| 4440 | end |
---|
| 4441 | if isequal(par.maskflag,'y') |
---|
| 4442 | civ1.mask=par.maskname; |
---|
| 4443 | end |
---|
[229] | 4444 | civ1.dt=par.Dt; |
---|
[112] | 4445 | civ1.unit='pixel'; |
---|
| 4446 | civ1.absolut_time_T0=par.T0; |
---|
| 4447 | civ1.pixcmx=par.pxcmx; |
---|
| 4448 | civ1.pixcmy=par.pxcmy; |
---|
| 4449 | civ1.convectFlow='n'; |
---|
[12] | 4450 | |
---|
[112] | 4451 | xml_civ1_parameters=civ1; |
---|
| 4452 | |
---|
[12] | 4453 | %------------------------------------------------------------------------ |
---|
[282] | 4454 | % --- CheckCiv2 Unified |
---|
[94] | 4455 | function civ2=CIV2_CMD_Unified(filename,namelog,par) |
---|
[12] | 4456 | %------------------------------------------------------------------------ |
---|
[2] | 4457 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
[282] | 4458 | %global CivBin%name of the executable for checkciv1 calculation |
---|
[275] | 4459 | |
---|
[272] | 4460 | filename=regexprep(filename,'.nc',''); |
---|
[2] | 4461 | |
---|
| 4462 | civ2.image1=par.filename_ima_a; |
---|
| 4463 | civ2.image2=par.filename_ima_b; |
---|
[112] | 4464 | civ2.imageSize_X=par.npx; |
---|
[2] | 4465 | civ2.imageSize_Y=par.npy; |
---|
| 4466 | civ2.inputFileName=[par.filename_nc1 '.nc']; |
---|
| 4467 | civ2.outputFileName=[filename '.nc']; |
---|
| 4468 | civ2.correlationBoxesSize_X=par.ibx; |
---|
| 4469 | civ2.correlationBoxesSize_Y=par.iby; |
---|
| 4470 | civ2.ro=par.rho; |
---|
[287] | 4471 | %checkciv2.decimalShift=par.CheckDecimal; |
---|
| 4472 | %checkciv2.CheckDeformation=par.CheckDeformation; |
---|
[2] | 4473 | if isequal(par.decimal,'1') |
---|
| 4474 | civ2.decimalShift='y'; |
---|
| 4475 | else |
---|
| 4476 | civ2.decimalShift='n'; |
---|
| 4477 | end |
---|
| 4478 | if isequal(par.deformation,'1') |
---|
| 4479 | civ2.deformation='y'; |
---|
| 4480 | else |
---|
| 4481 | civ2.deformation='n'; |
---|
| 4482 | end |
---|
| 4483 | if isequal(par.gridflag,'y') |
---|
| 4484 | civ2.grid=par.gridname; |
---|
| 4485 | else |
---|
| 4486 | civ2.grid='n'; |
---|
| 4487 | civ2.gridSpacing_X=par.dx; |
---|
| 4488 | civ2.gridSpacing_Y=par.dy; |
---|
| 4489 | end |
---|
| 4490 | civ2.gridSpacing_X='10'; |
---|
| 4491 | civ2.gridSpacing_Y='10';%NOTE: faut mettre gridSpacing pourque ca tourne, meme si c'est la grille qui est utilisee |
---|
| 4492 | if isequal(par.maskflag,'y') |
---|
| 4493 | civ2.mask=par.maskname; |
---|
| 4494 | else |
---|
| 4495 | civ2.mask='n'; |
---|
| 4496 | end |
---|
| 4497 | civ2.dt=par.Dt; |
---|
| 4498 | civ2.unit='pixel'; |
---|
| 4499 | civ2.absolut_time_T0=par.T0; |
---|
| 4500 | civ2.pixcmx=par.pxcmx; |
---|
| 4501 | civ2.pixcmy=par.pxcmy; |
---|
| 4502 | civ2.convectFlow='n'; |
---|
| 4503 | civ2.pixcmx=par.pxcmx; |
---|
| 4504 | civ2.pixcmy=par.pxcmy; |
---|
| 4505 | civ2.convectFlow='n'; |
---|
| 4506 | |
---|
[12] | 4507 | %------------------------------------------------------------------------ |
---|
[282] | 4508 | % --- CheckCiv2 CheckCiv2 CheckCiv2 CheckCiv2 |
---|
[272] | 4509 | function cmd_CIV2=CIV2_CMD(filename,param) |
---|
[12] | 4510 | %------------------------------------------------------------------------ |
---|
[2] | 4511 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
[282] | 4512 | % global civ2Bin sge%name of the executable for checkciv1 calculation |
---|
[275] | 4513 | filename=regexprep(filename,'.nc',''); |
---|
[290] | 4514 | if isequal(Param.Civ2.Dt,'0') |
---|
| 4515 | Param.Civ2.Dt='1' ;%case of 'displacement' mode |
---|
[112] | 4516 | end |
---|
[290] | 4517 | Param.Civ2.filename_ima_a=regexprep(Param.Civ2.filename_ima_a,'.png',''); |
---|
| 4518 | Param.Civ2.filename_ima_b=regexprep(Param.Civ2.filename_ima_b,'.png','');% bug : .png appears two times ? |
---|
[174] | 4519 | [fid,errormsg]=fopen([filename '.civ2.cmx'],'w'); |
---|
| 4520 | if isequal(fid,-1) |
---|
| 4521 | msgbox_uvmat('ERROR',errormsg) |
---|
| 4522 | cmd_CIV2=''; |
---|
| 4523 | return |
---|
| 4524 | end |
---|
[94] | 4525 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
[290] | 4526 | fprintf(fid, ['FirstImage ' regexprep(Param.Civ2.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4527 | fprintf(fid, ['LastImage ' regexprep(Param.Civ2.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
[94] | 4528 | fprintf(fid, ['XX' '\n' ]); |
---|
[290] | 4529 | fprintf(fid, ['Mask ' Param.Civ2.MaskFlag '\n' ]); |
---|
| 4530 | fprintf(fid, ['MaskName ' regexprep(Param.Civ2.MaskName,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 4531 | fprintf(fid, ['ImageSize ' Param.Civ2.npx ' ' Param.Civ2.npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 4532 | fprintf(fid, ['CorrelationBoxesSize ' Param.Civ2.ibx ' ' Param.Civ2.iby '\n' ]); |
---|
| 4533 | fprintf(fid, ['SearchBoxeSize ' Param.Civ2.ibx ' ' Param.Civ2.iby '\n']); |
---|
| 4534 | fprintf(fid, ['RO ' Param.Civ2.rho '\n']); |
---|
| 4535 | fprintf(fid, ['GridSpacing ' Param.Civ2.dx ' ' Param.Civ2.dy '\n']); |
---|
[94] | 4536 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
[290] | 4537 | fprintf(fid, ['Dt_TO ' Param.Civ2.Dt ' ' Param.Civ2.T0 '\n' ]); |
---|
| 4538 | fprintf(fid, ['PixCmXY ' Param.Civ2.pxcmx ' ' Param.Civ2.pxcmy '\n' ]); |
---|
[94] | 4539 | fprintf(fid, ['XX 1' '\n' ]); |
---|
[122] | 4540 | fprintf(fid, 'ShiftXY 0 0\n'); |
---|
[290] | 4541 | fprintf(fid, ['Grid ' Param.Civ2.GridFlag '\n' ]); |
---|
| 4542 | fprintf(fid, ['GridName ' regexprep(Param.Civ2.GridName,'\\','\\\\') '\n']); |
---|
[94] | 4543 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 4544 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4545 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 4546 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
[290] | 4547 | fprintf(fid, ['DecimalShift ' Param.Civ2.decimal '\n']); |
---|
| 4548 | fprintf(fid, ['Deformation ' Param.Civ2.deformation '\n']); |
---|
[94] | 4549 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 4550 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 4551 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 4552 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
[290] | 4553 | fprintf(fid, ['ImageToUse ' Param.Civ2.term_a ' ' Param.Civ2.term_b '\n' ]); % VERIFIER ? |
---|
| 4554 | fprintf(fid, ['ImageUsedBefore ' regexprep(Param.Civ2.filename_nc1,'\\','\\\\') '\n']); |
---|
[94] | 4555 | fclose(fid); |
---|
| 4556 | |
---|
[134] | 4557 | if(isunix) |
---|
[230] | 4558 | cmd_CIV2=['cp -f ' filename '.civ2.cmx ' filename '.cmx\n']; |
---|
[284] | 4559 | cmd_CIV2=[cmd_CIV2 Param.xml.Civ2Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx |
---|
[230] | 4560 | cmd_CIV2=[cmd_CIV2 '\n' 'mv ' filename '.log' ' ' filename '.civ2.log' '\n' 'chmod g+w ' filename '.nc'];%preserve the log file as .civ2.log |
---|
[282] | 4561 | % cmd_CIV2=[cmd_CIV2 '\n' 'mv ' filename '.cmx' ' ' filename '.checkciv2.cmx' '\n'];%rename .cmx as .checkciv2.cmx, the result file is named [filename '.nc'] by CIVx |
---|
[230] | 4562 | |
---|
[163] | 4563 | else |
---|
[174] | 4564 | filename=regexprep(filename,'\\','\\\\'); |
---|
[272] | 4565 | cmd_CIV2=['copy /Y "' filename '.civ2.cmx" "' filename '.cmx"']; |
---|
[284] | 4566 | cmd_CIV2=[cmd_CIV2 '\n "' regexprep(Param.xml.Civ2Bin,'\\','\\\\') '" -f "' filename '.cmx" >"' filename '.log"' ]; % redirect standard output to the log file |
---|
[272] | 4567 | cmd_CIV2=[cmd_CIV2 '\n ' 'copy /Y "' filename '.log' '" "' filename '.civ2.log"']; |
---|
[282] | 4568 | % cmd_CIV2=[cmd_CIV2 '\n' 'copy /Y "' filename '.cmx' '" "' filename '.checkciv2.cmx"']; |
---|
[134] | 4569 | end |
---|
| 4570 | |
---|
| 4571 | |
---|
[12] | 4572 | %------------------------------------------------------------------------ |
---|
[2] | 4573 | %--read images and convert them to the uint16 format used for PIV |
---|
[45] | 4574 | function A=read_image(filename,type_ima,num,movieobject) |
---|
[12] | 4575 | %------------------------------------------------------------------------ |
---|
[2] | 4576 | %num is the view number needed for an avi movie |
---|
[45] | 4577 | switch type_ima |
---|
| 4578 | case 'movie' |
---|
| 4579 | A=read(movieobject,num); |
---|
| 4580 | case 'avi' |
---|
[112] | 4581 | mov=aviread(filename,num); |
---|
| 4582 | A=frame2im(mov(1)); |
---|
[45] | 4583 | case 'multimage' |
---|
| 4584 | A=imread(filename,num); |
---|
[112] | 4585 | case 'image' |
---|
[45] | 4586 | A=imread(filename); |
---|
| 4587 | end |
---|
| 4588 | siz=size(A); |
---|
| 4589 | if length(siz)==3;%color images |
---|
[2] | 4590 | A=sum(double(A),3); |
---|
| 4591 | A=uint16(A); |
---|
| 4592 | end |
---|
| 4593 | |
---|
[12] | 4594 | %------------------------------------------------------------------------ |
---|
[2] | 4595 | function ref_i_Callback(hObject, eventdata, handles) |
---|
[12] | 4596 | %------------------------------------------------------------------------ |
---|
[282] | 4597 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 4598 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[2] | 4599 | mode=mode_list{mode_value}; |
---|
[45] | 4600 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
[12] | 4601 | if isequal(mode,'series(Di)') || ...% we do patch2 only |
---|
[282] | 4602 | (get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0) |
---|
[2] | 4603 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 4604 | end |
---|
| 4605 | |
---|
[12] | 4606 | %------------------------------------------------------------------------ |
---|
[2] | 4607 | function ref_j_Callback(hObject, eventdata, handles) |
---|
[12] | 4608 | %------------------------------------------------------------------------ |
---|
[282] | 4609 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 4610 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[2] | 4611 | mode=mode_list{mode_value}; |
---|
[282] | 4612 | if isequal(get(handles.CheckCiv1,'Value'),0)|| isequal(mode,'series(Dj)') |
---|
[2] | 4613 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
| 4614 | end |
---|
[45] | 4615 | if isequal(mode,'series(Dj)') || ... |
---|
[282] | 4616 | (get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0) |
---|
[2] | 4617 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
| 4618 | end |
---|
[12] | 4619 | |
---|
| 4620 | %------------------------------------------------------------------------ |
---|
[71] | 4621 | function ref_i_civ2_Callback(hObject, eventdata, handles) |
---|
| 4622 | %------------------------------------------------------------------------ |
---|
[282] | 4623 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 4624 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[71] | 4625 | mode=mode_list{mode_value}; |
---|
| 4626 | find_netcpair_civ2(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
| 4627 | |
---|
| 4628 | %------------------------------------------------------------------------ |
---|
| 4629 | function ref_j_civ2_Callback(hObject, eventdata, handles) |
---|
| 4630 | %------------------------------------------------------------------------ |
---|
[282] | 4631 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 4632 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[71] | 4633 | mode=mode_list{mode_value}; |
---|
[112] | 4634 | if isequal(mode,'series(Dj)') |
---|
[71] | 4635 | find_netcpair_civ2(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
| 4636 | end |
---|
| 4637 | |
---|
| 4638 | %------------------------------------------------------------------------ |
---|
[282] | 4639 | % --- Executes on button press in ListCompareMode. |
---|
| 4640 | function ListCompareMode_Callback(hObject, eventdata, handles) |
---|
[12] | 4641 | %------------------------------------------------------------------------ |
---|
[282] | 4642 | test=get(handles.ListCompareMode,'Value'); |
---|
[263] | 4643 | if test==2 || test==3 % case 'dispalcemen' or 'stereo PIV' |
---|
[71] | 4644 | filebase=get(handles.RootName,'String'); |
---|
[273] | 4645 | browse=get(handlesRootName,'Userdata'); |
---|
[2] | 4646 | browse.nom_type_ima1=browse.nom_type_ima; |
---|
[273] | 4647 | set(handlesRootName,'UserData',browse); |
---|
[2] | 4648 | set(handles.sub_txt,'Visible','on') |
---|
[112] | 4649 | set(handles.RootName_1,'Visible','On');%mkes the second file input window visible |
---|
[282] | 4650 | mode_store=get(handles.ListPairMode,'String');%get the present 'mode' |
---|
| 4651 | set(handles.ListCompareMode,'UserData',mode_store);%store the mode display |
---|
| 4652 | set(handles.ListPairMode,'Visible','off') |
---|
[2] | 4653 | if test==2 |
---|
[282] | 4654 | set(handles.ListPairMode,'Visible','off') |
---|
| 4655 | set(handles.ListPairMode,'Value',1) % mode 'civX' selected by default |
---|
[2] | 4656 | else |
---|
[282] | 4657 | set(handles.ListPairMode,'Visible','on') |
---|
| 4658 | set(handles.ListPairMode,'Value',3) % mode 'Matlab' selected for stereo |
---|
[2] | 4659 | end |
---|
| 4660 | |
---|
[273] | 4661 | %% menuopen an image file with the browser |
---|
[2] | 4662 | ind_opening=1;%default |
---|
| 4663 | browse.incr_pair=[0 0]; %default |
---|
[71] | 4664 | oldfile=get(handles.RootName,'String'); |
---|
[229] | 4665 | menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)'; |
---|
| 4666 | '*.xml', '.xml files '; ... |
---|
| 4667 | '*.civ', '.civ files '; ... |
---|
| 4668 | '*.png','.png image files'; ... |
---|
| 4669 | '*.jpg',' jpeg image files'; ... |
---|
| 4670 | '*.tif','.tif image files'; ... |
---|
| 4671 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 4672 | '*.nc','.netcdf files'; ... |
---|
| 4673 | '*.*', 'All Files (*.*)'}; |
---|
| 4674 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file of the second series',oldfile); |
---|
[112] | 4675 | fileinput=[PathName FileName];%complete file name |
---|
[2] | 4676 | sizf=size(fileinput); |
---|
[229] | 4677 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
[275] | 4678 | [path,name,ext]=fileparts(fileinput); |
---|
[2] | 4679 | [path1]=fileparts(filebase); |
---|
[263] | 4680 | if isunix |
---|
[289] | 4681 | [status,path]=system(['readlink ' path]); |
---|
| 4682 | [status,path1]=system(['readlink ' path1]);% look for the true path in case of symbolic paths |
---|
[263] | 4683 | end |
---|
[2] | 4684 | if ~strcmp(path1,path) |
---|
[263] | 4685 | msgbox_uvmat('ERROR','The second image series must be in the same directory as the first one') |
---|
[2] | 4686 | return |
---|
[263] | 4687 | end |
---|
| 4688 | % set(handles.RootName_1,'String',name); |
---|
[2] | 4689 | [RootPath,RootFile,field_count,str2,str_a,str_b,xx,nom_type,subdir]=name2display(name); |
---|
[263] | 4690 | set(handles.RootName_1,'String',RootFile); |
---|
[273] | 4691 | browse=get(handlesRootName,'UserData'); |
---|
[2] | 4692 | browse.nom_type_ima_1=nom_type; |
---|
[273] | 4693 | set(handlesRootName,'UserData',browse) |
---|
[2] | 4694 | |
---|
| 4695 | %check image extension |
---|
[71] | 4696 | if ~strcmp(ext,get(handles.ImaExt,'String')) |
---|
[263] | 4697 | msgbox_uvmat('ERROR','The second image series must have the same extension name as the first one') |
---|
[2] | 4698 | return |
---|
| 4699 | end |
---|
| 4700 | |
---|
[229] | 4701 | %% check coincidence of image sizes |
---|
[263] | 4702 | % ref_i=get(handles.ref_i,'string'); |
---|
| 4703 | % ref_j=get(handles.ref_j,'string'); |
---|
| 4704 | % [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc]=set_civ_filenames(handles,ref_i,ref_j,[1 0 0 0 0 0]); |
---|
[282] | 4705 | % A=imread(filecell.ima1.checkciv1{1}); |
---|
[263] | 4706 | % A_1=imread(fileinput); |
---|
| 4707 | % npxy=size(A); |
---|
| 4708 | % npxy_1=size(A_1); |
---|
| 4709 | % if ~isequal(size(A),size(A_1)) |
---|
| 4710 | % msgbox_uvmat('ERROR','The two input image series do not have the same size') |
---|
| 4711 | % return |
---|
| 4712 | % end |
---|
[2] | 4713 | else |
---|
[282] | 4714 | set(handles.ListPairMode,'Visible','on') |
---|
[71] | 4715 | set(handles.RootName_1,'Visible','Off'); |
---|
[2] | 4716 | set(handles.sub_txt,'Visible','off') |
---|
[71] | 4717 | set(handles.RootName_1,'String',[]); |
---|
[282] | 4718 | mode_store=get(handles.ListCompareMode,'UserData'); |
---|
| 4719 | set(handles.ListPairMode,'Value',1) |
---|
| 4720 | set(handles.ListPairMode,'String',mode_store) |
---|
[2] | 4721 | set(handles.test_stereo1,'Value',0) |
---|
[282] | 4722 | set(handles.CheckStereo,'Value',0) |
---|
| 4723 | set(handles.ListPairMode,'Value',1) % mode 'civX' selected by default |
---|
[2] | 4724 | end |
---|
[282] | 4725 | if test==3 && get(handles.CheckPatch1,'Value') |
---|
[263] | 4726 | set(handles.test_stereo1,'Visible','on') |
---|
[252] | 4727 | else |
---|
[263] | 4728 | set(handles.test_stereo1,'Visible','off') |
---|
[252] | 4729 | end |
---|
[282] | 4730 | if test==3 && get(handles.CheckPatch2,'Value') |
---|
| 4731 | set(handles.CheckStereo,'Visible','on') |
---|
[252] | 4732 | else |
---|
[282] | 4733 | set(handles.CheckStereo,'Visible','off') |
---|
[252] | 4734 | end |
---|
[2] | 4735 | mode_Callback(hObject, eventdata, handles) |
---|
| 4736 | |
---|
[12] | 4737 | %------------------------------------------------------------------------ |
---|
[2] | 4738 | % --- Executes on button press in get_ref_fix1. |
---|
| 4739 | function get_ref_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 4740 | %------------------------------------------------------------------------ |
---|
[71] | 4741 | filebase=get(handles.RootName,'String'); |
---|
[2] | 4742 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 4743 | {'*.nc', ' (*.nc)'; |
---|
| 4744 | '*.nc', 'netcdf files '; ... |
---|
| 4745 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4746 | 'Pick a file',filebase); |
---|
| 4747 | |
---|
[2] | 4748 | fileinput=[PathName FileName]; |
---|
| 4749 | sizf=size(fileinput); |
---|
[122] | 4750 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
[2] | 4751 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 4752 | ref.filebase=fullfile(Path,File); |
---|
| 4753 | ref.num_a=stra2num(str_a); |
---|
| 4754 | ref.num_b=stra2num(str_b); |
---|
[89] | 4755 | ref.num1=str2double(field_count); |
---|
| 4756 | ref.num2=str2double(str2); |
---|
[2] | 4757 | browse=[];%initialisation |
---|
| 4758 | if ~isequal(ref.ext,'.nc') |
---|
| 4759 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
| 4760 | return |
---|
| 4761 | end |
---|
| 4762 | set(handles.ref_fix1,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
| 4763 | set(handles.ref_fix1,'UserData',ref) |
---|
| 4764 | menu_field{1}='civ1'; |
---|
| 4765 | Data=nc2struct(fileinput,[]); |
---|
[45] | 4766 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
[2] | 4767 | menu_field{2}='filter1'; |
---|
| 4768 | end |
---|
[45] | 4769 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
[2] | 4770 | menu_field{3}='civ2'; |
---|
| 4771 | end |
---|
[45] | 4772 | if isfield(Data,'patch2') && isequal(Data.patch2,1) |
---|
[2] | 4773 | menu_field{4}='filter2'; |
---|
| 4774 | end |
---|
| 4775 | set(handles.field_ref1,'String',menu_field); |
---|
| 4776 | set(handles.field_ref1,'Value',length(menu_field)); |
---|
[287] | 4777 | set(handles.num_MinVel,'Value',2); |
---|
| 4778 | set(handles.num_MinVel,'String','1');%default threshold |
---|
[2] | 4779 | set(handles.ref_fix1,'Enable','on') |
---|
[12] | 4780 | |
---|
| 4781 | %------------------------------------------------------------------------ |
---|
[2] | 4782 | % --- Executes on button press in get_ref_fix2. |
---|
| 4783 | function get_ref_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 4784 | %------------------------------------------------------------------------ |
---|
[2] | 4785 | if isequal(get(handles.get_ref_fix2,'Value'),1) |
---|
[71] | 4786 | filebase=get(handles.RootName,'String'); |
---|
[2] | 4787 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
[112] | 4788 | {'*.nc', ' (*.nc)'; |
---|
| 4789 | '*.nc', 'netcdf files '; ... |
---|
| 4790 | '*.*', 'All Files (*.*)'}, ... |
---|
| 4791 | 'Pick a file',filebase); |
---|
[2] | 4792 | fileinput=[PathName FileName]; |
---|
| 4793 | sizf=size(fileinput); |
---|
[45] | 4794 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
[2] | 4795 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 4796 | ref.filebase=fullfile(Path,File); |
---|
| 4797 | ref.num_a=stra2num(str_a); |
---|
| 4798 | ref.num_b=stra2num(str_b); |
---|
| 4799 | ref.num1=str2num(field_count); |
---|
| 4800 | ref.num2=str2num(str2); |
---|
| 4801 | browse=[];%initialisation |
---|
| 4802 | if ~isequal(ref.ext,'.nc') |
---|
| 4803 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
| 4804 | return |
---|
| 4805 | end |
---|
| 4806 | set(handles.ref_fix2,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
[112] | 4807 | set(handles.ref_fix2,'UserData',ref) |
---|
[2] | 4808 | menu_field{1}='civ1'; |
---|
| 4809 | Data=nc2struct(fileinput,[]); |
---|
| 4810 | if isfield(Data,'patch') & isequal(Data.patch,1) |
---|
| 4811 | menu_field{2}='filter1'; |
---|
| 4812 | end |
---|
| 4813 | if isfield(Data,'civ2') & isequal(Data.civ2,1) |
---|
| 4814 | menu_field{3}='civ2'; |
---|
| 4815 | end |
---|
| 4816 | if isfield(Data,'patch2') & isequal(Data.patch2,1) |
---|
| 4817 | menu_field{4}='filter2'; |
---|
| 4818 | end |
---|
| 4819 | set(handles.field_ref2,'String',menu_field); |
---|
| 4820 | set(handles.field_ref2,'Value',length(menu_field)); |
---|
[287] | 4821 | set(handles.num_MinVel,'Value',2); |
---|
| 4822 | set(handles.num_MinVel,'String','1');%default threshold |
---|
[2] | 4823 | set(handles.ref_fix2,'Enable','on') |
---|
| 4824 | set(handles.ref_fix2,'Visible','on') |
---|
| 4825 | set(handles.field_ref2,'Visible','on') |
---|
| 4826 | else |
---|
| 4827 | set(handles.ref_fix2,'Visible','off') |
---|
| 4828 | set(handles.field_ref2,'Visible','off') |
---|
| 4829 | end |
---|
| 4830 | |
---|
[12] | 4831 | %------------------------------------------------------------------------ |
---|
[2] | 4832 | function ref_fix1_Callback(hObject, eventdata, handles) |
---|
[12] | 4833 | %------------------------------------------------------------------------ |
---|
[287] | 4834 | set(handles.num_MinVel,'Value',1); |
---|
[12] | 4835 | set(handles.field_ref1,'Value',1) |
---|
| 4836 | set(handles.field_ref1,'String',{' '}) |
---|
| 4837 | set(handles.ref_fix1,'UserData',[]); |
---|
| 4838 | set(handles.ref_fix1,'String',''); |
---|
| 4839 | set(handles.thresh_vel1,'String','0'); |
---|
[112] | 4840 | |
---|
[12] | 4841 | %------------------------------------------------------------------------ |
---|
[2] | 4842 | function ref_fix2_Callback(hObject, eventdata, handles) |
---|
[12] | 4843 | %------------------------------------------------------------------------ |
---|
[287] | 4844 | set(handles.num_MinVel,'Value',1); |
---|
[12] | 4845 | set(handles.field_ref2,'Value',1) |
---|
| 4846 | set(handles.field_ref2,'String',{' '}) |
---|
| 4847 | set(handles.ref_fix2,'UserData',[]); |
---|
| 4848 | set(handles.ref_fix2,'String',''); |
---|
[287] | 4849 | set(handles.num_MinVel,'String','0'); |
---|
[2] | 4850 | |
---|
[12] | 4851 | %------------------------------------------------------------------------ |
---|
[2] | 4852 | % --- Executes on button press in test_stereo1. |
---|
| 4853 | function test_stereo1_Callback(hObject, eventdata, handles) |
---|
[12] | 4854 | %------------------------------------------------------------------------ |
---|
[2] | 4855 | if isequal(get(handles.test_stereo1,'Value'),0) |
---|
| 4856 | set(handles.subdomain_patch1,'Visible','on') |
---|
| 4857 | set(handles.rho_patch1,'Visible','on') |
---|
| 4858 | else |
---|
| 4859 | set(handles.subdomain_patch1,'Visible','off') |
---|
| 4860 | set(handles.rho_patch1,'Visible','off') |
---|
| 4861 | end |
---|
| 4862 | |
---|
[12] | 4863 | %------------------------------------------------------------------------ |
---|
[282] | 4864 | % --- Executes on button press in CheckStereo. |
---|
[273] | 4865 | function StereoCheck_Callback(hObject, eventdata, handles) |
---|
[12] | 4866 | %------------------------------------------------------------------------ |
---|
[282] | 4867 | if isequal(get(handles.CheckStereo,'Value'),0) |
---|
[274] | 4868 | set(handles.num_SubdomainSize,'Visible','on') |
---|
[292] | 4869 | set(handles.num_SmoothingParam,'Visible','on') |
---|
[2] | 4870 | else |
---|
[274] | 4871 | set(handles.num_SubdomainSize,'Visible','off') |
---|
[292] | 4872 | set(handles.num_SmoothingParam,'Visible','off') |
---|
[2] | 4873 | end |
---|
| 4874 | |
---|
[12] | 4875 | %------------------------------------------------------------------------ |
---|
[276] | 4876 | % --- Executes on button press in check_Threshold. |
---|
[2] | 4877 | function ImaThreshold_Callback(hObject, eventdata, handles) |
---|
[12] | 4878 | %------------------------------------------------------------------------ |
---|
[276] | 4879 | if isequal(get(handles.check_Threshold,'Value'),1) |
---|
[282] | 4880 | set(handles.num_MinIma,'Visible','on') |
---|
| 4881 | set(handles.num_MaxIma,'Visible','on') |
---|
[2] | 4882 | else |
---|
[282] | 4883 | set(handles.num_MinIma,'Visible','off') |
---|
| 4884 | set(handles.num_MaxIma,'Visible','off') |
---|
[2] | 4885 | end |
---|
| 4886 | |
---|
[12] | 4887 | %------------------------------------------------------------------------ |
---|
[2] | 4888 | % --- Executes on button press in ImaThreshold2. |
---|
| 4889 | function ImaThreshold2_Callback(hObject, eventdata, handles) |
---|
[12] | 4890 | %------------------------------------------------------------------------ |
---|
[2] | 4891 | if isequal(get(handles.ImaThreshold2,'Value'),1) |
---|
[287] | 4892 | set(handles.num_MinIma,'Visible','on') |
---|
| 4893 | set(handles.num_MaxIma,'Visible','on') |
---|
[2] | 4894 | else |
---|
[287] | 4895 | set(handles.num_MinIma,'Visible','off') |
---|
| 4896 | set(handles.num_MaxIma,'Visible','off') |
---|
[2] | 4897 | end |
---|
| 4898 | |
---|
[224] | 4899 | %------------------------------------------------------------------------ |
---|
[225] | 4900 | % --- Executes on button press in TestCiv1: display image correlation function |
---|
[150] | 4901 | function TestCiv1_Callback(hObject, eventdata, handles) |
---|
[224] | 4902 | %------------------------------------------------------------------------ |
---|
[233] | 4903 | set(handles.TestCiv1,'BackgroundColor',[1 1 0]) |
---|
| 4904 | drawnow |
---|
[150] | 4905 | test_civ1=get(handles.TestCiv1,'Value'); |
---|
| 4906 | if test_civ1 |
---|
[227] | 4907 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
| 4908 | if strcmp(get(handles.ref_j,'Visible'),'on') |
---|
| 4909 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
| 4910 | else |
---|
| 4911 | ref_j=1;%default |
---|
| 4912 | end |
---|
[224] | 4913 | [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]=... |
---|
[273] | 4914 | set_civ_filenames(handles,ref_i,ref_j,[1 0 0 0 0 0]); |
---|
[224] | 4915 | Data.ListVarName={'ny','nx','A'}; |
---|
| 4916 | Data.VarDimName={'ny','nx',{'ny','nx'}}; |
---|
| 4917 | Data.A=imread(filecell.ima1.civ1{1}); |
---|
| 4918 | Data.ny=[size(Data.A,1) 1]; |
---|
| 4919 | Data.nx=[1 size(Data.A,2)]; |
---|
[227] | 4920 | par_civ1=read_param_civ1(handles,filecell.ima1.civ1{1}); |
---|
[231] | 4921 | par_civ1.filename_ima_a=filecell.ima1.civ1{1}; |
---|
| 4922 | par_civ1.filename_ima_b=filecell.ima2.civ1{1}; |
---|
| 4923 | par_civ1.T0=0; |
---|
| 4924 | par_civ1.Dt=1; |
---|
[246] | 4925 | Param.Civ1=par_civ1; |
---|
| 4926 | Data=civ_uvmat(Param); |
---|
[231] | 4927 | Data.ListVarName=[Data.ListVarName {'ny','nx','A'}]; |
---|
| 4928 | Data.VarDimName=[Data.VarDimName {'ny','nx',{'ny','nx'}}]; |
---|
| 4929 | Data.A=imread(filecell.ima1.civ1{1}); |
---|
| 4930 | Data.ny=[size(Data.A,1) 1]; |
---|
| 4931 | Data.nx=[1 size(Data.A,2)]; |
---|
| 4932 | hview_field=view_field(Data); |
---|
| 4933 | set(0,'CurrentFigure',hview_field) |
---|
| 4934 | hhview_field=guihandles(hview_field); |
---|
| 4935 | set(hview_field,'CurrentAxes',hhview_field.axes3) |
---|
| 4936 | ViewData=get(hview_field,'UserData'); |
---|
| 4937 | ViewData.CivHandle=handles.civ;% indicate the handle of the civ GUI in view_field |
---|
[224] | 4938 | ViewData.axes3.B=imread(filecell.ima2.civ1{1});%store the second image in the UserData of the GUI view_field |
---|
[236] | 4939 | ViewData.axes3.X=Data.Civ1_X; %keep the set of points in memeory |
---|
| 4940 | ViewData.axes3.Y=Data.Civ1_Y; |
---|
[231] | 4941 | set(hview_field,'UserData',ViewData) |
---|
[224] | 4942 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
| 4943 | if isempty(corrfig) |
---|
| 4944 | corrfig=figure; |
---|
| 4945 | set(corrfig,'tag','corrfig') |
---|
| 4946 | set(corrfig,'name','image correlation') |
---|
| 4947 | set(corrfig,'DeleteFcn',{@closeview_field})% |
---|
| 4948 | end |
---|
[233] | 4949 | set(handles.TestCiv1,'BackgroundColor',[1 0 0]) |
---|
[224] | 4950 | else |
---|
| 4951 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
| 4952 | if ~isempty(corrfig) |
---|
| 4953 | delete(corrfig) |
---|
| 4954 | end |
---|
| 4955 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
| 4956 | if ~isempty(hview_field) |
---|
| 4957 | delete(hview_field) |
---|
| 4958 | end |
---|
[150] | 4959 | end |
---|
[71] | 4960 | |
---|
[224] | 4961 | function closeview_field(gcbo,eventdata) |
---|
| 4962 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
| 4963 | if ~isempty(hview_field) |
---|
| 4964 | delete(hview_field) |
---|
| 4965 | end |
---|
[177] | 4966 | %------------------------------------------------------------------- |
---|
| 4967 | % --- Executes on button press in status. |
---|
| 4968 | function status_Callback(hObject, eventdata, handles) |
---|
| 4969 | %------------------------------------------------------------------- |
---|
| 4970 | val=get(handles.status,'Value'); |
---|
| 4971 | if val==0 |
---|
[252] | 4972 | set(handles.status,'BackgroundColor',[0 1 0]) |
---|
[177] | 4973 | hfig=findobj(allchild(0),'name','civ_status'); |
---|
| 4974 | if ~isempty(hfig) |
---|
| 4975 | delete(hfig) |
---|
| 4976 | end |
---|
| 4977 | return |
---|
| 4978 | end |
---|
[252] | 4979 | set(handles.status,'BackgroundColor',[1 1 0]) |
---|
| 4980 | drawnow |
---|
[177] | 4981 | listtype={'civ1','fix1','patch1','civ2','fix2','patch2'}; |
---|
[282] | 4982 | Param.CheckCiv1=get(handles.CheckCiv1,'Value'); |
---|
| 4983 | Param.CheckFix1=get(handles.CheckFix1,'Value'); |
---|
| 4984 | Param.CheckPatch1=get(handles.CheckPatch1,'Value'); |
---|
| 4985 | Param.CheckCiv2=get(handles.CheckCiv2,'Value'); |
---|
| 4986 | Param.CheckFix2=get(handles.CheckFix2,'Value'); |
---|
| 4987 | Param.CheckPatch2=get(handles.CheckPatch2,'Value'); |
---|
[284] | 4988 | box_test=[Param.CheckCiv1 Param.CheckFix1 Param.CheckPatch1 Param.CheckCiv2 Param.CheckFix2 Param.CheckPatch2]; |
---|
| 4989 | |
---|
[180] | 4990 | option_civ=find(box_test,1,'last');%last selected option (non-zero index of box_test) |
---|
[252] | 4991 | filecell=get(handles.civ,'UserData');%retrieve the list of output files expected for PIV |
---|
| 4992 | test_new=0; |
---|
[177] | 4993 | if ~isfield(filecell,'nc') |
---|
[252] | 4994 | test_new=1; |
---|
[227] | 4995 | [ref_i,ref_j,errormsg]=find_ref_indices(handles); |
---|
| 4996 | if ~isempty(errormsg) |
---|
| 4997 | msgbox_uvmat('ERROR',errormsg) |
---|
| 4998 | return |
---|
| 4999 | end |
---|
[252] | 5000 | filecell=set_civ_filenames(handles,ref_i,ref_j,box_test);%determine the output file expected from the GUI status |
---|
[177] | 5001 | end |
---|
| 5002 | if ~isequal(box_test(4:6),[0 0 0]) |
---|
[252] | 5003 | civ_files=filecell.nc.civ2;%case of civ2 operations |
---|
[177] | 5004 | else |
---|
| 5005 | civ_files=filecell.nc.civ1; |
---|
| 5006 | end |
---|
| 5007 | [root,filename,ext]=fileparts(civ_files{1}); |
---|
| 5008 | [rootroot,subdir,extdir]=fileparts(root); |
---|
| 5009 | hfig=findobj(allchild(0),'name','civ_status'); |
---|
| 5010 | if isempty(hfig) |
---|
[252] | 5011 | hfig=figure('DeleteFcn',@stop_status); |
---|
[177] | 5012 | set(hfig,'name','civ_status') |
---|
[182] | 5013 | hlist=uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', @open_view_field,'tag','list'); |
---|
[252] | 5014 | uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','msgbox','Max',2,'String','checking files...'); |
---|
[177] | 5015 | uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]); |
---|
[182] | 5016 | 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] | 5017 | BarPosition=[0.05 0.81 0.01 0.05]; |
---|
| 5018 | hwaitbar=uicontrol('Style','frame','Units','normalized', 'Position',BarPosition ,'BackgroundColor',[1 0 0],'tag','waitbar'); |
---|
[252] | 5019 | drawnow |
---|
[177] | 5020 | end |
---|
[188] | 5021 | % datnum=[]; |
---|
[177] | 5022 | Tabchar={}; |
---|
| 5023 | nbfiles=numel(civ_files); |
---|
| 5024 | count=0; |
---|
[188] | 5025 | testrecent=0; |
---|
[177] | 5026 | while count<nbfiles |
---|
| 5027 | count=0; |
---|
[188] | 5028 | datnum=zeros(1,nbfiles); |
---|
[177] | 5029 | for ifile=1:nbfiles |
---|
| 5030 | detect=exist(civ_files{ifile},'file'); % check the existence of the file |
---|
[179] | 5031 | option=0; |
---|
[177] | 5032 | if detect==0 |
---|
[179] | 5033 | option_str='not created'; |
---|
[177] | 5034 | else |
---|
[219] | 5035 | datfile=dir(civ_files{ifile}); |
---|
[188] | 5036 | if isfield(datfile,'datenum') |
---|
| 5037 | datnum(ifile)=datfile.datenum;%only available in recent matlab versions |
---|
| 5038 | testrecent=1; |
---|
| 5039 | end |
---|
[177] | 5040 | filefound(ifile)={datfile.name}; |
---|
| 5041 | lastfield=''; |
---|
| 5042 | % check the content netcdf file |
---|
| 5043 | Data=nc2struct(civ_files{ifile},'ListGlobalAttribute','patch2','fix2','civ2','patch','fix'); |
---|
| 5044 | if ~isempty(Data.patch2) && isequal(Data.patch2,1) |
---|
[179] | 5045 | option=6; |
---|
| 5046 | option_str='patch2'; |
---|
[177] | 5047 | elseif ~isempty(Data.fix2) && isequal(Data.fix2,1) |
---|
[179] | 5048 | option=5; |
---|
| 5049 | option_str='fix2'; |
---|
[177] | 5050 | elseif ~isempty(Data.civ2) && isequal(Data.civ2,1); |
---|
[179] | 5051 | option=4; |
---|
| 5052 | option_str='civ2'; |
---|
[177] | 5053 | elseif ~isempty(Data.patch) && isequal(Data.patch,1); |
---|
[179] | 5054 | option=3; |
---|
| 5055 | option_str='patch1'; |
---|
[177] | 5056 | elseif ~isempty(Data.fix) && isequal(Data.fix,1); |
---|
[179] | 5057 | option=2; |
---|
| 5058 | option_str='fix1'; |
---|
[177] | 5059 | else |
---|
[179] | 5060 | option=1; |
---|
| 5061 | option_str='civ1'; |
---|
[177] | 5062 | end |
---|
| 5063 | end |
---|
[179] | 5064 | if option >= option_civ |
---|
[177] | 5065 | count=count+1; |
---|
| 5066 | end |
---|
| 5067 | [rr,filename,ext]=fileparts(civ_files{ifile}); |
---|
[179] | 5068 | Tabchar{ifile,1}=[fullfile([subdir extdir],filename) ext '...' option_str]; |
---|
[177] | 5069 | end |
---|
[219] | 5070 | datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files |
---|
[188] | 5071 | if isempty(datnum) |
---|
| 5072 | if testrecent |
---|
| 5073 | message='no civ result created yet'; |
---|
| 5074 | else |
---|
| 5075 | message=''; |
---|
| 5076 | end |
---|
[177] | 5077 | else |
---|
[219] | 5078 | datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files |
---|
[177] | 5079 | [first,ind]=min(datnum); |
---|
| 5080 | [last,indlast]=max(datnum); |
---|
[252] | 5081 | if test_new |
---|
| 5082 | message='existing file status, no processing launched yet'; |
---|
| 5083 | else |
---|
[177] | 5084 | message={[num2str(count) ' file(s) done over ' num2str(nbfiles)] ;['oldest modification: ' cell2mat(filefound(ind)) ' : ' datestr(first)];... |
---|
| 5085 | ['latest modification: ' cell2mat(filefound(indlast)) ' : ' datestr(last)]}; |
---|
[252] | 5086 | end |
---|
[177] | 5087 | end |
---|
| 5088 | hfig=findobj(allchild(0),'name','civ_status'); |
---|
[252] | 5089 | if isempty(hfig)% the status list has been deleted |
---|
[177] | 5090 | return |
---|
| 5091 | else |
---|
| 5092 | hlist=findobj(hfig,'tag','list'); |
---|
| 5093 | hmsgbox=findobj(hfig,'tag','msgbox'); |
---|
| 5094 | hwaitbar=findobj(hfig,'tag','waitbar'); |
---|
| 5095 | set(hlist,'String',Tabchar) |
---|
| 5096 | set(hmsgbox,'String', message) |
---|
[252] | 5097 | if count>0 && ~test_new |
---|
[177] | 5098 | BarPosition(3)=0.9*count/nbfiles; |
---|
| 5099 | set(hwaitbar,'Position',BarPosition) |
---|
| 5100 | end |
---|
| 5101 | end |
---|
| 5102 | set(hlist,'UserData',rootroot) |
---|
[252] | 5103 | pause(10)% wait 10 seconds for next check |
---|
[177] | 5104 | end |
---|
[150] | 5105 | |
---|
[177] | 5106 | |
---|
[252] | 5107 | %------------------------------------------------------------------------ |
---|
| 5108 | % call 'view_field.fig' to display the field selected in the list of 'status' |
---|
[177] | 5109 | function open_view_field(hObject, eventdata) |
---|
[252] | 5110 | %------------------------------------------------------------------------ |
---|
| 5111 | list=get(hObject,'String'); |
---|
| 5112 | index=get(hObject,'Value'); |
---|
| 5113 | rootroot=get(hObject,'UserData'); |
---|
| 5114 | filename=list{index}; |
---|
| 5115 | ind_dot=findstr(filename,'...'); |
---|
| 5116 | filename=filename(1:ind_dot-1); |
---|
| 5117 | filename=fullfile(rootroot,filename); |
---|
| 5118 | delete(get(hObject,'parent'))%delete the display figure to stop the check process |
---|
| 5119 | if exist(filename,'file')%visualise the vel field if it exists |
---|
| 5120 | uvmat(filename) |
---|
| 5121 | set(gcbo,'Value',1) |
---|
| 5122 | end |
---|
[150] | 5123 | |
---|
[252] | 5124 | %------------------------------------------------------------------------ |
---|
| 5125 | % launched by pressing OK on the status figure |
---|
[182] | 5126 | function close_GUI(hObject, eventdata) |
---|
[252] | 5127 | %------------------------------------------------------------------------ |
---|
| 5128 | delete(gcbf) |
---|
| 5129 | |
---|
| 5130 | %------------------------------------------------------------------------ |
---|
| 5131 | % launched by deleting the status figure |
---|
| 5132 | function stop_status(hObject, eventdata) |
---|
| 5133 | %------------------------------------------------------------------------ |
---|
| 5134 | hciv=findobj(allchild(0),'tag','civ'); |
---|
| 5135 | hhciv=guidata(hciv); |
---|
| 5136 | set(hhciv.status,'value',0) %reset the status uicontrol in the GUI civ |
---|
| 5137 | set(hhciv.status,'BackgroundColor',[0 1 0]) |
---|
[220] | 5138 | |
---|
[252] | 5139 | %------------------------------------------------------------------------ |
---|
[282] | 5140 | % % --- Executes on button press in ListPairMode. |
---|
[273] | 5141 | % function CivMode_Callback(hObject, eventdata, handles) |
---|
| 5142 | % %------------------------------------------------------------------------ |
---|
[282] | 5143 | % Listprog=get(handles.ListPairMode,'String'); |
---|
| 5144 | % index=get(handles.ListPairMode,'Value'); |
---|
[273] | 5145 | % prog=Listprog{index}; |
---|
| 5146 | % switch prog |
---|
| 5147 | % case 'CivX' |
---|
| 5148 | % set(handles.thresh_patch1,'Visible','off') |
---|
| 5149 | % set(handles.thresh_text1,'Visible','off') |
---|
[274] | 5150 | % set(handles.num_MaxDiff,'Visible','off') |
---|
[273] | 5151 | % set(handles.thresh_text2,'Visible','off') |
---|
[282] | 5152 | % set(handles.num_Rho,'Style','edit') |
---|
| 5153 | % set(handles.num_Rho,'String','1') |
---|
[273] | 5154 | % set(handles.BATCH,'Enable','on') |
---|
| 5155 | % case 'CivAll' |
---|
[282] | 5156 | % if get(handles.CheckPatch1,'Value') |
---|
[273] | 5157 | % set(handles.thresh_patch1,'Visible','on') |
---|
| 5158 | % set(handles.thresh_text1,'Visible','on') |
---|
| 5159 | % end |
---|
[282] | 5160 | % set(handles.num_Rho,'Style','edit') |
---|
| 5161 | % set(handles.num_Rho,'String','1') |
---|
[273] | 5162 | % set(handles.BATCH,'Enable','on') |
---|
| 5163 | % case 'CivUvmat' |
---|
| 5164 | % |
---|
| 5165 | % end |
---|
| 5166 | |
---|
| 5167 | |
---|
| 5168 | % -------------------------------------------------------------------- |
---|
| 5169 | function MenuHelp_Callback(hObject, eventdata, handles) |
---|
[276] | 5170 | path_civ=fileparts(which ('civ')); |
---|
| 5171 | helpfile=fullfile(path_civ,'uvmat_doc','uvmat_doc.html'); |
---|
| 5172 | if isempty(dir(helpfile)) |
---|
| 5173 | msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package') |
---|
[273] | 5174 | else |
---|
[276] | 5175 | addpath (fullfile(path_civ,'uvmat_doc')) |
---|
[273] | 5176 | web([helpfile '#civ']) |
---|
[224] | 5177 | end |
---|
[273] | 5178 | |
---|
| 5179 | % -------------------------------------------------------------------- |
---|
| 5180 | function CivX_Callback(hObject, eventdata, handles) |
---|
| 5181 | %set(handles.thresh_patch1,'Visible','off') |
---|
| 5182 | set(handles.thresh_text1,'Visible','off') |
---|
[274] | 5183 | set(handles.num_MaxDiff,'Visible','off') |
---|
[273] | 5184 | set(handles.thresh_text2,'Visible','off') |
---|
[282] | 5185 | set(handles.num_Rho,'Style','edit') |
---|
| 5186 | set(handles.num_Rho,'String','1') |
---|
[273] | 5187 | set(handles.BATCH,'Enable','on') |
---|
| 5188 | |
---|
| 5189 | % -------------------------------------------------------------------- |
---|
| 5190 | function Matlab_Callback(hObject, eventdata, handles) |
---|
| 5191 | set(handles.Matlab,'checked','on') |
---|
| 5192 | set(handles.CivX,'checked','off') |
---|
[282] | 5193 | if get(handles.CheckPatch1,'Value') |
---|
[273] | 5194 | set(handles.thresh_patch1,'Visible','on') |
---|
| 5195 | set(handles.thresh_text1,'Visible','on') |
---|
| 5196 | end |
---|
[282] | 5197 | if get(handles.CheckPatch2,'Value') |
---|
[274] | 5198 | set(handles.num_MaxDiff,'Visible','on') |
---|
[273] | 5199 | set(handles.thresh_text2,'Visible','on') |
---|
| 5200 | end |
---|
[282] | 5201 | set(handles.num_Rho,'Style','popupmenu') |
---|
| 5202 | set(handles.num_Rho,'Value',1) |
---|
| 5203 | set(handles.num_Rho,'String',{'1';'2'}) |
---|
[273] | 5204 | set(handles.BATCH,'Enable','off') |
---|
| 5205 | |
---|
| 5206 | % -------------------------------------------------------------------- |
---|
| 5207 | % --- read a panel with handle 'handle' producing a structure 'struct' |
---|
| 5208 | function struct=read_panel(handle) |
---|
| 5209 | hchild=get(handle,'children'); |
---|
| 5210 | for ichild=1:numel(hchild) |
---|
[282] | 5211 | if strcmp(get(hchild(ichild),'Visible'),'on') |
---|
| 5212 | object_style=get(hchild(ichild),'Style'); |
---|
| 5213 | tag=get(hchild(ichild),'tag'); |
---|
| 5214 | check_input=1;%default |
---|
| 5215 | switch object_style |
---|
| 5216 | case 'edit' |
---|
| 5217 | switch(tag(1:4)) |
---|
| 5218 | case 'num_' |
---|
| 5219 | input=str2double(get(hchild(ichild),'String')); |
---|
| 5220 | %deal with undefined input: retrieve the default value stored as UserData |
---|
| 5221 | if isnan(input) |
---|
| 5222 | input=get(hchild(ichild),'UserData'); |
---|
| 5223 | set(hchild(ichild),'String',num2str(input)) |
---|
| 5224 | end |
---|
| 5225 | case 'txt_' |
---|
| 5226 | input=get(hchild(ichild),'String'); |
---|
| 5227 | end |
---|
| 5228 | key=tag(5:end); |
---|
| 5229 | case 'checkbox' |
---|
| 5230 | input=get(hchild(ichild),'Value'); |
---|
| 5231 | key=tag(7:end); |
---|
| 5232 | otherwise |
---|
| 5233 | check_input=0; |
---|
| 5234 | end |
---|
| 5235 | if check_input |
---|
| 5236 | eval(['struct.' key '=input;']) |
---|
| 5237 | end |
---|
[273] | 5238 | end |
---|
| 5239 | end |
---|
[284] | 5240 | |
---|
| 5241 | |
---|
| 5242 | |
---|
| 5243 | function cmd=cmd_civ1(filename,Param) |
---|
| 5244 | %TODO : include filename in par_civ1 |
---|
| 5245 | %------------------------------------------------------------------------ |
---|
| 5246 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 5247 | |
---|
| 5248 | %changes : filename_cmx -> filename ( no extension ) |
---|
| 5249 | |
---|
[285] | 5250 | filename=regexprep(filename,'.nc',''); |
---|
[284] | 5251 | |
---|
| 5252 | if isequal(Param.Civ1.Dt,'0') |
---|
| 5253 | Param.Civ1.Dt='1' ;%case of 'displacement' mode |
---|
| 5254 | end |
---|
| 5255 | Param.Civ1.filename_ima_a=regexprep(Param.Civ1.filename_ima_a,'.png',''); |
---|
| 5256 | Param.Civ1.filename_ima_b=regexprep(Param.Civ1.filename_ima_b,'.png',''); |
---|
| 5257 | fid=fopen([filename '.civ1.cmx'],'w'); |
---|
| 5258 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
| 5259 | fprintf(fid, ['FirstImage ' regexprep(Param.Civ1.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 5260 | fprintf(fid, ['LastImage ' regexprep(Param.Civ1.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 5261 | fprintf(fid, ['XX' '\n' ]); |
---|
[285] | 5262 | fprintf(fid, ['Mask ' Param.Civ1.MaskFlag '\n' ]); |
---|
| 5263 | fprintf(fid, ['MaskName ' regexprep(Param.Civ1.MaskName,'\\','\\\\') '\n' ]); |
---|
[284] | 5264 | fprintf(fid, ['ImageSize ' num2str(Param.Civ1.npx) ' ' num2str(Param.Civ1.npy) '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 5265 | fprintf(fid, ['CorrelationBoxesSize ' num2str(Param.Civ1.Bx) ' ' num2str(Param.Civ1.By) '\n' ]); |
---|
[287] | 5266 | fprintf(fid, ['SearchBoxeSize ' num2str(Param.Civ1.Searchx) ' ' num2str(Param.Civ1.Searchy) '\n' ]); |
---|
[284] | 5267 | fprintf(fid, ['RO ' num2str(Param.Civ1.Rho) '\n' ]); |
---|
| 5268 | fprintf(fid, ['GridSpacing ' num2str(Param.Civ1.Dx) ' ' num2str(Param.Civ1.Dy) '\n' ]); |
---|
| 5269 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 5270 | fprintf(fid, ['Dt_TO ' num2str(Param.Civ1.Dt) ' ' num2str(Param.Civ1.T0) '\n' ]); |
---|
| 5271 | fprintf(fid, ['PixCmXY ' num2str(Param.Civ1.pxcmx) ' ' num2str(Param.Civ1.pxcmy) '\n' ]); |
---|
| 5272 | fprintf(fid, ['XX 1' '\n' ]); |
---|
| 5273 | fprintf(fid, ['ShiftXY ' num2str(Param.Civ1.Shiftx) ' ' num2str(Param.Civ1.Shifty) '\n' ]); |
---|
[285] | 5274 | fprintf(fid, ['Grid ' Param.Civ1.GridFlag '\n' ]); |
---|
| 5275 | fprintf(fid, ['GridName ' regexprep(Param.Civ1.GridName,'\\','\\\\') '\n' ]); |
---|
[284] | 5276 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 5277 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 5278 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 5279 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
| 5280 | fprintf(fid, [ 'DecimalShift 0' '\n' ]); |
---|
| 5281 | fprintf(fid, ['Deformation 0' '\n' ]); |
---|
| 5282 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 5283 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 5284 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 5285 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
| 5286 | fprintf(fid, ['ImageToUse ' Param.Civ1.term_a ' ' Param.Civ1.term_b '\n' ]); % VERIFIER ? |
---|
| 5287 | fprintf(fid, ['ImageUsedBefore null null' '\n' ]); |
---|
| 5288 | fclose(fid); |
---|
| 5289 | |
---|
| 5290 | % cmd_CIV1=[sparam.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file |
---|
| 5291 | % cmd_CIV1=regexprep(cmd_CIV1,'\\','\\\\'); |
---|
| 5292 | % namelog=regexprep(namelog,'\\','\\\\'); |
---|
| 5293 | if(isunix) |
---|
| 5294 | cmd=['cp -f ' filename '.civ1.cmx ' filename '.cmx \n '];% the cmx file gives the name to the nc file |
---|
| 5295 | cmd=[cmd Param.xml.Civ1Bin ' -f ' filename '.cmx >' filename '.civ1.log \n ' ]; % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx |
---|
| 5296 | % cmd=[cmd '\n' 'mv ' filename '.log' ' ' filename '.civ1.log' '\n' 'chmod g+w ' filename '.civ1.log' '\n' 'chmod g+w ' filename '.nc'];%rename .log as .civ1.log and set the netcdf result file for group user writting |
---|
| 5297 | % cmd=[cmd '\n' 'mv ' filename '.cmx' ' ' filename '.civ1.cmx' '\n'];%rename .cmx as .civ1.cmx |
---|
| 5298 | cmd=[cmd 'rm ' filename '.cmx']; |
---|
| 5299 | else %Windows system |
---|
| 5300 | filename=regexprep(filename,'\\','\\\\'); |
---|
| 5301 | cmd=['copy /Y "' filename '.civ1.cmx" "' filename '.cmx" \n ']; |
---|
| 5302 | cmd=[cmd '"' regexprep(Param.xml.Civ1Bin,'\\','\\\\')... |
---|
| 5303 | '" -f "' filename '.cmx" >"' filename '.civ1.log" \n ' ]; % redirect standard output to the log file |
---|
| 5304 | % namelog=regexprep(namelog,'\\','\\\\'); |
---|
| 5305 | % cmd=[cmd '\n ' 'copy /Y "' filename '.log' '" "' filename '.civ1.log"']; %preserve the log file as .civ1.log |
---|
[290] | 5306 | cmd=[cmd 'del "' filename '.cmx"']; |
---|
[284] | 5307 | end |
---|
[285] | 5308 | |
---|
| 5309 | |
---|
| 5310 | function cmd=cmd_fix(filename,Param,fixname) |
---|
| 5311 | %% |
---|
[291] | 5312 | switch fixname |
---|
| 5313 | case 'Fix1' |
---|
| 5314 | fi2_value=num2str(Param.(fixname).CheckF2); |
---|
| 5315 | case 'Fix2' |
---|
| 5316 | fi2_value=num2str(Param.(fixname).CheckF4);%need to understand why... |
---|
| 5317 | end |
---|
| 5318 | |
---|
| 5319 | |
---|
| 5320 | |
---|
[285] | 5321 | filename=regexprep(filename,'.nc',''); |
---|
[287] | 5322 | MaskName_string='';%default |
---|
| 5323 | if Param.(fixname).CheckMask |
---|
[288] | 5324 | MaskName_string=[' -maskName "' Param.(fixname).MaskName '"']; |
---|
[287] | 5325 | end |
---|
| 5326 | MaxVel_string='';%default |
---|
| 5327 | if ~isempty(Param.(fixname).MaxVel) |
---|
[289] | 5328 | MaxVel_string=[' -threshV ' num2str(Param.(fixname).MaxVel)]; |
---|
[287] | 5329 | end |
---|
[285] | 5330 | if isunix |
---|
[287] | 5331 | cmd=[Param.xml.FixBin ' -f ' filename '.nc -fi1 ' num2str(Param.(fixname).CheckFmin2) ... |
---|
[291] | 5332 | ' -fi2 ' fi2_value ' -fi3 ' num2str(Param.(fixname).CheckF3) ... |
---|
[287] | 5333 | ' -threshC ' num2str(Param.(fixname).MinCorr) MaxVel_string MaskName_string... |
---|
| 5334 | ' >' filename '.' lower(fixname) '.log 2>&1']; |
---|
[285] | 5335 | else |
---|
| 5336 | cmd=['"' Param.xml.FixBin '" -f "' filename '.nc" -fi1 ' num2str(Param.(fixname).CheckFmin2)... |
---|
[291] | 5337 | ' -fi2 ' fi2_value ' -fi3 ' num2str(Param.(fixname).CheckF3) ... |
---|
[288] | 5338 | ' -threshC ' num2str(Param.(fixname).MinCorr) MaxVel_string MaskName_string... |
---|
| 5339 | ' > "' filename '.' lower(fixname) '.log"']; |
---|
[285] | 5340 | cmd=regexprep(cmd,'\\','\\\\'); |
---|
| 5341 | end |
---|
[286] | 5342 | |
---|
| 5343 | |
---|
| 5344 | function cmd=cmd_patch(filename,Param,patchname) |
---|
| 5345 | %% ------------------------------------------------------------------------ |
---|
| 5346 | filename=regexprep(filename,'.nc',''); |
---|
| 5347 | % if test_interp==0 |
---|
| 5348 | if isunix |
---|
| 5349 | cmd=[Param.xml.PatchBin... |
---|
| 5350 | ' -f ' filename '.nc -m ' num2str(Param.(patchname).Nx)... |
---|
[292] | 5351 | ' -n ' num2str(Param.(patchname).Ny) ' -ro ' num2str(Param.(patchname).SmoothingParam)... |
---|
[286] | 5352 | ' -nopt ' num2str(Param.(patchname).SubdomainSize) ... |
---|
| 5353 | ' > ' filename '.' lower(patchname) '.log 2>&1']; % redirect standard output to the log file |
---|
| 5354 | else |
---|
| 5355 | cmd=['"' Param.xml.PatchBin... |
---|
| 5356 | '" -f "' filename '.nc" -m ' num2str(Param.(patchname).Nx)... |
---|
[292] | 5357 | ' -n ' num2str(Param.(patchname).Ny) ' -ro ' num2str(Param.(patchname).SmoothingParam)... |
---|
[286] | 5358 | ' -nopt ' num2str(Param.(patchname).SubdomainSize)... |
---|
| 5359 | ' > "' filename '.' lower(patchname) '.log" 2>&1']; % redirect standard output to the log file |
---|
| 5360 | cmd=regexprep(cmd,'\\','\\\\'); |
---|
| 5361 | end |
---|
| 5362 | % else %nouveau programme patch |
---|
| 5363 | % cmd=[PatchBin ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ... |
---|
| 5364 | % ' -max ' thresh_value ' -nopt ' subdomain_patch ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
| 5365 | % end |
---|
[290] | 5366 | |
---|
| 5367 | |
---|
| 5368 | %------------------------------------------------------------------------ |
---|
| 5369 | % --- CheckCiv2 CheckCiv2 CheckCiv2 CheckCiv2 |
---|
| 5370 | function cmd=cmd_civ2(filename,Param) |
---|
| 5371 | %------------------------------------------------------------------------ |
---|
| 5372 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
| 5373 | % global civ2Bin sge%name of the executable for checkciv1 calculation |
---|
| 5374 | filename=regexprep(filename,'.nc',''); |
---|
| 5375 | if isequal(Param.Civ2.Dt,'0') |
---|
| 5376 | Param.Civ2.Dt='1' ;%case of 'displacement' mode |
---|
| 5377 | end |
---|
| 5378 | Param.Civ2.filename_ima_a=regexprep(Param.Civ2.filename_ima_a,'.png',''); |
---|
| 5379 | Param.Civ2.filename_ima_b=regexprep(Param.Civ2.filename_ima_b,'.png','');% bug : .png appears two times ? |
---|
| 5380 | [fid,errormsg]=fopen([filename '.civ2.cmx'],'w'); |
---|
| 5381 | if isequal(fid,-1) |
---|
| 5382 | msgbox_uvmat('ERROR',errormsg) |
---|
| 5383 | cmd=''; |
---|
| 5384 | return |
---|
| 5385 | end |
---|
| 5386 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
| 5387 | fprintf(fid, ['FirstImage ' regexprep(Param.Civ2.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 5388 | fprintf(fid, ['LastImage ' regexprep(Param.Civ2.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 5389 | fprintf(fid, ['XX' '\n' ]); |
---|
| 5390 | fprintf(fid, ['Mask ' Param.Civ2.MaskFlag '\n' ]); |
---|
| 5391 | fprintf(fid, ['MaskName ' regexprep(Param.Civ2.MaskName,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
| 5392 | fprintf(fid, ['ImageSize ' num2str(Param.Civ2.npx) ' ' num2str(Param.Civ2.npy) '\n' ]); %VERIFIER CAS GENERAL ? |
---|
| 5393 | fprintf(fid, ['CorrelationBoxesSize ' num2str(Param.Civ2.Bx) ' ' num2str(Param.Civ2.By) '\n' ]); |
---|
| 5394 | fprintf(fid, ['SearchBoxeSize ' num2str(Param.Civ2.Bx) ' ' num2str(Param.Civ2.By) '\n']); |
---|
| 5395 | fprintf(fid, ['RO ' num2str(Param.Civ2.Rho) '\n']); |
---|
| 5396 | fprintf(fid, ['GridSpacing ' num2str(Param.Civ2.Dx) ' ' num2str(Param.Civ2.Dy) '\n']); |
---|
| 5397 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 5398 | fprintf(fid, ['Dt_TO ' num2str(Param.Civ2.Dt) ' ' num2str(Param.Civ2.T0) '\n' ]); |
---|
| 5399 | fprintf(fid, ['PixCmXY ' num2str(Param.Civ2.pxcmx) ' ' num2str(Param.Civ2.pxcmy) '\n' ]); |
---|
| 5400 | fprintf(fid, ['XX 1' '\n' ]); |
---|
| 5401 | fprintf(fid, 'ShiftXY 0 0\n'); |
---|
| 5402 | fprintf(fid, ['Grid ' Param.Civ2.GridFlag '\n' ]); |
---|
| 5403 | fprintf(fid, ['GridName ' regexprep(Param.Civ2.GridName,'\\','\\\\') '\n']); |
---|
| 5404 | fprintf(fid, ['XX 85' '\n' ]); |
---|
| 5405 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 5406 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
| 5407 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
| 5408 | fprintf(fid, ['DecimalShift ' num2str(Param.Civ2.CheckDecimal) '\n']); |
---|
| 5409 | fprintf(fid, ['Deformation ' num2str(Param.Civ2.CheckDeformation) '\n']); |
---|
| 5410 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
| 5411 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
| 5412 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
| 5413 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
| 5414 | fprintf(fid, ['ImageToUse ' Param.Civ2.term_a ' ' Param.Civ2.term_b '\n' ]); % VERIFIER ? |
---|
| 5415 | fprintf(fid, ['ImageUsedBefore ' regexprep(Param.Civ2.filename_nc1,'\\','\\\\') '\n']); |
---|
| 5416 | fclose(fid); |
---|
| 5417 | |
---|
| 5418 | if(isunix) |
---|
| 5419 | cmd=['cp -f ' filename '.civ2.cmx ' filename '.cmx\n'... |
---|
| 5420 | Param.xml.Civ2Bin ' -f ' filename '.cmx >' filename '.civ2.log \n '... % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx |
---|
| 5421 | 'rm ' filename '.cmx \n'];%rename .cmx as .checkciv2.cmx, the result file is named [filename '.nc'] by CIVx |
---|
| 5422 | else |
---|
| 5423 | filename=regexprep(filename,'\\','\\\\'); |
---|
| 5424 | cmd=['copy /Y "' filename '.civ2.cmx" "' filename '.cmx" \n'... |
---|
| 5425 | '"' regexprep(Param.xml.Civ2Bin,'\\','\\\\') '" -f "' filename '.cmx" >"' filename '.civ2.log" \n'... |
---|
| 5426 | 'del "' filename '.cmx" \n']; |
---|
| 5427 | end |
---|