VMT_PlotXSCont

PURPOSE ^

Plots contours for the variable 'var' within the mean cross section given

SYNOPSIS ^

function [z,A,V,zmin,zmax,log_text,fig_contour_handle] = VMT_PlotXSCont(z,A,V,var,exag,plot_english)

DESCRIPTION ^

 Plots contours for the variable 'var' within the mean cross section given
 by the structure V. 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,zmin,zmax,log_text,fig_contour_handle] = VMT_PlotXSCont(z,A,V,var,exag,plot_english)
0002 % Plots contours for the variable 'var' within the mean cross section given
0003 % by the structure V. IF data is not supplied, user will be prompted to
0004 % load data (browse to data).
0005 %
0006 % (adapted from code by J. Czuba)
0007 %
0008 % P.R. Jackson, USGS, 12-10-08
0009 % Last modified: F.L. Engel, USGS, 2/20/2013
0010 
0011 
0012 
0013 %disp(['Plotting Mean Cross Section Contour Plot: ' var])
0014 log_text = {['Plotting Mean Cross Section Contour Plot']};
0015 
0016 %% User Input
0017 
0018 %exag=50;    %Vertical exaggeration
0019 if exist('plot_english') == 0
0020     plot_english = 0;  %plot english units (else metric)
0021     disp('No units specified, plotting in metric units by default')
0022 end
0023 
0024 %% Load the data if not supplied
0025 if isempty(z) & isempty(A) & isempty(V) 
0026     [zPathName,zFileName,zf] = VMT_SelectFiles;  %Have the user select the preprocessed input files
0027     eval(['load ' zPathName '\' zFileName{1}]);
0028 end
0029 
0030 
0031 %% Plot contours
0032 
0033 % See if PLOT 3 exists already, if so clear the figure
0034 fig_contour_handle = findobj(0,'name','Mean Cross Section Contour');
0035 
0036 if ~isempty(fig_contour_handle) &&  ishandle(fig_contour_handle)
0037     figure(fig_contour_handle); clf
0038 else
0039     fig_contour_handle = figure('name','Mean Cross Section Contour'); clf
0040     %set(gca,'DataAspectRatio',[1 1 1],'PlotBoxAspectRatio',[1 1 1])
0041 end
0042 
0043 % Turn off the menu bar, and keep only specified tools
0044 disableMenuBar(fig_contour_handle)
0045 
0046 clvls = 60;
0047 
0048 %Find the direction of primary discharge (flip if necessary)
0049 binwidth  = diff(V.mcsDist,1,2);
0050 binwidth  = horzcat(binwidth(:,1), binwidth);
0051 binheight = diff(V.mcsDepth,1,1);
0052 binheight = vertcat(binheight, binheight(1,:));
0053 flux = nansum(nansum(V.u./100.*binwidth.*binheight)); %Not a true measured discharge because of averaging, smoothing, edges, etc. but close
0054 
0055 % if zerosecq
0056 %     pdmin = nanmin(nanmin(V.vp));
0057 %     pdmax = nanmax(nanmax(V.vp));
0058 % else
0059 %     pdmin = nanmin(nanmin(V.u));
0060 %     pdmax = nanmax(nanmax(V.u));
0061 % end
0062 if flux < 0; %abs(pdmin) > abs(pdmax)
0063     flipxs = 1;
0064 else
0065     flipxs = 0;
0066 end
0067 
0068 if flipxs 
0069     %disp(['Streamwise Flow Direction (Normal to mean XS; deg) = ' num2str(V.phi - 180)])
0070     %disp(['Primary Flow Direction (deg) = ' num2str(V.phisp - 180)])
0071     msg_str_1 = {['   Streamwise Flow Direction (Normal to mean XS; deg) = ' num2str(V.phi - 180)];...
0072         ['   Primary Flow Direction (deg) = ' num2str(V.phisp - 180)]};
0073 else
0074     %disp(['Streamwise Flow Direction (Normal to mean XS; deg) = ' num2str(V.phi)])
0075     %disp(['Primary Flow Direction (deg) = ' num2str(V.phisp)])
0076     msg_str_1 = {['   Streamwise Flow Direction (Normal to mean XS; deg) = ' num2str(V.phi)];...
0077         ['   Primary Flow Direction (deg) = ' num2str(V.phisp)]};
0078 end
0079 %disp(['Deviation from Streamwise Direction (deg) = ' num2str(V.alphasp)])
0080 %disp(['Horizontal Grid Node Spacing (m) = ' num2str(A(1).hgns)])
0081 
0082 %Display in message box for compiled version
0083 msg_string = {['   Deviation from Streamwise Direction (deg) = ' num2str(V.alphasp)];...
0084     ...['   Horizontal Grid Node Spacing (m) = ' num2str(A(1).hgns)]...
0085     };
0086 %msgbox([msg_str_1, msg_string],'VMT Cross Section Characteristics','help','replace');
0087 log_text = vertcat(log_text,msg_str_1,msg_string);
0088 
0089 switch var
0090     case{'streamwise'}  %Plots the streamwise velocity
0091         if flipxs
0092             wtp=['-V.uSmooth'];
0093             zmin=floor(nanmin(nanmin(-V.uSmooth)));
0094             zmax=ceil(nanmax(nanmax(-V.uSmooth)));
0095         else
0096             wtp=['V.uSmooth'];
0097             zmin=floor(nanmin(nanmin(V.uSmooth)));
0098             zmax=ceil(nanmax(nanmax(V.uSmooth)));
0099         end
0100         zinc = (zmax - zmin) / clvls;
0101         zlevs = zmin:zinc:zmax;     
0102     case{'transverse'} %Plots the transverse velocity
0103         wtp=['V.vSmooth'];
0104         zmax=ceil(max(abs(nanmin(nanmin(V.vSmooth))),abs(nanmax(nanmax(V.vSmooth)))));
0105         zmin=-zmax;
0106         zinc = (zmax - zmin) / clvls;
0107         zlevs = zmin:zinc:zmax;
0108     case{'vertical'} %Plots the vertical velocity
0109         wtp=['V.wSmooth'];
0110         zmax=ceil(max(abs(nanmin(nanmin(V.wSmooth))),abs(nanmax(nanmax(V.wSmooth)))));
0111         zmin=-zmax;
0112         zinc = (zmax - zmin) / clvls;
0113         zlevs = zmin:zinc:zmax;
0114     case{'mag'} %Plots the velocity magnitude
0115         wtp=['V.mcsMagSmooth'];
0116         zmin=floor(nanmin(nanmin(V.mcsMagSmooth)));
0117         zmax=ceil(nanmax(nanmax(V.mcsMagSmooth)));
0118         zinc = (zmax - zmin) / clvls;
0119         zlevs = zmin:zinc:zmax;
0120     case{'east'} %Plots the east velocity
0121         wtp=['V.mcsEastSmooth'];
0122         zmin=floor(nanmin(nanmin(V.mcsEastSmooth)));
0123         zmax=ceil(nanmax(nanmax(V.mcsEastSmooth)));
0124         zinc = (zmax - zmin) / clvls;
0125         zlevs = zmin:zinc:zmax;
0126     case{'north'} %Plots the north velocity
0127         wtp=['V.mcsNorthSmooth'];
0128         zmin=floor(nanmin(nanmin(V.mcsNorthSmooth)));
0129         zmax=ceil(nanmax(nanmax(V.mcsNorthSmooth)));
0130         zinc = (zmax - zmin) / clvls;
0131         zlevs = zmin:zinc:zmax;
0132     case{'primary_zsd'}  %Plots the primary velocity with zero secondary discharge definition
0133         if flipxs
0134             wtp=['-V.vpSmooth'];
0135             zmin=floor(nanmin(nanmin(-V.vpSmooth)));
0136             zmax=ceil(nanmax(nanmax(-V.vpSmooth)));
0137         else
0138             wtp=['V.vpSmooth'];
0139             zmin=floor(nanmin(nanmin(V.vpSmooth)));
0140             zmax=ceil(nanmax(nanmax(V.vpSmooth)));
0141         end
0142         zinc = (zmax - zmin) / clvls;
0143         zlevs = zmin:zinc:zmax;                  
0144     case{'secondary_zsd'} %Plots the secondary velocity with zero secondary discharge definition
0145         wtp=['V.vsSmooth'];
0146         zmax=ceil(max(abs(nanmin(nanmin(V.vsSmooth))),abs(nanmax(nanmax(V.vsSmooth)))));
0147         zmin=-zmax;
0148         zinc = (zmax - zmin) / clvls;
0149         zlevs = zmin:zinc:zmax;
0150     case{'primary_roz'}  %Plots the primary velocity with Rozovskii definition
0151 %         wtp=['V.Roz.upSmooth'];
0152 %         zmin=floor(nanmin(nanmin(V.Roz.upSmooth)));
0153 %         zmax=ceil(nanmax(nanmax(V.Roz.upSmooth)));
0154         
0155         if flipxs
0156             wtp=['-V.Roz.upSmooth'];  
0157             zmin=floor(nanmin(nanmin(-V.Roz.upSmooth)));
0158             zmax=ceil(nanmax(nanmax(-V.Roz.upSmooth)));
0159         else
0160             wtp=['V.Roz.upSmooth'];
0161             zmin=floor(nanmin(nanmin(V.Roz.upSmooth)));
0162             zmax=ceil(nanmax(nanmax(V.Roz.upSmooth)));
0163         end
0164         zinc = (zmax - zmin) / clvls;
0165         zlevs = zmin:zinc:zmax;                
0166     case{'secondary_roz'} %Plots the secondary velocity with Rozovskii definition
0167         wtp=['V.Roz.usSmooth'];
0168         zmax=ceil(max(abs(nanmin(nanmin(V.Roz.usSmooth))),abs(nanmax(nanmax(V.Roz.usSmooth)))));
0169         zmin=-zmax;
0170         zinc = (zmax - zmin) / clvls;
0171         zlevs = zmin:zinc:zmax;
0172     case{'primary_roz_x'}  %Plots the primary velocity with Rozovskii definition (downstream component)
0173 %         wtp=['V.Roz.upxSmooth'];
0174 %         zmin=floor(nanmin(nanmin(V.Roz.upxSmooth)));
0175 %         zmax=ceil(nanmax(nanmax(V.Roz.upxSmooth)));
0176       
0177         if flipxs
0178             wtp=['-V.Roz.upxSmooth'];  
0179             zmin=floor(nanmin(nanmin(-V.Roz.upxSmooth)));
0180             zmax=ceil(nanmax(nanmax(-V.Roz.upxSmooth)));
0181         else
0182             wtp=['V.Roz.upxSmooth'];
0183             zmin=floor(nanmin(nanmin(V.Roz.upxSmooth)));
0184             zmax=ceil(nanmax(nanmax(V.Roz.upxSmooth)));
0185         end
0186         zinc = (zmax - zmin) / clvls;
0187         zlevs = zmin:zinc:zmax; 
0188     case{'primary_roz_y'}  %Plots the primary velocity with Rozovskii definition (cross-stream component)
0189         wtp=['V.Roz.upySmooth'];
0190         zmin=floor(nanmin(nanmin(V.Roz.upySmooth)));
0191         zmax=ceil(nanmax(nanmax(V.Roz.upySmooth)));
0192             
0193 %         if flipxs
0194 %             wtp=['-V.Roz.upySmooth'];
0195 %             zmin=floor(nanmin(nanmin(-V.Roz.upySmooth)));
0196 %             zmax=ceil(nanmax(nanmax(-V.Roz.upySmooth)));
0197 %         else
0198 %             wtp=['V.Roz.upySmooth'];
0199 %             zmin=floor(nanmin(nanmin(V.Roz.upySmooth)));
0200 %             zmax=ceil(nanmax(nanmax(V.Roz.upySmooth)));
0201 %         end
0202         zinc = (zmax - zmin) / clvls;
0203         zlevs = zmin:zinc:zmax;
0204     case{'secondary_roz_x'} %Plots the secondary velocity with Rozovskii definition (downstream component)
0205         wtp=['V.Roz.usxSmooth'];
0206         zmax=ceil(max(abs(nanmin(nanmin(V.Roz.usxSmooth))),abs(nanmax(nanmax(V.Roz.usxSmooth)))));
0207         zmin=-zmax;
0208         zinc = (zmax - zmin) / clvls;
0209         zlevs = zmin:zinc:zmax;
0210     case{'secondary_roz_y'} %Plots the secondary velocity with Rozovskii definition (cross-stream component)
0211         wtp=['V.Roz.usySmooth'];
0212         zmax=ceil(max(abs(nanmin(nanmin(V.Roz.usySmooth))),abs(nanmax(nanmax(V.Roz.usySmooth)))));
0213         zmin=-zmax;
0214         zinc = (zmax - zmin) / clvls;
0215         zlevs = zmin:zinc:zmax;        
0216     case{'backscatter'} %Plots the backscatter
0217         wtp=['V.mcsBackSmooth'];
0218         zmin=floor(nanmin(nanmin(V.mcsBackSmooth)));
0219         zmax=ceil(nanmax(nanmax(V.mcsBackSmooth)));
0220         zinc = (zmax - zmin) / clvls;
0221         zlevs = zmin:zinc:zmax;
0222     case{'flowangle'} %Plots the flow direction (N = 0.0 deg)
0223         wtp=['V.mcsDirSmooth'];
0224         zmin=floor(nanmin(nanmin(V.mcsDirSmooth)));
0225         zmax=ceil(nanmax(nanmax(V.mcsDirSmooth)));
0226         zinc = (zmax - zmin) / clvls;
0227         zlevs = zmin:zinc:zmax;
0228     case{'vorticity_vw'} 
0229         wtp=['V.vorticity_vw'];
0230         zmin=floor(nanmin(V.vorticity_vw(:)));
0231         zmax=ceil(nanmax(V.vorticity_vw(:)));
0232         zinc = (zmax - zmin) / clvls;
0233         zlevs = zmin:zinc:zmax;
0234     case{'vorticity_zsd'}
0235         wtp=['V.vorticity_zsd'];
0236         zmin=floor(nanmin(V.vorticity_zsd(:)));
0237         zmax=ceil(nanmax(V.vorticity_zsd(:)));
0238         zinc = (zmax - zmin) / clvls;
0239         zlevs = zmin:zinc:zmax;
0240     case{'vorticity_roz'} 
0241         wtp=['V.vorticity_roz'];
0242         zmin = floor(nanmin(V.vorticity_roz(:)));
0243         zmax = ceil(nanmax(V.vorticity_roz(:)));
0244         zinc = (zmax - zmin) / clvls;
0245         zlevs = zmin:zinc:zmax;
0246 
0247 %     case{'dirdevp'} %Plots the directional deviation from the primary velocity
0248 %         wtp=['V.mcsDirDevp'];
0249 %         %zmax=ceil(max(abs(nanmin(nanmin(V.mcsDirDevp))),abs(nanmax(nanmax(V.mcsDirDevp)))));
0250 %         %zmin=-zmax;
0251 %         zmin=floor(nanmin(nanmin(V.mcsDirDevp)));
0252 %         zmax=ceil(nanmax(nanmax(V.mcsDirDevp)));
0253 %         zinc = (zmax - zmin) / clvls;
0254 %         zlevs = zmin:zinc:zmax;
0255 end
0256 
0257 
0258 figure(fig_contour_handle); hold all
0259 if plot_english
0260     convfact = 0.03281; %cm/s to ft/s
0261     switch var
0262         case{'backscatter'}
0263             convfact = 1.0; 
0264         case{'flowangle'}
0265             convfact = 1.0;
0266     end
0267     contour_handle = pcolor(V.mcsDist*3.281,V.mcsDepth*3.281,eval(wtp)*convfact); hold on
0268     shading interp
0269 %     contour(V.mcsDist*3.281,V.mcsDepth*3.281,eval(wtp)*convfact,zlevs*convfact,'Fill','on','Linestyle','none'); hold on  %wtp(1,:)
0270     bed_handle = plot(V.mcsDist(1,:)*3.281,V.mcsBed*3.281,'w', 'LineWidth',2); hold on
0271 else
0272     contour_handle = pcolor(V.mcsDist,V.mcsDepth,eval(wtp)); hold on
0273     shading interp
0274 %     contour(V.mcsDist,V.mcsDepth,eval(wtp),zlevs,'Fill','on','Linestyle','none'); hold on  %wtp(1,:)
0275     bed_handle = plot(V.mcsDist(1,:),V.mcsBed,'w', 'LineWidth',2); hold on
0276 end
0277 
0278 
0279 
0280 %Plot the grid node for a check
0281 if 0
0282     plot(V.mcsDist,V.mcsDepth,'k.','MarkerSize',3); hold on
0283     [goodcellsx,goodcellsy] = find(isnan(eval(wtp)) == 0);
0284     plot(V.mcsDist(1,goodcellsy),V.mcsDepth(goodcellsx,1),'w.','MarkerSize',3); hold on
0285 end
0286 
0287 if plot_english
0288     unitlabel = '(ft/s)';
0289 else
0290     unitlabel = '(cm/s)';
0291 end
0292 
0293 switch var
0294     case{'streamwise'}
0295         title_handle = title(['Streamwise Velocity ' unitlabel]);
0296     case{'transverse'}
0297         title_handle = title(['Transverse Velocity ' unitlabel]);
0298     case{'vertical'}
0299         title_handle = title(['Vertical Velocity ' unitlabel]);
0300     case{'mag'}
0301         title_handle = title(['Velocity Magnitude (Streamwise and Transverse) ' unitlabel]);
0302     case{'east'}
0303         title_handle = title(['East Velocity ' unitlabel]);
0304     case{'north'}
0305         title_handle = title(['North Velocity ' unitlabel]);
0306     case{'primary_zsd'}
0307         title_handle = title(['Primary Velocity (Zero Secondary Discharge Definition) ' unitlabel]);
0308     case{'secondary_zsd'}
0309         title_handle = title(['Secondary Velocity (Zero Secondary Discharge Definition) ' unitlabel]);
0310     case{'primary_roz'}
0311         title_handle = title(['Primary Velocity (Rozovskii Definition) ' unitlabel]);
0312     case{'secondary_roz'}
0313         title_handle = title(['Secondary Velocity (Rozovskii Definition) ' unitlabel]); 
0314     case{'primary_roz_x'}
0315         title_handle = title(['Primary Velocity (Rozovskii Definition; Downstream Component) ' unitlabel]);    
0316     case{'primary_roz_y'}
0317         title_handle = title(['Primary Velocity (Rozovskii Definition; Cross-Stream Component) ' unitlabel]);        
0318     case{'secondary_roz_x'}
0319         title_handle = title(['Secondary Velocity (Rozovskii Definition; Downstream Component) ' unitlabel]);        
0320     case{'secondary_roz_y'}
0321         title_handle = title(['Secondary Velocity (Rozovskii Definition; Cross-Stream Component) ' unitlabel]);        
0322     case{'backscatter'}
0323         title_handle = title('Backscatter Intensity (dB)');
0324     case{'flowangle'}
0325         title_handle = title('Flow Direction (deg)');
0326     case{'vorticity_vw'}
0327         title_handle = title('Streamwise Vorticity');
0328     case{'vorticity_zsd'}
0329         title_handle = title('Streamwise Vorticity (Zero Secondary Discharge Definition)');
0330     case{'vorticity_roz'}
0331         title_handle = title('Streamwise Vorticity (Rozovskii Definition)');
0332 %     case{'dirdevp'}
0333 %         title('Deviation from Primary Flow Direction (deg)')
0334 end
0335 colorbar_handle = colorbar; hold all
0336 
0337 if plot_english
0338     caxis([zmin*convfact zmax*convfact])
0339     xlim([nanmin(nanmin(V.mcsDist*3.281)) nanmax(nanmax(V.mcsDist*3.281))])
0340     ylim([0 max(V.mcsBed*3.281)])
0341     set(gca,'YDir','reverse')
0342     if flipxs
0343         set(gca,'XDir','reverse')
0344     end
0345     ylabel_handle = ylabel('Depth (ft)');
0346     xlabel_handle = xlabel('Distance (ft)');
0347 else
0348     caxis([zmin zmax])
0349     xlim([nanmin(nanmin(V.mcsDist)) nanmax(nanmax(V.mcsDist))])
0350     ylim([0 max(V.mcsBed)])
0351     set(gca,'YDir','reverse')
0352     if flipxs
0353         set(gca,'XDir','reverse')
0354     end
0355     ylabel_handle = ylabel('Depth (m)');
0356     xlabel_handle = xlabel('Distance (m)');
0357 end
0358 
0359 if strcmp(var,'vorticity_vw')||strcmp(var,'vorticity_zsd')||strcmp(var,'vorticity_roz')
0360     rng = zmax - zmin;
0361     cmr = [linspace(0,1,25)'];
0362     cmr = [cmr; linspace(1,1,25)'];
0363     cmg = [linspace(0,1,25)'];
0364     cmg = [cmg; linspace(1,0,25)'];
0365     cmb = [linspace(1,1,25)'];
0366     cmb = [cmb; linspace(1,0,25)'];
0367     figure(3)
0368     colormap([cmr cmg cmb])
0369     caxis([-rng/2 rng/2])
0370 else
0371     colormap jet
0372 end
0373 
0374 % Tag the elements in the figure
0375 set(contour_handle,                 'Tag','ContouredVelocities')
0376 set(bed_handle,                     'Tag','PlotBedElevation')
0377 set(colorbar_handle,                'Tag','ColorBar')
0378 set(title_handle,                   'Tag','ContourPlotTitle')
0379 set(ylabel_handle,                  'Tag','yLabelText')
0380 set(xlabel_handle,                  'Tag','xLabelText')
0381 
0382 % Adjust the plot
0383 set(gca,...
0384     'DataAspectRatio',   [exag 1 1],...
0385     'PlotBoxAspectRatio',[exag 1 1]...
0386     ...'FontSize',          14)
0387     )
0388 % set(get(gca,'Title'),   'FontSize',14,'Color','w')
0389 % set(get(gca,'xlabel'),  'FontSize',14,'Color','w')
0390 % set(get(gca,'ylabel'),  'FontSize',14,'Color','w')
0391 % set(gca,...
0392 %     'XColor','w',...
0393 %     'YColor','w',...
0394 %     'ZColor','w',...
0395 %     'Color',[0.3 0.3 0.3])
0396 % set(gcf,...
0397 %     'InvertHardCopy','off',...
0398 %     'Color','k')
0399 %figure('Name','Cross Section','NumberTitle','off')
0400 % scrsz = get(0,'ScreenSize');
0401 % figure('OuterPosition',[1 scrsz(4) scrsz(3) scrsz(4)])
0402 
0403 %figure(5); clf; compass(V.mcsEast,V.mcsNorth)
0404

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