VMT_PlotPlanViewQuivers

PURPOSE ^

This function plots a plan view of the measurement region with a vector

SYNOPSIS ^

function [PVdata,fig_planview_handle,log_text] = VMT_PlotPlanViewQuivers(z,A,V,Map,drng,ascale,QuiverSpacing,pvsmwin,pshore,plot_english,varargin)

DESCRIPTION ^

 This function plots a plan view of the measurement region with a vector
 field of depth averaged velocity for each processed mean cross section.

 ASC version is for plotting ASCII loaded data. 9/2/09 (also has new
 pvsmwin input for the filter window)

 Added DOQQ plotting capabilities (PRJ, 6-23-10)
 Added english units option
 Added vector data output option in GUI

 User Notes:

 1. Supply z, A, V, and Map for plotting a single mean cross section
 2. Leave z, A, V, and Map blank (i.e. [],[],[],[]) to load multiple,
   (preprocessed and saved) cross sections. In this case, user must supply
   a cell array of filenames, and a path
 3. Leave drng blank (i.e. []) for full depth means or specify
   the a 2 component vector of depths in meters (drng = [ dupper dlower])
   of the depth range to average and plot

 (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:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [PVdata,fig_planview_handle,log_text] = VMT_PlotPlanViewQuivers(z,A,V,Map,drng,ascale,QuiverSpacing,pvsmwin,pshore,plot_english,varargin)
0002 % This function plots a plan view of the measurement region with a vector
0003 % field of depth averaged velocity for each processed mean cross section.
0004 %
0005 % ASC version is for plotting ASCII loaded data. 9/2/09 (also has new
0006 % pvsmwin input for the filter window)
0007 %
0008 % Added DOQQ plotting capabilities (PRJ, 6-23-10)
0009 % Added english units option
0010 % Added vector data output option in GUI
0011 %
0012 % User Notes:
0013 %
0014 % 1. Supply z, A, V, and Map for plotting a single mean cross section
0015 % 2. Leave z, A, V, and Map blank (i.e. [],[],[],[]) to load multiple,
0016 %   (preprocessed and saved) cross sections. In this case, user must supply
0017 %   a cell array of filenames, and a path
0018 % 3. Leave drng blank (i.e. []) for full depth means or specify
0019 %   the a 2 component vector of depths in meters (drng = [ dupper dlower])
0020 %   of the depth range to average and plot
0021 %
0022 % (adapted from code by J. Czuba)
0023 %
0024 % P.R. Jackson, USGS, 12-10-08
0025 % Last modified: F.L. Engel, USGS, 2/20/2013
0026 
0027 
0028 warning off
0029 % disp('Plotting Plan View with Depth-Averaged Velocity Vectors...')
0030 
0031 %% User Input
0032 
0033 %QuiverSpacing   = 15;  %Plots a quiver every X emsembles
0034 %ascale          = 1.5; %Set to 1 for autoscaling and other values for increased or decreased arrow lengths
0035 if exist('plot_english')==0
0036     plot_english  = 0;
0037     disp('No units specified, plotting in metric units by default')
0038 end
0039 
0040 %% Plot Quivers on Area Map
0041 
0042 if isnan(drng)
0043     drng = [];
0044 end
0045 
0046 windowSize      = pvsmwin; %Size of window for running average in smoothing of mean vel vectors (set in GUI)
0047 
0048 % See if PLOT 1 exists already, if so clear the figure
0049 fig_planview_handle = findobj(0,'name','Plan View Map');
0050 
0051 if ~isempty(fig_planview_handle) &&  ishandle(fig_planview_handle)
0052     figure(fig_planview_handle); clf
0053 else
0054     fig_planview_handle = figure('name','Plan View Map'); clf
0055     %set(gca,'DataAspectRatio',[1 1 1],'PlotBoxAspectRatio',[1 1 1])
0056 end
0057 
0058 % Turn off the menu bar, and keep only specified tools
0059 disableMenuBar(fig_planview_handle)
0060 
0061 % Parse optional arguements
0062 minrng       = [];
0063 maxrng       = [];
0064 usecolormap  = [];
0065 cptfullfile  = [];
0066 if ~isempty(varargin)
0067     if iscell(varargin{1})
0068         mapmult = true;
0069         zf = length(varargin{1});
0070     else
0071         mapmult = false;
0072         zf = 1;
0073     end
0074     zPathName = varargin{2};
0075     zFileName = varargin{1};
0076     
0077     
0078     % Parse VMT_GraphicsControl arguements
0079     if size(varargin,2) > 2 % min and max specified at least
0080         minrng       = varargin{3};
0081         maxrng       = varargin{4};
0082         usecolormap  = varargin{5};
0083         cptfullfile  = varargin{6};
0084     end
0085 else
0086     mapmult = false;
0087     zf = 1;
0088 end
0089 
0090 for n=1:zf
0091     if mapmult
0092         eval(['load (' sprintf( '\''' ) fullfile(zPathName,zFileName{n}) sprintf( '\''' ) ')']);
0093     end
0094     
0095     if ~isempty(drng)
0096         indx = find(V.mcsDepth(:,1) < drng(1) | V.mcsDepth(:,1) > drng(2));
0097         
0098         %Set all data outside depth range to nan
0099         V.mcsX(indx,:) = nan;
0100         V.mcsY(indx,:) = nan;
0101         V.mcsEast(indx,:) = nan;
0102         V.mcsNorth(indx,:) = nan;
0103         
0104 %         if n == 1
0105 %             if plot_english
0106 %                 disp(['Plotting Depth Range ' num2str(drng(1)*3.281) 'ft to ' num2str(drng(2)*3.281) 'ft'])
0107 %             else
0108 %                 disp(['Plotting Depth Range ' num2str(drng(1)) 'm to ' num2str(drng(2)) 'm'])
0109 %             end
0110 %         end
0111         
0112         clear indx
0113     end
0114     
0115    %Compute mean positions
0116    V.mcsX1 = nanmean(V.mcsX,1);
0117    V.mcsY1 = nanmean(V.mcsY,1);
0118     
0119    if 0; %Compute the depth averaged velocity (straight arithmetic mean--old method)
0120         V.mcsEast1 = nanmean(V.mcsEast,1);
0121         V.mcsNorth1 = nanmean(V.mcsNorth,1);
0122     
0123    else %Compute the depth (or layer) averaged velocity (new method)
0124         V.mcsEast1  = VMT_LayerAveMean(V.mcsDepth,V.mcsEast);
0125         V.mcsNorth1 = VMT_LayerAveMean(V.mcsDepth,V.mcsNorth);
0126    end
0127     
0128 
0129     %Smooth using a running mean defined by WindowSize (averages
0130     %'2*windowsize+1' ensembles together (centered on node (boxcar filter))
0131     if windowSize == 0
0132         V.mcsX1sm     = V.mcsX1;
0133         V.mcsY1sm     = V.mcsY1;
0134         V.mcsEast1sm  = V.mcsEast1;
0135         V.mcsNorth1sm = V.mcsNorth1;
0136     else
0137 %         V.mcsX1sm     = filter(ones(1,windowSize)/windowSize,1,V.mcsX1);
0138 %         V.mcsY1sm     = filter(ones(1,windowSize)/windowSize,1,V.mcsY1);
0139 %         V.mcsEast1sm  = filter(ones(1,windowSize)/windowSize,1,V.mcsEast1);
0140 %         V.mcsNorth1sm = filter(ones(1,windowSize)/windowSize,1,V.mcsNorth1);
0141         
0142         V.mcsEast1sm  = nanmoving_average(V.mcsEast1,windowSize);  %added 1-7-10, prj
0143         V.mcsNorth1sm = nanmoving_average(V.mcsNorth1,windowSize);
0144         V.mcsX1sm     = V.mcsX1;
0145         V.mcsY1sm     = V.mcsY1;
0146     end
0147     
0148     for zi = 1 : z
0149         Mag(:,:,zi) = A(zi).Comp.mcsMag(:,:);
0150         %Mag(:,:,zi) = A(zi).Clean.vMag(:,:);
0151     end
0152     numavg = nansum(~isnan(Mag),3);
0153     numavg(numavg==0) = NaN;
0154     enscnt = nanmean(numavg,1);
0155     [I,J] = ind2sub(size(enscnt),find(enscnt>=1));  %Changed to 1 from 2 (PRJ, 12-12-08)
0156 
0157     et = windowSize+J(1):QuiverSpacing:J(end);  
0158     
0159     % M(2*n-1,1)=V.mcsX(1,1);
0160     % M(2*n,1)=V.mcsX(1,end);
0161     % M(2*n-1,2)=V.mcsY(1,1);
0162     % M(2*n,2)=V.mcsY(1,end);
0163     %
0164     % idx=strfind(zFileName{n},'.');
0165     % namecut=zFileName{1,n}(2:idx(1)-1);
0166     %
0167     % pwr_kml(namecut,latlon);
0168     
0169     if n == 1
0170         toquiv(1:493,1:4)=NaN;
0171         lenp = 0;
0172     end
0173     
0174     len = length(V.mcsX1sm(1,et));
0175 
0176     toquiv(lenp+1:len+lenp,1)=V.mcsX1sm(1,et);
0177     toquiv(lenp+1:len+lenp,2)=V.mcsY1sm(1,et);
0178     toquiv(lenp+1:len+lenp,3)=nanmean(V.mcsEast1sm(:,et),1);
0179     toquiv(lenp+1:len+lenp,4)=nanmean(V.mcsNorth1sm(:,et),1);
0180 
0181     lenp = length(V.mcsX1sm(1,et))+lenp;
0182 
0183     % quiverc2wcmap(V.mcsX1sm(1,et),V.mcsY1sm(1,et),nanmean(V.mcsEast1sm(:,et),1),nanmean(V.mcsNorth1sm(:,et),1),0);
0184     %quiverc(V.mcsX1sm(1,et),V.mcsY1sm(1,et),nanmean(V.mcsEast1sm(:,et),1),nanmean(V.mcsNorth1sm(:,et),1),0)
0185     %     quiver(V.mcsX1sm(1,et),V.mcsY1sm(1,et),nanmean(V.mcsEast1sm(:,et),1),nanmean(V.mcsNorth1sm(:,et),1),0)
0186     
0187     if mapmult
0188         clear A V z Mag numavg enscnt I J latlon idx namecut
0189     end
0190 end
0191 vr = sqrt(toquiv(:,3).^2+toquiv(:,4).^2);
0192 
0193 % Save only the good data  %Added 3-28-12 PRJ
0194 gdindx = find(~isnan(vr));
0195 toquiv = toquiv(gdindx,:);
0196 
0197 figure(fig_planview_handle); hold on
0198 % if pdoqq
0199 %     VMT_OverlayDOQQ
0200 % end
0201 % if pshore
0202 %     if ~isempty(Map)
0203 %         VMT_PlotShoreline(Map)
0204 %     end
0205 % end
0206 %quiverc2wcmap(toquiv(:,1),toquiv(:,2),toquiv(:,3),toquiv(:,4),0,vr,1);
0207 if plot_english
0208     %quiverc(toquiv(:,1),toquiv(:,2),toquiv(:,3)*0.03281,toquiv(:,4)*0.03281,ascale);  %*0.03281 to go from cm/s to ft/s
0209     quiverc(toquiv(:,1),toquiv(:,2),toquiv(:,3)*0.03281,toquiv(:,4)*0.03281,ascale,...
0210         minrng,...
0211         maxrng,...
0212         usecolormap,...
0213         cptfullfile);
0214     colorbar%('FontSize',16,'XColor','w','YColor','w');
0215     if sum(~isnan(vr)) == 0
0216         errordlg('No Data in Specified Depth Range','Plotting Error');
0217     end
0218     log_text = {sprintf('   DAV range: %6.3f to %6.3f ft/s', nanmin(vr)*0.03281,nanmax(vr)*0.03281)};
0219     %caxis([nanmin(vr*0.03281) nanmax(vr*0.03281)])  %resets the color bar axis from 0 to 64 to span the velocity mag range
0220     % Reset the color bar axis from 0 to 64 to span the velocity mag range
0221     if ~isempty(minrng)
0222         caxis([minrng maxrng])  
0223     else
0224         caxis([nanmin(vr*0.03281) nanmax(vr*0.03281)])
0225     end
0226     if ~isempty(drng)
0227         title({'Depth-Averaged Velocities (ft/s)'; ['Averaged over depths ' num2str(drng(1)*3.281) 'ft to ' num2str(drng(2)*3.281) 'ft']})%,'Color','w');
0228     else
0229         title('Depth-Averaged Velocities (ft/s)')%,'Color','w');
0230     end
0231 else  %plot in metric units
0232     %quiverc(toquiv(:,1),toquiv(:,2),toquiv(:,3),toquiv(:,4),ascale);
0233     quiverc(toquiv(:,1),toquiv(:,2),toquiv(:,3),toquiv(:,4),ascale,...
0234         minrng,...
0235         maxrng,...
0236         usecolormap,...
0237         cptfullfile);
0238     colorbar%('FontSize',16,'XColor','w','YColor','w');
0239     if sum(~isnan(vr)) == 0
0240         errordlg('No Data in Specified Depth Range','Plotting Error');
0241     end
0242     log_text = {sprintf('   DAV range: %6.3f to %6.3f m/s', nanmin(vr),nanmax(vr))};
0243     
0244     % Reset the color bar axis from 0 to 64 to span the velocity mag range
0245     if ~isempty(minrng)
0246         caxis([minrng maxrng])  
0247     else
0248         caxis([nanmin(vr) nanmax(vr)])
0249     end
0250     
0251     if ~isempty(drng)
0252         title({'Depth-Averaged Velocities (cm/s)'; ['Averaged over depths ' num2str(drng(1)) 'm to ' num2str(drng(2)) 'm']})%,'Color','w');
0253     else
0254         title('Depth-Averaged Velocities (cm/s)')%,'Color','w');
0255     end
0256 end
0257 
0258 xlabel('UTM Easting (m)')
0259 ylabel('UTM Northing (m)')
0260 figure(fig_planview_handle); box on
0261 %set(gcf,'Color',[0 0 0]) %[0.2 0.2 0.2]
0262 %set(gca,'Color',[0.8,0.733,0.533]) %[0.3 0.3 0.3]
0263 set(gca,'DataAspectRatio',[1 1 1],'PlotBoxAspectRatio',[1 1 1])
0264 set(gca,'TickDir','out')
0265 
0266 % Format the ticks for UTM and allow zooming and panning
0267 ticks_format('%6.0f','%8.0f'); %formats the ticks for UTM
0268 hdlzm = zoom;
0269 set(hdlzm,'ActionPostCallback',@mypostcallback_zoom);
0270 set(hdlzm,'Enable','on');
0271 hdlpn = pan;
0272 set(hdlpn,'ActionPostCallback',@mypostcallback_pan);
0273 set(hdlpn,'Enable','on');
0274 
0275 % Display the figure
0276 % Hide the figure until the end (this makes the rendering look better)
0277 %set(fig_planview_handle,'visible','on')
0278 
0279 %% Save the planview data as output and to an *.anv file with spacing and smoothing (for iRiC)
0280 outmat = zeros(size(toquiv,1),5);
0281 outmat(:,1:2) = toquiv(:,1:2);  % In metric units
0282 outmat(:,4:5) = toquiv(:,3:4)./100;  %Converts cm/s to m/s
0283 
0284 %Screen to ID missing data
0285 goodrows = [];
0286 for i = 1:length(outmat)
0287     rowsum = sum(isnan(outmat(i,:)));
0288     if rowsum == 0
0289         goodrows = [goodrows; i];
0290     end
0291 end
0292 
0293 PVdata.outmat = outmat(goodrows,:)';
0294 
0295 function mypostcallback_zoom(obj,evd)
0296 ticks_format('%6.0f','%8.0f'); %formats the ticks for UTM (when zooming)
0297 
0298 function mypostcallback_pan(obj,evd)
0299 ticks_format('%6.0f','%8.0f'); %formats the ticks for UTM (when panning)
0300 
0301

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