writeph_pck_create
-
t_writephbin *writeph_pck_create(const char *filename, const char *ifname, int flags)
- Parameters:
filename -- pathname of the file
ifname -- internal filename (max 60 characters)
flags -- reserved for future extensions (must be zero)
- Returns:
ephemeris descriptor. This value is NULL if an error occurs, otherwise non-NULL value.
This function creates for writing a new PCK file whose pathname is the string pointed to by filename, and returns an ephemeris descriptor associated to it. If a file with the same name already exists, it is overwritten.
The function writeph_close() must be called to free memory allocated by this function.
The function writeph_dump() and writeph_restore() can be called to create a checkpoint restart if the creation of the file is very long.
The following example creates and writes the ephemeris file ephemeris.bpc
t_writephbin *weph;
weph = writeph_pck_create("ephemeris.bpc","asteroid_1", 0);
if (weph)
{
/*
... computation and writing to weph ...
*/
writeph_close(weph);
}
writeph_pck_open
-
t_writephbin *writeph_pck_open(const char *filename)
- Parameters:
filename -- pathname of the file
- Returns:
ephemeris descriptor. This value is NULL if an error occurs, otherwise non-NULL value.
This function opens an existing PCK ephemeris file in order to append ephemeris data to it, whose pathname is the string pointed to by filename, and returns an ephemeris descriptor associated to it. If the file doesn't exist, or if it isn't a PCK file, the function fails and returns NULL. This file must be compliant to the format specified by the 'SPICE' PCK ephemeris file.
The function writeph_close() must be called to free memory allocated by this function.
The following example appends data to the ephemeris file ephemeris.bpc
t_writephbin *weph;
weph = writeph_pck_open("ephemeris.bpc");
if (weph)
{
/*
... computation and writing to weph ...
*/
writeph_close(weph);
}
The following PCK functions are to be used to write binary PCK files:
writeph_pck2_seq_write
-
int writeph_pck2_seq_write(t_writephbin *eph, int target, int frame, double start_jd0_tdb, double start_frac_tdb, double end_jd0_tdb, double end_frac_tdb, double intlen_jd_tdb, const double *polynomials, int record_count, int deg, const char *segid)
- Parameters:
eph -- ephemeris descriptor
target -- The body or reference point whose coordinates will be written (see NAIF identification numbers).
frame -- reference frame (see Frame numbers).
start_jd0_tdb -- starting Julian date integer part (TDB).
start_frac_tdb -- starting Julian date fraction part (TDB).
end_jd0_tdb -- stop Julian date integer part (TDB).
end_frac_tdb -- stop Julian date fraction part (TDB).
intlen_jd_tdb -- length of the interpolation interval (in days, TDB).
polynomials -- array of Chebyshev polynomial coefficients.
record_count -- number of records to be written.
deg -- degree of the Chebyshev polynomials.
segid -- segment identifier (must be unique within the file, max 40 characters).
- Returns:
0 if an error occurs, otherwise non-zero value.
This function writes in sequential mode a type 2 segment (Chebyshev polynomials of Chebyshev polynomials of the angles only) in the time scale TDB to the PCK file associated to the ephemeris descriptor eph.
The polynomials array must be of size record_count*(deg+1)*3 and have the following structure :
E1's 1st coef 1st record. |
... |
E1's (deg + 1)th coef 1st record. |
E2's 1st coef 1st record. |
... |
E2's (deg + 1)th coef 1st record. |
E3's 1st coef 1st record. |
... |
E3's (deg + 1)th coef 1st record. |
... |
... |
... |
... |
... |
... |
... |
... |
... |
E1's 1st coef (record_count)th record |
... |
E1's (deg + 1)th coef (record_count)th record |
E2's 1st coef (record_count)th record |
... |
E2's (deg + 1)th coef (record_count)th record |
E3's 1st coef (record_count)th record |
... |
E3'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 orientation of one body.
t_writephbin *weph;
const char segid[] = "seg_planet";
weph = writeph_pck_create("ephemeris.bpc","planet_2", 0);
if (weph)
{
int len_timespan = 32; /* days */
int frame = 1; /* ICRF */
int record_count = 10;
int degree = 12;
double jd_start = 2460000;
double jd_end = jd_start+record_count*len_timespan;
double coefs[390]; /* size = 10*13*3 = record_count * (degree+1) * 3 components */
for (int k=0; k<record_count; k++)
{
double jd_startk = jd_start+k*len_timespan;
double jd_endk = jd_start+(k+1)*len_timespan;
/* ... fill the array coefs with the coefficients of the Chebychev polynomials ...
coefs[..] =...
*/
}
writeph_pck2_seq_write(weph, 4000099, frame, jd_start, 0.0, jd_end, 0.0,
len_timespan, coefs, record_count, degree+1, segid);
writeph_close(weph);
}
writeph_pck2_par_reserve
-
int writeph_pck2_par_reserve(t_writephbin *eph, int target_count, const int *targets, int frame, double start_jd0_tdb, double start_frac_tdb, double end_jd0_tdb, double end_frac_tdb, const double *intlens_jd_tdb, const int *record_counts, int deg, const char *segids[])
- Parameters:
eph -- ephemeris descriptor
target_count -- number of targets the reservation is done for.
targets -- array of bodies or reference points whose coordinates will be written (see NAIF identification numbers).
frame -- reference frame (see Frame numbers).
start_jd0_tdb -- starting Julian date integer part (TDB).
start_frac_tdb -- starting Julian date fraction part (TDB).
end_jd0_tdb -- stop Julian date integer part (TDB).
end_frac_tdb -- stop Julian date fraction part (TDB).
intlens_jd_tdb -- array containing the interpolation interval length for each target (in days, TDB).
record_counts -- array of number of records for each target.
deg -- degree of the Chebyshev polynomials.
segids -- array of segment identifiers (one per target, each must be unique within the file, max 40 characters).
- Returns:
return a reservation identifier on success, 0 on failure.
This function is meant to enable the parallel writing (with multiple threads) of several type 2 segments (Chebyshev polynomials of the angle only) in the time scale TDB to the PCK file associated to the ephemeris descriptor eph.
It reserves space in the file for target_count segments, each segment associated to a target in the targets array. Each target has its own interpolation interval length specified in the intlens_jd_tdb array, its own number of records specified in the record_counts array, and its own segment identifier specified in the segids array. All the targets share the same frame, start_..._tdb, end_..._tdb and deg parameters.
The arrays targets, intlens_jd_tdb, record_counts and segids must be of size target_count.
The reservation id returned by this function must be used in the function writeph_pck2_par_write() to write in the corresponding reserved space.
In addition, the function writeph_pck2_par_write() will require a target_index, which is the index of the target in the targets array used in this function.
A call to writeph_pck2_par_reserve() is always performed by a single thread and is followed by several calls to writeph_pck2_par_write() by one or several threads.
Warning
The data covers the same timespan from the date start_jd_tdb+start_frac_tdb to end_jd_tdb+end_frac_tdb for all targets, but each target may have a different number of polynomials.
The time span record_counts*intlens_jd_tdb must be equal to the timespan defined from the date start_jd_tdb+start_frac_tdb to end_jd_tdb+end_frac_tdb.
If the targets doesnot have the timespan, multiple reservations must be performed before the call to writing writeph_pck2_par_write().
The following example creates a new ephemeris file ephemeris.bsp with segment of type 2 for the orientation of two bodies using OpenMP.
t_writephbin *weph;
weph = writeph_pck_create("ephemeris.bpc","planet_2", 0);
if (weph)
{
int frame = 1; /* ICRF */
int degree = 12;
int target_count = 2;
int targets[2] = { 3000099, 4000099 };
int records_count[2] = { 10, 20 };
int len_timespan[2] = { 32, 16 };
const char segids[2] = { "seg_body1", "seg_body2" };
double jd_start = 2460000;
double jd_end = 2460000+32*10;
int reservation;
reservation = writeph_pck2_seq_reserve(weph, target_count, targets,
frame, jd_start, 0.0, jd_end, 0.0,
len_timespan, record_counts, degree+1, segids);
#pragma omp parallel for
for (int body = 0; body<target_count; body++)
{
#pragma omp parallel for
for (int k=0; k<records_count[body]; k++)
{
double coefs[39]; /* size = 13*3 = (degree+1) * 3 components */
double jd_startk = jd_start+k*len_timespan[body];
double jd_endk = jd_start+(k+1)*len_timespan[body];
/* ... fill the array coefs with the coefficients of the Chebychev polynomials ...
coefs[..] =...
*/
writeph_pck2_par_write(weph, reservation, body, k, 1, coefs);
}
}
writeph_close(weph);
}
writeph_pck2_par_write
-
int writeph_pck2_par_write(t_writephbin *eph, int reservation, int target_index, int record_begin_index, int record_count, const double *polynomials)
- Parameters:
eph -- ephemeris descriptor
reservation -- reservation identifier.
target_index -- index of the target body in the reservation.
record_begin_index -- index of the first record to be written in the target's segment.
record_count -- number of records to be written.
polynomials -- array of Chebyshev polynomial coefficients.
- Returns:
0 if an error occurs, otherwise non-zero value.
This function writes in parallel mode records of a type 2 segment (Chebyshev polynomials of the angle only) in the time scale TDB to the PCK file associated to the ephemeris descriptor eph.
The reservation parameter must be the reservation id returned by the function writeph_pck2_par_reserve().
The target_index parameter is the index of the target in the targets array that was passed to the function writeph_pck2_par_reserve().
The record_begin_index parameter is the index of the first record to be written in the target's segment.
The record_count parameter is the number of records to be written starting from the record_begin_index.
The polynomials array must be of size record_count*(deg+1)*3 and have the following structure :
E1's 1st coef 1st record. |
... |
E1's (deg + 1)th coef 1st record. |
E2's 1st coef 1st record. |
... |
E2's (deg + 1)th coef 1st record. |
E3's 1st coef 1st record. |
... |
E3's (deg + 1)th coef 1st record. |
... |
... |
... |
... |
... |
... |
... |
... |
... |
E1's 1st coef (record_count)th record |
... |
E1's (deg + 1)th coef (record_count)th record |
E2's 1st coef (record_count)th record |
... |
E2's (deg + 1)th coef (record_count)th record |
E3's 1st coef (record_count)th record |
... |
E3's (deg + 1)th coef (record_count)th record |
With the 1st record being the record at index record_begin_index, and the (record_count)th record being the record at index record_begin_index + record_count - 1.
Multiple threads can call this function at the same time, but with different values of target_index and/or record_begin_index. The behavior is undefined if multiple threads overlap the written data : e.g., two threads write to the same target target_index and a common record number.
writeph_pck3_seq_write
-
int writeph_pck3_seq_write(t_writephbin *eph, int target, int frame, double start_jd0_tdb, double start_frac_tdb, double end_jd0_tdb, double end_frac_tdb, double intlen_jd_tdb, const double *polynomials, int record_count, int deg, const char *segid)
- Parameters:
eph -- ephemeris descriptor
target -- The body or reference point whose coordinates will be written (see NAIF identification numbers).
frame -- reference frame (see Frame numbers).
start_jd0_tdb -- starting Julian date integer part (TDB).
start_frac_tdb -- starting Julian date fraction part (TDB).
end_jd0_tdb -- stop Julian date integer part (TDB).
end_frac_tdb -- stop Julian date fraction part (TDB).
intlen_jd_tdb -- length of the interpolation interval (in days, TDB).
polynomials -- array of Chebyshev polynomial coefficients.
record_count -- number of records to be written.
deg -- degree of the Chebyshev polynomials.
segid -- segment identifier (must be unique within the file, max 40 characters).
- Returns:
0 if an error occurs, otherwise non-zero value.
This function writes in sequential mode a type 3 segment (Chebyshev polynomials of the angles and their derivatives) in the time scale TDB to the PCK file associated to the ephemeris descriptor eph.
The polynomials array must be of size record_count*(deg+1)*6 and have the following structure :
E1's 1st coef 1st record |
... |
E1's (deg + 1)th coef 1st record |
E2's 1st coef 1st record |
... |
E2's (deg + 1)th coef 1st record |
E3's 1st coef 1st record |
... |
E3's (deg + 1)th coef 1st record |
dE1's 1st coef 1st record |
... |
dE1's (deg + 1)th coef 1st record |
dE2's 1st coef 1st record |
... |
dE2's (deg + 1)th coef 1st record |
dE3's 1st coef 1st record |
... |
dE3's (deg + 1)th coef 1st record |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
E1's 1st coef (record_count)th record |
... |
E1's (deg + 1)th coef (record_count)th record |
E2's 1st coef (record_count)th record |
... |
E2's (deg + 1)th coef (record_count)th record |
E3's 1st coef (record_count)th record |
... |
E3's (deg + 1)th coef (record_count)th record |
dE1's 1st coef (record_count)th record |
... |
dE1's (deg + 1)th coef (record_count)th record |
dE2's 1st coef (record_count)th record |
... |
dE2's (deg + 1)th coef (record_count)th record |
dE3's 1st coef (record_count)th record |
... |
dE3's (deg + 1)th coef (record_count)th record |
The following example creates a new ephemeris file ephemeris.bsp with segment of type 3 for the orientation of one body.
t_writephbin *weph;
const char segid[] = "seg_planet";
weph = writeph_pck_create("ephemeris.bpc","planet_2", 0);
if (weph)
{
int len_timespan = 32; /* days */
int frame = 1; /* ICRF */
int record_count = 10;
int degree = 12;
double jd_start = 2460000;
double jd_end = jd_start+record_count*len_timespan;
double coefs[780]; /* size = 10*13*6 = record_count * (degree+1) * 6 components */
for (int k=0; k<record_count; k++)
{
double jd_startk = jd_start+k*len_timespan;
double jd_endk = jd_start+(k+1)*len_timespan;
/* ... fill the array coefs with the coefficients of the Chebychev polynomials ...
coefs[..] =...
*/
}
writeph_pck3_seq_write(weph, 4000099, frame, jd_start, 0.0, jd_end, 0.0,
len_timespan, coefs, record_count, degree+1, segid);
writeph_close(weph);
}
writeph_pck3_par_reserve
-
int writeph_pck3_par_reserve(t_writephbin *eph, int target_count, const int *targets, int frame, double start_jd0_tdb, double start_frac_tdb, double end_jd0_tdb, double end_frac_tdb, const double *intlens_jd_tdb, const int *record_counts, int deg, const char *segids[])
- Parameters:
eph -- ephemeris descriptor
target_count -- number of targets the reservation is done for.
targets -- array of bodies or reference points whose coordinates will be written (see NAIF identification numbers).
frame -- reference frame (see Frame numbers).
start_jd0_tdb -- starting Julian date integer part (TDB).
start_frac_tdb -- starting Julian date fraction part (TDB).
end_jd0_tdb -- stop Julian date integer part (TDB).
end_frac_tdb -- stop Julian date fraction part (TDB).
intlens_jd_tdb -- array containing the interpolation interval length for each target (in days, TDB).
record_counts -- array of number of records for each target.
deg -- degree of the Chebyshev polynomials.
segids -- array of segment identifiers (one per target, each must be unique within the file, max 40 characters).
- Returns:
return a reservation identifier on success, 0 on failure.
This function is meant to enable the parallel writing (with multiple threads) of several type 3 segments (Chebyshev polynomials of the angles and their derivatives) to the PCK file associated to the ephemeris descriptor eph.
It reserves space in the file for target_count segments, each segment associated to a target in the targets array. Each target has its own interpolation interval length specified in the intlens_jd_tdb array, its own number of records specified in the record_counts array, and its own segment identifier specified in the segids array. All the targets share the same frame, start_..._tdb, end_..._tdb and deg parameters.
The array targets, intlens_jd_tdb, record_counts and segids must be of size target_count.
The reservation id returned by this function must be used in the function writeph_pck3_par_write() to write in the corresponding reserved space.
In addition, the function writeph_pck3_par_write() will require a target_index, which is the index of the target in the targets array used in this function.
A call to writeph_pck3_par_reserve is always performed by a single thread and is followed by several calls to writeph_pck3_par_write() by one or several threads.
Warning
The data covers the same timespan from the date start_jd_tdb+start_frac_tdb to end_jd_tdb+end_frac_tdb for all targets, but each target may have a different number of polynomials.
The time span record_counts*intlens_jd_tdb must be equal to the timespan defined from the date start_jd_tdb+start_frac_tdb to end_jd_tdb+end_frac_tdb.
If the targets doesnot have the timespan, multiple reservations must be performed before the call to writing writeph_pck3_par_write().
The following example creates a new ephemeris file ephemeris.bsp with segment of type 3 for the orientation of two bodiesusing OpenMP.
t_writephbin *weph;
weph = writeph_pck_create("ephemeris.bpc","planet_2", 0);
if (weph)
{
int frame = 1; /* ICRF */
int degree = 12;
int target_count = 2;
int targets[2] = { 3000099, 4000099 };
int records_count[2] = { 10, 20 };
int len_timespan[2] = { 32, 16 };
const char segids[2] = { "seg_body1", "seg_body2" };
double jd_start = 2460000;
double jd_end = 2460000+32*10;
int reservation;
reservation = writeph_pck3_seq_reserve(weph, target_count, targets,
frame, jd_start, 0.0, jd_end, 0.0,
len_timespan, record_counts, degree+1, segids);
#pragma omp parallel for
for (int body = 0; body<target_count; body++)
{
#pragma omp parallel for
for (int k=0; k<records_count[body]; k++)
{
double coefs[78]; /* size = 13*6 = (degree+1) * 6 components */
double jd_startk = jd_start+k*len_timespan[body];
double jd_endk = jd_start+(k+1)*len_timespan[body];
/* ... fill the array coefs with the coefficients of the Chebychev polynomials ...
coefs[..] =...
*/
writeph_pck3_par_write(weph, reservation, body, k, 1, coefs);
}
}
writeph_close(weph);
}
writeph_pck3_par_write
-
int writeph_pck3_par_write(t_writephbin *eph, int reservation, int target_index, int record_begin_index, int record_count, const double *polynomials)
- Parameters:
eph -- ephemeris descriptor
reservation -- reservation identifier.
target_index -- index of the target body in the reservation.
record_begin_index -- index of the first record to be written in the target's segment.
record_count -- number of records to be written.
polynomials -- array of Chebyshev polynomial coefficients.
- Returns:
0 if an error occurs, otherwise non-zero value.
This function writes in parallel mode records of a type 3 segment (Chebyshev polynomials of the angles and their derivatives) in the time scale TDB to the PCK file associated to the ephemeris descriptor eph.
The reservation parameter must be the reservation id returned by the function writeph_pck3_par_reserve().
The target_index parameter is the index of the target in the targets array that was passed to the function writeph_pck3_par_reserve(), starting from 0.
The record_begin_index parameter is the index of the first record to be written in the target's segment, starting from 0.
The record_count parameter is the number of records to be written starting from the record_begin_index.
The polynomials array must be of size record_count*(deg+1)*6 and have the following structure :
E1's 1st coef 1st record |
... |
E1's (deg + 1)th coef 1st record |
E2's 1st coef 1st record |
... |
E2's (deg + 1)th coef 1st record |
E3's 1st coef 1st record |
... |
E3's (deg + 1)th coef 1st record |
dE1's 1st coef 1st record |
... |
dE1's (deg + 1)th coef 1st record |
dE2's 1st coef 1st record |
... |
dE2's (deg + 1)th coef 1st record |
dE3's 1st coef 1st record |
... |
dE3's (deg + 1)th coef 1st record |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
E1's 1st coef (record_count)th record |
... |
E1's (deg + 1)th coef (record_count)th record |
E2's 1st coef (record_count)th record |
... |
E2's (deg + 1)th coef (record_count)th record |
E3's 1st coef (record_count)th record |
... |
E3's (deg + 1)th coef (record_count)th record |
dE1's 1st coef (record_count)th record |
... |
dE1's (deg + 1)th coef (record_count)th record |
dE2's 1st coef (record_count)th record |
... |
dE2's (deg + 1)th coef (record_count)th record |
dE3's 1st coef (record_count)th record |
... |
dE3's (deg + 1)th coef (record_count)th record |
With the 1st record being the record at index record_begin_index, and the (record_count)th record being the record at index record_begin_index + record_count - 1.
Multiple threads can call this function at the same time, but with different values of target_index and/or record_begin_index. The behavior is undefined if multiple threads overlap the written data : e.g., two threads write to the same target target_index and a common record number.
writeph_pck102_seq_write
-
int writeph_pck102_seq_write(t_writephbin *eph, int target, int frame, double start_jd0_tcb, double start_frac_tcb, double end_jd0_tcb, double end_frac_tcb, double intlen_jd_tcb, const double *polynomials, int record_count, int deg, const char *segid)
- Parameters:
eph -- ephemeris descriptor
target -- The body or reference point whose coordinates will be written (see NAIF identification numbers).
frame -- reference frame (see Frame numbers).
start_jd0_tcb -- starting Julian date integer part (TCB).
start_frac_tcb -- starting Julian date fraction part (TCB).
end_jd0_tcb -- stop Julian date integer part (TCB).
end_frac_tcb -- stop Julian date fraction part (TCB).
intlen_jd_tcb -- length of the interpolation interval (in days, TCB).
polynomials -- array of Chebyshev polynomial coefficients.
record_count -- number of records to be written.
deg -- degree of the Chebyshev polynomials.
segid -- segment identifier (must be unique within the file, max 40 characters).
- Returns:
0 if an error occurs, otherwise non-zero value.
This function writes in sequential mode a type 102 segment (Chebyshev polynomials of the angle only) in the time scale TCB to the PCK file associated to the ephemeris descriptor eph.
The polynomials array must be of size record_count*(deg+1)*3 and have the following structure :
E1's 1st coef 1st record. |
... |
E1's (deg + 1)th coef 1st record. |
E2's 1st coef 1st record. |
... |
E2's (deg + 1)th coef 1st record. |
E3's 1st coef 1st record. |
... |
E3's (deg + 1)th coef 1st record. |
... |
... |
... |
... |
... |
... |
... |
... |
... |
E1's 1st coef (record_count)th record |
... |
E1's (deg + 1)th coef (record_count)th record |
E2's 1st coef (record_count)th record |
... |
E2's (deg + 1)th coef (record_count)th record |
E3's 1st coef (record_count)th record |
... |
E3'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 orientation of one body, in the timescale TCB.
t_writephbin *weph;
const char segid[] = "seg_planet";
weph = writeph_pck_create("ephemeris.bpc","planet_2", 0);
if (weph)
{
int len_timespan = 32; /* days */
int frame = 1; /* ICRF */
int record_count = 10;
int degree = 12;
double jd_start = 2460000;
double jd_end = jd_start+record_count*len_timespan;
double coefs[390]; /* size = 10*13*3 = record_count * (degree+1) * 3 components */
for (int k=0; k<record_count; k++)
{
double jd_startk = jd_start+k*len_timespan;
double jd_endk = jd_start+(k+1)*len_timespan;
/* ... fill the array coefs with the coefficients of the Chebychev polynomials ...
coefs[..] =...
*/
}
writeph_pck102_seq_write(weph, 4000099, frame, jd_start, 0.0, jd_end, 0.0,
len_timespan, coefs, record_count, degree+1, segid);
writeph_close(weph);
}
writeph_pck102_par_reserve
-
int writeph_pck102_par_reserve(t_writephbin *eph, int target_count, const int *targets, int frame, double start_jd0_tcb, double start_frac_tcb, double end_jd0_tcb, double end_frac_tcb, const double *intlens_jd_tcb, const int *record_counts, int deg, const char *segids[])
- Parameters:
eph -- ephemeris descriptor
target_count -- number of targets the reservation is done for.
targets -- array of bodies or reference points whose coordinates will be written (see NAIF identification numbers).
frame -- reference frame (see Frame numbers).
start_jd0_tcb -- starting Julian date integer part (TCB).
start_frac_tcb -- starting Julian date fraction part (TCB).
end_jd0_tcb -- stop Julian date integer part (TCB).
end_frac_tcb -- stop Julian date fraction part (TCB).
intlens_jd_tcb -- array containing the interpolation interval length for each target (in days, TCB).
record_counts -- array of number of records for each target.
deg -- degree of the Chebyshev polynomials.
segids -- array of segment identifiers (one per target, each must be unique within the file, max 40 characters).
- Returns:
return a reservation identifier on success, 0 on failure.
This function is meant to enable the parallel writing (with multiple threads) of several type 102 segments (Chebyshev polynomials of the angle only ) in the time scale TCB to the PCK file associated to the ephemeris descriptor eph.
It reserves space in the file for target_count segments, each segment associated to a target in the targets array. Each target has its own interpolation interval length specified in the intlens_jd_tdb array, its own number of records specified in the record_counts array, and its own segment identifier specified in the segids array. All the targets share the same frame, start_..._tdb, end_..._tdb and deg parameters.
The arrays targets, intlens_jd_tdb, record_counts and segids must be of size target_count.
The reservation id returned by this function must be used in the function writeph_pck102_par_write() to write in the corresponding reserved space.
In addition, the function writeph_pck102_par_write() will require a target_index, which is the index of the target in the targets array used in this function.
A call to writeph_pck102_par_reserve() is always performed by a single thread and is followed by several calls to writeph_pck102_par_write() by one or several threads.
Warning
The data covers the same timespan from the date start_jd_tcb+start_frac_tcb to end_jd_tcb+end_frac_tcb for all targets, but each target may have a different number of polynomials.
The time span record_counts*intlens_jd_tcb must be equal to the timespan defined from the date start_jd_tcb+start_frac_tcb to end_jd_tcb+end_frac_tcb.
If the targets doesnot have the timespan, multiple reservations must be performed before the call to writing writeph_pck102_par_write().
The following example creates a new ephemeris file ephemeris.bsp with segment of type 102 for the heliocentric coordinates of Mercury and Venus, in the timescale TCB, using OpenMP.
t_writephbin *weph;
weph = writeph_pck_create("ephemeris.bpc","planet_2", 0);
if (weph)
{
int frame = 1; /* ICRF */
int degree = 12;
int target_count = 2;
int targets[2] = { 3000099, 4000099 };
int records_count[2] = { 10, 20 };
int len_timespan[2] = { 32, 16 };
const char segids[2] = { "seg_body1", "seg_body2" };
double jd_start = 2460000;
double jd_end = 2460000+32*10;
int reservation;
reservation = writeph_pck102_seq_reserve(weph, target_count, targets,
frame, jd_start, 0.0, jd_end, 0.0,
len_timespan, record_counts, degree+1, segids);
#pragma omp parallel for
for (int body = 0; body<target_count; body++)
{
#pragma omp parallel for
for (int k=0; k<records_count[body]; k++)
{
double coefs[39]; /* size = 13*3 = (degree+1) * 3 components */
double jd_startk = jd_start+k*len_timespan[body];
double jd_endk = jd_start+(k+1)*len_timespan[body];
/* ... fill the array coefs with the coefficients of the Chebychev polynomials ...
coefs[..] =...
*/
ret = writeph_pck102_par_write(weph, reservation, body, k, 1, coefs);
}
}
writeph_close(weph);
}
writeph_pck102_par_write
-
int writeph_pck102_par_write(t_writephbin *eph, int reservation, int target_index, int record_begin_index, int record_count, const double *polynomials)
- Parameters:
eph -- ephemeris descriptor
reservation -- reservation identifier.
target_index -- index of the target body in the reservation.
record_begin_index -- index of the first record to be written in the target's segment.
record_count -- number of records to be written.
polynomials -- array of Chebyshev polynomial coefficients.
- Returns:
0 if an error occurs, otherwise non-zero value.
This function writes in parallel mode records of a type 102 segment (Chebyshev polynomials of the angle only ) in the time scale TCB to the PCK file associated to the ephemeris descriptor eph.
The reservation parameter must be the reservation id returned by the function writeph_pck102_par_reserve().
The target_index parameter is the index of the target in the targets array that was passed to the function writeph_pck102_par_reserve().
The record_begin_index parameter is the index of the first record to be written in the target's segment.
The record_count parameter is the number of records to be written starting from the record_begin_index.
The polynomials array must have the following structure :
E1's 1st coef 1st record. |
... |
E1's (deg + 1)th coef 1st record. |
E2's 1st coef 1st record. |
... |
E2's (deg + 1)th coef 1st record. |
E3's 1st coef 1st record. |
... |
E3's (deg + 1)th coef 1st record. |
... |
... |
... |
... |
... |
... |
... |
... |
... |
E1's 1st coef (record_count)th record |
... |
E1's (deg + 1)th coef (record_count)th record |
E2's 1st coef (record_count)th record |
... |
E2's (deg + 1)th coef (record_count)th record |
E3's 1st coef (record_count)th record |
... |
E3's (deg + 1)th coef (record_count)th record |
With the 1st record being the record at index record_begin_index, and the (record_count)th record being the record at index record_begin_index + record_count - 1.
Multiple threads can call this function at the same time, but with different values of target_index and/or record_begin_index. The behavior is undefined if multiple threads overlap the written data : e.g., two threads write to the same target target_index and a common record number.
writeph_pck103_seq_write
-
int writeph_pck103_seq_write(t_writephbin *eph, int target, int frame, double start_jd0_tcb, double start_frac_tcb, double end_jd0_tcb, double end_frac_tcb, double intlen_jd_tcb, const double *polynomials, int record_count, int deg, const char *segid)
- Parameters:
eph -- ephemeris descriptor
target -- The body or reference point whose coordinates will be written (see NAIF identification numbers).
frame -- reference frame (see Frame numbers).
start_jd0_tcb -- starting Julian date integer part (TCB).
start_frac_tcb -- starting Julian date fraction part (TCB).
end_jd0_tcb -- stop Julian date integer part (TCB).
end_frac_tcb -- stop Julian date fraction part (TCB).
intlen_jd_tcb -- length of the interpolation interval (in days, TCB).
polynomials -- array of Chebyshev polynomial coefficients.
record_count -- number of records to be written.
deg -- degree of the Chebyshev polynomials.
segid -- segment identifier (must be unique within the file, max 40 characters).
- Returns:
0 if an error occurs, otherwise non-zero value.
This function writes in sequential mode a type 103 segment (Chebyshev polynomials of the angles and their derivatives ) in the time scale TCB to the PCK file associated to the ephemeris descriptor eph.
The polynomials array must be of size record_count*(deg+1)*6 and have the following structure :
E1's 1st coef 1st record |
... |
E1's (deg + 1)th coef 1st record |
E2's 1st coef 1st record |
... |
E2's (deg + 1)th coef 1st record |
E3's 1st coef 1st record |
... |
E3's (deg + 1)th coef 1st record |
dE1's 1st coef 1st record |
... |
dE1's (deg + 1)th coef 1st record |
dE2's 1st coef 1st record |
... |
dE2's (deg + 1)th coef 1st record |
dE3's 1st coef 1st record |
... |
dE3's (deg + 1)th coef 1st record |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
E1's 1st coef (record_count)th record |
... |
E1's (deg + 1)th coef (record_count)th record |
E2's 1st coef (record_count)th record |
... |
E2's (deg + 1)th coef (record_count)th record |
E3's 1st coef (record_count)th record |
... |
E3's (deg + 1)th coef (record_count)th record |
dE1's 1st coef (record_count)th record |
... |
dE1's (deg + 1)th coef (record_count)th record |
dE2's 1st coef (record_count)th record |
... |
dE2's (deg + 1)th coef (record_count)th record |
dE3's 1st coef (record_count)th record |
... |
dE3's (deg + 1)th coef (record_count)th record |
The following example creates a new ephemeris file ephemeris.bsp with segment of type 3 for the orientation of one body, in the timescale TCB.
t_writephbin *weph;
const char segid[] = "seg_planet";
weph = writeph_pck_create("ephemeris.bpc","planet_2", 0);
if (weph)
{
int len_timespan = 32; /* days */
int frame = 1; /* ICRF */
int record_count = 10;
int degree = 12;
double jd_start = 2460000;
double jd_end = jd_start+record_count*len_timespan;
double coefs[780]; /* size = 10*13*6 = record_count * (degree+1) * 6 components */
for (int k=0; k<record_count; k++)
{
double jd_startk = jd_start+k*len_timespan;
double jd_endk = jd_start+(k+1)*len_timespan;
/* ... fill the array coefs with the coefficients of the Chebychev polynomials ...
coefs[..] =...
*/
}
writeph_pck103_seq_write(weph, 4000099, frame, jd_start, 0.0, jd_end, 0.0,
len_timespan, coefs, record_count, degree+1, segid);
writeph_close(weph);
}
writeph_pck103_par_reserve
-
int writeph_pck103_par_reserve(t_writephbin *eph, int target_count, const int *targets, int frame, double start_jd0_tcb, double start_frac_tcb, double end_jd0_tcb, double end_frac_tcb, const double *intlens_jd_tcb, const int *record_counts, int deg, const char *segids[])
- Parameters:
eph -- ephemeris descriptor
target_count -- number of targets the reservation is done for.
targets -- array of bodies or reference points whose coordinates will be written (see NAIF identification numbers).
frame -- reference frame (see Frame numbers).
start_jd0_tcb -- starting Julian date integer part (TCB).
start_frac_tcb -- starting Julian date fraction part (TCB).
end_jd0_tcb -- stop Julian date integer part (TCB).
end_frac_tcb -- stop Julian date fraction part (TCB).
intlens_jd_tcb -- array containing the interpolation interval length for each target (in days, TCB).
record_counts -- array of number of records for each target.
deg -- degree of the Chebyshev polynomials.
segids -- array of segment identifiers (one per target, each must be unique within the file, max 40 characters).
- Returns:
return a reservation identifier on success, 0 on failure.
This function is meant to enable the parallel writing (with multiple threads) of several type 103 segments (Chebyshev polynomials of the angles and their derivatives ) in the time scale TCB to the PCK file associated to the ephemeris descriptor eph.
It reserves space in the file for target_count segments, each segment associated to a target in the targets array. Each target has its own interpolation interval length specified in the intlens_jd_tcb array, its own number of records specified in the record_counts array, and its own segment identifier specified in the segids array. All the targets share the same frame, start_..._tcb, end_..._tcb and deg parameters.
The array targets, intlens_jd_tcb, record_counts and segids must be of size target_count.
The reservation id returned by this function must be used in the function writeph_pck103_par_write() to write in the corresponding reserved space.
In addition, the function writeph_pck103_par_write() will require a target_index, which is the index of the target in the targets array used in this function.
A call to writeph_pck103_par_reserve is always performed by a single thread and is followed by several calls to writeph_pck103_par_write() by one or several threads.
Warning
The data covers the same timespan from the date start_jd_tcb+start_frac_tcb to end_jd_tcb+end_frac_tcb for all targets, but each target may have a different number of polynomials.
The time span record_counts*intlens_jd_tcb must be equal to the timespan defined from the date start_jd_tcb+start_frac_tcb to end_jd_tcb+end_frac_tcb.
If the targets doesnot have the timespan, multiple reservations must be performed before the call to writing writeph_pck103_par_write().
The following example creates a new ephemeris file ephemeris.bsp with segment of type 103 for the heliocentric coordinates of Mercury and Venus, in the timescale TCB, using OpenMP.
t_writephbin *weph;
weph = writeph_pck_create("ephemeris.bpc","planet_2", 0);
if (weph)
{
int frame = 1; /* ICRF */
int degree = 12;
int target_count = 2;
int targets[2] = { 3000099, 4000099 };
int records_count[2] = { 10, 20 };
int len_timespan[2] = { 32, 16 };
const char segids[2] = { "seg_body1", "seg_body2" };
double jd_start = 2460000;
double jd_end = 2460000+32*10;
int reservation;
reservation = writeph_pck103_seq_reserve(weph, target_count, targets,
frame, jd_start, 0.0, jd_end, 0.0,
len_timespan, record_counts, degree+1, segids);
#pragma omp parallel for
for (int body = 0; body<target_count; body++)
{
#pragma omp parallel for
for (int k=0; k<records_count[body]; k++)
{
double coefs[78]; /* size = 13*6 = (degree+1) * 6 components */
double jd_startk = jd_start+k*len_timespan[body];
double jd_endk = jd_start+(k+1)*len_timespan[body];
/* ... fill the array coefs with the coefficients of the Chebychev polynomials ...
coefs[..] =...
*/
ret = writeph_pck103_par_write(weph, reservation, body, k, 1, coefs);
}
}
writeph_close(weph);
}
writeph_pck103_par_write
-
int writeph_pck103_par_write(t_writephbin *eph, int reservation, int target_index, int record_begin_index, int record_count, const double *polynomials)
- Parameters:
eph -- ephemeris descriptor
reservation -- reservation identifier.
target_index -- index of the target body in the reservation.
record_begin_index -- index of the first record to be written in the target's segment.
record_count -- number of records to be written.
polynomials -- array of Chebyshev polynomial coefficients.
- Returns:
0 if an error occurs, otherwise non-zero value.
This function writes in parallel mode records of a type 103 segment (Chebyshev polynomials of the angles and their derivatives ) in the time scale TCB to the PCK file associated to the ephemeris descriptor eph.
The reservation parameter must be the reservation id returned by the function writeph_pck3_par_reserve().
The target_index parameter is the index of the target in the targets array that was passed to the function writeph_pck3_par_reserve(), starting from 0.
The record_begin_index parameter is the index of the first record to be written in the target's segment, starting from 0.
The record_count parameter is the number of records to be written starting from the record_begin_index.
The polynomials array must be of size record_count*(deg+1)*6 and have the following structure :
E1's 1st coef 1st record |
... |
E1's (deg + 1)th coef 1st record |
E2's 1st coef 1st record |
... |
E2's (deg + 1)th coef 1st record |
E3's 1st coef 1st record |
... |
E3's (deg + 1)th coef 1st record |
dE1's 1st coef 1st record |
... |
dE1's (deg + 1)th coef 1st record |
dE2's 1st coef 1st record |
... |
dE2's (deg + 1)th coef 1st record |
dE3's 1st coef 1st record |
... |
dE3's (deg + 1)th coef 1st record |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
... |
E1's 1st coef (record_count)th record |
... |
E1's (deg + 1)th coef (record_count)th record |
E2's 1st coef (record_count)th record |
... |
E2's (deg + 1)th coef (record_count)th record |
E3's 1st coef (record_count)th record |
... |
E3's (deg + 1)th coef (record_count)th record |
dE1's 1st coef (record_count)th record |
... |
dE1's (deg + 1)th coef (record_count)th record |
dE2's 1st coef (record_count)th record |
... |
dE2's (deg + 1)th coef (record_count)th record |
dE3's 1st coef (record_count)th record |
... |
dE3's (deg + 1)th coef (record_count)th record |
With the 1st record being the record at index record_begin_index, and the (record_count)th record being the record at index record_begin_index + record_count - 1.
Multiple threads can call this function at the same time, but with different values of target_index and/or record_begin_index. The behavior is undefined if multiple threads overlap the written data : e.g., two threads write to the same target target_index and a common record number.