SPKW15 ( SPK, write a type 15 segment )
SUBROUTINE SPKW15 ( HANDLE, BODY, CENTER, FRAME, FIRST, LAST,
. SEGID, EPOCH, TP, PA, P, ECC,
. J2FLG, PV, GM, J2, RADIUS )
Write an SPK segment of type 15 given a type 15 data record.
SPK
EPHEMERIS
INTEGER HANDLE
INTEGER BODY
INTEGER CENTER
CHARACTER*(*) FRAME
DOUBLE PRECISION FIRST
DOUBLE PRECISION LAST
CHARACTER*(*) SEGID
DOUBLE PRECISION EPOCH
DOUBLE PRECISION TP ( 3 )
DOUBLE PRECISION PA ( 3 )
DOUBLE PRECISION P
DOUBLE PRECISION ECC
DOUBLE PRECISION J2FLG
DOUBLE PRECISION PV ( 3 )
DOUBLE PRECISION GM
DOUBLE PRECISION J2
DOUBLE PRECISION RADIUS
Variable I/O Description
-------- --- --------------------------------------------------
HANDLE I Handle of an SPK file open for writing.
BODY I Body code for ephemeris object.
CENTER I Body code for the center of motion of the body.
FRAME I The reference frame of the states.
FIRST I First valid time for which states can be computed.
LAST I Last valid time for which states can be computed.
SEGID I Segment identifier.
EPOCH I Epoch of the periapse.
TP I Trajectory pole vector.
PA I Periapsis vector.
P I Semi-latus rectum.
ECC I Eccentricity.
J2FLG I J2 processing flag.
PV I Central body pole vector.
GM I Central body GM.
J2 I Central body J2.
RADIUS I Equatorial radius of central body.
HANDLE is the file handle of an SPK file that has been
opened for writing.
BODY is the NAIF ID for the body whose states are
to be recorded in an SPK file.
CENTER is the NAIF ID for the center of motion associated
with BODY.
FRAME is the reference frame that states are referenced to,
for example 'J2000'.
FIRST are the bounds on the ephemeris times, expressed as
LAST seconds past J2000.
SEGID is the segment identifier. An SPK segment identifier
may contain up to 40 characters.
EPOCH is the epoch of the orbit elements at periapse
in ephemeris seconds past J2000.
TP is a unit vector parallel to the angular momentum
vector of the orbit at epoch expressed relative to
FRAME.
PA is a unit vector parallel to the position vector
of the trajectory at periapsis of EPOCH expressed
relative to FRAME.
P is the semi-latus rectum--- p in the equation:
r = p/(1 + ECC*COS(Nu))
ECC is the eccentricity.
J2FLG is the J2 processing flag describing what J2
corrections are to be applied when the orbit is
propagated.
All J2 corrections are applied if the value of J2FLG
is not 1, 2 or 3.
If the value of the flag is 3 no corrections are
done.
If the value of the flag is 1 no corrections are
computed for the precession of the line of apsides.
However, regression of the line of nodes is
performed.
If the value of the flag is 2 no corrections are
done for the regression of the line of nodes.
However, precession of the line of apsides is
performed.
Note that J2 effects are computed only if the orbit
is elliptic and does not intersect the central body.
PV is a unit vector parallel to the north pole vector
of the central body expressed relative to FRAME.
GM is the central body GM.
J2 is the central body J2 (dimensionless).
RADIUS is the equatorial radius of the central body.
Units are radians, km, seconds.
None. A type 15 segment is written to the file attached
to HANDLE.
None.
1) If the eccentricity is less than zero, the error
'SPICE(BADECCENTRICITY)' will be signalled.
2) If the semi-latus rectum is 0, the error
'SPICE(BADLATUSRECTUM)' is signalled.
3) If the pole vector, trajectory pole vector or periapsis vector
have zero length, the error 'SPICE(BADVECTOR)' is signalled.
4) If the trajectory pole vector and the periapsis vector are
not orthogonal, the error 'SPICE(BADINITSTATE)' is signalled.
The test for orthogonality is very crude. The routine simply
checks that the dot product of the unit vectors parallel
to the trajectory pole and periapse vectors is less than
0.00001. This check is intended to catch blunders, not to
enforce orthogonality to double precision capacity.
5) If the mass of the central body is non-positive, the error
'SPICE(NONPOSITIVEMASS)' is signalled.
6) If the radius of the central body is negative, the error
'SPICE(BADRADIUS)' is signalled.
7) If the segment identifier has more than 40 non-blank characters
the error 'SPICE(SEGIDTOOLONG)' is signalled.
8) If the segment identifier contains non-printing characters
the error 'SPICE(NONPRINTABLECHARS)' is signalled.
9) If there are inconsistencies in the BODY, CENTER, FRAME or
FIRST and LAST times, the problem will be diagnosed by
a routine in the call tree of this routine.
A new type 15 SPK segment is written to the SPK file attached
to HANDLE.
This routine writes an SPK type 15 data segment to the open SPK
file according to the format described in the type 15 section of
the SPK Required Reading. The SPK file must have been opened with
write access.
This routine is provided to provide direct support for the MASL
precessing orbit formulation.
Suppose that at time EPOCH you have the J2000 periapsis
state of some object relative to some central body and would
like to create a type 15 SPK segment to model the motion of
the object using simple regression and precession of the
line of nodes and apsides. The following code fragment
illustrates how you can prepare such a segment. We shall
assume that you have in hand the J2000 direction of the
central body's pole vector, its GM, J2 and equatorial
radius. In addition we assume that you have opened an SPK
file for write access and that it is attached to HANDLE.
(If your state is at an epoch other than periapse the
fragment below will NOT produce a "correct" type 15 segment
for modelling the motion of your object.)
C
C First we get the osculating elements.
C
CALL OSCELT ( STATE, EPOCH, GM, ELTS )
C
C From these collect the eccentricity and semi-latus rectum.
C
ECC = ELTS ( 2 )
P = ELTS ( 1 ) * ( 1.0D0 + ECC )
C
C Next get the trajectory pole vector and the
C periapsis vector.
C
CALL UCRSS ( STATE(1), STATE(4), TP )
CALL VHAT ( STATE(1), PA )
C
C Enable both J2 corrections.
C
J2FLG = 0.0D0
C
C Now add the segment.
C
CALL SPKW15 ( HANDLE, BODY, CENTER, FRAME, FIRST, LAST,
. SEGID, EPOCH, TP, PA, P, ECC,
. J2FLG, PV, GM, J2, RADIUS )
None.
None.
W.L. Taber (JPL)
SPICELIB Version 1.0.0, 28-NOV-1994 (WLT)
|