Table of contents
CSPICE_CKOPN opens a new CK file, returning the handle
of the opened file.
Given:
fname a string defining the name of the CK file to open.
help, fname
STRING = Scalar
ifname a string defining the descriptive internal file name for the CK.
help, ifname
STRING = Scalar
ncomch the scalar integer number of characters to reserve for comments.
help, ncomch
LONG = Scalar
the call:
cspice_ckopn, fname, ifname, ncomch, handle
returns:
handle a scalar integer file handle assigned to `fname'.
help, handle
LONG = Scalar
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 ckopn_ex1
;;
;; Define needed parameters.
;;
SPICETRUE = 1L
CK3 = "ckopn_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.
Open a new CK file, reserving room for comments if requested.
A cspice_ckcls call should balance every cspice_ckopn
call.
1) If the value of `ncomch' is negative, a value of zero (0) will
be used for the number of comment characters to be set aside
for comments.
2) If an error occurs while attempting to open a CK file the
value of `handle' will not represent a valid file handle.
3) If any of the input arguments, `fname', `ifname' or `ncomch',
is undefined, an error is signaled by the IDL error handling
system.
4) If any of the input arguments, `fname', `ifname' or `ncomch',
is not of the expected type, or it does not have the expected
dimensions and size, an error is signaled by the Icy
interface.
5) If the output argument `handle' is not a named variable, an
error is signaled by the Icy interface.
See `fname' and `handle'.
None.
ICY.REQ
CK.REQ
None.
J. Diaz del Rio (ODC Space)
E.D. Wright (JPL)
-Icy Version 1.1.0, 10-AUG-2021 (JDR)
Changed the input argument name "name" to "fname" for
consistency with other routines.
Edited the -Examples section to comply with NAIF standard. Added
complete code example, based on the cspice_ckw03 example.
Added -Parameters, -Exceptions, -Files, -Restrictions,
-Literature_References and -Author_and_Institution sections, and
completed -Particulars section.
Removed reference to the routine's corresponding CSPICE header from
-Abstract section.
Added arguments' type and size information in the -I/O section.
-Icy Version 1.0.0, 16-JUN-2003 (EDW)
open a new CK file
|