ckcls_c |
Table of contents
Procedureckcls_c ( CK, Close file ) void ckcls_c ( SpiceInt handle ) AbstractClose an open CK file. Required_ReadingNone. KeywordsCK Brief_I/OVARIABLE I/O DESCRIPTION -------- --- -------------------------------------------------- handle I Handle of the CK file to be closed. Detailed_Inputhandle is the handle of the CK file that is to be closed. Detailed_OutputNone. ParametersNone. Exceptions1) If there are no segments in the file, the error SPICE(NOSEGMENTSFOUND) is signaled by a routine in the call tree of this routine. FilesSee -Detailed_Input. ParticularsClose the CK file attached to handle. ExamplesThe 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. /. Program ckcls_ex1 ./ #include "SpiceUsr.h" int main( ) { /. Local parameters. ./ #define CK3 "ckcls_ex1.bc" #define SPTICK 0.001 #define INST -77703 #define MAXREC 201 /. Local variables. ./ SpiceChar * ref; SpiceChar * ifname; SpiceChar * segid; SpiceDouble avvs [MAXREC][3]; SpiceDouble begtim; SpiceDouble endtim; SpiceDouble quats [MAXREC][4]; SpiceDouble rate; SpiceDouble rwmat [3][3]; SpiceDouble spaces; SpiceDouble sclkdp [MAXREC]; SpiceDouble starts [MAXREC/2]; SpiceDouble sticks; SpiceDouble theta; SpiceDouble wmat [3][3]; SpiceDouble wquat [4]; SpiceInt handle; SpiceInt i; SpiceInt ncomch; SpiceInt nints; SpiceBoolean avflag; /. `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 `quats'. ./ moved_c ( wquat, 4, quats[0] ); /. 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[0] ); /. Set the initial value of the encoded ticks. ./ sclkdp[0] = 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 1000.0 ticks. ./ 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[0]; 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 output directory. RestrictionsNone. Literature_ReferencesNone. Author_and_InstitutionN.J. Bachman (JPL) J. Diaz del Rio (ODC Space) K.R. Gehringer (JPL) E.D. Wright (JPL) Version-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) Index_Entriesclose a CK file |
Fri Dec 31 18:41:02 2021