function [ut,vt,jmax] = utrans(latstore,longstore)
%
%  Read in track file, calculate translation speeds and smooth
%               K. Emanuel 11/8/2008
%  Copyright 2009 WindRiskTech L.L.C.
%
%-----------------------------------------------------------------------
%  Smoothing factor
%
smfac=0.4;
%
%-----------------------------------------------------------------------
pifac=acos(-1)/180;
dfac=60.*1.852;
dtfac=1./(4.*1.852);
netfac=dtfac.*dfac;
%
[nn,m]=size(latstore);
%
ut=zeros(nn,m);
vt=zeros(nn,m);
lat=zeros(1,m);
long=zeros(1,m);
jmax=zeros(1,nn);
for n=1:nn,
%
   lat=latstore(n,:);
   [dum,jm]=min(abs(lat));
   jm=jm-1;
   jmax(n)=jm;
   long=longstore(n,:);
   for j=2:jm,
       if long(1) > 280 & long(j) < 100 
           long(j)=long(j)+360.0;
       end
       if long(1) < 100 & long(j) > 280 
           long(j)=long(j)-360.0;
       end
   end
   ut(n,2:jm-1)=netfac.*cos(pifac.*lat(2:jm-1)).*(long(3:jm)-long(1:jm-2));
   vt(n,2:jm-1)=netfac.*(latstore(n,3:jm)-latstore(n,1:jm-2));
   j2=min(3,jm);
   j3=max(jm-2,1);
   ut(n,1)=2.*ut(n,2)-ut(n,j2);
   ut(n,jm)=2.*ut(n,jm-1)-ut(n,j3);
   vt(n,1)=2.*vt(n,2)-vt(n,j2);
   vt(n,jm)=2.*vt(n,jm-1)-vt(n,j3);
   %
   %  Smooth translation velocity
   %
   vt(n,2:jm-1)=vt(n,2:jm-1)+smfac.*(vt(n,1:jm-2)+vt(n,3:jm)-2.*vt(n,2:jm-1));
   ut(n,2:jm-1)=ut(n,2:jm-1)+smfac.*(ut(n,1:jm-2)+ut(n,3:jm)-2.*ut(n,2:jm-1));
end   
   
   