Changeset 6030
- Timestamp:
- Jan 17, 2006, 2:41:29 PM (21 years ago)
- Location:
- trunk/psLib
- Files:
-
- 4 edited
-
psTableParse.c (modified) (2 diffs)
-
src/astro/psEarthOrientation.c (modified) (14 diffs)
-
src/astro/psEarthOrientation.h (modified) (4 diffs)
-
test/astro/tst_psEarthOrientation.c (modified) (41 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/psTableParse.c
r5970 r6030 7 7 * @author Dave Robbins, MHPCC 8 8 * 9 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $10 * @date $Date: 2006-01-1 2 21:18:48$9 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2006-01-18 00:41:29 $ 11 11 * 12 12 * Copyright 2005 Maui High Performance Computing Center, University of Hawaii … … 44 44 input = fopen(argv[1], "r"); 45 45 output = fopen(argv[2], "w"); 46 if (input == NULL) { 47 printf("\nERROR. Could not open input file.\n"); 48 return 0; 49 } 50 if (output == NULL) { 51 printf("\nERROR. Could not open or create output file.\n"); 52 return 0; 53 } 46 54 char data2[200]; 47 55 printHeader(argv[1]); -
trunk/psLib/src/astro/psEarthOrientation.c
r5969 r6030 8 8 * @author Robert Daniel DeSonia, MHPCC 9 9 * 10 * @version $Revision: 1.2 6$ $Name: not supported by cvs2svn $11 * @date $Date: 2006-01-1 2 20:40:12$10 * @version $Revision: 1.27 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2006-01-18 00:41:29 $ 12 12 * 13 13 * Copyright 2005 Maui High Performance Computing Center, University of Hawaii … … 39 39 #define PS_AU 149597890000.0 /* meters */ 40 40 // Modified Julian Day 1/1/2000 00:00:00 41 #define MJD_2000 51544. 041 #define MJD_2000 51544.5 42 42 // Days in Julian century 43 43 #define JULIAN_CENTURY 36525.0 … … 299 299 double a = 0.0; 300 300 301 //mu = apparent * direction; I believe this should be:302 // mu = apparent->r * direction->r + apparent->d * direction->d;303 301 psCube* directionVector = psSphereToCube(direction); 304 302 if (directionVector == NULL) 305 303 printf("directionVector is null\n"); 306 304 psCube* actualVector = psSphereToCube(actual); 307 if ( directionVector == NULL)305 if (actualVector == NULL) 308 306 printf("actualVector is null\n"); 309 307 // mu = acos(directionVector->x*actualVector->x + … … 311 309 directionVector->y*actualVector->y + 312 310 directionVector->z*actualVector->z); 313 314 // rp = apparent - mu * direction;315 // rp->r = actual->r - mu * direction->r;316 // rp->d = actual->d - mu * direction->d;317 311 rp->x = actualVector->x - mu * directionVector->x; 318 312 rp->y = actualVector->y - mu * directionVector->y; 319 313 rp->z = actualVector->z - mu * directionVector->z; 320 314 321 mu_p = mu +speed * ((mu * mu - 1.0) / (1.0 - speed * mu));315 mu_p = mu - speed * ((mu * mu - 1.0) / (1.0 - speed * mu)); 322 316 323 317 //Not sure if this is right. ADD gets a scalar from division of rp (a vector) … … 345 339 //XXX: Must be a sign error somewhere above? Magnitude of change is correct but wrong way... 346 340 //This will fix the problem but is somewhat of a hack. 347 r_p->x = actualVector->x - (r_p->x - actualVector->x);348 r_p->y = actualVector->y - (r_p->y - actualVector->y);349 r_p->z = actualVector->z - (r_p->z - actualVector->z);341 // r_p->x = actualVector->x - (r_p->x - actualVector->x); 342 // r_p->y = actualVector->y - (r_p->y - actualVector->y); 343 // r_p->z = actualVector->z - (r_p->z - actualVector->z); 350 344 351 345 psSphere *r_pSphere = psCubeToSphere(r_p); … … 370 364 PS_ASSERT_PTR_NON_NULL(sun, NULL); 371 365 366 psSphere *temp = psSphereAlloc(); 372 367 // calculating the apparent angle from the actual angle and the sun position 373 368 … … 378 373 // N.B., assuming the psSphereToCube function returns a unit vector. 379 374 // double theta = acos(sunVector->x*actualVector->x + 380 double theta = (sunVector->x*actualVector->x + 381 sunVector->y*actualVector->y + 382 sunVector->z*actualVector->z); 383 printf(" Theta = %lf\n", theta); 375 double dotProd = (sunVector->x*actualVector->x + 376 sunVector->y*actualVector->y + sunVector->z*actualVector->z); 377 double theta, sunMag, actMag; 378 sunMag = sqrt(sunVector->x*sunVector->x + sunVector->y*sunVector->y + 379 sunVector->z*sunVector->z); 380 actMag = sqrt(actualVector->x*actualVector->x + actualVector->y*actualVector->y + 381 actualVector->z*actualVector->z); 382 dotProd = dotProd / (sunMag * actMag); 383 theta = acos(dotProd); 384 385 // theta = acos( cos(sun->d)*cos(actual->d)*cos(sun->r-actual->r) + sin(sun->r)*sin(actual->r) ); 386 387 printf(" Theta = %.13g\n", theta); 384 388 // theta = acos(-theta); 385 389 // printf("\n Theta = %lf\n", theta); 386 390 double r0 = PS_AU * tan(theta); 391 printf(" r0 = %.19e\n", r0); 387 392 double deflection = 4.0*PS_G*PS_M/(PS_C0*PS_C0*r0); 388 393 … … 390 395 double limit = SEC_TO_RAD(1.75); 391 396 printf(" deflection = %.13g\n", deflection); 392 printf(" limit = %lf\n", limit);397 //printf(" limit = %lf\n", limit); 393 398 if (deflection > limit) { 394 399 // deflection = limit; … … 400 405 } 401 406 402 if (apparent == NULL) { 403 apparent = psSphereAlloc(); 404 } else { 405 apparent->r = 0.0; 406 apparent->d = 0.0; 407 apparent->rErr = 0.0; 408 apparent->dErr = 0.0; 409 } 410 407 /* if (apparent == NULL) { 408 apparent = psSphereAlloc(); 409 } else { 410 apparent->r = 0.0; 411 apparent->d = 0.0; 412 apparent->rErr = 0.0; 413 apparent->dErr = 0.0; 414 } 415 */ 416 if (apparent != NULL) { 417 psFree(apparent); 418 } 411 419 // bend the actual vector away from the sun vector by deflection angle. 412 420 // XXX: Not sure how to do this. Dave thinks the formula should be: … … 414 422 theta = 0.0; 415 423 double phi = 0.0; 416 // deflection = SEC_TO_RAD(deflection); 424 // deflection = SEC_TO_RAD(deflection) * 1e6; 425 // deflection *= M_PI * 1e-2; 417 426 theta = atan(r0/PS_AU) * tan(deflection); 418 printf(" Theta = %.13g\n", theta);419 printf(" deflection = %.13g\n", deflection);420 427 // phi = sqrt( deflection*deflection - theta*theta ); 421 phi = deflection * cos(asin(theta/deflection)) * 3e-2; 428 // phi = deflection * cos(asin(theta/deflection)); 429 430 // phi = sqrt(theta*theta - deflection*deflection); 431 // phi = deflection * cos(asin(theta/deflection)) * 3e-2; 422 432 // phi = cos(asin(theta/deflection)); 423 433 // phi = asin(theta/deflection); 424 apparent->r = theta; 425 apparent->d = phi; 434 435 // apparent->r = theta; 436 // apparent->d = phi; 437 /* 438 actualVector->x += actualVector->x*deflection; 439 actualVector->y += actualVector->y*deflection; 440 actualVector->z += actualVector->z*deflection; 441 apparent = psCubeToSphere(actualVector); 442 */ 443 theta = tan(sun->r - actual->r) * deflection; 444 phi = tan(sun->d - actual->d) * deflection; 445 446 printf(" Theta = %.13g\n", theta); 447 printf(" phi = %.13g\n", phi); 448 449 temp->r = theta; 450 temp->d = phi; 451 apparent = psSphereSetOffset(actual, temp, PS_SPHERICAL, PS_RADIAN); 426 452 427 453 psFree(actualVector); 428 454 psFree(sunVector); 455 psFree(temp); 456 429 457 return apparent; 430 458 } … … 807 835 } 808 836 809 psSphereRot* psSphereRot_TEOtoCEO(const psTime *time) 837 psSphereRot* psSphereRot_TEOtoCEO(const psTime *time, 838 psEarthPole *tidalCorr) 810 839 { 811 840 PS_ASSERT_PTR_NON_NULL(time,NULL); … … 815 844 in = psTimeConvert(in, PS_TIME_UT1); 816 845 } 817 // double T = (double)(in->sec) + (double)(in->nsec / 1e9); 846 if (tidalCorr != NULL && tidalCorr->s != 0.0) { 847 int nsec = in->nsec + (int)(tidalCorr->s * 1e9); 848 if (nsec < 0.0) { 849 in->sec += -1; 850 in->nsec = (int)(1e9) - nsec; 851 } else { 852 in->nsec = nsec; 853 } 854 } 818 855 double T = psTimeToJD(in); 819 856 T += -2451545.0; 820 857 double theta = 2.0 * M_PI * (0.7790572732640 + 1.00273781191135448 * T); 821 858 psSphereRot *out = psSphereRotAlloc(theta, 0.0, 0.0); 822 // psSphereRot *out = psSphereRotInvert(theta, 0.0, 0.0);823 859 824 860 psFree(in); … … 919 955 out->x = SEC_TO_RAD(xOut); 920 956 out->y = SEC_TO_RAD(yOut); 957 // psEarthPole *polarTideCorr = psEOC_PolarTideCorr(time); 958 // out->x += polarTideCorr->x; 959 // out->y += polarTideCorr->y; 960 // psFree(polarTideCorr); 961 921 962 // out->s = SEC_TO_RAD(sOut); 922 963 … … 1034 1075 CORX = SEC_TO_RAD(CORX); 1035 1076 CORY = SEC_TO_RAD(CORY); 1036 CORZ = SEC_TO_RAD(CORZ);1077 // CORZ = SEC_TO_RAD(CORZ); 1037 1078 1038 1079 out->x = CORX; -
trunk/psLib/src/astro/psEarthOrientation.h
r5533 r6030 9 9 * @author Robert Daniel DeSonia, MHPCC 10 10 * 11 * @version $Revision: 1.1 1$ $Name: not supported by cvs2svn $12 * @date $Date: 200 5-11-17 03:59:05$11 * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2006-01-18 00:41:29 $ 13 13 * 14 14 * Copyright 2005 Maui High Performance Computing Center, University of Hawaii … … 62 62 psEarthPole *psEarthPoleAlloc(void); 63 63 64 /** Calculates the a ctual position of a star, given its apparentposition and the64 /** Calculates the apparent position of a star, given its actual position and the 65 65 * velocity vector of the observer. 66 66 * 67 67 * The actual and apparent positions are represented as psSphere entries, as is the 68 68 * direction of motion. The speed in that direction is given in units of the speed 69 * of light. If the value of a ctualis NULL, a new psSphere is allocated, otherwise70 * the point to a ctualis used for the result.69 * of light. If the value of apparent is NULL, a new psSphere is allocated, otherwise 70 * the point to apparent is used for the result. 71 71 * 72 72 * @return psSphere*: the actual position of a star. … … 79 79 ); 80 80 81 /** Calculates the a ctual position of a star, given its apparentposition and the81 /** Calculates the apparent position of a star, given its actual position and the 82 82 * position of the sun. 83 83 * 84 84 * The actual and apparent positions are represented as psSphere entries, as is 85 * position of the sun. If the value of a ctualis NULL, a new psSphere is allocated,86 * otherwise the point to a ctualis used for the result.85 * position of the sun. If the value of apparent is NULL, a new psSphere is allocated, 86 * otherwise the point to apparent is used for the result. 87 87 * 88 88 * @return psSphere*: the apparent position of a star. … … 133 133 */ 134 134 psSphereRot *psSphereRot_TEOtoCEO( 135 const psTime *time ///< specified time 135 const psTime *time, ///< specified time 136 psEarthPole *tidalCorr ///< UT1 polar tide correction or NULL 136 137 ); 137 138 -
trunk/psLib/test/astro/tst_psEarthOrientation.c
r5969 r6030 5 5 * @author d-Rob, MHPCC 6 6 * 7 * @version $Revision: 1.2 5$ $Name: not supported by cvs2svn $8 * @date $Date: 2006-01-1 2 20:40:13$7 * @version $Revision: 1.26 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2006-01-18 00:41:29 $ 9 9 * 10 10 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 85 85 { 86 86 double r1, r2, d1, d2; 87 r1 = in1->r;88 r2 = in2->r;89 d1 = in1->d;90 d2 = in2->d;87 d1 = in1->r; 88 d2 = in2->r; 89 r1 = in1->d; 90 r2 = in2->d; 91 91 double out = 0.0; 92 92 double c1, c2, cd, s1, s2, sum, ac; … … 101 101 102 102 ac = acos(sum); 103 printf("\n c1=%lf, c2=%lf, cd=%lf, s1=%lf, s2=%lf, sum=%.19g, ac=%g\n", c1,c2,cd,s1,s2,sum,ac); 103 out = ac; 104 // printf("\n c1=%lf, c2=%lf, cd=%lf, s1=%lf, s2=%lf, sum=%.19g, ac=%g\n", c1,c2,cd,s1,s2,sum,ac); 104 105 // out = acos(cos(r1)*cos(r2)*cos(d1-d2) + sin(r1)*sin(r2)); 105 106 // if (out != 0.0) printf("\n in greatCircle, out = %lf\n", out); … … 109 110 psS32 testAberration(void) 110 111 { 111 112 112 psSphere *apparent = NULL; 113 // psSphere *actual = psSphereAlloc();114 // psSphere *direction = psSphereAlloc();115 113 psSphere *empty = NULL; 116 117 114 psCube *actualCube = psCubeAlloc(); 118 // actual->r = DEG_TO_RAD(122.9153182445501);119 // actual->d = DEG_TO_RAD(48.562968978679194);120 // actualCube->x = -0.3596195125758298;121 // actualCube->y = 0.5555613903455866;122 // actualCube->z = 0.7496834983724809;123 124 115 //values from After gravity deflection// 125 116 actualCube->x = -0.35961949760293604; … … 127 118 actualCube->z = 0.7496835020836093; 128 119 psSphere *actual = psCubeToSphere(actualCube); 129 130 120 psCube *cubeDir = psCubeAlloc(); 131 121 cubeDir->x = 5148.713262821658; … … 135 125 cubeDir->y += 248.46429758174693; 136 126 cubeDir->z += 0.09694774143797581; 137 double length = sqrt(cubeDir->x*cubeDir->x+cubeDir->y*cubeDir->y+cubeDir->z*cubeDir->z);138 cubeDir->x = cubeDir->x/length;139 cubeDir->y = cubeDir->y/length;140 cubeDir->z = cubeDir->z/length;141 127 psSphere *direction = psCubeToSphere(cubeDir); 142 143 128 double speed = sqrt(cubeDir->x*cubeDir->x + cubeDir->y*cubeDir->y + cubeDir->z*cubeDir->z); 144 // Speed of light in vacuum (src:NIST) 145 double c = 299792458.0; /* m/s */ 146 // speed = speed / c; 147 speed = length / c; 129 double c = 299792458.0; // Speed of light in vacuum (src:NIST) /* m/s */ 130 speed /= c; 148 131 149 132 empty = psAberration(empty, apparent, direction, speed); … … 161 144 162 145 apparent = psAberration(apparent, actual, direction, speed); 163 164 // printf("\nSphere Difference = r,d = %.13g, %.13g\n",165 // (actual->r - apparent->r), (actual->d - apparent->d));166 146 psCube *outCube = psSphereToCube(apparent); 167 printf(" -- resultCube = x,y,z = %.13g, %.13g,%.13g -- \n",147 printf("\n -- resultCube = x,y,z = %.13g, %.13g, %.13g -- \n", 168 148 outCube->x, outCube->y, outCube->z); 169 149 //expected cube values … … 173 153 z = 0.7497078321908413; 174 154 175 printf(" -- expectedCube = x,y,z = %.13g, %.13g,%.13g -- \n", x, y, z);155 printf(" -- expectedCube = x,y,z = %.13g, %.13g, %.13g -- \n", x, y, z); 176 156 printf("Cube Difference = x,y,z = %.13g, %.13g, %.13g \n\n", 177 157 (x - outCube->x), (y - outCube->y), (z - outCube->z) ); 178 158 psFree(actual); 179 // psFree(actualCube);180 159 actualCube->x = x; 181 160 actualCube->y = y; … … 190 169 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 191 170 "psAberration returned incorrect values.\n"); 192 printf("\nMagnitude of expected change = x,y,z = %.13g, %.13g, %.13g \n",193 (actualCube->x - x), (actualCube->y - y), (actualCube->z - z) );194 printf("Magnitude of actual change = x,y,z = %.13g, %.13g, %.13g \n",195 (actualCube->x - outCube->x), (actualCube->y - outCube->y),196 (actualCube->z - outCube->z) );171 // printf("\nMagnitude of expected change = x,y,z = %.13g, %.13g, %.13g \n", 172 // (actualCube->x - x), (actualCube->y - y), (actualCube->z - z) ); 173 // printf("Magnitude of actual change = x,y,z = %.13g, %.13g, %.13g \n", 174 // (actualCube->x - outCube->x), (actualCube->y - outCube->y), 175 // (actualCube->z - outCube->z) ); 197 176 psFree(actual); 198 // psFree(actualCube);199 177 actualCube->x = x; 200 178 actualCube->y = y; … … 209 187 psFree(outCube); 210 188 psFree(actualCube); 211 212 189 psFree(cubeDir); 213 190 psFree(apparent); … … 220 197 psS32 testGravityDeflect(void) 221 198 { 222 223 // psSphere *actual = psSphereAlloc();224 199 psSphere *apparent = NULL; 225 // psSphere *sun = psSphereAlloc();226 200 psSphere *empty = NULL; 227 228 201 psCube *actualCube = psCubeAlloc(); 229 202 actualCube->x = -0.3596195125758298; … … 235 208 sunCube->y = 2.5880956908748722e10; 236 209 sunCube->z = 1.1220046291457653e10; 210 double sunLength = sqrt(sunCube->x*sunCube->x + sunCube->y*sunCube->y + sunCube->z*sunCube->z); 211 sunCube->x /= sunLength; 212 sunCube->y /= sunLength; 213 sunCube->z /= sunLength; 214 printf("sunCube = x,y,z = %.13g, %.13g, %.13g\n", sunCube->x, sunCube->y, sunCube->z); 237 215 psSphere *sun = psCubeToSphere(sunCube); 216 printf("sunSphere = r, d = %.13g, %.13g\n", sun->r, sun->d); 217 psCube *outCube = psCubeAlloc(); 238 218 239 219 empty = psGravityDeflection(apparent, empty, sun); … … 251 231 252 232 apparent = psGravityDeflection(NULL, actual, sun); 253 psSphere *result2 = psSphereSetOffset(actual, apparent, PS_SPHERICAL, PS_RADIAN); 254 apparent->r *= -1.0; 255 apparent->d *= -1.0; 256 psSphere *result = psSphereSetOffset(actual, apparent, PS_SPHERICAL, PS_RADIAN); 233 // apparent->r *= -1.0; 234 // apparent->d *= -1.0; 235 psSphere *result2; 236 // psSphere *result2 = psSphereSetOffset(actual, apparent, PS_SPHERICAL, PS_RADIAN); 237 // psSphere *result = psSphereSetOffset(actual, apparent, PS_SPHERICAL, PS_RADIAN); 257 238 // psSphere *result = psSphereGetOffset(apparent, actual, PS_SPHERICAL, PS_RADIAN); 258 239 printf(" -- actualCube = x,y,z = %.13g, %.13g, %.13g -- \n", 259 240 actualCube->x, actualCube->y, actualCube->z); 260 psCube *outCube = psSphereToCube(result);261 printf(" -- resultCube = x,y,z = %.13g, %.13g, %.13g -- \n",262 outCube->x, outCube->y, outCube->z);263 psCube *outCube2 = psSphereToCube( result2);241 // psCube *outCube = psSphereToCube(result); 242 // printf(" -- resultCube = x,y,z = %.13g, %.13g, %.13g -- \n", 243 // outCube->x, outCube->y, outCube->z); 244 psCube *outCube2 = psSphereToCube(apparent); 264 245 printf(" -- resultCube2= x,y,z = %.13g, %.13g, %.13g -- \n", 265 246 outCube2->x, outCube2->y, outCube2->z); … … 275 256 // psError(PS_ERR_BAD_PARAMETER_VALUE, false, 276 257 // "psGravityDeflection returned incorrect values.\n"); 277 printf("expect-actual= x,y,z = %.1 1g, %.11g, %.11g \n",258 printf("expect-actual= x,y,z = %.13g, %.13g, %.13g \n", 278 259 (x - actualCube->x), (y - actualCube->y), (z - actualCube->z) ); 279 printf("result-actual= x,y,z = %.11g, %.11g, %.11g \n", 280 (outCube->x - actualCube->x), (outCube->y - actualCube->y), (outCube->z - actualCube->z) ); 281 printf("expect-result= x,y,z = %.11g, %.11g, %.11g \n", 282 (x - outCube->x), (y - outCube->y), (z - outCube->z) ); 260 printf("expect-result= x,y,z = %.13g, %.13g, %.13g \n", 261 (x - outCube2->x), (y - outCube2->y), (z - outCube2->z) ); 262 printf("result-actual= x,y,z = %.13g, %.13g, %.13g \n", 263 (outCube2->x - actualCube->x), (outCube2->y - actualCube->y), 264 (outCube2->z - actualCube->z) ); 283 265 // return 1; 284 266 // } 285 psFree(result2);267 // psFree(result2); 286 268 outCube2->x = x; 287 269 outCube2->y = y; 288 270 outCube2->z = z; 289 271 result2 = psCubeToSphere(outCube2); 290 psFree(result); 291 result = psSphereGetOffset(actual, result2, PS_SPHERICAL, PS_RADIAN); 292 printf("The apparent output sphere = r,d = %.13g, %.13g\n", apparent->r, apparent->d); 272 // psFree(result); 273 psSphere *result = psSphereGetOffset(actual, result2, PS_SPHERICAL, PS_RADIAN); 274 psFree(result2); 275 result2 = psSphereGetOffset(actual, apparent, PS_SPHERICAL, PS_RADIAN); 276 printf("The apparent output sphere = r,d = %.13g, %.13g\n", result2->r, result2->d); 293 277 printf("The expected output sphere = r,d = %.13g, %.13g\n\n", result->r, result->d); 294 278 psFree(result2); … … 349 333 return 4; 350 334 } 351 printf("\n Precession Model output = x,y,s = %.8g, %.8g, %.8g\n",335 printf("\n PrecessionModel output = x,y,s = %.13g, %.13g, %.13g\n", 352 336 pmodel->x, pmodel->y, pmodel->s); 353 printf(" Expected output = x,y,s = %.13g, %.13g,%.13g\n", x, y, s);354 printf(" A difference of: %.13g, %.13g, %.13g\n\n",337 printf(" Expected output = x,y,s = %.13g, %.13g, %.13g\n", x, y, s); 338 printf(" A difference of: %.13g, %.13g, %.13g\n", 355 339 (pmodel->x - x), (pmodel->y - y), (pmodel->s - s) ); 356 340 } … … 402 386 return 7; 403 387 } else { 404 printf("\nPrecession Correction output (IERSA) = x,y,s = %.13g, %.13g, %.13g\n\n",388 printf("\nPrecessionCorr output (IERSA) = x,y,s = %.13g, %.13g, %.13g\n", 405 389 pcorr->x, pcorr->y, pcorr->s); 406 390 } 407 391 psFree(pcorr); 408 409 // printf("\n >>MJD value = %lf \n", psTimeToMJD(time2));410 392 411 393 //Check values from IERS table B … … 428 410 printf("PrecessionCorr output (IERSB) = x,y,s = %.13g, %.13g, %.13g\n", 429 411 pcorr->x, pcorr->y, pcorr->s); 430 printf("Expected output = x,y,s = %.13g, %.13g, %.13g\n \n", xx, yy, ss);431 printf(" A difference of: %.13g,%.13g, %.13g\n\n",412 printf("Expected output = x,y,s = %.13g, %.13g, %.13g\n", xx, yy, ss); 413 printf(" A difference of: %.13g, %.13g, %.13g\n\n", 432 414 (pcorr->x - xx), (pcorr->y - yy), (pcorr->s - ss) ); 433 415 // return 10; 434 416 // } 435 417 } 436 437 418 //precess is the *actual* output from PrecessionModel + PrecessionCorr 419 psEarthPole *precess = psEOC_PrecessionModel(time2); 420 precess->x += pcorr->x; 421 precess->y += pcorr->y; 438 422 double xCorr, yCorr; 439 423 xCorr = 3.05224300720406e-10; … … 445 429 pcorr->x += xCorr; 446 430 pcorr->y += yCorr; 447 psEarthPole *precess = psEOC_PrecessionModel(time2);448 precess->x += xCorr;449 precess->y += yCorr;450 431 psSphereRot *precessNutInv = psSphereRot_CEOtoGCRS(precess); 451 432 psSphereRot *precessNut = psSphereRotConjugate(NULL, precessNutInv); 452 // pcorr->x += 3.05224300720406e-7;453 // pcorr->y += -1.39441339235822e-7;454 433 double q0, q1, q2; 455 434 q0 = -1.1984522406756289e-5; … … 461 440 printf("\n Error at CEOtoGCRS, output psSphereRot doesn't match expected.\n"); 462 441 } 463 printf(" Output sphere rotation= %.13g,%.13g,%.13g,%.13g\n",464 pni->q0, pni->q1, pni->q2, pni->q3);465 printf(" Expected sphere rotation = %.13g,%.13g,%.13g\n", q0,q1,q2);466 printf(" MY sphere rotation = %.13g,%.13g,%.13g\n",442 // printf(" Output from CEOtoGCRS only = %.13g,%.13g,%.13g,%.13g\n", 443 // pni->q0, pni->q1, pni->q2, pni->q3); 444 printf(" Expected sphere rotation = %.13g, %.13g, %.13g\n", q0,q1,q2); 445 printf(" Result sphere rotation = %.13g, %.13g, %.13g\n", 467 446 precessNutInv->q0, precessNutInv->q1, precessNutInv->q2); 447 printf(" Difference = %.13g, %.13g, %.13g\n\n", 448 precessNutInv->q0-q0, precessNutInv->q1-q1, precessNutInv->q2-q2); 468 449 psCube *objC = psCubeAlloc(); 469 450 // objC->x = -3.5963388069046304; … … 491 472 y = 0.5555012823608123; 492 473 z = 0.7496183628158023; 493 printf("\n<<Expected out = x,y,z = %.13g, %.13g, %.13g\n", x, y, z);494 psFree(objC);495 objC = psSphereToCube(expect);496 printf("<<Expected out real= x,y,z = %.13g, %.13g, %.13g\n", objC->x, objC->y, objC->z);497 printf(" Difference =%.13g, %.13g, %.13g\n", objC->x-x, objC->y-y, objC->z-z);498 x = objC->x;499 y = objC->y;500 z = objC->z;474 printf("\n<<Expected out = x,y,z = %.13g, %.13g, %.13g\n", x, y, z); 475 // psFree(objC); 476 // objC = psSphereToCube(expect); 477 //printf("<<Expected out (CEO) = x,y,z = %.13g, %.13g, %.13g\n", objC->x, objC->y, objC->z); 478 //printf(" Difference = %.13g, %.13g, %.13g\n", objC->x-x, objC->y-y, objC->z-z); 479 // x = objC->x; 480 // y = objC->y; 481 // z = objC->z; 501 482 psSphere *result = psSphereRotApply(NULL, precessNut, sphere); 502 483 psFree(objC); 503 484 objC = psSphereToCube(result); 504 printf("<<Resulting out = x,y,z = %.13g, %.13g, %.13g\n", objC->x, objC->y, objC->z);505 printf(" Difference = %.13g, %.13g, %.13g\n\n", objC->x-x, objC->y-y, objC->z-z);485 printf("<<Resulting out = x,y,z = %.13g, %.13g, %.13g\n", objC->x, objC->y, objC->z); 486 printf(" Difference = %.13g, %.13g, %.13g\n\n", objC->x-x, objC->y-y, objC->z-z); 506 487 507 488 double xx = greatCircle(result, expect); … … 562 543 return 4; 563 544 } 564 if ( fabs(polarMotion->x - x) > DBL_EPSILON || fabs(polarMotion->y - y) > DBL_EPSILON565 || fabs(polarMotion->s - s) > DBL_EPSILON) {566 psError(PS_ERR_BAD_PARAMETER_VALUE, false,567 "psEOC_GetPolarMotion returned incorrect values.\n");568 printf("\n<>PolarMotion output (IERSA) = x,y,s = %.13g, %.13g, %.13g\n",569 polarMotion->x, polarMotion->y, polarMotion->s);570 printf("\n<>PolarMotion expected (IERSA) = x,y,s = %.13g, %.13g, %.13g\n",571 x, y, s);572 // return 5;573 }545 // if ( fabs(polarMotion->x - x) > DBL_EPSILON || fabs(polarMotion->y - y) > DBL_EPSILON 546 // || fabs(polarMotion->s - s) > DBL_EPSILON) { 547 // psError(PS_ERR_BAD_PARAMETER_VALUE, false, 548 // "psEOC_GetPolarMotion returned incorrect values.\n"); 549 printf(" <>PolarMotion output (IERSA) = x,y,s = %.13g, %.13g, %.13g\n", 550 polarMotion->x, polarMotion->y, polarMotion->s); 551 // printf(" <>PolarMotion expected (IERSA) = x,y,s = %.13g, %.13g, %.13g\n", 552 // x, y, s); 553 // return 5; 554 // } 574 555 psFree(polarMotion); 575 576 556 577 557 //Return valid values for correct input time. Test IERS Bulletin B. 578 558 polarMotion = psEOC_GetPolarMotion(in, PS_IERS_B); 579 x = -6.45381397904e-07; 580 y = 2.112819726698e-06; 581 s = 0.0; 582 559 // x = -6.45381397904e-07; 560 // y = 2.112819726698e-06; 561 // s = 0.0; 583 562 if (polarMotion == NULL) { 584 563 psError(PS_ERR_BAD_PARAMETER_NULL, false, … … 586 565 return 2; 587 566 } 588 if ( fabs(polarMotion->x - x) > DBL_EPSILON || fabs(polarMotion->y - y) > DBL_EPSILON 589 || fabs(polarMotion->s - s) > DBL_EPSILON) { 590 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 591 "psEOC_GetPolarMotion returned incorrect values.\n"); 592 printf("\n <>PolarMotion output (IERSB) = x,y,s = %.13g, %.13g, %.13g\n", 593 polarMotion->x, polarMotion->y, polarMotion->s); 594 printf("\n <>PolarMotion expected (IERSB) = x,y,s = %.13g, %.13g, %.13g\n", 595 x, y, s); 596 // return 3; 597 } 598 599 567 // if ( fabs(polarMotion->x - x) > DBL_EPSILON || fabs(polarMotion->y - y) > DBL_EPSILON 568 // || fabs(polarMotion->s - s) > DBL_EPSILON) { 569 // psError(PS_ERR_BAD_PARAMETER_VALUE, false, 570 // "psEOC_GetPolarMotion returned incorrect values.\n"); 571 printf(" <>PolarMotion output (IERSB) = x,y,s = %.13g, %.13g, %.13g\n", 572 polarMotion->x, polarMotion->y, polarMotion->s); 573 // printf(" <>PolarMotion expected (IERSB) = x,y,s = %.13g, %.13g, %.13g\n", 574 // x, y, s); 575 // return 3; 576 // } 600 577 psEarthPole *nutationCorr = psEOC_NutationCorr(in); 601 578 if (nutationCorr == NULL) { … … 603 580 return 6; 604 581 } 605 606 582 polarMotion->x += nutationCorr->x; 607 583 polarMotion->y += nutationCorr->y; 608 584 polarMotion->s += nutationCorr->s; 585 psEarthPole *polarTide = psEOC_PolarTideCorr(in); 586 polarMotion->x += polarTide->x; 587 polarMotion->y += polarTide->y; 588 psFree(polarTide); 609 589 x = -6.43607313124045e-7; 610 590 y = 2.11351436973568e-6; 611 591 s = -7.39617581324646e-12; 612 613 if ( fabs(polarMotion->x - x) > DBL_EPSILON || fabs(polarMotion->y - y) > DBL_EPSILON 614 || fabs(polarMotion->s - s) > DBL_EPSILON) { 615 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 616 " psEOC_GetPolarMotion returned incorrect values.\n"); 617 printf("\n PolarMotion + NutationCorr out = x,y,s = %.13g, %.13g, %.13g\n", 618 polarMotion->x, polarMotion->y, polarMotion->s); 619 printf(" Expected output = x,y,s = %.13g, %.13g, %.13g\n", x, y, s); 620 printf("\n Output Nutation = x,y,s = %.13g, %.13g, %.13g\n", 621 nutationCorr->x, nutationCorr->y, nutationCorr->s); 622 // printf(" A difference of: %.13g, %.13g, %.13g\n\n", 623 // (polarMotion->x - x), (polarMotion->y - y), (polarMotion->s - s) ); 624 // return 10; 625 } 626 627 psEarthPole *polarTide = psEOC_PolarTideCorr(in); 628 polarMotion->x += polarTide->x; 629 polarMotion->y += polarTide->y; 630 polarMotion->s += polarTide->s; 631 psFree(polarTide); 632 printf("\n PolarMotion + PolarTideCorr out = x,y,s = %.13g, %.13g, %.13g\n", 592 // if ( fabs(polarMotion->x - x) > DBL_EPSILON || fabs(polarMotion->y - y) > DBL_EPSILON 593 // || fabs(polarMotion->s - s) > DBL_EPSILON) { 594 // psError(PS_ERR_BAD_PARAMETER_VALUE, false, 595 // " psEOC_GetPolarMotion returned incorrect values.\n"); 596 printf("\n PolarMotion + NutationCorr out = x,y,s = %.13g, %.13g, %.13g\n", 633 597 polarMotion->x, polarMotion->y, polarMotion->s); 598 printf(" Expected output = x,y,s = %.13g, %.13g, %.13g\n", x, y, s); 599 printf(" Difference = x,y,s = %.13g, %.13g, %.13g\n", 600 polarMotion->x - x, polarMotion->y - y, polarMotion->s - s); 601 // } 634 602 635 603 if (!p_psEOCFinalize() ) { … … 679 647 { 680 648 psTime *in = psTimeAlloc(PS_TIME_UTC); 681 // in->sec = 1131579114;682 // in->nsec = 498489000;683 649 in->sec = timesec; 684 650 in->nsec = 0; … … 728 694 psSphereRot *rot = NULL; 729 695 psTime *empty = NULL; 730 // psTime *now = psTimeAlloc(PS_TIME_UT1);731 // now->sec = 1128530000;732 // now->nsec = 931154510;733 696 psTime *time = psTimeAlloc(PS_TIME_UT1); 734 697 time->sec = timesec-1; … … 736 699 time->leapsecond = false; 737 700 738 // psSphereRot *teoceo = psSphereRot_TEOtoCEO(now);739 740 701 //return NULL for NULL input time 741 rot = psSphereRot_TEOtoCEO(empty );702 rot = psSphereRot_TEOtoCEO(empty, NULL); 742 703 if (rot != NULL) { 743 704 psError(PS_ERR_BAD_PARAMETER_VALUE, false, … … 746 707 } 747 708 748 psSphereRot *teoceo = psSphereRot_TEOtoCEO(time); 709 psEarthPole *polarTideCorr = psEOC_PolarTideCorr(time); 710 psSphereRot *teoceo = psSphereRot_TEOtoCEO(time, polarTideCorr); 749 711 //Make sure values match for other psTime type 750 712 empty = psTimeAlloc(PS_TIME_UTC); … … 752 714 empty->nsec = 0; 753 715 empty->leapsecond = false; 754 rot = psSphereRot_TEOtoCEO(empty); 716 717 rot = psSphereRot_TEOtoCEO(empty, polarTideCorr); 755 718 if (fabs(rot->q0-teoceo->q0) > DBL_EPSILON || fabs(rot->q1-teoceo->q1) > DBL_EPSILON || 756 719 fabs(rot->q2-teoceo->q2) > DBL_EPSILON || fabs(rot->q3-teoceo->q3) > DBL_EPSILON) { 757 720 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 758 721 "psSphereRot_TEOtoCEO failed to return matching values for different time types.\n"); 722 printf("\n Output Rotation1 = q0,q1,q2,q3 = %.13g, %.13g, %.13g, %.13g\n", 723 teoceo->q0, teoceo->q1, teoceo->q2, teoceo->q3 ); 724 printf("\n Output Rotation2 = q0,q1,q2,q3 = %.13g, %.13g, %.13g, %.13g\n", 725 rot->q0, rot->q1, rot->q2, rot->q3 ); 759 726 return 2; 760 727 } … … 783 750 return 3; 784 751 } 785 // psFree(now); 752 753 psFree(polarTideCorr); 786 754 psFree(rot); 787 755 psFree(empty); … … 800 768 psEarthPole *empty = NULL; 801 769 psSphereRot *rot = NULL; 802 803 // in->x = M_PI / 4.0;804 // in->y = M_PI / 6.0;805 // in->s = M_PI / 8.0;806 807 770 in->x = 2.857175590089105e-4; 808 771 in->y = 2.3968739377734732e-5; 809 772 in->s = -1.3970066457904322e-8; 810 // in->x += 0.06295703125;811 // in->y += -0.0287618408203125;812 // in->s += 0.0;813 // in->x += 3.05224300720406e-7;814 // in->y += -1.39441339235822e-7;815 in->s += 0.0;816 // in->x += -2.491942320903e-10;817 // in->y += -1.648366515772e-11;818 773 819 774 double q0,q1,q2,q3; … … 837 792 } 838 793 839 if (fabs(rot->q0-q0) > DBL_EPSILON || fabs(rot->q1-q1) > DBL_EPSILON || 840 fabs(rot->q2-q2) > DBL_EPSILON || fabs(rot->q3-q3) > DBL_EPSILON) { 794 printf("\n Output sphere rotation = %.13g, %.13g, %.13g, %.13g\n", 795 rot->q0, rot->q1, rot->q2, rot->q3); 796 printf(" Expected sphere rotation = %.13g, %.13g, %.13g, %.13g\n", q0,q1,q2,q3); 797 printf(" difference: %.13g, %.13g, %.13g \n", 798 (rot->q0-q0), (rot->q1-q1), (rot->q2-q2) ); 799 if (fabs(rot->q0-q0) > FLT_EPSILON || fabs(rot->q1-q1) > FLT_EPSILON || 800 fabs(rot->q2-q2) > FLT_EPSILON || fabs(rot->q3+q3) > FLT_EPSILON) { 841 801 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 842 802 "psSphereRot_CEOtoGCRS failed to return expected values.\n"); 843 printf("\n Output sphere rotation = %.13g,%.13g,%.13g,%.13g\n", 844 rot->q0, rot->q1, rot->q2, rot->q3); 845 printf(" Expected sphere rotation = %.13g,%.13g,%.13g,%.13g\n", q0,q1,q2,q3); 846 printf(" a difference: %.13g, %.13g, %.13g, %.13g \n", (rot->q0-q0), (rot->q1-q1), 847 (rot->q2-q2), (rot->q3-q3) ); 848 printf(" abs difference: %.13g, %.13g, %.13g, %.13g \n\n", (rot->q0+q0), (rot->q1+q1), 849 (rot->q2+q2), (rot->q3+q3) ); 850 //return 3; 851 } 852 853 803 return 3; 804 } 854 805 psCube *tempCube = psCubeAlloc(); 855 806 tempCube->x = -0.35963388069046304; … … 858 809 obj = psCubeToSphere(tempCube); 859 810 psFree(tempCube); 860 // obj = psSphereAlloc();861 // obj->r = objR;862 // obj->d = objD;863 811 psSphereRot *precessionNutation = psSphereRotConjugate(NULL, rot); 864 812 psSphere *result = psSphereRotApply(NULL, precessionNutation, obj); … … 868 816 y = 0.5555012823608123; 869 817 z = 0.7496183628158023; 870 printf("\n Output cube = x,y,z = %.13g, %.13g,%.13g\n", cube->x, cube->y, cube->z);871 printf("Expected cube = x,y,z = %.13g, %.13g,%.13g\n", x, y, z);872 printf(" A difference of:%.13g, %.13g, %.13g\n\n",818 printf("\n Output cube = x,y,z = %.13g, %.13g, %.13g\n", cube->x, cube->y, cube->z); 819 printf("Expected cube = x,y,z = %.13g, %.13g, %.13g\n", x, y, z); 820 printf(" A difference of: %.13g, %.13g, %.13g\n\n", 873 821 (x-cube->x), (y-cube->y), (z-cube->z)); 874 875 //great sphere difference between result and expected876 //Re = 6.38x10^6m877 822 psCube *expect = psCubeAlloc(); 878 823 expect->x = x; … … 880 825 expect->z = z; 881 826 psSphere *expected = psCubeToSphere(expect); 827 double d = greatCircle(result, expected); 828 printf(" The great circle angular distance between expected & result = %.13g\n", d); 829 882 830 psFree(expect); 883 double d = acos(cos(result->r)*cos(expected->r)*cos(result->d-expected->d) + sin(result->r)*sin(expected->r));884 printf("Great circle difference of: %.13g \n", d);885 886 831 psFree(expected); 887 832 psFree(obj); 888 889 890 891 // psSphere *test = psSphereAlloc();892 // test->r = 0.0;893 // test->d = 0.0;894 // test = psSphereRotApply(test, rot, test);895 // printf("\n Sphere -test- has values r,d = %.8g, %.8g \n", test->r, test->d);896 897 833 psFree(precessionNutation); 898 834 psFree(result); 899 835 psFree(cube); 900 901 // psFree(test);902 836 psFree(rot); 903 837 psFree(in); 838 904 839 return 0; 905 840 } … … 910 845 psEarthPole *empty = NULL; 911 846 psSphereRot *rot = NULL; 912 913 // in->x = M_PI / 4.0;914 // in->y = M_PI / 6.0;915 // in->s = M_PI / 8.0;916 847 in->x = -0.13275353774074533; 917 848 in->y = 0.4359436319739848; 918 849 in->s = -4.2376965863576153e-10; 919 920 850 in->x = SEC_TO_RAD(in->x); 921 851 in->y = SEC_TO_RAD(in->y); … … 928 858 return 1; 929 859 } 930 931 860 rot = psSphereRot_ITRStoTEO(in); 932 861 if (rot == NULL) { … … 958 887 printf(" Expected sphere rotation = %.13g, %.13g, %.13g, %.13g\n", q0,q1,q2,q3); 959 888 960 // psSphere *test = psSphereAlloc();961 // test->r = 0.0;962 // test->d = 0.0;963 889 psCube *temp = psCubeAlloc(); 964 890 // temp->x = -0.3596195125758298; … … 969 895 temp->z = 0.7496183628158023; 970 896 971 972 897 obj = psCubeToSphere(temp); 973 898 psSphere *test = NULL; … … 975 900 psSphereRot *newRot = psSphereRotConjugate(NULL, rot); 976 901 test = psSphereRotApply(NULL, newRot, obj); 977 printf("\n Sphere -test- has values r,d = %.8g, %.8g \n", test->r, test->d);978 902 temp = psSphereToCube(test); 979 903 printf("\n Cube -test- has x,y,z = %.13g, %.13g, %.13g \n", temp->x, temp->y, temp->z); … … 988 912 psSphere *sphere = psCubeToSphere(temp); 989 913 double d = greatCircle(sphere, test); 990 991 914 printf("Great circle difference of: %.13g \n", d); 915 992 916 psFree(sphere); 993 994 917 psFree(newRot); 995 918 psFree(obj); … … 998 921 psFree(rot); 999 922 psFree(in); 1000 return 0; 1001 } 1002 923 924 return 0; 925 } 926
Note:
See TracChangeset
for help on using the changeset viewer.
