VMT_PlotShiptracks

PURPOSE ^

Plots the shiptracks, and interpolated grid in the VMT GUI axes. Also

SYNOPSIS ^

function hf = VMT_PlotShiptracks(A,V,z,setends,hf)

DESCRIPTION ^

 Plots the shiptracks, and interpolated grid in the VMT GUI axes. Also
 plots the mean cross section normal vector, and the mean flow direction
 vector.

 F.L. Engel, USGS, 2/20/2013

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function hf = VMT_PlotShiptracks(A,V,z,setends,hf)
0002 % Plots the shiptracks, and interpolated grid in the VMT GUI axes. Also
0003 % plots the mean cross section normal vector, and the mean flow direction
0004 % vector.
0005 %
0006 % F.L. Engel, USGS, 2/20/2013
0007 
0008 % See if PLOT 1 exists already, if so clear the figure
0009 % fig_shiptracks_handle = findobj(0,'name','Shiptracks');
0010 
0011 
0012 if ~isempty(hf) &&  ishandle(hf)
0013     %figure(fig_shiptracks_handle); clf
0014     axes(hf)
0015     cla
0016     set(hf,'NextPlot','replacechildren')
0017 else
0018     hf = figure('name','Shiptracks'); clf
0019     set(gca,'DataAspectRatio',[1 1 1])
0020         %...'PlotBoxAspectRatio',[1 1 1],...
0021         
0022 end
0023 
0024 
0025 for zi = 1 : z
0026     axes(hf); hold on
0027     plot(hf,A(zi).Comp.xUTMraw,A(zi).Comp.yUTMraw,'b'); hold on
0028     
0029     % Plot the various reject and/or adjusted GPS location data for
0030     % reference
0031     %plot(A(zi).Comp.xUTM,A(zi).Comp.yUTM,'r'); hold on
0032     plot(hf,...
0033         ...A(zi).Comp.xUTMraw(A(zi).Comp.gps_reject_locations),...
0034         ...A(zi).Comp.yUTMraw(A(zi).Comp.gps_reject_locations),'g.',...
0035         ...A(zi).Comp.xUTMraw(A(zi).Comp.gps_repeat_locations),...
0036         ...A(zi).Comp.yUTMraw(A(zi).Comp.gps_repeat_locations),'y.',...
0037         A(zi).Comp.xUTMraw(A(zi).Comp.gps_fly_aways),...
0038         A(zi).Comp.yUTMraw(A(zi).Comp.gps_fly_aways),'r.')
0039 end
0040 % Gets a user text file with fixed cross section end points
0041 if setends
0042     [x,y] = loadUserSetEndpoints(); % subfunction
0043     figure(hf); hold on
0044     plot(hf,x,y,'go','MarkerSize',10); hold on
0045     
0046     %     % Save the shorepath
0047     %     if exist('LastDir.mat') == 2
0048     %         save('LastDir.mat','endspath','-append')
0049     %     else
0050     %         save('LastDir.mat','endspath')
0051     %     end
0052 end
0053 
0054 % Plot the equation of the best fit line
0055 xrng = V.xe - V.xw;
0056 yrng = V.yn - V.ys;
0057 
0058 if xrng >= yrng
0059     P(1) = V.m;
0060     P(2) = V.b;
0061     
0062     axes(hf); hold on;
0063     plot(hf,V.mcsX(1,:),polyval(P,V.mcsX(1,:)),'g-')
0064 else
0065     P(1) = 1/V.m;
0066     P(2) = -V.b/V.m;
0067     
0068     axes(hf); hold on;
0069     plot(hf,polyval(P,V.mcsY(1,:)),V.mcsY(1,:),'g-')
0070 end
0071 
0072 % Determine the direction of the streamwise coordinate, which
0073 % is taken as perpendicular to the mean cross section. Theta is
0074 % expressed in geographical (N = 0 deg, clockwise positive)
0075 % coordinates. This method uses a vector based approach which
0076 % is insensitive to orientation of the cross section.
0077 
0078 % First compute the normal unit vector to the mean
0079 % cross section
0080 N = [-V.dy/sqrt(V.dx^2+V.dy^2)...
0081     V.dx/sqrt(V.dx^2+V.dy^2)];
0082 
0083 % Compute the mean flow direction in the cross section. To do
0084 % this, we also have to convert from geographic angle to
0085 % arimetic angle
0086 arimfddeg = geo2arideg(V.mfd);
0087 [xmfd,ymfd] = pol2cart(arimfddeg*pi/180,1);
0088 M = [xmfd ymfd];
0089 
0090 % Now compute the angle between the normal and mean flow
0091 % direction unit vectors
0092 vdif = acos(dot(N,M)/(norm(N)*norm(M)))*180/pi;
0093 
0094 % If the angle is greater than 90 degs, the normal vector needs
0095 % to be reversed before resolving the u,v coordinates
0096 if vdif >= 90
0097     N = -N;
0098 end
0099 
0100 % Plot N and M to check (scale of the vectors is 10% of the
0101 % total length of the cross section)
0102 midy = V.ys+abs(yrng)/2;
0103 midx = V.xw+xrng/2;
0104 axes(hf); hold on;
0105 quiver(hf,...
0106     midx,midy,N(1)*V.dl*0.1,...
0107     N(2)*V.dl*0.1,1,'k')
0108 quiver(hf,...
0109     midx,midy,M(1)*V.dl*0.1,...
0110     M(2)*V.dl*0.1,1,'r')
0111 
0112 %Plot data to check
0113 xensall = [];
0114 yensall = [];
0115 for zi = 1 : z
0116     plot(hf,A(zi).Comp.xm,A(zi).Comp.ym,'b.')
0117     %xensall = [xensall; A(zi).Comp.xm];
0118     %yensall = [yensall; A(zi).Comp.ym];
0119 end
0120 % plot(A(3).Comp.xm,A(3).Comp.ym,'xg')
0121 % plot(A(4).Comp.xm,A(4).Comp.ym,'oy')
0122 xlabel('UTM Easting (m)')
0123 ylabel('UTM Northing (m)')
0124 box on
0125 grid on
0126 %Plot a legend in Figure 1
0127 %figure(1); hold on
0128 %legend('Shoreline','GPS(corr)','GPS(raw)','Best Fit','Trans 1
0129 %(mapped)','Other Trans (mapped)')
0130 
0131 %Plot the MCS on figure 1
0132 axes(hf); hold on
0133 plot(hf,V.xLeftBank,V.yLeftBank,'gs','MarkerFaceColor','g'); hold on  %Green left bank start point
0134 plot(hf,V.xRightBank,V.yRightBank,'rs','MarkerFaceColor','r'); hold on %Red right bank end point
0135 plot(hf,V.mcsX(1,:),V.mcsY(1,:),'k+'); hold on
0136 axes(hf); 
0137 set(gca,'DataAspectRatio',[1 1 1],'PlotBoxAspectRatio',[1 1 1])
0138 
0139 
0140 % % Format the ticks for UTM and allow zooming and panning
0141 % axes(hf);
0142 ticks_format('%6.0f','%8.0f'); %formats the ticks for UTM
0143 % hdlzm_fig1 = zoom;
0144 % set(hdlzm_fig1,'ActionPostCallback',@mypostcallback_zoom);
0145 % set(hdlzm_fig1,'Enable','on');
0146 % hdlpn_fig1 = pan;
0147 % set(hdlpn_fig1,'ActionPostCallback',@mypostcallback_pan);
0148 % set(hdlpn_fig1,'Enable','on');
0149 
0150 %%%%%%%%%%%%%%%%
0151 % SUBFUNCTIONS %
0152 %%%%%%%%%%%%%%%%
0153 function [x,y] = loadUserSetEndpoints()
0154 defaultpath = 'C:\';
0155 endspath = [];
0156 if 0 %exist('VMT\LastDir.mat') == 2
0157     % load('VMT\LastDir.mat');
0158     % if exist(endspath) == 7
0159         % [file,endspath] = uigetfile({'*.txt;*.csv','All Text Files'; '*.*','All Files'},'Select Endpoint Text File',endspath);
0160     % else
0161         % [file,endspath] = uigetfile({'*.txt;*.csv','All Text Files'; '*.*','All Files'},'Select Endpoint Text File',defaultpath);
0162     % end
0163 else
0164     [file,endspath] = uigetfile({'*.txt;*.csv','All Text Files'; '*.*','All Files'},'Select Endpoint Text File',defaultpath);
0165 end
0166 infile = [endspath file];
0167 %[file,path] = uigetfile({'*.txt;*.csv','All Text Files'; '*.*','All Files'},'Select Endpoint Text File');
0168 %infile = [path file];
0169 disp('Loading Endpoint File...' );
0170 disp(infile);
0171 data = dlmread(infile);
0172 x = data(:,1);
0173 y = data(:,2);
0174 
0175 function mypostcallback_zoom(obj,evd)
0176 ticks_format('%6.0f','%8.0f'); %formats the ticks for UTM (when zooming)
0177 
0178 function mypostcallback_pan(obj,evd)
0179 ticks_format('%6.0f','%8.0f'); %formats the ticks for UTM (when panning)
0180

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