Table of contents
CSPICE_SPKPVN returns, for a specified SPK segment and time, the state
(position and velocity) of the segment's target body relative to its
center of motion.
Given:
handle,
descr the file handle assigned to an SPK file, and the descriptor for
a segment within the file.
help, handle
LONG = Scalar
help, descr
DOUBLE = Array[5]
Together they determine the ephemeris data from which the state
of the body is to be computed.
et the epoch (ephemeris time) at which the state is to be computed.
help, et
DOUBLE = Scalar
the call:
cspice_spkpvn, handle, descr, et, ref, state, center
returns:
ref the id-code of the reference frame to which the vectors returned
by the routine belong.
help, ref
LONG = Scalar
state a 6-dimensional vector that contains the position and velocity,
at epoch `et', for whatever body is covered by the specified
segment.
help, state
DOUBLE = Array[6]
`state' has six elements: the first three contain the body's
position; the last three contain the body's velocity. These
vectors are rotated into the specified reference frame, the
origin of which is located at the center of motion for the body
(see `center', below). Units are always km and km/sec.
center the integer ID code of the center of motion for the state.
help, center
LONG = Scalar
None.
Any numerical results shown for this example may differ between
platforms as the results depend on the SPICE kernels used as input
and the machine specific arithmetic implementation.
1) In the following code example, an SPK file is searched for
a segment containing ephemeris data for the Jupiter system
barycenter at a particular epoch. Using this segment,
states of the Jupiter system barycenter relative to the
solar system barycenter are evaluated at a sequence of times.
This method of state computation minimizes the number of
segment searches required to obtain requested data, but
it bypasses the SPK subsystem's state chaining mechanism.
Use the meta-kernel shown below to load the required SPICE
kernels.
KPL/MK
File name: spkpvn_ex1.tm
This meta-kernel is intended to support operation of SPICE
example programs. The kernels shown here should not be
assumed to contain adequate or correct versions of data
required by SPICE-based user applications.
In order for an application to use this meta-kernel, the
kernels referenced here must be present in the user's
current working directory.
The names and contents of the kernels referenced
by this meta-kernel are as follows:
File name Contents
--------- --------
de421.bsp Planetary ephemeris
naif0010.tls Leapseconds
\begindata
KERNELS_TO_LOAD = ( 'de421.bsp',
'naif0010.tls' )
\begintext
End of meta-kernel
Example code begins here.
PRO spkpvn_ex1
;;
;; Local constants
;;
META = 'spkpvn_ex1.tm'
ND = 2
NI = 6
TIMFMT = 'YYYY MON DD HR:MN:SC.######::TDB TDB'
TIMLEN = 41
;;
;; Load meta-kernel.
;;
cspice_furnsh, META
;;
;; Convert starting time to seconds past J2000 TDB.
;;
timstr = '2012 APR 27 00:00:00.000 TDB'
cspice_str2et, timstr, et0
;;
;; Find a loaded segment for the Jupiter barycenter
;; that covers 'et0'.
;;
body = 5;
cspice_spksfs, body, et0, $
handle, descr, segid, found
if ( ~found ) then begin
cspice_kclear
print, 'Body : ', body
print, 'Time : ', timstr
print, 'No SPK segment found for the body at time.'
return
endif
;;
;; Unpack the descriptor of the current segment.
;;
cspice_dafus, descr, ND, NI, dc, ic
cspice_frmnam, ic[2], frname
print, format='(A, I10)', 'Body = ',ic[0]
print, format='(A, I10)', 'Center = ',ic[1]
print, format='(A, A)', 'Frame = ',frname
print, format='(A, I10)', 'Data type = ', ic[3]
print, format='(A, e16.8)', 'Start ET = ',dc[0]
print, format='(A, e16.8)', 'Stop ET = ',dc[1]
print, format='(A, A)', 'Segment ID = ',segid
print
;;
;; Evaluate states at 10-second steps, starting at 'et0'
;; and continuing for 20 seconds.
;;
for i=0, 2 do begin
et = et0 + ( 10.D * i )
;;
;; Convert 'et' to a string for display.
;;
cspice_timout, et, TIMFMT, TIMLEN, outstr
;;
;; Attempt to compute a state only if the segment's
;; coverage interval contains 'et'.
;;
if ( et le dc[1] ) then begin
;;
;; This segment has data at 'et'. Evaluate the
;; state of the target relative to its center
;; of motion.
;;
cspice_spkpvn, handle, descr, et, ref_id, state, center
;;
;; Display the time and state.
;;
print, outstr
print, format='(A, e24.17)', 'Position X (km): ',state[0]
print, format='(A, e24.17)', 'Position Y (km): ',state[1]
print, format='(A, e24.17)', 'Position Z (km): ',state[2]
print, format='(A, e24.17)', 'Velocity X (km/s): ',state[3]
print, format='(A, e24.17)', 'Velocity Y (km/s): ',state[4]
print, format='(A, e24.17)', 'Velocity Z (km/s): ',state[5]
print
endif else begin
print, 'Body : ', body
print, 'Time : ', outstr
print, 'No data for body found at time'
cspice_kclear
return
endelse
endfor
;;
;; It's always good form to unload kernels after use,
;; particularly in IDL due to data persistence.
;;
cspice_kclear
END
When this program was executed on a Mac/Intel/IDL8.x/64-bit
platform, the output was:
Body = 5
Center = 0
Frame = J2000
Data type = 2
Start ET = -3.16919520e+09
Stop ET = 1.69685280e+09
Segment ID = DE-0421LE-0421
2012 APR 27 00:00:00.000000 TDB
Position X (km): 4.64528993982164860e+08
Position Y (km): 5.41513126156852007e+08
Position Z (km): 2.20785135624629408e+08
Velocity X (km/s): -1.03868564830765493e+01
Velocity Y (km/s): 7.95324700713742416e+00
Velocity Z (km/s): 3.66185835431306517e+00
2012 APR 27 00:00:10.000000 TDB
Position X (km): 4.64528890113592625e+08
Position Y (km): 5.41513205689313412e+08
Position Z (km): 2.20785172243209451e+08
Velocity X (km/s): -1.03868579616041927e+01
Velocity Y (km/s): 7.95324528430304944e+00
Velocity Z (km/s): 3.66185765185608103e+00
2012 APR 27 00:00:20.000000 TDB
Position X (km): 4.64528786245005608e+08
Position Y (km): 5.41513285221757650e+08
Position Z (km): 2.20785208861782461e+08
Velocity X (km/s): -1.03868594401314791e+01
Velocity Y (km/s): 7.95324356146845002e+00
Velocity Z (km/s): 3.66185694939899253e+00
For most user applications, the high-level SPK APIs
cspice_spkezr
cspice_spkez
cspice_spkpos
cspice_spkezp
should be used instead of this routine.
The f2c'd routine spkpvn_ called by cspice_spkpvn is the most basic of
the SPK readers, the reader upon which spkezr_c and spkgeo_c, etc.
are built. cspice_spkpvn normally should not be called directly except in
cases where some optimization is required. (That is, where the
calling program has prior knowledge of the center-barycenter shifts
to be performed, or a non-standard method of determining the files
and segments to be used when computing states.)
This is the only reader that makes distinctions between the
various segment types in the SPK format. The complete list
of types currently supported is shown below.
Type Description
---- -------------------------
1 Modified Difference Array
2 Chebyshev (P)
3 Chebyshev (P,V)
5 Two body propagation between discrete states
8 Lagrange interpolation, equally spaced discrete states
9 Lagrange interpolation, unequally spaced discrete states
12 Hermite interpolation, equally spaced discrete states
13 Hermite interpolation, unequally spaced discrete states
14 Chebyshev Unequally spaced
15 Precessing Ellipse
17 Equinoctial Elements
18 ESOC/DDID Hermite/Lagrange Interpolation
19 ESOC/DDID Piecewise Interpolation
21 Extended Modified Difference Array
The maximum record lengths for each data type currently
supported are as follows:
Data type Maximum record length
--------- ---------------------
1 71
2 87
3 171
5 15
8 171
9 197
12 87
13 99
14 Variable
15 16
17 12
18 198
19 198
21 96
1) If the segment type is not supported by the current
version of cspice_spkpvn, the error SPICE(SPKTYPENOTSUPP)
is signaled by a routine in the call tree of this routine.
2) If any of the input arguments, `handle', `descr' or `et', is
undefined, an error is signaled by the IDL error handling
system.
3) If any of the input arguments, `handle', `descr' or `et', is
not of the expected type, or it does not have the expected
dimensions and size, an error is signaled by the Icy
interface.
4) If any of the output arguments, `ref', `state' or `center', is
not a named variable, an error is signaled by the Icy
interface.
See argument `handle'.
None.
SPK.REQ
None.
J. Diaz del Rio (ODC Space)
E.D. Wright (JPL)
-Icy Version 1.0.1, 09-AUG-2021 (JDR)
Edited header to comply with NAIF standard.
Added -Parameters, -Exceptions, -Files, -Restrictions,
-Literature_References and -Author_and_Institution sections.
Removed reference to the routine's corresponding CSPICE header from
-Abstract section.
Added arguments' type and size information in the -I/O section.
-Icy Version 1.0.0, 24-OCT-2012 (EDW)
position and velocity from ephemeris
SPK file position and velocity
|