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{'error'} %Plots the error velocity
0127         wtp=['V.mcsErrorSmooth'];
0128         zmin=floor(nanmin(nanmin(V.mcsErrorSmooth)));
0129         zmax=ceil(nanmax(nanmax(V.mcsErrorSmooth)));
0130         zinc = (zmax - zmin) / clvls;
0131         zlevs = zmin:zinc:zmax;
0132     case{'north'} %Plots the north velocity
0133         wtp=['V.mcsNorthSmooth'];
0134         zmin=floor(nanmin(nanmin(V.mcsNorthSmooth)));
0135         zmax=ceil(nanmax(nanmax(V.mcsNorthSmooth)));
0136         zinc = (zmax - zmin) / clvls;
0137         zlevs = zmin:zinc:zmax;
0138     case{'primary_zsd'}  %Plots the primary velocity with zero secondary discharge definition
0139         if flipxs
0140             wtp=['-V.vpSmooth'];
0141             zmin=floor(nanmin(nanmin(-V.vpSmooth)));
0142             zmax=ceil(nanmax(nanmax(-V.vpSmooth)));
0143         else
0144             wtp=['V.vpSmooth'];
0145             zmin=floor(nanmin(nanmin(V.vpSmooth)));
0146             zmax=ceil(nanmax(nanmax(V.vpSmooth)));
0147         end
0148         zinc = (zmax - zmin) / clvls;
0149         zlevs = zmin:zinc:zmax;                  
0150     case{'secondary_zsd'} %Plots the secondary velocity with zero secondary discharge definition
0151         wtp=['V.vsSmooth'];
0152         zmax=ceil(max(abs(nanmin(nanmin(V.vsSmooth))),abs(nanmax(nanmax(V.vsSmooth)))));
0153         zmin=-zmax;
0154         zinc = (zmax - zmin) / clvls;
0155         zlevs = zmin:zinc:zmax;
0156     case{'primary_roz'}  %Plots the primary velocity with Rozovskii definition
0157 %         wtp=['V.Roz.upSmooth'];
0158 %         zmin=floor(nanmin(nanmin(V.Roz.upSmooth)));
0159 %         zmax=ceil(nanmax(nanmax(V.Roz.upSmooth)));
0160         
0161         if flipxs
0162             wtp=['-V.Roz.upSmooth'];  
0163             zmin=floor(nanmin(nanmin(-V.Roz.upSmooth)));
0164             zmax=ceil(nanmax(nanmax(-V.Roz.upSmooth)));
0165         else
0166             wtp=['V.Roz.upSmooth'];
0167             zmin=floor(nanmin(nanmin(V.Roz.upSmooth)));
0168             zmax=ceil(nanmax(nanmax(V.Roz.upSmooth)));
0169         end
0170         zinc = (zmax - zmin) / clvls;
0171         zlevs = zmin:zinc:zmax;                
0172     case{'secondary_roz'} %Plots the secondary velocity with Rozovskii definition
0173         wtp=['V.Roz.usSmooth'];
0174         zmax=ceil(max(abs(nanmin(nanmin(V.Roz.usSmooth))),abs(nanmax(nanmax(V.Roz.usSmooth)))));
0175         zmin=-zmax;
0176         zinc = (zmax - zmin) / clvls;
0177         zlevs = zmin:zinc:zmax;
0178     case{'primary_roz_x'}  %Plots the primary velocity with Rozovskii definition (downstream component)
0179 %         wtp=['V.Roz.upxSmooth'];
0180 %         zmin=floor(nanmin(nanmin(V.Roz.upxSmooth)));
0181 %         zmax=ceil(nanmax(nanmax(V.Roz.upxSmooth)));
0182       
0183         if flipxs
0184             wtp=['-V.Roz.upxSmooth'];  
0185             zmin=floor(nanmin(nanmin(-V.Roz.upxSmooth)));
0186             zmax=ceil(nanmax(nanmax(-V.Roz.upxSmooth)));
0187         else
0188             wtp=['V.Roz.upxSmooth'];
0189             zmin=floor(nanmin(nanmin(V.Roz.upxSmooth)));
0190             zmax=ceil(nanmax(nanmax(V.Roz.upxSmooth)));
0191         end
0192         zinc = (zmax - zmin) / clvls;
0193         zlevs = zmin:zinc:zmax; 
0194     case{'primary_roz_y'}  %Plots the primary velocity with Rozovskii definition (cross-stream component)
0195         wtp=['V.Roz.upySmooth'];
0196         zmin=floor(nanmin(nanmin(V.Roz.upySmooth)));
0197         zmax=ceil(nanmax(nanmax(V.Roz.upySmooth)));
0198             
0199 %         if flipxs
0200 %             wtp=['-V.Roz.upySmooth'];
0201 %             zmin=floor(nanmin(nanmin(-V.Roz.upySmooth)));
0202 %             zmax=ceil(nanmax(nanmax(-V.Roz.upySmooth)));
0203 %         else
0204 %             wtp=['V.Roz.upySmooth'];
0205 %             zmin=floor(nanmin(nanmin(V.Roz.upySmooth)));
0206 %             zmax=ceil(nanmax(nanmax(V.Roz.upySmooth)));
0207 %         end
0208         zinc = (zmax - zmin) / clvls;
0209         zlevs = zmin:zinc:zmax;
0210     case{'secondary_roz_x'} %Plots the secondary velocity with Rozovskii definition (downstream component)
0211         wtp=['V.Roz.usxSmooth'];
0212         zmax=ceil(max(abs(nanmin(nanmin(V.Roz.usxSmooth))),abs(nanmax(nanmax(V.Roz.usxSmooth)))));
0213         zmin=-zmax;
0214         zinc = (zmax - zmin) / clvls;
0215         zlevs = zmin:zinc:zmax;
0216     case{'secondary_roz_y'} %Plots the secondary velocity with Rozovskii definition (cross-stream component)
0217         wtp=['V.Roz.usySmooth'];
0218         zmax=ceil(max(abs(nanmin(nanmin(V.Roz.usySmooth))),abs(nanmax(nanmax(V.Roz.usySmooth)))));
0219         zmin=-zmax;
0220         zinc = (zmax - zmin) / clvls;
0221         zlevs = zmin:zinc:zmax;        
0222     case{'backscatter'} %Plots the backscatter
0223         wtp=['V.mcsBackSmooth'];
0224         zmin=floor(nanmin(nanmin(V.mcsBackSmooth)));
0225         zmax=ceil(nanmax(nanmax(V.mcsBackSmooth)));
0226         zinc = (zmax - zmin) / clvls;
0227         zlevs = zmin:zinc:zmax;
0228     case{'flowangle'} %Plots the flow direction (N = 0.0 deg)
0229         wtp=['V.mcsDirSmooth'];
0230         zmin=floor(nanmin(nanmin(V.mcsDirSmooth)));
0231         zmax=ceil(nanmax(nanmax(V.mcsDirSmooth)));
0232         zinc = (zmax - zmin) / clvls;
0233         zlevs = zmin:zinc:zmax;
0234     case{'vorticity_vw'} 
0235         wtp=['V.vorticity_vw'];
0236         zmin=floor(nanmin(V.vorticity_vw(:)));
0237         zmax=ceil(nanmax(V.vorticity_vw(:)));
0238         zinc = (zmax - zmin) / clvls;
0239         zlevs = zmin:zinc:zmax;
0240     case{'vorticity_zsd'}
0241         wtp=['V.vorticity_zsd'];
0242         zmin=floor(nanmin(V.vorticity_zsd(:)));
0243         zmax=ceil(nanmax(V.vorticity_zsd(:)));
0244         zinc = (zmax - zmin) / clvls;
0245         zlevs = zmin:zinc:zmax;
0246     case{'vorticity_roz'} 
0247         wtp=['V.vorticity_roz'];
0248         zmin = floor(nanmin(V.vorticity_roz(:)));
0249         zmax = ceil(nanmax(V.vorticity_roz(:)));
0250         zinc = (zmax - zmin) / clvls;
0251         zlevs = zmin:zinc:zmax;
0252 
0253 %     case{'dirdevp'} %Plots the directional deviation from the primary velocity
0254 %         wtp=['V.mcsDirDevp'];
0255 %         %zmax=ceil(max(abs(nanmin(nanmin(V.mcsDirDevp))),abs(nanmax(nanmax(V.mcsDirDevp)))));
0256 %         %zmin=-zmax;
0257 %         zmin=floor(nanmin(nanmin(V.mcsDirDevp)));
0258 %         zmax=ceil(nanmax(nanmax(V.mcsDirDevp)));
0259 %         zinc = (zmax - zmin) / clvls;
0260 %         zlevs = zmin:zinc:zmax;
0261 end
0262 
0263 
0264 figure(fig_contour_handle); hold all
0265 if plot_english
0266     convfact = 0.03281; %cm/s to ft/s
0267     switch var
0268         case{'backscatter'}
0269             convfact = 1.0; 
0270         case{'flowangle'}
0271             convfact = 1.0;
0272     end
0273     contour_handle = pcolor(V.mcsDist*3.281,V.mcsDepth*3.281,eval(wtp)*convfact); hold on
0274     shading interp
0275     %[~,contour_handle] = contour(V.mcsDist*3.281,V.mcsDepth*3.281,eval(wtp)*convfact,zlevs*convfact,'Fill','on','Linestyle','none'); hold on  %wtp(1,:)
0276     bed_handle         = plot(V.mcsDist(1,:)*3.281,V.mcsBed*3.281,'w', 'LineWidth',2); hold on
0277 else
0278     contour_handle = pcolor(V.mcsDist,V.mcsDepth,eval(wtp)); hold on
0279     shading interp
0280     %[~,contour_handle] = contour(V.mcsDist,V.mcsDepth,eval(wtp),zlevs,'Fill','on','Linestyle','none'); hold on  %wtp(1,:)
0281     bed_handle         = plot(V.mcsDist(1,:),V.mcsBed,'w', 'LineWidth',2); hold on
0282 end
0283 
0284 
0285 
0286 %Plot the grid node for a check
0287 if 0
0288     plot(V.mcsDist,V.mcsDepth,'k.','MarkerSize',3); hold on
0289     [goodcellsx,goodcellsy] = find(isnan(eval(wtp)) == 0);
0290     plot(V.mcsDist(1,goodcellsy),V.mcsDepth(goodcellsx,1),'w.','MarkerSize',3); hold on
0291 end
0292 
0293 if plot_english
0294     unitlabel = '(ft/s)';
0295 else
0296     unitlabel = '(cm/s)';
0297 end
0298 
0299 switch var
0300     case{'streamwise'}
0301         title_handle = title(['Streamwise Velocity ' unitlabel]);
0302     case{'transverse'}
0303         title_handle = title(['Transverse Velocity ' unitlabel]);
0304     case{'vertical'}
0305         title_handle = title(['Vertical Velocity ' unitlabel]);
0306     case{'mag'}
0307         title_handle = title(['Velocity Magnitude (Streamwise and Transverse) ' unitlabel]);
0308     case{'east'}
0309         title_handle = title(['East Velocity ' unitlabel]);
0310     case{'north'}
0311         title_handle = title(['North Velocity ' unitlabel]);
0312     case{'error'}
0313         title_handle = title(['Error Velocity ' unitlabel]);
0314     case{'primary_zsd'}
0315         title_handle = title(['Primary Velocity (Zero Secondary Discharge Definition) ' unitlabel]);
0316     case{'secondary_zsd'}
0317         title_handle = title(['Secondary Velocity (Zero Secondary Discharge Definition) ' unitlabel]);
0318     case{'primary_roz'}
0319         title_handle = title(['Primary Velocity (Rozovskii Definition) ' unitlabel]);
0320     case{'secondary_roz'}
0321         title_handle = title(['Secondary Velocity (Rozovskii Definition) ' unitlabel]); 
0322     case{'primary_roz_x'}
0323         title_handle = title(['Primary Velocity (Rozovskii Definition; Downstream Component) ' unitlabel]);    
0324     case{'primary_roz_y'}
0325         title_handle = title(['Primary Velocity (Rozovskii Definition; Cross-Stream Component) ' unitlabel]);        
0326     case{'secondary_roz_x'}
0327         title_handle = title(['Secondary Velocity (Rozovskii Definition; Downstream Component) ' unitlabel]);        
0328     case{'secondary_roz_y'}
0329         title_handle = title(['Secondary Velocity (Rozovskii Definition; Cross-Stream Component) ' unitlabel]);        
0330     case{'backscatter'}
0331         title_handle = title('Backscatter Intensity (dB)');
0332     case{'flowangle'}
0333         title_handle = title('Flow Direction (deg)');
0334     case{'vorticity_vw'}
0335         title_handle = title('Streamwise Vorticity');
0336     case{'vorticity_zsd'}
0337         title_handle = title('Streamwise Vorticity (Zero Secondary Discharge Definition)');
0338     case{'vorticity_roz'}
0339         title_handle = title('Streamwise Vorticity (Rozovskii Definition)');
0340 %     case{'dirdevp'}
0341 %         title('Deviation from Primary Flow Direction (deg)')
0342 end
0343 colorbar_handle = colorbar; hold all
0344 
0345 if plot_english
0346     caxis([zmin*convfact zmax*convfact])
0347     xlim([nanmin(nanmin(V.mcsDist*3.281)) nanmax(nanmax(V.mcsDist*3.281))])
0348     ylim([0 max(V.mcsBed*3.281)])
0349     set(gca,'YDir','reverse')
0350     if flipxs
0351         set(gca,'XDir','reverse')
0352     end
0353     ylabel_handle = ylabel('Depth (ft)');
0354     xlabel_handle = xlabel('Distance (ft)');
0355 else
0356     caxis([zmin zmax])
0357     xlim([nanmin(nanmin(V.mcsDist)) nanmax(nanmax(V.mcsDist))])
0358     ylim([0 max(V.mcsBed)])
0359     set(gca,'YDir','reverse')
0360     if flipxs
0361         set(gca,'XDir','reverse')
0362     end
0363     ylabel_handle = ylabel('Depth (m)');
0364     xlabel_handle = xlabel('Distance (m)');
0365 end
0366 
0367 if strcmp(var,'vorticity_vw')||strcmp(var,'vorticity_zsd')||strcmp(var,'vorticity_roz')
0368     rng = zmax - zmin;
0369     cmr = [linspace(0,1,25)'];
0370     cmr = [cmr; linspace(1,1,25)'];
0371     cmg = [linspace(0,1,25)'];
0372     cmg = [cmg; linspace(1,0,25)'];
0373     cmb = [linspace(1,1,25)'];
0374     cmb = [cmb; linspace(1,0,25)'];
0375     figure(3)
0376     colormap([cmr cmg cmb])
0377     caxis([-rng/2 rng/2])
0378 else
0379     colormap jet
0380 end
0381 
0382 % Tag the elements in the figure
0383 set(contour_handle,                 'Tag','ContouredVelocities')
0384 set(bed_handle,                     'Tag','PlotBedElevation')
0385 set(colorbar_handle,                'Tag','ColorBar')
0386 set(title_handle,                   'Tag','ContourPlotTitle')
0387 set(ylabel_handle,                  'Tag','yLabelText')
0388 set(xlabel_handle,                  'Tag','xLabelText')
0389 
0390 % Adjust the plot
0391 set(gca,...
0392     'DataAspectRatio',   [exag 1 1],...
0393     'PlotBoxAspectRatio',[exag 1 1]...
0394     ...'FontSize',          14)
0395     )
0396 % set(get(gca,'Title'),   'FontSize',14,'Color','w')
0397 % set(get(gca,'xlabel'),  'FontSize',14,'Color','w')
0398 % set(get(gca,'ylabel'),  'FontSize',14,'Color','w')
0399 % set(gca,...
0400 %     'XColor','w',...
0401 %     'YColor','w',...
0402 %     'ZColor','w',...
0403 %     'Color',[0.3 0.3 0.3])
0404 % set(gcf,...
0405 %     'InvertHardCopy','off',...
0406 %     'Color','k')
0407 %figure('Name','Cross Section','NumberTitle','off')
0408 % scrsz = get(0,'ScreenSize');
0409 % figure('OuterPosition',[1 scrsz(4) scrsz(3) scrsz(4)])
0410 
0411 %figure(5); clf; compass(V.mcsEast,V.mcsNorth)
0412

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