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

Table of contents
Abstract
I/O
Parameters
Examples
Particulars
Exceptions
Files
Restrictions
Required_Reading
Literature_References
Author_and_Institution
Version
Index_Entries


Abstract


   CSPICE_SPKW02 writes a type 2 SPK segment to a SPK file.

I/O


   Given:

      handle   the DAF handle of an SPK file to which a type 2 segment is to be
               added.

               help, handle
                  LONG = Scalar

               The SPK file must be open for writing.

      body     the NAIF integer code for an ephemeris object whose state
               relative to another body is described by the segment to be
               created.

               help, body
                  LONG = Scalar

      center   the NAIF integer code for the center of motion of the object
               identified by `body'.

               help, center
                  LONG = Scalar

      frame    the NAIF name for a reference frame relative to which the state
               information for `body' is specified.

               help, frame
                  STRING = Scalar

      first,
      last     the start and stop times of the time interval over which the
               segment defines the state of body.

               help, first
                  DOUBLE = Scalar
               help, last
                  DOUBLE = Scalar

      segid    the segment identifier.

               help, segid
                  STRING = Scalar

               An SPK segment identifier may contain up to 40 characters.

      intlen   the length of time, in seconds, covered by each set of Chebyshev
               polynomial coefficients (each logical record).

               help, intlen
                  DOUBLE = Scalar

               Each set of Chebyshev coefficients must cover this fixed time
               interval, `intlen'.

      n        the number of sets of Chebyshev polynomial coefficients for
               coordinates (number of logical records) to be stored in the
               segment.

               help, n
                  LONG = Scalar

               There is one set of Chebyshev coefficients for each time
               period.

      polydg   the degree of each set of Chebyshev polynomials used to
               represent the ephemeris information.

               help, polydg
                  LONG = Scalar

               That is, the number of Chebyshev coefficients per coordinate
               minus one. `polydg' must not exceed MAXDEG (see -Parameters
               below).

      cdata    a time-ordered array of `n' sets of Chebyshev polynomial
               coefficients to be placed in the segment of the SPK file.

               help, cdata
                  DOUBLE = Array[n*SETSZ]

               Each set has size SETSZ = 3*(polydg+1). The coefficients are
               stored in `cdata' in order as follows:

                  the (polydg+1) coefficients for the first
                  coordinate of the first logical record,

                  the coefficients for the second coordinate,

                  the coefficients for the third coordinate,

                  the coefficients for the first coordinate for
                  the second logical record, ...

                  and so on.

      btime    the begin time (seconds past J2000 TDB) of first set of
               Chebyshev polynomial coefficients (first logical record).

               help, btime
                  DOUBLE = Scalar

               `first' is an appropriate value for `btime'.

   the call:

      cspice_spkw02, handle, body,   center, frame,  first,  last,           $
                     segid,  intlen, n,      polydg, cdata,  btime

   writes to the SPK file referred to by `handle' a type 02 SPK segment
   containing the data in `cdata'.

   See the -Particulars section for details about the structure of a
   type 02 SPK segment.

Parameters


   None.

