Skip to content

Commit

Permalink
Isolated the issue to bad syntax in VMT_PlotShipTracks.
Browse files Browse the repository at this point in the history
I verified that N and M are computed correctly in VMT_MapEns2MeanXS, and then
assigned new vars to V.N and V.M. Now the plotting routine calls those vars
instead.
  • Loading branch information
frank-engel-usgs committed Apr 26, 2017
1 parent 915c80c commit 377fe1f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 35 deletions.
2 changes: 1 addition & 1 deletion VMT.m
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function VMT_OpeningFcn(hObject, eventdata, handles, varargin)
% Initialize the GUI parameters:
% ------------------------------
guiparams = createGUIparams;
guiparams.vmt_version = {'v4.08'; 'r20170404'};
guiparams.vmt_version = {'v4.08'; 'r20170426'};

% Draw the VMT Background
% -----------------
Expand Down
6 changes: 4 additions & 2 deletions VMT_MapEns2MeanXS.m
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@

% First compute the normal unit vector to the mean
% cross section
N = [-dy/sqrt(dx^2+dy^2)...
dx/sqrt(dx^2+dy^2)];
N = [-dy dx]./sqrt(dx^2+dy^2);

% Compute the mean flow direction in the cross section. To do
% this, we also have to convert from geographic angle to
Expand All @@ -133,6 +132,7 @@
% to be reversed before resolving the u,v coordinates
if vdif >= 90
N = -N;
% N = [dy -dx]./sqrt(dx^2+dy^2);
end

% Plot N and M to check (scale of the vectors is 10% of the
Expand All @@ -149,6 +149,8 @@

% Geographic angle of the normal vector to the cross section
V.phi = ari2geodeg(cart2pol(N(1),N(2))*180/pi);
V.N = N;
V.M = M;

clear x y stats whichstats zi

Expand Down
36 changes: 4 additions & 32 deletions VMT_PlotShiptracks.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,45 +70,17 @@
plot(hf,polyval(P,V.mcsY(1,:)),V.mcsY(1,:),'g-')
end

% Determine the direction of the streamwise coordinate, which
% is taken as perpendicular to the mean cross section. Theta is
% expressed in geographical (N = 0 deg, clockwise positive)
% coordinates. This method uses a vector based approach which
% is insensitive to orientation of the cross section.

% First compute the normal unit vector to the mean
% cross section
N = [-V.dy/sqrt(V.dx^2+V.dy^2)...
V.dx/sqrt(V.dx^2+V.dy^2)];

% Compute the mean flow direction in the cross section. To do
% this, we also have to convert from geographic angle to
% arimetic angle
arimfddeg = geo2arideg(V.mfd);
[xmfd,ymfd] = pol2cart(arimfddeg*pi/180,1);
M = [xmfd ymfd];

% Now compute the angle between the normal and mean flow
% direction unit vectors
vdif = acos(dot(N,M)/(norm(N)*norm(M)))*180/pi;

% If the angle is greater than 90 degs, the normal vector needs
% to be reversed before resolving the u,v coordinates
if vdif >= 90
N = -N;
end

% Plot N and M to check (scale of the vectors is 10% of the
% total length of the cross section)
midy = V.ys+abs(yrng)/2;
midx = V.xw+xrng/2;
axes(hf); hold on;
quiver(hf,...
midx,midy,N(1)*V.dl*0.1,...
N(2)*V.dl*0.1,1,'k')
midx,midy,V.N(1)*V.dl*0.1,...
V.N(2)*V.dl*0.1,1,'k')
quiver(hf,...
midx,midy,M(1)*V.dl*0.1,...
M(2)*V.dl*0.1,1,'r')
midx,midy,V.M(1)*V.dl*0.1,...
V.M(2)*V.dl*0.1,1,'r')

%Plot data to check
xensall = [];
Expand Down

0 comments on commit 377fe1f

Please sign in to comment.