;+ ;Function: SPICE_BODY_POS ; ;Purpose: Returns the position of an object relative to an observer. ; This is a wrapper to the cspice routine: CSPICE_SPKPOS ;Keywords: ; check_objects: frame or body name that the routine will check for valid times to prevent crashing. ; ; Author: Davin Larson ; $LastChangedBy: davin-mac $ ; $LastChangedDate: 2019-05-11 00:00:35 -0700 (Sat, 11 May 2019) $ ; $LastChangedRevision: 27221 $ ; $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/tags/spedas_3_2/general/spice/spice_body_pos.pro $ ;- function spice_body_pos,body_name,obs_name,utc=utc,et=et,frame=frame,ltime=ltime,abcorr=abcorr,check_objects=check_objects,force_objects=force_objects on_error,2 if not keyword_set(frame) then frame = 'ECLIPJ2000' if not keyword_set(abcorr) then abcorr = 'NONE' ut = time_double(utc) et = time_ephemeris(ut,/ut2et) ns = n_elements(et) if keyword_set(check_objects) then begin time_valid = spice_valid_times(et,object=check_objects,force_objects=force_objects) ; printdat,check_objects,time_valid ind = where(time_valid ne 0,nind) dprint,dlevel=2,verbose=verbose,nind,' Valid times from:',check_objects endif else begin ; nind = ns ind = lindgen((nind = ns)) endelse pos = replicate(!values.d_nan,3,ns) if arg_present(ltime) then ltime = replicate(!values.d_nan,ns) if nind ne 0 then begin cspice_spkpos,body_name,et[ind],frame,abcorr,obs_name, pos2, ltime2 pos[*,ind] = pos2 if keyword_set(ltime) then ltime[ind] = ltime2 endif else dprint,'No Valid SPK frame for: ',check_objects return,pos end