This function writes in sequential mode a type 102 segment (Chebyshev polynomials of the position only ) in the time scale TCB to the SPK file associated to the ephemeris descriptor eph.
The polynomials array must be of size record_count*(deg+1)*3 and have the following structure :
X's 1st coef 1st record |
... |
X's (deg + 1)th coef 1st record |
Y's 1st coef 1st record |
... |
Y's (deg + 1)th coef 1st record |
Z's 1st coef 1st record |
... |
Z's (deg + 1)th coef 1st record |
... |
... |
... |
... |
... |
... |
... |
... |
... |
X's 1st coef (record_count)th record |
... |
X's (deg + 1)th coef (record_count)th record |
Y's 1st coef (record_count)th record |
... |
Y's (deg + 1)th coef (record_count)th record |
Z's 1st coef (record_count)th record |
... |
Z's (deg + 1)th coef (record_count)th record |
The following example creates a new ephemeris file ephemeris.bsp with segment of type 2 for the heliocentric coordinates of Venus, in the timescale TCB.
USE, INTRINSIC :: ISO_C_BINDING
use calceph
TYPE(C_PTR) :: weph
INTEGER len_timespan
REAL(8) :: jd_start, jd_end
INTEGER frame, record_count, degree, k, ret
REAL(8), dimension(390) :: coefs ! size = 10*13*3 = record_count * (degree+1) * 3 components
len_timespan = 32 ! days
frame = 1 ! ICRF
record_count = 10
degree = 12
jd_start = 2460000
jd_end = jd_start+record_count*len_timespan
weph = writeph_spk_create("ephemeris.bsp"//C_NULL_CHAR, "planet_2"//C_NULL_CHAR, 0)
if (C_ASSOCIATED(peph)) then
do k=0, record_count-1
! ... fill the array coefs with the coefficients of the Chebychev polynomials ...
! coefs(...) =...
enddo
ret = writeph_spk102_seq_write(weph, NAIFID_VENUS, NAIFID_SUN, frame, jd_start, 0.0, jd_end, 0.0,
len_timespan, coefs, record_count, degree+1, "seg_planet"//C_NULL_CHAR)
call writeph_close(peph)
endif