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

Abstract
I/O
Examples
Particulars
Required Reading
Version
Index_Entries

Abstract


   CSPICE_CKW02 adds a type 2 segment to a C-kernel.

I/O


   Given:

      handle   file handle for an open CK file, returned from cspice_ckopn.

               [1,1] = size(handle); int32 = class(handle)

      begtim   encoded SCLK segment begin time.

               [1,1] = size(begtim); double = class(begtim)

      endtim   encoded SCLK segment end time.

               [1,1] = size(endtim); double = class(endtim)

      inst     NAIF instrument ID code.

               [1,1] = size(inst); int32 = class(inst)

      ref      name of the reference frame for the segment.

               [1,c1] = size(ref); char = class(ref)

                  or

               [1,1] = size(ref); cell = class(ref)

      segid    name to identify the segment.

               [1,c2] = size(segid); char = class(segid)

                  or

               [1,1] = size(segid); cell = class(segid)

      start    an array containing encoded SCLK interval start times.

               [n,1] = size(start); double = class(start)

      stop     an array containing the encoded SCLK interval stop times.

               [n,1] = size(stop); double = class(stop)

      quats    array of SPICE style quaternions representing instrument
               pointing.

               [4,n] = size(quats); double = class(quats)

      avvs     array of angular velocity vectors in units of radians per
               second.

               [3,n] = size(avvs); double = class(avvs)

      rates    the number of seconds per tick for each interval.

               [n,1] = size(rates); double = class(rates)

   the call:

      cspice_ckw02( handle,  ...
                    begtime, ...
                    endtime, ...
                    inst,    ...
                    ref,     ...
                    segid,   ...
                    start,   ...
                    stop,    ...
                    quats,   ...
                    avvs,    ...
                    rates )

   returns:

      Adds a type 2 segment to a CK.

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.

      %
      % Create a CK type 2 segment; fill with data for a simple time
      % dependent rotation and angular velocity.
      %

      %
      % Define needed parameters
      %
      CK2        = 'type2.bc';
      INST       = -77702;
      MAXREC     = 21;
      SECPERTICK = 0.001;
      IFNAME     = 'Test CK type 2 segment created by cspice_ckw02';
      SEGID      = 'Test type 2 CK segment';

      %
      % '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 = 0;

      %
      % The base reference from for the rotation data.
      %
      REF = 'J2000';

      %
      % Time spacing in encoded ticks.
      %
      SPACING_TICKS = 10.;

      %
      % Time spacing in seconds
      %
      SPACING_SECS = SPACING_TICKS * SECPERTICK;

      %
      % Declare an angular rate in radians per sec.
      %
      RATE = 1.d-2;

      %
      % Create a 4xMAXREC matrix for quaternions, and a
      % 3xMAXREC for expavs.
      %
      quats = zeros( [4, MAXREC] );
      av    = zeros( [3, MAXREC] );

      %
      % Create a 3x3 double precision identity matrix.
      %
      work_mat = eye( 3 );

      %
      % Convert the 'work_mat' to quaternions.
      %
      work_quat = cspice_m2q( work_mat);

      %
      % Copy the work quaternions to the first row of
      % 'quats'.
      %
      quats(:,1) = work_quat;

      %
      % Create an angular velocity vector. Copy to the third (Z) row
      % of 'av'. This vector is in the 'REF' reference frame and
      % indicates a constant rotation about the Z axis.
      %
      av(3,:) = RATE;

      %
      % Create arrays of interval start and stop times.  The interval
      % associated with each quaternion will start at the epoch of
      % the quaternion and will extend 0.8 * SPACING_TICKS forward in time,
      % leaving small gaps between the intervals.
      %
      % Fill in the clock rates array with a constant 'SECPERTICK' for
      % all values.
      %
      rates  = zeros( [MAXREC,1] ) + SECPERTICK;

      %
      % Create an array of encoded tick values in increments of
      % 'SPACING_TICKS' with an initial value of 1000 ticks.
      %
      sclkdp = [0:MAXREC-1]' * SPACING_TICKS + 1000;

      starts = sclkdp;
      stops  = sclkdp + ( 0.8 * SPACING_TICKS );

      %
      % Fill the rest of the av and quats matrices
      % with simple data.
      %
      for i = 2:MAXREC

         %
         % Create the transformation matrix for a rotation of 'theta'
         % about the Z axis. Calculate 'theta' from the constant
         % angular rate 'RATE' at increments of 'SPACING_SECS'.
         %
         theta    = (i-1) * RATE * SPACING_SECS;
         work_mat = cspice_rotmat( work_mat, theta, 3 );

         %
         % Convert the 'work_mat' matrix to SPICE type quaternions.
         %
         work_quat = cspice_m2q( work_mat );

         %
         % Store the quaternions in the 'quat' matrix.
         %
         quats(:,i) = work_quat;

      end

      %
      % Set the segment boundaries equal to the first and last
      % time in the segment.
      %
      begtime = starts(1);
      endtime = stops(MAXREC);

      %
      % All information ready to write. Write to a CK type 2 segment
      % to the file indicated by 'handle'.
      %
      try
         handle = cspice_ckopn( CK2, IFNAME, NCOMCH );
         cspice_ckw02(  handle,  ...
                        begtime, ...
                        endtime, ...
                        INST,    ...
                        REF,     ...
                        SEGID,   ...
                        starts,  ...
                        stops,   ...
                        quats,   ...
                        av,      ...
                        rates )
      catch
         error( [ 'Failure: ' lasterr] )
      end

      %
      % SAFELY close the file.
      %
      cspice_ckcls( handle )

   MATLAB outputs:

      The example code creates a CK with one type 2 segment.

Particulars


   None.

Required Reading


   For important details concerning this module's function, please refer to
   the CSPICE routine ckw02_c.

   MICE.REQ
   CK.REQ
   DAF.REQ
   SCLK.REQ

Version


   -Mice Version 1.0.3, 29-OCT-2014, EDW (JPL)

       Edited I/O section to conform to NAIF standard for Mice documentation.

   -Mice Version 1.0.2, 11-JUN-2013, EDW (JPL)

       I/O descriptions edits to conform to Mice documentation format.

   -Mice Version 1.0.1, 30-DEC-2008, EDW (JPL)

      Corrected misspellings.

   -Mice Version 1.0.0, 04-JAN-2008, EDW (JPL)

Index_Entries


   write ck type_2 pointing data segment


Wed Apr  5 18:00:30 2017