Examples


   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) This example demonstrates how to create an SPK type 2 kernel
      containing only one segment, given a set of Chebyshev
      coefficients and their associated epochs.


      Example code begins here.


      PRO spkw02_ex1

         ;;
         ;; Define the segment identifier parameters.
         ;;
         BODY          = 3
         CENTER        = 10
         REF           = 'J2000'
         N_RECORDS     = 4
         SPK2          = "spkw02_ex1.bsp"
         CHBDEG        = 2

         ;;
         ;; A set of Chebyshev coefficients.
         ;;
         CHEBYCOEFFS02 = [1.0101d, 1.0102d, 1.0103d, $
                          1.0201d, 1.0202d, 1.0203d, $
                          1.0301d, 1.0302d, 1.0303d, $
                          2.0101d, 2.0102d, 2.0103d, $
                          2.0201d, 2.0202d, 2.0203d, $
                          2.0301d, 2.0302d, 2.0303d, $
                          3.0101d, 3.0102d, 3.0103d, $
                          3.0201d, 3.0202d, 3.0203d, $
                          3.0301d, 3.0302d, 3.0303d, $
                          4.0101d, 4.0102d, 4.0103d, $
                          4.0201d, 4.0202d, 4.0203d, $
                          4.0301d, 4.0302d, 4.0303d  $
                         ]

         ;;
         ;; A set of epochs.
         ;;
         DISCRETEEPOCHS = [ 100.d, 200.d, 300.d, 400.d, 500.d, $
                            600.d, 700.d, 800.d, 900.d         $
                          ]

         ;;
         ;; Create a segment identifier.
         ;;
         segid = 'SPK type 2 test segment'

         ;;
         ;; Open a new SPK file.
         ;;
         cspice_spkopn, SPK2, 'Type 2 SPK internal file name.', 4, handle

         ;;
         ;; Create a type 2 segment.
         ;;
         intlen = DISCRETEEPOCHS[1]-DISCRETEEPOCHS[0];

         cspice_spkw02, handle,                    $
                        BODY,                      $
                        CENTER,                    $
                        REF,                       $
                        DISCRETEEPOCHS[0],         $
                        DISCRETEEPOCHS[N_RECORDS], $
                        segid,                     $
                        intlen,                    $
                        N_RECORDS,                 $
                        CHBDEG,                    $
                        CHEBYCOEFFS02,             $
                        DISCRETEEPOCHS[0]

         ;;
         ;; Close the SPK file.
         ;;
         cspice_spkcls, handle

      END


      When this program is executed, no output is presented on
      screen. After run completion, a new SPK type 2 exists in
      the output directory.

Particulars


   This routine writes an SPK type 2 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.

   The ephemeris data supplied to the type 2 SPK writer is packed
   into an array as a sequence of records. The logical data records
   are stored contiguously:

      +----------+
      | Record 1 |
      +----------+
      | Record 2 |
      +----------+
          ...
      +----------+
      | Record N |
      +----------+

   The contents of an individual record are:

      +--------------------------------------+
      | Coeff set for X position component   |
      +--------------------------------------+
      | Coeff set for Y position component   |
      +--------------------------------------+
      | Coeff set for 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.

Exceptions


   1)  If the number of sets of coefficients is not positive, the
       error SPICE(NUMCOEFFSNOTPOS) is signaled by a routine in the
       call tree of this routine.

   2)  If the interval length is not positive, the error
       SPICE(INTLENNOTPOS) is signaled by a routine in the call tree
       of this routine.

   3)  If the name of the reference frame is not recognized, the
       error SPICE(INVALIDREFFRAME) is signaled by a routine in the
       call tree of this routine.

   4)  If segment stop time is not greater then the begin time, the
       error SPICE(BADDESCRTIMES) is signaled by a routine in the
       call tree of this routine.

   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 by a routine in the call tree of this routine. 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 by a
       routine in the call tree of this routine.

   7)  If the last non-blank character of `segid' occurs past index 40,
       or if `segid' contains any nonprintable characters, an error is
       signaled by a routine in the call tree of this routine.

   8)  If any of the input arguments, `handle', `body', `center',
       `frame', `first', `last', `segid', `intlen', `n', `polydg',
       `cdata' or `btime', is undefined, an error is signaled by the
       IDL error handling system.

   9)  If any of the input arguments, `handle', `body', `center',
       `frame', `first', `last', `segid', `intlen', `n', `polydg',
       `cdata' or `btime', is not of the expected type, or it does
       not have the expected dimensions and size, an error is
       signaled by the Icy interface.

Files


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

Restrictions


   None.

Required_Reading


   ICY.REQ
   SPK.REQ

Literature_References


   None.

Author_and_Institution


   J. Diaz del Rio     (ODC Space)
   E.D. Wright         (JPL)

Version


   -Icy Version 1.0.1, 27-AUG-2021 (JDR)

       Edited the header to comply with NAIF standard. Added example's
       problem statement.

       Extended "polydg" and "cdata" arguments description to provide the
       size of the Chebyshev polynomials sets.

       Added -Parameters, -Exceptions, -Files, -Restrictions,
       -Literature_References and -Author_and_Institution sections, and
       completed -Particulars section.

       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, 16-JUN-2003 (EDW)

Index_Entries


   write SPK type_2 data segment



Fri Dec 31 18:43:07 2021