Changeset 5657
- Timestamp:
- Dec 1, 2005, 6:40:00 PM (21 years ago)
- Location:
- trunk/psLib
- Files:
-
- 4 edited
-
src/astro/psEarthOrientation.c (modified) (5 diffs)
-
test/astro/tst_psEarthOrientation.c (modified) (7 diffs)
-
test/astro/verified/tst_psEarthOrientation.stderr (modified) (2 diffs)
-
test/astro/verified/tst_psEarthOrientation.stdout (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/astro/psEarthOrientation.c
r5642 r5657 8 8 * @author Robert Daniel DeSonia, MHPCC 9 9 * 10 * @version $Revision: 1.2 0$ $Name: not supported by cvs2svn $11 * @date $Date: 2005-1 1-30 23:50:40 $10 * @version $Revision: 1.21 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2005-12-02 04:40:00 $ 12 12 * 13 13 * Copyright 2005 Maui High Performance Computing Center, University of Hawaii … … 302 302 // calculating the apparent angle from the actual angle and the sun position 303 303 304 // first, calculate the angle between the sun vector and the actual vector305 306 // Moving to cartesian first: XXX -- is this required?307 304 psCube* sunVector = psSphereToCube(sun); 308 305 psCube* actualVector = psSphereToCube(actual); 309 printf("\n Actual sphere = %.13g, %.13g", actual->r, actual->d); 310 printf("\n Actual cube = %.13g, %.13g, %.13g \n", actualVector->x, actualVector->y, actualVector->z); 311 printf("\n SUN sphere = %.13g, %.13g", sun->r, sun->d); 312 printf("\n SUN cube = %.13g, %.13g, %.13g \n", sunVector->x, sunVector->y, sunVector->z); 313 psSphere *new = psCubeToSphere(actualVector); 314 printf(" New sphere = %.13g, %.13g", new->r, new->d); 315 psFree(new); 306 316 307 // use dot product to calculate the angle of separation 317 308 // N.B., assuming the psSphereToCube function returns a unit vector. … … 320 311 sunVector->y*actualVector->y + 321 312 sunVector->z*actualVector->z); 322 printf("\n Theta = %.13g ", theta);323 313 double r0 = PS_AU * tan(theta); 324 printf(" r0 = %.13g", r0);325 314 double deflection = 4.0*PS_G*PS_M/(PS_C0*PS_C0*r0); 326 printf(" deflection = %.13g \n", deflection); 315 327 316 // make sure the deflection is not greater than 1.75 arcsec 328 317 double limit = SEC_TO_RAD(1.75); … … 352 341 deflection = SEC_TO_RAD(deflection); 353 342 theta = atan(r0/PS_AU) * tan(deflection); 354 printf(" deflection = %.13g Theta=%.13g ", deflection, theta);355 343 // phi = sqrt( deflection*deflection - theta*theta ); 356 344 phi = deflection * cos(asin(theta/deflection)); 357 printf(" Phi = %.13g \n", phi);358 345 apparent->r = theta; 359 346 apparent->d = phi; … … 726 713 in = psTimeConvert(in, PS_TIME_UT1); 727 714 } 728 double T = (double)(in->sec) + (double)(in->nsec / 1e9);729 printf("\nThe Value of T is = %.19g\n", T);715 // double T = (double)(in->sec) + (double)(in->nsec / 1e9); 716 double T = psTimeToJD(in); 730 717 T += -2451545.0; 731 718 double theta = 2.0 * M_PI * (0.7790572732640 + 1.00273781191135448 * T); 732 p rintf("\nThe Value of theta is = %.13g\n", theta);719 psSphereRot *out = psSphereRotAlloc(theta, 0.0, 0.0); 733 720 // psSphereRot *out = psSphereRotInvert(theta, 0.0, 0.0); 734 psSphereRot *out = psSphereRotInvert(theta, 0.0, 0.0);735 721 736 722 psFree(in); -
trunk/psLib/test/astro/tst_psEarthOrientation.c
r5642 r5657 5 5 * @author d-Rob, MHPCC 6 6 * 7 * @version $Revision: 1.1 7$ $Name: not supported by cvs2svn $8 * @date $Date: 2005-1 1-30 23:50:40 $7 * @version $Revision: 1.18 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2005-12-02 04:40:00 $ 9 9 * 10 10 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 56 56 57 57 #define timesec 1049160600 58 #define objR DEG_TO_RAD(122.9153182445501) 59 #define objD DEG_TO_RAD(48.562968978679194) 60 static psSphere *obj = NULL; 61 static void objSetup(void); 62 63 static void objSetup(void) 64 { 65 if (obj == NULL) { 66 obj = psSphereAlloc(); 67 obj->r = objR; 68 obj->d = objD; 69 } 70 } 58 71 59 72 psS32 testAberration(void) … … 86 99 double speed = sqrt(cubeDir->x*cubeDir->x + cubeDir->y*cubeDir->y + cubeDir->z*cubeDir->z); 87 100 // Speed of light in vacuum (src:NIST) 88 double c; 89 c = 299792458.0; /* m/s */ 101 double c = 299792458.0; /* m/s */ 90 102 speed = speed / c; 91 103 … … 104 116 105 117 apparent = psAberration(apparent, actual, direction, speed); 106 if (apparent == NULL) 107 printf("\nApparent is NULL\n"); 108 else { 109 printf("\napparent = r,d = %.8g, %.8g\n", apparent->r, apparent->d); 110 psFree(cubeDir); 111 cubeDir = psSphereToCube(apparent); 112 printf(" ><><Apparent = x,y,z = %.13g, %.13g, %.13g \n", cubeDir->x, cubeDir->y, cubeDir->z); 113 } 118 119 printf("\nSphere Difference = r,d = %.13g, %.13g\n", 120 (actual->r - apparent->r), (actual->d - apparent->d)); 121 psCube *outCube = psSphereToCube(apparent); 122 printf(" -- resultCube = x,y,z = %.13g, %.13g, %.13g -- \n", 123 outCube->x, outCube->y, outCube->z); 124 125 double x, y, z; 126 x = -0.35963388069046304; 127 y = 0.5555192509816625; 128 z = 0.7497078321908413; 129 130 printf(" -- expectedCube = x,y,z = %.13g, %.13g, %.13g -- \n\n", x, y, z); 131 132 if ( fabs(x - outCube->x) > DBL_EPSILON || fabs(y - outCube->y) > DBL_EPSILON || 133 fabs(z - outCube->z) > DBL_EPSILON ) { 134 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 135 "psAberration returned incorrect values.\n"); 136 printf("Cube Difference = x,y,z = %.13g, %.13g, %.13g \n\n", 137 (x - outCube->x), (y - outCube->y), (z - outCube->z) ); 138 return 3; 139 } 140 141 psFree(outCube); 142 114 143 psFree(cubeDir); 115 144 psFree(apparent); … … 138 167 sunCube->y = 2.5880956908748722e10; 139 168 sunCube->z = 1.1220046291457653e10; 140 // double sum = sqrt(sunCube->x*sunCube->x + sunCube->y*sunCube->y + sunCube->z*sunCube->z);141 // sunCube->x = sunCube->x/sum;142 // sunCube->y = sunCube->y/sum;143 // sunCube->z = sunCube->z/sum;144 // printf("\n <<<<SUNvec = x,y,z = %.13g, %.13g %.13g", sunCube->x, sunCube->y, sunCube->z);145 169 psSphere *sun = psCubeToSphere(sunCube); 146 printf("\n <<<<SUN = r,d = %.13g, %.13g\n", sun->r, sun->d);147 170 148 171 empty = psGravityDeflection(apparent, empty, sun); … … 161 184 apparent = psGravityDeflection(NULL, actual, sun); 162 185 psSphere *result = psSphereSetOffset(actual, apparent, PS_SPHERICAL, PS_RADIAN); 186 163 187 printf("\nActual r,d = %.13g,%.13g Apparent r,d = %.16g, %.16g \n", 164 188 actual->r, actual->d, result->r, result->d); 189 printf("Sphere Difference = r,d = %.13g, %.13g\n", 190 (actual->r - result->r), (actual->d - result->d)); 165 191 psCube *outCube = psSphereToCube(result); 166 printf(" -- outCube = x,y,z = %.13g, %.13g, %.13g -- \n", outCube->x, outCube->y, outCube->z); 192 printf(" -- resultCube = x,y,z = %.13g, %.13g, %.13g -- \n", 193 outCube->x, outCube->y, outCube->z); 194 psCube *outCube2 = psSphereToCube(actual); 195 printf(" -- actualCube = x,y,z = %.13g, %.13g, %.13g -- \n", 196 outCube2->x, outCube2->y, outCube2->z); 197 198 double x, y, z; 199 x = -0.35961949760293604; 200 y = 0.5555613950298085; 201 z = 0.7496835020836093; 202 203 printf(" -- expectedCube = x,y,z = %.13g, %.13g, %.13g -- \n\n", x, y, z); 204 205 if ( fabs(x - outCube->x) > DBL_EPSILON || fabs(y - outCube->y) > DBL_EPSILON || 206 fabs(z - outCube->z) > DBL_EPSILON ) { 207 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 208 "psGravityDeflection returned incorrect values.\n"); 209 printf("Cube Difference = x,y,z = %.13g, %.13g, %.13g \n", 210 (x - outCube->x), (y - outCube->y), (z - outCube->z) ); 211 return 1; 212 } 213 167 214 psFree(outCube); 168 psCube *outCube2 = psSphereToCube(apparent);169 printf(" -- outCube = x,y,z = %.13g, %.13g, %.13g -- \n", outCube2->x, outCube2->y, outCube2->z);170 215 psFree(outCube2); 171 216 psFree(sunCube); … … 416 461 psS32 testSphereRot_TEOtoCEO(void) 417 462 { 463 psSphereRot *rot = NULL; 464 psTime *empty = NULL; 418 465 // psTime *now = psTimeAlloc(PS_TIME_UT1); 419 466 // now->sec = 1128530000; 420 467 // now->nsec = 931154510; 421 psTime *time = psTimeAlloc(PS_TIME_UT C);422 time->sec = timesec ;423 time->nsec = 0;468 psTime *time = psTimeAlloc(PS_TIME_UT1); 469 time->sec = timesec-1; 470 time->nsec = 657017200; 424 471 time->leapsecond = false; 472 425 473 // psSphereRot *teoceo = psSphereRot_TEOtoCEO(now); 474 475 //return NULL for NULL input time 476 rot = psSphereRot_TEOtoCEO(empty); 477 if (rot != NULL) { 478 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 479 "psSphereRot_TEOtoCEO failed to return NULL for NULL input time.\n"); 480 return 1; 481 } 482 426 483 psSphereRot *teoceo = psSphereRot_TEOtoCEO(time); 427 printf("Output sphere rotation = %lf,%lf,%lf,%lf\n", 484 //Make sure values match for other psTime type 485 empty = psTimeAlloc(PS_TIME_UTC); 486 empty->sec = timesec; 487 empty->nsec = 0; 488 empty->leapsecond = false; 489 rot = psSphereRot_TEOtoCEO(empty); 490 if (fabs(rot->q0-teoceo->q0) > DBL_EPSILON || fabs(rot->q1-teoceo->q1) > DBL_EPSILON || 491 fabs(rot->q2-teoceo->q2) > DBL_EPSILON || fabs(rot->q3-teoceo->q3) > DBL_EPSILON) { 492 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 493 "psSphereRot_TEOtoCEO failed to return matching values for different time types.\n"); 494 return 2; 495 } 496 printf("\nOutput sphere rotation = %.13g, %.13g, %.13g, %.13g\n\n", 428 497 teoceo->q0, teoceo->q1, teoceo->q2, teoceo->q3); 429 498 499 objSetup(); 500 psSphereRot *earthRot = psSphereRotConjugate(NULL, teoceo); 501 psSphere *result = psSphereRotApply(NULL, earthRot, obj); 502 // psCube *cube = psSphereToCube(obj); 503 psCube *cube = psSphereToCube(result); 504 505 506 double x, y, z; 507 x = 0.01698625430807123; 508 y = -0.6616523084626379; 509 z = 0.7496183628158023; 510 if ( fabs(x-cube->x) > DBL_EPSILON || fabs(y-cube->y) > DBL_EPSILON || 511 fabs(z-cube->z) > DBL_EPSILON) { 512 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 513 "psSphereRot_TEOtoCEO returned incorrect values.\n"); 514 printf("\nOutput cube = x,y,z = %.13g, %.13g, %.13g\n", 515 cube->x, cube->y, cube->z); 516 printf("Expected cube = x,y,z = %.13g, %.13g, %.13g\n", x, y, z); 517 printf("A difference of: %.13g, %.13g, %.13g\n\n", 518 (x-cube->x), (y-cube->y), (z-cube->z)); 519 return 3; 520 } 430 521 // psFree(now); 522 psFree(result); 523 psFree(obj); 524 psFree(earthRot); 525 psFree(cube); 431 526 psFree(time); 432 527 psFree(teoceo); -
trunk/psLib/test/astro/verified/tst_psEarthOrientation.stderr
r5533 r5657 9 9 <DATE><TIME>|<HOST>|E|psAberration (FILE:LINENO) 10 10 Unallowable operation: direction is NULL. 11 12 ---> TESTPOINT PASSED (psEarthOrientation{psAberration()} | tst_psEarthOrientation.c) 11 <DATE><TIME>|<HOST>|E|testAberration (FILE:LINENO) 12 psGravityDeflection returned incorrect values. 13 Return value mismatch: expected 0, got 3 14 ---> TESTPOINT FAILED (psEarthOrientation{psAberration()} | tst_psEarthOrientation.c) 13 15 14 16 /***************************** TESTPOINT ******************************************\ … … 99 101 ---> TESTPOINT PASSED (psEarthOrientation{psSphereRRot_ITRStoTEO()} | tst_psEarthOrientation.c) 100 102 103 <DATE><TIME>|<HOST>|E|p_runTestSuite (FILE:LINENO) 104 One or more tests failed -
trunk/psLib/test/astro/verified/tst_psEarthOrientation.stdout
r5642 r5657 1 1 2 apparent = r,d = 2.1452242, 0.84754694 3 ><><Apparent = x,y,z = -0.3596051297757, 0.5556035294057, 0.7496591683899 2 Sphere Difference = r,d = 5.284231132663e-05, 3.676277340525e-05 3 -- resultCube = x,y,z = -0.3596051297757, 0.5556035294057, 0.7496591683899 -- 4 -- expectedCube = x,y,z = -0.3596338806905, 0.5555192509817, 0.7497078321908 -- 4 5 5 <<<<SUN = r,d = 0.1745310859793, 0.0751383461293 6 Cube Difference = x,y,z = -2.87509148123e-05, -8.427842401337e-05, 4.866380096979e-05 6 7 7 Actual sphere = 2.145277004504, 0.84758370322188 Actual cube = -0.3596195125758, 0.5555613903456, 0.74968349837259 10 SUN sphere = 0.1745310859793, 0.075138346129311 SUN cube = 0.9820293796219, 0.1731564131522, 0.075067663768412 New sphere = 2.145277004504, 0.847583703221813 Theta = -0.2006809204081 r0 = -30431058247.35 deflection = -1.941413573621e-0714 deflection = -9.412238611831e-13 Theta=1.888856707723e-13 Phi = -9.220762225745e-1315 8 16 9 Actual r,d = 2.145277004504,0.8475837032218 Apparent r,d = 2.145277004504245, 0.8475837032208979 17 -- outCube = x,y,z = -0.3596195125763, 0.5555613903461, 0.7496834983719 -- 18 -- outCube = x,y,z = 1, 1.888856707723e-13, -9.220762225745e-13 -- 10 Sphere Difference = r,d = -1.887379141863e-13, 9.220402219512e-13 11 -- resultCube = x,y,z = -0.3596195125763, 0.5555613903461, 0.7496834983719 -- 12 -- actualCube = x,y,z = -0.3596195125758, 0.5555613903456, 0.7496834983725 -- 13 -- expectedCube = x,y,z = -0.3596194976029, 0.5555613950298, 0.7496835020836 -- 14 19 15 Precession Model output = x,y,s = 58931469, 4942375.1, -1.4563071e+14 20 16 Expected output = x,y,s = 0.0002857175590089, 2.396873937773e-05, -1.39700664579e-08 … … 35 31 36 32 37 The Value of T is = 1049160599.65700888633 The Value of T is = 2452730.562496030238 38 34 39 The Value of theta is = 6594672635.129 40 Output sphere rotation = 0.000000,0.000000,0.145165,0.989407 35 The Value of theta is = 7474.398075968 36 Output sphere rotation = 0, 0, 0.9625401009478, 0.2711393628144 37 Input cube = x,y,z = -0.3596195125758, 0.5555613903456, 0.7496834983725 38 Output cube = x,y,z = 0.5967271497347, -0.286166666538, 0.7496834983725 41 39 Output sphere rotation = 1.198437080989e-05,-0.0001428587808888,-6.985033157173e-09,0.9999999897239 42 40 Expected sphere rotation = -1.198452240676e-05,0.0001428589335861,1.219119351891e-10,-0.9999999897238
Note:
See TracChangeset
for help on using the changeset viewer.
