VMT_PlotXSContQuiver

PURPOSE ^

This function plots the the contour plot (mean XS) for the variable 'var'

SYNOPSIS ^

function [z,A,V,log_text] = VMT_PlotXSContQuiver(z,A,V,var,sf,exag,qspchorz,qspcvert,secvecvar,vvelcomp,plot_english,varargin)

DESCRIPTION ^

 This function plots the the contour plot (mean XS) for the variable 'var'
 and then plots quivers with secondary flow (vertical and transverse
 components) on top of the contour plot.  IF data is not supplied, user
 will be prompted to load data (browse to data).


 (adapted from code by J. Czuba)

 P.R. Jackson, USGS, 12-10-08 
 Last modified: F.L. Engel, USGS, 2/20/2013

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [z,A,V,log_text] = VMT_PlotXSContQuiver(z,A,V,var,sf,exag,qspchorz,qspcvert,secvecvar,vvelcomp,plot_english,varargin)
0002 % This function plots the the contour plot (mean XS) for the variable 'var'
0003 % and then plots quivers with secondary flow (vertical and transverse
0004 % components) on top of the contour plot.  IF data is not supplied, user
0005 % will be prompted to load data (browse to data).
0006 %
0007 %
0008 % (adapted from code by J. Czuba)
0009 %
0010 % P.R. Jackson, USGS, 12-10-08
0011 % Last modified: F.L. Engel, USGS, 2/20/2013
0012 
0013 
0014 %% User input
0015 if exist('plot_english') == 0
0016     plot_english = 0;  %plot english units (else metric)
0017     disp('No units specified, plotting in metric units by default')
0018 end
0019 
0020 AS = 1;  %Turns on and off autoscaling (0 = off, 1 = on)
0021 if AS == 0
0022     MANrefvel = 25; %Reference velocity in cm/s (manual setting)
0023 end
0024 
0025 %% Parse any extra args
0026 %  This is used by VMT_GraphicsControl
0027 if any(size(varargin)>0)
0028     reference_velocity = varargin{1};
0029     distance           = varargin{2};
0030     depth              = varargin{3};
0031 else
0032     reference_velocity = [];
0033     distance           = [];
0034     depth              = [];
0035 end
0036 
0037 %% Plot the contour plot
0038 if isempty(z) & isempty(A) & isempty(V)
0039     [z,A,V,zmin,zmax,cont_log_text,fig_contour_handle] = VMT_PlotXSCont([],[],[],var,exag,plot_english);
0040 else
0041     [z,A,V,zmin,zmax,cont_log_text,fig_contour_handle] = VMT_PlotXSCont(z,A,V,var,exag,plot_english);
0042 end
0043 log_text = cont_log_text;
0044 
0045 % if vvelcomp
0046 %     disp(['Plotting Secondary Flow Vector Field: ' secvecvar ' (with vertical velocity component)'])
0047 % else
0048 %     disp(['Plotting Secondary Flow Vector Field: ' secvecvar ' (without vertical velocity component)'])
0049 % end
0050 %% Plot the secondary flow quivers
0051 
0052 if plot_english
0053     sf = sf/0.01;  %Scale factor changes with units--this makes the sf basically equal for engligh units to that for metric units
0054 end
0055 
0056 %User input
0057 
0058 clvls = 60;
0059 %sf=3;       %Scale factor
0060 %exag=50;    %Vertical exaggeration
0061 %qspchorz=20;   %Vector spacing in # of ensembles
0062 
0063 % Misc computations
0064 if 0 %A(1).Sup.binSize_cm == 25  %Changed some stuff below--not sure of the reason this 25 cm binsize is singled out  PRJ  (singled out due to vertical velocity bias--omit for now)
0065     [I,J] = ind2sub(size(V.vp(2,:)),find(~isnan(V.vp(2,:))==1));  % Use row 2 because all row 1 values are nans (WHY???--set to zero for ringing?)
0066     et = J(1):qspchorz:J(end);
0067     [r c]=size(V.vp);
0068     bi = 1:2:r;  %8:4:r;
0069 else
0070     [I,J] = ind2sub(size(V.vp(1,:)),find(~isnan(V.vp(1,:))==1));
0071     et = J(1):qspchorz:J(end);
0072     [r c]=size(V.vp);
0073     bi = 1:qspcvert:r;
0074 end
0075 
0076 %zmin = floor(nanmin(nanmin(V.vp)));
0077 %zmax = ceil(nanmax(nanmax(V.vp)));
0078 %zinc = (zmax - zmin) / clvls;
0079 %zlevs = zmin:zinc:zmax;
0080 
0081 %Set the vertical velocity component
0082 if vvelcomp  %include vertical velocity compoent in vector?
0083     vertcomp = V.wSmooth;
0084 else
0085     vertcomp = zeros(size(V.wSmooth));
0086 end
0087 
0088 figure(fig_contour_handle); hold all
0089 %quiver(V.mcsDist(bi,et),V.mcsDepth(bi,et),-sf.*V.vsSmooth(bi,et),-sf.*V.wSmooth(bi,et),0,'k')
0090 switch secvecvar
0091     case{'transverse'}  %uses secondary velocity computed in the plane of the mean cross section (i.e. transverse)
0092         vr = sqrt(abs((-sf.*V.vSmooth(bi,et)).^2 + (-sf./exag.*vertcomp(bi,et)).^2));
0093     case{'secondary_zsd'} %Uses secondary velocity computed with a zero secondary discharge
0094         vr = sqrt(abs((-sf.*V.vsSmooth(bi,et)).^2 + (-sf./exag.*vertcomp(bi,et)).^2));  
0095     case{'secondary_roz'}
0096         vr = sqrt(abs((-sf.*V.Roz.usSmooth(bi,et)).^2 + (-sf./exag.*vertcomp(bi,et)).^2));
0097     case{'secondary_roz_y'}
0098         vr = sqrt(abs((-sf.*V.Roz.usySmooth(bi,et)).^2 + (-sf./exag.*vertcomp(bi,et)).^2));
0099     case{'primary_roz_y'}
0100         vr = sqrt(abs((-sf.*V.Roz.upySmooth(bi,et)).^2 + (-sf./exag.*vertcomp(bi,et)).^2));
0101 end
0102         
0103 %vr=sqrt(abs(-sf.*V.vsSmooth(bi,et).^2+-sf./exag.*V.wSmooth(bi,et).^2));
0104 [rw cl] = size(V.mcsDist(bi,et));
0105 toquiv(:,1) = reshape(V.mcsDist(bi,et),rw*cl,1);
0106 toquiv(:,2) = reshape(V.mcsDepth(bi,et),rw*cl,1);
0107 switch secvecvar
0108     case{'transverse'}
0109         toquiv(:,3) = reshape(-sf.*V.vSmooth(bi,et),rw*cl,1); %Add negative sign to reverse the +x direction (we take RHR with +x into the page lookign DS, matlab uses opposite convention)
0110         refvel = ceil(max(max(abs(V.vSmooth(bi,et)))));
0111         %meansecvec = mean(mean(V.vSmooth(bi,et)));
0112     case{'secondary_zsd'}
0113         toquiv(:,3) = reshape(-sf.*V.vsSmooth(bi,et),rw*cl,1); %Add negative sign to reverse the +x direction (we take RHR with +x into the page lookign DS, matlab uses opposite convention)
0114         refvel = ceil(max(max(abs(V.vsSmooth(bi,et)))));
0115         %meansecvec = mean(mean(V.vsSmooth(bi,et)));
0116     case{'secondary_roz'}
0117         toquiv(:,3) = reshape(-sf.*V.Roz.usSmooth(bi,et),rw*cl,1); %Add negative sign to reverse the +x direction (we take RHR with +x into the page lookign DS, matlab uses opposite convention)
0118         refvel = ceil(max(max(abs(V.Roz.usSmooth(bi,et)))));
0119         %meansecvec = mean(mean(V.Roz.us(bi,et)));
0120     case{'secondary_roz_y'}
0121         toquiv(:,3) = reshape(-sf.*V.Roz.usySmooth(bi,et),rw*cl,1); %Add negative sign to reverse the +x direction (we take RHR with +x into the page lookign DS, matlab uses opposite convention)
0122         refvel = ceil(max(max(abs(V.Roz.usySmooth(bi,et)))));
0123         %meansecvec = mean(mean(V.Roz.usy(bi,et)));
0124     case{'primary_roz_y'}
0125         toquiv(:,3) = reshape(-sf.*V.Roz.upySmooth(bi,et),rw*cl,1); %Add negative sign to reverse the +x direction (we take RHR with +x into the page lookign DS, matlab uses opposite convention)
0126         refvel = ceil(max(max(abs(V.Roz.upySmooth(bi,et)))));
0127         %meansecvec = mean(mean(V.Roz.upy(bi,et))));
0128 end
0129 toquiv(:,4) = reshape(-sf./exag.*vertcomp(bi,et),rw*cl,1);  %Add negative sign to account for flipped vertical axes
0130 toquiv(:,5) = reshape(vr,rw*cl,1);
0131 
0132 %Ref arrow
0133 if isempty(distance)
0134     x1 = 0.06*max(max(V.mcsDist));
0135     x2 = 0.95*max(max(V.mcsBed));
0136     if AS == 0
0137         refvel = MANrefvel; %manual scaling
0138     end
0139 else
0140     x1 = distance;
0141     x2 = depth;
0142     refvel = reference_velocity;
0143 end
0144 x3=sf.*refvel; %Set to rounded max secondary velocity (absolute value added 3/29/12 PRJ) (autoscaling)
0145 x4=0;
0146 x5=x3;
0147 toquiv(end+1,1) = x1;
0148 toquiv(end,2) = x2;
0149 toquiv(end,3) = x3;
0150 toquiv(end,4) = x4;
0151 toquiv(end,5) = x5;
0152 %quiverc(toquiv(:,1),toquiv(:,2),toquiv(:,3),toquiv(:,4),sf); hold on
0153 
0154 if plot_english
0155     unitlabel = '(ft/s)';
0156 else
0157     unitlabel = '(cm/s)';
0158 end
0159 
0160 if plot_english %english units
0161     convfact = 0.03281; %cm/s to ft/s
0162     switch var
0163         case{'backscatter'}
0164             convfact = 1.0; 
0165         case{'flowangle'}
0166             convfact = 1.0;
0167     end
0168     
0169     hh = quiverc2wcmap(toquiv(:,1)*3.281,toquiv(:,2)*3.281,toquiv(:,3)*0.03281,toquiv(:,4)*0.03281,0,toquiv(:,5)*0.03281,exag);
0170     %plot(V.mcsDist(1,:)*3.281,V.mcsBed*3.281,'w', 'LineWidth',2); hold on
0171     ylim([0 max(V.mcsBed*3.281)])
0172     caxis([zmin*convfact zmax*convfact]) %Reset the color bar to match that in the original contour plot
0173     switch var        
0174         case{'streamwise'}
0175             title_handle = title({['Streamwise Velocity ' unitlabel];['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0176         case{'transverse'}
0177             title_handle = title({['Transverse Velocity ' unitlabel];['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0178         case{'vertical'}
0179             title_handle = title({['Vertical Velocity ' unitlabel];['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0180         case{'mag'}
0181             title_handle = title({['Velocity Magnitude (Streamwise and Transverse) ' unitlabel];['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0182         case{'east'}
0183             title_handle = title({'East Velocity';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0184         case{'north'}
0185             title_handle = title({'North Velocity';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0186         case{'primary_zsd'}
0187             title_handle = title({['Primary Velocity (Zero Secondary Discharge Definition) ' unitlabel];['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0188         case{'secondary_zsd'}
0189             title_handle = title({['Secondary Velocity (Zero Secondary Discharge Definition) ' unitlabel];['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0190         case{'primary_roz'}
0191             title_handle = title({['Primary Velocity (Rozovskii Definition) ' unitlabel];['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0192         case{'secondary_roz'}
0193             title_handle = title({['Secondary Velocity (Rozovskii Definition) ' unitlabel];['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0194         case{'primary_roz_x'}
0195             title_handle = title({['Primary Velocity (Rozovskii Definition; Downstream Component) ' unitlabel];['with secondary flow vectors (' secvecvar ')']},'Interpreter','none'); 
0196         case{'primary_roz_y'}
0197             title_handle = title({['Primary Velocity (Rozovskii Definition; Cross-Stream Component) ' unitlabel];['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');       
0198         case{'secondary_roz_x'}
0199             title_handle = title({['Secondary Velocity (Rozovskii Definition; Downstream Component) ' unitlabel];['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');       
0200         case{'secondary_roz_y'}
0201             title_handle = title({['Secondary Velocity (Rozovskii Definition; Cross-Stream Component) ' unitlabel];['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0202         case{'backscatter'}
0203             title({'Backscatter Intensity (dB)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0204         case{'flowangle'}
0205             title_handle = title({'Flow Direction (deg)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0206     end
0207 
0208     ylabel_handle = ylabel('Depth (ft)');
0209     xlabel_handle = xlabel('Distance (ft)');
0210     ref_vector_text_handle = text(x1*3.281, x2*3.281+.5,[num2str(refvel*0.03281,3) ' ft/s'],'FontSize',12,'Color','w');
0211 else %metric units
0212     hh = quiverc2wcmap(toquiv(:,1),toquiv(:,2),toquiv(:,3),toquiv(:,4),0,toquiv(:,5),exag);
0213     %plot(V.mcsDist(1,:),V.mcsBed,'w', 'LineWidth',2); hold on
0214     ylim([0 max(V.mcsBed)])
0215     %Reset the color bar to match that in the original contour plot
0216     if strcmp(var,'vorticity_vw')||strcmp(var,'vorticity_zsd')||strcmp(var,'vorticity_roz')
0217         rng = zmax - zmin;
0218         caxis([-rng/2 rng/2])
0219     else
0220         caxis([zmin zmax])
0221     end
0222     switch var        
0223         case{'streamwise'}
0224             title_handle = title({'Streamwise Velocity (cm/s)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0225         case{'transverse'}
0226             title_handle = title({'Transverse Velocity (cm/s)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0227         case{'vertical'}
0228             title_handle = title({'Vertical Velocity (cm/s)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0229         case{'mag'}
0230             title_handle = title({'Velocity Magnitude (Streamwise and Transverse) (cm/s)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0231         case{'east'}
0232             title_handle = title({'East Velocity (cm/s)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0233         case{'north'}
0234             title_handle = title({'North Velocity (cm/s)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0235         case{'primary_zsd'}
0236             title_handle = title({'Primary Velocity (Zero Secondary Discharge Definition) (cm/s)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0237         case{'secondary_zsd'}
0238             title_handle = title({'Secondary Velocity (Zero Secondary Discharge Definition) (cm/s)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0239         case{'primary_roz'}
0240             title_handle = title({'Primary Velocity (Rozovskii Definition) (cm/s)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0241         case{'secondary_roz'}
0242             title_handle = title({'Secondary Velocity (Rozovskii Definition) (cm/s)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');   
0243         case{'primary_roz_x'}
0244             title_handle = title({'Primary Velocity (Rozovskii Definition; Downstream Component) (cm/s)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0245         case{'primary_roz_y'}
0246             title_handle = title({'Primary Velocity (Rozovskii Definition; Cross-Stream Component) (cm/s)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0247         case{'secondary_roz_x'}
0248             title_handle = title({'Secondary Velocity (Rozovskii Definition; Downstream Component) (cm/s)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');       
0249         case{'secondary_roz_y'}
0250             title_handle = title({'Secondary Velocity (Rozovskii Definition; Cross-Stream Component) (cm/s)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0251         case{'backscatter'}
0252             title_handle = title({'Backscatter Intensity (dB)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0253         case{'flowangle'}
0254             title_handle = title({'Flow Direction (deg)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0255         case{'vorticity_vw'}
0256             title_handle = title({'Streamwise Vorticity';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0257         case{'vorticity_zsd'}
0258             title_handle = title({'Streamwise Vorticity (Zero Secondary Discharge Definition)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0259         case{'vorticity_roz'}
0260             title_handle = title({'Streamwise Vorticity (Rozovskii Definition)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0261     end
0262 
0263     ylabel_handle = ylabel('Depth (m)');
0264     xlabel_handle = xlabel('Distance (m)');
0265     ref_vector_text_handle = text(x1, x2+.16,[num2str(refvel) ' cm/s'],'FontSize',12,'Color','w');
0266 end
0267 
0268 % Tag the elements in the figure
0269 secondary_vector_handles = findobj(gcf,'Type','line','-not','tag','PlotBedElevation');
0270 set(secondary_vector_handles,       'Tag','SecondaryVectors')
0271 set(ref_vector_text_handle,         'Tag','ReferenceVectorText')
0272 set(title_handle,                   'Tag','ContourPlotTitle')
0273 set(ylabel_handle,                  'Tag','yLabelText')
0274 set(xlabel_handle,                  'Tag','xLabelText')
0275 
0276 % Adjust the plot
0277 set(gca,...
0278     'DataAspectRatio',   [exag 1 1],...
0279     'PlotBoxAspectRatio',[exag 1 1]...
0280     ...'FontSize',          14)
0281     )
0282 % set(get(gca,'Title'),   'FontSize',14,'Color','w')
0283 % set(get(gca,'xlabel'),  'FontSize',14,'Color','w')
0284 % set(get(gca,'ylabel'),  'FontSize',14,'Color','w')
0285 % set(gca,...
0286 %     'XColor','w',...
0287 %     'YColor','w',...
0288 %     'ZColor','w',...
0289 %     'Color',[0.3 0.3 0.3])
0290 % set(gcf,...
0291 %     'InvertHardCopy','off',...
0292 %     'Color','k')
0293 if 1  %Set the vector line widths
0294     VectorLineWidth = 1.0;
0295     set(secondary_vector_handles  ,'LineWidth',VectorLineWidth)
0296 end
0297 
0298 
0299 
0300 % scrsz = get(0,'ScreenSize');
0301 % figure('OuterPosition',[1 scrsz(4) scrsz(3) scrsz(4)])
0302 
0303 %Display the ratio of the mean secondary and primary velocity magnitudes
0304 spratio_zsd = nanmedian(nanmedian(abs(V.vs)))./nanmedian(nanmedian(abs(V.vp)));
0305 spratio_roz = nanmedian(nanmedian(abs(V.Roz.usy)))./nanmedian(nanmedian(abs(V.Roz.up)));
0306 % disp(['Ratio of median Secondary to median Primary Velocity (zsd) = ' num2str(spratio_zsd)])
0307 % disp(['Ratio of median Secondary to median Primary Velocity (roz) = ' num2str(spratio_roz)])
0308 log_text = vertcat(log_text,...
0309     {['   Ratio of median Secondary to median Primary Velocity (zsd) = ' num2str(spratio_zsd)];...
0310     ['   Ratio of median Secondary to median Primary Velocity (roz) = ' num2str(spratio_roz)]}...
0311     );
0312 
0313 return
0314 
0315 
0316 %Add labels to the reference arrow and colorbar
0317 % text(50,12,['Vertical Distances Exaggerated by ',num2str(exag)],'FontSize',16)
0318 % text(140,17,'10 cm/s','FontSize',16)
0319

Generated on Wed 14-Aug-2013 08:31:52 by m2html © 2005