IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5455


Ignore:
Timestamp:
Nov 1, 2005, 3:07:25 PM (21 years ago)
Author:
drobbin
Message:

updated tests, function spec's and verified files. resolved some existing issues.

Location:
trunk/psLib
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/astro/psEarthOrientation.c

    r5450 r5455  
    99*  @author Robert Daniel DeSonia, MHPCC
    1010*
    11 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    12 *  @date $Date: 2005-10-28 02:25:22 $
     11*  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     12*  @date $Date: 2005-11-02 01:07:25 $
    1313*
    1414*  Copyright 2005 Maui High Performance Computing Center, University of Hawaii
     
    5454static bool eocInit()
    5555{
    56     int nFail = 0;
     56    unsigned int nFail = 0;
    5757
    5858    // Read config file
     
    158158}
    159159
    160 psSphere *psAberration(psSphere *actual,
    161                        const psSphere *apparent,
     160psSphere *psAberration(psSphere *apparent,
     161                       const psSphere *actual,
    162162                       const psSphere *direction,
    163163                       double speed)
    164164{
    165     PS_ASSERT_PTR_NON_NULL(apparent, NULL);
     165    PS_ASSERT_PTR_NON_NULL(actual, NULL);
    166166    PS_ASSERT_PTR_NON_NULL(direction, NULL);
    167167    if (fabs(speed) < DBL_EPSILON) {
     
    171171    }
    172172
    173     if (actual == NULL) {
    174         actual = psSphereAlloc();
     173    if (apparent == NULL) {
     174        apparent = psSphereAlloc();
    175175    } else {
    176         actual->r = 0.0;
    177         actual->d = 0.0;
    178         actual->rErr = 0.0;
    179         actual->dErr = 0.0;
     176        apparent->r = 0.0;
     177        apparent->d = 0.0;
     178        apparent->rErr = 0.0;
     179        apparent->dErr = 0.0;
    180180    }
    181181    psSphere *rp = psSphereAlloc();
     
    188188    //    mu = apparent->r * direction->r + apparent->d * direction->d;
    189189    psCube* directionVector = psSphereToCube(direction);
    190     psCube* apparentVector = psSphereToCube(apparent);
    191     mu = acos(directionVector->x*apparentVector->x +
    192               directionVector->y*apparentVector->y +
    193               directionVector->z*apparentVector->z);
     190    psCube* actualVector = psSphereToCube(actual);
     191    mu = acos(directionVector->x*actualVector->x +
     192              directionVector->y*actualVector->y +
     193              directionVector->z*actualVector->z);
    194194
    195195    //rp = apparent - mu * direction;
    196     rp->r = apparent->r - mu * direction->r;
    197     rp->d = apparent->d - mu * direction->d;
     196    rp->r = actual->r - mu * direction->r;
     197    rp->d = actual->d - mu * direction->d;
    198198
    199199    mu_p = mu + speed * ((mu * mu - 1.0) / (1.0 - speed * mu));
     
    210210    r_p->d = mu_p * direction->d + a * rp->d;
    211211
    212     *actual = *r_p;
     212    *apparent = *r_p;
    213213    /*
    214214        psSphereRot *rot = NULL;
     
    218218        double sinD = sin(direction->d);
    219219        rot = psSphereRotQuat(cosR*cosD, sinR*cosD, sinD, speed);
    220      
     220
    221221        actual = psSphereRotApply(actual, rot, apparent);
    222222    */
     
    224224    psFree(r_p);
    225225    psFree(directionVector);
    226     psFree(apparentVector);
     226    psFree(actualVector);
    227227    psFree(rpVector);
    228     return actual;
    229 }
    230 
    231 psSphere *psGravityDeflection(psSphere *actual,
    232                               psSphere *apparent,
     228    return apparent;
     229}
     230
     231psSphere *psGravityDeflection(psSphere *apparent,
     232                              psSphere *actual,
    233233                              psSphere *sun)
    234234{
    235     PS_ASSERT_PTR_NON_NULL(apparent, NULL);
     235    PS_ASSERT_PTR_NON_NULL(actual, NULL);
    236236    PS_ASSERT_PTR_NON_NULL(sun, NULL);
    237237
    238     // calculating the actual angle from the apparent angle and the sun position
    239 
    240     // first, calculate the angle between the sun vector and the apparent vector
     238    // calculating the apparent angle from the actual angle and the sun position
     239
     240    // first, calculate the angle between the sun vector and the actual vector
    241241
    242242    // Moving to cartesian first:  XXX -- is this required?
    243243    psCube* sunVector = psSphereToCube(sun);
    244     psCube* apparentVector = psSphereToCube(apparent);
     244    psCube* actualVector = psSphereToCube(actual);
    245245
    246246    // use dot product to calculate the angle of separation
    247247    // N.B., assuming the psSphereToCube function returns a unit vector.
    248     double theta = acos(sunVector->x*apparentVector->x +
    249                         sunVector->y*apparentVector->y +
    250                         sunVector->z*apparentVector->z);
     248    double theta = acos(sunVector->x*actualVector->x +
     249                        sunVector->y*actualVector->y +
     250                        sunVector->z*actualVector->z);
    251251
    252252    double r0 = PS_AU * tan(theta);
     
    259259        //if deflection is greater than limit, the light rays will hit the sun
    260260        psWarning("Invalid positions.  Light ray will not be seen on earth.\n");
    261         psFree(apparentVector);
     261        psFree(actualVector);
    262262        psFree(sunVector);
    263         return actual;
    264     }
    265 
    266     if (actual == NULL) {
    267         actual = psSphereAlloc();
     263        return apparent;
     264    }
     265
     266    if (apparent == NULL) {
     267        apparent = psSphereAlloc();
    268268    } else {
    269         actual->r = 0.0;
    270         actual->d = 0.0;
    271         actual->rErr = 0.0;
    272         actual->dErr = 0.0;
    273     }
    274 
    275     // bend the apparent vector away from the sun vector by deflection angle.
     269        apparent->r = 0.0;
     270        apparent->d = 0.0;
     271        apparent->rErr = 0.0;
     272        apparent->dErr = 0.0;
     273    }
     274
     275    // bend the actual vector away from the sun vector by deflection angle.
    276276    // XXX: Not sure how to do this.  Dave thinks the formula should be:
    277277    //      theta = atan(r0/d)*tan(deflection), phi = thete/tan(deflection)
     
    281281    theta = atan(r0/PS_AU) * tan(deflection);
    282282    phi = sqrt( deflection*deflection - theta*theta );
    283     actual->r = theta;
    284     actual->d = phi;
    285     psFree(apparentVector);
     283    apparent->r = theta;
     284    apparent->d = phi;
     285    psFree(actualVector);
    286286    psFree(sunVector);
    287     return actual;
     287    return apparent;
    288288}
    289289
  • trunk/psLib/src/astro/psEarthOrientation.h

    r5450 r5455  
    99*  @author Robert Daniel DeSonia, MHPCC
    1010*
    11 *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    12 *  @date $Date: 2005-10-28 02:25:22 $
     11*  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     12*  @date $Date: 2005-11-02 01:07:25 $
    1313*
    1414*  Copyright 2005 Maui High Performance Computing Center, University of Hawaii
     
    5656 */
    5757psSphere *psAberration(
    58     psSphere *actual,                  ///< actual position of star
    59     const psSphere *apparent,          ///< apparent position of star
     58    psSphere *apparent,                ///< apparent position of star
     59    const psSphere *actual,            ///< actual position of star
    6060    const psSphere *direction,         ///< direction of motion of observer
    6161    double speed                       ///< speed of motion of observer
     
    7272 */
    7373psSphere *psGravityDeflection(
     74    psSphere *apparent,                ///< apparent position of star
    7475    psSphere *actual,                  ///< actual position of star
    75     psSphere *apparent,                ///< apparent position of star
    7676    psSphere *sun                      ///< position of the sun
    7777);
  • trunk/psLib/src/types/psMetadata.h

    r5454 r5455  
    1111*  @author Ross Harman, MHPCC
    1212*
    13 *  @version $Revision: 1.69 $ $Name: not supported by cvs2svn $
    14 *  @date $Date: 2005-10-29 00:05:53 $
     13*  @version $Revision: 1.70 $ $Name: not supported by cvs2svn $
     14*  @date $Date: 2005-11-02 01:07:25 $
    1515*
    1616*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    709709 *  returned.
    710710 *
    711  *  @return char*:           Value of metadata item.
     711 *  @return psString:           Value of metadata item.
    712712 */
    713713psString psMetadataLookupStr(
  • trunk/psLib/test/astro/tst_psEarthOrientation.c

    r5450 r5455  
    11/** @file  tst_psEarthOrientation.c
    22*
    3 *  @brief The code will go on ...
    4 *
     3*  @brief The code will perform earth orientation calculations and sphere rotations.
    54*
    65*  @author d-Rob, MHPCC
    76*
    8 *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
    9 *  @date $Date: 2005-10-28 02:25:22 $
     7*  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
     8*  @date $Date: 2005-11-02 01:07:25 $
    109*
    1110*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    4342psS32 testAberration(void)
    4443{
    45     psSphere *actual = NULL;
    46     psSphere *apparent = psSphereAlloc();
     44    psSphere *apparent = NULL;
     45    psSphere *actual = psSphereAlloc();
    4746    psSphere *direction = psSphereAlloc();
    4847    psSphere *empty = NULL;
    4948
    50     apparent->r = 0.2;
    51     apparent->d = 0.2;
     49    actual->r = 0.2;
     50    actual->d = 0.2;
    5251    direction->r = 0.2035;
    5352    direction->d = 0.2035;
    5453
    55     empty = psAberration(empty, actual, direction, 0.1);
     54    empty = psAberration(empty, apparent, direction, 0.1);
    5655    if (empty != NULL) {
    5756        psError(PS_ERR_BAD_PARAMETER_NULL, false,
    58                 "psAberration failed to return NULL for NULL apparent input.\n");
     57                "psAberration failed to return NULL for NULL actual input.\n");
    5958        return 1;
    6059    }
    61     empty = psAberration(empty, apparent, actual, 0.1);
     60    empty = psAberration(empty, actual, apparent, 0.1);
    6261    if (empty != NULL) {
    6362        psError(PS_ERR_BAD_PARAMETER_NULL, false,
     
    6665    }
    6766
    68     actual = psAberration(actual, apparent, direction, 0.4);
    69     printf("\nactual = r,d  = %.8g, %.8g\n", actual->r, actual->d);
     67    apparent = psAberration(apparent, actual, direction, 0.4);
     68    printf("\napparent = r,d  = %.8g, %.8g\n", apparent->r, apparent->d);
    7069
     70    psFree(apparent);
    7171    psFree(actual);
    72     psFree(apparent);
    7372    psFree(direction);
    7473
     
    7978{
    8079
    81     psSphere *actual = NULL;
    82     psSphere *apparent = psSphereAlloc();
     80    psSphere *actual = psSphereAlloc();
     81    psSphere *apparent = NULL;
    8382    psSphere *sun = psSphereAlloc();
    8483    psSphere *empty = NULL;
     
    8685    sun->r = 0.2;
    8786    sun->d = 0.2;
    88     apparent->r = 0.2035;
    89     apparent->d = 0.2035;
     87    actual->r = 0.2035;
     88    actual->d = 0.2035;
    9089
    91     empty = psGravityDeflection(empty, actual, sun);
     90    empty = psGravityDeflection(apparent, empty, sun);
    9291    if (empty != NULL) {
    9392        psError(PS_ERR_BAD_PARAMETER_NULL, true,
    94                 "psGravityDeflection Failed to return NULL for NULL apparent input sphere.\n");
     93                "psGravityDeflection Failed to return NULL for NULL actual input sphere.\n");
    9594        return 1;
    9695    }
    97     empty = psGravityDeflection(empty, apparent, actual);
     96    empty = psGravityDeflection(apparent, actual, empty);
    9897    if (empty != NULL) {
    9998        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     
    102101    }
    103102
    104     actual = psGravityDeflection(actual, apparent, sun);
    105     psSphere *result = psSphereSetOffset(apparent, actual, PS_SPHERICAL, PS_RADIAN);
    106     printf("\nApparent r,d = %.13g,%.13g    Actual r,d = %.13g, %.13g \n",
    107            apparent->r, apparent->d, result->r, result->d);
     103    apparent = psGravityDeflection(apparent, actual, sun);
     104    psSphere *result = psSphereSetOffset(actual, apparent, PS_SPHERICAL, PS_RADIAN);
     105    printf("\nActual r,d = %.13g,%.13g    Apparent r,d = %.13g, %.13g \n",
     106           actual->r, actual->d, result->r, result->d);
    108107    psFree(result);
    109108    psFree(actual);
  • trunk/psLib/test/astro/tst_psSphereOps.c

    r5450 r5455  
    11/** @file  tst_psSphereOps.c
    22*
    3 *  @brief The code will ..... Work ....
    4 *
     3*  @brief The code will perform sphere rotations and transformations.
    54*
    65*  @author d-Rob, MHPCC
    76*
    8 *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
    9 *  @date $Date: 2005-10-28 02:25:22 $
     7*  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
     8*  @date $Date: 2005-11-02 01:07:25 $
    109*
    1110*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    1413#include "psTest.h"
    1514#include "pslib_strict.h"
     15
    1616static psS32 testSphereRotAlloc(void);
    1717static psS32 testSphereRotQuat(void);
     
    275275                    RAD_TO_DEG(galactic->r),RAD_TO_DEG(galactic->d),
    276276                    l[x], b[x]);
    277             printf("togal- %lf,%lf,%lf,%lf   fromgal- %lf,%lf,%lf,%lf\n",
    278                    toGalactic->q0, toGalactic->q1, toGalactic->q2, toGalactic->q3,
    279                    fromGalactic->q0, fromGalactic->q1, fromGalactic->q2, fromGalactic->q3);
    280277            return 3;
    281278        }
    282         if (fabs(RAD_TO_DEG(icrsFromGalactic->r) - alpha[x]) > TOLERANCE ||
     279        if ( (fabs(RAD_TO_DEG(icrsFromGalactic->r) - alpha[x]) > TOLERANCE &&
     280                fabs(RAD_TO_DEG(icrsFromGalactic->d) - 90.0) > TOLERANCE ) ||
    283281                fabs(RAD_TO_DEG(icrsFromGalactic->d) - delta[x]) > TOLERANCE) {
    284282            psError(PS_ERR_UNKNOWN, false,
  • trunk/psLib/test/astro/verified/tst_psEarthOrientation.stderr

    r5450 r5455  
    66
    77<DATE><TIME>|<HOST>|E|psAberration (FILE:LINENO)
    8     Unallowable operation: apparent is NULL.
     8    Unallowable operation: actual is NULL.
    99<DATE><TIME>|<HOST>|E|psAberration (FILE:LINENO)
    1010    Unallowable operation: direction is NULL.
     
    1919
    2020<DATE><TIME>|<HOST>|E|psGravityDeflection (FILE:LINENO)
    21     Unallowable operation: apparent is NULL.
     21    Unallowable operation: actual is NULL.
    2222<DATE><TIME>|<HOST>|E|psGravityDeflection (FILE:LINENO)
    2323    Unallowable operation: sun is NULL.
  • trunk/psLib/test/astro/verified/tst_psEarthOrientation.stdout

    r5450 r5455  
    11
    2 actual = r,d  = 0.10218436, 0.10218436
     2apparent = r,d  = 0.10218436, 0.10218436
    33
    4 Apparent r,d = 0.2035,0.2035    Actual r,d = 0.2035000000002, 0.2035000000391
     4Actual r,d = 0.2035,0.2035    Apparent r,d = 0.2035000000002, 0.2035000000391
  • trunk/psLib/test/astro/verified/tst_psSphereOps.stderr

    r5437 r5455  
    11/***************************** TESTPOINT ******************************************\
    22*             TestFile: tst_psSphereOps.c                                          *
    3 *            TestPoint: psCoord{psSphereRotAlloc()}                                *
     3*            TestPoint: psSphereOps{psSphereRotAlloc()}                            *
    44*             TestType: Positive                                                   *
    55\**********************************************************************************/
    66
    77
    8 ---> TESTPOINT PASSED (psCoord{psSphereRotAlloc()} | tst_psSphereOps.c)
     8---> TESTPOINT PASSED (psSphereOps{psSphereRotAlloc()} | tst_psSphereOps.c)
    99
    1010/***************************** TESTPOINT ******************************************\
    1111*             TestFile: tst_psSphereOps.c                                          *
    12 *            TestPoint: psCoord{psSphereRotQuat()}                                 *
     12*            TestPoint: psSphereOps{psSphereRotQuat()}                             *
    1313*             TestType: Positive                                                   *
    1414\**********************************************************************************/
    1515
    1616
    17 ---> TESTPOINT PASSED (psCoord{psSphereRotQuat()} | tst_psSphereOps.c)
     17---> TESTPOINT PASSED (psSphereOps{psSphereRotQuat()} | tst_psSphereOps.c)
    1818
    1919/***************************** TESTPOINT ******************************************\
    2020*             TestFile: tst_psSphereOps.c                                          *
    21 *            TestPoint: psCoord{psSphereRotApply()}                                *
     21*            TestPoint: psSphereOps{psSphereRotApply()}                            *
    2222*             TestType: Positive                                                   *
    2323\**********************************************************************************/
     
    3232    Unallowable operation: coord is NULL.
    3333
    34 ---> TESTPOINT PASSED (psCoord{psSphereRotApply()} | tst_psSphereOps.c)
     34---> TESTPOINT PASSED (psSphereOps{psSphereRotApply()} | tst_psSphereOps.c)
    3535
    3636/***************************** TESTPOINT ******************************************\
    3737*             TestFile: tst_psSphereOps.c                                          *
    38 *            TestPoint: psCoord{psSphereRotApplyCel()}                             *
     38*            TestPoint: psSphereOps{psSphereRotApplyCel()}                         *
    3939*             TestType: Positive                                                   *
    4040\**********************************************************************************/
    4141
    42 <DATE><TIME>|<HOST>|E|testSphereRotApplyCelestial (FILE:LINENO)
    43     ICRS for Galactic tranformation incorrect.  Result is (180,90), expected (0,90)
    4442
    45 ---> TESTPOINT PASSED (psCoord{psSphereRotApplyCel()} | tst_psSphereOps.c)
     43---> TESTPOINT PASSED (psSphereOps{psSphereRotApplyCel()} | tst_psSphereOps.c)
    4644
    4745/***************************** TESTPOINT ******************************************\
    4846*             TestFile: tst_psSphereOps.c                                          *
    49 *            TestPoint: psCoord{psSphereRotPrecess()}                              *
     47*            TestPoint: psSphereOps{psSphereRotPrecess()}                          *
    5048*             TestType: Positive                                                   *
    5149\**********************************************************************************/
     
    6462    Unallowable operation: coords is NULL.
    6563
    66 ---> TESTPOINT PASSED (psCoord{psSphereRotPrecess()} | tst_psSphereOps.c)
     64---> TESTPOINT PASSED (psSphereOps{psSphereRotPrecess()} | tst_psSphereOps.c)
    6765
    6866/***************************** TESTPOINT ******************************************\
    6967*             TestFile: tst_psSphereOps.c                                          *
    70 *            TestPoint: psCoord{testSphereToFromCube()}                            *
     68*            TestPoint: psSphereOps{testSphereOffset()}                            *
    7169*             TestType: Positive                                                   *
    7270\**********************************************************************************/
    7371
     72<DATE><TIME>|<HOST>|E|psSphereSetOffset (FILE:LINENO)
     73    Unallowable operation: position is NULL.
     74<DATE><TIME>|<HOST>|E|psSphereSetOffset (FILE:LINENO)
     75    Unallowable operation: offset is NULL.
     76<DATE><TIME>|<HOST>|E|psSphereGetOffset (FILE:LINENO)
     77    Unallowable operation: position1 is NULL.
     78<DATE><TIME>|<HOST>|E|psSphereGetOffset (FILE:LINENO)
     79    Unallowable operation: position2 is NULL.
    7480
    75 ---> TESTPOINT PASSED (psCoord{testSphereToFromCube()} | tst_psSphereOps.c)
     81---> TESTPOINT PASSED (psSphereOps{testSphereOffset()} | tst_psSphereOps.c)
    7682
    77 /***************************** TESTPOINT ******************************************\
    78 *             TestFile: tst_psSphereOps.c                                          *
    79 *            TestPoint: psCoord{testSphereOffset()}                                *
    80 *             TestType: Positive                                                   *
    81 \**********************************************************************************/
    82 
    83 
    84 ---> TESTPOINT PASSED (psCoord{testSphereOffset()} | tst_psSphereOps.c)
    85 
Note: See TracChangeset for help on using the changeset viewer.