Changeset 5716
- Timestamp:
- Dec 6, 2005, 4:13:40 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/astro/tst_psEarthOrientation.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/astro/tst_psEarthOrientation.c
r5657 r5716 5 5 * @author d-Rob, MHPCC 6 6 * 7 * @version $Revision: 1.1 8$ $Name: not supported by cvs2svn $8 * @date $Date: 2005-12-0 2 04:40:00 $7 * @version $Revision: 1.19 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2005-12-07 02:13:40 $ 9 9 * 10 10 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 18 18 static psS32 testGravityDeflect(void); 19 19 static psS32 testEOCPrecession(void); 20 static psS32 testEOCPrecessionCorr(void); 20 21 static psS32 testEOCPolar(void); 21 22 static psS32 testEOCNutation(void); … … 28 29 {testGravityDeflect, 667, "psGravityDeflect()", 0, false}, 29 30 {testEOCPrecession, 669, "psEOCPrecession()", 0, false}, 30 {testEOCPolar, 670, "psEOCPolar()", 0, false}, 31 {testEOCNutation, 671, "psEOCNutation()", 0, false}, 32 {testSphereRot_TEOtoCEO, 672, "psSphereRot_TEOtoCEO()", 0, false}, 33 {testSphereRot_CEOtoGCRS, 673, "psSphereRot_CEOtoGCRS()", 0, false}, 34 {testSphereRot_ITRStoTEO, 674, "psSphereRRot_ITRStoTEO()", 0, false}, 31 {testEOCPrecessionCorr, 670, "psEOCPrecessionCorr()", 0, false}, 32 {testEOCPolar, 671, "psEOCPolar()", 0, false}, 33 {testEOCNutation, 672, "psEOCNutation()", 0, false}, 34 {testSphereRot_TEOtoCEO, 673, "psSphereRot_TEOtoCEO()", 0, false}, 35 {testSphereRot_CEOtoGCRS, 674, "psSphereRot_CEOtoGCRS()", 0, false}, 36 {testSphereRot_ITRStoTEO, 675, "psSphereRRot_ITRStoTEO()", 0, false}, 35 37 {NULL} 36 38 }; … … 257 259 return 3; 258 260 } else { 259 printf("Precession Model output = x,y,s = %.8g, %.8g, %.8g\n",260 pmodel->x, pmodel->y, pmodel->s);261 261 double x, y, s; 262 262 x = 2.857175590089105e-4; 263 263 y = 2.3968739377734732e-5; 264 264 s = -1.3970066457904322e-8; 265 printf("Expected output = x,y,s = %.13g, %.13g, %.13g\n\n", x, y, s); 265 if ( fabs(pmodel->x - x) > DBL_EPSILON || fabs(pmodel->y - y) > DBL_EPSILON 266 || fabs(pmodel->s - s) > DBL_EPSILON) { 267 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 268 " psEOC_PrecessionModel return incorrect values.\n"); 269 printf("\n Precession Model output = x,y,s = %.8g, %.8g, %.8g\n", 270 pmodel->x, pmodel->y, pmodel->s); 271 printf(" Expected output = x,y,s = %.13g, %.13g, %.13g\n", x, y, s); 272 printf(" A difference of: %.13g, %.13g, %.13g\n\n", 273 (pmodel->x - x), (pmodel->y - y), (pmodel->s - s) ); 274 return 4; 275 } 266 276 } 267 277 psFree(pmodel); 268 278 279 psFree(time); 280 if (!p_psEOCFinalize() ) { 281 psError(PS_ERR_BAD_PARAMETER_VALUE, false, "EOC failed finalization!\n"); 282 return 12; 283 } 284 285 return 0; 286 } 287 288 psS32 testEOCPrecessionCorr(void) 289 { 290 psTime *empty = NULL; 291 psTime *time2 = psTimeAlloc(PS_TIME_UTC); 292 time2->sec = timesec; 293 time2->nsec = 0; 294 time2->leapsecond = false; 295 269 296 //XXX: MAY Be an Error here... Time for Precession Correction has to be TAI or seg faults 270 psTime *time2 = psTimeAlloc(PS_TIME_UTC);271 *time2 = *time;272 297 time2 = psTimeConvert(time2, PS_TIME_TAI); 273 298 //Tests for Precession Correction function// … … 278 303 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 279 304 "psEOC_PrecessionCorr failed to return NULL for NULL time input.\n"); 280 return 4;305 return 5; 281 306 } 282 307 … … 286 311 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 287 312 "psEOC_PrecessionCorr failed to return NULL for incorrect IERS table.\n"); 288 return 5;313 return 6; 289 314 } 290 315 psFree(pcorr); … … 295 320 psError(PS_ERR_BAD_PARAMETER_NULL, false, 296 321 "psEOC_PrecessionCorr returned NULL for valid inputs.\n"); 297 return 6;322 return 7; 298 323 } else { 299 printf(" Precession Correction output (IERSA) = x,y,s = %.8g, %.8g, %.8g\n",324 printf("\nPrecession Correction output (IERSA) = x,y,s = %.13g, %.13g, %.13g\n\n", 300 325 pcorr->x, pcorr->y, pcorr->s); 301 326 } … … 307 332 psError(PS_ERR_BAD_PARAMETER_NULL, false, 308 333 "psEOC_PrecessionCorr returned NULL for valid inputs.\n"); 309 return 7;334 return 9; 310 335 } else { 311 printf("Precession Correction output (IERSB) = x,y,s = %.8g, %.8g, %.8g\n",312 pcorr->x, pcorr->y, pcorr->s);313 336 double xx, yy, ss; 314 337 xx = 0.06295703125; 315 338 yy = -0.0287618408203125; 316 339 ss = 0.0; 317 printf("Expected output = x,y,s = %.13g, %.13g, %.13g\n\n", xx, yy, ss); 318 } 340 if ( fabs(pcorr->x - xx) > DBL_EPSILON || fabs(pcorr->y - yy) > DBL_EPSILON 341 || fabs(pcorr->s - ss) > DBL_EPSILON) { 342 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 343 " psEOC_PrecessionCorr return incorrect values.\n"); 344 printf("\nPrecession Correction output (IERSB) = x,y,s = %.13g, %.13g, %.13g\n", 345 pcorr->x, pcorr->y, pcorr->s); 346 printf("Expected output = x,y,s = %.13g, %.13g, %.13g\n\n", xx, yy, ss); 347 printf(" A difference of: %.13g, %.13g, %.13g\n\n", 348 (pcorr->x - xx), (pcorr->y - yy), (pcorr->s - ss) ); 349 return 10; 350 } 351 } 352 319 353 psFree(pcorr); 320 354 321 psFree(time);322 355 psFree(time2); 323 356 if (!p_psEOCFinalize() ) { … … 355 388 return 2; 356 389 } 357 358 psEarthPole *polarMotion = NULL;359 polarMotion = psEOC_GetPolarMotion(empty, PS_IERS_B);360 if (polarMotion != NULL) {361 psError(PS_ERR_BAD_PARAMETER_VALUE, false,362 "psEOC_GetPolarMotion failed to return NULL for NULL input time.\n");363 return 3;364 }365 polarMotion = psEOC_GetPolarMotion(in, PS_IERS_B);366 if (polarMotion == NULL) {367 psError(PS_ERR_BAD_PARAMETER_NULL, false,368 "psEOC_GetPolarMotion returned NULL for valid input time.\n");369 return 4;370 }371 390 psTime *in2 = psTimeAlloc(PS_TIME_UTC); 372 391 in2->sec = timesec; … … 375 394 in2 = psTimeConvert(in2, PS_TIME_TAI); 376 395 psSphere *interm = p_psTimeGetPoleCoords(in2); 396 printf("\n Polar Tide Corrections \n"); 377 397 printf(" -- sphere = r=%.8g, d=%.8g\n", interm->r, interm->d); 378 398 printf(" -- Eop = x=%.8g, y=%.8g, s=%.8g\n", eop->x, eop->y, eop->s); 399 400 psEarthPole *polarMotion = NULL; 401 polarMotion = psEOC_GetPolarMotion(empty, PS_IERS_B); 402 if (polarMotion != NULL) { 403 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 404 "psEOC_GetPolarMotion failed to return NULL for NULL input time.\n"); 405 return 3; 406 } 407 polarMotion = psEOC_GetPolarMotion(in, PS_IERS_B); 408 if (polarMotion == NULL) { 409 psError(PS_ERR_BAD_PARAMETER_NULL, false, 410 "psEOC_GetPolarMotion returned NULL for valid input time.\n"); 411 return 4; 412 } 379 413 380 414 … … 384 418 return 5; 385 419 } 386 printf("\n -- PolarMotion = x=%.13g, y=%.13g, s=%.13g\n", polarMotion->x,420 printf("\n -- PolarMotion = x=%.13g, y=%.13g, s=%.13g\n", polarMotion->x, 387 421 polarMotion->y, polarMotion->s); 388 printf(" -- NutationCorr = x,y,s = %.13g, %.13g, %.13g\n", nutationCorr->x, 422 double sum; 423 sum = sqrt(nutationCorr->x*nutationCorr->x + nutationCorr->y*nutationCorr->y + nutationCorr->s*nutationCorr->s); 424 nutationCorr->x = nutationCorr->x / sum; 425 nutationCorr->y = nutationCorr->y / sum; 426 nutationCorr->s = nutationCorr->s / sum; 427 printf(" -- NutationCorr = x,y,s = %.13g, %.13g, %.13g\n\n", nutationCorr->x, 389 428 nutationCorr->y, nutationCorr->s); 390 429 polarMotion->x += nutationCorr->x; 391 430 polarMotion->y += nutationCorr->y; 392 431 polarMotion->s += nutationCorr->s; 393 printf("\n -- Output Earthpole = x,y,s = %.13g, %.13g, %.13g\n", polarMotion->x,394 polarMotion->y, polarMotion->s);395 432 double x,y,s; 396 433 x = -0.13275353774074533; 397 434 y = 0.4359436319739848; 398 435 s = -4.2376965863576153e-10; 399 printf(" -- Expected Earthpole = x,y,s = %.13g, %.13g, %.13g\n", x, y, s); 436 437 if ( fabs(polarMotion->x - x) > DBL_EPSILON || fabs(polarMotion->y - y) > DBL_EPSILON 438 || fabs(polarMotion->s - s) > DBL_EPSILON) { 439 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 440 " psEOC_GetPolarMotion returned incorrect values.\n"); 441 442 443 printf("\n Precession Correction output (IERSB) = x,y,s = %.13g, %.13g, %.13g\n", 444 polarMotion->x, polarMotion->y, polarMotion->s); 445 printf(" Expected output = x,y,s = %.13g, %.13g, %.13g\n", x, y, s); 446 printf(" A difference of: %.13g, %.13g, %.13g\n\n", 447 (polarMotion->x - x), (polarMotion->y - y), (polarMotion->s - s) ); 448 return 10; 449 } 400 450 401 451 if (!p_psEOCFinalize() ) { … … 564 614 return 2; 565 615 } 566 printf("Output sphere rotation = %.13g,%.13g,%.13g,%.13g\n", 567 rot->q0, rot->q1, rot->q2, rot->q3); 568 printf("Expected sphere rotation = %.13g,%.13g,%.13g,%.13g\n", q0,q1,q2,q3); 616 617 if (fabs(rot->q0-q0) > DBL_EPSILON || fabs(rot->q1-q1) > DBL_EPSILON || 618 fabs(rot->q2-q2) > DBL_EPSILON || fabs(rot->q3-q3) > DBL_EPSILON) { 619 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 620 "psSphereRot_CEOtoGCRS failed to return expected values.\n"); 621 printf("\n Output sphere rotation = %.13g,%.13g,%.13g,%.13g\n", 622 rot->q0, rot->q1, rot->q2, rot->q3); 623 printf(" Expected sphere rotation = %.13g,%.13g,%.13g,%.13g\n", q0,q1,q2,q3); 624 printf(" a difference: %.13g, %.13g, %.13g, %.13g \n", (rot->q0-q0), (rot->q1-q1), 625 (rot->q2-q2), (rot->q3-q3) ); 626 printf(" abs difference: %.13g, %.13g, %.13g, %.13g \n\n", (rot->q0+q0), (rot->q1+q1), 627 (rot->q2+q2), (rot->q3+q3) ); 628 return 3; 629 } 569 630 570 631 psSphere *test = psSphereAlloc(); … … 606 667 return 2; 607 668 } 608 printf("Output sphere rotation = %.13g,%.13g,%.13g,%.13g\n", 609 rot->q0, rot->q1, rot->q2, rot->q3); 669 610 670 double q0,q1,q2,q3; 611 671 q0 = -1.0567571848664005e-6; … … 613 673 q2 = -3.3580195807204483e-12; 614 674 q3 = -0.9999999999993899; 615 printf("Expected sphere rotation = %.13g,%.13g,%.13g,%.13g\n", q0,q1,q2,q3); 675 if (fabs(rot->q0-q0) > DBL_EPSILON || fabs(rot->q1-q1) > DBL_EPSILON || 676 fabs(rot->q2-q2) > DBL_EPSILON || fabs(rot->q3-q3) > DBL_EPSILON) { 677 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 678 "psSphereRot_ITRStoTEO failed to return expected values.\n"); 679 printf("\n Output sphere rotation = %.13g,%.13g,%.13g,%.13g\n", 680 rot->q0, rot->q1, rot->q2, rot->q3); 681 printf(" Expected sphere rotation = %.13g,%.13g,%.13g,%.13g\n", q0,q1,q2,q3); 682 printf(" a difference: %.13g, %.13g, %.13g, %.13g \n", (rot->q0-q0), (rot->q1-q1), 683 (rot->q2-q2), (rot->q3-q3) ); 684 return 3; 685 } 616 686 617 687 psSphere *test = psSphereAlloc();
Note:
See TracChangeset
for help on using the changeset viewer.
