function [xfac,yfac]=arrowm(x,y,u,v,style,origin,lonc,latc);

%

%function [xfac,yfac]=arrowm(x,y,u,[v],[style],[origin],latc,lonc);

%  function to plot scaled arrows on a simple lat-long projection

%  x,y  == arrow origin

%  u,v  == vector to be plotted

%  style==0: hollow arrows 

%  style==1: stick arrows

%  style==-1 (default): solid arrows

%  style==-2  thick line arrows

%  style==-3  sticks

%  origin==0: origin in center of arrows: default

%  origin==1: origin at tail end of arrows:

%  lonc = deg lon/u,v unit

%  latc = deg lat/u,v unit



%

% program was modified from Rocky G.'s arrow by jchurchill

%

load arrow

%

hold on

narg=nargin;

if (length(u)>1)&(length(v)==1)      %complex u

      if exist('style')==1; origin=style; end

      v=imag(u);

      u=real(u);

            narg=narg+1;

end

cstr='-';

if narg>=6

      if style==0

         ax=ax2; ay=ay2;

      elseif style==1

         ax=ax3; ay=ay3;

      elseif style==-2

         ax=ax(1:31); ay=ay(1:31);

      elseif style==-3

         ax=ax4; ay=ay4;

      end

      if style>1

         cstr=['-c',int2str(style)];

      end      

end

if narg<7; origin=0; end;

ax=ax+origin/2;

g=find((x(:)~=nan)&(u(:)~=nan)&(v(:)~=nan));

g=g(:);

x=x(g); y=y(g); u=u(g); v=v(g);

x=x(:)'; y=y(:)'; u=u(:)'; v=v(:)';



xfac = lonc;

yfac = latc;

[theta,umag]=directio(u,v);

theta=90-theta;

outx=ax'*umag;

outy=ay'*umag;

[outxr,outyr]=rotm(theta,outx,outy);

  outxf=outxr*(xfac); 

  outyf=outyr*(yfac); 

  outxf=outxf + ones(length(outxr),1)*x;

  outyf=outyf + ones(length(outyr),1)*y;

  plot(outxf,outyf,cstr,'color','w')

