; docformat = 'rst' ;+ ;This function takes in a GPS time and computes the velocity of the ;spacecraft. ; ; :Examples: ; velocity = scvel(gps_time, ecef=ecef, dv=dv) ;- ;+ ; :Params: ; Time : in, required, type=double ; Input GPS time in microseconds. Must be a scalar. ; ; :Keywords: ; ecef : in, optional, type=boolean ; Set this keyword to return the velocity in ECEF coordinates, ; defaults to ECI. ; dv : out, optional, type=double ; 1 sigma of uncertainty in each coordinate, in km/h. ; ; :Returns: ; Returns the velocity vector of the spacecraft, in km/h. ;- function scvel,Time,ecef=ecef,dv=dv if ~real_numeric_type(Time) then begin doc_library, 'scvel' return, -1 endif if has_astron_lib() then begin JD=usec2jd(Time) spacecraft_pv,!SC_NUMBER,JD,pv,pv_uncertainty=dpv,tle_path=!tle_path,status=status if status gt 0 then message,"spacecraft_pv didn't work" v=pv[3:5] dv=dpv[3:5] end else begin r1=scpos(Time-1d6); r2=scpos(Time); r3=scpos(Time+1d6); v1=r2-r1; v2=r3-r2; v=(v1+v2)/2 dv=[1,1,1]*0.001 end if keyword_set(ecef) then begin dv=transformgrid(eci_to_ecef(time),dv) return,transformgrid(eci_to_ecef(time),v) end else begin return,v; end end