This function writes in sequential mode a type 9 segment (discrete states of the positions and velocities, Lagrange interpolation with unequal timesteps) 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 epochs array must be of size record_count and contain the epochs (in Julian date TDB) corresponding to each state vector, it has the following structure :

Epoch of the 1st record

...

Epoch of the (record_count)th record

The following example creates a new ephemeris file ephemeris.bsp with segment of type 9 for the heliocentric coordinates of Venus.

t_writephbin *weph;
const char segid[] = "seg_planet";

weph = writeph_spk_create("ephemeris.bsp","planet_2", 0);
if (weph)
{
      int frame = 1; /* ICRF */
      int record_count = 100;
      int interpolation_degree = 7;
      double jd_start = 2460000;
      double jd_end = jd_start+record_count*len_timespan;
      double pos_vel[600];  /*  size = 100*6  = record_count* 6 components */
      double epochs[100];  /*  size = 100  = record_count components */

      for (int k=0; k<record_count; k++)
      {


           /* ... fill the array epochs and pos_vel with the positions and velocities ...
               epochs[k]   = ...
               pos_vel[..] = ...
           */
      }
      writeph_spk9_seq_write(weph, NAIFID_VENUS, NAIFID_SUN, frame, jd_start, 0.0, jd_end, 0.0,
                             pos_vel, epochs, record_count, interpolation_degree, segid);


      writeph_close(weph);
}