Index Page
spkw20_c
A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X 

Procedure
Abstract
Required_Reading
Keywords
Brief_I/O
Detailed_Input
Detailed_Output
Parameters
Exceptions
Files
Particulars
Examples
Restrictions
Literature_References
Author_and_Institution
Version
Index_Entries

Procedure

   void spkw20_c  ( SpiceInt            handle,
                    SpiceInt            body,
                    SpiceInt            center,
                    ConstSpiceChar    * frame,
                    SpiceDouble         first,
                    SpiceDouble         last,
                    ConstSpiceChar    * segid,
                    SpiceDouble         intlen,
                    SpiceInt            n,
                    SpiceInt            polydg,
                    ConstSpiceDouble    cdata[],
                    SpiceDouble         dscale, 
                    SpiceDouble         tscale,
                    SpiceDouble         initjd,
                    SpiceDouble         initfr  )

Abstract

 
   Write a type 20 segment to an SPK file. 
 

Required_Reading

 
   DAF 
   NAIF_IDS 
   TIME 
   SPK 
 

Keywords

 
   EPHEMERIS 
 

Brief_I/O

 
 Variable  I/O  Description 
   --------  ---  -------------------------------------------------- 
   handle     I   Handle of SPK file open for writing. 
   body       I   NAIF code for ephemeris object. 
   center     I   NAIF code for the center of motion of the body. 
   frame      I   Reference frame name. 
   first      I   Start time of interval covered by segment. 
   last       I   End time of interval covered by segment. 
   segid      I   Segment identifier. 
   intlen     I   Length of time covered by logical record (days). 
   n          I   Number of logical records in segment. 
   polydg     I   Chebyshev polynomial degree. 
   cdata      I   Array of Chebyshev coefficients and positions. 
   dscale     I   Distance scale of data. 
   tscale     I   Time scale of data. 
   initjd     I   Integer part of begin time (TDB Julian date) of 
                  first record. 
   initfr     I   Fractional part of begin time (TDB Julian date) of 
                  first record. 
   MAXDEG     P   Maximum allowed degree of Chebyshev expansions. 
   DTOL       P   Absolute tolerance for coverage bound checking. 
   TOLSCL     P   Tolerance scale for coverage bound checking. 
 

Detailed_Input

 
   handle         is the DAF handle of an SPK file to which a type 20 
                  segment is to be added.  The SPK file must be open 
                  for writing. 
 
   body           is the NAIF integer code for an ephemeris object 
                  whose state relative to another body is described 
                  by the segment to be created. 
 
   center         is the NAIF integer code for the center of motion 
                  of the object identified by `body'. 
 
   frame          is the NAIF name for a reference frame relative to 
                  which the state information for `body' is specified. 
 
   first, 
   last           are the start and stop times of the time interval 
                  over which the segment defines the state of the 
                  object identified by `body'. 
 
   segid          is a segment identifier. An SPK segment identifier 
                  may contain up to 40 characters, not counting the
                  terminating null character. 
 
   intlen         is the length of time, in TDB Julian days, covered 
                  by each set of Chebyshev polynomial coefficients 
                  (each logical record). 
 
   n              is the number of number of logical records to be
                  stored in the segment. There is one logical record
                  for each time period. Each logical record contains
                  three sets of Chebyshev coefficients---one for each
                  coordinate---and three position vector components.
 
   polydg         is the degree of each set of Chebyshev 
                  polynomials, i.e. the number of Chebyshev 
                  coefficients per coordinate minus one. `polydg' must 
                  be less than or equal to the parameter MAXDEG. 
 
   cdata          is an array containing all the sets of Chebyshev 
                  polynomial coefficients and position components to 
                  be placed in the new segment of the SPK file. 
                  There are three sets of coefficients and position 
                  components for each time interval covered by the 
                  segment. 
 
                  The coefficients and position components are 
                  stored in `cdata' in order as follows: 
 
                     the (degree + 1) coefficients for the first 
                     coordinate of the first logical record, 
                     followed by the X component of position at the 
                     first interval midpoint. 
 
                     the coefficients for the second coordinate, 
                     followed by the Y component of position at the 
                     first interval midpoint. 
 
                     the coefficients for the third coordinate, 
                     followed by the Z component of position at the 
                     first interval midpoint. 
 
                     the coefficients for the first coordinate for 
                     the second logical record, followed by the X 
                     component of position at the second interval 
                     midpoint. 
 
                     and so on. 
 
                    
                  A diagram follows:

                     +--------------------------------------+
                     | Coeff set for X velocity component   |
                     +--------------------------------------+
                     | X position component                 |
                     +--------------------------------------+
                     | Coeff set for Y velocity component   |
                     +--------------------------------------+
                     | Y position component                 |
                     +--------------------------------------+
                     | Coeff set for Z velocity component   |
                     +--------------------------------------+
                     | Z position component                 |
                     +--------------------------------------+

                 Each coefficient set has the structure:

                     +--------------------------------------+
                     | Coefficient of T_0                   |
                     +--------------------------------------+
                     | Coefficient of T_1                   |
                     +--------------------------------------+
                                       ...
                     +--------------------------------------+
                     | Coefficient of T_POLYDG              |
                     +--------------------------------------+

                  Where T_n represents the Chebyshev polynomial
                  of the first kind of degree n.


   dscale,  
   tscale         are, respectively, the distance scale of the input 
                  position and velocity data in km, and the time 
                  scale of the input velocity data in TDB seconds. 
 
                  For example, if the input distance data have units
                  of astronomical units (AU), `dscale' should be set
                  to the number of km in one AU. If the input
                  velocity data have time units of Julian days, then
                  `tscale' should be set to the number of seconds per
                  Julian day (86400).
 
 
   initjd         is the integer part of the Julian ephemeris date of
                  initial epoch of the first record. `initjd' may be
                  less than, equal to, or greater than the initial
                  epoch.
 
   initfr         is the fractional part of the Julian ephemeris date
                  of initial epoch of the first record. `initfr' has
                  units of Julian days. `initfr' has magnitude strictly
                  less than 1 day. The sum
 
                     initjd + initfr  
 
                  equals the Julian ephemeris date of the initial 
                  epoch of the first record. 
 
 

