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_spkopa

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


Abstract


   CSPICE_SPKOPA opens an existing SPK file for subsequent write.

I/O


   Given:

      file     the name of an existing SPK file to which you wish to append
               additional SPK segments.

               help, file
                  STRING = Scalar

   the call:

      cspice_spkopa, file, handle

   returns:

      handle   the DAF integer handle that refers to the SPK file opened for
               appending.

               help, handle
                  LONG = Scalar

               `handle' is required by any of the SPK writing routines.

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 add a new segment to an
      SPK type 5 kernel.

      For this example, we will first create an SPK type 5 kernel
      containing only one segment, given a time-ordered set of
      discrete states and epochs, and the gravitational parameter
      of a central body.

      Then, we will reopen the SPK and add a second segment. The
      example below shows one set of calls that you could perform
      to make the addition. Obviously, there is no need to close
      and re-open the file in order to add multiple segments. It is
      done in this example to demonstrate the use of cspice_spkopa.

      Note that you could add segments of other data types by
      replacing the call to cspice_spkw05 with a suitably modified call to
      another SPK writing routine.


      Example code begins here.


      PRO spkopa_ex1

         ;;
         ;; Define the segment identifier parameters.
         ;;
         SPK5   =   'spkopa_ex1.bsp'
         REF    =   'J2000'
         GMSUN  =   132712440023.31D0
         BODY   =   3L
         CENTER =   10L
         NSTATS =   9L

         ;;
         ;; Define the states and epochs.
         ;;
         states = [ [ 101.D0, 201.D0, 301.D0, 401.D0, 501.D0, 601.D0 ],      $
                    [ 102.D0, 202.D0, 302.D0, 402.D0, 502.D0, 602.D0 ],      $
                    [ 103.D0, 203.D0, 303.D0, 403.D0, 503.D0, 603.D0 ],      $
                    [ 104.D0, 204.D0, 304.D0, 404.D0, 504.D0, 604.D0 ],      $
                    [ 105.D0, 205.D0, 305.D0, 405.D0, 505.D0, 605.D0 ],      $
                    [ 106.D0, 206.D0, 306.D0, 406.D0, 506.D0, 606.D0 ],      $
                    [ 107.D0, 207.D0, 307.D0, 407.D0, 507.D0, 607.D0 ],      $
                    [ 108.D0, 208.D0, 308.D0, 408.D0, 508.D0, 608.D0 ],      $
                    [ 109.D0, 209.D0, 309.D0, 409.D0, 509.D0, 609.D0 ] ]

         epoch1 = [ 100.D0, 200.D0, 300.D0,                                  $
                    400.D0, 500.D0, 600.D0,                                  $
                    700.D0, 800.D0, 900.D0 ]

         epoch2 = [ 1100.D0, 1200.D0, 1300.D0,                               $
                    1400.D0, 1500.D0, 1600.D0,                               $
                    1700.D0, 1800.D0, 1900.D0 ]

         ;;
         ;; Set the start and stop times of interval covered by
         ;; the first segment.
         ;;
         first  = epoch1[0]
         last   = epoch1[NSTATS-1]

         ;;
         ;; `ncomch' is the number of characters to reserve for the
         ;; kernel's comment area. This example doesn't write
         ;; comments, so set to zero.
         ;;
         ncomch = 0L

         ;;
         ;; Internal file name and segment ID.
         ;;
         ifname = 'Type 5 SPK internal file name.'
         segid  = 'SPK type 5 test segment #1'

         ;;
         ;; Open a new SPK file.
         ;;
         cspice_spkopn, SPK5, ifname, ncomch, handle

         ;;
         ;; Write the segment.
         ;;
         cspice_spkw05, handle, BODY,  CENTER, REF,    first, last,          $
                        segid,  GMSUN, NSTATS, states, epoch1

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

         ;;
         ;; At this point we have an existing SPK type 5 kernel
         ;; that contains a single segment. Let's now demonstrate
         ;; the use of cspice_spkopa.
         ;;
         ;; Open the an existing SPK file for subsequent write.
         ;;
         cspice_spkopa, SPK5, handle

         ;;
         ;; Set the start and stop times of interval covered by
         ;; the second segment, and the segment ID.
         ;;
         first  = epoch2[0]
         last   = epoch2[NSTATS-1]

         segid  = 'SPK type 5 test segment #2'

         ;;
         ;; Now write the second segment. Use the same set of
         ;; states time-ordered set of discrete states and the
         ;; gravitational parameter. Set the epochs to be `epoch2'.
         ;;
         cspice_spkw05, handle, BODY,  CENTER, REF,    first, last,          $
                        segid,  GMSUN, NSTATS, states, epoch2

         ;;
         ;; Finally, close the file.
         ;;
         cspice_spkcls, handle

      END


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

Particulars


   This file provides an interface for opening existing SPK
   files for the addition of SPK segments. If you need
   to open an new SPK file for writing, call the routine cspice_spkopn.

Exceptions


   If any of the following exceptions occur, `handle' will be returned
   with the value 0.

   1)  If the file specified does not exist, the error
       SPICE(FILENOTFOUND) is signaled by a routine in the call tree
       of this routine.

   2)  If the file specified is not an SPK file, the error
       SPICE(FILEISNOTSPK) is signaled by a routine in the call tree
       of this routine.

   3)  If the file specified is not an SPK file, the error
       SPICE(FILEISNOTSPK) is signaled by a routine in the call tree
       of this routine.

   4)  If the specified SPK file cannot be opened for writing, an
       error is signaled by a routine in the call tree of this
       routine.

   5)  If the specified SPK file uses a non-native binary file
       format, an error is signaled by a routine in the call tree of
       this routine.

   6)  If the specified SPK file is corrupted or otherwise invalid,
       an error is signaled by a routine in the call tree of this
       routine.

   7)  If the input argument `file' is undefined, an error is
       signaled by the IDL error handling system.

   8)  If the input argument `file' is not of the expected type, or
       it does not have the expected dimensions and size, an error is
       signaled by the Icy interface.

   9)  If the output argument `handle' is not a named variable, an
       error is signaled by the Icy interface.

Files


   None.

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.2, 10-AUG-2021 (JDR)

       Edited the header to comply with NAIF standard. Added complete
       code example.

       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.1, 09-DEC-2005 (EDW)

       Added -Examples section.

   -Icy Version 1.0.0, 16-JUN-2003 (EDW)

Index_Entries


   Open an existing SPK file for adding segments



Fri Dec 31 18:43:07 2021