CSPICE_EKACLD adds a column of double precision data to an EK
For important details concerning this module's function, please refer to
the CSPICE routine ekacld_c.
handle the scalar integer referring to an EK file open for
segno the scalar integer indicating EK segment number
for the new record
column the scalar string naming the target column for the data
stored in 'dvals'
dvals an array of double precision values, listed in row order,
containing the data to add to the EK referred to by 'handle'
entszs an array of integers containing the sizes of column
entries - used only for columns possessing variable size
entries; the ith element of 'entszs' corresponds to the
size of the ith entry of 'dvals'
nlflgs an array of booleans indicating whether the
corresponding 'dvals' has a null value, with
the ith entry of 'nlflgs' corresponding to the ith
entry of 'dvals'
rcptrs an integer array of record pointers, returned from
cspice_ekifld, for the input segment
wkindx a read/write array of integers, used as a workspace
when building an column index - as this array
functions as read/write, the calling routine must
declare an appropriate size of nrows (the number of
rows in the column)
cspice_ekacld, handle, segno, column, dvals, entszs, nlflgs, $
writes the 'dvals' data to 'column' in segment 'segno' of the
EK referred to by 'handle'.
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.
;; Initialize needed parameters.
SPICEFALSE = 0B
SPICETRUE = 1B
EKNAME = 'ekacld.ek'
IFNAME = 'Test EK'
LNMLEN = 50
LSK = 'standard.tm'
NCOLS = 2
NRESVC = 0
NROWS = 9
TABLE = 'DATAORDERS'
;; Load a leapseconds kernel for UTC/ET conversion.
;; Open a new EK file. For simplicity, we won't
;; reserve space for the comment area, so the
;; number of reserved comment characters is zero.
;; The constant IFNAME is the internal file name.
if ( cspice_exists( EKNAME) ) then begin
cspice_ekopn, EKNAME, IFNAME, NRESVC, handle
cnames = strarr( NCOLS )
cdecls = strarr( NCOLS )
;; Note, store a time value in double precision,
;; ephemeris seconds past J2000.
cnames = 'ORDER_DATE'
cdecls = 'DATATYPE = TIME, INDEXED = TRUE'
cnames = 'COST'
cdecls = 'DATATYPE = DOUBLE PRECISION, '+$
'INDEXED = TRUE, NULLS_OK = TRUE'
;; Start the segment. We presume the number of rows
;; of data is known in advance.
cspice_ekifld, handle, TABLE, NCOLS, NROWS, $
cnames, cdecls, segno, rcptrs
;; At this point, arrays containing data for the
;; segment's columns may be filled in. The names
;; of the data arrays are shown below.
;; Column Data array
;; 'ORDER_DATE' odates
;; 'COST' costs
;; The null flags array indicates which entries are null.
;; It is ignored for columns that don't allow null
;; values. In this case, only the COST column allows
;; Fill in data arrays and null flag arrays here. This code
;; section would normally be replaced by calls to user functions
;; returning column values.
costs = dblarr( NROWS)
ets = dblarr( NROWS)
nlflgs = lonarr( NROWS)
wkindx = lonarr( NROWS)
sizes = lonarr( NROWS)
for i = 0, (NROWS-1) do begin
costs [i] = double(100*i)
date_string = '2001 Mar ' + string(i)
cspice_utc2et, date_string, et
ets[i] = et
nlflgs[i] = SPICEFALSE
nlflgs = SPICETRUE
;; The sizes array shown below is ignored for scalar
;; and fixed-size array columns, so we need not
;; initialize it. For variable-size arrays, the
;; Ith element of the sizes array must contain the size
;; of the Ith column entry in the column being written.
;; Normally, the sizes array would be reset for each
;; variable-size column.
;; Add the columns of data to the segment. All of the
;; data for each column is written in one shot.
cspice_ekacld, handle, segno, 'order_date', ets , sizes, $
nlflgs, rcptrs, wkindx
cspice_ekacld, handle, segno, 'cost' , costs, sizes, $
nlflgs, rcptrs, wkindx
;; Complete the segment. The rcptrs array is that
;; returned by ekifld_c.
cspice_ekffld, handle, segno, rcptrs
;; The file must be closed by a call to cspice_ekcls
;; It's always good form to unload kernels after use,
;; particularly in IDL due to data persistence.
-Icy Version 1.0.2, 27-FEB-2007, EDW (JPL)
Add cspice_kclear call to example section.
-Icy Version 1.0.0, 16-JUN-2003, EDW (JPL)
write entire double precision column to EK segment