This function writes in sequential mode a type 8 segment (discrete states of the positions and velocities, Lagrange interpolation with equal timesteps) in the time scale TDB to the SPK file associated to the ephemeris descriptor eph.
The states array must be of size record_count*6 and have the following structure :
X coord 1st record |
Y coord 1st record |
Z coord 1st record |
dX 1st record |
dY 1st record |
dZ 1st record |
... |
... |
... |
... |
... |
... |
X coord (record_count)th record |
Y coord (record_count)th record |
Z coord (record_count)th record |
dX (record_count)th record |
dY (record_count)th record |
dZ (record_count)th record |
The following example creates a new ephemeris file ephemeris.bsp with segment of type 8 for the heliocentric coordinates of Venus.
USE, INTRINSIC :: ISO_C_BINDING
use calceph
TYPE(C_PTR) :: weph
INTEGER len_timespan
REAL(8) :: jd_start, jd_end, jd
INTEGER frame, record_count, interpolation_degree, k, ret
REAL(8), dimension(600) :: pos_vel ! size = 600 = record_count * 6 components
len_timespan = 32 ! days
frame = 1 ! ICRF
record_count = 100
interpolation_degree = 7
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)
if (C_ASSOCIATED(weph)) then
do k=0, record_count-1
jd = jd_start+k*len_timespan
! ... fill the array pos_vel with the positions and velocities at the date jd ...
! pos_vel(...) =...
enddo
ret = writeph_spk8_seq_write(weph, NAIFID_VENUS, NAIFID_SUN, frame, jd_start, 0.0, jd_end, 0.0,
len_timespan, pos_vel, record_count, interpolation_degree, "seg_planet"//C_NULL_CHAR)
call writeph_close(weph)
endif