IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

Debugging/Test code updates. Aberration, Gravity, and CEOtoTEO mainly

File:
1 edited

Legend:

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

    r5642 r5657  
    55*  @author d-Rob, MHPCC
    66*
    7 *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
    8 *  @date $Date: 2005-11-30 23:50:40 $
     7*  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
     8*  @date $Date: 2005-12-02 04:40:00 $
    99*
    1010*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    5656
    5757#define timesec 1049160600
     58#define objR DEG_TO_RAD(122.9153182445501)
     59#define objD DEG_TO_RAD(48.562968978679194)
     60static psSphere *obj = NULL;
     61static void objSetup(void);
     62
     63static void objSetup(void)
     64{
     65    if (obj == NULL) {
     66        obj = psSphereAlloc();
     67        obj->r = objR;
     68        obj->d = objD;
     69    }
     70}
    5871
    5972psS32 testAberration(void)
     
    8699    double speed = sqrt(cubeDir->x*cubeDir->x + cubeDir->y*cubeDir->y + cubeDir->z*cubeDir->z);
    87100    // Speed of light in vacuum (src:NIST)
    88     double c;
    89     c = 299792458.0; /* m/s */
     101    double c = 299792458.0; /* m/s */
    90102    speed = speed / c;
    91103
     
    104116
    105117    apparent = psAberration(apparent, actual, direction, speed);
    106     if (apparent == NULL)
    107         printf("\nApparent is NULL\n");
    108     else {
    109         printf("\napparent = r,d  = %.8g, %.8g\n", apparent->r, apparent->d);
    110         psFree(cubeDir);
    111         cubeDir = psSphereToCube(apparent);
    112         printf("  ><><Apparent = x,y,z = %.13g, %.13g, %.13g \n", cubeDir->x, cubeDir->y, cubeDir->z);
    113     }
     118
     119    printf("\nSphere Difference  =  r,d  =  %.13g, %.13g\n",
     120           (actual->r - apparent->r), (actual->d - apparent->d));
     121    psCube *outCube = psSphereToCube(apparent);
     122    printf(" -- resultCube = x,y,z = %.13g, %.13g, %.13g  -- \n",
     123           outCube->x, outCube->y, outCube->z);
     124
     125    double x, y, z;
     126    x = -0.35963388069046304;
     127    y = 0.5555192509816625;
     128    z = 0.7497078321908413;
     129
     130    printf(" -- expectedCube = x,y,z = %.13g, %.13g, %.13g  -- \n\n", x, y, z);
     131
     132    if ( fabs(x - outCube->x) > DBL_EPSILON || fabs(y - outCube->y) > DBL_EPSILON ||
     133            fabs(z - outCube->z) > DBL_EPSILON ) {
     134        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     135                "psAberration returned incorrect values.\n");
     136        printf("Cube Difference  =  x,y,z  = %.13g, %.13g, %.13g \n\n",
     137               (x - outCube->x), (y - outCube->y), (z - outCube->z) );
     138        return 3;
     139    }
     140
     141    psFree(outCube);
     142
    114143    psFree(cubeDir);
    115144    psFree(apparent);
     
    138167    sunCube->y = 2.5880956908748722e10;
    139168    sunCube->z = 1.1220046291457653e10;
    140     //    double sum = sqrt(sunCube->x*sunCube->x + sunCube->y*sunCube->y + sunCube->z*sunCube->z);
    141     //    sunCube->x = sunCube->x/sum;
    142     //    sunCube->y = sunCube->y/sum;
    143     //    sunCube->z = sunCube->z/sum;
    144     //    printf("\n <<<<SUNvec = x,y,z = %.13g, %.13g %.13g", sunCube->x, sunCube->y, sunCube->z);
    145169    psSphere *sun = psCubeToSphere(sunCube);
    146     printf("\n <<<<SUN = r,d = %.13g, %.13g\n", sun->r, sun->d);
    147170
    148171    empty = psGravityDeflection(apparent, empty, sun);
     
    161184    apparent = psGravityDeflection(NULL, actual, sun);
    162185    psSphere *result = psSphereSetOffset(actual, apparent, PS_SPHERICAL, PS_RADIAN);
     186
    163187    printf("\nActual r,d = %.13g,%.13g    Apparent r,d = %.16g, %.16g \n",
    164188           actual->r, actual->d, result->r, result->d);
     189    printf("Sphere Difference  =  r,d  =  %.13g, %.13g\n",
     190           (actual->r - result->r), (actual->d - result->d));
    165191    psCube *outCube = psSphereToCube(result);
    166     printf(" -- outCube = x,y,z = %.13g, %.13g, %.13g  -- \n", outCube->x, outCube->y, outCube->z);
     192    printf(" -- resultCube = x,y,z = %.13g, %.13g, %.13g  -- \n",
     193           outCube->x, outCube->y, outCube->z);
     194    psCube *outCube2 = psSphereToCube(actual);
     195    printf(" -- actualCube = x,y,z = %.13g, %.13g, %.13g  -- \n",
     196           outCube2->x, outCube2->y, outCube2->z);
     197
     198    double x, y, z;
     199    x = -0.35961949760293604;
     200    y = 0.5555613950298085;
     201    z = 0.7496835020836093;
     202
     203    printf(" -- expectedCube = x,y,z = %.13g, %.13g, %.13g  -- \n\n", x, y, z);
     204
     205    if ( fabs(x - outCube->x) > DBL_EPSILON || fabs(y - outCube->y) > DBL_EPSILON ||
     206            fabs(z - outCube->z) > DBL_EPSILON ) {
     207        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     208                "psGravityDeflection returned incorrect values.\n");
     209        printf("Cube Difference  =  x,y,z  = %.13g, %.13g, %.13g \n",
     210               (x - outCube->x), (y - outCube->y), (z - outCube->z) );
     211        return 1;
     212    }
     213
    167214    psFree(outCube);
    168     psCube *outCube2 = psSphereToCube(apparent);
    169     printf(" -- outCube = x,y,z = %.13g, %.13g, %.13g  -- \n", outCube2->x, outCube2->y, outCube2->z);
    170215    psFree(outCube2);
    171216    psFree(sunCube);
     
    416461psS32 testSphereRot_TEOtoCEO(void)
    417462{
     463    psSphereRot *rot = NULL;
     464    psTime *empty = NULL;
    418465    //    psTime *now = psTimeAlloc(PS_TIME_UT1);
    419466    //    now->sec = 1128530000;
    420467    //    now->nsec = 931154510;
    421     psTime *time = psTimeAlloc(PS_TIME_UTC);
    422     time->sec = timesec;
    423     time->nsec = 0;
     468    psTime *time = psTimeAlloc(PS_TIME_UT1);
     469    time->sec = timesec-1;
     470    time->nsec = 657017200;
    424471    time->leapsecond = false;
     472
    425473    //    psSphereRot *teoceo = psSphereRot_TEOtoCEO(now);
     474
     475    //return NULL for NULL input time
     476    rot = psSphereRot_TEOtoCEO(empty);
     477    if (rot != NULL) {
     478        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     479                "psSphereRot_TEOtoCEO failed to return NULL for NULL input time.\n");
     480        return 1;
     481    }
     482
    426483    psSphereRot *teoceo = psSphereRot_TEOtoCEO(time);
    427     printf("Output sphere rotation = %lf,%lf,%lf,%lf\n",
     484    //Make sure values match for other psTime type
     485    empty = psTimeAlloc(PS_TIME_UTC);
     486    empty->sec = timesec;
     487    empty->nsec = 0;
     488    empty->leapsecond = false;
     489    rot = psSphereRot_TEOtoCEO(empty);
     490    if (fabs(rot->q0-teoceo->q0) > DBL_EPSILON || fabs(rot->q1-teoceo->q1) > DBL_EPSILON ||
     491            fabs(rot->q2-teoceo->q2) > DBL_EPSILON || fabs(rot->q3-teoceo->q3) > DBL_EPSILON) {
     492        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     493                "psSphereRot_TEOtoCEO failed to return matching values for different time types.\n");
     494        return 2;
     495    }
     496    printf("\nOutput sphere rotation = %.13g, %.13g, %.13g, %.13g\n\n",
    428497           teoceo->q0, teoceo->q1, teoceo->q2, teoceo->q3);
    429498
     499    objSetup();
     500    psSphereRot *earthRot = psSphereRotConjugate(NULL, teoceo);
     501    psSphere *result = psSphereRotApply(NULL, earthRot, obj);
     502    //    psCube *cube = psSphereToCube(obj);
     503    psCube *cube = psSphereToCube(result);
     504
     505
     506    double x, y, z;
     507    x = 0.01698625430807123;
     508    y = -0.6616523084626379;
     509    z = 0.7496183628158023;
     510    if ( fabs(x-cube->x) > DBL_EPSILON  || fabs(y-cube->y) > DBL_EPSILON ||
     511            fabs(z-cube->z) > DBL_EPSILON) {
     512        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     513                "psSphereRot_TEOtoCEO returned incorrect values.\n");
     514        printf("\nOutput cube = x,y,z = %.13g, %.13g, %.13g\n",
     515               cube->x, cube->y, cube->z);
     516        printf("Expected cube = x,y,z = %.13g, %.13g, %.13g\n", x, y, z);
     517        printf("A difference of:   %.13g, %.13g, %.13g\n\n",
     518               (x-cube->x), (y-cube->y), (z-cube->z));
     519        return 3;
     520    }
    430521    //    psFree(now);
     522    psFree(result);
     523    psFree(obj);
     524    psFree(earthRot);
     525    psFree(cube);
    431526    psFree(time);
    432527    psFree(teoceo);
Note: See TracChangeset for help on using the changeset viewer.