12 PGSt_double
const frame_time[],
175 enum {SUN_AT_SD, SUN_AT_EV, MOON_AT_SV, NUM_TIMES};
196 double sunSD[3] = {0.0};
198 double moonecr[3] = {0.0};
199 double mooninst[3] = {0.0};
200 double T_sc2ecr[NUM_TIMES][3][3] = {0.0};
201 double T_inst2ecr[NUM_TIMES][3][3] = {0.0};
203 PGSt_double sunecr[3] = {0.0};
204 PGSt_double moon_vector[1][3] = {0.0};
205 PGSt_double sun_vector[2][3] = {0.0};
206 PGSt_double toff[NUM_TIMES] = {0.0};
207 PGSt_double tveci[NUM_TIMES][6] = {0.0};
209 PGSt_double tvecr[NUM_TIMES][6] = {0.0};
211 PGSt_double positionECR[NUM_TIMES][3], velocityECR[NUM_TIMES][3];
212 PGSt_SMF_status PGS_error_code = PGS_S_SUCCESS;
213 int ecr, eci, inst, sc, sd;
214 PGSt_SMF_status retval=PGS_S_SUCCESS;
217 uint32 sample_quality[NUM_TIMES][2];
218 char msgbuf[PGS_SMF_MAX_MSGBUF_SIZE] =
"";
219 static char filefunc[] = __FILE__
", GEO_solar_and_lunar_vectors";
221 if (frame_data ==
NULL || geo_params ==
NULL || fill_values==
NULL ||
222 cb_vectors ==
NULL || frame_time ==
NULL)
225 "frame_data = %p, geo_params = %p, fill_values=%p, cb_vectors = %p"
226 "frame_time = %p", (
void*)frame_data, (
void*)geo_params,
227 (
void*)fill_values, (
void*)cb_vectors, (
void*)frame_time);
232 *cb_vectors = empty_cb;
250 toff[SUN_AT_EV] = frame_time[frame_data->
EV_frames/2];
264 geo_params, CCSDS_EV_start, sc_state, T_sc2ecr, T_inst2ecr, positionECR,
265 velocityECR, rpy, sample_quality);
266 if (PGS_error_code != PGS_S_SUCCESS) {
267 sprintf(msgbuf,
"GEO_interp_ECR(%.3f)", frame_data->
EV_start);
272 if (sc_state[SUN_AT_EV].position[0] < PGSd_GEO_ERROR_VALUE)
274 cb_vectors->
sc.
time = (float64)sc_state[SUN_AT_EV].
time;
275 for (ecr=0; ecr<3; ecr++)
278 (float64)positionECR[SUN_AT_EV][ecr];
280 (float64)velocityECR[SUN_AT_EV][ecr];
282 (float64)sc_state[SUN_AT_EV].eulerAngles[ecr];
283 for (inst=0; inst<3; inst++)
285 (float64)T_inst2ecr[SUN_AT_EV][ecr][inst];
290 if (positionECR[SUN_AT_EV][0] < PGSd_GEO_ERROR_VALUE ||
291 positionECR[SUN_AT_SD][0] < PGSd_GEO_ERROR_VALUE)
293 PGS_error_code = PGS_CBP_Earth_CB_Vector(2, CCSDS_EV_start, toff,
294 PGSd_SUN, sun_vector);
295 if (PGS_error_code != PGS_S_SUCCESS) {
296 sprintf(msgbuf,
"PGS_CBP_Earth_CB_Vector(%s, SUN)", CCSDS_EV_start);
309 memcpy(tveci[SUN_AT_SD], sun_vector[SUN_AT_SD],
310 sizeof(sun_vector[SUN_AT_SD]));
311 memcpy(tveci[SUN_AT_EV], sun_vector[SUN_AT_EV],
312 sizeof(sun_vector[SUN_AT_EV]));
315 PGS_CSC_ECItoECR(2, CCSDS_EV_start, toff, tveci, tvecr);
316 if (PGS_error_code != PGS_S_SUCCESS &&
317 PGS_error_code != PGSCSC_W_PREDICTED_UT1)
319 sprintf(msgbuf,
"PGS_CSC_ECItoECR(%s, SUN)", CCSDS_EV_start);
325 if(positionECR[SUN_AT_EV][0] < PGSd_GEO_ERROR_VALUE &&
326 tvecr[SUN_AT_EV][0] < PGSd_GEO_ERROR_VALUE &&
329 for(ecr=0; ecr<3; ecr++)
330 sunecr[ecr] = (
double)tvecr[SUN_AT_EV][ecr];
335 modsmf(
MODIS_E_GEO,
"GEO_vec_unit3(sun_unit_vector)",
343 if(positionECR[SUN_AT_SD][0] < PGSd_GEO_ERROR_VALUE &&
344 tvecr[SUN_AT_SD][0] < PGSd_GEO_ERROR_VALUE)
346 for(ecr=0; ecr<3; ecr++)
347 sunecr[ecr] = (
double)tvecr[SUN_AT_SD][ecr];
353 for (sc=0; sc<3; sc++)
356 for (ecr=0; ecr<3; ecr++)
358 T_sc2ecr[SUN_AT_SD][ecr][sc] * sunecr[ecr];
366 for (sd=0; sd<3; sd++)
369 for (sc=0; sc<3; sc++)
378 sqrt(sunSD[0] * sunSD[0] + sunSD[1] * sunSD[1]));
387 PGS_error_code = PGS_CBP_Earth_CB_Vector(1, CCSDS_EV_start, &toff[MOON_AT_SV],
388 PGSd_MOON, moon_vector);
389 if (PGS_error_code != PGS_S_SUCCESS) {
390 sprintf(msgbuf,
"PGS_CBP_Earth_CB_Vector(%s, MOON)", CCSDS_EV_start);
396 for (eci = 0; eci < 3; eci++)
397 tveci[MOON_AT_SV][eci] =
398 moon_vector[0][eci] - sc_state[MOON_AT_SV].position[eci];
400 PGS_error_code = PGS_CSC_ECItoECR(1, CCSDS_EV_start, toff+MOON_AT_SV,
401 tveci+MOON_AT_SV, tvecr+MOON_AT_SV);
402 if (PGS_error_code != PGS_S_SUCCESS &&
403 PGS_error_code != PGSCSC_W_PREDICTED_UT1 && (
404 tvecr[MOON_AT_SV][0] >= PGSd_GEO_ERROR_VALUE ||
405 tvecr[MOON_AT_SV][1] >= PGSd_GEO_ERROR_VALUE ||
406 tvecr[MOON_AT_SV][2] >= PGSd_GEO_ERROR_VALUE))
408 sprintf(msgbuf,
"PGS_CSC_ECItoECR(%s, MOON)", CCSDS_EV_start);
414 for(ecr=0; ecr<3; ecr++)
415 moonecr[ecr] = (
double)tvecr[MOON_AT_SV][ecr];
420 for(inst=0; inst<3; inst++) {
421 mooninst[inst] = 0.0;
422 for (ecr=0; ecr<3; ecr++)
423 mooninst[inst] += T_inst2ecr[MOON_AT_SV][ecr][inst] * moonecr[ecr];
427 modsmf(
MODIS_E_GEO,
"GEO_vec_unit3(moon_unit_vector)", filefunc);