function plotreg(plottype, frame)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% %%
%% Copyright (C) 2005-2007 Anurag Singh %%
%% %%
%% This program/code snippet/file (hence forth refered as "library") %%
%% is free software; you can redistribute it and/or %%
%% modify it under the terms of the GNU Lesser General Public %%
%% License as published by the Free Software Foundation; either %%
%% version 2.1 of the License, or (at your option) any later version. %%
%% %%
%% This library is distributed in the hope that it will be useful, %%
%% but WITHOUT ANY WARRANTY; without even the implied warranty of %%
%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU %%
%% Lesser General Public License for more details. %%
%% %%
%% You should have received a copy of the GNU Lesser General Public %%
%% License along with this library; if not, write to the Free Software %%
%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA %%
%% %%
%% FILENAME: %%
%% plotreg.m %%
%% %%
%% AUTHOR: %%
%% %%
%% Anurag Singh, %%
%% MS, 2007 %%
%% Aerospace Engineering & Mechanics %%
%% University of Minnesota - Twin Cities. %%
%% Minneapolis, MN 55455 (USA) %%
%% %%
%% (currently working at: Exa Corporation, Burlington, MA 01803) %%
%% %%
%% CONTACT/EMAIL: %%
%% %%
%% anurag@aem.umn.edu %%
%% anurag9@gmail.com %%
%% %%
%% SOURCE CONTROL INFORMATION: %%
%% None (since I was planning on putting it under source control since it has %%
%% reached the critical file system size. Would be a good thing to put it under %%
%% source control while making changes. %%
%% %%
%% DESCRIPTION: %%
%% %%
%% %%
%% %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%USAGE
%
% plotreg(<plot_type>)
%
% where plot type could have any of the following string values:
% case 'reg vs frame'
%
% case 'try'
%
% case 'length vs thresh'
%
% case 'width vs thresh'
%
% case 'area vs thresh'
%
% case 'avgnumregion vs thresh'
%
% case 'numregion vs thresh'
%
% case 'image plot'
if(nargin < 1)
help plotreg;
return;
end
switch plottype
case 'reg vs frame'
plotregvsframe;
case 'try'
plottry;
case 'length vs thresh'
plot_length_pdf;
case 'width vs thresh'
plot_width_pdf;
case 'area vs thresh'
plot_area_pdf;
case 'avgnumregion vs thresh'
plot_avgnumregions;
case 'numregion vs thresh'
plot_numregions;
case 'image plot'
plot_image(frame);
otherwise
disp('PLOTREG ERROR: Unknown plot type');
end
return
function plotregvsframe()
global thresh NZ
%temp1 = [[thresh(m).regions(:).frame], [thresh(m).regions(:).length]]; % temp1 = [frame legth of identified frames
ny = size([thresh(:)],1) + 1;
regvsfrm = zeros(NZ,ny);
hold on;
avgregs = [];
for n=1:ny-1
temp2 = [];
temp2 = [[thresh(n).regions(:).frame]]; % get the frame data corresponding to threshold n
frame1 = temp2(1);
frame2 = temp2(end);
temp3 = hist(temp2,frame2 - frame1 + 1); % temp3 has the numregions for all the frames
avgregs = [avgregs mean(temp3)];
plot(frame1:frame2,temp3,getlinespec(n));
end
hold off;
plot([[thresh(:).value]],avgregs,'-*r');
return;
function linespec=getlinespec(n)
switch n
case 1
linespec = '-vr';
case 2
linespec = '-db';
case 3
linespec = '-sg';
case 4
linespec = '-ok';
case 5
linespec = '-*b';
case 6
linespec = '-^r';
case 7
linespec = '->g';
case 8
linespec = '-*r';
case 9
linespec = '-+r';
case 10
linespec = ':sr';
case 11
linespec = '--ob';
case 12
linespec = '-vg';
case 13
linespec = '-pk';
case 14
linespec = '-hm';
case 15
linespec = ':dg';
otherwise
linespec = '--<k';
end
return
function plottry
global thresh
%for n=1:8
% temp = [[thresh( 1).regions(:).frame]]; temp1 = hist(temp,temp(end) - temp(1) + 1); [t1 tx1 ] = hist(temp1 );
%end
temp = [[thresh( 1).regions(:).frame]]; temp1 = hist(temp,temp(end) - temp(1) + 1); [t1 tx1 ] = hist(temp1 );
temp = [[thresh( 2).regions(:).frame]]; temp2 = hist(temp,temp(end) - temp(1) + 1); [t2 tx2 ] = hist(temp2 );
temp = [[thresh( 3).regions(:).frame]]; temp3 = hist(temp,temp(end) - temp(1) + 1); [t3 tx3 ] = hist(temp3 );
temp = [[thresh( 4).regions(:).frame]]; temp4 = hist(temp,temp(end) - temp(1) + 1); [t4 tx4 ] = hist(temp4 );
temp = [[thresh( 5).regions(:).frame]]; temp5 = hist(temp,temp(end) - temp(1) + 1); [t5 tx5 ] = hist(temp5 );
temp = [[thresh( 6).regions(:).frame]]; temp6 = hist(temp,temp(end) - temp(1) + 1); [t6 tx6 ] = hist(temp6 );
temp = [[thresh( 7).regions(:).frame]]; temp7 = hist(temp,temp(end) - temp(1) + 1); [t7 tx7 ] = hist(temp7 );
temp = [[thresh( 8).regions(:).frame]]; temp8 = hist(temp,temp(end) - temp(1) + 1); [t8 tx8 ] = hist(temp8 );
%temp = [[thresh( 9).regions(:).frame]]; temp9 = hist(temp,temp(end) - temp(1) + 1); [t9 tx9 ] = hist(temp9 );
%temp = [[thresh(11).regions(:).frame]]; temp11 = hist(temp,temp(end) - temp(1) + 1); [t11 tx11] = hist(temp11);
%temp = [[thresh(12).regions(:).frame]]; temp12 = hist(temp,temp(end) - temp(1) + 1); [t12 tx12] = hist(temp12);
plot(tx1,t1,'->g'); hold on;
plot(tx2,t2,'-+b');
plot(tx3,t3,'-<c');
plot(tx4,t4,'->k');
plot(tx5,t5,'-dm');
plot(tx6,t6,'--^k');
plot(tx7,t7,':*m');
legend('0.50','0.75','1.00','1.25','1.50','1.75','2.00');
return
figure;
avgregs = [ mean(temp1 ) ...
mean(temp2 ) ...
mean(temp3 ) ...
mean(temp4 ) ...
mean(temp5 ) ...
mean(temp6 ) ...
mean(temp7 ) ...
mean(temp8 ) ...
mean(temp9 ) ...
mean(temp10) ...
mean(temp11) ...
mean(temp12) ];
plot(0.5:0.15:2.25,avgregs,':*g');
return
function plot_length_pdf()
global thresh
title(['Effect of velocity threshold on length of the identified regions/per frame',sprintf('\n'),'(U_{th} = U_{m} - n*U_{\sigma})']);
xlabel('Normalized slow speed region length, \lambda^{+}_{x} ->');
ylabel('Frequency count/PDF ->');
hold on;
for n=1:size(thresh,2)
temp1 = thresh(n).regions;
temp2 = [temp1(:).length];
t1 = []; tx1 = [];
[t1 x1] = hist(temp2);
plot(x1,t1,getlinespec(n));
end
legend(char(num2str([thresh(:).value]')));
hold off;
return
function plot_width_pdf()
global thresh
title(['Effect of velocity threshold on width of the identified regions/per frame',sprintf('\n'),'(U_{th} = U_{m} - n*U_{\sigma})']);
xlabel('Normalized slow speed region width, \lambda^{+}_{y} ->');
ylabel('Frequency count/PDF ->');
hold on;
for n=1:size(thresh,2)
temp1 = thresh(n).regions;
temp2 = [temp1(:).width];
t1 = []; tx1 = [];
[t1 x1] = hist(temp2);
plot(x1,t1,getlinespec(n));
end
legend(char(num2str([thresh(:).value]')));
hold off;
return
function plot_area_pdf()
global thresh
title(['Effect of velocity threshold on area of the identified regions/per frame',sprintf('\n'),'(U_{th} = U_{m} - n*U_{\sigma})']);
xlabel('Normalized slow speed region area, A^{+}_{y} ->');
ylabel('Frequency count/PDF ->');
hold on;
for n=1:size(thresh,2)
temp1 = thresh(n).regions;
temp2 = [temp1(:).area];
t1 = []; tx1 = [];
[t1 x1] = hist(temp2);
plot(x1,t1,getlinespec(n));
end
legend(char(num2str([thresh(:).value]')));
hold off;
return
function plot_avgnumregions()
global thresh
avgregs = [];
for n=1:size(thresh,2)
temp = [[thresh(n).regions(:).frame]];
temp1 = hist(temp,temp(end) - temp(1) + 1);
avgregs = [avgregs mean(temp1)];
end
plot([thresh(:).value],avgregs,getlinespec(1));
title(['Effect of velocity threshold on average no. identified regions/per frame',sprintf('\n'),'(U_{th} = U_{m} - n*U_{\sigma})']);
xlabel('Threshold multiplier n; (U_{th} = U_{m} - n*U_{\sigma}) ->');
ylabel('Average number of identified regions per frame ->');
return
function plot_numregions()
global thresh
title(['Effect of velocity threshold on no. identified regions/per frame',sprintf('\n'),'(U_{th} = U_{m} - n*U_{\sigma})']);
xlabel('No. of identified regions ->');
ylabel('Frequency count/PDF ->');
hold on;
for n=1:size(thresh,2)
temp = [[thresh(n).regions(:).frame]];
temp1 = hist(temp,temp(end) - temp(1) + 1);
t1 = []; tx1 = [];
[t1 tx1] = hist(temp1 );
plot(tx1,t1,getlinespec(n));
end
hold off;
legend(char(num2str([thresh(:).value]')));
return
function plot_image(frame)
global x y piv_ustd vecimfreq u_norm u v uim xim yim uim xim1 yim1 uim1 xim3 yim3 uim3 delta_99 u_tau nu slowregion
global piv_ustdplus u_normplus v_plus
n = 3;
zdispim = squeeze(u_norm(frame,:,:));
zdispim = squeeze(u_normplus(frame,:,:));
figure;
colormap(hsvmap(30,5,[1 0 0],[0 0 1]));
pcolor(x*u_tau/nu, y*u_tau/nu, zdispim); % the squeeze is to squeeze down a 3d matrix (where one of the dimensions is one) to a 2d matrix
% caxis([-n*piv_ustd n*piv_ustd]) % i am setting the colorbar based on the rms of the signal
caxis([-n*piv_ustdplus n*piv_ustdplus]) % i am setting the colorbar based on the rms of the signal
title(['Image frame # ',num2str(frame),' at time ', num2str(frame/vecimfreq, '%.5f'), ' s'])
xlabel('x^{+}');
ylabel('y^{+}');
cb = colorbar('vert'); % display the colorbar
set(get(cb,'YLabel'),'String',['Normalized, streamwise fluctuating velocity, u^{+}']);
shading interp; % interpolated shading
lighting phong; % nice spline fit to the shading
daspect([1 1 1]); % set aspect ratio to one (equal x and y scale)
hold on;
% quiver(x*u_tau/nu, y*u_tau/nu, squeeze(u_norm(frame,:,:)), squeeze(v(frame,:,:)),1.5,'k');
quiver(x*u_tau/nu, y*u_tau/nu, squeeze(u_normplus(frame,:,:)), squeeze(v_plus(frame,:,:)),1.5,'k');
[c h]=contour(x*u_tau/nu,y*u_tau/nu,(slowregion == 0), 1, '-k' ); set(h,'linewidth',3);
hold off;
return