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
ckr04

Table of contents
Procedure
Abstract
Required_Reading
Keywords
Declarations
Brief_I/O
Detailed_Input
Detailed_Output
Parameters
Exceptions
Files
Particulars
Examples
Restrictions
Literature_References
Author_and_Institution
Version

Procedure

     CKR04 ( C-kernel, read pointing record, data type 4 )

     SUBROUTINE CKR04 ( HANDLE, DESCR, SCLKDP, TOL, NEEDAV,
    .                   RECORD, FOUND )

Abstract

     Read a single data record from a type 4 CK segment.

Required_Reading

     CK
     DAF

Keywords

     POINTING

Declarations

     IMPLICIT NONE

     INCLUDE               'ckparam.inc'

     INTEGER               HANDLE
     DOUBLE PRECISION      DESCR  ( * )
     DOUBLE PRECISION      SCLKDP
     DOUBLE PRECISION      TOL
     LOGICAL               NEEDAV
     DOUBLE PRECISION      RECORD ( * )
     LOGICAL               FOUND

Brief_I/O

     VARIABLE  I/O  DESCRIPTION
     --------  ---  --------------------------------------------------
     HANDLE     I   File handle.
     DESCR      I   Segment descriptor.
     SCLKDP     I   Pointing request time.
     TOL        I   Time tolerance.
     NEEDAV     I   Angular velocity request flag.
     RECORD     O   Pointing data record.
     FOUND      O   .TRUE. when a record covering SCLKDP is found.

Detailed_Input

     HANDLE   is the integer handle of the CK file containing the
              segment.

     DESCR    is the descriptor of the segment.

     SCLKDP   is the encoded spacecraft clock time for which
              pointing is being requested.

     TOL      is a time tolerance, measured in the same units as
              encoded spacecraft clock.

              When SCLKDP falls within the bounds of one of the
              interpolation intervals then the tolerance has no
              effect because pointing will be returned at the
              request time.

              However, if the request time is not in one of the
              intervals, then the tolerance is used to determine
              if pointing at one of the interval endpoints should
              be returned.

     NEEDAV   is .TRUE. if angular velocity is requested.

Detailed_Output

     RECORD   is the record that CKE04 will evaluate to determine
              the pointing and it includes parameters:

              ---------------------------------------------------
              |    Encoded onboard time which is the closest    |
              |  to SCLKDP and belongs to one of approximation  |
              |                   intervals                     |
              ---------------------------------------------------
              |       encoded SCLK time of the midpoint of      |
              |             interpolation interval              |
              ---------------------------------------------------
              |          radii of interpolation interval        |
              |    expressed as double precision SCLK ticks     |
              ---------------------------------------------------
              |         Number of coefficients for q0           |
              ---------------------------------------------------
              |         Number of coefficients for q1           |
              ---------------------------------------------------
              |         Number of coefficients for q2           |
              ---------------------------------------------------
              |         Number of coefficients for q3           |
              ---------------------------------------------------
              |         Number of coefficients for AV1          |
              ---------------------------------------------------
              |         Number of coefficients for AV2          |
              ---------------------------------------------------
              |         Number of coefficients for AV3          |
              ---------------------------------------------------
              |               q0 Cheby coefficients             |
              ---------------------------------------------------
              |               q1 Cheby coefficients             |
              ---------------------------------------------------
              |               q2 Cheby coefficients             |
              ---------------------------------------------------
              |               q3 Cheby coefficients             |
              ---------------------------------------------------
              |         AV1 Cheby coefficients (optional)       |
              ---------------------------------------------------
              |         AV2 Cheby coefficients (optional)       |
              ---------------------------------------------------
              |         AV3 Cheby coefficients (optional)       |
              ---------------------------------------------------

     FOUND    is .TRUE. if a record was found to satisfy the pointing
              request. This occurs when the time for which pointing
              is requested falls inside one of the interpolation
              intervals, or when the request time is within the
              tolerance of an interval endpoint.

Parameters

     See 'ckparam.inc'.

Exceptions

     1)  If the specified handle does not belong to an open DAF file,
         an error is signaled by a routine in the call tree of this
         routine.

     2)  If the specified descriptor does not belong to a segment data
         format organized in accordance with generic segment
         architecture, an error is signaled by a routine in the call
         tree of this routine.

     3)  If DESCR is not a valid descriptor of a segment in the CK
         file specified by HANDLE, the results of this routine are
         unpredictable.

     4)  If the segment is not of data type 4, as specified in the
         third integer component of the segment descriptor,
         the error SPICE(WRONGDATATYPE) is signaled.

     5)  If angular velocity data was requested but the segment
         contains no such data, the error SPICE(NOAVDATA) is
         signaled.

Files

     See argument HANDLE.

Particulars

     See the CK Required Reading file for a detailed description of
     the structure of a type 4 pointing segment.

     When the time for which pointing was requested falls within an
     interpolation interval, then FOUND will be true and RECORD will
     contain the set of Chebyshev polynomial coefficients for the
     time interval that brackets the request time. CKE04 will
     evaluate RECORD to give pointing at the request time.

     However, when the request time is not within any of the
     interpolation intervals, then FOUND will be true only if the
     interval endpoint closest to the request time is within the
     tolerance specified by the user. In this case RECORD will
     contain the set of Chebyshev polynomial coefficients for the
     time interval one of the ends of which was within tolerance
     from the request time, and CKE04 will evaluate RECORD to give
     pointing at the time associated with that interval end time.

