IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 25, 2005, 10:50:35 AM (21 years ago)
Author:
evanalst
Message:

Update test case for psSphereTransformEclipticToICRS.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/astronomy/tst_psCoord.c

    r3324 r3331  
    66*  @author GLG, MHPCC
    77*
    8 *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
    9 *  @date $Date: 2005-02-25 02:47:53 $
     8*  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
     9*  @date $Date: 2005-02-25 20:50:35 $
    1010*
    1111*  XXX: Must test psSpherePrecess.
     
    3030static psS32 testSphereTransformApply2( void );
    3131static psS32 testSphereTransformICRSToEcliptic( void );
    32 static psS32 test6( void );
     32static psS32 testSphereTransformEclipticToICRS( void );
    3333static psS32 test7( void );
    3434static psS32 test8( void );
     
    4747                              {testSphereTransformApply1, 820, "psPSphereTransformApply()", 0, false},
    4848                              {testSphereTransformApply2, 820, "psPSphereTransformApply()", 0, false},
    49                               {testSphereTransformICRSToEcliptic, 0000, "psSphereTransformICRSToEcliptic()", 0, false},
    50                               {test6, 0000, "psSphereTransformEclipticToICRS()", 0, false},
     49                              {testSphereTransformICRSToEcliptic, 821, "psSphereTransformICRSToEcliptic()", 0, false},
     50                              {testSphereTransformEclipticToICRS, 822, "psSphereTransformEclipticToICRS()", 0, false},
    5151                              {test7, 0000, "psSphereTransformICRSToGalatic()", 0, false},
    5252                              {test8, 0000, "psSphereTransformGalaticToICRS()", 0, false},
     
    589589// Thes values calculated from ADD-09 equations
    590590#define EXPECT_COS_DELTAP_2000    0.917482
    591 #define EXPECT_SIN_DELTAP_2000   -0.397777
     591#define EXPECT_SIN_DELTAP_2000    0.397777
    592592#define EXPECT_COS_DELTAP_2100    0.917572
    593 #define EXPECT_SIN_DELTAP_2100   -0.397567
     593#define EXPECT_SIN_DELTAP_2100    0.397567
    594594
    595595#define ERROR_TOL   0.0001
     
    600600    psF64  expectedAlphaP = 0.0;
    601601    psF64  expectedCosDeltaP = EXPECT_COS_DELTAP_2000;
    602     psF64  expectedSinDeltaP = EXPECT_SIN_DELTAP_2000;
     602    psF64  expectedSinDeltaP = -EXPECT_SIN_DELTAP_2000;
    603603
    604604    // Set test date time to 1/1/2000 00:00:00
     
    633633
    634634    expectedCosDeltaP = EXPECT_COS_DELTAP_2100;
    635     expectedSinDeltaP = EXPECT_SIN_DELTAP_2100;
     635    expectedSinDeltaP = -EXPECT_SIN_DELTAP_2100;
    636636
    637637    // Set test date time to 1/1/2100 00:00:00
     
    687687
    688688
    689 psS32 test6( void )
    690 {
    691     psS32 testStatus = 0;
    692     psTime* now = psTimeGetTime(PS_TIME_UTC);
    693     struct tm *tm_time = psTimeToTM(now);
    694     psF64 MJD = psTimeToMJD(now);
    695     struct tm *tmTime = psTimeToTM(now);
    696     psF64 year = (psF64)(1900 - MJD + tmTime->tm_year);
    697     psF64 T = year / 100.0;
    698     psF64 expectedAlphaP = 0.0;
    699     psF64 expectedDeltaP = DEG_TO_RAD(23.0) +
    700                            SEC_TO_RAD(27.0) +
    701                            MIN_TO_RAD(8.0) -
    702                            (SEC_TO_RAD(46.845) * T) -
    703                            (SEC_TO_RAD(0.0059) * T * T) +
    704                            (SEC_TO_RAD(0.00181) * T * T * T);
    705     psF64 expectedPhiP = 0.0;
    706     psSphereTransform *myST = psSphereTransformEclipticToICRS(now);
    707 
    708     if (FLT_EPSILON < fabs(sin(expectedDeltaP) - myST->sinDeltaP)) {
    709         printf("ERROR: myST->sinDeltaP is %f, should be %f\n", myST->sinDeltaP, sin(expectedDeltaP));
    710         testStatus = 1;
    711     }
    712 
    713     if (FLT_EPSILON < fabs(cos(expectedDeltaP) - myST->cosDeltaP)) {
    714         printf("ERROR: myST->cosDeltaP is %f, should be %f\n", myST->cosDeltaP, cos(expectedDeltaP));
    715         testStatus = 1;
    716     }
    717 
    718     if (FLT_EPSILON < fabs(expectedAlphaP - myST->alphaP)) {
    719         printf("ERROR: myST->alphaP is %f, should be %f\n", myST->alphaP, expectedAlphaP);
    720         testStatus = 3;
    721     }
    722 
    723     if (FLT_EPSILON < fabs(expectedPhiP - myST->phiP)) {
    724         printf("ERROR: myST->phiP is %f, should be %f\n", myST->phiP, expectedPhiP);
    725         testStatus = 4;
    726     }
    727 
     689psS32 testSphereTransformEclipticToICRS( void )
     690{
     691    psF64  expectedPhiP = 0.0;
     692    psF64  expectedAlphaP = 0.0;
     693    psF64  expectedCosDeltaP = EXPECT_COS_DELTAP_2000;
     694    psF64  expectedSinDeltaP = EXPECT_SIN_DELTAP_2000;
     695
     696    // Set test date time to 1/1/2000 00:00:00
     697    psTime* testDateTime = psTimeFromMJD(MJD_2000);
     698
     699    // Invoke function to set psSphereTransforma object
     700    psSphereTransform *myST = psSphereTransformEclipticToICRS(testDateTime);
     701
     702    // Verify expected values for the specified time
     703    if (ERROR_TOL < fabs(expectedSinDeltaP - myST->sinDeltaP)) {
     704        psError(PS_ERR_UNKNOWN,true,"myST->sinDeltaP is %f, should be %f",
     705                myST->sinDeltaP, expectedSinDeltaP);
     706        return 1;
     707    }
     708    if (ERROR_TOL < fabs(expectedCosDeltaP - myST->cosDeltaP)) {
     709        psError(PS_ERR_UNKNOWN,true,"myST->cosDeltaP is %f, should be %f",
     710                myST->cosDeltaP, expectedCosDeltaP);
     711        return 2;
     712    }
     713    if (ERROR_TOL < fabs(expectedAlphaP - myST->alphaP)) {
     714        psError(PS_ERR_UNKNOWN,true,"myST->alphaP is %f, should be %f",
     715                myST->alphaP, expectedAlphaP);
     716        return 3;
     717    }
     718    if (ERROR_TOL < fabs(expectedPhiP - myST->phiP)) {
     719        psError(PS_ERR_UNKNOWN,true,"myST->phiP is %f, should be %f",
     720                myST->phiP, expectedPhiP);
     721        return 4;
     722    }
    728723    psFree(myST);
    729     psFree(tm_time);
    730     psFree(tmTime);
    731     psFree(now);
    732 
    733     printf("-------------------------------------------------------------------\n");
    734     printf("Calling psSphereTransformEclipticToICRS() with NULL input.  Should generate error, return NULL.\n");
     724    psFree(testDateTime);
     725
     726    expectedCosDeltaP = EXPECT_COS_DELTAP_2100;
     727    expectedSinDeltaP = EXPECT_SIN_DELTAP_2100;
     728
     729    // Set test date time to 1/1/2100 00:00:00
     730    testDateTime = psTimeFromMJD(MJD_2100);
     731
     732    // Invoke function to set psSphereTransforma objec
     733    myST = psSphereTransformEclipticToICRS(testDateTime);
     734
     735    // Verify expected values for the specified time
     736    if (ERROR_TOL < fabs(expectedSinDeltaP - myST->sinDeltaP)) {
     737        psError(PS_ERR_UNKNOWN,true,"myST->sinDeltaP is %f, should be %f",
     738                myST->sinDeltaP, expectedSinDeltaP);
     739        return 5;
     740    }
     741    if (ERROR_TOL < fabs(expectedCosDeltaP - myST->cosDeltaP)) {
     742        psError(PS_ERR_UNKNOWN,true,"myST->cosDeltaP is %f, should be %f",
     743                myST->cosDeltaP, expectedCosDeltaP);
     744        return 6;
     745    }
     746    if (ERROR_TOL < fabs(expectedAlphaP - myST->alphaP)) {
     747        psError(PS_ERR_UNKNOWN,true,"myST->alphaP is %f, should be %f",
     748                myST->alphaP, expectedAlphaP);
     749        return 7;
     750    }
     751    if (ERROR_TOL < fabs(expectedPhiP - myST->phiP)) {
     752        psError(PS_ERR_UNKNOWN,true,"myST->phiP is %f, should be %f",
     753                myST->phiP, expectedPhiP);
     754        return 8;
     755    }
     756    psFree(myST);
     757    psFree(testDateTime);
     758
     759    // Verify if argument psTime is NULL, function returns NULL and error message generated
     760    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message");
    735761    myST = psSphereTransformEclipticToICRS(NULL);
    736762    if (myST != NULL) {
    737         printf("TEST ERROR: psSphereTransformApply() did not return NULL.\n");
    738         testStatus = false;
    739         myST = NULL;
    740     }
    741 
    742     return(testStatus);
     763        psError(PS_ERR_UNKNOWN,true,"psSphereTransformEclipticICRS() did not return NULL.");
     764        return 9;
     765    }
     766
     767    // Verify if argument psTime is less than 1900, function return NULL and error msg generated
     768    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message");
     769    testDateTime = psTimeFromMJD(MJD_1900 - 1.0);
     770    myST = psSphereTransformEclipticToICRS(testDateTime);
     771    if (myST != NULL) {
     772        psError(PS_ERR_UNKNOWN,true,"psSphereTransformEclipticToICRS() did not return NULL.");
     773        return 10;
     774    }
     775    psFree(testDateTime);
     776
     777    return 0;
    743778}
    744779
Note: See TracChangeset for help on using the changeset viewer.