Changeset 5507
- Timestamp:
- Nov 11, 2005, 5:37:34 PM (20 years ago)
- Location:
- trunk/psLib
- Files:
-
- 4 edited
-
src/astro/psEarthOrientation.c (modified) (6 diffs)
-
src/astro/psTime.c (modified) (1 diff)
-
src/astro/psTime.h (modified) (2 diffs)
-
test/astro/tst_psEarthOrientation.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/astro/psEarthOrientation.c
r5493 r5507 8 8 * @author Robert Daniel DeSonia, MHPCC 9 9 * 10 * @version $Revision: 1.1 1$ $Name: not supported by cvs2svn $11 * @date $Date: 2005-11-1 0 00:13:50$10 * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2005-11-12 03:37:34 $ 12 12 * 13 13 * Copyright 2005 Maui High Performance Computing Center, University of Hawaii … … 487 487 } 488 488 489 490 489 psEarthPole *psEOC_PrecessionCorr(const psTime *time, 491 490 psTimeBulletin bulletin) 492 491 { 493 return NULL; 492 PS_ASSERT_PTR_NON_NULL(time,NULL); 493 PS_ASSERT_INT_WITHIN_RANGE(bulletin, PS_IERS_A, PS_IERS_B, NULL); 494 495 int tableColumn; 496 double mjd; 497 psLookupStatusType status; 498 char* tableName[1] = {"dailyTable"}; 499 double x, y, s; 500 // psMetadataItem *tableMetadataItem = NULL; 501 // psVector *temp = NULL; 502 // double calc = 0.0; 503 // double t = 0.0; 504 // psMetadata *timeMetadata = p_psTimeGetMetadata(); 505 506 mjd = psTimeToMJD(time); 507 508 if (bulletin == PS_IERS_A) { 509 tableColumn = 1; 510 } else { 511 tableColumn = 4; 512 } 513 514 x = p_psTimeSearchTables(mjd, tableColumn, tableName, 1, &status); 515 if ( status == PS_LOOKUP_ERROR ) { 516 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 517 "Time table search returned unsuccessful status.\n"); 518 return NULL; 519 } else if (status != PS_LOOKUP_SUCCESS) { 520 psSphere *sphere = p_psTimeGetPoleCoords(time); 521 x = sphere->r; 522 psFree(sphere); 523 } else { 524 x = SEC_TO_RAD(x); 525 } 526 527 528 /* }else if(status == PS_LOOKUP_PAST_TOP) { 529 // Date too early for tables. Get default time delta value from metadata, and issue warning. 530 psLogMsg(__func__,PS_LOG_WARN,PS_ERRORTEXT_psTime_TIME_PREDATES_TABLES,mjd,"xp"); 531 532 // Lookup value from time metadata loaded from pslib.config 533 tableMetadataItem = psMetadataLookup(timeMetadata, "psLib.time.before.xp"); 534 if(tableMetadataItem == NULL) { 535 psError(PS_ERR_BAD_PARAMETER_VALUE, true, PS_ERRORTEXT_psTime_LOOKUP_METADATA_FAILED, 536 "psLib.time.before.xp"); 537 return NULL; 538 } 539 x = tableMetadataItem->data.F64; 540 541 } else if(status == PS_LOOKUP_PAST_BOTTOM) { 542 tableMetadataItem = psMetadataLookup(timeMetadata, "psLib.time.predict.mjd"); 543 if(tableMetadataItem == NULL) { 544 psError(PS_ERR_BAD_PARAMETER_VALUE, true, PS_ERRORTEXT_psTime_LOOKUP_METADATA_FAILED, 545 "psLib.time.predict.mjd"); 546 return NULL; 547 } 548 mjdPred = tableMetadataItem->data.F64; 549 550 // Get xp 551 tableMetadataItem = psMetadataLookup(timeMetadata, "psLib.time.predict.xp"); 552 if(tableMetadataItem == NULL) { 553 psError(PS_ERR_BAD_PARAMETER_VALUE, true, PS_ERRORTEXT_psTime_LOOKUP_METADATA_FAILED, "psLib.time.predict.xp"); 554 return NULL; 555 } 556 xp = (psVector*)tableMetadataItem->data.V; 557 PS_ASSERT_PTR_NON_NULL(xp,NULL); 558 559 // Get yp 560 tableMetadataItem = psMetadataLookup(timeMetadata, "psLib.time.predict.yp"); 561 if(tableMetadataItem == NULL) { 562 psError(PS_ERR_BAD_PARAMETER_VALUE, true, PS_ERRORTEXT_psTime_LOOKUP_METADATA_FAILED, "psLib.time.predict.yp"); 563 return NULL; 564 } 565 yp = (psVector*)tableMetadataItem->data.V; 566 PS_ASSERT_PTR_NON_NULL(yp,NULL); 567 568 // Calculate "a" and "c" constants 569 a = TWOPI*(mjd - mjdPred)/365.25; 570 c = TWOPI*(mjd - mjdPred)/435.0; 571 572 // Calculate x and y polar coordinates 573 x = xp->data.F64[0] + 574 xp->data.F64[1]*cos(a) + 575 xp->data.F64[2]*sin(a) + 576 xp->data.F64[3]*cos(c) + 577 xp->data.F64[4]*sin(c); 578 579 580 581 582 583 } 584 */ 585 586 587 tableColumn++; 588 y = p_psTimeSearchTables(mjd, tableColumn, tableName, 1, &status); 589 if ( status == PS_LOOKUP_ERROR ) { 590 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 591 "Time table search returned unsuccessful status.\n"); 592 return NULL; 593 } else if (status != PS_LOOKUP_SUCCESS) { 594 psSphere *sphere = p_psTimeGetPoleCoords(time); 595 y = sphere->d; 596 psFree(sphere); 597 } else { 598 y = SEC_TO_RAD(y); 599 } 600 601 tableColumn++; 602 s = p_psTimeSearchTables(mjd, tableColumn, tableName, 1, &status); 603 if ( status == PS_LOOKUP_ERROR ) { 604 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 605 "Time table search returned unsuccessful status.\n"); 606 return NULL; 607 } else if (status != PS_LOOKUP_SUCCESS) { 608 s = psTimeGetUT1Delta(time, bulletin); 609 } else { 610 s = SEC_TO_RAD(s); 611 } 612 613 //XXX: Do I need to do something for nutation terms w/periods of less than 2 days??? 614 psEarthPole *out = psEarthPoleAlloc(); 615 out->x = x; 616 out->y = y; 617 out->s = s; 618 619 // psFree(tableMetadataItem); 620 // psFree(timeMetadata); 621 return out; 494 622 } 495 623 … … 566 694 } 567 695 568 569 696 psSphereRot* psSphereRot_TEOtoCEO(const psTime *time) 570 697 { … … 589 716 psTimeBulletin bulletin) 590 717 { 591 592 return NULL; 718 PS_ASSERT_PTR_NON_NULL(time, NULL); 719 720 psEarthPole *out = psEarthPoleAlloc(); 721 psSphere *in = NULL; 722 double s; 723 724 //XXX: This may be the wrong idea... ADD says to use 3rd-order polys to interpolate 725 //polar motion coordinates. 726 in = p_psTimeGetPoleCoords(time); 727 if (in == NULL) { 728 psError(PS_ERR_BAD_PARAMETER_NULL, true, 729 "p_psTimeGetPoleCoords return NULL psSphere for non-NULL input time.\n"); 730 return NULL; 731 } 732 out->x = in->r; 733 out->y = in->d; 734 735 s = psTimeGetUT1Delta(time, bulletin); 736 out->s = s; 737 738 //XXX: Apply polar tide correction here??? 739 psEarthPole *correction = psEOC_PolarTideCorr(time); 740 out->x += correction->x; 741 out->y += correction->y; 742 out->s += correction->s; 743 744 745 psFree(in); 746 psFree(correction); 747 return out; 593 748 } 594 749 … … 711 866 diag_sum[2] = 1.0 - A[0][0] - A[1][1] + A[2][2]; 712 867 diag_sum[3] = 1.0 + A[0][0] + A[1][1] + A[2][2]; 713 868 714 869 maxi = 0; 715 870 for (int i = 1; i < 4; ++i) { … … 718 873 } 719 874 } 720 875 721 876 double p = 0.5 * sqrt(diag_sum[maxi]); 722 877 recip = 1.0 / (4.0 * p); 723 878 724 879 if (maxi == 0) { 725 880 out->q0 = p; -
trunk/psLib/src/astro/psTime.c
r5224 r5507 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1.7 4$ $Name: not supported by cvs2svn $13 * @date $Date: 2005-1 0-05 03:51:41$12 * @version $Revision: 1.75 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2005-11-12 03:37:34 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii -
trunk/psLib/src/astro/psTime.h
r5466 r5507 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.4 2$ $Name: not supported by cvs2svn $14 * @date $Date: 2005-11- 03 04:31:22$13 * @version $Revision: 1.43 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2005-11-12 03:37:34 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 375 375 char* p_psGetConfigFileName(); 376 376 377 /** 378 * 379 * 380 * 377 /** Searches the IERS time tables for a specified entry location. 378 * 379 * Returns the interpolated double precision (arcsec) value at the specified entry 380 * location. Inputs to specify are the time index in mjd, the column number 381 * corresponding to Xp, Yp, or Sp (UT1-UTC) in IERS A or B, the time table names, 382 * and the number of time tables. 383 * 384 * @return psF64: Resulting table entry for specified parameters. 381 385 */ 382 386 psF64 p_psTimeSearchTables( 383 psF64 index, ///< 384 psU64 column, ///< 385 char *metadataTableNames[], ///< 386 psU32 nTables, ///< 387 psLookupStatusType* status ///< 387 psF64 index, ///< time index for which to search 388 psU64 column, ///< column number of specified index 389 char *metadataTableNames[], ///< names of IERS tables to search 390 psU32 nTables, ///< number of IERS tables to search 391 psLookupStatusType* status ///< status of table search 388 392 ); 389 393 -
trunk/psLib/test/astro/tst_psEarthOrientation.c
r5493 r5507 5 5 * @author d-Rob, MHPCC 6 6 * 7 * @version $Revision: 1. 9$ $Name: not supported by cvs2svn $8 * @date $Date: 2005-11-1 0 00:13:51$7 * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2005-11-12 03:37:34 $ 9 9 * 10 10 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 139 139 psS32 testEOCPrecession(void) 140 140 { 141 141 psTime *empty = NULL; 142 psTime *time = psTimeAlloc(PS_TIME_TAI); 143 time->sec = 1131579114; 144 time->nsec = 498489000; 145 time->leapsecond = false; 146 147 148 //Tests for Precession Correction function// 149 //Return NULL for NULL time input 150 psEarthPole *pcorr = NULL; 151 pcorr = psEOC_PrecessionCorr(empty, PS_IERS_A); 152 if (pcorr != NULL) { 153 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 154 "psEOC_PrecessionCorr failed to return NULL for NULL time input.\n"); 155 return 4; 156 } 157 158 //Return NULL for Invalid IERS table 159 pcorr = psEOC_PrecessionCorr(time, 3); 160 if (pcorr != NULL) { 161 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 162 "psEOC_PrecessionCorr failed to return NULL for incorrect IERS table.\n"); 163 return 5; 164 } 165 psFree(pcorr); 166 167 //Check values from IERS table A 168 pcorr = psEOC_PrecessionCorr(time, PS_IERS_A); 169 if ( pcorr == NULL ) { 170 psError(PS_ERR_BAD_PARAMETER_NULL, false, 171 "psEOC_PrecessionCorr returned NULL for valid inputs.\n"); 172 return 6; 173 } else { 174 printf("Precession Correction output (IERSA) = x,y,s = %.8g, %.8g, %.8g\n", 175 pcorr->x, pcorr->y, pcorr->s); 176 } 177 psFree(pcorr); 178 179 //Check values from IERS table B 180 pcorr = psEOC_PrecessionCorr(time, PS_IERS_B); 181 if ( pcorr == NULL ) { 182 psError(PS_ERR_BAD_PARAMETER_NULL, false, 183 "psEOC_PrecessionCorr returned NULL for valid inputs.\n"); 184 return 7; 185 } else { 186 printf("Precession Correction output (IERSB) = x,y,s = %.8g, %.8g, %.8g\n", 187 pcorr->x, pcorr->y, pcorr->s); 188 } 189 psFree(pcorr); 190 191 psFree(time); 142 192 return 0; 143 193 } … … 167 217 } 168 218 219 psEarthPole *polarMotion = NULL; 220 polarMotion = psEOC_GetPolarMotion(empty, PS_IERS_B); 221 if (polarMotion != NULL) { 222 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 223 "psEOC_GetPolarMotion failed to return NULL for NULL input time.\n"); 224 return 3; 225 } 226 polarMotion = psEOC_GetPolarMotion(in, PS_IERS_B); 227 if (polarMotion == NULL) { 228 psError(PS_ERR_BAD_PARAMETER_NULL, false, 229 "psEOC_GetPolarMotion returned NULL for valid input time.\n"); 230 return 4; 231 } 232 233 psSphere *interm = p_psTimeGetPoleCoords(in); 234 printf(" -- sphere = r=%.8g, d=%.8g\n", interm->r, interm->d); 169 235 printf(" -- Eop = x=%.8g, y=%.8g, s=%.8g\n", eop->x, eop->y, eop->s); 236 printf(" -- PolarMotion = x=%.8g, y=%.8g, s=%.8g\n", polarMotion->x, 237 polarMotion->y, polarMotion->s); 170 238 psFree(in); 171 239 psFree(eop); 240 psFree(polarMotion); 241 psFree(interm); 172 242 return 0; 173 243 }
Note:
See TracChangeset
for help on using the changeset viewer.
