disp('read_hp_day')
fclose('all');
clear all;
jd=input('julian day, ddd','s');
f=['D:\hp_ascii\proc_son' jd  '.txt']
	flist=fopen(f,'r');

jazx=fscanf(flist,'%g%g%g%g%g%g',[6,inf]);

e=['D:\hp_ascii\proc_scs' jd  '.txt']
	fid=fopen(e,'r');
jaz=fscanf(fid,'%g%g%g%g%g%g%g%g%g%g%g%g%g%g%g%g',[16,inf]);



[a,b]=size(jazx);%jazx
[c,d]=size(jaz);%jaz

tn=60*24;%number of minutes in a day
n=1:tn;
jad0=str2num(jd)+(n-1)/24/60;
jadson=jazx(1,1:b);
jadscs=jaz(1,1:d);


clear jazx1;
%fill in beginning empty spots 
jk=1;
while jad0(jk)<jadson(1),
   jazx1(:,jk)=jazx(:,1);
   jk=jk+1;
end;

for i=jk:tn;
   t=find(jadson>jad0(i));j=t(1);
   dt=jadson(j)-jadson(j-1);Dt=jad0(i)-jadson(j-1);
   jazx1(:,i)=jazx(:,j-1)*(1-Dt/dt)+jazx(:,j)*Dt/dt;
end;
jk=tn
while jad0(jk)>=jadson(b),
   jazx1(:,jk)=jazx(:,b);
   jk=jk-1;
end;

clear jaz1;
%fill in beginning empty spots 
jk=1;
while jad0(jk)<jadscs(1),
   jaz1(:,jk)=jaz(:,1);
   jk=jk+1;
end;

for i=jk:tn;
   t=find(jadscs>jad0(i));j=t(1);
   dt=jadscs(j)-jadscs(j-1);Dt=jad0(i)-jadscs(j-1);
   jaz1(:,i)=jaz(:,j-1)*(1-Dt/dt)+jaz(:,j)*Dt/dt;
end;
jk=tn
while jad0(jk)>=jadscs(d),
   jaz1(:,jk)=jaz(:,d);
   jk=jk-1;
end;
U=jazx1(2,:);
V=jazx1(3,:);
w=jazx1(4,:);
lrgm1=jaz1(13,:);
cogm1=jaz1(5,:);
sogm1=jaz1(6,:);
imum1=jaz1(15,:);
imdm1=jaz1(16,:);
odec1=jaz1(14,:);


dc=pi/180;
un1=U.*cos(lrgm1*dc)+sogm1.*cos(cogm1*dc)+V.*sin(lrgm1*dc);
ue1=U.*sin(lrgm1*dc)+sogm1.*sin(cogm1*dc)-V.*cos(lrgm1*dc);
un2=(U+odec1).*cos(lrgm1*dc)+V.*sin(lrgm1*dc);
ue2=(U+odec1).*sin(lrgm1*dc)-V.*cos(lrgm1*dc);
s1=sqrt(un1.*un1+ue1.*ue1);
s2=sqrt(un2.*un2+ue2.*ue2);
dir1=mod(atan2(-ue1,-un1)*180/pi+360,360);
dir2=mod(atan2(-ue2,-un2)*180/pi+360,360);

