├── LICENSE ├── Matlab ├── CIL_small_logo.mat ├── docs │ └── openpiv-podbox-getting-started.pdf ├── getvecfiles.fig ├── getvecfiles.m ├── pod.m ├── pod_pete.m ├── podbox.fig ├── podbox.m ├── poduv.m ├── podvort.m ├── uipickfiles.m ├── uipickfiles_folder_icon.png └── vecread.m ├── Python └── notebooks │ └── poduv.ipynb ├── README.md ├── runPOD_Matlab.bat └── test ├── 06302014_2Hz_particles000200.T000.D000.P000.H000.L.vec ├── 06302014_2Hz_particles000201.T000.D000.P000.H000.L.vec ├── 06302014_2Hz_particles000202.T000.D000.P000.H000.L.vec ├── 06302014_2Hz_particles000203.T000.D000.P000.H000.L.vec ├── 06302014_2Hz_particles000204.T000.D000.P000.H000.L.vec ├── 06302014_2Hz_particles000205.T000.D000.P000.H000.L.vec ├── 06302014_2Hz_particles000206.T000.D000.P000.H000.L.vec ├── 06302014_2Hz_particles000207.T000.D000.P000.H000.L.vec ├── 06302014_2Hz_particles000208.T000.D000.P000.H000.L.vec ├── 06302014_2Hz_particles000209.T000.D000.P000.H000.L.vec └── 06302014_2Hz_particles000210.T000.D000.P000.H000.L.vec /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 OpenPIV 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /Matlab/CIL_small_logo.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenPIV/openpiv-podbox/e3a745416924239416bdd0e081f4cb86e3e70eef/Matlab/CIL_small_logo.mat -------------------------------------------------------------------------------- /Matlab/docs/openpiv-podbox-getting-started.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenPIV/openpiv-podbox/e3a745416924239416bdd0e081f4cb86e3e70eef/Matlab/docs/openpiv-podbox-getting-started.pdf -------------------------------------------------------------------------------- /Matlab/getvecfiles.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenPIV/openpiv-podbox/e3a745416924239416bdd0e081f4cb86e3e70eef/Matlab/getvecfiles.fig -------------------------------------------------------------------------------- /Matlab/getvecfiles.m: -------------------------------------------------------------------------------- 1 | function varargout = getVECfiles(varargin) 2 | 3 | gui_Singleton = 1; 4 | gui_State = struct('gui_Name', mfilename, ... 5 | 'gui_Singleton', gui_Singleton, ... 6 | 'gui_OpeningFcn', @getVECfiles_OpeningFcn, ... 7 | 'gui_OutputFcn', @getVECfiles_OutputFcn, ... 8 | 'gui_LayoutFcn', [] , ... 9 | 'gui_Callback', []); 10 | if nargin & isstr(varargin{1}) 11 | % str2func(varargin{1}) 12 | gui_State.gui_Callback = str2func(varargin{1}); 13 | end 14 | 15 | if nargout 16 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); 17 | else 18 | gui_mainfcn(gui_State, varargin{:}); 19 | end 20 | 21 | 22 | % --- Executes just before getVECfiles is made visible. 23 | function getVECfiles_OpeningFcn(hObject, eventdata, handles, varargin) 24 | % This function has no output args, see OutputFcn. 25 | % hObject handle to figure 26 | % eventdata reserved - to be defined in a future version of MATLAB 27 | % handles structure with handles and user data (see GUIDATA) 28 | % varargin command line arguments to getVECfiles (see VARARGIN) 29 | 30 | % Choose default command line output for getVECfiles 31 | handles = guihandles; 32 | handles.output = hObject; 33 | handles.path = cd; 34 | handles.state3d = 0; 35 | 36 | % Update handles structure 37 | guidata(hObject, handles); 38 | update_gui(hObject,[],handles); 39 | % % 40 | % % % UIWAIT makes getVECfiles wait for user response (see %uiresume) 41 | uiwait(handles.fig); 42 | 43 | 44 | % --- Outputs from this function are returned to the command line. 45 | function varargout = getVECfiles_OutputFcn(hObject, eventdata, handles) 46 | % varargout cell array for returning output args (see VARARGOUT); 47 | % hObject handle to figure 48 | % eventdata reserved - to be defined in a future version of MATLAB 49 | % handles structure with handles and user data (see GUIDATA) 50 | 51 | % Get default command line output from handles structure 52 | % if nargout 53 | if isfield(handles,'filenames') 54 | varargout{1} = handles.filenames; 55 | varargout{2} = handles.path; 56 | % varargout{3} = handles.dT*handles.step; 57 | % varargout{4} = handles.scale; 58 | % varargout{5} = handles.state3d; 59 | 60 | else 61 | varargout{1} = {}; 62 | varargout{2} = {}; 63 | % varargout{3} = NaN; 64 | % varargout{4} = NaN; 65 | % varargout{5} = NaN; 66 | end 67 | close(handles.fig); 68 | 69 | 70 | % --- Executes on button press in pushbutton_load. 71 | function pushbutton_load_Callback(hObject, eventdata, handles) 72 | % hObject handle to pushbutton_load (see GCBO) 73 | % eventdata reserved - to be defined in a future version of MATLAB 74 | % handles structure with handles and user data (see GUIDATA) 75 | 76 | % Returns the names of the selected files 77 | handles.list_entries = get(handles.listbox_files,'String'); 78 | handles.index_selected = get(handles.listbox_files,'Value'); 79 | if isempty(handles.index_selected) | min(handles.index_selected) < 3 80 | errordlg('Wrong selection','Incorrect Selection','modal') 81 | else 82 | 83 | % if ~isfield(handles,'step') 84 | % handles.step = str2double(get(handles.edit_step,'String')); 85 | % handles.dT = str2double(get(handles.edit_dT,'String')); 86 | % handles.scale = str2double(get(handles.edit_scale,'String')); 87 | % end 88 | 89 | switch length(handles.index_selected) 90 | case {1} % only the first file is selected, 91 | % pick all files from it up to last 92 | % How many files are selected 93 | % index = handles.index_selected:handles.step:length(handles.list_entries); 94 | % June 26, 2004, bug fix of the first release. 95 | index = handles.index_selected; 96 | % [handles.filenames{1:length(index),1}] = deal(handles.list_entries(index)); 97 | handles.filenames = handles.list_entries(index); 98 | case {2} 99 | % two files are selected, first and last 100 | % June 26, 2004, bug fix of the first release. 101 | % index = min(handles.index_selected):handles.step:max(handles.index_selected); 102 | index = handles.index_selected; % 103 | 104 | % [handles.filenames{1:length(index),1}] = deal(handles.list_entries(index)); 105 | handles.filenames = handles.list_entries(index); 106 | 107 | otherwise 108 | % many files are selected, no step is involved, just read 109 | % all of them 110 | % [handles.filenames{1:length(handles.index_selected),1}] = deal(handles.list_entries(handles.index_selected)); 111 | handles.filenames = handles.list_entries(handles.index_selected); 112 | 113 | end 114 | guidata(hObject,handles); 115 | uiresume(handles.fig); 116 | end 117 | 118 | 119 | 120 | 121 | % --- Executes on button press in pushbutton_cancel. 122 | function pushbutton_cancel_Callback(hObject, eventdata, handles) 123 | % hObject handle to pushbutton_cancel (see GCBO) 124 | % eventdata reserved - to be defined in a future version of MATLAB 125 | % handles structure with handles and user data (see GUIDATA) 126 | uiresume(handles.fig); 127 | 128 | 129 | % --- Executes during object creation, after setting all properties. 130 | function listbox_files_CreateFcn(hObject, eventdata, handles) 131 | 132 | 133 | % --- Executes on selection change in listbox_files. 134 | function listbox_files_Callback(hObject, eventdata, handles) 135 | 136 | if strcmp(get(handles.fig,'SelectionType'),'open') % If double click 137 | index_selected = get(handles.listbox_files,'Value'); 138 | file_list = get(handles.listbox_files,'String'); 139 | filename = file_list{index_selected}; % Item selected in list box 140 | % keyboard 141 | if isdir([handles.path,filesep,filename]) % If directory 142 | if index_selected == 2 143 | handles.path = handles.path(1:max(findstr(handles.path,filesep)-1)); 144 | elseif index_selected > 2 145 | handles.path = [handles.path,filesep,filename]; 146 | end 147 | guidata(handles.fig,handles); 148 | update_gui(handles.fig,[],handles); 149 | end 150 | end 151 | 152 | 153 | 154 | 155 | % --- Executes during object creation, after setting all properties. 156 | function edit_path_CreateFcn(hObject, eventdata, handles) 157 | % hObject handle to edit_path (see GCBO) 158 | % eventdata reserved - to be defined in a future version of MATLAB 159 | % handles empty - handles not created until after all CreateFcns called 160 | 161 | % Hint: edit controls usually have a white background on Windows. 162 | % See ISPC and COMPUTER. 163 | if ispc 164 | set(hObject,'BackgroundColor','white'); 165 | else 166 | set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); 167 | end 168 | handles = guihandles; 169 | if ~isfield(handles,'path') 170 | handles.path = cd; 171 | end 172 | set(hObject,'String',handles.path); 173 | guidata(hObject,handles); 174 | 175 | 176 | 177 | function edit_path_Callback(hObject, eventdata, handles) 178 | % hObject handle to edit_path (see GCBO) 179 | % eventdata reserved - to be defined in a future version of MATLAB 180 | % handles structure with handles and user data (see GUIDATA) 181 | 182 | % Hints: get(hObject,'String') returns contents of edit_path as text 183 | % str2double(get(hObject,'String')) returns contents of edit_path as a double 184 | 185 | tmp = get(hObject,'String'); 186 | if isdir(tmp) 187 | handles.path = tmp; 188 | else 189 | set(hObject,'String',handles.path); 190 | end 191 | guidata(hObject,handles); 192 | update_gui(hObject, [], handles); 193 | 194 | % --- Executes on button press in pushbutton_cd. 195 | function pushbutton_cd_Callback(hObject, eventdata, handles) 196 | % hObject handle to pushbutton_cd (see GCBO) 197 | % eventdata reserved - to be defined in a future version of MATLAB 198 | % handles structure with handles and user data (see GUIDATA) 199 | tmp = uigetdir(handles.path); 200 | if tmp > 0 & isdir(tmp), handles.path = tmp; end 201 | set(handles.edit_path,'String',handles.path); 202 | guidata(hObject, handles); 203 | update_gui(hObject, [], handles); 204 | 205 | 206 | % function edit_step_Callback(hObject, eventdata, handles) 207 | % % hObject handle to edit_step (see GCBO) 208 | % % eventdata reserved - to be defined in a future version of MATLAB 209 | % % handles structure with handles and user data (see GUIDATA) 210 | % 211 | % % Hints: get(hObject,'String') returns contents of edit_step as text 212 | % % str2double(get(hObject,'String')) returns contents of edit_step as a double 213 | % tmp = str2double(get(hObject,'String')); 214 | % if isnan(tmp) | floor(tmp) ~= tmp 215 | % set(hObject,'String','1'); 216 | % else 217 | % handles.step = tmp; 218 | % end 219 | % guidata(hObject,handles); 220 | 221 | % function edit_dT_Callback(hObject, eventdata, handles) 222 | % % hObject handle to edit_dT (see GCBO) 223 | % % eventdata reserved - to be defined in a future version of MATLAB 224 | % % handles structure with handles and user data (see GUIDATA) 225 | % 226 | % % Hints: get(hObject,'String') returns contents of edit_dT as text 227 | % % str2double(get(hObject,'String')) returns contents of edit_dT as a double 228 | % if isnan(str2double(get(hObject,'String'))) 229 | % set(hObject,'String','1'); 230 | % end 231 | % handles.dT = str2double(get(hObject,'String')); 232 | % guidata(hObject,handles); 233 | 234 | 235 | function edit_scale_Callback(hObject, eventdata, handles) 236 | % hObject handle to edit_scale (see GCBO) eventdata reserved - to be 237 | % defined in a future version of MATLAB handles structure with handles 238 | % and user data (see GUIDATA) 239 | 240 | % Hints: get(hObject,'String') returns contents of edit_scale as text 241 | % str2double(get(hObject,'String')) returns contents of edit_scale 242 | % as a double 243 | if isnan(str2double(get(hObject,'String'))) 244 | set(hObject,'String','1'); 245 | end 246 | handles.scale = str2double(get(hObject,'String')); 247 | guidata(hObject,handles); 248 | 249 | 250 | % --- Executes during object creation, after setting all properties. 251 | function fig_CreateFcn(hObject, eventdata, handles) 252 | % hObject handle to fig (see GCBO) 253 | % eventdata reserved - to be defined in a future version of MATLAB 254 | % handles empty - handles not created until after all CreateFcns called 255 | 256 | handles = guihandles(hObject); 257 | movegui(hObject,'northwest') 258 | 259 | 260 | % --- Executes on button press in pushbutton_updir. 261 | function pushbutton_updir_Callback(hObject, eventdata, handles) 262 | % hObject handle to pushbutton_updir (see GCBO) 263 | % eventdata reserved - to be defined in a future version of MATLAB 264 | % handles structure with handles and user data (see GUIDATA) 265 | 266 | s = handles.path; 267 | s = s(1:max(3,max(findstr(s,filesep))-1)); 268 | if exist(s,'dir') 269 | handles.path = s; 270 | end 271 | guidata(hObject,handles); 272 | update_gui(hObject,[],handles); 273 | 274 | function update_gui(hObject, eventdata, handles) 275 | % Self made UPDATE GUI function 276 | % %keyboard 277 | if isdir(handles.path) 278 | set(handles.edit_path,'String',handles.path); 279 | % if get(handles.check3d,'Value') == 1 280 | % handles.files = dir(fullfile(handles.path,'*.v3d')); % tmp2 281 | % else 282 | handles.files = dir(fullfile(handles.path,'*.vec')); 283 | % end; 284 | else 285 | handles.path = cd; 286 | set(handles.edit_path,'String',handles.path); 287 | % if get(handles.check3d,'Value') == 1 288 | % handles.files = dir(fullfile(handles.path,'*.v3d')); % tmp2 289 | % else 290 | handles.files = dir(fullfile(handles.path,'*.vec')); 291 | % end; 292 | end 293 | list = dir(handles.path); 294 | ind = find(cat(1,list.isdir)); 295 | set(handles.fig,'SelectionType','normal'); 296 | set(handles.listbox_files,'String',{list(ind).name,handles.files.name},'Value',1); 297 | guidata(handles.fig, handles); 298 | 299 | 300 | 301 | % % --- Executes during object creation, after setting all properties. 302 | % function edit_step_CreateFcn(hObject, eventdata, handles) 303 | % % hObject handle to edit_step (see GCBO) 304 | % % eventdata reserved - to be defined in a future version of MATLAB 305 | % % handles empty - handles not created until after all CreateFcns called 306 | % 307 | % % Hint: edit controls usually have a white background on Windows. 308 | % % See ISPC and COMPUTER. 309 | % if ispc 310 | % set(hObject,'BackgroundColor','white'); 311 | % else 312 | % set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); 313 | % end 314 | % tmp = str2double(get(hObject,'String')); 315 | % if isnan(tmp) | floor(tmp) ~= tmp 316 | % set(hObject,'String','1'); 317 | % else 318 | % handles.step = tmp; 319 | % end 320 | % guidata(hObject,handles); 321 | 322 | 323 | % % --- Executes during object creation, after setting all properties. 324 | % function edit_dT_CreateFcn(hObject, eventdata, handles) 325 | % % hObject handle to edit_dT (see GCBO) 326 | % % eventdata reserved - to be defined in a future version of MATLAB 327 | % % handles empty - handles not created until after all CreateFcns called 328 | % 329 | % % Hint: edit controls usually have a white background on Windows. 330 | % % See ISPC and COMPUTER. 331 | % if ispc 332 | % set(hObject,'BackgroundColor','white'); 333 | % else 334 | % set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); 335 | % end 336 | % if isnan(str2double(get(hObject,'String'))) 337 | % set(hObject,'String','1'); 338 | % end 339 | % handles.dT = str2double(get(hObject,'String')); 340 | % guidata(hObject,handles); 341 | 342 | 343 | % % --- Executes during object creation, after setting all properties. 344 | % function edit_scale_CreateFcn(hObject, eventdata, handles) 345 | % % hObject handle to edit_scale (see GCBO) 346 | % % eventdata reserved - to be defined in a future version of MATLAB 347 | % % handles empty - handles not created until after all CreateFcns called 348 | % 349 | % % Hint: edit controls usually have a white background on Windows. 350 | % % See ISPC and COMPUTER. 351 | % if ispc 352 | % set(hObject,'BackgroundColor','white'); 353 | % else 354 | % set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); 355 | % end 356 | % 357 | % 358 | % if isnan(str2double(get(hObject,'String'))) 359 | % set(hObject,'String','1'); 360 | % end 361 | % handles.scale = str2double(get(hObject,'String')); 362 | % guidata(hObject,handles); 363 | 364 | 365 | % % --- Executes on button press in check3d. 366 | % function check3d_Callback(hObject, eventdata, handles) 367 | % % hObject handle to check3d (see GCBO) 368 | % % eventdata reserved - to be defined in a future version of MATLAB 369 | % % handles structure with handles and user data (see GUIDATA) 370 | % 371 | % % Hint: get(hObject,'Value') returns toggle state of check3d 372 | % if get(hObject,'Value') == 1 373 | % handles.state3d = 1; 374 | % else 375 | % handles.state3d = 0; 376 | % end 377 | % guidata(hObject,handles); 378 | % update_gui(hObject, [], handles); 379 | 380 | -------------------------------------------------------------------------------- /Matlab/pod.m: -------------------------------------------------------------------------------- 1 | function [L,modes,varargout] = pod(data,options) 2 | % POD(DATA,OPTIONS) 3 | % DATA = a 4D matrix of rows x cols x N x nComponents (N = number of 4 | % snapshots), nComponents = number of the vector dimensions (1 = scalar); 5 | % 6 | % OPTIONS - structure which contains the following (optional) fields: 7 | % options.mean_method = 'mean' or 'none' ('m' or 'n') 8 | % options.method = 'direct' or 'snapshots' ('d' or 's') 9 | % options.numofmodes = 'all' or integer smaller than size(data,3) 10 | % options.output = 'modes','reconstruct','multimode' 11 | % 12 | % if options.output = 'reconstruct' or 'multimode' 13 | % then: options.numofsnapshot = number in the interval [1,N] 14 | % and: options.selectedmodes = list of modes to use, e.g. [1,3,5] or 15 | % 'all' 16 | % 17 | % 18 | % Example: 19 | % options = struct(); 20 | % options.mean_method = 'mean'; 21 | % options.method = 'snapshot'; 22 | % options.numofmodes = 10; 23 | % options.output = 'reconstruct'; 24 | % options.numofsnapshot = 8; 25 | % options.selectedmodes = [1,2,3]; 26 | % load tmp.mat 27 | % [l,modes,rec8] = podscalar(flipdim(u,1),options); 28 | % figure, plot(cumsum(l)./sum(l)*100); ylabel('Cummulative energy, per-cent'); 29 | % figure, imagesc(modes(:,:,1)); title('Mode 1'); 30 | % figure, imagesc([rec8,flipud(u(:,:,8))]); axis equal 31 | 32 | [r,c,N,k] = size(data); %4D data 33 | len = r*c; 34 | Uf = zeros(len*k,N); % r*c*3 length of the vector 35 | 36 | for j = 1:k 37 | for i = 1:N 38 | Uf((j-1)*len+1:j*len,i) = reshape(data(:,:,i,j),len,1); 39 | end 40 | end 41 | 42 | 43 | switch options.mean_method 44 | case{'mean','m'} 45 | meanU = mean(Uf,2); 46 | for i = 1:N 47 | Uf(:,i) = Uf(:,i) - meanU; 48 | end 49 | end 50 | 51 | 52 | switch options.method % additional switch, to distinguish between 53 | % direct and snapshots methods, Alex, 08.07.05 54 | case {'s','snapshot'} 55 | R = Uf'*Uf; 56 | case {'d','direct'} 57 | % Covariance matrix: 58 | R = Uf*Uf'; 59 | end 60 | 61 | [V,D] = eig(R); 62 | clear R 63 | [L,I] = sort(diag(D)/N); 64 | 65 | nL = length(L); 66 | L = L(nL:-1:1); 67 | I = I(nL:-1:1); 68 | 69 | 70 | if ischar(options.numofmodes) && strcmp(options.numofmodes,'all') 71 | m = N; 72 | else 73 | m = options.numofmodes; 74 | end 75 | 76 | 77 | switch options.method 78 | case {'s', 'snapshot'} 79 | % Diagonal matrix containing the square roots of the eigenvalues: 80 | S = sqrt(diag(D)); 81 | S = S(I); 82 | V = V(:,I); 83 | a = diag(S(1:m))*(V(:,1:m)'); 84 | phi = Uf*V(:,1:m)*diag(1./S(1:m)); 85 | 86 | case {'d','direct'} 87 | phi = V(:,I); 88 | S = sqrt(diag(D)); 89 | a = (Uf'*phi(:,1:m)).'; 90 | phi = phi(:,1:m); 91 | end 92 | modes = zeros(r,c,m,k); 93 | for j = 1:k 94 | for i=1:m 95 | modes(:,:,i,j) = reshape(phi((j-1)*len+1:j*len,i),[r c] ); 96 | end 97 | end 98 | 99 | switch options.output 100 | case{'reconstruct'} 101 | n = options.numofsnapshot; 102 | t = options.selectedmodes; 103 | if ischar(options.selectedmodes) && strcmp(options.selectedmodes,'all') 104 | t = 1:size(phi,2); 105 | else 106 | t = options.selectedmodes; 107 | end 108 | Q = phi(:,t)*a(t,n) + meanU; 109 | 110 | for j = 1:k 111 | varargout{j} = reshape(Q((j-1)*len+1:len*j),r,c); % u-components of reconstructed velocity field 112 | end 113 | 114 | case{'multimode'} % multi-mode, weighted reconstruction 115 | 116 | n = options.numofsnapshot; 117 | 118 | for j = 1:k 119 | uRec = modes(:,:,options.selectedmodes(1),j) * L(options.selectedmodes(1)); 120 | for i = 1:length(options.selectedmodes) 121 | uRec = uRec + modes(:,:,options.selectedmodes(i),j) * L(options.selectedmodes(i)); 122 | end 123 | varargout{j} = uRec; 124 | end 125 | end 126 | 127 | 128 | -------------------------------------------------------------------------------- /Matlab/pod_pete.m: -------------------------------------------------------------------------------- 1 | function [varargout] = pod_pete(handles, step) 2 | 3 | persistent r c N len U meanU Uf V D L I a phi 4 | 5 | % dbstop if caught error MATLAB:nonExistentField 6 | 7 | 8 | %load data.mat 9 | 10 | switch step 11 | %% Vorticity (or other scalar function) modes construction 12 | case{1} % first time we call the function 13 | 14 | [r,c,N] = size(handles.vort); % 4-D is the number of files 15 | 16 | len = r*c; 17 | 18 | Uf = zeros(len,N); % r*c*3 length of the vector 19 | 20 | % small rearrangement 21 | for i = 1:N 22 | Uf(1:len,i) = reshape(handles.vort(:,:,i),len,1); 23 | % U(len+1:2*len,i) = reshape(handles.v(:,:,i),len,1); 24 | end 25 | 26 | % Ensemble average of U: 27 | meanU = mean(Uf,2); 28 | % meanU = zeros(len,1); 29 | % Fluctuations 30 | % % Uf = U - repmat(meanU,1,N); 31 | for i = 1:N 32 | Uf(:,i) = Uf(:,i) - meanU; 33 | end 34 | 35 | 36 | % keyboard 37 | switch handles.METHOD_FLAG % additional switch, to distinguish between 38 | % direct and snapshots methods, Alex, 08.07.05 39 | case {0,'snapshot'} 40 | R = Uf'*Uf; 41 | case {1,'direct'} 42 | % Covariance matrix: 43 | R = Uf*Uf'; 44 | end 45 | % Eigenvalue problem: 46 | % [~,D,V] = svds(R,min(len*2,N)); 47 | [V,D] = eig(R); 48 | clear R 49 | [L,I] = sort(diag(D)/N); 50 | 51 | nL = length(L); 52 | L = L(nL:-1:1); 53 | I = I(nL:-1:1); 54 | 55 | varargout{1} = L; 56 | %% 57 | 58 | 59 | %% 60 | case{2} 61 | % second call, the number of modes is known or the amount of energy 62 | % and POD prepares modes 63 | m = handles.numOfModes; 64 | switch handles.METHOD_FLAG 65 | case {0, 'snapshot'} 66 | % Diagonal matrix containing the square roots of the eigenvalues: 67 | 68 | S = sqrt(diag(D)); 69 | % [S, I] = sort(S); 70 | % S = flipud(S); 71 | % I = flipud(I); 72 | S = S(I); 73 | V = V(:,I); 74 | 75 | 76 | 77 | a = diag(S(1:m))*(V(:,1:m)'); 78 | 79 | 80 | % Calculation of POD modes: 81 | 82 | % for i=1:m 83 | % y = Uf*V(:,i); 84 | % phi(:,i) = y/norm(y); 85 | % end; 86 | 87 | % phi = Uf*V(:,1:m); 88 | % phi = phi./repmat(sum(abs(phi).^2).^(1/2),len*2,1); 89 | 90 | phi = Uf*V(:,1:m)*diag(1./S(1:m)); 91 | 92 | case {1,'direct'} 93 | phi = V(:,I); 94 | S = sqrt(diag(D)); 95 | % S = S(I); 96 | % a = diag(S(1:m))*(phi(:,1:m)'); 97 | % a = diag(L(1:m))*(V(:,1:m)'); 98 | a = (Uf'*phi(:,1:m)).'; 99 | phi = phi(:,1:m); 100 | % disp('direct') 101 | % whos 102 | end 103 | 104 | % [umodes,vmodes,wmodes,vel] = deal(zeros(r,c,m)); 105 | if length(phi) == len 106 | % [umodes,vmodes] = deal(zeros(r,c,m)); 107 | [vortmodes] = deal(zeros(r,c,m)); 108 | for i=1:m 109 | vortmodes(:,:,i) = reshape(phi(1:len,i),[r c] ); 110 | % vmodes(:,:,i) = reshape(phi(len+1:2*len,i),[r c]); 111 | end 112 | 113 | % vel = (umodes.^2 + vmodes.^2).^(0.5); % .+wmodes.^2); % Velocity vector magnitude 114 | 115 | % misterious -1 116 | varargout{1} = vortmodes; 117 | % varargout{2} = vmodes; 118 | else length(phi) == 2*len 119 | [umodes,vmodes] = deal(zeros(r,c,m)); 120 | for i=1:m 121 | umodes(:,:,i) = reshape(phi(1:len,i),[r c] ); 122 | vmodes(:,:,i) = reshape(phi(len+1:2*len,i),[r c]); 123 | end 124 | 125 | % vel = (umodes.^2 + vmodes.^2).^(0.5); % .+wmodes.^2); % Velocity vector magnitude 126 | 127 | % misterious -1 128 | varargout{1} = umodes; 129 | varargout{2} = vmodes; 130 | % varargout{1} = -1*umodes; 131 | % varargout{2} = -1*vmodes; 132 | end 133 | 134 | %% 135 | %% CASE 3 - reconstruction of instantaneous maps 136 | 137 | case{3} 138 | 139 | n = handles.current; 140 | if isfield(handles,'SelectedModes') & ~isempty(handles.SelectedModes) 141 | t = handles.SelectedModes; 142 | else 143 | t = 1:size(phi,2); 144 | end 145 | try 146 | Q = phi(:,t)*a(t,n) + meanU; 147 | catch 148 | Q = phi(:,t)*a(t,n); 149 | end 150 | varargout{1} = reshape(Q(1:r*c),r,c); % u-components of reconstructed velocity field 151 | varargout{2} = reshape(Q(r*c+1:2*r*c),r,c); % v-components of reconstructed velocity field 152 | 153 | case{4} % multi-mode, weighted reconstruction 154 | 155 | n = handles.current; 156 | 157 | uRec = handles.umodes(:,:,handles.multimode(1)) * L(handles.multimode(1)); 158 | % vRec = handles.vmodes(:,:,handles.multimode(1)) * L(handles.multimode(1)); 159 | % uRec = handles.umodes(:,:,handles.multimode(1)) * L(handles.multimode(1)); 160 | % vRec = handles.vmodes(:,:,handles.multimode(1)) * L(handles.multimode(1)); 161 | 162 | for i = 1:length(handles.multimode) % (1) + 1 : handles.multimode(end) 163 | uRec = uRec + handles.umodes(:,:,handles.multimode(i)) * L(handles.multimode(i)); 164 | % vRec = vRec + handles.vmodes(:,:,handles.multimode(i)) * L(handles.multimode(i)); 165 | end 166 | 167 | varargout{1} = uRec; 168 | % varargout{2} = vRec; 169 | % % r c N len U meanU Uf V L I a phi 170 | % varargout{1} = U; 171 | % varargout{2} = meanU; 172 | % varargout{3} = Uf; 173 | % varargout{4} = V; 174 | % varargout{5} = L; 175 | % varargout{6} = I; 176 | % varargout{7} = a; 177 | % varargout{8} = phi; 178 | % 179 | % clear r c N len U meanU Uf V L I a phi 180 | 181 | case{6} % first time we call the function, but different from case 1 it is 182 | % without subtracting the mean of the velocity fields. 183 | 184 | [r,c,N] = size(handles.u); % 4-D is the number of files 185 | 186 | len = r*c; 187 | 188 | Uf = zeros(len*2,N); % r*c*3 length of the vector 189 | 190 | % small rearrangement 191 | for i = 1:N 192 | Uf(1:len,i) = reshape(handles.u(:,:,i),len,1); 193 | Uf(len+1:2*len,i) = reshape(handles.v(:,:,i),len,1); 194 | end 195 | 196 | % Ensemble average of U: 197 | % meanU = mean(U,2); 198 | % meanU = zeros(2*len,1); 199 | %% NOTE - I manually removed the mean 200 | warning('Mean is assumed zero, fix it manually if it is not true') 201 | % Fluctuations 202 | % Uf = U - repmat(meanU,1,N); 203 | % for i = 1:N 204 | % Uf(:,i) = U(:,i) - meanU; 205 | % end 206 | 207 | % Covariance matrix: 208 | R = Uf'*Uf; 209 | 210 | % Eigenvalue problem: 211 | [V,D] = eig(R); 212 | 213 | clear R 214 | 215 | 216 | [L,I]=sort(diag(D)); 217 | nL = length(L); 218 | L = L(nL:-1:1); 219 | I = I(nL:-1:1); 220 | 221 | varargout{1} = L; 222 | varargout{2} = a; 223 | 224 | end % of switch -------------------------------------------------------------------------------- /Matlab/podbox.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenPIV/openpiv-podbox/e3a745416924239416bdd0e081f4cb86e3e70eef/Matlab/podbox.fig -------------------------------------------------------------------------------- /Matlab/podbox.m: -------------------------------------------------------------------------------- 1 | function varargout = podbox(varargin) 2 | warning off 3 | 4 | global orighandles current_path; 5 | 6 | if nargin == 0 7 | current_path = cd; 8 | addpath(current_path); 9 | 10 | fig = openfig(mfilename,'reuse','invisible'); 11 | movegui(fig,'center') 12 | set(fig,'DockControls','off'); 13 | 14 | handles = guihandles(fig); 15 | 16 | handles.inst_list = '-|u|v|(u^2+v^2)^(1/2)|vorticity|sxx=du/dx|du/dy|dv/dx|syy=dv/dy|du/dx+dv/dy|sxy'; 17 | 18 | handles.fig = fig; 19 | handles.previous_quantity = '-'; 20 | handles.multimode = 1; 21 | handles.SelectedModes = 1; 22 | if ~isfield(handles,'axes_main') 23 | handles.axes_main = get(handles.fig,'CurrentAxes'); 24 | end 25 | orighandles = handles; 26 | guidata(handles.fig, handles); 27 | 28 | 29 | set(fig,'Color',get(0,'defaultUicontrolBackgroundColor')); 30 | 31 | guidata(handles.fig, handles); 32 | 33 | if nargout > 0 34 | varargout{1} = fig; 35 | end 36 | set(findobj(handles.fig,'type','uicontrol'),'Enable','Off'); 37 | 38 | Pos_spat=get(handles.spatial_controls,'Position'); 39 | set(handles.spatial_controls,'Position',... 40 | [0.95-Pos_spat(3) 0.96-Pos_spat(4) Pos_spat(3) Pos_spat(4)]); 41 | 42 | Pos_ctrl=get(handles.select_controls,'Position'); 43 | set(handles.select_controls,'Position',... 44 | [0.95-Pos_spat(3) 0.96-Pos_ctrl(4) Pos_spat(3) Pos_ctrl(4)]); 45 | 46 | Pos_energy=get(handles.uipanel_relEnergy,'Position'); 47 | set(handles.uipanel_relEnergy,'Position',... 48 | [0.95-Pos_spat(3) 0.93-Pos_ctrl(4)-Pos_energy(3) Pos_spat(3) Pos_energy(4)]); 49 | 50 | Pos_plot=get(handles.uipanel_plotoptions,'Position'); 51 | set(handles.uipanel_plotoptions,'Position',... 52 | [0.95-Pos_spat(3) 0.93-Pos_ctrl(4)-Pos_energy(4)-0.14 Pos_spat(3) Pos_plot(4)]); 53 | 54 | set(handles.fig,'Visible','on'); 55 | 56 | elseif ischar(varargin{1}) 57 | 58 | try 59 | if (nargout) 60 | [varargout{1:nargout}] = feval(varargin{:}); 61 | else 62 | feval(varargin{:}); 63 | end 64 | catch 65 | disp(lasterr); 66 | end 67 | 68 | end 69 | warning off 70 | 71 | % -------------------------------------------------------------------- 72 | function checkbox_arrow_Callback(hObject, eventdata, handles) 73 | if get(handles.checkbox_arrow,'Value') == 0 74 | handles.color=0; 75 | set(handles.checkbox_arrow_color,'Enable','off'); 76 | set(handles.checkbox_arrow_color,'Value',0); 77 | else 78 | set(handles.checkbox_arrow_color,'Enable','on'); 79 | delete(get(handles.axes_main,'children')); 80 | end 81 | guidata(handles.fig,handles); 82 | update_gui(handles.fig,[],handles); 83 | 84 | 85 | % -------------------------------------------------------------------- 86 | function checkbox_arrow_color_Callback(hObject, eventdata, handles) 87 | if (get(hObject,'Value') == 1) 88 | handles.color = 1; 89 | else 90 | 91 | handles.color = 0; 92 | 93 | set(handles.color_quiver,'Visible','off'); 94 | end 95 | 96 | guidata(handles.fig,handles); 97 | update_gui(handles.fig,[],handles); 98 | 99 | 100 | % -------------------------------------------------------------------- 101 | function varargout = popupmenu_quantity_Callback(h, eventdata, handles) 102 | 103 | if get(handles.checkbox_modes,'Value' ) == 1 104 | switch get(handles.popupmenu_quantity,'Value') 105 | case 1 106 | handles.property = []; 107 | set(handles.edit_min_clim,'Visible','Off'); 108 | set(handles.edit_max_clim,'Visible','Off'); 109 | set(handles.pushbutton_set_clim,'Visible','Off'); 110 | handles.alltodisp = 0; 111 | handles.allfields = 0; 112 | 113 | case 2 114 | handles.units = handles.velUnits; 115 | 116 | handles.property = handles.umodes(:,:,handles.current); 117 | case 3 118 | handles.units = handles.velUnits; 119 | handles.property = handles.vmodes(:,:,handles.current); 120 | case 4 121 | handles.units = handles.velUnits; 122 | handles.property = sqrt(handles.umodes(:,:,handles.current).^2+... 123 | handles.vmodes(:,:,handles.current).^2); 124 | case 5 125 | if ~isempty(findstr(handles.velUnits,'s')) 126 | handles.units='[1/s]' ; 127 | else 128 | handles.units = '[1/\Delta t]'; 129 | end 130 | 131 | [handles.dudx,handles.dudy] = gradient(handles.umodes(:,:,handles.current),... 132 | handles.dx, handles.dy); 133 | [handles.dvdx,handles.dvdy] = gradient(handles.vmodes(:,:,handles.current),... 134 | handles.dx, handles.dy); 135 | 136 | handles.property = handles.dvdx - handles.dudy ; 137 | case 6 138 | if ~isempty(findstr(handles.velUnits,'s')) 139 | handles.units='[1/s]' ; 140 | else 141 | handles.units = '[1/\Delta t]'; 142 | end 143 | [handles.dudx,handles.dudy] = gradient(handles.umodes(:,:,handles.current),... 144 | handles.dx, handles.dy); 145 | handles.property = handles.dudx; 146 | case 7 147 | if ~isempty(findstr(handles.velUnits,'s')) 148 | handles.units='[1/s]' ; 149 | else 150 | handles.units = '[1/\Delta t]'; 151 | end 152 | [handles.dudx,handles.dudy] = gradient(handles.umodes(:,:,handles.current),... 153 | handles.dx, handles.dy); 154 | handles.property = handles.dudy; 155 | case 8 156 | if ~isempty(findstr(handles.velUnits,'s')) 157 | handles.units='[1/s]' ; 158 | else 159 | handles.units = '[1/\Delta t]'; 160 | end 161 | [handles.dvdx,handles.dvdy] = gradient(handles.vmodes(:,:,handles.current),... 162 | handles.dx, handles.dy); 163 | 164 | handles.property = handles.dvdx; 165 | case 9 166 | if ~isempty(findstr(handles.velUnits,'s')) 167 | handles.units='[1/s]' ; 168 | else 169 | handles.units = '[1/\Delta t]'; 170 | end 171 | [handles.dvdx,handles.dvdy] = gradient(handles.vmodes(:,:,handles.current),... 172 | handles.dx, handles.dy); 173 | handles.property = handles.dvdy; 174 | case 10 175 | if ~isempty(findstr(handles.velUnits,'s')) 176 | handles.units='[1/s]' ; 177 | else 178 | handles.units = '[1/\Delta t]'; 179 | end 180 | [handles.dudx,handles.dudy] = gradient(handles.umodes(:,:,handles.current),... 181 | handles.dx, handles.dy); 182 | [handles.dvdx,handles.dvdy] = gradient(handles.vmodes(:,:,handles.current),... 183 | handles.dx, handles.dy); 184 | 185 | handles.property = handles.dudx + handles.dvdy; 186 | case 11 % s_xy 187 | if ~isempty(findstr(handles.velUnits,'s')) 188 | handles.units='[1/s]' ; 189 | else 190 | handles.units = '[1/\Delta t]'; 191 | end 192 | [handles.dudx,handles.dudy] = gradient(handles.umodes(:,:,handles.current),... 193 | handles.dx, handles.dy); 194 | [handles.dvdx,handles.dvdy] = gradient(handles.vmodes(:,:,handles.current),... 195 | handles.dx, handles.dy); 196 | 197 | handles.property = 0.5*(handles.dvdx + handles.dudy); 198 | end 199 | 200 | elseif (get(handles.checkbox_reconstruction,'Value') == 1 || get(handles.radiobutton_multimode,'Value') == 1) 201 | 202 | if get(handles.checkbox_reconstruction,'Value') == 1 203 | [handles.uRec, handles.vRec] = poduv(handles,3); 204 | end 205 | %--------------------------- 206 | switch get(handles.popupmenu_quantity,'Value') 207 | case 1 208 | handles.property = []; 209 | set(handles.edit_min_clim,'Visible','Off'); 210 | set(handles.edit_max_clim,'Visible','Off'); 211 | set(handles.pushbutton_set_clim,'Visible','Off'); 212 | handles.alltodisp = 0; 213 | handles.allfields = 0; 214 | 215 | case 2 216 | handles.units = handles.velUnits; 217 | handles.property = handles.uRec; 218 | 219 | case 3 220 | handles.units = handles.velUnits; 221 | handles.property = handles.vRec; 222 | 223 | case 4 224 | handles.units = handles.velUnits; 225 | handles.property = sqrt(handles.uRec.^2 + handles.vRec.^2); 226 | 227 | case 5 228 | if ~isempty(findstr(handles.velUnits,'s')) 229 | handles.units = '[1/s]' ; 230 | else 231 | handles.units = '[1/\Delta t]'; 232 | end 233 | [dudx,dudy] = gradient(handles.uRec,handles.dx, handles.dy); 234 | [dvdx,dvdy] = gradient(handles.vRec,handles.dx, handles.dy); 235 | handles.property = dvdx - dudy; 236 | case 6 237 | if ~isempty(findstr(handles.velUnits,'s')) 238 | handles.units = '[1/s]' ; 239 | else 240 | handles.units = '[1/\Delta t]'; 241 | end 242 | [dudx,dudy] = gradient(handles.uRec,handles.dx, handles.dy); 243 | [dvdx,dvdy] = gradient(handles.vRec,handles.dx, handles.dy); 244 | handles.property = dudx; 245 | case 7 246 | if ~isempty(findstr(handles.velUnits,'s')) 247 | handles.units = '[1/s]' ; 248 | else 249 | handles.units = '[1/\Delta t]'; 250 | end 251 | [dudx,dudy] = gradient(handles.uRec,handles.dx, handles.dy); 252 | [dvdx,dvdy] = gradient(handles.vRec,handles.dx, handles.dy); 253 | handles.property = dudy; 254 | case 8 255 | if ~isempty(findstr(handles.velUnits,'s')) 256 | handles.units = '[1/s]' ; 257 | else 258 | handles.units = '[1/\Delta t]'; 259 | end 260 | [dudx,dudy] = gradient(handles.uRec,handles.dx, handles.dy); 261 | [dvdx,dvdy] = gradient(handles.vRec,handles.dx, handles.dy); 262 | handles.property = dvdx; 263 | case 9 264 | if ~isempty(findstr(handles.velUnits,'s')) 265 | handles.units = '[1/s]' ; 266 | else 267 | handles.units = '[1/\Delta t]'; 268 | end 269 | [dudx,dudy] = gradient(handles.uRec,handles.dx, handles.dy); 270 | [dvdx,dvdy] = gradient(handles.vRec,handles.dx, handles.dy); 271 | handles.property = dvdy; 272 | case 10 273 | if ~isempty(findstr(handles.velUnits,'s')) 274 | handles.units = '[1/s]' ; 275 | else 276 | handles.units = '[1/\Delta t]'; 277 | end 278 | [dudx,dudy] = gradient(handles.uRec,handles.dx, handles.dy); 279 | [dvdx,dvdy] = gradient(handles.vRec,handles.dx, handles.dy); 280 | handles.property = dudx + dvdy; 281 | case 11 % s_xy 282 | if ~isempty(findstr(handles.velUnits,'s')) 283 | handles.units = '[1/s]' ; 284 | else 285 | handles.units = '[1/\Delta t]'; 286 | end 287 | [dudx,dudy] = gradient(handles.uRec,handles.dx, handles.dy); 288 | [dvdx,dvdy] = gradient(handles.vRec,handles.dx, handles.dy); 289 | handles.property = 0.5*(dvdx + dudy); 290 | end 291 | end 292 | 293 | if ~isempty(handles.property) 294 | if strcmp( get(handles.edit_arrow_size,'Enable'),'on') 295 | set(handles.checkbox_arrow_color,'Enable','on'); 296 | end 297 | end 298 | 299 | tmp = cellstr(get(handles.popupmenu_quantity,'String')); 300 | if strcmp(handles.previous_quantity,tmp{get(handles.popupmenu_quantity,'Value')}) == 0 && ... 301 | get(handles.popupmenu_eachfield,'Value') == 3 302 | handles.previous_quantity = tmp{get(handles.popupmenu_quantity,'Value')}; 303 | popupmenu_eachfield_Callback(handles.fig, [], handles); 304 | else 305 | handles.previous_quantity = tmp{get(handles.popupmenu_quantity,'Value')}; 306 | guidata(handles.fig,handles); 307 | update_gui(handles.fig,[],handles); 308 | end 309 | 310 | function edit_numcolors_Callback(h, eventdata, handles) 311 | numcolors = str2double(get(h,'String')); 312 | if numcolors < 1 | isnan(numcolors) 313 | warndlg('Wrong number of colors, must be greater than 0', 'Error','modal'); 314 | set(h,'String',10); 315 | else 316 | handles.numcolors = numcolors; 317 | end 318 | if isempty(handles.numcolors), 319 | set(h,'String',10); 320 | handles.numcolors = 10; 321 | end 322 | guidata(handles.fig,handles); 323 | update_gui(handles.fig,[],handles); 324 | 325 | 326 | function update_gui(h, eventdata, handles) 327 | 328 | persistent kernel; 329 | kernel = ... 330 | [0.0030 0.0133 0.0219 0.0133 0.0030 331 | 0.0133 0.0596 0.0983 0.0596 0.0133 332 | 0.0219 0.0983 0.1621 0.0983 0.0219 333 | 0.0133 0.0596 0.0983 0.0596 0.0133 334 | 0.0030 0.0133 0.0219 0.0133 0.0030]; 335 | 336 | axes(handles.axes_main); grid on; box on; axis ij; 337 | delete(get(handles.axes_main,'children')); 338 | 339 | 340 | if ~isfield(handles,'umodes') || isempty(handles.umodes) 341 | handles.umodes = handles.u(:,:,1); 342 | handles.vmodes = handles.v(:,:,1); 343 | end 344 | 345 | if get(handles.popupmenu_quantity,'Value') == 1 , 346 | set(handles.checkbox_label,'Enable','Off'); 347 | set(handles.checkbox_colorbar,'Enable','Off'); 348 | set(handles.text_numberofcolors,'Enable','Off'); 349 | set(handles.edit_numcolors,'Enable','Off'); 350 | set(handles.popupmenu_eachfield,'Enable','Off'); 351 | set(handles.edit_max_clim,'Enable','Off'); 352 | set(handles.edit_min_clim,'Enable','Off'); 353 | set(handles.pushbutton_set_clim,'Enable','Off'); 354 | set(handles.popupmenu_contour_type,'Enable','Off'); 355 | else 356 | set(handles.checkbox_label,'Enable','On'); 357 | set(handles.checkbox_colorbar,'Enable','On'); 358 | set(handles.text_numberofcolors,'Enable','On'); 359 | set(handles.edit_numcolors,'Enable','On'); 360 | set(handles.popupmenu_eachfield,'Enable','On'); 361 | set(handles.edit_max_clim,'Enable','On'); 362 | set(handles.edit_min_clim,'Enable','On'); 363 | set(handles.pushbutton_set_clim,'Enable','On'); 364 | set(handles.popupmenu_contour_type,'Enable','On'); 365 | end 366 | 367 | if ~isempty(handles.property) 368 | switch (get(handles.popupmenu_contour_type,'Value')) 369 | case 1 370 | cla reset; 371 | case 2 372 | [handles.C,handles.CH] = contourf('v6',handles.x,handles.y,filter2(kernel,handles.property,'same'),handles.numcolors); 373 | set(handles.CH,'edgecolor','none'); 374 | case 3 375 | [handles.C,handles.CH] = contour('v6',handles.x,handles.y,filter2(kernel,handles.property,'same'),handles.numcolors); 376 | case 4 377 | [handles.C,handles.CH] = contourf('v6',handles.x,handles.y,filter2(kernel,handles.property,'same'),handles.numcolors); 378 | case 5 379 | [handles.C,handles.CH] = contour('v6',handles.x,handles.y,filter2(kernel,handles.property,'same'),handles.numcolors); 380 | set(handles.CH,'edgecolor','black'); 381 | end 382 | 383 | % handles.climit_prev = get(gca,'clim'); 384 | if handles.alltodisp == 1 385 | set(gca,'CLim',handles.climit); 386 | elseif handles.allfields == 1 387 | if get(handles.popupmenu_eachfield,'Value') == 4; 388 | handles.cmin = str2num(get(handles.edit_min_clim,'String')); 389 | handles.cmax = str2num(get(handles.edit_max_clim,'String')); 390 | end 391 | caxis('manual'); 392 | caxis(handles.axes_main,[handles.cmin handles.cmax]); 393 | end 394 | if handles.labelit == 1 395 | if get(handles.popupmenu_contour_type,'Value')>1 396 | clabel(handles.C,handles.CH,'Color','b','Rotation',0); 397 | end; 398 | end 399 | 400 | if handles.colorbar_flag 401 | handles.colorbar = colorbar('v6','peer',handles.axes_main); 402 | end 403 | else 404 | cla reset; 405 | handles.color = 0; 406 | set(handles.checkbox_arrow_color,'Enable','off'); 407 | set(handles.checkbox_arrow_color,'Value',0); 408 | set(handles.checkbox_colorbar,'Value',0); 409 | set(handles.checkbox_label,'Value',0); 410 | set(handles.popupmenu_eachfield,'Value',1); 411 | handles.colorbar_flag=0; 412 | handles.labelit= 0; 413 | end 414 | if get(handles.checkbox_arrow,'Value') == 1 415 | if handles.color == 1 416 | hold on; 417 | if (get(handles.checkbox_reconstruction,'Value') == 1 | get(handles.radiobutton_multimode,'Value') == 1) 418 | handles.color_quiver = quiverc(handles.x,handles.y,handles.uRec,handles.vRec,handles.arrow_scale,handles.property); 419 | elseif get(handles.checkbox_modes,'Value') == 1 420 | handles.color_quiver = quiverc(handles.x,handles.y,handles.umodes(:,:,handles.current),handles.vmodes(:,:,handles.current),handles.arrow_scale,handles.property); 421 | end 422 | hold off; 423 | if handles.colorbar_flag 424 | handles.colorbar = colorbar('v6','peer',handles.axes_main); 425 | end 426 | else 427 | hold on; 428 | if (get(handles.checkbox_reconstruction,'Value') == 1 | get(handles.radiobutton_multimode,'Value') == 1) 429 | handles.quiver = quiver(handles.x,handles.y,handles.uRec,handles.vRec,handles.arrow_scale,'k'); 430 | else 431 | handles.quiver = quiver(handles.x,handles.y,handles.umodes(:,:,handles.current),handles.vmodes(:,:,handles.current),handles.arrow_scale,'k'); 432 | end 433 | 434 | end 435 | hold off; 436 | end 437 | handles.climit_prev = get(gca,'clim'); 438 | set(handles.axes_main,'XLim',[min(handles.x(:)),max(handles.x(:))]); 439 | set(handles.axes_main,'YLim',[min(handles.y(:)),max(handles.y(:))]); 440 | xlabel(['x ',handles.xUnits]); 441 | ylabel(['y ',handles.xUnits]); 442 | 443 | if isfield(handles,'colorbar') & get(handles.checkbox_colorbar,'Value') == 1 444 | set(handles.axes_main,'Units','normalized'); 445 | axpos = get(handles.axes_main,'Position'); 446 | set(handles.colorbar,'Units','normalized','Position',[axpos(1)+axpos(3)+0.018+0.04,axpos(2),0.020,axpos(4)]); 447 | set(handles.axes_main,'Position',[axpos(1),axpos(2),axpos(3)+0.04,axpos(4)]); 448 | 449 | end 450 | box( handles.axes_main,'on'); 451 | guidata(handles.fig,handles); 452 | 453 | function varargout = edit_min_clim_Callback(h, eventdata, handles, varargin) 454 | handles.cmin = str2num(get(handles.edit_min_clim,'String')); 455 | if isempty(handles.cmin) 456 | warndlg('Wrong input','Error','modal'); 457 | current_clim = get(handles.axes_main,'clim'); 458 | set(handles.edit_min_clim,'String',sprintf('%3.2f',current_clim(1))); 459 | handles.cmin = current_clim(2); 460 | end 461 | % handles.alltodisp = 0; 462 | % handles.allfields = 1; 463 | guidata(handles.fig,handles); 464 | 465 | 466 | function varargout = edit_max_clim_Callback(h, eventdata, handles, varargin) 467 | handles.cmax = str2num(get(handles.edit_max_clim,'String')); 468 | if isempty(handles.cmax), 469 | warndlg('Wrong input','Error','modal'); 470 | current_clim = get(handles.axes_main,'clim'); 471 | set(handles.edit_max_clim,'String',sprintf('%3.2f',current_clim(2))); 472 | handles.cmax = current_clim(2); 473 | end 474 | % handles.alltodisp = 0; 475 | % handles.allfields = 1; 476 | guidata(handles.fig,handles); 477 | 478 | 479 | function varargout = pushbutton_set_clim_Callback(h, eventdata, handles, varargin) 480 | 481 | edit_min_clim_Callback(h, eventdata, handles, varargin) 482 | edit_max_clim_Callback(h, eventdata, handles, varargin) 483 | 484 | % handles.cmin = str2num(get(handles.edit_min_clim,'String')); 485 | % handles.cmax = str2num(get(handles.edit_max_clim,'String')); 486 | 487 | if handles.cmin >= handles.cmax 488 | warndlg('Wrong limits, min should be less than max', 'Error','modal'); 489 | current_clim = get(handles.axes_main,'clim'); 490 | handles.cmin = current_clim(1); 491 | handles.cmax = current_clim(2); 492 | set(handles.edit_min_clim,'String',sprintf('%3.2f',handles.cmin)); 493 | set(handles.edit_max_clim,'String',sprintf('%3.2f',handles.cmax)); 494 | end 495 | guidata(handles.fig,handles); 496 | update_gui(handles.fig,[],handles); 497 | 498 | 499 | function varargout = pushbutton_previous_Callback(h, eventdata, handles, varargin) 500 | if handles.current > 1 501 | handles.current = handles.current - 1; 502 | set(handles.edit_current,'String',handles.current); 503 | delete(get(handles.axes_main,'children')); 504 | guidata(handles.fig,handles); 505 | popupmenu_quantity_Callback(handles.fig, [], handles); 506 | else 507 | beep; 508 | end 509 | 510 | 511 | function varargout = pushbutton_next_Callback(h, eventdata, handles, varargin) 512 | if get(handles.checkbox_modes,'Value') == 1 513 | if handles.current < handles.numOfModes 514 | handles.current = handles.current + 1; 515 | set(handles.edit_current,'String',handles.current); 516 | guidata(handles.fig,handles); 517 | delete(get(handles.axes_main,'children')); 518 | popupmenu_quantity_Callback(handles.fig, [], handles); 519 | else 520 | beep; 521 | end 522 | else 523 | if handles.current < handles.N 524 | handles.current = handles.current + 1; 525 | set(handles.edit_current,'String',handles.current); 526 | guidata(handles.fig,handles); 527 | delete(get(handles.axes_main,'children')); 528 | popupmenu_quantity_Callback(handles.fig, [], handles); 529 | else 530 | beep; 531 | end 532 | end 533 | 534 | function varargout = edit_current_Callback(h, eventdata, handles, varargin) 535 | tmp = fix(str2double(get(handles.edit_current,'String'))); 536 | 537 | if isnan(tmp) 538 | beep 539 | tmp = 1; 540 | set(handles.edit_current,'String','1'); 541 | end 542 | 543 | if get(handles.checkbox_modes,'Value') == 1 544 | 545 | if tmp > 0 & tmp <= handles.numOfModes 546 | handles.current = tmp; 547 | guidata(handles.fig,handles); 548 | popupmenu_quantity_Callback(handles.fig, [], handles); 549 | else 550 | beep 551 | set(handles.edit_current,'String',handles.current); 552 | end 553 | else 554 | if tmp > 0 & tmp <= handles.N 555 | handles.current = tmp; 556 | guidata(handles.fig,handles); 557 | popupmenu_quantity_Callback(handles.fig, [], handles); 558 | else 559 | beep 560 | set(handles.edit_current,'String',handles.current); 561 | end 562 | end 563 | 564 | 565 | 566 | function varargout = edit_arrow_size_Callback(h, eventdata, handles, varargin) 567 | handles.arrow_scale = str2double(get(h,'String')); 568 | if handles.arrow_scale == 0 | isempty(handles.arrow_scale) | isnan(handles.arrow_scale) 569 | handles.arrow_scale = 1; 570 | set(handles.edit_arrow_size,'String','1'); 571 | end 572 | guidata(handles.fig,handles); 573 | update_gui(handles.fig,[],handles); 574 | 575 | 576 | function varargout = pushbutton_animate_Callback(h, eventdata, handles, varargin) 577 | 578 | if get(handles.pushbutton_animate,'Value') == 1 579 | startpoint = handles.current; 580 | if get(handles.checkbox_modes,'Value') == 1 581 | for i = startpoint:handles.numOfModes 582 | if get(handles.pushbutton_animate,'Value') == 0 583 | break; 584 | end 585 | handles.current = i; 586 | set(handles.edit_current,'String',handles.current); 587 | delete(get(handles.axes_main,'children')); 588 | guidata(handles.fig,handles); 589 | popupmenu_quantity_Callback(handles.fig, [], handles); 590 | drawnow; 591 | end 592 | elseif get(handles.checkbox_reconstruction,'Value') == 1 593 | for i = startpoint:handles.N 594 | if get(handles.pushbutton_animate,'Value') == 0 595 | break; 596 | end 597 | handles.current = i; 598 | set(handles.edit_current,'String',handles.current); 599 | delete(get(handles.axes_main,'children')); 600 | guidata(handles.fig,handles); 601 | popupmenu_quantity_Callback(handles.fig, [], handles); 602 | drawnow; 603 | end 604 | end 605 | else 606 | 607 | end 608 | set(handles.pushbutton_animate,'Value',0); 609 | 610 | 611 | 612 | function varargout = pushbutton_save_movie_Callback(h, eventdata, handles, varargin) 613 | 614 | if get(handles.pushbutton_save_movie,'Value') == 1 615 | file = []; 616 | file = inputdlg('File Name','Input File Name for the movie'); 617 | if isempty(file) | exist(file{1},'file') | exist([file{1},'.avi'],'file') 618 | set(handles.pushbutton_save_movie,'Value',0); 619 | return 620 | end 621 | handles.mov = avifile(file{1},'compression','none','quality',100,'fps',15); 622 | 623 | startpoint = handles.current; 624 | if get(handles.checkbox_modes,'Value') == 1 625 | for i = startpoint:handles.numOfModes 626 | handles.current = i; 627 | set(handles.edit_current,'String',handles.current); 628 | delete(get(handles.axes_main,'children')); 629 | guidata(handles.fig,handles); 630 | popupmenu_quantity_Callback(handles.fig, [], handles); 631 | F = getframe(handles.axes_main); 632 | if get(handles.pushbutton_save_movie,'Value') == 0 633 | break; 634 | end 635 | handles.mov = addframe(handles.mov,F); 636 | end 637 | elseif get(handles.checkbox_reconstruction,'Value') ==1 638 | for i = startpoint:handles.N 639 | handles.current = i; 640 | set(handles.edit_current,'String',handles.current); 641 | delete(get(handles.axes_main,'children')); 642 | guidata(handles.fig,handles); 643 | popupmenu_quantity_Callback(handles.fig, [], handles); 644 | F = getframe(handles.axes_main); 645 | if get(handles.pushbutton_save_movie,'Value') == 0 646 | break; 647 | end 648 | handles.mov = addframe(handles.mov,F); 649 | end 650 | end 651 | 652 | if isfield(handles,'mov') 653 | handles.mov = close(handles.mov); 654 | handles = rmfield(handles,'mov'); 655 | end 656 | 657 | end 658 | set(handles.pushbutton_save_movie,'Value',0); 659 | 660 | % ------------------------------------------------------------------------- 661 | function varargout = checkbox_label_Callback(h, eventdata, handles, varargin) 662 | if (get(h,'Value') == get(h,'Max')) 663 | if get(handles.popupmenu_contour_type,'Value')>1 664 | handles.labelit = 1; 665 | 666 | clabel(handles.C,handles.CH,'Color','b','Rotation',0); 667 | guidata(handles.fig,handles); 668 | else 669 | set(handles.checkbox_label,'Value',0); 670 | end; 671 | else 672 | handles.labelit = 0; 673 | guidata(handles.fig,handles); 674 | update_gui(handles.fig,[],handles); 675 | end 676 | 677 | 678 | function varargout = checkbox_colorbar_Callback(h, eventdata, handles, varargin) 679 | if get(h,'Value') == 1 680 | handles.colorbar_flag = 1; 681 | guidata(handles.fig,handles); 682 | update_gui(handles.fig,[],handles); 683 | else 684 | delete(findobj(handles.fig,'Tag','Colorbar')); 685 | handles.colorbar_flag = 0; 686 | guidata(handles.fig,handles); 687 | end 688 | 689 | function popupmenu_eachfield_Callback(hObject, eventdata, handles) 690 | % Each Field, All to display, all fields & manual processing 691 | 692 | % get value and assign selected property to handles.property which is default to display 693 | val = get(handles.popupmenu_eachfield,'Value'); 694 | % redirect in case of 695 | if get(handles.radiobutton_multimode,'Value')==1 696 | if val==2 | val==3 697 | val=1; 698 | set(handles.popupmenu_eachfield,'Value',1); 699 | end 700 | end 701 | 702 | switch val 703 | case 1 704 | set(handles.edit_min_clim,'Visible','Off'); 705 | set(handles.edit_max_clim,'Visible','Off'); 706 | set(handles.pushbutton_set_clim,'Visible','Off'); 707 | handles.alltodisp = 0; % unset all other flags 708 | handles.allfields = 0; 709 | case 2 710 | set(handles.edit_min_clim,'Visible','Off'); 711 | set(handles.edit_max_clim,'Visible','Off'); 712 | set(handles.pushbutton_set_clim,'Visible','Off'); 713 | handles.alltodisp = 1; 714 | handles.climit = handles.climit_prev; 715 | case 3 716 | set(handles.edit_min_clim,'Visible','Off'); 717 | set(handles.edit_max_clim,'Visible','Off'); 718 | set(handles.pushbutton_set_clim,'Visible','Off'); 719 | handles.alltodisp = 0; 720 | handles.allfields = 1; 721 | if get(handles.checkbox_modes,'Value') == 1 722 | switch get(handles.popupmenu_quantity,'Value') 723 | case 1 724 | handles.cmin = 0; handles.cmax = 1; 725 | case 2 726 | handles.cmin = min(handles.umodes(:)); handles.cmax = max(handles.umodes(:)); 727 | case 3 728 | handles.cmin = min(handles.vmodes(:)); handles.cmax = max(handles.vmodes(:)); 729 | case 4 730 | handles.cmin = min(sqrt(handles.umodes(:).^2+handles.vmodes(:).^2)); 731 | handles.cmax = max(sqrt(handles.umodes(:).^2+handles.vmodes(:).^2)); 732 | case 5 733 | handles.cmin = Inf; 734 | handles.cmax = -Inf; 735 | for i = 1:handles.numOfModes 736 | [dudx,dudy] = gradient(handles.umodes(:,:,handles.current),handles.dx, handles.dy); 737 | [dvdx,dvdy] = gradient(handles.vmodes(:,:,handles.current),handles.dx, handles.dy); 738 | tmp = dvdx - dudy ; 739 | handles.cmin = min(handles.cmin,min(tmp(:))); 740 | handles.cmax = max(handles.cmax,max(tmp(:))); 741 | end 742 | case 6 743 | handles.cmin = Inf; 744 | handles.cmax = -Inf; 745 | for i = 1:handles.numOfModes 746 | [dudx,dudy] = gradient(handles.umodes(:,:,handles.current),handles.dx, handles.dy); 747 | tmp = dudx; 748 | handles.cmin = min(handles.cmin,min(tmp(:))); 749 | handles.cmax = max(handles.cmax,max(tmp(:))); 750 | end 751 | case 7 752 | handles.cmin = Inf; 753 | handles.cmax = -Inf; 754 | for i = 1:handles.numOfModes 755 | [dudx,dudy] = gradient(handles.umodes(:,:,handles.current),handles.dx, handles.dy); 756 | tmp = dudy; 757 | handles.cmin = min(handles.cmin,min(tmp(:))); 758 | handles.cmax = max(handles.cmax,max(tmp(:))); 759 | end 760 | 761 | case 8 762 | handles.cmin = Inf; 763 | handles.cmax = -Inf; 764 | for i = 1:handles.numOfModes 765 | [dvdx,dvdy] = gradient(handles.vmodes(:,:,handles.current),handles.dx, handles.dy); 766 | tmp = dvdx; 767 | handles.cmin = min(handles.cmin,min(tmp(:))); 768 | handles.cmax = max(handles.cmax,max(tmp(:))); 769 | end 770 | case 9 771 | handles.cmin = Inf; 772 | handles.cmax = -Inf; 773 | for i = 1:handles.numOfModes 774 | [dvdx,dvdy] = gradient(handles.vmodes(:,:,handles.current),handles.dx, handles.dy); 775 | tmp = dvdy; 776 | handles.cmin = min(handles.cmin,min(tmp(:))); 777 | handles.cmax = max(handles.cmax,max(tmp(:))); 778 | end 779 | 780 | case 10 781 | handles.cmin = Inf; 782 | handles.cmax = -Inf; 783 | for i = 1:handles.numOfModes 784 | [dudx,dudy] = gradient(handles.umodes(:,:,handles.current),handles.dx, handles.dy); 785 | [dvdx,dvdy] = gradient(handles.vmodes(:,:,handles.current),handles.dx, handles.dy); 786 | tmp = dudx + dvdy; 787 | handles.cmin = min(handles.cmin,min(tmp(:))); 788 | handles.cmax = max(handles.cmax,max(tmp(:))); 789 | end 790 | case 11 791 | handles.cmin = Inf; 792 | handles.cmax = -Inf; 793 | for i = 1:handles.numOfModes 794 | [dudx,dudy] = gradient(handles.umodes(:,:,handles.current),handles.dx, handles.dy); 795 | [dvdx,dvdy] = gradient(handles.vmodes(:,:,handles.current),handles.dx, handles.dy); 796 | tmp = 0.5* (dvdx + dudy); 797 | handles.cmin = min(handles.cmin,min(tmp(:))); 798 | handles.cmax = max(handles.cmax,max(tmp(:))); 799 | end 800 | end 801 | elseif (get(handles.checkbox_reconstruction,'Value') == 1 | get(handles.radiobutton_multimode,'Value')==1) 802 | switch get(handles.popupmenu_quantity,'Value') 803 | case 1 804 | handles.cmin = 0; 805 | handles.cmax = 1; 806 | case 2 807 | 808 | handles.cmin = Inf; 809 | handles.cmax = -Inf; 810 | tmpcounter = handles.current; 811 | for i = 1:handles.N 812 | handles.current = i; 813 | [handles.uRec, handles.vRec] = poduv(handles,3); 814 | handles.cmin = min(handles.cmin,min(handles.uRec(:))); 815 | handles.cmax = max(handles.cmax,max(handles.uRec(:))); 816 | end 817 | handles.current = tmpcounter; 818 | 819 | case 3 820 | handles.cmin = Inf; 821 | handles.cmax = -Inf; 822 | tmpcounter = handles.current; 823 | for i = 1:handles.N 824 | handles.current = i; 825 | [handles.uRec, handles.vRec] = poduv(handles,3); 826 | handles.cmin = min(handles.cmin,min(handles.vRec(:))); 827 | handles.cmax = max(handles.cmax,max(handles.vRec(:))); 828 | end 829 | handles.current = tmpcounter; 830 | 831 | case 4 832 | handles.cmin = Inf; 833 | handles.cmax = -Inf; 834 | tmpcounter = handles.current; 835 | for i = 1:handles.N 836 | handles.current = i; 837 | [handles.uRec, handles.vRec] = poduv(handles,3); 838 | tmp = sqrt(handles.uRec.^2 + handles.vRec.^2); 839 | handles.cmin = min(handles.cmin,min(tmp(:))); 840 | handles.cmax = max(handles.cmax,max(tmp(:))); 841 | end 842 | handles.current = tmpcounter; 843 | 844 | case 5 845 | handles.cmin = Inf; 846 | handles.cmax = -Inf; 847 | tmpcounter = handles.current; 848 | for i = 1:handles.N 849 | handles.current = i; 850 | [handles.uRec, handles.vRec] = poduv(handles,3); 851 | [dudx,dudy] = gradient(handles.uRec,handles.dx, handles.dy); 852 | [dvdx,dvdy] = gradient(handles.vRec,handles.dx, handles.dy); 853 | tmp = 0.5* (dvdx - dudy); 854 | handles.cmin = min(handles.cmin,min(tmp(:))); 855 | handles.cmax = max(handles.cmax,max(tmp(:))); 856 | end 857 | handles.current = tmpcounter; 858 | case 6 859 | handles.cmin = Inf; 860 | handles.cmax = -Inf; 861 | tmpcounter = handles.current; 862 | for i = 1:handles.N 863 | handles.current = i; 864 | 865 | [handles.uRec, handles.vRec] = poduv(handles,3); 866 | [dudx,dudy] = gradient(handles.uRec,handles.dx, handles.dy); 867 | [dvdx,dvdy] = gradient(handles.vRec,handles.dx, handles.dy); 868 | tmp = dudx; 869 | handles.cmin = min(handles.cmin,min(tmp(:))); 870 | handles.cmax = max(handles.cmax,max(tmp(:))); 871 | end 872 | handles.current = tmpcounter; 873 | case 7 874 | handles.cmin = Inf; 875 | handles.cmax = -Inf; 876 | tmpcounter = handles.current; 877 | for i = 1:handles.N 878 | handles.current = i; 879 | 880 | [handles.uRec, handles.vRec] = poduv(handles,3); 881 | [dudx,dudy] = gradient(handles.uRec,handles.dx, handles.dy); 882 | [dvdx,dvdy] = gradient(handles.vRec,handles.dx, handles.dy); 883 | tmp = dudy; 884 | handles.cmin = min(handles.cmin,min(tmp(:))); 885 | handles.cmax = max(handles.cmax,max(tmp(:))); 886 | end 887 | handles.current = tmpcounter; 888 | case 8 889 | handles.cmin = Inf; 890 | handles.cmax = -Inf; 891 | tmpcounter = handles.current; 892 | for i = 1:handles.N 893 | handles.current = i; 894 | [handles.uRec, handles.vRec] = poduv(handles,3); 895 | [dudx,dudy] = gradient(handles.uRec,handles.dx, handles.dy); 896 | [dvdx,dvdy] = gradient(handles.vRec,handles.dx, handles.dy); 897 | tmp = dvdx; 898 | handles.cmin = min(handles.cmin,min(tmp(:))); 899 | handles.cmax = max(handles.cmax,max(tmp(:))); 900 | end 901 | handles.current = tmpcounter; 902 | case 9 903 | handles.cmin = Inf; 904 | handles.cmax = -Inf; 905 | tmpcounter = handles.current; 906 | for i = 1:handles.N 907 | handles.current = i; 908 | [handles.uRec, handles.vRec] = poduv(handles,3); 909 | [dudx,dudy] = gradient(handles.uRec,handles.dx, handles.dy); 910 | [dvdx,dvdy] = gradient(handles.vRec,handles.dx, handles.dy); 911 | tmp = dvdy; 912 | handles.cmin = min(handles.cmin,min(tmp(:))); 913 | handles.cmax = max(handles.cmax,max(tmp(:))); 914 | end 915 | handles.current = tmpcounter; 916 | case 10 917 | handles.cmin = Inf; 918 | handles.cmax = -Inf; 919 | tmpcounter = handles.current; 920 | for i = 1:handles.N 921 | handles.current = i; 922 | [handles.uRec, handles.vRec] = poduv(handles,3); 923 | [dudx,dudy] = gradient(handles.uRec,handles.dx, handles.dy); 924 | [dvdx,dvdy] = gradient(handles.vRec,handles.dx, handles.dy); 925 | tmp = dudx + dvdy; 926 | handles.cmin = min(handles.cmin,min(tmp(:))); 927 | handles.cmax = max(handles.cmax,max(tmp(:))); 928 | end 929 | handles.current = tmpcounter; 930 | case 11 931 | handles.cmin = Inf; 932 | handles.cmax = -Inf; 933 | tmpcounter = handles.current; 934 | for i = 1:handles.N 935 | handles.current = i; 936 | [handles.uRec, handles.vRec] = poduv(handles,3); 937 | [dudx,dudy] = gradient(handles.uRec,handles.dx, handles.dy); 938 | [dvdx,dvdy] = gradient(handles.vRec,handles.dx, handles.dy); 939 | tmp = 0.5* (dvdx + dudy); 940 | handles.cmin = min(handles.cmin,min(tmp(:))); 941 | handles.cmax = max(handles.cmax,max(tmp(:))); 942 | end 943 | handles.current = tmpcounter; 944 | end 945 | end 946 | case 4 947 | set(handles.edit_min_clim,'Visible','On'); 948 | set(handles.edit_max_clim,'Visible','On'); 949 | set(handles.pushbutton_set_clim,'Visible','On'); 950 | handles.alltodisp = 0; 951 | handles.allfields = 1; 952 | current_clim = get(handles.axes_main,'clim'); 953 | set(handles.edit_min_clim,'String',sprintf('%3.2f',current_clim(1))); 954 | set(handles.edit_max_clim,'String',sprintf('%3.2f',current_clim(2))); 955 | end 956 | 957 | guidata(handles.fig,handles); 958 | update_gui(handles.fig,[],handles); 959 | 960 | 961 | 962 | function checkbox_modes_Callback(hObject, eventdata, handles) 963 | 964 | set (handles.arrow_ctrls,'Enable','on'); 965 | set(handles.checkbox_modes,'Value',1); 966 | if get(handles.checkbox_modes,'Value') == 1 967 | set(handles.edit_numfields,'String',int2str(handles.numOfModes)); 968 | set(handles.checkbox_reconstruction,'Value',0) 969 | set(handles.radiobutton_multimode,'Value',0); 970 | set(handles.edit_multimode,'Visible','off','Enable','off'); 971 | set(handles.edit_SelectedModes,'Visible','off','Enable','off'); 972 | set(handles.radiobutton_weights,'Visible','off','Value',0); 973 | set(handles.edit_min_clim,'Visible','Off'); 974 | set(handles.edit_max_clim,'Visible','Off'); 975 | set(handles.pushbutton_set_clim,'Visible','Off'); 976 | handles.alltodisp = 0; 977 | handles.allfields = 0; 978 | set(handles.popupmenu_eachfield,'String','Each Field|All to Display|All Fields|Manual'); 979 | 980 | handles.current = 1; 981 | set(handles.edit_current,'String',handles.current); 982 | set(handles.pushbutton_previous,'Enable','on'); 983 | set(handles.pushbutton_next,'Enable','on'); 984 | set(handles.pushbutton_animate,'Enable','on'); 985 | set(handles.pushbutton_save_movie,'Enable','on'); 986 | set(handles.edit_current,'Enable','on'); 987 | 988 | end 989 | set(handles.popupmenu_eachfield,'String','Each Field|All to Display|All Fields|Manual'); 990 | 991 | set(handles.popupmenu_quantity,'Value',1); 992 | handles.property = []; 993 | handles.C = []; 994 | handles.CH = []; 995 | guidata(handles.fig,handles); 996 | update_gui(handles.fig,[],handles); 997 | 998 | 999 | function checkbox_reconstruction_Callback(hObject, eventdata, handles) 1000 | set(handles.arrow_ctrls,'Enable','on'); 1001 | set(handles.edit_numfields,'String',int2str(handles.N)); 1002 | set(handles.checkbox_reconstruction,'Value',1); 1003 | % if (get(handles.checkbox_reconstruction,'Value') == 1) 1004 | set(handles.edit_numfields,'String',int2str(handles.N)); 1005 | set(handles.checkbox_modes,'Value',0); 1006 | set(handles.radiobutton_multimode,'Value',0); 1007 | set(handles.edit_multimode,'Visible','off','Enable','off'); 1008 | set(handles.radiobutton_weights,'Visible','off','Enable','off'); 1009 | set(handles.edit_min_clim,'Visible','Off'); 1010 | set(handles.edit_max_clim,'Visible','Off'); 1011 | set(handles.pushbutton_set_clim,'Visible','Off'); 1012 | handles.current = 1; 1013 | set(handles.edit_current,'String',int2str(handles.current)); 1014 | set(handles.pushbutton_previous,'Enable','on'); 1015 | set(handles.pushbutton_next,'Enable','on'); 1016 | set(handles.pushbutton_animate,'Enable','on'); 1017 | set(handles.pushbutton_save_movie,'Enable','on'); 1018 | set(handles.edit_current,'Enable','on'); 1019 | handles.alltodisp = 0; 1020 | handles.allfields = 0; 1021 | set(handles.popupmenu_eachfield,'String','Each Field|All to Display|All Fields|Manual'); 1022 | % end 1023 | 1024 | set(handles.popupmenu_quantity,'Value',1); 1025 | set(handles.edit_SelectedModes,'Visible','on','Enable','on'); 1026 | set(handles.edit_SelectedModes,'String',['1:',int2str(handles.numOfModes)]); 1027 | 1028 | try 1029 | handles.SelectedModes = sort(eval(['[',get(handles.edit_SelectedModes,'String'),']',])); 1030 | catch 1031 | warndlg('Wrong input: e.g. 1,3,5 or 1:2:5 or 1:5','Error','modal'); 1032 | end 1033 | 1034 | if min(size(handles.SelectedModes)) ~= 1 | ~isempty(findstr(get(handles.edit_SelectedModes,'String'),'.')) % | max(size(handles.SelectedModes)) ~= 2 1035 | warndlg('Wrong input: e.g. 1,3,5 or 1:2:5 or 1:5','Error','modal'); 1036 | elseif ( handles.SelectedModes(1) < 1 | max(handles.SelectedModes) > handles.numOfModes) 1037 | warndlg('Input must be in the range of 1:number of modes','Error','modal'); 1038 | end 1039 | 1040 | [handles.uRec, handles.vRec] = poduv(handles,3); 1041 | handles.current = 1; 1042 | handles.property = []; 1043 | handles.C = []; 1044 | handles.CH = []; 1045 | guidata(handles.fig,handles); 1046 | update_gui(handles.fig,[],handles); 1047 | 1048 | 1049 | function File_Callback(hObject, eventdata, handles) 1050 | 1051 | function load_Callback(hObject, eventdata, handles) 1052 | 1053 | global orighandles; 1054 | if isfield(handles,'restoreorig') 1055 | handles = orighandles; 1056 | end 1057 | handles.restoreorig = 1; 1058 | 1059 | try 1060 | % [gui_files,gui_path] = getVECfiles; 1061 | fileTypes = {'*.txt', 'OpenPIV TXT files' 1062 | '*.vec', 'Insight 3G VEC files' 1063 | '*.mat', 'SpatialToolbox MAT files'}; 1064 | 1065 | [handles.files] = uipickfiles('Type',fileTypes); 1066 | 1067 | % handles.N = length(gui_files); 1068 | % if handles.N >= 1 1069 | % handles.files = gui_files; 1070 | % handles.path = gui_path; 1071 | % set(handles.fig,'pointer','watch'); 1072 | % else 1073 | % warndlg('More than 2 files are required','Error','modal'); 1074 | % set(handles.fig,'pointer','arrow'); 1075 | % return 1076 | % end 1077 | 1078 | handles.N = length(handles.files); % number of files selected 1079 | if handles.N > 0 1080 | [handles.path,~,extension] = fileparts(handles.files{1}); 1081 | set(handles.fig,'pointer','watch'); 1082 | else 1083 | return 1084 | end 1085 | 1086 | switch(extension) 1087 | case{'.vec'} 1088 | [handles.xUnits,handles.velUnits,d] = vecread(handles.files{1}); 1089 | [rows,cols,~] = size(d); 1090 | [handles.u,handles.v] = deal(zeros(rows,cols,handles.N)); 1091 | handles.x = d(:,:,1); 1092 | handles.y = d(:,:,2); 1093 | handles.u(:,:,1) = d(:,:,3); 1094 | handles.v(:,:,1) = d(:,:,4); 1095 | for i = 2:handles.N 1096 | d = vecread(handles.files{i},1,5); 1097 | handles.u(:,:,i) = d(:,:,3); 1098 | handles.v(:,:,i) = d(:,:,4); 1099 | end 1100 | 1101 | case{'.txt'} 1102 | d = load(handles.files{1}); 1103 | d = repmat(d,[1 1 handles.N]); 1104 | for i = 2:handles.N 1105 | d(:,:,i) = load(handles.files{i}); 1106 | end 1107 | 1108 | x = d(:,1,:); 1109 | x = x(x~=0); 1110 | unX = unique(x); 1111 | 1112 | minX = min(unX); 1113 | maxX = max(unX); 1114 | dX = ceil((maxX-minX)/(length(unX)-1)); 1115 | 1116 | y = d(:,2,:); 1117 | y = y(y~=0); 1118 | unY = unique(y); 1119 | 1120 | minY = min(unY); 1121 | maxY = max(unY); 1122 | dY = ceil((maxY-minY)/(length(unY)-1)); 1123 | 1124 | [handles.x,handles.y] = meshgrid(minX:dX:maxX,minY:dY:maxY); 1125 | [rows,cols] = size(handles.x); 1126 | 1127 | [handles.u,handles.v] = deal(zeros(rows,cols,handles.N+1)); % 11.04.04, Alex 1128 | 1129 | for i = 1:handles.N 1130 | x = d(:,1,i); 1131 | tmp = d(x~=0,:,i); 1132 | y = tmp(:,2); 1133 | x = tmp(:,1); 1134 | for j = 1:length(x) 1135 | [m,n] = find(handles.x == x(j) & handles.y == y(j)); 1136 | handles.u(m,n,i) = tmp(j,3); 1137 | handles.v(m,n,i) = tmp(j,4); 1138 | end 1139 | end 1140 | 1141 | handles.xUnits = 'pix'; 1142 | handles.velUnits = 'pix/dt'; 1143 | 1144 | case{'.mat'} 1145 | tmp = load(handles.files{1}); % should be only one file 1146 | handles.x = tmp.x; 1147 | handles.y = tmp.y; 1148 | handles.u = tmp.u; 1149 | handles.v = tmp.v; 1150 | handles.uf = tmp.uf; 1151 | handles.vf = tmp.vf; 1152 | handles.files = tmp.files; 1153 | handles.path = tmp.path; 1154 | handles.dx = tmp.dx; 1155 | handles.dy = tmp.dy; 1156 | handles.dudx = tmp.dudx; 1157 | handles.dvdx = tmp.dvdx; 1158 | handles.dudy = tmp.dudy; 1159 | handles.dvdy = tmp.dvdy; 1160 | handles.gridX = tmp.gridX; 1161 | handles.gridY = tmp.gridY; 1162 | handles.N = tmp.N; 1163 | handles.xUnits = tmp.xUnits; 1164 | handles.velUnits = tmp.velUnits; 1165 | clear tmp 1166 | 1167 | otherwise 1168 | 1169 | end % of switch 1170 | catch 1171 | warndlg('Something wrong with vector files','Error','modal'); 1172 | set(handles.fig,'pointer','arrow'); 1173 | return 1174 | end 1175 | 1176 | 1177 | handles.dx = handles.x(1,2) - handles.x(1,1); 1178 | handles.dy = handles.y(2,1) - handles.y(1,1); % sometimes negative 1179 | handles.gridX = abs(handles.dx); 1180 | handles.gridY = abs(handles.dy); 1181 | 1182 | handles.current = 1; 1183 | set(handles.edit_current,'String',handles.current); 1184 | set(handles.edit_numfields,'String',handles.N); 1185 | 1186 | handles.numcolors = 10; 1187 | colormap(handles.axes_main,'jet'); 1188 | set(handles.edit_numcolors,'String', handles.numcolors); 1189 | 1190 | handles.arrow_scale = 1; % default scale 1191 | set(handles.edit_arrow_size,'String',handles.arrow_scale); 1192 | 1193 | set(handles.checkbox_modes,'Value',1); 1194 | set(handles.checkbox_reconstruction,'Value',0); 1195 | set(handles.radiobutton_multimode,'Value',0); 1196 | set(handles.edit_multimode,'Visible','off','Enable','off'); 1197 | 1198 | handles.color = 0; 1199 | handles.alltodisp = 0; 1200 | handles.allfields = 0; 1201 | handles.labelit = 0; 1202 | handles.colorbar_flag = 0; 1203 | handles.current_index = handles.current; 1204 | handles.distribOn=0; 1205 | handles.rowlock=0; handles.columnlock=0; 1206 | handles.previousSel=[]; 1207 | 1208 | handles.i=[]; 1209 | handles.j=[]; 1210 | handles.PointsH=[]; 1211 | handles.Allselected=0; 1212 | 1213 | 1214 | set(handles.spatial_controls,'Visible','off'); 1215 | set(handles.select_controls,'Visible','on'); 1216 | set(findobj(handles.select_controls,'type','uicontrol'),'Enable','On'); 1217 | % set(handles.uipanel_plotoptions,'Visible','on'); 1218 | % set(findobj(handles.uipanel_plotoptions,'type','uicontrol'),'Enable','On'); 1219 | % set(handles.checkbox_DirectSnapshot,'Enable','off'); 1220 | set(handles.pushbutton_select,'String','> Select <'); 1221 | set(handles.pushbutton_pod,'String','POD'); 1222 | 1223 | set(handles.popupmenu_quantity,'Visible','on'); 1224 | set(handles.popupmenu_quantity,'Value',1); 1225 | set(handles.popupmenu_contour_type,'Visible','on'); 1226 | set(handles.popupmenu_contour_type,'Value',1); 1227 | set(handles.popupmenu_eachfield,'Visible','on'); 1228 | set(handles.popupmenu_eachfield,'Value',1); 1229 | 1230 | set(handles.checkbox_arrow,'Enable','On'); 1231 | set(handles.edit_arrow_size,'Enable','On'); 1232 | set(handles.checkbox_reconstruction,'Enable','On'); 1233 | set(handles.checkbox_modes,'Enable','On'); 1234 | set(handles.popupmenu_quantity,'Enable','On'); 1235 | set(handles.pushbutton_previous,'Enable','On'); 1236 | set(handles.pushbutton_next,'Enable','On'); 1237 | set(handles.edit_current,'Enable','On'); 1238 | set(handles.pushbutton_animate,'Enable','On'); 1239 | set(handles.pushbutton_save_movie,'Enable','on'); 1240 | 1241 | set(handles.popupmenu_quantity,'String',handles.inst_list); 1242 | 1243 | handles.property = []; 1244 | 1245 | handles.select_options_panel = [... 1246 | handles.pushbutton_selectreg,... 1247 | handles.pushbutton_selectall,... 1248 | handles.pushbutton_reset,... 1249 | handles.pushbutton_start... 1250 | ]; 1251 | 1252 | handles.arrow_ctrls = [ ... 1253 | handles.edit_arrow_size,... 1254 | handles.checkbox_arrow,... 1255 | handles.checkbox_arrow_color... 1256 | ]; 1257 | 1258 | set(handles.pushbutton_pod,'Enable','Off'); 1259 | 1260 | set(handles.fig,'pointer','arrow'); 1261 | 1262 | set(handles.checkbox_DirectSnapshot,'Value',0); 1263 | % sizeU = size(handles.u); 1264 | % if (sizeU(1)*sizeU(2) > handles.N) 1265 | % set(handles.checkbox_DirectSnapshot,'Value',0); 1266 | % else 1267 | % set(handles.checkbox_DirectSnapshot,'Value',1); 1268 | % end 1269 | 1270 | guidata(handles.fig,handles); 1271 | 1272 | update_gui(handles.fig,[],handles); 1273 | 1274 | 1275 | function exit_Callback(hObject, eventdata, handles) 1276 | while ~strcmpi(get(hObject,'Type'),'figure'), 1277 | hObject = get(hObject,'Parent'); 1278 | end 1279 | delete(hObject); 1280 | 1281 | function pushbutton_pod_Callback(hObject, eventdata, handles) 1282 | 1283 | set(handles.spatial_controls,'Visible','on'); 1284 | set(handles.select_controls,'Visible','Off'); 1285 | set(handles.uipanel_relEnergy,'Visible','Off'); 1286 | set(handles.pushbutton_pod,'FontWeight','bold'); 1287 | set(handles.pushbutton_select,'FontWeight','normal'); 1288 | set(handles.pushbutton_pod,'String','>POD<'); 1289 | set(handles.pushbutton_select,'String','Select'); 1290 | val = get(handles.popupmenu_eachfield,'Value'); 1291 | if val == 4 1292 | set(handles.edit_min_clim,'Visible','On'); 1293 | set(handles.edit_max_clim,'Visible','On'); 1294 | set(handles.pushbutton_set_clim,'Visible','On'); 1295 | end 1296 | 1297 | handles.i = []; handles.j = []; 1298 | handles.rowlock=0; handles.columnlock=0; 1299 | handles.previousSel=[]; 1300 | 1301 | update_gui(gcbo,[],guidata(gcbo)); 1302 | guidata(handles.fig,handles); 1303 | 1304 | 1305 | function pushbutton_select_Callback(hObject, eventdata, handles) 1306 | set(handles.spatial_controls,'Visible','Off'); 1307 | set(handles.select_controls,'Visible','on'); 1308 | set(handles.uipanel_relEnergy,'Visible','on'); 1309 | set(findobj(handles.select_controls,'type','uicontrol'),'Enable','On'); 1310 | set(handles.pushbutton_select,'String','> Select <'); 1311 | set(handles.pushbutton_pod,'String','POD'); 1312 | 1313 | 1314 | set(handles.pushbutton_pod,'FontWeight','normal'); 1315 | set(handles.pushbutton_select,'FontWeight','bold'); 1316 | val = get(handles.popupmenu_eachfield,'Value'); 1317 | handles.i = []; handles.j = []; 1318 | handles.rowlock=0; handles.columnlock=0; 1319 | handles.previousSel=[]; 1320 | 1321 | update_gui(gcbo,[],guidata(gcbo)); 1322 | guidata(handles.fig,handles); 1323 | 1324 | 1325 | function pushbutton_selectreg_Callback(hObject, eventdata, handles) 1326 | set(findobj(handles.uipanel_relEnergy,'type','uicontrol'),'Enable','Off'); 1327 | set(findobj(handles.uipanel_relEnergy,'type','uicontrol'),'Enable','Off'); 1328 | set(findobj(handles.select_controls,'type','uicontrol'),'Enable','Off'); 1329 | 1330 | set(handles.region_text,'Visible','on','Enable','on'); 1331 | 1332 | k = waitforbuttonpress; 1333 | point1 = get(gca,'CurrentPoint'); 1334 | finalRect = rbbox; 1335 | point2 = get(gca,'CurrentPoint'); 1336 | point1 = point1(1,1:2); 1337 | point2 = point2(1,1:2); 1338 | p1 = min(point1,point2); 1339 | Offset = abs(point1-point2); 1340 | 1341 | 1342 | limX = xlim; limY = ylim; 1343 | leftcolX = fix(( p1(1)-limX(1,1) )/ handles.gridX +1) + 1; 1344 | rightcolX = fix(( p1(1)+Offset(1)-limX(1,1) )/ handles.gridX )+1; 1345 | bottomrowY = fix(( p1(2)-limY(1,1) )/ handles.gridY+1 )+1; 1346 | uprowY = fix(( p1(2) + Offset(2) - limY(1,1) )/ handles.gridY)+1; 1347 | 1348 | 1349 | plotstateX=0;plotstateY=0; 1350 | if leftcolX<1 leftcolX=1; 1351 | plotstateY= 1; 1352 | end; 1353 | rightLimit=fix((limX(1,2)-limX(1,1))/handles.gridX)+1; 1354 | if rightcolX>rightLimit rightcolX=rightLimit; end; 1355 | uprowLimit=fix((limY(1,2)-limY(1,1))/handles.gridY)+1; 1356 | if bottomrowY<1 bottomrowY=1; 1357 | plotstateX= 1; 1358 | end 1359 | if uprowY>uprowLimit uprowY=uprowLimit; end; 1360 | 1361 | 1362 | 1363 | sizeI = size(handles.i,1); 1364 | sizeJ = size(handles.j,1); 1365 | numofcols = rightcolX-leftcolX+1; 1366 | numofrows = uprowY-bottomrowY+1; 1367 | 1368 | 1369 | if ~isempty(handles.previousSel) 1370 | a = handles.previousSel; 1371 | if ((rightcolX-leftcolX) == a(2)-a(1) && a(2) == rightcolX && handles.rowlock~=1) 1372 | handles.columnlock=1; 1373 | elseif ((uprowY-bottomrowY)==a(4)-a(3) && a(4)==uprowY && handles.columnlock~=1) 1374 | handles.rowlock=1; 1375 | else 1376 | warndlg('Your Selection is Invalid...','Error','modal'); 1377 | set(findobj(handles.select_controls,'type','uicontrol'),'Enable','On'); 1378 | set(handles.region_text,'Visible','off'); 1379 | return; 1380 | return; 1381 | end 1382 | end 1383 | 1384 | if sizeI 1385 | if ismember([bottomrowY leftcolX],[handles.i handles.j],'rows') || ismember([bottomrowY rightcolX],[handles.i handles.j],'rows') || ... 1386 | ismember([uprowY leftcolX],[handles.i handles.j],'rows') || ismember([uprowY rightcolX],[handles.i handles.j],'rows') 1387 | warndlg('Your Selection is Invalid...','Error','modal'); 1388 | set(findobj(handles.select_controls,'type','uicontrol'),'Enable','On'); 1389 | 1390 | set(handles.region_text,'Visible','off'); 1391 | return; 1392 | end 1393 | end 1394 | 1395 | for i1 = bottomrowY:uprowY 1396 | handles.i(sizeI+1:sizeI+numofcols,1) = i1; 1397 | handles.j(sizeJ+1:sizeJ+numofcols,1) = leftcolX:rightcolX; 1398 | sizeI = sizeI+numofcols; 1399 | sizeJ = sizeJ+numofcols; 1400 | end 1401 | 1402 | lx_box=limX(1,1)+(leftcolX-1)*handles.gridX*~plotstateY; 1403 | rx_box=limX(1,1)+(rightcolX-1)*handles.gridX; 1404 | uy_box=limY(1,1)+(uprowY-1)*handles.gridY; 1405 | by_box=limY(1,1)+(bottomrowY-1)*handles.gridY*~plotstateX; 1406 | 1407 | 1408 | x1 = [lx_box rx_box rx_box lx_box lx_box]; 1409 | y1 = [by_box by_box uy_box uy_box by_box]; 1410 | hold on 1411 | handles.selectionbox = plot(x1,y1,'--b','LineWidth',1.5); 1412 | hold off 1413 | handles.previousSel=[leftcolX rightcolX bottomrowY uprowY]; 1414 | 1415 | set(findobj(handles.select_controls,'type','uicontrol'),'Enable','On'); 1416 | set(handles.pushbutton_selectreg,'Enable','Off'); 1417 | set(handles.pushbutton_selectall,'Enable','Off'); 1418 | set(handles.region_text,'Visible','off'); 1419 | 1420 | sizeU = (handles.i(length(handles.i))-handles.i(1)+1)*(handles.j(length(handles.j))-handles.j(1)+1); 1421 | if (sizeU > handles.N) 1422 | set(handles.checkbox_DirectSnapshot,'Value',0); 1423 | else 1424 | set(handles.checkbox_DirectSnapshot,'Value',1); 1425 | end 1426 | % set(handles.checkbox_DirectSnapshot,'Enable','off'); 1427 | 1428 | guidata(handles.fig,handles); 1429 | 1430 | function pushbutton_selectall_Callback(hObject, eventdata, handles) 1431 | set(handles.pushbutton_selectreg,'Enable','Off'); 1432 | set(handles.pushbutton_selectall,'Enable','Off'); 1433 | handles.Allselected=1; 1434 | update_gui(hObject,[],guidata(hObject)); 1435 | handles.i=[]; handles.j=[]; handles.previousSel=[]; 1436 | limX=xlim; limY=ylim; 1437 | x1 = [limX(1,1) limX(1,2) limX(1,2) limX(1,1) limX(1,1)]; 1438 | y1 = [limY(1,1) limY(1,1) limY(1,2) limY(1,2) limY(1,1)]; 1439 | hold on 1440 | handles.selectionbox = plot(x1,y1,':b','LineWidth',4); 1441 | hold off 1442 | leftcolX = 1; 1443 | rightcolX = fix((limX(1,2)-limX(1,1))/handles.gridX)+1; 1444 | bottomrowY = 1; 1445 | uprowY = fix((limY(1,2)-limY(1,1))/handles.gridY)+1; 1446 | numofcols=rightcolX-leftcolX+1; 1447 | sizeI=size(handles.i,1); 1448 | sizeJ=size(handles.j,1); 1449 | for i1 = bottomrowY:uprowY 1450 | handles.i(sizeI+1:sizeI+numofcols,1)=i1; 1451 | handles.j(sizeJ+1:sizeJ+numofcols,1)=leftcolX:rightcolX; 1452 | sizeI=sizeI+numofcols; sizeJ=sizeJ+numofcols; 1453 | end 1454 | sizeU = (handles.i(length(handles.i))-handles.i(1)+1)*(handles.j(length(handles.j))-handles.j(1)+1); 1455 | if (sizeU > handles.N) 1456 | set(handles.checkbox_DirectSnapshot,'Value',0); 1457 | else 1458 | set(handles.checkbox_DirectSnapshot,'Value',1); 1459 | end 1460 | 1461 | % set(handles.checkbox_DirectSnapshot,'Enable','off'); 1462 | 1463 | guidata(handles.fig,handles); 1464 | 1465 | function pushbutton_reset_Callback(hObject, eventdata, handles) 1466 | 1467 | handles.i = []; handles.j = []; 1468 | handles.rowlock=0; handles.columnlock=0; 1469 | handles.previousSel=[]; 1470 | set(handles.pushbutton_selectreg,'Enable','on'); 1471 | set(handles.pushbutton_selectall,'Enable','on'); 1472 | set(findobj(handles.uipanel_relEnergy,'type','uicontrol'),'Enable','Off'); 1473 | set(findobj(handles.uipanel_plotoptions,'type','uicontrol'),'Enable','Off'); 1474 | guidata(handles.fig,handles); 1475 | update_gui(gcbo,[],guidata(gcbo)); 1476 | 1477 | 1478 | function figure_pod_CreateFcn(hObject, eventdata, handles) 1479 | 1480 | tmp = load('CIL_small_logo.mat'); 1481 | imshow(tmp.im,tmp.map); 1482 | axis off 1483 | 1484 | 1485 | function axes_main_CreateFcn(hObject, eventdata, handles) 1486 | 1487 | handles.axes_main = hObject; 1488 | axis ij; 1489 | guidata(hObject, handles); 1490 | 1491 | 1492 | function hh = quiverc(varargin) 1493 | alpha = 0.33; 1494 | beta = 0.33; 1495 | autoscale = 1; 1496 | plotarrows = 1; 1497 | sym = ''; 1498 | 1499 | filled = 0; 1500 | ls = '-'; 1501 | ms = ''; 1502 | col = ''; 1503 | 1504 | nin = nargin; 1505 | 1506 | while isstr(varargin{nin}), 1507 | vv = varargin{nin}; 1508 | if ~isempty(vv) & strcmp(lower(vv(1)),'f') 1509 | filled = 1; 1510 | nin = nin-1; 1511 | else 1512 | [l,c,m,msg] = colstyle(vv); 1513 | if ~isempty(msg), 1514 | error(sprintf('Unknown option "%s".',vv)); 1515 | end 1516 | if ~isempty(l), ls = l; end 1517 | if ~isempty(c), col = c; end 1518 | if ~isempty(m), ms = m; plotarrows = 0; end 1519 | if isequal(m,'.'), ms = ''; end 1520 | nin = nin-1; 1521 | end 1522 | end 1523 | 1524 | error(nargchk(2,6,nin)); 1525 | 1526 | 1527 | if nin<4, 1528 | [msg,x,y,u,v] = xyzchk(varargin{1:2}); 1529 | else 1530 | [msg,x,y,u,v] = xyzchk(varargin{1:4}); 1531 | end 1532 | if ~isempty(msg), error(msg); end 1533 | 1534 | if nin==4 | nin==6, 1535 | autoscale = varargin{nin-1}; 1536 | z = varargin{nin}; 1537 | end 1538 | 1539 | if prod(size(u))==1, u = u(ones(size(x))); end 1540 | if prod(size(v))==1, v = v(ones(size(u))); end 1541 | 1542 | if autoscale, 1543 | if min(size(x))==1 1544 | n=sqrt(prod(size(x))); 1545 | m=n; 1546 | else 1547 | [m,n]=size(x); 1548 | end 1549 | delx = diff([min(x(:)) max(x(:))])/n; 1550 | dely = diff([min(y(:)) max(y(:))])/m; 1551 | del = delx.^2 + dely.^2; 1552 | if del>0 1553 | len = sqrt((u.^2 + v.^2)/del); 1554 | maxlen = max(len(:)); 1555 | else 1556 | maxlen = 0; 1557 | end 1558 | 1559 | if maxlen>0 1560 | autoscale = autoscale*0.9 / maxlen; 1561 | else 1562 | autoscale = autoscale*0.9; 1563 | end 1564 | u = u*autoscale; v = v*autoscale; 1565 | end 1566 | 1567 | 1568 | ax = newplot; 1569 | next = lower(get(ax,'NextPlot')); 1570 | hold_state = ishold; 1571 | 1572 | x = x(:).'; y = y(:).'; 1573 | u = u(:).'; v = v(:).'; 1574 | uu = [x;x+u;repmat(NaN,size(u))]; 1575 | vv = [y;y+v;repmat(NaN,size(u))]; 1576 | 1577 | z = [z(:)';z(:)';NaN*z(:)']; 1578 | 1579 | h1 = patch([uu(:),uu(:)],[vv(:),vv(:)], [z(:),z(:)],'Parent',ax,'EdgeColor','Flat','FaceColor','None'); 1580 | 1581 | if plotarrows, 1582 | hu = [x+u-alpha*(u+beta*(v+eps));x+u; ... 1583 | x+u-alpha*(u-beta*(v+eps));repmat(NaN,size(u))]; 1584 | hv = [y+v-alpha*(v-beta*(u+eps));y+v; ... 1585 | y+v-alpha*(v+beta*(u+eps));repmat(NaN,size(v))]; 1586 | hold on 1587 | z = [z(1,:); z]; 1588 | h2 = patch([hu(:),hu(:)],[hv(:),hv(:)], [z(:),z(:)],'Parent',ax,'EdgeColor','Flat','FaceColor','None'); 1589 | 1590 | else 1591 | h2 = []; 1592 | end 1593 | 1594 | if ~isempty(ms), 1595 | hu = x; hv = y; 1596 | hold on 1597 | h3 = plot(hu(:),hv(:),[col ms]); 1598 | if filled, set(h3,'markerfacecolor',get(h1,'color')); end 1599 | else 1600 | h3 = []; 1601 | end 1602 | 1603 | if ~hold_state, hold off, view(2); set(ax,'NextPlot',next); end 1604 | 1605 | if nargout > 0, hh = [h1;h2;h3]; end 1606 | 1607 | function ed_max_CreateFcn(hObject, eventdata, handles) 1608 | if ispc 1609 | set(hObject,'BackgroundColor','white'); 1610 | else 1611 | set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); 1612 | end 1613 | 1614 | 1615 | 1616 | function export2figure_Callback(hObject, eventdata, handles) 1617 | handles.export_figure = figure; 1618 | copyobj(handles.axes_main,handles.export_figure); 1619 | 1620 | set(handles.export_figure,'Units','normalized'); 1621 | set(get(handles.export_figure,'children'),'Units','normalized'); 1622 | set(get(handles.export_figure,'children'),'Position',[0.13 0.11 0.775 0.815]); 1623 | set(get(handles.export_figure,'children'),'Box','on'); 1624 | 1625 | % if isfield(handles,'color_flag') 1626 | if handles.colorbar_flag 1627 | hcol=colorbar('v6'); 1628 | set(handles.axes_main,'Units','normalized'); 1629 | axpos = get(gca,'Position'); 1630 | set(hcol,'Units','normalized','Position',[axpos(1)+axpos(3)+0.018+0.04,axpos(2),0.020,axpos(4)]); 1631 | set(gca,'Position',[axpos(1),axpos(2),axpos(3)+0.04,axpos(4)]); 1632 | end 1633 | % end 1634 | guidata(handles.fig, handles); 1635 | 1636 | 1637 | function pushbutton_start_Callback(hObject, eventdata, handles) 1638 | 1639 | 1640 | if ~isempty(handles.i) 1641 | 1642 | size_x = size(handles.x); 1643 | 1644 | sel_row_start = size_x(1) - handles.i(length(handles.i))+1; 1645 | sel_row_end = size_x(1) - handles.i(1)+1; 1646 | 1647 | handles.x = handles.x(sel_row_start:sel_row_end, handles.j(1):handles.j(length(handles.j)) ); 1648 | handles.y = handles.y(sel_row_start:sel_row_end, handles.j(1):handles.j(length(handles.j)) ); 1649 | handles.u = handles.u(sel_row_start:sel_row_end, handles.j(1):handles.j(length(handles.j)),: ); 1650 | handles.v = handles.v(sel_row_start:sel_row_end, handles.j(1):handles.j(length(handles.j)),:); 1651 | 1652 | if min(size(handles.x)) < 2 1653 | warndlg('The region is N x 1, select at least 2 rows or 2 columns','Error','modal'); 1654 | return 1655 | end 1656 | 1657 | set(handles.pushbutton_reset,'Enable','off'); 1658 | 1659 | handles.METHOD_FLAG = get(handles.checkbox_DirectSnapshot,'Value'); 1660 | 1661 | clear pod 1662 | try 1663 | [L] = poduv(handles,1); 1664 | catch 1665 | warndlg('Computation of POD modes failed due to memory problem'); 1666 | end 1667 | 1668 | axes(handles.axes_main); 1669 | set(handles.export2figure,'Enable','on'); 1670 | delete(get(handles.axes_main,'children')); 1671 | handles.Erel = cumsum(L(1:end))/sum(L(1:end)); 1672 | plot(1:length(handles.Erel),handles.Erel*100) 1673 | 1674 | set(handles.checkbox_DirectSnapshot,'Enable','off'); 1675 | set(handles.pushbutton_start,'Enable','off'); 1676 | 1677 | 1678 | set(get(handles.axes_main,'xlabel'),'string','Number of modes') 1679 | set(get(handles.axes_main,'ylabel'),'string','Cummulative relative energy, %') 1680 | 1681 | set(handles.uipanel_relEnergy,'Visible','On'); 1682 | set(get(handles.uipanel_relEnergy,'Children'),'Visible','On','Enable','On'); 1683 | 1684 | set(handles.uipanel_plotoptions,'Visible','On'); 1685 | set(get(handles.uipanel_plotoptions,'Children'),'Visible','On','Enable','On'); 1686 | 1687 | handles.relEnergy = max(handles.Erel); 1688 | set(handles.edit_relEnergy,'String',num2str(100*handles.relEnergy)); 1689 | set(handles.edit_numOfModes,'String',num2str(length(L))); 1690 | handles.Energy=L; 1691 | guidata(handles.fig,handles); 1692 | else 1693 | warndlg('Select region of interest','Error','modal'); 1694 | end 1695 | 1696 | 1697 | 1698 | function edit_relEnergy_Callback(hObject, eventdata, handles) 1699 | handles.relEnergy = str2double(get(hObject,'String'))/100; 1700 | if handles.relEnergy > 1 | isnan(handles.relEnergy) 1701 | handles.relEnergy = 1; 1702 | set(handles.edit_relEnergy,'String',int2str(handles.relEnergy*100)); 1703 | elseif handles.relEnergy < 0.01 1704 | handles.relEnergy = 0.01; 1705 | set(handles.edit_relEnergy,'String',int2str(handles.relEnergy*100)); 1706 | end 1707 | handles.numOfModes = min(find(handles.Erel >= handles.relEnergy)); 1708 | set(handles.edit_numOfModes,'String',int2str(handles.numOfModes)); 1709 | handles.METHOD_FLAG = get(handles.checkbox_DirectSnapshot,'Value'); 1710 | guidata(handles.fig,handles); 1711 | 1712 | function edit_relEnergy_CreateFcn(hObject, eventdata, handles) 1713 | 1714 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 1715 | set(hObject,'BackgroundColor','white'); 1716 | end 1717 | 1718 | function edit_numOfModes_Callback(hObject, eventdata, handles) 1719 | 1720 | handles.numOfModes = str2double(get(hObject,'String')); 1721 | if handles.numOfModes > handles.N | isnan(handles.numOfModes) 1722 | handles.numOfModes = handles.N; 1723 | set(handles.edit_numOfModes,'String',int2str(handles.numOfModes)); 1724 | elseif handles.numOfModes < 1 1725 | handles.numOfModes = 1; 1726 | set(handles.edit_numOfModes,'String',int2str(handles.numOfModes)); 1727 | end 1728 | handles.relEnergy = handles.Erel(handles.numOfModes); 1729 | set(handles.edit_relEnergy,'String',sprintf('%3.0f',100*handles.relEnergy)); 1730 | guidata(handles.fig,handles); 1731 | 1732 | 1733 | function edit_numOfModes_CreateFcn(hObject, eventdata, handles) 1734 | 1735 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 1736 | set(hObject,'BackgroundColor','white'); 1737 | end 1738 | 1739 | 1740 | function pushbutton_continue_Callback(hObject, eventdata, handles) 1741 | edit_numOfModes_Callback(handles.edit_numOfModes,[], handles) 1742 | handles.numOfModes = str2double(get(handles.edit_numOfModes,'String')); 1743 | 1744 | [handles.umodes,handles.vmodes] = poduv(handles,2); 1745 | 1746 | handles.current = 1; 1747 | set(handles.edit_current,'String',handles.current); 1748 | set(handles.edit_numfields,'String',handles.numOfModes); 1749 | set(handles.edit_multimode,'String',['1:',int2str(handles.numOfModes)]); 1750 | set(handles.edit_SelectedModes,'String',['1:',int2str(handles.numOfModes)]); 1751 | handles.numcolors = 10; 1752 | set(handles.edit_numcolors,'String', handles.numcolors); 1753 | 1754 | handles.arrow_scale = 1; 1755 | set(handles.edit_arrow_size,'String',handles.arrow_scale); 1756 | 1757 | set(handles.checkbox_modes,'Value',1); 1758 | 1759 | 1760 | handles.color = 0; 1761 | handles.alltodisp = 0; 1762 | handles.allfields = 0; 1763 | handles.labelit = 0; 1764 | handles.colorbar_flag = 0; 1765 | handles.current_index = handles.current; 1766 | handles.distribOn = 0; 1767 | handles.rowlock = 0; 1768 | handles.columnlock = 0; 1769 | handles.previousSel = []; 1770 | 1771 | set(handles.spatial_controls,'Visible','on'); 1772 | set(handles.select_controls,'Visible','Off'); 1773 | set(handles.uipanel_relEnergy,'Visible','Off'); 1774 | set(handles.uipanel_plotoptions,'Visible','Off'); 1775 | 1776 | set(findobj(handles.spatial_controls,'type','uicontrol'),'Enable','On'); 1777 | set(findobj(handles.select_controls,'type','uicontrol'),'Enable','Off'); 1778 | set(findobj(handles.uipanel_relEnergy,'type','uicontrol'),'Enable','Off'); 1779 | set(findobj(handles.uipanel_plotoptions,'type','uicontrol'),'Enable','Off'); 1780 | set(handles.pushbutton_pod,'FontWeight','bold'); 1781 | set(handles.pushbutton_select,'FontWeight','normal'); 1782 | set(handles.pushbutton_select,'String','Select'); 1783 | set(handles.pushbutton_select,'Enable','Off'); 1784 | set(handles.pushbutton_pod,'String','>POD<'); 1785 | set(handles.pushbutton_pod,'Enable','on'); 1786 | set(handles.pushbutton_pod,'Enable','Off'); 1787 | 1788 | set(handles.popupmenu_quantity,'Visible','on'); 1789 | set(handles.popupmenu_quantity,'Value',1); 1790 | set(handles.popupmenu_contour_type,'Visible','on'); 1791 | set(handles.popupmenu_contour_type,'Value',1); 1792 | set(handles.popupmenu_eachfield,'Visible','on'); 1793 | set(handles.popupmenu_eachfield,'Value',1); 1794 | 1795 | set(handles.checkbox_arrow,'Enable','On'); 1796 | set(handles.edit_arrow_size,'Enable','On'); 1797 | set(handles.checkbox_reconstruction,'Enable','On'); 1798 | set(handles.edit_SelectedModes,'Enable','off','Visible','off'); 1799 | set(handles.checkbox_modes,'Enable','On'); 1800 | set(handles.radiobutton_weights,'Value',0, 'Enable','off'); 1801 | set(handles.popupmenu_quantity,'Enable','On'); 1802 | set(handles.pushbutton_previous,'Enable','On'); 1803 | set(handles.pushbutton_next,'Enable','On'); 1804 | set(handles.edit_current,'Enable','On'); 1805 | set(handles.pushbutton_animate,'Enable','On'); 1806 | set(handles.pushbutton_save_movie,'Enable','on'); 1807 | 1808 | set(handles.popupmenu_quantity,'String',handles.inst_list); 1809 | 1810 | handles.property = []; 1811 | 1812 | set(handles.fig,'pointer','arrow'); 1813 | 1814 | % set(handles.checkbox_reconstruction,'Value',0, 'Enable','off'); 1815 | % set(handles.radiobutton_multimode,'Value',0, 'Enable','off'); 1816 | %menuhandle=get(handles.File,'Children'); 1817 | set(get(handles.File,'Children'),'Enable','on'); 1818 | 1819 | guidata(handles.fig,handles); 1820 | 1821 | update_gui(handles.fig,[],handles); 1822 | 1823 | 1824 | function radiobutton_multimode_Callback(hObject, eventdata, handles) 1825 | set(handles.radiobutton_multimode,'Value',1); 1826 | % if get(hObject,'Value') == 1 1827 | set(handles.checkbox_modes,'Value',0); 1828 | set(handles.checkbox_reconstruction,'Value',0); 1829 | set(handles.edit_multimode,'Visible','on','Enable','on'); 1830 | set(handles.edit_SelectedModes,'Visible','off','Enable','off'); 1831 | set(handles.radiobutton_weights,'Visible','on','Enable','on','Value',0); 1832 | set(handles.edit_min_clim,'Visible','Off'); 1833 | set(handles.edit_max_clim,'Visible','Off'); 1834 | set(handles.pushbutton_set_clim,'Visible','Off'); 1835 | handles.alltodisp = 0; 1836 | handles.allfields = 0; 1837 | % end 1838 | 1839 | set(findobj(handles.flow_field_panel,'type','uicontrol'),'Enable','off'); 1840 | % handles.uRec = sum(handles.umodes(:,:,handles.multimode(1):handles.multimode(2)),3); % sum of all modes 1841 | % handles.vRec = 1842 | % sum(handles.vmodes(:,:,handles.multimode(1):handles.multimode(2)),3); 1843 | 1844 | try 1845 | handles.multimode = sort(eval(['[',get(handles.edit_multimode,'String'),']'])); 1846 | catch 1847 | warndlg('Wrong input: e.g. 1 5 or 1,5 or 1:5 or 1:2:5','Error','modal'); 1848 | end 1849 | 1850 | if min(size(handles.multimode)) ~= 1 | ~isempty(findstr(get(handles.edit_multimode,'String'),'.')) % | max(size(handles.multimode)) ~= 2 1851 | warndlg('Wrong input: e.g. 1 5 or 1,5 or 1:5 or 1:2:5','Error','modal'); 1852 | elseif (handles.multimode(1) < 1 | max(handles.multimode) > handles.numOfModes) 1853 | warndlg('Input must be in the range of 1 - number of modes','Error','modal'); 1854 | end 1855 | 1856 | handles.uRec = sum(handles.umodes(:,:,handles.multimode),3); % sum of all modes 1857 | handles.vRec = sum(handles.vmodes(:,:,handles.multimode),3); 1858 | handles.current = 1; 1859 | set(handles.popupmenu_eachfield,'String','Automatic|---|---|Manual'); 1860 | 1861 | set(handles.popupmenu_quantity,'Value',1); 1862 | handles.property = []; handles.C = []; handles.CH = []; 1863 | 1864 | guidata(handles.fig,handles); 1865 | update_gui(handles.fig,[],handles); 1866 | 1867 | 1868 | function edit_multimode_Callback(hObject, eventdata, handles) 1869 | 1870 | try 1871 | handles.multimode = sort(eval(['[',get(handles.edit_multimode,'String'),']'])); 1872 | catch 1873 | warndlg('Wrong input: e.g. 1 5 or 1,5 or 1:5 or 1:2:5','Error','modal'); 1874 | end 1875 | 1876 | if min(size(handles.multimode)) ~= 1 | ~isempty(findstr(get(handles.edit_multimode,'String'),'.')) % | max(size(handles.multimode)) ~= 2 1877 | warndlg('Wrong input: e.g. 1 5 or 1,5 or 1:5 or 1:2:5','Error','modal'); 1878 | elseif (handles.multimode(1) < 1 | max(handles.multimode) > handles.numOfModes) 1879 | warndlg('Input must be in the range of 1 - number of modes','Error','modal'); 1880 | else 1881 | if get(handles.radiobutton_weights,'Value') == 0 1882 | handles.uRec = sum(handles.umodes(:,:,handles.multimode),3); 1883 | handles.vRec = sum(handles.vmodes(:,:,handles.multimode),3); 1884 | % handles.vRec = sum(handles.vmodes(:,:,handles.multimode(1):handles.multimode(2)),3); 1885 | 1886 | else 1887 | [handles.uRec,handles.vRec] = poduv(handles,4); 1888 | end 1889 | handles.current = 1; 1890 | guidata(handles.fig,handles); 1891 | popupmenu_quantity_Callback(handles.fig, [], handles); 1892 | end 1893 | 1894 | function edit_multimode_CreateFcn(hObject, eventdata, handles) 1895 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 1896 | set(hObject,'BackgroundColor','white'); 1897 | end 1898 | 1899 | 1900 | function radiobutton_weights_Callback(hObject, eventdata, handles) 1901 | 1902 | if get(handles.radiobutton_weights,'Value') == 0 1903 | % handles.uRec = sum(handles.umodes(:,:,handles.multimode(1):handles.multimode(2)),3); 1904 | % handles.vRec = sum(handles.vmodes(:,:,handles.multimode(1):handles.multimode(2)),3); 1905 | handles.uRec = sum(handles.umodes(:,:,handles.multimode),3); 1906 | handles.vRec = sum(handles.vmodes(:,:,handles.multimode),3); 1907 | else 1908 | [handles.uRec,handles.vRec] = poduv(handles,4); 1909 | end 1910 | guidata(handles.fig,handles); 1911 | popupmenu_quantity_Callback(handles.fig, [], handles); 1912 | 1913 | 1914 | 1915 | function edit_numfields_Callback(hObject, eventdata, handles) 1916 | guidata(handles.fig,handles); 1917 | 1918 | function checkbox_DirectSnapshot_Callback(hObject, eventdata, handles) 1919 | guidata(handles.fig,handles); 1920 | 1921 | 1922 | % -------------------------------------------------------------------- 1923 | function export2csv_Callback(hObject, eventdata, handles) 1924 | % hObject handle to export2csv (see GCBO) 1925 | % eventdata reserved - to be defined in a future version of MATLAB 1926 | % handles structure with handles and user data (see GUIDATA) 1927 | 1928 | 1929 | % LEARN MATLAB TRICKS: VECTORIZE YOUR LOOPS :-) 1930 | % in addition, it was some mismatch between ind and 1931 | % the size of matr. 1932 | % Alex, 05.10.2005 1933 | 1934 | % ind=1; 1935 | % for x_val=1:length(handles.x); 1936 | % for y_val=1:length(handles.y); 1937 | % matr(ind,1)=x_val; 1938 | % matr(ind,2)=y_val; 1939 | % ind=ind+1; 1940 | % end; 1941 | % end; 1942 | 1943 | matr = zeros(length(handles.x(:)),5); 1944 | matr(:,1) = handles.x(:); 1945 | matr(:,2) = handles.y(:); 1946 | 1947 | if get(handles.checkbox_modes,'Value') == 1 % in case of single mode 1948 | matr(:,3) = reshape(handles.umodes(:,:,handles.current),[],1); 1949 | matr(:,4) = reshape(handles.vmodes(:,:,handles.current),[],1); 1950 | else % in case of multimode or reconstruction 1951 | matr(:,3) = reshape(handles.uRec,[],1); 1952 | matr(:,4) = reshape(handles.vRec,[],1); 1953 | end; 1954 | 1955 | if (get(handles.popupmenu_quantity,'Value') > 1 | handles.color == 1) %save quantity if needed 1956 | matr(:,5) = reshape(handles.property,[],1); 1957 | else 1958 | matr = matr(:,1:4); 1959 | end 1960 | 1961 | clear file 1962 | file = inputdlg('File Name','Input Name for CSV File'); 1963 | if ~isempty(file) 1964 | csvwrite(file{1},matr); 1965 | else 1966 | warndlg('Choose a valid file name !!! ','Error','modal'); 1967 | end; 1968 | 1969 | 1970 | 1971 | 1972 | % --- Executes on button press in SaveCVSEnergy. 1973 | function SaveCVSEnergy_Callback(hObject, eventdata, handles) 1974 | matr(:,1) = 1:length(handles.Energy); 1975 | matr(:,2) = handles.Energy; 1976 | clear file 1977 | file = inputdlg('File Name','Input Name for CSV File'); 1978 | if ~isempty(file) 1979 | csvwrite(file{1},matr); 1980 | else 1981 | warndlg('Choose a valid file name !!! ','Error','modal'); 1982 | end; 1983 | 1984 | 1985 | % hObject handle to SaveCVSEnergy (see GCBO) 1986 | % eventdata reserved - to be defined in a future version of MATLAB 1987 | % handles structure with handles and user data (see GUIDATA) 1988 | 1989 | 1990 | % --- Executes on button press in checkbox_loglog. 1991 | function checkbox_loglog_Callback(hObject, eventdata, handles) 1992 | axes(handles.axes_main); 1993 | delete(get(handles.axes_main,'children')); 1994 | if get(handles.checkbox_loglog,'Value') == 1 1995 | loglog(1:length(handles.Erel),handles.Erel*100); 1996 | grid on; 1997 | else 1998 | plot(1:length(handles.Erel),handles.Erel*100); 1999 | end; 2000 | set(get(handles.axes_main,'xlabel'),'string','Number of modes') 2001 | set(get(handles.axes_main,'ylabel'),'string','Cummulative relative energy, %') 2002 | % hObject handle to checkbox_loglog (see GCBO) 2003 | % eventdata reserved - to be defined in a future version of MATLAB 2004 | % handles structure with handles and user data (see GUIDATA) 2005 | 2006 | % Hint: get(hObject,'Value') returns toggle state of checkbox_loglog 2007 | 2008 | 2009 | 2010 | 2011 | 2012 | function edit_SelectedModes_Callback(hObject, eventdata, handles) 2013 | % hObject handle to edit_SelectedModes (see GCBO) 2014 | % eventdata reserved - to be defined in a future version of MATLAB 2015 | % handles structure with handles and user data (see GUIDATA) 2016 | 2017 | % Hints: get(hObject,'String') returns contents of edit_SelectedModes as text 2018 | % str2double(get(hObject,'String')) returns contents of edit_SelectedModes as a double 2019 | 2020 | try 2021 | handles.SelectedModes = sort(eval(['[',get(handles.edit_SelectedModes,'String'),']',])); 2022 | catch 2023 | warndlg('Wrong input: e.g. 1,3,5 or 1:2:5 or 1:5','Error','modal'); 2024 | end 2025 | 2026 | if min(size(handles.SelectedModes)) ~= 1 | ~isempty(findstr(get(handles.edit_SelectedModes,'String'),'.'))% | max(size(handles.SelectedModes)) ~= 2 2027 | warndlg('Wrong input: e.g. 1,3,5 or 1:2:5 or 1:5','Error','modal'); 2028 | elseif ( handles.SelectedModes(1) < 1 | max(handles.SelectedModes) > handles.numOfModes) 2029 | warndlg('Input must be in the range of 1:number of modes','Error','modal'); 2030 | else 2031 | [handles.uRec, handles.vRec] = poduv(handles,3); 2032 | % handles.current = 1; 2033 | % handles.property = []; 2034 | % handles.C = []; 2035 | % handles.CH = []; 2036 | guidata(handles.fig,handles); 2037 | popupmenu_quantity_Callback(handles.fig, [], handles); 2038 | % update_gui(handles.fig,[],handles); 2039 | end 2040 | 2041 | 2042 | 2043 | % --- Executes during object creation, after setting all properties. 2044 | function edit_SelectedModes_CreateFcn(hObject, eventdata, handles) 2045 | % hObject handle to edit_SelectedModes (see GCBO) 2046 | % eventdata reserved - to be defined in a future version of MATLAB 2047 | % handles empty - handles not created until after all CreateFcns called 2048 | 2049 | % Hint: edit controls usually have a white background on Windows. 2050 | % See ISPC and COMPUTER. 2051 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 2052 | set(hObject,'BackgroundColor','white'); 2053 | end 2054 | 2055 | 2056 | -------------------------------------------------------------------------------- /Matlab/poduv.m: -------------------------------------------------------------------------------- 1 | function [varargout] = poduv(handles,step,varargin) 2 | % PODUV is the Proper Orthogonal Decomposition of U,V velocity fields 3 | % 4 | 5 | % Copyright (c) 2003 Alex Liberzon and Roi Gurka 6 | persistent r c N len U meanU Uf V D L I a phi 7 | 8 | % dbstop if caught error MATLAB:nonExistentField 9 | 10 | switch step 11 | case{1} % first time we call the function 12 | 13 | [r,c,N] = size(handles.u); % 4-D is the number of files 14 | 15 | len = r*c; 16 | 17 | U = zeros(len*2,N); % r*c*3 length of the vector 18 | 19 | % small rearrangement 20 | for i = 1:N 21 | U(1:len,i) = reshape(handles.u(:,:,i),len,1); 22 | U(len+1:2*len,i) = reshape(handles.v(:,:,i),len,1); 23 | end 24 | 25 | % Ensemble average of U: 26 | % meanU = mean(U,2); 27 | % Uf = U; 28 | % meanU = zeros(len,1); 29 | % Fluctuations 30 | % % Uf = U - repmat(meanU,1,N); 31 | % for i = 1:N 32 | % Uf(:,i) = U(:,i) - meanU; 33 | % end 34 | meanU = mean(U,2); 35 | Uf = bsxfun(@minus,U,meanU); 36 | 37 | 38 | % keyboard 39 | switch handles.METHOD_FLAG % additional switch, to distinguish between 40 | % direct and snapshots methods, Alex, 08.07.05 41 | case {0,'snapshot'} 42 | R = Uf'*Uf; 43 | case {1,'direct'} 44 | % Covariance matrix: 45 | R = Uf*Uf'; 46 | end 47 | % Eigenvalue problem: 48 | % [~,D,V] = svds(R,min(len*2,N)); 49 | [V,D] = eig(R); 50 | clear R 51 | [L,I] = sort(diag(D)/N); 52 | 53 | nL = length(L); 54 | L = L(nL:-1:1); 55 | I = I(nL:-1:1); 56 | 57 | varargout{1} = L; 58 | 59 | 60 | case{2} 61 | % second call, the number of modes is known or the amount of energy 62 | % and POD prepares modes 63 | m = handles.numOfModes; 64 | switch handles.METHOD_FLAG 65 | case {0, 'snapshot'} 66 | % Diagonal matrix containing the square roots of the eigenvalues: 67 | 68 | S = sqrt(diag(D)); 69 | % [S, I] = sort(S); 70 | % S = flipud(S); 71 | % I = flipud(I); 72 | S = S(I); 73 | V = V(:,I); 74 | 75 | 76 | 77 | a = diag(S(1:m))*(V(:,1:m)'); 78 | 79 | 80 | % Calculation of POD modes: 81 | 82 | % for i=1:m 83 | % y = Uf*V(:,i); 84 | % phi(:,i) = y/norm(y); 85 | % end; 86 | 87 | % phi = Uf*V(:,1:m); 88 | % phi = phi./repmat(sum(abs(phi).^2).^(1/2),len*2,1); 89 | 90 | phi = Uf*V(:,1:m)*diag(1./S(1:m)); 91 | 92 | case {1,'direct'} 93 | phi = V(:,I); 94 | % S = sqrt(diag(D)); 95 | % S = S(I); 96 | % a = diag(S(1:m))*(phi(:,1:m)'); 97 | % a = diag(L(1:m))*(V(:,1:m)'); 98 | a = (Uf'*phi(:,1:m)).'; 99 | phi = phi(:,1:m); 100 | % disp('direct') 101 | % whos 102 | end 103 | 104 | [umodes,vmodes] = deal(zeros(r,c,m)); 105 | for i=1:m 106 | umodes(:,:,i) = reshape(phi(1:len,i),[r c] ); 107 | vmodes(:,:,i) = reshape(phi(len+1:2*len,i),[r c]); 108 | end 109 | 110 | % vel = (umodes.^2 + vmodes.^2).^(0.5); % .+wmodes.^2); % Velocity vector magnitude 111 | 112 | % misterious -1 113 | varargout{1} = umodes; 114 | varargout{2} = vmodes; 115 | % varargout{1} = -1*umodes; 116 | % varargout{2} = -1*vmodes; 117 | 118 | case{3} % reconstruction 119 | 120 | n = handles.current; 121 | if isfield(handles,'SelectedModes') && ~isempty(handles.SelectedModes) 122 | t = handles.SelectedModes; 123 | else 124 | t = 1:size(phi,2); 125 | end 126 | Q = phi(:,t)*a(t,n) + meanU; 127 | varargout{1} = reshape(Q(1:r*c),r,c); % u-components of reconstructed velocity field 128 | varargout{2} = reshape(Q(r*c+1:2*r*c),r,c); % v-components of reconstructed velocity field 129 | 130 | case{4} % multi-mode, weighted reconstruction 131 | 132 | % n = handles.current; 133 | 134 | uRec = handles.umodes(:,:,handles.multimode(1)) * L(handles.multimode(1)); 135 | vRec = handles.vmodes(:,:,handles.multimode(1)) * L(handles.multimode(1)); 136 | % uRec = handles.umodes(:,:,handles.multimode(1)) * L(handles.multimode(1)); 137 | % vRec = handles.vmodes(:,:,handles.multimode(1)) * L(handles.multimode(1)); 138 | 139 | for i = 1:length(handles.multimode) % (1) + 1 : handles.multimode(end) 140 | uRec = uRec + handles.umodes(:,:,handles.multimode(i)) * L(handles.multimode(i)); 141 | vRec = vRec + handles.vmodes(:,:,handles.multimode(i)) * L(handles.multimode(i)); 142 | end 143 | 144 | varargout{1} = uRec; 145 | varargout{2} = vRec; 146 | % % r c N len U meanU Uf V L I a phi 147 | % varargout{1} = U; 148 | % varargout{2} = meanU; 149 | % varargout{3} = Uf; 150 | % varargout{4} = V; 151 | % varargout{5} = L; 152 | % varargout{6} = I; 153 | % varargout{7} = a; 154 | % varargout{8} = phi; 155 | % 156 | % clear r c N len U meanU Uf V L I a phi 157 | 158 | case{6} % first time we call the function, but different from case 1 it is 159 | % without subtracting the mean of the velocity fields. 160 | 161 | [r,c,N] = size(handles.u); % 4-D is the number of files 162 | 163 | len = r*c; 164 | 165 | U = zeros(len*2,N); % r*c*3 length of the vector 166 | 167 | % small rearrangement 168 | for i = 1:N 169 | U(1:len,i) = reshape(handles.u(:,:,i),len,1); 170 | U(len+1:2*len,i) = reshape(handles.v(:,:,i),len,1); 171 | end 172 | 173 | % Ensemble average of U: 174 | % meanU = mean(U,2); 175 | meanU = zeros(len,1); 176 | 177 | % Fluctuations 178 | % Uf = U - repmat(meanU,1,N); 179 | for i = 1:N 180 | Uf(:,i) = U(:,i) - meanU; 181 | end 182 | 183 | % Covariance matrix: 184 | R = Uf'*Uf; 185 | 186 | % Eigenvalue problem: 187 | [V,D] = eig(R); 188 | 189 | clear R 190 | 191 | 192 | [L,I]=sort(diag(D)); 193 | nL = length(L); 194 | L = L(nL:-1:1); 195 | I = I(nL:-1:1); 196 | 197 | varargout{1} = L; 198 | varargout{2} = a; 199 | 200 | end % of switch -------------------------------------------------------------------------------- /Matlab/podvort.m: -------------------------------------------------------------------------------- 1 | function [varargout] = pod(handles, step) 2 | % POD is the Proper Orthogonal Decomposition 3 | % 4 | 5 | % Copyright (c) 2003 Alex Liberzon and Roi Gurka 6 | 7 | persistent r c N len U meanU Uf V D L I a phi 8 | 9 | % dbstop if caught error MATLAB:nonExistentField 10 | 11 | 12 | %load data.mat 13 | 14 | switch step 15 | %% Vorticity (or other scalar function) modes construction 16 | case{1} % first time we call the function 17 | 18 | [r,c,N] = size(handles.vort); % 4-D is the number of files 19 | 20 | len = r*c; 21 | 22 | Uf = zeros(len,N); % r*c*3 length of the vector 23 | 24 | % small rearrangement 25 | for i = 1:N 26 | Uf(1:len,i) = reshape(handles.vort(:,:,i),len,1); 27 | % U(len+1:2*len,i) = reshape(handles.v(:,:,i),len,1); 28 | end 29 | 30 | % Ensemble average of U: 31 | meanU = mean(Uf,2); 32 | % meanU = zeros(len,1); 33 | % Fluctuations 34 | % % Uf = U - repmat(meanU,1,N); 35 | for i = 1:N 36 | Uf(:,i) = Uf(:,i) - meanU; 37 | end 38 | 39 | 40 | % keyboard 41 | switch handles.METHOD_FLAG % additional switch, to distinguish between 42 | % direct and snapshots methods, Alex, 08.07.05 43 | case {0,'snapshot'} 44 | R = Uf'*Uf; 45 | case {1,'direct'} 46 | % Covariance matrix: 47 | R = Uf*Uf'; 48 | end 49 | % Eigenvalue problem: 50 | % [~,D,V] = svds(R,min(len*2,N)); 51 | [V,D] = eig(R); 52 | clear R 53 | [L,I] = sort(diag(D)/N); 54 | 55 | nL = length(L); 56 | L = L(nL:-1:1); 57 | I = I(nL:-1:1); 58 | 59 | varargout{1} = L; 60 | %% 61 | 62 | 63 | %% 64 | case{2} 65 | % second call, the number of modes is known or the amount of energy 66 | % and POD prepares modes 67 | m = handles.numOfModes; 68 | switch handles.METHOD_FLAG 69 | case {0, 'snapshot'} 70 | % Diagonal matrix containing the square roots of the eigenvalues: 71 | 72 | S = sqrt(diag(D)); 73 | % [S, I] = sort(S); 74 | % S = flipud(S); 75 | % I = flipud(I); 76 | S = S(I); 77 | V = V(:,I); 78 | 79 | 80 | 81 | a = diag(S(1:m))*(V(:,1:m)'); 82 | 83 | 84 | % Calculation of POD modes: 85 | 86 | % for i=1:m 87 | % y = Uf*V(:,i); 88 | % phi(:,i) = y/norm(y); 89 | % end; 90 | 91 | % phi = Uf*V(:,1:m); 92 | % phi = phi./repmat(sum(abs(phi).^2).^(1/2),len*2,1); 93 | 94 | phi = Uf*V(:,1:m)*diag(1./S(1:m)); 95 | 96 | case {1,'direct'} 97 | phi = V(:,I); 98 | S = sqrt(diag(D)); 99 | % S = S(I); 100 | % a = diag(S(1:m))*(phi(:,1:m)'); 101 | % a = diag(L(1:m))*(V(:,1:m)'); 102 | a = (Uf'*phi(:,1:m)).'; 103 | phi = phi(:,1:m); 104 | % disp('direct') 105 | % whos 106 | end 107 | 108 | % [umodes,vmodes,wmodes,vel] = deal(zeros(r,c,m)); 109 | if length(phi) == len 110 | % [umodes,vmodes] = deal(zeros(r,c,m)); 111 | [vortmodes] = deal(zeros(r,c,m)); 112 | for i=1:m 113 | vortmodes(:,:,i) = reshape(phi(1:len,i),[r c] ); 114 | % vmodes(:,:,i) = reshape(phi(len+1:2*len,i),[r c]); 115 | end 116 | 117 | % vel = (umodes.^2 + vmodes.^2).^(0.5); % .+wmodes.^2); % Velocity vector magnitude 118 | 119 | % misterious -1 120 | varargout{1} = vortmodes; 121 | % varargout{2} = vmodes; 122 | else length(phi) == 2*len 123 | [umodes,vmodes] = deal(zeros(r,c,m)); 124 | for i=1:m 125 | umodes(:,:,i) = reshape(phi(1:len,i),[r c] ); 126 | vmodes(:,:,i) = reshape(phi(len+1:2*len,i),[r c]); 127 | end 128 | 129 | % vel = (umodes.^2 + vmodes.^2).^(0.5); % .+wmodes.^2); % Velocity vector magnitude 130 | 131 | % misterious -1 132 | varargout{1} = umodes; 133 | varargout{2} = vmodes; 134 | % varargout{1} = -1*umodes; 135 | % varargout{2} = -1*vmodes; 136 | end 137 | 138 | %% 139 | %% CASE 3 - reconstruction of instantaneous maps 140 | 141 | case{3} 142 | 143 | n = handles.current; 144 | if isfield(handles,'SelectedModes') & ~isempty(handles.SelectedModes) 145 | t = handles.SelectedModes; 146 | else 147 | t = 1:size(phi,2); 148 | end 149 | try 150 | Q = phi(:,t)*a(t,n) + meanU; 151 | catch 152 | Q = phi(:,t)*a(t,n); 153 | end 154 | varargout{1} = reshape(Q(1:r*c),r,c); % u-components of reconstructed velocity field 155 | varargout{2} = reshape(Q(r*c+1:2*r*c),r,c); % v-components of reconstructed velocity field 156 | 157 | case{4} % multi-mode, weighted reconstruction 158 | 159 | n = handles.current; 160 | 161 | uRec = handles.umodes(:,:,handles.multimode(1)) * L(handles.multimode(1)); 162 | % vRec = handles.vmodes(:,:,handles.multimode(1)) * L(handles.multimode(1)); 163 | % uRec = handles.umodes(:,:,handles.multimode(1)) * L(handles.multimode(1)); 164 | % vRec = handles.vmodes(:,:,handles.multimode(1)) * L(handles.multimode(1)); 165 | 166 | for i = 1:length(handles.multimode) % (1) + 1 : handles.multimode(end) 167 | uRec = uRec + handles.umodes(:,:,handles.multimode(i)) * L(handles.multimode(i)); 168 | % vRec = vRec + handles.vmodes(:,:,handles.multimode(i)) * L(handles.multimode(i)); 169 | end 170 | 171 | varargout{1} = uRec; 172 | % varargout{2} = vRec; 173 | % % r c N len U meanU Uf V L I a phi 174 | % varargout{1} = U; 175 | % varargout{2} = meanU; 176 | % varargout{3} = Uf; 177 | % varargout{4} = V; 178 | % varargout{5} = L; 179 | % varargout{6} = I; 180 | % varargout{7} = a; 181 | % varargout{8} = phi; 182 | % 183 | % clear r c N len U meanU Uf V L I a phi 184 | 185 | %% CASE 6 is like case 1 - first call and construction of the C matrix, but 186 | % without the MEAN substraction 187 | case{6} % first time we call the function, but different from case 1 it is 188 | % without subtracting the mean of the velocity fields. 189 | 190 | [r,c,N] = size(handles.u); % 4-D is the number of files 191 | 192 | len = r*c; 193 | 194 | Uf = zeros(len*2,N); % r*c*3 length of the vector 195 | 196 | % small rearrangement 197 | for i = 1:N 198 | Uf(1:len,i) = reshape(handles.u(:,:,i),len,1); 199 | Uf(len+1:2*len,i) = reshape(handles.v(:,:,i),len,1); 200 | end 201 | 202 | % Ensemble average of U: 203 | % meanU = mean(U,2); 204 | % meanU = zeros(2*len,1); 205 | %% NOTE - I manually removed the mean 206 | warning('Mean is assumed zero, fix it manually if it is not true') 207 | 208 | % Covariance matrix: 209 | R = Uf'*Uf; 210 | 211 | % Eigenvalue problem: 212 | [V,D] = eig(R); 213 | 214 | clear R 215 | 216 | 217 | [L,I]=sort(diag(D)); 218 | nL = length(L); 219 | L = L(nL:-1:1); 220 | I = I(nL:-1:1); 221 | 222 | varargout{1} = L; 223 | varargout{2} = a; 224 | 225 | end % of switch -------------------------------------------------------------------------------- /Matlab/uipickfiles.m: -------------------------------------------------------------------------------- 1 | function out = uipickfiles(varargin) 2 | %uipickfiles: GUI program to select files and/or directories. 3 | % 4 | % Syntax: 5 | % files = uipickfiles('PropertyName',PropertyValue,...) 6 | % 7 | % The current directory can be changed by operating in the file navigator: 8 | % double-clicking on a directory in the list or pressing Enter to move 9 | % further down the tree, using the popup menu, clicking the up arrow button 10 | % or pressing Backspace to move up the tree, typing a path in the box to 11 | % move to any directory or right-clicking (control-click on Mac) on the 12 | % path box to revisit a previously-listed directory. (Windows only: To go 13 | % to a UNC-named resource you will have to type the UNC name in the path 14 | % box, but all such visited resources will be remembered and listed along 15 | % with the mapped drives.) 16 | % 17 | % Files can be added to the list by double-clicking or selecting files 18 | % (non-contiguous selections are possible with the control key) and 19 | % pressing the Add button. Since double-clicking a folder will open it, 20 | % folders can be added only by selecting them and pressing the Add button. 21 | % Files/folders in the list can be removed or re-ordered. When finished, a 22 | % press of the Done button will return the full paths to the selected files 23 | % in a cell array, structure array or character array. If the Cancel 24 | % button is pressed then zero is returned. 25 | % 26 | % The following optional property/value pairs can be specified as arguments 27 | % to control the indicated behavior: 28 | % 29 | % Property Value 30 | % ---------- ---------------------------------------------------------- 31 | % FilterSpec String to specify starting directory and/or file filter. 32 | % Ex: 'C:\bin' will start up in that directory. '*.txt' 33 | % will list only files ending in '.txt'. 'c:\bin\*.txt' will 34 | % do both. Default is to start up in the current directory 35 | % and list all files. Can be changed with the GUI. 36 | % 37 | % REFilter String containing a regular expression used to filter the 38 | % file list. Ex: '\.m$|\.mat$' will list files ending in 39 | % '.m' and '.mat'. Default is empty string. Can be used 40 | % with FilterSpec and both filters are applied. Can be 41 | % changed with the GUI. 42 | % 43 | % REDirs Logical flag indicating whether to apply the regular 44 | % expression filter to directory names. Default is false 45 | % which means that all directories are listed. Can be 46 | % changed with the GUI. 47 | % 48 | % Type Two-column cell array where the first column contains file 49 | % filters and the second column contains descriptions. If 50 | % this property is specified an additional popup menu will 51 | % appear below the File Filter and selecting an item will put 52 | % that item into the File Filter. By default, the first item 53 | % will be entered into the File Filter. For example, 54 | % { '*.m', 'M-files' ; 55 | % '*.mat', 'MAT-files' }. 56 | % Can also be a cell vector of file filter strings in which 57 | % case the descriptions will be the same as the file filters 58 | % themselves. 59 | % Must be a cell array even if there is only one entry. 60 | % 61 | % Prompt String containing a prompt appearing in the title bar of 62 | % the figure. Default is 'Select files'. 63 | % 64 | % NumFiles Scalar or vector specifying number of files that must be 65 | % selected. A scalar specifies an exact value; a two-element 66 | % vector can be used to specify a range, [min max]. The 67 | % function will not return unless the specified number of 68 | % files have been chosen. Default is [] which accepts any 69 | % number of files. 70 | % 71 | % Output String specifying the data type of the output: 'cell', 72 | % 'struct' or 'char'. Specifying 'cell' produces a cell 73 | % array of strings, the strings containing the full paths of 74 | % the chosen files. 'Struct' returns a structure array like 75 | % the result of the dir function except that the 'name' field 76 | % contains a full path instead of just the file name. 'Char' 77 | % returns a character array of the full paths. This is most 78 | % useful when you have just one file and want it in a string 79 | % instead of a cell array containing just one string. The 80 | % default is 'cell'. 81 | % 82 | % All properties and values are case-insensitive and need only be 83 | % unambiguous. For example, 84 | % 85 | % files = uipickfiles('num',1,'out','ch') 86 | % 87 | % is valid usage. 88 | 89 | % Version: 1.7, 8 August 2010 90 | % Author: Douglas M. Schwarz 91 | % Email: dmschwarz=ieee*org, dmschwarz=urgrad*rochester*edu 92 | % Real_email = regexprep(Email,{'=','*'},{'@','.'}) 93 | 94 | 95 | % Define properties and set default values. 96 | prop.filterspec = '*'; 97 | prop.refilter = ''; 98 | prop.redirs = false; 99 | prop.type = {}; 100 | prop.prompt = 'Select files'; 101 | prop.numfiles = []; 102 | prop.output = 'cell'; 103 | 104 | % Process inputs and set prop fields. 105 | properties = fieldnames(prop); 106 | arg_index = 1; 107 | while arg_index <= nargin 108 | arg = varargin{arg_index}; 109 | if ischar(arg) 110 | prop_index = find(strncmpi(arg,properties,length(arg))); 111 | if length(prop_index) == 1 112 | prop.(properties{prop_index}) = varargin{arg_index + 1}; 113 | else 114 | error('Property ''%s'' does not exist or is ambiguous.',arg) 115 | end 116 | arg_index = arg_index + 2; 117 | elseif isstruct(arg) 118 | arg_fn = fieldnames(arg); 119 | for ii = 1:length(arg_fn) 120 | prop_index = find(strncmpi(arg_fn{ii},properties,... 121 | length(arg_fn{ii}))); 122 | if length(prop_index) == 1 123 | prop.(properties{prop_index}) = arg.(arg_fn{ii}); 124 | else 125 | error('Property ''%s'' does not exist or is ambiguous.',... 126 | arg_fn{ii}) 127 | end 128 | end 129 | arg_index = arg_index + 1; 130 | else 131 | error(['Properties must be specified by property/value pairs',... 132 | ' or structures.']) 133 | end 134 | end 135 | 136 | % Validate FilterSpec property. 137 | if isempty(prop.filterspec) 138 | prop.filterspec = '*'; 139 | end 140 | if ~ischar(prop.filterspec) 141 | error('FilterSpec property must contain a string.') 142 | end 143 | 144 | % Validate REFilter property. 145 | if ~ischar(prop.refilter) 146 | error('REFilter property must contain a string.') 147 | end 148 | 149 | % Validate REDirs property. 150 | if ~isscalar(prop.redirs) 151 | error('REDirs property must contain a scalar.') 152 | end 153 | 154 | % Validate Type property. 155 | if isempty(prop.type) 156 | elseif iscellstr(prop.type) && isvector(prop.type) 157 | prop.type = repmat(prop.type(:),1,2); 158 | elseif iscellstr(prop.type) && size(prop.type,2) == 2 159 | else 160 | error(['Type property must be empty or a cellstr vector or ',... 161 | 'a 2-column cellstr matrix.']) 162 | end 163 | 164 | % Validate Prompt property. 165 | if ~ischar(prop.prompt) 166 | error('Prompt property must contain a string.') 167 | end 168 | 169 | % Validate NumFiles property. 170 | if numel(prop.numfiles) > 2 || any(prop.numfiles < 0) 171 | error('NumFiles must be empty, a scalar or two-element vector.') 172 | end 173 | prop.numfiles = unique(prop.numfiles); 174 | if isequal(prop.numfiles,1) 175 | numstr = 'Select exactly 1 file.'; 176 | elseif length(prop.numfiles) == 1 177 | numstr = sprintf('Select exactly %d files.',prop.numfiles); 178 | else 179 | numstr = sprintf('Select %d to %d files.',prop.numfiles); 180 | end 181 | 182 | % Validate Output property. 183 | legal_outputs = {'cell','struct','char'}; 184 | out_idx = find(strncmpi(prop.output,legal_outputs,length(prop.output))); 185 | if length(out_idx) == 1 186 | prop.output = legal_outputs{out_idx}; 187 | else 188 | error(['Value of ''Output'' property, ''%s'', is illegal or '... 189 | 'ambiguous.'],prop.output) 190 | end 191 | 192 | 193 | % Set style preference for display of folders/directories. 194 | % 1 => folder icon before and filesep after 195 | % 2 => bullet before and filesep after 196 | % 3 => filesep after only 197 | folder_style_pref = 1; 198 | fsdata = set_folder_style(folder_style_pref); 199 | 200 | % Initialize file lists. 201 | [current_dir,f,e] = fileparts(prop.filterspec); 202 | filter = [f,e]; 203 | if isempty(current_dir) 204 | current_dir = pwd; 205 | end 206 | if isempty(filter) 207 | filter = '*'; 208 | end 209 | re_filter = prop.refilter; 210 | full_filter = fullfile(current_dir,filter); 211 | network_volumes = {}; 212 | [path_cell,new_network_vol] = path2cell(current_dir); 213 | if exist(new_network_vol,'dir') 214 | network_volumes = unique([network_volumes,{new_network_vol}]); 215 | end 216 | fdir = filtered_dir(full_filter,re_filter,prop.redirs); 217 | filenames = {fdir.name}'; 218 | filenames = annotate_file_names(filenames,fdir,fsdata); 219 | 220 | % Initialize some data. 221 | file_picks = {}; 222 | full_file_picks = {}; 223 | dir_picks = dir(' '); % Create empty directory structure. 224 | show_full_path = false; 225 | nodupes = true; 226 | history = {current_dir}; 227 | 228 | % Create figure. 229 | gray = get(0,'DefaultUIControlBackgroundColor'); 230 | fig = figure('Position',[0 0 740 445+34],... 231 | 'Color',gray,... 232 | 'WindowStyle','modal',... 233 | 'Resize','off',... 234 | 'NumberTitle','off',... 235 | 'Name',prop.prompt,... 236 | 'IntegerHandle','off',... 237 | 'CloseRequestFcn',@cancel,... 238 | 'CreateFcn',{@movegui,'center'}); 239 | 240 | % Set font on Mac and Windows to system font. 241 | if ismac 242 | set(fig,'DefaultUIControlFontName','Lucida Grande') 243 | set(fig,'DefaultUIControlFontSize',9) 244 | elseif ispc 245 | set(fig,'DefaultUIControlFontName','Tahoma') 246 | set(fig,'DefaultUIControlFontSize',8) 247 | end 248 | 249 | % Create uicontrols. 250 | uicontrol('Style','frame',... 251 | 'Position',[255 260 110 70]) 252 | uicontrol('Style','frame',... 253 | 'Position',[275 135 110 100]) 254 | 255 | navlist = uicontrol('Style','listbox',... 256 | 'Position',[10 10 250 320],... 257 | 'String',filenames,... 258 | 'Value',[],... 259 | 'BackgroundColor','w',... 260 | 'Callback',@clicknav,... 261 | 'KeyPressFcn',@keypressnav,... 262 | 'Max',2); 263 | pickslist = uicontrol('Style','listbox',... 264 | 'Position',[380 10 350 320],... 265 | 'String',{},... 266 | 'BackgroundColor','w',... 267 | 'Callback',@clickpicks,... 268 | 'Max',2); 269 | 270 | openbut = uicontrol('Style','pushbutton',... 271 | 'Position',[270 300 80 20],... 272 | 'String','Open',... 273 | 'Enable','off',... 274 | 'Callback',@open); 275 | 276 | arrow = [ ... 277 | ' 1 '; 278 | ' 10 '; 279 | ' 10 '; 280 | '000000000000'; 281 | ' 10 '; 282 | ' 10 '; 283 | ' 1 ']; 284 | cmap = NaN(128,3); 285 | cmap(double('10'),:) = [0.5 0.5 0.5;0 0 0]; 286 | arrow_im = NaN(7,76,3); 287 | arrow_im(:,45:56,:) = ind2rgb(double(arrow),cmap); 288 | addbut = uicontrol('Style','pushbutton',... 289 | 'Position',[270 270 80 20],... 290 | 'String','Add ',... 291 | 'Enable','off',... 292 | 'CData',arrow_im,... 293 | 'Callback',@add); 294 | 295 | removebut = uicontrol('Style','pushbutton',... 296 | 'Position',[290 205 80 20],... 297 | 'String','Remove',... 298 | 'Enable','off',... 299 | 'Callback',@remove); 300 | moveupbut = uicontrol('Style','pushbutton',... 301 | 'Position',[290 175 80 20],... 302 | 'String','Move Up',... 303 | 'Enable','off',... 304 | 'Callback',@moveup); 305 | movedownbut = uicontrol('Style','pushbutton',... 306 | 'Position',[290 145 80 20],... 307 | 'String','Move Down',... 308 | 'Enable','off',... 309 | 'Callback',@movedown); 310 | 311 | dir_popup = uicontrol('Style','popupmenu',... 312 | 'Position',[10 335 225 20],... 313 | 'BackgroundColor','w',... 314 | 'String',path_cell,... 315 | 'Value',length(path_cell),... 316 | 'Callback',@dirpopup); 317 | 318 | uparrow = [ ... 319 | ' 0 '; 320 | ' 000 '; 321 | '00000 '; 322 | ' 0 '; 323 | ' 0 '; 324 | ' 0 '; 325 | ' 000000']; 326 | cmap = NaN(128,3); 327 | cmap(double('0'),:) = [0 0 0]; 328 | uparrow_im = ind2rgb(double(uparrow),cmap); 329 | up_dir_but = uicontrol('Style','pushbutton',... 330 | 'Position',[240 335 20 20],... 331 | 'CData',uparrow_im,... 332 | 'Callback',@dir_up_one); 333 | if length(path_cell) > 1 334 | set(up_dir_but','Enable','on') 335 | else 336 | set(up_dir_but','Enable','off') 337 | end 338 | 339 | hist_cm = uicontextmenu; 340 | pathbox = uicontrol('Position',[10 360 250 26],... 341 | 'Style','edit',... 342 | 'BackgroundColor','w',... 343 | 'String',current_dir,... 344 | 'HorizontalAlignment','left',... 345 | 'Callback',@change_path,... 346 | 'UIContextMenu',hist_cm); 347 | uicontrol('Position',[10 386 250 16],... 348 | 'Style','text',... 349 | 'String','Current Directory',... 350 | 'HorizontalAlignment','center',... 351 | 'UIContextMenu',hist_cm) 352 | hist_menus = []; 353 | hist_cb = @history_cb; 354 | hist_menus = make_history_cm(hist_cb,hist_cm,hist_menus,history); 355 | 356 | uicontrol('Position',[10 425+36 80 17],... 357 | 'Style','text',... 358 | 'String','File Filter',... 359 | 'HorizontalAlignment','left') 360 | uicontrol('Position',[100 425+36 160 17],... 361 | 'Style','text',... 362 | 'String','Reg. Exp. Filter',... 363 | 'HorizontalAlignment','left') 364 | showallfiles = uicontrol('Position',[270 405+32 100 20],... 365 | 'Style','checkbox',... 366 | 'String','Show All Files',... 367 | 'Value',0,... 368 | 'HorizontalAlignment','left',... 369 | 'Callback',@togglefilter); 370 | refilterdirs = uicontrol('Position',[270 405+10 100 20],... 371 | 'Style','checkbox',... 372 | 'String','RE Filter Dirs',... 373 | 'Value',prop.redirs,... 374 | 'HorizontalAlignment','left',... 375 | 'Callback',@toggle_refiltdirs); 376 | filter_ed = uicontrol('Position',[10 405+30 80 26],... 377 | 'Style','edit',... 378 | 'BackgroundColor','w',... 379 | 'String',filter,... 380 | 'HorizontalAlignment','left',... 381 | 'Callback',@setfilspec); 382 | refilter_ed = uicontrol('Position',[100 405+30 160 26],... 383 | 'Style','edit',... 384 | 'BackgroundColor','w',... 385 | 'String',re_filter,... 386 | 'HorizontalAlignment','left',... 387 | 'Callback',@setrefilter); 388 | 389 | if ~isempty(prop.type) 390 | type_value = 1; 391 | set(filter_ed,'String',prop.type{type_value,1}) 392 | setfilspec() 393 | type_popup = uicontrol('Position',[10 407 250 20],... 394 | 'Style','popupmenu',... 395 | 'String',prop.type(:,2),... 396 | 'BackgroundColor','w',... 397 | 'Value',type_value,... 398 | 'Callback',@filter_type_callback); 399 | end 400 | 401 | viewfullpath = uicontrol('Style','checkbox',... 402 | 'Position',[380 335 230 20],... 403 | 'String','Show full paths',... 404 | 'Value',show_full_path,... 405 | 'HorizontalAlignment','left',... 406 | 'Callback',@showfullpath); 407 | remove_dupes = uicontrol('Style','checkbox',... 408 | 'Position',[380 360 280 20],... 409 | 'String','Remove duplicates (as per full path)',... 410 | 'Value',nodupes,... 411 | 'HorizontalAlignment','left',... 412 | 'Callback',@removedupes); 413 | uicontrol('Position',[380 405 350 20],... 414 | 'Style','text',... 415 | 'String','Selected Files',... 416 | 'HorizontalAlignment','center') 417 | uicontrol('Position',[280 80 80 30],'String','Done',... 418 | 'Callback',@done); 419 | uicontrol('Position',[280 30 80 30],'String','Cancel',... 420 | 'Callback',@cancel); 421 | 422 | % If necessary, add warning about number of files to be selected. 423 | if ~isempty(prop.numfiles) 424 | uicontrol('Position',[380 385 350 16],... 425 | 'Style','text',... 426 | 'String',numstr,... 427 | 'ForegroundColor',[0.8 0 0],... 428 | 'HorizontalAlignment','center') 429 | end 430 | 431 | set(fig,'HandleVisibility','off') 432 | 433 | % Wait until figure is closed. 434 | uiwait(fig) 435 | 436 | % Compute desired output. 437 | switch prop.output 438 | case 'cell' 439 | out = full_file_picks; 440 | case 'struct' 441 | out = dir_picks(:); 442 | case 'char' 443 | out = char(full_file_picks); 444 | case 'cancel' 445 | out = 0; 446 | end 447 | 448 | 449 | % -------------------- Callback functions -------------------- 450 | 451 | function add(varargin) 452 | values = get(navlist,'Value'); 453 | for i = 1:length(values) 454 | dir_pick = fdir(values(i)); 455 | pick = dir_pick.name; 456 | pick_full = fullfile(current_dir,pick); 457 | dir_pick.name = pick_full; 458 | if ~nodupes || ~any(strcmp(full_file_picks,pick_full)) 459 | file_picks{end + 1} = pick; %#ok 460 | full_file_picks{end + 1} = pick_full; %#ok 461 | dir_picks(end + 1) = dir_pick; %#ok 462 | end 463 | end 464 | if show_full_path 465 | set(pickslist,'String',full_file_picks,'Value',[]); 466 | else 467 | set(pickslist,'String',file_picks,'Value',[]); 468 | end 469 | set([removebut,moveupbut,movedownbut],'Enable','off'); 470 | end 471 | 472 | function remove(varargin) 473 | values = get(pickslist,'Value'); 474 | file_picks(values) = []; 475 | full_file_picks(values) = []; 476 | dir_picks(values) = []; 477 | top = get(pickslist,'ListboxTop'); 478 | num_above_top = sum(values < top); 479 | top = top - num_above_top; 480 | num_picks = length(file_picks); 481 | new_value = min(min(values) - num_above_top,num_picks); 482 | if num_picks == 0 483 | new_value = []; 484 | set([removebut,moveupbut,movedownbut],'Enable','off') 485 | end 486 | if show_full_path 487 | set(pickslist,'String',full_file_picks,'Value',new_value,... 488 | 'ListboxTop',top) 489 | else 490 | set(pickslist,'String',file_picks,'Value',new_value,... 491 | 'ListboxTop',top) 492 | end 493 | end 494 | 495 | function open(varargin) 496 | values = get(navlist,'Value'); 497 | if fdir(values).isdir 498 | set(fig,'pointer','watch') 499 | drawnow 500 | current_dir = fullfile(current_dir,fdir(values).name); 501 | history{end+1} = current_dir; 502 | history = unique(history); 503 | hist_menus = make_history_cm(hist_cb,hist_cm,hist_menus,... 504 | history); 505 | full_filter = fullfile(current_dir,filter); 506 | path_cell = path2cell(current_dir); 507 | fdir = filtered_dir(full_filter,re_filter,prop.redirs); 508 | filenames = {fdir.name}'; 509 | filenames = annotate_file_names(filenames,fdir,fsdata); 510 | set(dir_popup,'String',path_cell,'Value',length(path_cell)) 511 | if length(path_cell) > 1 512 | set(up_dir_but','Enable','on') 513 | else 514 | set(up_dir_but','Enable','off') 515 | end 516 | set(pathbox,'String',current_dir) 517 | set(navlist,'ListboxTop',1,'Value',[],'String',filenames) 518 | set(addbut,'Enable','off') 519 | set(openbut,'Enable','off') 520 | set(fig,'pointer','arrow') 521 | end 522 | end 523 | 524 | function clicknav(varargin) 525 | value = get(navlist,'Value'); 526 | nval = length(value); 527 | dbl_click_fcn = @add; 528 | switch nval 529 | case 0 530 | set([addbut,openbut],'Enable','off') 531 | case 1 532 | set(addbut,'Enable','on'); 533 | if fdir(value).isdir 534 | set(openbut,'Enable','on') 535 | dbl_click_fcn = @open; 536 | else 537 | set(openbut,'Enable','off') 538 | end 539 | otherwise 540 | set(addbut,'Enable','on') 541 | set(openbut,'Enable','off') 542 | end 543 | if strcmp(get(fig,'SelectionType'),'open') 544 | dbl_click_fcn(); 545 | end 546 | end 547 | 548 | function keypressnav(h,evt) %#ok 549 | if length(path_cell) > 1 && strcmp(evt.Key,'backspace') 550 | dir_up_one() 551 | end 552 | 553 | % Some key combinations cause the menu bar to appear so we turn it 554 | % back off. 555 | set(fig,'MenuBar','none') 556 | end 557 | 558 | function clickpicks(varargin) 559 | value = get(pickslist,'Value'); 560 | if isempty(value) 561 | set([removebut,moveupbut,movedownbut],'Enable','off') 562 | else 563 | set(removebut,'Enable','on') 564 | if min(value) == 1 565 | set(moveupbut,'Enable','off') 566 | else 567 | set(moveupbut,'Enable','on') 568 | end 569 | if max(value) == length(file_picks) 570 | set(movedownbut,'Enable','off') 571 | else 572 | set(movedownbut,'Enable','on') 573 | end 574 | end 575 | if strcmp(get(fig,'SelectionType'),'open') 576 | remove(); 577 | end 578 | end 579 | 580 | function dirpopup(varargin) 581 | value = get(dir_popup,'Value'); 582 | path_cell = path_cell(1:value); 583 | set(fig,'pointer','watch') 584 | drawnow 585 | if ispc && value == 1 586 | current_dir = ''; 587 | full_filter = filter; 588 | drives = getdrives(network_volumes); 589 | num_drives = length(drives); 590 | temp = tempname; 591 | mkdir(temp) 592 | dir_temp = dir(temp); 593 | rmdir(temp) 594 | fdir = repmat(dir_temp(1),num_drives,1); 595 | [fdir.name] = deal(drives{:}); 596 | else 597 | current_dir = cell2path(path_cell); 598 | history{end+1} = current_dir; 599 | history = unique(history); 600 | hist_menus = make_history_cm(hist_cb,hist_cm,hist_menus,... 601 | history); 602 | full_filter = fullfile(current_dir,filter); 603 | fdir = filtered_dir(full_filter,re_filter,prop.redirs); 604 | end 605 | filenames = {fdir.name}'; 606 | filenames = annotate_file_names(filenames,fdir,fsdata); 607 | set(dir_popup,'String',path_cell,'Value',length(path_cell)) 608 | if length(path_cell) > 1 609 | set(up_dir_but','Enable','on') 610 | else 611 | set(up_dir_but','Enable','off') 612 | end 613 | set(pathbox,'String',current_dir) 614 | set(navlist,'String',filenames,'Value',[]) 615 | set(addbut,'Enable','off') 616 | set(fig,'pointer','arrow') 617 | end 618 | 619 | function dir_up_one(varargin) 620 | value = length(path_cell) - 1; 621 | path_cell = path_cell(1:value); 622 | set(fig,'pointer','watch') 623 | drawnow 624 | if ispc && value == 1 625 | current_dir = ''; 626 | full_filter = filter; 627 | drives = getdrives(network_volumes); 628 | num_drives = length(drives); 629 | temp = tempname; 630 | mkdir(temp) 631 | dir_temp = dir(temp); 632 | rmdir(temp) 633 | fdir = repmat(dir_temp(1),num_drives,1); 634 | [fdir.name] = deal(drives{:}); 635 | else 636 | current_dir = cell2path(path_cell); 637 | history{end+1} = current_dir; 638 | history = unique(history); 639 | hist_menus = make_history_cm(hist_cb,hist_cm,hist_menus,... 640 | history); 641 | full_filter = fullfile(current_dir,filter); 642 | fdir = filtered_dir(full_filter,re_filter,prop.redirs); 643 | end 644 | filenames = {fdir.name}'; 645 | filenames = annotate_file_names(filenames,fdir,fsdata); 646 | set(dir_popup,'String',path_cell,'Value',length(path_cell)) 647 | if length(path_cell) > 1 648 | set(up_dir_but','Enable','on') 649 | else 650 | set(up_dir_but','Enable','off') 651 | end 652 | set(pathbox,'String',current_dir) 653 | set(navlist,'String',filenames,'Value',[]) 654 | set(addbut,'Enable','off') 655 | set(fig,'pointer','arrow') 656 | end 657 | 658 | function change_path(varargin) 659 | set(fig,'pointer','watch') 660 | drawnow 661 | proposed_path = get(pathbox,'String'); 662 | % Process any directories named '..'. 663 | proposed_path_cell = path2cell(proposed_path); 664 | ddots = strcmp(proposed_path_cell,'..'); 665 | ddots(find(ddots) - 1) = true; 666 | proposed_path_cell(ddots) = []; 667 | proposed_path = cell2path(proposed_path_cell); 668 | % Check for existance of directory. 669 | if ~exist(proposed_path,'dir') 670 | set(fig,'pointer','arrow') 671 | uiwait(errordlg(['Directory "',proposed_path,... 672 | '" does not exist.'],'','modal')) 673 | return 674 | end 675 | current_dir = proposed_path; 676 | history{end+1} = current_dir; 677 | history = unique(history); 678 | hist_menus = make_history_cm(hist_cb,hist_cm,hist_menus,history); 679 | full_filter = fullfile(current_dir,filter); 680 | [path_cell,new_network_vol] = path2cell(current_dir); 681 | if exist(new_network_vol,'dir') 682 | network_volumes = unique([network_volumes,{new_network_vol}]); 683 | end 684 | fdir = filtered_dir(full_filter,re_filter,prop.redirs); 685 | filenames = {fdir.name}'; 686 | filenames = annotate_file_names(filenames,fdir,fsdata); 687 | set(dir_popup,'String',path_cell,'Value',length(path_cell)) 688 | if length(path_cell) > 1 689 | set(up_dir_but','Enable','on') 690 | else 691 | set(up_dir_but','Enable','off') 692 | end 693 | set(pathbox,'String',current_dir) 694 | set(navlist,'String',filenames,'Value',[]) 695 | set(addbut,'Enable','off') 696 | set(openbut,'Enable','off') 697 | set(fig,'pointer','arrow') 698 | end 699 | 700 | function showfullpath(varargin) 701 | show_full_path = get(viewfullpath,'Value'); 702 | if show_full_path 703 | set(pickslist,'String',full_file_picks) 704 | else 705 | set(pickslist,'String',file_picks) 706 | end 707 | end 708 | 709 | function removedupes(varargin) 710 | nodupes = get(remove_dupes,'Value'); 711 | if nodupes 712 | num_picks = length(full_file_picks); 713 | [unused,rev_order] = unique(full_file_picks(end:-1:1)); 714 | order = sort(num_picks + 1 - rev_order); 715 | full_file_picks = full_file_picks(order); 716 | file_picks = file_picks(order); 717 | dir_picks = dir_picks(order); 718 | if show_full_path 719 | set(pickslist,'String',full_file_picks,'Value',[]) 720 | else 721 | set(pickslist,'String',file_picks,'Value',[]) 722 | end 723 | set([removebut,moveupbut,movedownbut],'Enable','off') 724 | end 725 | end 726 | 727 | function moveup(varargin) 728 | value = get(pickslist,'Value'); 729 | set(removebut,'Enable','on') 730 | n = length(file_picks); 731 | omega = 1:n; 732 | index = zeros(1,n); 733 | index(value - 1) = omega(value); 734 | index(setdiff(omega,value - 1)) = omega(setdiff(omega,value)); 735 | file_picks = file_picks(index); 736 | full_file_picks = full_file_picks(index); 737 | dir_picks = dir_picks(index); 738 | value = value - 1; 739 | if show_full_path 740 | set(pickslist,'String',full_file_picks,'Value',value) 741 | else 742 | set(pickslist,'String',file_picks,'Value',value) 743 | end 744 | if min(value) == 1 745 | set(moveupbut,'Enable','off') 746 | end 747 | set(movedownbut,'Enable','on') 748 | end 749 | 750 | function movedown(varargin) 751 | value = get(pickslist,'Value'); 752 | set(removebut,'Enable','on') 753 | n = length(file_picks); 754 | omega = 1:n; 755 | index = zeros(1,n); 756 | index(value + 1) = omega(value); 757 | index(setdiff(omega,value + 1)) = omega(setdiff(omega,value)); 758 | file_picks = file_picks(index); 759 | full_file_picks = full_file_picks(index); 760 | dir_picks = dir_picks(index); 761 | value = value + 1; 762 | if show_full_path 763 | set(pickslist,'String',full_file_picks,'Value',value) 764 | else 765 | set(pickslist,'String',file_picks,'Value',value) 766 | end 767 | if max(value) == n 768 | set(movedownbut,'Enable','off') 769 | end 770 | set(moveupbut,'Enable','on') 771 | end 772 | 773 | function togglefilter(varargin) 774 | set(fig,'pointer','watch') 775 | drawnow 776 | value = get(showallfiles,'Value'); 777 | if value 778 | filter = '*'; 779 | re_filter = ''; 780 | set([filter_ed,refilter_ed],'Enable','off') 781 | else 782 | filter = get(filter_ed,'String'); 783 | re_filter = get(refilter_ed,'String'); 784 | set([filter_ed,refilter_ed],'Enable','on') 785 | end 786 | full_filter = fullfile(current_dir,filter); 787 | fdir = filtered_dir(full_filter,re_filter,prop.redirs); 788 | filenames = {fdir.name}'; 789 | filenames = annotate_file_names(filenames,fdir,fsdata); 790 | set(navlist,'String',filenames,'Value',[]) 791 | set(addbut,'Enable','off') 792 | set(fig,'pointer','arrow') 793 | end 794 | 795 | function toggle_refiltdirs(varargin) 796 | set(fig,'pointer','watch') 797 | drawnow 798 | value = get(refilterdirs,'Value'); 799 | prop.redirs = value; 800 | full_filter = fullfile(current_dir,filter); 801 | fdir = filtered_dir(full_filter,re_filter,prop.redirs); 802 | filenames = {fdir.name}'; 803 | filenames = annotate_file_names(filenames,fdir,fsdata); 804 | set(navlist,'String',filenames,'Value',[]) 805 | set(addbut,'Enable','off') 806 | set(fig,'pointer','arrow') 807 | end 808 | 809 | function setfilspec(varargin) 810 | set(fig,'pointer','watch') 811 | drawnow 812 | filter = get(filter_ed,'String'); 813 | if isempty(filter) 814 | filter = '*'; 815 | set(filter_ed,'String',filter) 816 | end 817 | % Process file spec if a subdirectory was included. 818 | [p,f,e] = fileparts(filter); 819 | if ~isempty(p) 820 | newpath = fullfile(current_dir,p,''); 821 | set(pathbox,'String',newpath) 822 | filter = [f,e]; 823 | if isempty(filter) 824 | filter = '*'; 825 | end 826 | set(filter_ed,'String',filter) 827 | change_path(); 828 | end 829 | full_filter = fullfile(current_dir,filter); 830 | fdir = filtered_dir(full_filter,re_filter,prop.redirs); 831 | filenames = {fdir.name}'; 832 | filenames = annotate_file_names(filenames,fdir,fsdata); 833 | set(navlist,'String',filenames,'Value',[]) 834 | set(addbut,'Enable','off') 835 | set(fig,'pointer','arrow') 836 | end 837 | 838 | function setrefilter(varargin) 839 | set(fig,'pointer','watch') 840 | drawnow 841 | re_filter = get(refilter_ed,'String'); 842 | fdir = filtered_dir(full_filter,re_filter,prop.redirs); 843 | filenames = {fdir.name}'; 844 | filenames = annotate_file_names(filenames,fdir,fsdata); 845 | set(navlist,'String',filenames,'Value',[]) 846 | set(addbut,'Enable','off') 847 | set(fig,'pointer','arrow') 848 | end 849 | 850 | function filter_type_callback(varargin) 851 | type_value = get(type_popup,'Value'); 852 | set(filter_ed,'String',prop.type{type_value,1}) 853 | setfilspec() 854 | end 855 | 856 | function done(varargin) 857 | % Optional shortcut: click on a file and press 'Done'. 858 | % if isempty(full_file_picks) && strcmp(get(addbut,'Enable'),'on') 859 | % add(); 860 | % end 861 | numfiles = length(full_file_picks); 862 | if ~isempty(prop.numfiles) 863 | if numfiles < prop.numfiles(1) 864 | msg = {'Too few files selected.',numstr}; 865 | uiwait(errordlg(msg,'','modal')) 866 | return 867 | elseif numfiles > prop.numfiles(end) 868 | msg = {'Too many files selected.',numstr}; 869 | uiwait(errordlg(msg,'','modal')) 870 | return 871 | end 872 | end 873 | delete(fig) 874 | end 875 | 876 | function cancel(varargin) 877 | prop.output = 'cancel'; 878 | delete(fig) 879 | end 880 | 881 | function history_cb(varargin) 882 | set(fig,'pointer','watch') 883 | drawnow 884 | current_dir = history{varargin{3}}; 885 | full_filter = fullfile(current_dir,filter); 886 | path_cell = path2cell(current_dir); 887 | fdir = filtered_dir(full_filter,re_filter,prop.redirs); 888 | filenames = {fdir.name}'; 889 | filenames = annotate_file_names(filenames,fdir,fsdata); 890 | set(dir_popup,'String',path_cell,'Value',length(path_cell)) 891 | if length(path_cell) > 1 892 | set(up_dir_but','Enable','on') 893 | else 894 | set(up_dir_but','Enable','off') 895 | end 896 | set(pathbox,'String',current_dir) 897 | set(navlist,'ListboxTop',1,'Value',[],'String',filenames) 898 | set(addbut,'Enable','off') 899 | set(openbut,'Enable','off') 900 | set(fig,'pointer','arrow') 901 | end 902 | end 903 | 904 | 905 | % -------------------- Subfunctions -------------------- 906 | 907 | function [c,network_vol] = path2cell(p) 908 | % Turns a path string into a cell array of path elements. 909 | if ispc 910 | p = strrep(p,'/','\'); 911 | k = regexp(p,'(^\\\\[^\\]+\\[^\\]+)|(^[A-Za-z]+:)','end'); 912 | vol = p(1:k); 913 | c1 = strread(p(k+2:end),'%s','delimiter','\\/'); 914 | c = [{'My Computer'};{vol};c1]; 915 | if strncmp(vol,'\\',2) 916 | network_vol = vol; 917 | else 918 | network_vol = ''; 919 | end 920 | else 921 | c = strread(p,'%s','delimiter','\\/'); 922 | c = [{filesep};c(2:end)]; 923 | network_vol = ''; 924 | end 925 | end 926 | 927 | % -------------------- 928 | 929 | function p = cell2path(c) 930 | % Turns a cell array of path elements into a path string. 931 | if ispc 932 | p = fullfile(c{2:end},''); 933 | else 934 | p = fullfile(c{:},''); 935 | end 936 | end 937 | 938 | % -------------------- 939 | 940 | function d = filtered_dir(full_filter,re_filter,filter_both) 941 | % Like dir, but applies filters and sorting. 942 | p = fileparts(full_filter); 943 | if isempty(p) && full_filter(1) == '/' 944 | p = '/'; 945 | end 946 | if exist(full_filter,'dir') 947 | dfiles = dir(' '); 948 | else 949 | dfiles = dir(full_filter); 950 | end 951 | if ~isempty(dfiles) 952 | dfiles([dfiles.isdir]) = []; 953 | end 954 | ddir = dir(p); 955 | ddir = ddir([ddir.isdir]); 956 | % Additional regular expression filter. 957 | if nargin > 1 && ~isempty(re_filter) 958 | if ispc || ismac 959 | no_match = cellfun('isempty',regexpi({dfiles.name},re_filter)); 960 | else 961 | no_match = cellfun('isempty',regexp({dfiles.name},re_filter)); 962 | end 963 | dfiles(no_match) = []; 964 | end 965 | if filter_both 966 | if nargin > 1 && ~isempty(re_filter) 967 | if ispc || ismac 968 | no_match = cellfun('isempty',regexpi({ddir.name},re_filter)); 969 | else 970 | no_match = cellfun('isempty',regexp({ddir.name},re_filter)); 971 | end 972 | ddir(no_match) = []; 973 | end 974 | end 975 | % Set navigator style: 976 | % 1 => list all directories before all files, case-insensitive sorting 977 | % 2 => mix files and directories, case-insensitive sorting 978 | % 3 => list all directories before all files, case-sensitive sorting 979 | nav_style = 1; 980 | switch nav_style 981 | case 1 982 | [unused,index1] = sort(lower({dfiles.name})); 983 | ddir(strcmp({ddir.name},'.') | strcmp({ddir.name},'..')) = []; 984 | [unused,index2] = sort(lower({ddir.name})); 985 | d = [ddir(index2);dfiles(index1)]; 986 | case 2 987 | ddir(strcmp({ddir.name},'.') | strcmp({ddir.name},'..')) = []; 988 | d = [dfiles;ddir]; 989 | [unused,index] = sort(lower({d.name})); 990 | d = d(index); 991 | case 3 992 | [unused,index1] = sort({dfiles.name}); 993 | ddir(strcmp({ddir.name},'.') | strcmp({ddir.name},'..')) = []; 994 | [unused,index2] = sort({ddir.name}); 995 | d = [ddir(index2);dfiles(index1)]; 996 | end 997 | end 998 | 999 | % -------------------- 1000 | 1001 | function drives = getdrives(other_drives) 1002 | % Returns a cell array of drive names on Windows. 1003 | letters = char('A':'Z'); 1004 | num_letters = length(letters); 1005 | drives = cell(1,num_letters); 1006 | for i = 1:num_letters 1007 | if exist([letters(i),':\'],'dir'); 1008 | drives{i} = [letters(i),':']; 1009 | end 1010 | end 1011 | drives(cellfun('isempty',drives)) = []; 1012 | if nargin > 0 && iscellstr(other_drives) 1013 | drives = [drives,unique(other_drives)]; 1014 | end 1015 | end 1016 | 1017 | % -------------------- 1018 | 1019 | function filenames = annotate_file_names(filenames,dir_listing,fsdata) 1020 | % Adds a trailing filesep character to directory names and, optionally, 1021 | % prepends a folder icon or bullet symbol. 1022 | for i = 1:length(filenames) 1023 | if dir_listing(i).isdir 1024 | filenames{i} = sprintf('%s%s%s%s',fsdata.pre,filenames{i},... 1025 | fsdata.filesep,fsdata.post); 1026 | end 1027 | end 1028 | end 1029 | 1030 | % -------------------- 1031 | 1032 | function hist_menus = make_history_cm(cb,hist_cm,hist_menus,history) 1033 | % Make context menu for history. 1034 | if ~isempty(hist_menus) 1035 | delete(hist_menus) 1036 | end 1037 | num_hist = length(history); 1038 | hist_menus = zeros(1,num_hist); 1039 | for i = 1:num_hist 1040 | hist_menus(i) = uimenu(hist_cm,'Label',history{i},... 1041 | 'Callback',{cb,i}); 1042 | end 1043 | end 1044 | 1045 | % -------------------- 1046 | 1047 | function success = generate_folder_icon(icon_path) 1048 | % Black = 1, manila color = 2, transparent = 3. 1049 | im = [ ... 1050 | 3 3 3 1 1 1 1 3 3 3 3 3; 1051 | 3 3 1 2 2 2 2 1 3 3 3 3; 1052 | 3 1 1 1 1 1 1 1 1 1 1 3; 1053 | 1 2 2 2 2 2 2 2 2 2 2 1; 1054 | 1 2 2 2 2 2 2 2 2 2 2 1; 1055 | 1 2 2 2 2 2 2 2 2 2 2 1; 1056 | 1 2 2 2 2 2 2 2 2 2 2 1; 1057 | 1 2 2 2 2 2 2 2 2 2 2 1; 1058 | 1 2 2 2 2 2 2 2 2 2 2 1; 1059 | 1 1 1 1 1 1 1 1 1 1 1 1]; 1060 | cmap = [0 0 0;255 220 130;255 255 255]/255; 1061 | fid = fopen(icon_path,'w'); 1062 | if fid > 0 1063 | fclose(fid); 1064 | imwrite(im,cmap,icon_path,'Transparency',[1 1 0]) 1065 | end 1066 | success = exist(icon_path,'file'); 1067 | end 1068 | 1069 | % -------------------- 1070 | 1071 | function fsdata = set_folder_style(folder_style_pref) 1072 | % Set style to preference. 1073 | fsdata.style = folder_style_pref; 1074 | % If style = 1, check to make sure icon image file exists. If it doesn't, 1075 | % try to create it. If that fails set style = 2. 1076 | if fsdata.style == 1 1077 | icon_path = fullfile(fileparts(mfilename('fullpath')),... 1078 | 'uipickfiles_folder_icon.png'); 1079 | if ~exist(icon_path,'file') 1080 | success = generate_folder_icon(icon_path); 1081 | if ~success 1082 | fsdata.style = 2; 1083 | end 1084 | end 1085 | end 1086 | % Set pre and post fields. 1087 | if fsdata.style == 1 1088 | icon_url = ['file://localhost/',... 1089 | strrep(strrep(icon_path,':','|'),'\','/')]; 1090 | fsdata.pre = sprintf(' ',icon_url); 1091 | fsdata.post = ''; 1092 | elseif fsdata.style == 2 1093 | fsdata.pre = ' '; 1094 | fsdata.post = ''; 1095 | elseif fsdata.style == 3 1096 | fsdata.pre = ''; 1097 | fsdata.post = ''; 1098 | end 1099 | fsdata.filesep = filesep; 1100 | 1101 | end 1102 | -------------------------------------------------------------------------------- /Matlab/uipickfiles_folder_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenPIV/openpiv-podbox/e3a745416924239416bdd0e081f4cb86e3e70eef/Matlab/uipickfiles_folder_icon.png -------------------------------------------------------------------------------- /Matlab/vecread.m: -------------------------------------------------------------------------------- 1 | function [varargout] = vecread(varargin) 2 | %VECREAD Reads *.VEC files produced by Insight 3.3 software 3 | % [HEADER,DATA] = VECREAD(FILENAME,HEADLINE,COLUMNS) will read the 4 | % FILENAME file (with or without .vec extension), with HEADLINE, number 5 | % of header lines, usually 1, and COLUMNS, number of columns in the file, 6 | % usually 5. HEADER is a string and DATA is a 3D matrix as described below. 7 | % 8 | % [DATA] = VECREAD(FILENAME) Reads the FILENAME.VEC to the DATA 3D matrix 9 | % as described below, and default values for HEADLINE = 1, COLUMNS = 5 10 | % (Usual 2D .vec file) are used. 11 | % 12 | % DATA(:,:,1)=X, DATA(:,:,2)=Y, DATA(:,:,3)=U, DATA(:,:,4)=V, DATA(:,;,5)=CHC. 13 | % (See Insight manual for more info) 14 | % 15 | % example: 16 | % [h,d] = vecread('tmp.vec',1,5); 17 | % quivervec(d); 18 | % title(h); 19 | % 20 | % See also READEXPDIR QUIVERVEC 21 | % 22 | 23 | % Created: 21-May-2001 24 | % Author: Alex Liberzon 25 | % Copyright (c) 2001 - 2016 OpenPIV 26 | % 27 | % Modified at: 21-May-2001 28 | % $Revision: 1.0 $ $Date: 21-May-2001 09:36:48$ 29 | % 30 | % $Revision: 2.0 $ $Date: 21-May-2001 21:08:48$ 31 | % - change the reshaping 32 | % - change the inputs check 33 | % $Revision: 2.1 $ $Date: 27-May-2001 22:46:48$ 34 | % - minor changes of the HELP section 35 | % $Revision: 3.0 $ $Date: 28-May-2001 22:43:00$ 36 | % - 'Bad data' points are replaced by NaNs (>9.99e9); 37 | % $Revision: 3.1 $ $Date: 17-Jun-2001 21:49:00$ 38 | % - 'Bad data' points are replaced by 0 (zeros) (>9.99e9); 39 | % NaNs are not compatible with the following POD analysis 40 | % Modified at: June 03, 2004 by Alex Liberzon 41 | % - updated version can read multi-column VEC files, automatically 42 | % scanning the header for the number of variables. 43 | % usual VEC and V3D files work fine, unusual V3D are not checked 44 | 45 | 46 | 47 | % Inputs: 48 | narginchk(1,3); 49 | % Defaults: 50 | if nargin < 3 51 | varargin{3} = 5; % default columns value 52 | if nargin < 2 53 | varargin{2} = 1; % default number of header lins 54 | end 55 | end 56 | 57 | % Assign variables 58 | name = varargin{1}; 59 | comments = varargin{2}; 60 | columns = varargin{3}; 61 | 62 | % Extension issue 63 | if isempty(strfind(name,'.vec')), name = strcat(name,'.vec'); end; 64 | 65 | % Read the file 66 | fid=fopen(name,'r'); 67 | 68 | if fid<0 69 | errordlg('File not found'); 70 | end 71 | [dch,count]=fread(fid,inf,'uchar'); 72 | fclose(fid); 73 | 74 | % Reformat the data 75 | chdat=[dch(:)',char(13)]; 76 | 77 | ind10 = find(chdat == char(10)); 78 | chdat(ind10) = repmat(char(13),[length(ind10),1]); 79 | % chdat(ind10) = repmat(char(' '),[length(ind10),1]); 80 | 81 | % comp=computer; 82 | % if strcmp(comp(1:3),'PCW')|strcmp(comp(1:3),'VAX')|strcmp(comp(1:3),'ALP'), 83 | % % replace cr-lf with cr only for PC's, VAXen and Alphas 84 | % chdat(ind10)=char(' '*ones(1,length(ind10))); 85 | % else 86 | % %replace line-feeds with carriage-returns for Unix boxes 87 | % chdat(ind10)=char(13*ones(length(ind10),1)); 88 | % end 89 | 90 | % Now replace commas with spaces 91 | indcom = find(chdat == ','); 92 | chdat(indcom) = repmat(char(' '),[length(indcom),1]); 93 | 94 | %find carriage-returns 95 | ind13 = find(chdat == char(13)); 96 | 97 | % Truncate array to just have data 98 | if comments==0, 99 | char1=1; 100 | else 101 | char1=ind13(comments)+1; 102 | end 103 | hdr = lower(chdat(1:char1-1)); 104 | chdata=chdat(char1:count); 105 | 106 | % Update of the vecread towards Insight 7 with plugins and new variables 107 | % multiple-columns, June 03, 2004. 108 | % Alex, 22.02.08 - some change in VEC files - the space after variables= 109 | % disappeared, new columns appeared, e.g. datasetauxdata ... 110 | % variables = hdr(findstr(hdr,'variables=')+length('variables='):findstr(hdr,'zone')-1); 111 | try 112 | variables = hdr(strfind(hdr,'variables=')+length('variables='):strfind(hdr,'chc')+4); % '"chc" 113 | % columns = length(findstr(variables,'"'))/2; 114 | id = strfind(chdata(2:1000),char(13)); % char(13) is a newline 115 | id = id(1); % only first line 116 | firstline = chdata(1:id); 117 | tmp = sscanf(firstline,'%g'); 118 | columns = length(tmp); 119 | ind = strfind(variables,'"'); 120 | xUnits = variables(ind(1)+2:ind(2)-1); 121 | uUnits = variables(ind(5)+2:ind(6)-1); 122 | catch 123 | columns = 5; 124 | xUnits = ''; 125 | uUnits = ''; 126 | end 127 | data = sscanf(chdata,'%g',[columns inf])'; 128 | 129 | % Find and remove bad points > 9.99e9 130 | data(data>9e9) = 0; 131 | 132 | % Parse the header 133 | 134 | i = strfind(hdr,'i='); 135 | j = strfind(hdr,'j='); 136 | [i,~] = strtok(hdr(i+2:end)); 137 | [j,~] = strtok(hdr(j+2:end)); 138 | 139 | i = eval(i); j = eval(j); 140 | 141 | data = reshape(data,[i,j,columns]); 142 | data = permute(data,[2 1 3]); 143 | 144 | if nargout == 1 145 | varargout{1} = data; 146 | elseif nargout == 2 147 | varargout{1} = hdr; 148 | varargout{2} = data; 149 | elseif nargout == 3 150 | varargout{1} = xUnits; 151 | varargout{2} = uUnits; 152 | varargout{3} = data; 153 | elseif nargout == 4 154 | varargout{1} = hdr; 155 | varargout{2} = data; 156 | varargout{3} = str2int(i); 157 | varargout{4} = str2int(j); 158 | else 159 | warning('Wrong number of outputs') ; 160 | end 161 | -------------------------------------------------------------------------------- /Python/notebooks/poduv.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "# copy of poduv.m" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": null, 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "# read data and rearrange in columns\n", 19 | "[r,c,N] = size(u);\t# 4-D is the number of files\n", 20 | "\n", 21 | "len = r*c;\n", 22 | "\n", 23 | "U = zeros(len*2,N); # r*c*3 length of the vector\n", 24 | "\n", 25 | "% small rearrangement\n", 26 | "for i = 1:N\n", 27 | " U(1:len,i) = reshape(handles.u(:,:,i),len,1);\n", 28 | " U(len+1:2*len,i) = reshape(handles.v(:,:,i),len,1);\n", 29 | "end\n", 30 | "\n", 31 | "% Ensemble average of U:\n", 32 | "% meanU = mean(U,2);\n", 33 | "% Uf = U;\n", 34 | "% meanU = zeros(len,1);\n", 35 | "% Fluctuations\n", 36 | "% % Uf = U - repmat(meanU,1,N);\n", 37 | "% for i = 1:N\n", 38 | "% Uf(:,i) = U(:,i) - meanU;\n", 39 | "% end\n", 40 | "\n", 41 | "Uf = bsxfun(@minus,U,mean(U,2));" 42 | ] 43 | } 44 | ], 45 | "metadata": { 46 | "kernelspec": { 47 | "display_name": "Python 3", 48 | "language": "python", 49 | "name": "python3" 50 | }, 51 | "language_info": { 52 | "codemirror_mode": { 53 | "name": "ipython", 54 | "version": 3 55 | }, 56 | "file_extension": ".py", 57 | "mimetype": "text/x-python", 58 | "name": "python", 59 | "nbconvert_exporter": "python", 60 | "pygments_lexer": "ipython3", 61 | "version": "3.6.4" 62 | } 63 | }, 64 | "nbformat": 4, 65 | "nbformat_minor": 2 66 | } 67 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | OpenPIV Proper Orthogonal Decomposition (POD) Toolbox 2 | ===================================================== 3 | 4 | Proper Orthogonal Decomposition (POD) or Principal Component Analysis (PCA) http://en.wikipedia.org/wiki/Principal_component_analysis is an objective method to extract the most energetic structures from numerical or experimental data, in our case of fluid mechanics. The toolbox was originally developed by the OpenPIV group for the use with the Matlab (tm) version of OpenPIV in 2000, then for the use with Insight (tm) software by TSI Inc. (www.tsi.com). At present it can read the PIV data from OpenPIV (TXT ASCII files), Insight (VEC format) or OpenPIV Spatial Toolbox MAT files. The toolbox can estimate the POD modes using direct or snapshots method and it provides an extra layer of fluid dynamics insight using the linear combination of the POD modes, enabling the coherent structures detection and characterization. For the details, see the article listed below. 5 | 6 | 7 | How to obtain the toolbox 8 | ------------------------- 9 | 10 | Use Github repository if you wish to develop the toolbox further or download the ZIP file of the recent branch to get the repository copy without Git. 11 | 12 | 13 | How to use the toolbox 14 | ---------------------- 15 | 16 | Open Matlab, add the toolbox to the path using ```addpath''' or the graphical interface or simply change the folder to the POD Toolbox folder. Type: 17 | 18 | >> podbox 19 | 20 | The directory includes the folder ```/test''' with a small set of VEC files. Please follow the detailed Getting Started manual in the ```/docs''' directory 21 | 22 | 23 | 24 | 25 | How to cite this toolbox 26 | ------------------------ 27 | 28 | Use Bibtex: 29 | 30 | 31 | 32 | @article{Gurka2006416, 33 | title = "\{POD\} of vorticity fields: A method for spatial characterization of coherent structures ", 34 | journal = "International Journal of Heat and Fluid Flow ", 35 | volume = "27", 36 | number = "3", 37 | pages = "416 - 423", 38 | year = "2006", 39 | note = "", 40 | issn = "0142-727X", 41 | doi = "http://dx.doi.org/10.1016/j.ijheatfluidflow.2006.01.001", 42 | url = "http://www.sciencedirect.com/science/article/pii/S0142727X06000026", 43 | author = "Roi Gurka and Alexander Liberzon and Gad Hetsroni", 44 | keywords = "Boundary layer", 45 | keywords = "Vorticity", 46 | keywords = "Proper orthogonal decomposition", 47 | keywords = "Coherent structures", 48 | keywords = "Identification ", 49 | abstract = "We present a method to identify large scale coherent structures, in turbulent flows, and characterize them. The method is based on the linear combination of the proper orthogonal decomposition (POD) modes of vorticity. Spanwise vorticity is derived from the two-dimensional and two-component velocity fields measured by means of particle image velocimetry (PIV) in the streamwise–wall normal plane of a fully developed turbulent boundary layer in a flume. The identification method makes use of the whole data set simultaneously, through the two-point correlation tensor, providing a statistical description of the dominant coherent motions in a turbulent boundary layer. The identified pattern resembles an elongated, quasi-streamwise, vortical structure with streamwise length equal to the water height in the flume and inclined upwards in the streamwise–wall normal plane at angle of approximately 8°. " 50 | } 51 | 52 | 53 | -------------------------------------------------------------------------------- /runPOD_Matlab.bat: -------------------------------------------------------------------------------- 1 | matlab -nosplash -nodesktop -minimize -r Matlab/podbox --------------------------------------------------------------------------------