IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5507


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

Implemented PrecessionCorr function. Not verified, very possibly wrong.

Location:
trunk/psLib
Files:
4 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;
  • trunk/psLib/src/astro/psTime.c

    r5224 r5507  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.74 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2005-10-05 03:51:41 $
     12 *  @version $Revision: 1.75 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2005-11-12 03:37:34 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
  • trunk/psLib/src/astro/psTime.h

    r5466 r5507  
    1111 *  @author Ross Harman, MHPCC
    1212 *
    13  *  @version $Revision: 1.42 $ $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 $
    1515 *
    1616 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    375375char* p_psGetConfigFileName();
    376376
    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.
    381385 */
    382386psF64 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
    388392);
    389393
  • trunk/psLib/test/astro/tst_psEarthOrientation.c

    r5493 r5507  
    55*  @author d-Rob, MHPCC
    66*
    7 *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
    8 *  @date $Date: 2005-11-10 00:13:51 $
     7*  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
     8*  @date $Date: 2005-11-12 03:37:34 $
    99*
    1010*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    139139psS32 testEOCPrecession(void)
    140140{
    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);
    142192    return 0;
    143193}
     
    167217    }
    168218
     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);
    169235    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);
    170238    psFree(in);
    171239    psFree(eop);
     240    psFree(polarMotion);
     241    psFree(interm);
    172242    return 0;
    173243}
Note: See TracChangeset for help on using the changeset viewer.