Changeset 5507 for trunk/psLib/src/astro/psEarthOrientation.c
- Timestamp:
- Nov 11, 2005, 5:37:34 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/astro/psEarthOrientation.c (modified) (6 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;
Note:
See TracChangeset
for help on using the changeset viewer.
