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     % Reference arrow
0071     % Find first full row of data. Typically this is row 1 with RG data,
0072     % however it may not be for M9 and/or RR data.
0073     i = 1;
0074     while any(isnan(V.vp(i,:)))
0075         i=i+1;
0076         if i > size(V.vp,1)
0077             break
0078         end
0079     end
0080     i=5; % This is a temporary fix
0081     % If a bad ensemble exists, the above while loop might not find a
0082     % result. If that happens, just use row 1 anyway
0083     try
0084         [I,J] = ind2sub(size(V.vp(i,:)),find(~isnan(V.vp(i,:))==1));
0085     catch err
0086         [I,J] = ind2sub(size(V.vp(1,:)),find(~isnan(V.vp(1,:))==1));
0087     end
0088     
0089     et = J(1):qspchorz:J(end);
0090     [r c]=size(V.vp);
0091     bi = 1:qspcvert:r;
0092 end
0093 
0094 %zmin = floor(nanmin(nanmin(V.vp)));
0095 %zmax = ceil(nanmax(nanmax(V.vp)));
0096 %zinc = (zmax - zmin) / clvls;
0097 %zlevs = zmin:zinc:zmax;
0098 
0099 %Set the vertical velocity component
0100 if vvelcomp  %include vertical velocity compoent in vector?
0101     vertcomp = V.wSmooth;
0102 else
0103     vertcomp = zeros(size(V.wSmooth));
0104 end
0105 
0106 figure(fig_contour_handle); hold all
0107 %quiver(V.mcsDist(bi,et),V.mcsDepth(bi,et),-sf.*V.vsSmooth(bi,et),-sf.*V.wSmooth(bi,et),0,'k')
0108 switch secvecvar
0109     case{'transverse'}  %uses secondary velocity computed in the plane of the mean cross section (i.e. transverse)
0110         vr = sqrt(abs((-sf.*V.vSmooth(bi,et)).^2 + (-sf./exag.*vertcomp(bi,et)).^2));
0111     case{'secondary_zsd'} %Uses secondary velocity computed with a zero secondary discharge
0112         vr = sqrt(abs((-sf.*V.vsSmooth(bi,et)).^2 + (-sf./exag.*vertcomp(bi,et)).^2));  
0113     case{'secondary_roz'}
0114         vr = sqrt(abs((-sf.*V.Roz.usSmooth(bi,et)).^2 + (-sf./exag.*vertcomp(bi,et)).^2));
0115     case{'secondary_roz_y'}
0116         vr = sqrt(abs((-sf.*V.Roz.usySmooth(bi,et)).^2 + (-sf./exag.*vertcomp(bi,et)).^2));
0117     case{'primary_roz_y'}
0118         vr = sqrt(abs((-sf.*V.Roz.upySmooth(bi,et)).^2 + (-sf./exag.*vertcomp(bi,et)).^2));
0119 end
0120         
0121 %vr=sqrt(abs(-sf.*V.vsSmooth(bi,et).^2+-sf./exag.*V.wSmooth(bi,et).^2));
0122 [rw cl] = size(V.mcsDist(bi,et));
0123 toquiv(:,1) = reshape(V.mcsDist(bi,et),rw*cl,1);
0124 toquiv(:,2) = reshape(V.mcsDepth(bi,et),rw*cl,1);
0125 switch secvecvar
0126     case{'transverse'}
0127         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)
0128         refvel = ceil(max(max(abs(V.vSmooth(bi,et)))));
0129         %meansecvec = mean(mean(V.vSmooth(bi,et)));
0130     case{'secondary_zsd'}
0131         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)
0132         refvel = ceil(max(max(abs(V.vsSmooth(bi,et)))));
0133         %meansecvec = mean(mean(V.vsSmooth(bi,et)));
0134     case{'secondary_roz'}
0135         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)
0136         refvel = ceil(max(max(abs(V.Roz.usSmooth(bi,et)))));
0137         %meansecvec = mean(mean(V.Roz.us(bi,et)));
0138     case{'secondary_roz_y'}
0139         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)
0140         refvel = ceil(max(max(abs(V.Roz.usySmooth(bi,et)))));
0141         %meansecvec = mean(mean(V.Roz.usy(bi,et)));
0142     case{'primary_roz_y'}
0143         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)
0144         refvel = ceil(max(max(abs(V.Roz.upySmooth(bi,et)))));
0145         %meansecvec = mean(mean(V.Roz.upy(bi,et))));
0146 end
0147 toquiv(:,4) = reshape(-sf./exag.*vertcomp(bi,et),rw*cl,1);  %Add negative sign to account for flipped vertical axes
0148 toquiv(:,5) = reshape(vr,rw*cl,1);
0149 
0150 %Ref arrow
0151 if isempty(distance)
0152     x1 = 0.06*max(max(V.mcsDist));
0153     x2 = 0.95*max(max(V.mcsBed));
0154     if AS == 0
0155         refvel = MANrefvel; %manual scaling
0156     end
0157 else
0158     x1 = distance;
0159     x2 = depth;
0160     refvel = reference_velocity;
0161 end
0162 x3=sf.*refvel; %Set to rounded max secondary velocity (absolute value added 3/29/12 PRJ) (autoscaling)
0163 x4=0;
0164 x5=x3;
0165 toquiv(end+1,1) = x1;
0166 toquiv(end,2) = x2;
0167 toquiv(end,3) = x3;
0168 toquiv(end,4) = x4;
0169 toquiv(end,5) = x5;
0170 %quiverc(toquiv(:,1),toquiv(:,2),toquiv(:,3),toquiv(:,4),sf); hold on
0171 
0172 if plot_english
0173     unitlabel = '(ft/s)';
0174 else
0175     unitlabel = '(cm/s)';
0176 end
0177 
0178 if plot_english %english units
0179     convfact = 0.03281; %cm/s to ft/s
0180     switch var
0181         case{'backscatter'}
0182             convfact = 1.0; 
0183         case{'flowangle'}
0184             convfact = 1.0;
0185     end
0186     
0187     hh = quiverc2wcmap(toquiv(:,1)*3.281,toquiv(:,2)*3.281,toquiv(:,3)*0.03281,toquiv(:,4)*0.03281,0,toquiv(:,5)*0.03281,exag);
0188     %plot(V.mcsDist(1,:)*3.281,V.mcsBed*3.281,'w', 'LineWidth',2); hold on
0189     ylim([0 max(V.mcsBed*3.281)])
0190     caxis([zmin*convfact zmax*convfact]) %Reset the color bar to match that in the original contour plot
0191     switch var        
0192         case{'streamwise'}
0193             title_handle = title({['Streamwise Velocity ' unitlabel];['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0194         case{'transverse'}
0195             title_handle = title({['Transverse Velocity ' unitlabel];['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0196         case{'vertical'}
0197             title_handle = title({['Vertical Velocity ' unitlabel];['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0198         case{'mag'}
0199             title_handle = title({['Velocity Magnitude (Streamwise and Transverse) ' unitlabel];['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0200         case{'east'}
0201             title_handle = title({['East Velocity ' unitlabel];['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0202         case{'error'}
0203             title_handle = title({['Error Velocity ' unitlabel];['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0204         case{'north'}
0205             title_handle = title({['North Velocity ' unitlabel];['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0206         case{'primary_zsd'}
0207             title_handle = title({['Primary Velocity (Zero Secondary Discharge Definition) ' unitlabel];['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0208         case{'secondary_zsd'}
0209             title_handle = title({['Secondary Velocity (Zero Secondary Discharge Definition) ' unitlabel];['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0210         case{'primary_roz'}
0211             title_handle = title({['Primary Velocity (Rozovskii Definition) ' unitlabel];['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0212         case{'secondary_roz'}
0213             title_handle = title({['Secondary Velocity (Rozovskii Definition) ' unitlabel];['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0214         case{'primary_roz_x'}
0215             title_handle = title({['Primary Velocity (Rozovskii Definition; Downstream Component) ' unitlabel];['with secondary flow vectors (' secvecvar ')']},'Interpreter','none'); 
0216         case{'primary_roz_y'}
0217             title_handle = title({['Primary Velocity (Rozovskii Definition; Cross-Stream Component) ' unitlabel];['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');       
0218         case{'secondary_roz_x'}
0219             title_handle = title({['Secondary Velocity (Rozovskii Definition; Downstream Component) ' unitlabel];['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');       
0220         case{'secondary_roz_y'}
0221             title_handle = title({['Secondary Velocity (Rozovskii Definition; Cross-Stream Component) ' unitlabel];['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0222         case{'backscatter'}
0223             title_handle = title({'Backscatter Intensity (dB)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0224         case{'flowangle'}
0225             title_handle = title({'Flow Direction (deg)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0226     end
0227 
0228     ylabel_handle = ylabel('Depth (ft)');
0229     xlabel_handle = xlabel('Distance (ft)');
0230     rf_label_pos = [0.06*max(max(V.mcsDist)) 0.9*max(max(V.mcsBed))].*3.28084; % Conversion is to meters
0231     ref_vector_text_handle = text(rf_label_pos(1), rf_label_pos(2),[num2str(refvel*0.03281,3) ' ft/s'],'FontSize',12,'Color','w');
0232 else %metric units
0233     hh = quiverc2wcmap(toquiv(:,1),toquiv(:,2),toquiv(:,3),toquiv(:,4),0,toquiv(:,5),exag);
0234     %plot(V.mcsDist(1,:),V.mcsBed,'w', 'LineWidth',2); hold on
0235     ylim([0 max(V.mcsBed)])
0236     %Reset the color bar to match that in the original contour plot
0237     if strcmp(var,'vorticity_vw')||strcmp(var,'vorticity_zsd')||strcmp(var,'vorticity_roz')
0238         rng = zmax - zmin;
0239         caxis([-rng/2 rng/2])
0240     else
0241         caxis([zmin zmax])
0242     end
0243     switch var        
0244         case{'streamwise'}
0245             title_handle = title({'Streamwise Velocity (cm/s)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0246         case{'transverse'}
0247             title_handle = title({'Transverse Velocity (cm/s)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0248         case{'vertical'}
0249             title_handle = title({'Vertical Velocity (cm/s)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0250         case{'mag'}
0251             title_handle = title({'Velocity Magnitude (Streamwise and Transverse) (cm/s)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0252         case{'east'}
0253             title_handle = title({'East Velocity (cm/s)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0254         case{'error'}
0255             title_handle = title({'Error Velocity (cm/s)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0256         case{'north'}
0257             title_handle = title({'North Velocity (cm/s)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0258         case{'primary_zsd'}
0259             title_handle = title({'Primary Velocity (Zero Secondary Discharge Definition) (cm/s)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0260         case{'secondary_zsd'}
0261             title_handle = title({'Secondary Velocity (Zero Secondary Discharge Definition) (cm/s)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0262         case{'primary_roz'}
0263             title_handle = title({'Primary Velocity (Rozovskii Definition) (cm/s)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0264         case{'secondary_roz'}
0265             title_handle = title({'Secondary Velocity (Rozovskii Definition) (cm/s)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');   
0266         case{'primary_roz_x'}
0267             title_handle = title({'Primary Velocity (Rozovskii Definition; Downstream Component) (cm/s)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0268         case{'primary_roz_y'}
0269             title_handle = title({'Primary Velocity (Rozovskii Definition; Cross-Stream Component) (cm/s)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0270         case{'secondary_roz_x'}
0271             title_handle = title({'Secondary Velocity (Rozovskii Definition; Downstream Component) (cm/s)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');       
0272         case{'secondary_roz_y'}
0273             title_handle = title({'Secondary Velocity (Rozovskii Definition; Cross-Stream Component) (cm/s)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0274         case{'backscatter'}
0275             title_handle = title({'Backscatter Intensity (dB)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0276         case{'flowangle'}
0277             title_handle = title({'Flow Direction (deg)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0278         case{'vorticity_vw'}
0279             title_handle = title({'Streamwise Vorticity';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0280         case{'vorticity_zsd'}
0281             title_handle = title({'Streamwise Vorticity (Zero Secondary Discharge Definition)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0282         case{'vorticity_roz'}
0283             title_handle = title({'Streamwise Vorticity (Rozovskii Definition)';['with secondary flow vectors (' secvecvar ')']},'Interpreter','none');
0284     end
0285 
0286     ylabel_handle = ylabel('Depth (m)');
0287     xlabel_handle = xlabel('Distance (m)');
0288     rf_label_pos = [0.06*max(max(V.mcsDist)) 0.9*max(max(V.mcsBed))]; 
0289     ref_vector_text_handle = text(rf_label_pos(1), rf_label_pos(2),[num2str(refvel) ' cm/s'],'FontSize',12,'Color','w');
0290 end
0291 
0292 % Tag the elements in the figure
0293 secondary_vector_handles = findobj(gcf,'Type','line','-not','tag','PlotBedElevation');
0294 set(secondary_vector_handles,       'Tag','SecondaryVectors')
0295 set(ref_vector_text_handle,         'Tag','ReferenceVectorText')
0296 set(title_handle,                   'Tag','ContourPlotTitle')
0297 set(ylabel_handle,                  'Tag','yLabelText')
0298 set(xlabel_handle,                  'Tag','xLabelText')
0299 
0300 % Adjust the plot
0301 set(gca,...
0302     'DataAspectRatio',   [exag 1 1],...
0303     'PlotBoxAspectRatio',[exag 1 1]...
0304     ...'FontSize',          14)
0305     )
0306 % set(get(gca,'Title'),   'FontSize',14,'Color','w')
0307 % set(get(gca,'xlabel'),  'FontSize',14,'Color','w')
0308 % set(get(gca,'ylabel'),  'FontSize',14,'Color','w')
0309 % set(gca,...
0310 %     'XColor','w',...
0311 %     'YColor','w',...
0312 %     'ZColor','w',...
0313 %     'Color',[0.3 0.3 0.3])
0314 % set(gcf,...
0315 %     'InvertHardCopy','off',...
0316 %     'Color','k')
0317 if 1  %Set the vector line widths
0318     VectorLineWidth = 1.0;
0319     set(secondary_vector_handles  ,'LineWidth',VectorLineWidth)
0320 end
0321 
0322 
0323 
0324 % scrsz = get(0,'ScreenSize');
0325 % figure('OuterPosition',[1 scrsz(4) scrsz(3) scrsz(4)])
0326 
0327 %Display the ratio of the mean secondary and primary velocity magnitudes
0328 spratio_zsd = nanmedian(nanmedian(abs(V.vs)))./nanmedian(nanmedian(abs(V.vp)));
0329 spratio_roz = nanmedian(nanmedian(abs(V.Roz.usy)))./nanmedian(nanmedian(abs(V.Roz.up)));
0330 % disp(['Ratio of median Secondary to median Primary Velocity (zsd) = ' num2str(spratio_zsd)])
0331 % disp(['Ratio of median Secondary to median Primary Velocity (roz) = ' num2str(spratio_roz)])
0332 log_text = vertcat(log_text,...
0333     {['   Ratio of median Secondary to median Primary Velocity (zsd) = ' num2str(spratio_zsd)];...
0334     ['   Ratio of median Secondary to median Primary Velocity (roz) = ' num2str(spratio_roz)]}...
0335     );
0336 
0337 return
0338 
0339 
0340 %Add labels to the reference arrow and colorbar
0341 % text(50,12,['Vertical Distances Exaggerated by ',num2str(exag)],'FontSize',16)
0342 % text(140,17,'10 cm/s','FontSize',16)
0343

Generated on Thu 21-Aug-2014 10:40:31 by m2html © 2005