14 #define s_per_day 24 * 60 * 60
15 #define ms_per_day s_per_day * 1000
24 void asap_int2_(int32_t *nstp,
double *tsap,
double *asap,
double *pos_erri,
25 int32_t *ngps,
double *gpsec,
double *vecs,
float *pos_erro);
54 en_msec = (gattr->end_day != gattr->start_day) ?
55 gattr->end_msec +
ms_per_day : gattr->end_msec;
56 if (
get_orb_dat(gattr->start_year, gattr->start_day, gattr->start_msec,
63 int_orb_dat(orb, gattr->scan_lines, l1_data->msec, l1_data->orb_vec,
98 int i,
jd, st_min, en_min, ix_interp, ix_tim;
100 int nrec0,
nrec1,
nrec2, year0, year1, year2, day0, day1, day2;
101 double *orb0, *orb1, *orb2, *tmin0, *tmin1, *tmin2;
102 float *pos_err0, *pos_err1, *pos_err2;
109 for (
i = 0;
i < 4;
i++)
116 if ((floc = getenv(
"OCDATAROOT")) ==
NULL) {
117 printf(
"%s: environment variable OCDATAROOT undefined\n", __FILE__);
120 strcat(floc,
"/czcs/nav/");
126 "%s: Primary Nimbus 7 orbit file: %s\nwas not found but should exist\n",
141 st_min = (st_msec + 6000000) / (1000 * 60) - 100;
142 en_min = ((en_msec + 59999) / 1000) / 60;
147 if (*(tmin1) > st_min) {
152 if (
rd_smmr_orb(fname, &nrec0, &year0, &day0, &orb0, &tmin0,
155 if ((st_min - (*(tmin0 + nrec0 - 1) - 1440)) > gap_lim) {
157 orb->flag[ ix_interp ] = -1;
159 orb->flag[ ix_interp ] = 1;
160 orb->sec[ ix_interp ] = *(tmin0 + nrec0 - 1) - 1440;
161 orb->pos_err[ ix_interp ] = *(pos_err0 + nrec0 - 1);
162 for (
i = 0;
i < 3;
i++) {
163 orb->pos[ix_interp][
i] = *(orb0 + (nrec0 - 1) * 6 +
i);
164 orb->vel[ix_interp][
i] = *(orb0 + (nrec0 - 1) * 6 + 3 +
i);
183 while ((*(tmin1 + ix_tim) < (en_min + gap_lim)) &&
184 (ix_tim <
nrec1) && (ix_interp < 4)) {
185 if (*(tmin1 + ix_tim) >= st_min - gap_lim) {
187 if ((ix_interp > 0) && *(tmin1 + ix_tim) <= st_min)
189 orb->flag[ ix_interp ] = 1;
190 orb->sec[ ix_interp ] = *(tmin1 + ix_tim);
191 orb->pos_err[ ix_interp ] = *(pos_err1 + ix_tim);
192 for (
i = 0;
i < 3;
i++) {
193 orb->pos[ix_interp][
i] = *(orb1 + ix_tim * 6 +
i);
194 orb->vel[ix_interp][
i] = *(orb1 + ix_tim * 6 + 3 +
i);
210 if (*(tmin1 +
nrec1 - 1) <= en_min) {
215 if ((*tmin2 + 1440 - en_min) <= gap_lim) {
217 while (((*(tmin2 + ix_tim) + 1440) < (en_min + gap_lim)) &&
218 (ix_tim <
nrec2) && (ix_interp < 4)) {
219 if ((*(tmin2 + ix_tim) + 1440) >= st_min) {
220 orb->flag[ ix_interp ] = 1;
221 orb->sec[ ix_interp ] = *(tmin2 + ix_tim) + 1440;
222 orb->pos_err[ ix_interp ] = *(pos_err2 + ix_tim);
223 for (
i = 0;
i < 3;
i++) {
224 orb->pos[ix_interp][
i] = *(orb2 + ix_tim * 6 +
i);
225 orb->vel[ix_interp][
i] = *(orb2 + ix_tim * 6 + 3 +
i);
242 orb->n_good = ix_interp;
247 for (
i = 0;
i < 4;
i++) {
248 orb->sec[
i] = orb->sec[
i] * 60.;
290 double *sec, asap[24], *lcl_orb;
299 start_sec = *
msec / 1000 - 1;
301 if ((sec = (
double *) malloc(nlines *
sizeof (
double))) ==
NULL) {
302 printf(
"%s: malloc failed for seconds array\n", __FILE__);
305 if ((lcl_orb = (
double *) malloc(nlines * 6 *
sizeof (
double))) ==
NULL) {
306 printf(
"%s: malloc failed for lcl_orb array\n", __FILE__);
309 for (
i = 0;
i < nlines;
i++) {
310 *(sec +
i) = (
double) *(
msec +
i) / 1000.;
311 if (*(sec +
i) < start_sec)
319 if (orb.n_good <= 1) {
320 for (
i = 0;
i < nlines;
i++) {
328 for (
i = 0;
i < orb.n_good;
i++) {
329 for (
j = 0;
j < 3;
j++) {
330 *(asap +
j +
i * 6) = orb.pos[
i][
j];
331 *(asap +
j + 3 +
i * 6) = orb.vel[
i][
j];
337 asap_int2_(&(orb.n_good), orb.sec, asap, orb.pos_err, &nlines,
342 for (
i = 0;
i < nlines;
i++) {
343 for (
j = 0;
j < 3;
j++) {
344 *(orb_vec +
j + 3 *
i) = *(lcl_orb +
j + 6 *
i);