Table of contents
ckcls_c ( CK, Close file )
void ckcls_c ( SpiceInt handle )
Close an open CK file.
VARIABLE I/O DESCRIPTION
-------- --- --------------------------------------------------
handle I Handle of the CK file to be closed.
handle is the handle of the CK file that is to be closed.
1) If there are no segments in the file, the error
SPICE(NOSEGMENTSFOUND) is signaled by a routine in the call tree of
Close the CK file attached to handle.
The numerical results shown for this example may differ across
platforms. The results depend on the SPICE kernels used as
input, the compiler and supporting libraries, and the machine
specific arithmetic implementation.
1) Create a CK type 3 segment; fill with data for a simple time
dependent rotation and angular velocity, and reserve room in
the CK comments area for 5000 characters.
Example code begins here.
int main( )
#define CK3 "ckcls_ex1.bc"
#define SPTICK 0.001
#define INST -77703
#define MAXREC 201
SpiceChar * ref;
SpiceChar * ifname;
SpiceChar * segid;
SpiceDouble avvs [MAXREC];
SpiceDouble quats [MAXREC];
SpiceDouble rwmat ;
SpiceDouble sclkdp [MAXREC];
SpiceDouble starts [MAXREC/2];
SpiceDouble wmat ;
SpiceDouble wquat ;
`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 and in seconds
sticks = 10.0;
spaces = sticks * SPTICK;
Declare an angular rate in radians per sec.
rate = 1.e-2;
Internal file name and segment ID.
segid = "Test type 3 CK segment";
ifname = "Test CK type 3 segment created by ckw03_c";
Open a new kernel.
ckopn_c ( CK3, ifname, ncomch, &handle );
Create a 3x3 double precision identity matrix.
ident_c ( wmat );
Convert the matrix to quaternion.
m2q_c ( wmat, wquat );
Copy the work quaternion to the first row of
moved_c ( wquat, 4, quats );
Create an angular velocity vector. This vector is in the
`ref' reference frame and indicates a constant rotation
about the Z axis.
vpack_c ( 0.0, 0.0, rate, avvs );
Set the initial value of the encoded ticks.
sclkdp = 1000.0;
Fill the rest of the `avvs' and `quats' matrices
with simple data.
for ( i = 1; i < MAXREC; i++ )
Create the corresponding encoded tick value in
increments of `sticks' with an initial value of
sclkdp[i] = 1000.0 + i * sticks;
Create the transformation matrix for a rotation of
`theta' about the Z axis. Calculate `theta' from the
constant angular rate `rate' at increments of `spaces'.
theta = i * rate * spaces;
rotmat_c ( wmat, theta, 3, rwmat );
Convert the `rwmat' matrix to SPICE type quaternion.
m2q_c ( rwmat, wquat );
Store the quaternion in the `quats' matrix.
Store angular velocity in `avvs'.
moved_c ( wquat, 4, quats[i] );
vpack_c ( 0.0, 0.0, rate, avvs[i] );
Create an array start times for the interpolation
intervals. The end time for a particular interval is
determined as the time of the final data value prior in
time to the next start time.
nints = MAXREC/2;
for ( i = 0; i < nints; i++ )
starts[i] = sclkdp[i*2];
Set the segment boundaries equal to the first and last
time for the data arrays.
begtim = sclkdp;
endtim = sclkdp[MAXREC-1];
This segment contains angular velocity.
avflag = SPICETRUE;
All information ready to write. Write to a CK type 3
segment to the file indicated by `handle'.
ckw03_c ( handle, begtim, endtim, INST, ref, avflag, segid,
MAXREC, sclkdp, quats, avvs, nints, starts );
SAFELY close the file.
ckcls_c ( handle );
return ( 0 );
When this program is executed, no output is presented on
screen. After run completion, a new CK file exists in the
N.J. Bachman (JPL)
J. Diaz del Rio (ODC Space)
K.R. Gehringer (JPL)
E.D. Wright (JPL)
-CSPICE Version 1.0.2, 10-AUG-2021 (JDR)
Updated the header to comply with NAIF standard. Added
complete code example based on existing fragment.
Re-ordered header sections.
-CSPICE Version 1.0.1, 08-MAR-2002 (EDW)
Corrected header typo. Examples" to -Examples.
-CSPICE Version 1.0.0, 08-FEB-1998 (NJB) (KRG)
Based on SPICELIB Version 1.0.0, 26-JAN-1995 (KRG)
close a CK file