IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 1, 2005, 5:40:38 PM (21 years ago)
Author:
evanalst
Message:

Add test cases for psSpherePrecess function.

File:
1 edited

Legend:

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

    r3352 r3360  
    66*  @author GLG, MHPCC
    77*
    8 *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
    9 *  @date $Date: 2005-03-01 21:40:28 $
     8*  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
     9*  @date $Date: 2005-03-02 03:40:37 $
    1010*
    1111*  XXX: Must test psSpherePrecess.
     
    3636static psS32 testSphereTransformICRSToGalactic( void );
    3737static psS32 testSphereTransformGalacticToICRS( void );
     38static psS32 testSphereTransformPrecess(void);
    3839//static psS32 test20( void );
    3940//static psS32 test21( void );
     
    5758                              {testSphereTransformICRSToGalactic, 824, "psSphereTransformICRSToGalactic()", 0, false},
    5859                              {testSphereTransformGalacticToICRS, 823, "psSphereTransformGalacticToICRS()", 0, false},
     60                              {testSphereTransformPrecess, 825, "psSphereTransformPrecess()", 0, false},
    5961                              //         {test20, 0000, "psProject()", 0, false},
    6062                              //         {test21, 0000, "psDeProject()", 0, false},
     
    102104#define DELTA_P 2.0
    103105#define PHI_P 3.0
     106
    104107psS32 testSphereTransformAlloc( void )
    105108{
     
    850853psS32 testSphereTransformApply5( void)
    851854{
    852 
    853855    psSphereTransform*  testTransform;
    854856    psSphere*           inputCoord = psSphereAlloc();
     
    956958    psFree(inputCoord);
    957959    psFree(inverseOutputCoord);
     960
     961    return 0;
     962}
     963
     964#define SPHERE_PRECESS_TP1_R            0.0               //    0.0       degrees
     965#define SPHERE_PRECESS_TP1_D            0.0               //    0.0       degrees
     966#define SPHERE_PRECESS_TP1_EXPECT_R     6.238453          //  357.437     degrees
     967#define SPHERE_PRECESS_TP1_EXPECT_D    -0.019426          //   -1.113     degrees
     968#define SPHERE_PRECESS_TP2_R            0.0               //    0.0       degrees
     969#define SPHERE_PRECESS_TP2_D            1.570796          //   90.0       degrees
     970#define SPHERE_PRECESS_TP2_EXPECT_R     6.260828          //  358.719     degrees
     971#define SPHERE_PRECESS_TP2_EXPECT_D     1.551353          //   88.886     degrees
     972#define SPHERE_PRECESS_TP3_R            3.141593          //  180.0       degrees
     973#define SPHERE_PRECESS_TP3_D            0.523599          //   30.0       degrees
     974#define SPHERE_PRECESS_TP3_EXPECT_R     3.096616          //  177.423     degrees
     975#define SPHERE_PRECESS_TP3_EXPECT_D     0.543024          //   31.113     degrees
     976
     977psS32 testSphereTransformPrecess( void )
     978{
     979    psSphere*     inputCoord  = psSphereAlloc();
     980    psSphere*     outputCoord = NULL;
     981    psTime*       fromTime    = psTimeFromMJD(MJD_2100);
     982    psTime*       toTime      = psTimeFromMJD(MJD_1900);
     983
     984    // Set input coordinate
     985    inputCoord->r = SPHERE_PRECESS_TP1_R;
     986    inputCoord->d = SPHERE_PRECESS_TP1_D;
     987    inputCoord->rErr = 0.0;
     988    inputCoord->dErr = 0.0;
     989
     990    // Calculate precess
     991    outputCoord = psSpherePrecess(inputCoord, fromTime, toTime);
     992    // Verify return with expected values
     993    if( fabs(outputCoord->r - SPHERE_PRECESS_TP1_EXPECT_R) > ERROR_TOL) {
     994        psError(PS_ERR_UNKNOWN,true,"Precess r = %lg not equal to expected = %lg",
     995                outputCoord->r,SPHERE_PRECESS_TP1_EXPECT_R);
     996        return 1;
     997    }
     998    if( fabs(outputCoord->d - SPHERE_PRECESS_TP1_EXPECT_D) > ERROR_TOL) {
     999        psError(PS_ERR_UNKNOWN,true,"Precess d = %lg not equal to expected = %lg",
     1000                outputCoord->d,SPHERE_PRECESS_TP1_EXPECT_D);
     1001        return 2;
     1002    }
     1003    psFree(outputCoord);
     1004
     1005    // Set input coordinate
     1006    inputCoord->r = SPHERE_PRECESS_TP2_R;
     1007    inputCoord->d = SPHERE_PRECESS_TP2_D;
     1008    inputCoord->rErr = 0.0;
     1009    inputCoord->dErr = 0.0;
     1010
     1011    // Calculate precess
     1012    outputCoord = psSpherePrecess(inputCoord, fromTime, toTime);
     1013    // Verify return with expected values
     1014    if( fabs(outputCoord->r - SPHERE_PRECESS_TP2_EXPECT_R) > ERROR_TOL) {
     1015        psError(PS_ERR_UNKNOWN,true,"Precess r = %lg not equal to expected = %lg",
     1016                outputCoord->r,SPHERE_PRECESS_TP2_EXPECT_R);
     1017        return 3;
     1018    }
     1019    if( fabs(outputCoord->d - SPHERE_PRECESS_TP2_EXPECT_D) > ERROR_TOL) {
     1020        psError(PS_ERR_UNKNOWN,true,"Precess d = %lg not equal to expected = %lg",
     1021                outputCoord->d,SPHERE_PRECESS_TP2_EXPECT_D);
     1022        return 4;
     1023    }
     1024    psFree(outputCoord);
     1025
     1026    // Set input coordinate
     1027    inputCoord->r = SPHERE_PRECESS_TP3_R;
     1028    inputCoord->d = SPHERE_PRECESS_TP3_D;
     1029    inputCoord->rErr = 0.0;
     1030    inputCoord->dErr = 0.0;
     1031
     1032    // Calculate precess
     1033    outputCoord = psSpherePrecess(inputCoord, fromTime, toTime);
     1034    // Verify return with expected values
     1035    if( fabs(outputCoord->r - SPHERE_PRECESS_TP3_EXPECT_R) > ERROR_TOL) {
     1036        psError(PS_ERR_UNKNOWN,true,"Precess r = %lg not equal to expected = %lg",
     1037                outputCoord->r,SPHERE_PRECESS_TP3_EXPECT_R);
     1038        return 5;
     1039    }
     1040    if( fabs(outputCoord->d - SPHERE_PRECESS_TP3_EXPECT_D) > ERROR_TOL) {
     1041        psError(PS_ERR_UNKNOWN,true,"Precess d = %lg not equal to expected = %lg",
     1042                outputCoord->d,SPHERE_PRECESS_TP3_EXPECT_D);
     1043        return 6;
     1044    }
     1045    psFree(outputCoord);
     1046
     1047    // Invoke precess with invalid parameter
     1048    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message");
     1049    outputCoord = psSpherePrecess(inputCoord, fromTime, NULL);
     1050    if(outputCoord != NULL) {
     1051        psError(PS_ERR_UNKNOWN,true,"Did not return NULL with invalid input");
     1052        return 7;
     1053    }
     1054
     1055    // Invoke precess with invalid parameter
     1056    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message");
     1057    outputCoord = psSpherePrecess(inputCoord, NULL, toTime);
     1058    if(outputCoord != NULL) {
     1059        psError(PS_ERR_UNKNOWN,true,"Did not return NULL with invalid input");
     1060        return 8;
     1061    }
     1062
     1063    // Invoke precess with invalid parameter
     1064    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message");
     1065    outputCoord = psSpherePrecess(NULL, fromTime, toTime);
     1066    if(outputCoord != NULL) {
     1067        psError(PS_ERR_UNKNOWN,true,"Did not return NULL with invalid input");
     1068        return 9;
     1069    }
     1070
     1071    // Free objects
     1072    psFree(fromTime);
     1073    psFree(toTime);
     1074    psFree(inputCoord);
    9581075
    9591076    return 0;
Note: See TracChangeset for help on using the changeset viewer.