IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 11, 2005, 5:37:34 PM (21 years ago)
Author:
drobbin
Message:

Implemented PrecessionCorr function. Not verified, very possibly wrong.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/astro/psEarthOrientation.c

    r5493 r5507  
    88*  @author Robert Daniel DeSonia, MHPCC
    99*
    10 *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
    11 *  @date $Date: 2005-11-10 00:13:50 $
     10*  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
     11*  @date $Date: 2005-11-12 03:37:34 $
    1212*
    1313*  Copyright 2005 Maui High Performance Computing Center, University of Hawaii
     
    487487}
    488488
    489 
    490489psEarthPole *psEOC_PrecessionCorr(const psTime *time,
    491490                                  psTimeBulletin bulletin)
    492491{
    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;
    494622}
    495623
     
    566694}
    567695
    568 
    569696psSphereRot* psSphereRot_TEOtoCEO(const psTime *time)
    570697{
     
    589716                                  psTimeBulletin bulletin)
    590717{
    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;
    593748}
    594749
     
    711866        diag_sum[2] = 1.0 - A[0][0] - A[1][1] + A[2][2];
    712867        diag_sum[3] = 1.0 + A[0][0] + A[1][1] + A[2][2];
    713      
     868
    714869        maxi = 0;
    715870        for (int i = 1; i < 4; ++i) {
     
    718873            }
    719874        }
    720      
     875
    721876        double p = 0.5 * sqrt(diag_sum[maxi]);
    722877        recip = 1.0 / (4.0 * p);
    723      
     878
    724879        if (maxi == 0) {
    725880            out->q0 = p;
Note: See TracChangeset for help on using the changeset viewer.