Detailed_Output

 
   None. This routine writes data to an SPK file. 
 

Parameters

   The parameters listed below are not used directly in this
   routine; they are used by the underlying SPICELIB code that
   has been translated to C via f2c. 
 
   MAXDEG         is the maximum allowed degree of the input 
                  Chebyshev expansions. MAXDEG is declared in the 
                  SPICELIB Fortran INCLUDE file spk20.inc. 

                  The current value of MAXDEG is 50.
 

   TOLSCL         is a tolerance scale factor (also called a
                  "relative tolerance") used for time coverage
                  bound checking. TOLSCL is unitless. TOLSCL
                  produces a tolerance value via the formula

                     TOL = TOLSCL * MAX( ABS(FIRST), ABS(LAST) )

                  where FIRST and LAST are the coverage time bounds
                  of a type 20 segment, expressed as seconds past
                  J2000 TDB.

                  The resulting parameter TOL is used as a tolerance
                  for comparing the input segment descriptor time
                  bounds to the first and last epoch covered by the
                  sequence of time intervals defined by the inputs

                     initjd
                     initfr
                     intlen
                     n

                  See the Exceptions section below for a description
                  of the error check using this tolerance.
 
                  The current value of TOLSCL is 1e-13.
 

Exceptions

 
   1)  If the number of sets of coefficients is not positive 
       SPICE(INVALIDCOUNT) is signaled. 
 
   2)  If the interval length is not positive, SPICE(INTLENNOTPOS) 
       is signaled. 
 
   3)  If the name of the reference frame is not recognized, 
       SPICE(INVALIDREFFRAME) is signaled. 
 
   4)  If segment stop time is not greater then the begin time, 
       SPICE(BADDESCRTIMES) is signaled. 
 
   5)  If the start time of the first record exceeds the descriptor 
       begin time by more than a computed tolerance, or if the end 
       time of the last record precedes the descriptor end time by 
       more than a computed tolerance, the error SPICE(COVERAGEGAP) 
       is signaled. See the Parameters section above for a 
       description of the tolerance. 
 
   6)  If the input degree `polydg' is less than 0 or greater than 
       MAXDEG, the error SPICE(INVALIDDEGREE) is signaled. 
 
   7)  If the last non-blank character of `segid' occurs past index 
       40, or if `segid' contains any nonprintable characters, the 
       error will be diagnosed by a routine in the call tree of this 
       routine. 
 
   8)  If either the distance or time scale is non-positive, the
       error SPICE(NONPOSITIVESCALE) will be signaled.

   9)  The error SPICE(EMPTYSTRING) is signaled if any input string
       does not contain at least one character, since the input strings
       cannot be converted to a Fortran-style string in this case.
 
   10) The error SPICE(NULLPOINTER) is signaled if any input string
       pointer is null.

Files

 
   A new type 20 SPK segment is written to the SPK file attached 
   to `handle'. 
 

Particulars

 
   This routine writes an SPK type 20 data segment to the designated 
   SPK file, according to the format described in the SPK Required 
   Reading. 
 
   Each segment can contain data for only one target, central body, 
   and reference frame. The Chebyshev polynomial degree and length 
   of time covered by each logical record are also fixed. However, 
   an arbitrary number of logical records of Chebyshev polynomial 
   coefficients can be written in each segment.  Minimizing the 
   number of segments in an SPK file will help optimize how the 
   SPICE system accesses the file. 
 

Examples

 
   Suppose that you have in an array `cdata' sets of Chebyshev
   polynomial coefficients and position vectors representing the state
   of the moon (NAIF ID = 301), relative to the Earth-moon barycenter
   (NAIF ID = 3), in the J2000 reference frame, and you want to put
   these into a type 20 segment in an existing SPK file. The following
   code could be used to add one new type 20 segment. To add multiple
   segments, put the call to spkw20_c in a loop.
 
      #include "SpiceUsr.h"
           .
           .
           .
           
      /.
      First open the SPK file and get a handle for it. 
      ./
      spkopa_c ( spknam, &handle ); 

      /.
      Create a segment identifier. 
      ./
      segid = "MY_SAMPLE_SPK_TYPE_20_SEGMENT";

      /.    
      Note that the interval length `intlen' has units 
      of Julian days. The start time of the first record 
      is expressed using two inputs: integer and fractional 
      portions of the Julian ephemeris date of the start  
      time. 
  
      Write the segment.  
      ./
      spkw20_c ( handle, 301,    3,      "J2000", 
                 first,  last,   segid,  intlen, 
                 n,      polydg, cdata,  dscale, 
                 tscale, initjd, initfr          );
 
      /.
      Close the file. 
      ./
      spkcls_c ( handle );
 

Restrictions

 
   None. 
 

Literature_References

 
   None. 
 

Author_and_Institution

 
   N.J. Bachman (JPL) 
 

Version

 
   -CSPICE Version 1.0.0, 23-DEC-2013 (NJB)

Index_Entries

 
   write spk type_20 data segment 
 

Link to routine spkw20_c source file spkw20_c.c

Wed Apr  5 17:54:44 2017