;+ ; NAME: ; oc_naifstate.pro ; ; PURPOSE: ; returns a 6-element state (or a 6 x n matrix) ; ; DESCRIPTION: ; Calculates the state using the NAIF ICY routines. ; ; CALLING SEQUENCE: ; state = oc_naifstate(et,targ,$ ; obs=obs,abcorr=abcorr,frame=frame,lonlatalt=lonlatalt) ; ; INPUTS: ; et - the ET at which you want to know the coordinates (may be an ; array). Units are seconds of TDB (barycentric dynamical ; time) after J2000. ; targ = target code ; ; KEYWORDS ; obs - the keyword argument that indicates the observer location, ; default to Earth center (399). ; abcorr - aberation correction. Default 'LT' ; frame - frame of state, ra, dec. Default 'J2000' ; lonlatalt - lon, lat, altitude for topocentric ; ephemerides. Default geocentric ; OUTPUTS: ; ltime - optional output of light-travel time ; ; If et is a double, then return state = [x,y,z,x',y',z'] in ; km and km/s. ; If et is an array, return statearr = [ [state0], [state1], ...] ; so single states are accessed by statearr[*,i] ; ; RESTRICTIONS ; For geocentric observations, ltime and position can be off by ; Re/c = 21 ms. ; ; REVISON HISTORY: ; 2006 Jan 02 Leslie Young. Based on single_eph ; 2006 May 11 LAY Added ltime ;- function oc_naifstate, et,targ,$ obs=obs,abcorr=abcorr,frame=frame,lonlatalt=lonlatalt, ltime=ltime naifinit if not keyword_set(obs) then obs = 399 ; Earth if not keyword_set(abcorr) then abcorr = 'LT' ; light-time only if not keyword_set(frame) then frame = 'J2000' ; n = n_elements(et) statearr = dblarr(6,n) ltime = dblarr(n) for i = 0, n-1 do begin e = et[i] CSPICE_SPKEZ, targ, e, frame, abcorr, obs, $ stateTarget, ltime1 if keyword_set(lonlatalt) then begin stateTarget = stateTarget - oc_lla2xyz(lonlatalt,e) endif statearr[*,i] = stateTarget ltime[i] = ltime1 end if n eq 1 then begin if isarray(et) then begin return, reform(statearr,6,1) endif else begin ltime = ltime[0] return, reform(statearr[*,0], 6) endelse endif else begin return, statearr endelse end