IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5716


Ignore:
Timestamp:
Dec 6, 2005, 4:13:40 PM (21 years ago)
Author:
drobbin
Message:

Updated EOC tests to verify against given test cases. All tests fail. (no case for nutation).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/astro/tst_psEarthOrientation.c

    r5657 r5716  
    55*  @author d-Rob, MHPCC
    66*
    7 *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
    8 *  @date $Date: 2005-12-02 04:40:00 $
     7*  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
     8*  @date $Date: 2005-12-07 02:13:40 $
    99*
    1010*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    1818static psS32 testGravityDeflect(void);
    1919static psS32 testEOCPrecession(void);
     20static psS32 testEOCPrecessionCorr(void);
    2021static psS32 testEOCPolar(void);
    2122static psS32 testEOCNutation(void);
     
    2829                              {testGravityDeflect, 667, "psGravityDeflect()", 0, false},
    2930                              {testEOCPrecession, 669, "psEOCPrecession()", 0, false},
    30                               {testEOCPolar, 670, "psEOCPolar()", 0, false},
    31                               {testEOCNutation, 671, "psEOCNutation()", 0, false},
    32                               {testSphereRot_TEOtoCEO, 672, "psSphereRot_TEOtoCEO()", 0, false},
    33                               {testSphereRot_CEOtoGCRS, 673, "psSphereRot_CEOtoGCRS()", 0, false},
    34                               {testSphereRot_ITRStoTEO, 674, "psSphereRRot_ITRStoTEO()", 0, false},
     31                              {testEOCPrecessionCorr, 670, "psEOCPrecessionCorr()", 0, false},
     32                              {testEOCPolar, 671, "psEOCPolar()", 0, false},
     33                              {testEOCNutation, 672, "psEOCNutation()", 0, false},
     34                              {testSphereRot_TEOtoCEO, 673, "psSphereRot_TEOtoCEO()", 0, false},
     35                              {testSphereRot_CEOtoGCRS, 674, "psSphereRot_CEOtoGCRS()", 0, false},
     36                              {testSphereRot_ITRStoTEO, 675, "psSphereRRot_ITRStoTEO()", 0, false},
    3537                              {NULL}
    3638                          };
     
    257259        return 3;
    258260    } else {
    259         printf("Precession Model output = x,y,s = %.8g, %.8g, %.8g\n",
    260                pmodel->x, pmodel->y, pmodel->s);
    261261        double x, y, s;
    262262        x = 2.857175590089105e-4;
    263263        y = 2.3968739377734732e-5;
    264264        s = -1.3970066457904322e-8;
    265         printf("Expected output = x,y,s = %.13g, %.13g, %.13g\n\n", x, y, s);
     265        if ( fabs(pmodel->x - x) > DBL_EPSILON || fabs(pmodel->y - y) > DBL_EPSILON
     266                || fabs(pmodel->s - s) > DBL_EPSILON) {
     267            psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     268                    "   psEOC_PrecessionModel return incorrect values.\n");
     269            printf("\n  Precession Model output = x,y,s = %.8g, %.8g, %.8g\n",
     270                   pmodel->x, pmodel->y, pmodel->s);
     271            printf("  Expected output = x,y,s = %.13g, %.13g, %.13g\n", x, y, s);
     272            printf("  A difference of:   %.13g, %.13g, %.13g\n\n",
     273                   (pmodel->x - x), (pmodel->y - y), (pmodel->s - s) );
     274            return 4;
     275        }
    266276    }
    267277    psFree(pmodel);
    268278
     279    psFree(time);
     280    if (!p_psEOCFinalize() ) {
     281        psError(PS_ERR_BAD_PARAMETER_VALUE, false, "EOC failed finalization!\n");
     282        return 12;
     283    }
     284
     285    return 0;
     286}
     287
     288psS32 testEOCPrecessionCorr(void)
     289{
     290    psTime *empty = NULL;
     291    psTime *time2 = psTimeAlloc(PS_TIME_UTC);
     292    time2->sec = timesec;
     293    time2->nsec = 0;
     294    time2->leapsecond = false;
     295
    269296    //XXX:  MAY Be an Error here... Time for Precession Correction has to be TAI or seg faults
    270     psTime *time2 = psTimeAlloc(PS_TIME_UTC);
    271     *time2 = *time;
    272297    time2 = psTimeConvert(time2, PS_TIME_TAI);
    273298    //Tests for Precession Correction function//
     
    278303        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
    279304                "psEOC_PrecessionCorr failed to return NULL for NULL time input.\n");
    280         return 4;
     305        return 5;
    281306    }
    282307
     
    286311        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
    287312                "psEOC_PrecessionCorr failed to return NULL for incorrect IERS table.\n");
    288         return 5;
     313        return 6;
    289314    }
    290315    psFree(pcorr);
     
    295320        psError(PS_ERR_BAD_PARAMETER_NULL, false,
    296321                "psEOC_PrecessionCorr returned NULL for valid inputs.\n");
    297         return 6;
     322        return 7;
    298323    } else {
    299         printf("Precession Correction output (IERSA) = x,y,s = %.8g, %.8g, %.8g\n",
     324        printf("\nPrecession Correction output (IERSA) = x,y,s = %.13g, %.13g, %.13g\n\n",
    300325               pcorr->x, pcorr->y, pcorr->s);
    301326    }
     
    307332        psError(PS_ERR_BAD_PARAMETER_NULL, false,
    308333                "psEOC_PrecessionCorr returned NULL for valid inputs.\n");
    309         return 7;
     334        return 9;
    310335    } else {
    311         printf("Precession Correction output (IERSB) = x,y,s = %.8g, %.8g, %.8g\n",
    312                pcorr->x, pcorr->y, pcorr->s);
    313336        double xx, yy, ss;
    314337        xx = 0.06295703125;
    315338        yy = -0.0287618408203125;
    316339        ss = 0.0;
    317         printf("Expected output = x,y,s = %.13g, %.13g, %.13g\n\n", xx, yy, ss);
    318     }
     340        if ( fabs(pcorr->x - xx) > DBL_EPSILON || fabs(pcorr->y - yy) > DBL_EPSILON
     341                || fabs(pcorr->s - ss) > DBL_EPSILON) {
     342            psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     343                    "   psEOC_PrecessionCorr return incorrect values.\n");
     344            printf("\nPrecession Correction output (IERSB) = x,y,s = %.13g, %.13g, %.13g\n",
     345                   pcorr->x, pcorr->y, pcorr->s);
     346            printf("Expected output = x,y,s = %.13g, %.13g, %.13g\n\n", xx, yy, ss);
     347            printf("  A difference of:   %.13g, %.13g, %.13g\n\n",
     348                   (pcorr->x - xx), (pcorr->y - yy), (pcorr->s - ss) );
     349            return 10;
     350        }
     351    }
     352
    319353    psFree(pcorr);
    320354
    321     psFree(time);
    322355    psFree(time2);
    323356    if (!p_psEOCFinalize() ) {
     
    355388        return 2;
    356389    }
    357 
    358     psEarthPole *polarMotion = NULL;
    359     polarMotion = psEOC_GetPolarMotion(empty, PS_IERS_B);
    360     if (polarMotion != NULL) {
    361         psError(PS_ERR_BAD_PARAMETER_VALUE, false,
    362                 "psEOC_GetPolarMotion failed to return NULL for NULL input time.\n");
    363         return 3;
    364     }
    365     polarMotion = psEOC_GetPolarMotion(in, PS_IERS_B);
    366     if (polarMotion == NULL) {
    367         psError(PS_ERR_BAD_PARAMETER_NULL, false,
    368                 "psEOC_GetPolarMotion returned NULL for valid input time.\n");
    369         return 4;
    370     }
    371390    psTime *in2 = psTimeAlloc(PS_TIME_UTC);
    372391    in2->sec = timesec;
     
    375394    in2 = psTimeConvert(in2, PS_TIME_TAI);
    376395    psSphere *interm = p_psTimeGetPoleCoords(in2);
     396    printf("\n  Polar Tide Corrections \n");
    377397    printf(" -- sphere = r=%.8g, d=%.8g\n", interm->r, interm->d);
    378398    printf(" -- Eop = x=%.8g, y=%.8g, s=%.8g\n", eop->x, eop->y, eop->s);
     399
     400    psEarthPole *polarMotion = NULL;
     401    polarMotion = psEOC_GetPolarMotion(empty, PS_IERS_B);
     402    if (polarMotion != NULL) {
     403        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     404                "psEOC_GetPolarMotion failed to return NULL for NULL input time.\n");
     405        return 3;
     406    }
     407    polarMotion = psEOC_GetPolarMotion(in, PS_IERS_B);
     408    if (polarMotion == NULL) {
     409        psError(PS_ERR_BAD_PARAMETER_NULL, false,
     410                "psEOC_GetPolarMotion returned NULL for valid input time.\n");
     411        return 4;
     412    }
    379413
    380414
     
    384418        return 5;
    385419    }
    386     printf("\n -- PolarMotion = x=%.13g, y=%.13g, s=%.13g\n", polarMotion->x,
     420    printf("\n  -- PolarMotion = x=%.13g, y=%.13g, s=%.13g\n", polarMotion->x,
    387421           polarMotion->y, polarMotion->s);
    388     printf("  -- NutationCorr = x,y,s = %.13g, %.13g, %.13g\n", nutationCorr->x,
     422    double sum;
     423    sum = sqrt(nutationCorr->x*nutationCorr->x + nutationCorr->y*nutationCorr->y + nutationCorr->s*nutationCorr->s);
     424    nutationCorr->x = nutationCorr->x / sum;
     425    nutationCorr->y = nutationCorr->y / sum;
     426    nutationCorr->s = nutationCorr->s / sum;
     427    printf("  -- NutationCorr = x,y,s = %.13g, %.13g, %.13g\n\n", nutationCorr->x,
    389428           nutationCorr->y, nutationCorr->s);
    390429    polarMotion->x += nutationCorr->x;
    391430    polarMotion->y += nutationCorr->y;
    392431    polarMotion->s += nutationCorr->s;
    393     printf("\n  -- Output Earthpole = x,y,s = %.13g, %.13g, %.13g\n", polarMotion->x,
    394            polarMotion->y, polarMotion->s);
    395432    double x,y,s;
    396433    x = -0.13275353774074533;
    397434    y = 0.4359436319739848;
    398435    s = -4.2376965863576153e-10;
    399     printf("  -- Expected Earthpole = x,y,s = %.13g, %.13g, %.13g\n", x, y, s);
     436
     437    if ( fabs(polarMotion->x - x) > DBL_EPSILON || fabs(polarMotion->y - y) > DBL_EPSILON
     438            || fabs(polarMotion->s - s) > DBL_EPSILON) {
     439        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     440                "   psEOC_GetPolarMotion returned incorrect values.\n");
     441
     442
     443        printf("\n  Precession Correction output (IERSB) = x,y,s = %.13g, %.13g, %.13g\n",
     444               polarMotion->x, polarMotion->y, polarMotion->s);
     445        printf("  Expected output = x,y,s = %.13g, %.13g, %.13g\n", x, y, s);
     446        printf("  A difference of:   %.13g, %.13g, %.13g\n\n",
     447               (polarMotion->x - x), (polarMotion->y - y), (polarMotion->s - s) );
     448        return 10;
     449    }
    400450
    401451    if (!p_psEOCFinalize() ) {
     
    564614        return 2;
    565615    }
    566     printf("Output sphere rotation = %.13g,%.13g,%.13g,%.13g\n",
    567            rot->q0, rot->q1, rot->q2, rot->q3);
    568     printf("Expected sphere rotation = %.13g,%.13g,%.13g,%.13g\n", q0,q1,q2,q3);
     616
     617    if (fabs(rot->q0-q0) > DBL_EPSILON || fabs(rot->q1-q1) > DBL_EPSILON ||
     618            fabs(rot->q2-q2) > DBL_EPSILON || fabs(rot->q3-q3) > DBL_EPSILON) {
     619        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     620                "psSphereRot_CEOtoGCRS failed to return expected values.\n");
     621        printf("\n  Output sphere rotation   = %.13g,%.13g,%.13g,%.13g\n",
     622               rot->q0, rot->q1, rot->q2, rot->q3);
     623        printf("  Expected sphere rotation = %.13g,%.13g,%.13g,%.13g\n", q0,q1,q2,q3);
     624        printf("  a difference:   %.13g, %.13g, %.13g, %.13g \n", (rot->q0-q0), (rot->q1-q1),
     625               (rot->q2-q2), (rot->q3-q3) );
     626        printf("  abs difference:   %.13g, %.13g, %.13g, %.13g \n\n", (rot->q0+q0), (rot->q1+q1),
     627               (rot->q2+q2), (rot->q3+q3) );
     628        return 3;
     629    }
    569630
    570631    psSphere *test = psSphereAlloc();
     
    606667        return 2;
    607668    }
    608     printf("Output sphere rotation = %.13g,%.13g,%.13g,%.13g\n",
    609            rot->q0, rot->q1, rot->q2, rot->q3);
     669
    610670    double q0,q1,q2,q3;
    611671    q0 = -1.0567571848664005e-6;
     
    613673    q2 = -3.3580195807204483e-12;
    614674    q3 = -0.9999999999993899;
    615     printf("Expected sphere rotation = %.13g,%.13g,%.13g,%.13g\n", q0,q1,q2,q3);
     675    if (fabs(rot->q0-q0) > DBL_EPSILON || fabs(rot->q1-q1) > DBL_EPSILON ||
     676            fabs(rot->q2-q2) > DBL_EPSILON || fabs(rot->q3-q3) > DBL_EPSILON) {
     677        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     678                "psSphereRot_ITRStoTEO failed to return expected values.\n");
     679        printf("\n  Output sphere rotation   = %.13g,%.13g,%.13g,%.13g\n",
     680               rot->q0, rot->q1, rot->q2, rot->q3);
     681        printf("  Expected sphere rotation = %.13g,%.13g,%.13g,%.13g\n", q0,q1,q2,q3);
     682        printf("  a difference:   %.13g, %.13g, %.13g, %.13g \n", (rot->q0-q0), (rot->q1-q1),
     683               (rot->q2-q2), (rot->q3-q3) );
     684        return 3;
     685    }
    616686
    617687    psSphere *test = psSphereAlloc();
Note: See TracChangeset for help on using the changeset viewer.