Table of contents
CSPICE_CKCLS closes a CK file opened for read or write.
Given:
handle the handle of the CK file that is to be closed.
help, handle
LONG = Scalar
the call:
cspice_ckcls, handle
closes the file attached to `handle'.
None.
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) 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.
PRO ckcls_ex1
;;
;; Define needed parameters.
;;
SPICETRUE = 1L
CK3 = "ckcls_ex1.bc"
IFNAME = "Test CK type 3 created by cspice_ckw03"
INST = -77703
MAXREC = 201
SC = -777
SECPERTICK = 0.001d
SEGID = "Test type 3 segment test CK"
SPACING_TICKS = 10.d
;;
;; `NCOMCH' defines the number of characters to reserve for
;; the kernel's comment area. This example doesn't write
;; comments, but it reserves room for 5000 characters.
;;
NCOMCH = 5000
;;
;; The base reference from for the rotation data.
;;
REF = "J2000"
;;
;; Time spacing in encoded ticks.
;;
SPACING_TICKS = 10.d
;;
;; 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 angular velocity.
;;
quats = dblarr( 4, MAXREC )
av = dblarr( 3, MAXREC )
;;
;; Create a 3x3 double precision identity matrix.
;; The Icy call:
;;
;; cspice_ident, work_mat
;;
;; performs the same function.
;;
work_mat = identity( 3 )
;;
;; Convert the matrix to quaternion.
;;
cspice_m2q, work_mat, work_quat
;;
;; Copy the work quaternion to the first row of
;; quats.
;;
quats[0:3] = work_quat
;;
;; Create an angular velocity vector. Copy to the first row
;; of `av'. This vector is in the `REF' reference frame.
;;
av [0:2] = [0.d, 0.d, RATE ]
;;
;; Create an array of encoded tick values in increments of
;; `SPACING_TICKS' with an initial value of 1000 ticks...
;;
sclkdp = dindgen(MAXREC) * SPACING_TICKS
sclkdp = sclkdp + 1000.d
;;
;; Fill the rest of the av and quats matrices
;; with simple data.
;;
for i = 1, (MAXREC-1) do begin
;;
;; 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 = t * d(theta)
;; --------
;; dt
;;
theta = ( double(i) * RATE * SPACING_SECS)
cspice_rotmat, work_mat, theta, 3, rwmat
;;
;; Convert the `rwmat' matrix to SPICE type quaternion.
;;
cspice_m2q, rwmat, work_quat
;;
;; Store the quaternion in the `quats' matrix.
;; Store angular velocity in `av'. Both variables
;; represent arrays, but in IDL you can fill them
;; as vectors.
;;
;;
quats[ (i*4):((i*4)+3) ] = work_quat
av [ (i*3):((i*3)+2) ] = [ 0.d, 0.d, RATE ]
endfor
;;
;; Create and open the new CK file.
;;
cspice_ckopn, CK3, IFNAME, NCOMCH, handle
;;
;; 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.
;;
numint = MAXREC/2
starts = dblarr( numint )
for i = 0, (numint-1) do begin
starts[i] = sclkdp[2*i]
endfor
;;
;; Set the segment boundaries equal to the first and last
;; time in the segment.
;;
begtim = sclkdp[ 0]
endtim = sclkdp[MAXREC-1]
;;
;; Enter the information to go in the segment descriptor.
;;
;; 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'.
;;
cspice_ckw03, handle, $
begtim, $
endtim, $
INST , $
REF, $
avflag, $
SEGID , $
sclkdp, $
quats, $
av, $
starts
;;
;; SAFELY close the file
;;
cspice_ckcls, handle
END
When this program is executed, no output is presented on
screen. After run completion, a new CK file exists in the
output directory.
Close the CK file attached to `handle'.
The close operation tests the file to ensure the presence of data
segments.
A cspice_ckcls call should balance every cspice_ckopn call.
1) If there are no segments in the file, the error
SPICE(NOSEGMENTSFOUND) is signaled by a routine in the call
tree of this routine.
2) If the input argument `handle' is undefined, an error is
signaled by the IDL error handling system.
3) If the input argument `handle' is not of the expected type, or
it does not have the expected dimensions and size, an error is
signaled by the Icy interface.
None.
None.
ICY.REQ
CK.REQ
None.
J. Diaz del Rio (ODC Space)
E.D. Wright (JPL)
-Icy Version 1.0.1, 31-MAY-2021 (JDR)
Updated the header to comply with NAIF standard. Added
complete code example based on existing fragment.
Added -Parameters, -Exceptions, -Files, -Restrictions,
-Literature_References and -Author_and_Institution sections.
Removed reference to the routine's corresponding CSPICE header from
-Abstract section.
Added argument's type and size information in the -I/O section.
-Icy Version 1.0.0, 16-JUN-2003 (EDW)
close a CK file
|