;+
; Contains the read_eph procedure
;
; :Author:
; Baptiste Cecconi
;
; :History:
; 2006/07/16: Created
;
; 2006/07/16: Last Edit
;-
;
;+
; reads an ephemeris text file ../eph/fichier.eph
; (created from the web team page)
;
; :Params:
; fichier: in, required, type=sometype
; file, must have full path and extension included.
; x: out, required, type=sometype
; ephemeris in Rp (ecliptic or equatorial coordinates)
; y: out, required, type=sometype
; ephemeris in Rp (ecliptic or equatorial coordinates)
; z: out, required, type=sometype
; ephemeris in Rp (ecliptic or equatorial coordinates)
; r: out, required, type=sometype
; ephemeris in Rp (ecliptic or equatorial coordinates)
; t97: out, required, type=sometype
; time 1997.0
; rp: out, required, type=sometype
; in km
;-
pro READ_EPH, fichier, x, y, z, r, t97, rp
openr,u,fichier,/get_lun
comment = ''
readf,u,comment & readf,u,comment & readf,u,comment
str = strsplit(comment,'(',/extract)
str = (strsplit(str(1),')',/extract))(0)
message,str,/info
str = strsplit(str,'=',/extract)
str = (strsplit(str(1),'km',/extract))(0)
rp = float(str)
readf,u,comment & readf,u,comment & readf,u,comment
n=0
while not eof(u) do begin
; readf,u,a,j,h,m,s,xx,yy,zz,rr
readf,u,a,j,h,m,s,xx,yy,zz,rr,vx,vy,vz,vv ; new ephem data format
sec=h*3600.d0+m*60.d0+s
if n eq 0 then begin
aj=[a*1000.d0+j+sec/86400.d0] & x=[xx] & y=[yy] & z=[zz] & r=[rr]
endif else begin
aj=[aj,a*1000.d0+j+sec/86400.d0] & x=[x,xx] & y=[y,yy] & z=[z,zz] & r=[r,rr]
endelse
n=n+1
endwhile
close,u & free_lun,u
message,string(n)+' ephemeris lines read',/info
t97=aj_t97(aj)
dt=min(t97(1:*)-t97(0:n_elements(t97)-2))*1440.d0
message,'Dt = '+string(long(dt+0.5))+' minutes',/info
return
end