function [theta,r]=direction(u,v);
%function [theta,r]=thetar(u,v);
%       converts to polar coords, with theta first
%        compass direction, clockwise from north, expecting (E,N)
if nargin==1
    [n,m]=size(u);
    if (n==2)&(m~=2)
         v=u(2,:);
         u=u(1,:);
    else
         v=u(:,2);
         u=u(:,1);      
    end
end
im=sqrt(-1);
u=u+im*v;
r=abs(u);
theta=90-imag(log(u))*180/pi;
a=find(theta<0);
if length(a)>0
theta(a)=theta(a)+ones(a/a(1))*360;
end