Examples

     The CKRnn routines are usually used in tandem with the CKEnn
     routines, which evaluate the record returned by CKRnn to give
     the pointing information and output time.

     The following code fragment searches backwards through all of the
     segments in a file applicable to the Mars Global Surveyor
     spacecraft bus that are of data type 4, for a particular
     spacecraft clock time. It then evaluates the pointing for that
     epoch and prints the result.

     The search performed here does not mimic the behavior of the CK
     reader APIs CKGP and CKGPAV, which consider data from multiple CK
     files, when available. See the CK Required reading for details.

     C
     C     CK parameters include file.
     C
           INCLUDE               'ckparam.inc'

     C
     C     Local variables
     C
           CHARACTER*(20)        SCLKCH
           CHARACTER*(20)        SCTIME
           CHARACTER*(40)        IDENT

           DOUBLE PRECISION      AV     ( 3 )
           DOUBLE PRECISION      CLKOUT
           DOUBLE PRECISION      CMAT   ( 3, 3 )
           DOUBLE PRECISION      DCD    ( 2 )
           DOUBLE PRECISION      DESCR  ( 5 )
           DOUBLE PRECISION      RECORD ( CK4RSZ )
           DOUBLE PRECISION      SCLKDP
           DOUBLE PRECISION      TOL

           INTEGER               HANDLE
           INTEGER               I
           INTEGER               ICD    ( 6 )
           INTEGER               INST
           INTEGER               SC

           LOGICAL               FND
           LOGICAL               NEEDAV
           LOGICAL               SFND

     C
     C     Initial values.
     C
           SC     = -94
           INST   = -94000
           NEEDAV = .FALSE.

     C
     C     Load the MGS SCLK kernel and the C-kernel.
     C
           CALL FURNSH( 'MGS_SCLK.TSC' )
           CALL DAFOPR( 'MGS_CK4.BC', HANDLE )

     C
     C     Get the spacecraft clock time. Then encode it for use
     C     in the C-kernel.
     C
           CALL PROMPT( 'Enter SCLK string: ', SCLKCH )
           CALL SCENCD( SC, SCLKCH, SCLKDP )

     C
     C     Use a tolerance of 2 seconds (half of the nominal
     C     separation between MGS pointing instances ).
     C
           CALL SCTIKS ( SC, '0000000002:000', TOL )

     C
     C     Search backwards from the end of the CK file through all
     C     of the segments.
     C
           CALL DAFBBS( HANDLE )
           CALL DAFFPA( SFND   )

           FND = .FALSE.

           DO WHILE ( ( SFND ) .AND. ( .NOT. FND ) )

     C
     C        Get the segment identifier and descriptor.
     C
              CALL DAFGN( IDENT )
              CALL DAFGS( DESCR )

     C
     C        Unpack the segment descriptor into its integer and
     C        double precision components.
     C
              CALL DAFUS( DESCR, 2, 6, DCD, ICD )

     C
     C        Determine if this segment should be processed.
     C
              IF ( ( INST          .EQ. ICD( 1 ) ) .AND.
          .        ( SCLKDP + TOL  .GE. DCD( 1 ) ) .AND.
          .        ( SCLKDP - TOL  .LE. DCD( 2 ) ) .AND.
          .        ( CK4DTP        .EQ. ICD( 3 ) )      ) THEN

     C
     C           Find CK 4 record covering requested time.
     C
                 CALL CKR04( HANDLE, DESCR, SCLKDP, TOL, NEEDAV,
          .                  RECORD, FND )

                 IF ( FND ) THEN

     C
     C              Compute pointing using found CK 4 record.
     C
                    CALL CKE04( NEEDAV, RECORD, CMAT, AV, CLKOUT)

                    CALL SCDECD( SC, CLKOUT, SCTIME )

                    WRITE (*,*)
                    WRITE (*,*) 'Segment identifier: ', IDENT
                    WRITE (*,*)
                    WRITE (*,*) 'Pointing returned for time: ',
          .                      SCTIME
                    WRITE (*,*)
                    WRITE (*,*) 'C-matrix:'
                    WRITE (*,*)
                    WRITE (*,*) ( CMAT(1,I), I = 1, 3 )
                    WRITE (*,*) ( CMAT(2,I), I = 1, 3 )
                    WRITE (*,*) ( CMAT(3,I), I = 1, 3 )
                    WRITE (*,*)

                 END IF

              END IF

              CALL DAFFPA ( SFND )

           END DO

Restrictions

     1)  The file containing the segment should be opened for read
         or write access either by CKLPF, DAFOPR, or DAFOPW.

     2)  The record returned by this routine is intended to be
         evaluated by CKE04.

Literature_References

     None.

Author_and_Institution

     N.J. Bachman       (JPL)
     J. Diaz del Rio    (ODC Space)
     B.V. Semenov       (JPL)
     E.D. Wright        (JPL)
     Y.K. Zaiko         (JPL)

Version

    SPICELIB Version 1.0.3, 17-AUG-2021 (NJB) (JDR)

        Updated code example to use backwards search. Added
        note regarding difference between this search and those
        performed by the CK reader APIs CKGP and CKGPAV.

        Edited the header to comply with NAIF standard.

    SPICELIB Version 1.0.2, 18-APR-2014 (BVS)

        Minor header edits.

    SPICELIB Version 1.0.1, 22-AUG-2006 (EDW)

        Replaced references to LDPOOL with references
        to FURNSH.

    SPICELIB Version 1.0.0, 05-MAY-1999 (YKZ) (BVS)
Fri Dec 31 18:36:03 2021