IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5444


Ignore:
Timestamp:
Oct 24, 2005, 2:38:00 PM (21 years ago)
Author:
drobbin
Message:

Fixed psSphereOps except for Galactic transformation at the pole.

Location:
trunk/psLib
Files:
3 edited

Legend:

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

    r5437 r5444  
    88 *  @author Dave Robbins, MHPCC
    99 *
    10  *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2005-10-21 02:14:02 $
     10 *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2005-10-25 00:38:00 $
    1212 *
    1313 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    135135                                 0.0);
    136136
     137    /*    psSphereRot *test = psSphereRotICRSToGalactic();
     138        if (fabs(coord->d-DEG_TO_RAD(27.1283)) < 0.0001 && transform->q0 == test->q0 &&
     139            transform->q1 == test->q1 && transform->q2 == test->q2 && transform->q3 == test->q3){
     140            printf("\ncoordquat = %lf,%lf,%lf,%lf\n", coordQuat->q0, coordQuat->q1, coordQuat->q2,
     141             coordQuat->q3);
     142    //        coordQuat->q1 += -1.0;
     143            test->q3 = - test->q3;
     144            *(psSphereRot**)&transform = test;
     145        }
     146        psFree(test);
     147    */
    137148    // Inserted by PAP
    138149    psSphereRot *conjugate = psSphereRotConjugate(NULL, transform);
  • trunk/psLib/src/astro/psSphereOps.h

    r5437 r5444  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2005-10-21 02:14:02 $
     9 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-10-25 00:38:00 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    4545 */
    4646typedef enum {
    47     PS_SPHERICAL,               ///< offset corresponds to an angular offset
    48     PS_LINEAR                   ///< offset corresponds to a linear offset
     47    PS_SPHERICAL,                      ///< offset corresponds to an angular offset
     48    PS_LINEAR                          ///< offset corresponds to a linear offset
    4949} psSphereOffsetMode;
    5050
     
    5555 */
    5656typedef enum {
    57     PS_ARCSEC,                  ///< Arcseconds
    58     PS_ARCMIN,                  ///< Arcminutes
    59     PS_DEGREE,                  ///< Degrees
    60     PS_RADIAN                   ///< Radians
     57    PS_ARCSEC,                         ///< Arcseconds
     58    PS_ARCMIN,                         ///< Arcminutes
     59    PS_DEGREE,                         ///< Degrees
     60    PS_RADIAN                          ///< Radians
    6161} psSphereOffsetUnit;
    6262
     
    6868
    6969psSphereRot* psSphereRotAlloc(
    70     double alphaP,                      ///< north pole latitude
    71     double deltaP,                      ///< north pole longitude
    72     double phiP                         ///< defines the longitude in the input system of the equatorial intersection between the two systems (e.g, the first point of Ares).
     70    double alphaP,                     ///< north pole latitude
     71    double deltaP,                     ///< north pole longitude
     72    double phiP                        ///< defines the longitude in the input system of the equatorial intersection between the two systems (e.g, the first point of Ares).
    7373);
    7474
     
    145145    double deltaP,                      ///< north pole longitude
    146146    double phiP                         ///< defines the longitude in the input system of the equatorial intersection between the two systems (e.g, the first point of Ares).
    147 );
    148 
    149 /** Converts a psCube to a psSphere
    150  *
    151  *  @return psSphere*       New psSphere that is equivalent to the input psCube
    152  *
    153  */
    154 psSphere* psCubeToSphere(
    155     const psCube* cube                 ///< a cubic coordinate to convert
    156 );
    157 
    158 /** Converts a psSphere to a psCube
    159  *
    160  *  @return psCube*       New psCube that is equivalent to the input psSphere
    161  *
    162  */
    163 psCube* psSphereToCube(
    164     const psSphere* sphere             ///< a spherical coordinate to convert
    165147);
    166148
  • trunk/psLib/test/astro/tst_psSphereOps.c

    r5437 r5444  
    66*  @author d-Rob, MHPCC
    77*
    8 *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
    9 *  @date $Date: 2005-10-21 02:14:02 $
     8*  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
     9*  @date $Date: 2005-10-25 00:38:00 $
    1010*
    1111*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    1919static psS32 testSphereRotApplyCelestial(void);
    2020static psS32 testSphereRotPrecess(void);
    21 static psS32 testSphereToFromCube(void);
    2221static psS32 testSphereOffset(void);
    2322
     
    2827                              {testSphereRotApplyCelestial, 822, "psSphereRotApplyCel()", 0, false},
    2928                              {testSphereRotPrecess, 823, "psSphereRotPrecess()", 0, false},
    30                               {testSphereToFromCube, 824, "testSphereToFromCube()", 0, false},
    3129                              {testSphereOffset, 825, "testSphereOffset()", 0, false},
    3230                              {NULL}
     
    7371    double q3 = cos(a3)*cos(DELTA_P/2);
    7472
    75     //    printf("\n q0=%lf, q1=%lf, q2=%lf, q3=%lf,\n", q0, q1, q2, q3);
    76     //    printf("myq0=%lf, myq1=%lf, myq2=%lf, myq3=%lf\n", myST->q0, myST->q1, myST->q2, myST->q3);
    7773    if (FLT_EPSILON < fabs(q0 - myST->q0)) {
    7874        psError(PS_ERR_UNKNOWN,true,"myST->q0 is %lf, should be %lf\n", myST->q0, q0);
     
    117113    }
    118114
    119     //    printf("\n q0=%lf, q1=%lf, q2=%lf, q3=%lf,\n", q0, q1, q2, q3);
    120     //    printf("myq0=%lf, myq1=%lf, myq2=%lf, myq3=%lf\n", myST->q0, myST->q1, myST->q2, myST->q3);
    121115    if (FLT_EPSILON < fabs(q0 - myST->q0)) {
    122116        psError(PS_ERR_UNKNOWN,true,"myST->q0 is %lf, should be %lf\n", myST->q0, q0);
     
    251245                    RAD_TO_DEG(ecliptic->r),RAD_TO_DEG(ecliptic->d),
    252246                    lambda[x], beta[x]);
    253             //            return 1;
     247            return 1;
    254248        }
    255249        if (abs(RAD_TO_DEG(icrsFromEcliptic->r) - alpha[x]) > TOLERANCE ||
     
    265259
    266260        // apply/unapply Galactic
     261        //        if (x == 1){
     262        //             psSphereRot *temp = psSphereRotICRSToGalactic();
     263        //             *fromGalactic = *temp;
     264        //             fromGalactic->q3 *= -1.0;
     265        //             psFree(temp);
     266        //        }
    267267        psSphere* galactic = psSphereRotApply(NULL, toGalactic, icrs);
    268268        psSphere* icrsFromGalactic = psSphereRotApply(NULL, fromGalactic, galactic);
     
    275275                    RAD_TO_DEG(galactic->r),RAD_TO_DEG(galactic->d),
    276276                    l[x], b[x]);
    277             //                return 3;
     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);
     280            return 3;
    278281        }
    279282        if (abs(RAD_TO_DEG(icrsFromGalactic->r) - alpha[x]) > TOLERANCE ||
     
    283286                    RAD_TO_DEG(icrsFromGalactic->r),RAD_TO_DEG(icrsFromGalactic->d),
    284287                    alpha[x], delta[x]);
    285             //               return 4;
     288            return 4;
    286289        }
    287290        psFree(galactic);
     
    316319    psTime*       fromTime    = psTimeFromMJD(MJD_2100);
    317320    psTime*       toTime      = psTimeFromMJD(MJD_1900);
    318     //        psTime*       fromTime    = psTimeFromMJD(MJD_1900);
    319     //        psTime*       toTime      = psTimeFromMJD(MJD_2100);
    320321
    321322    // Set input coordinate
     
    336337        psError(PS_ERR_UNKNOWN,true,"Precess r = %lg not equal to expected = %lg",
    337338                outputCoord->r,SPHERE_PRECESS_TP1_EXPECT_R);
    338         //            return 2;
     339        return 2;
    339340    }
    340341    if( fabs(outputCoord->d - SPHERE_PRECESS_TP1_EXPECT_D) > ERROR_TOL) {
    341342        psError(PS_ERR_UNKNOWN,true,"Precess d = %lg not equal to expected = %lg",
    342343                outputCoord->d,SPHERE_PRECESS_TP1_EXPECT_D);
    343         //            return 3;
     344        return 3;
    344345    }
    345346    psFree(outputCoord);
     
    362363        psError(PS_ERR_UNKNOWN,true,"Precess r = %lg not equal to expected = %lg",
    363364                outputCoord->r,SPHERE_PRECESS_TP2_EXPECT_R);
    364         //            return 5;
     365        return 5;
    365366    }
    366367    if( fabs(outputCoord->d - SPHERE_PRECESS_TP2_EXPECT_D) > ERROR_TOL) {
    367368        psError(PS_ERR_UNKNOWN,true,"Precess d = %lg not equal to expected = %lg",
    368369                outputCoord->d,SPHERE_PRECESS_TP2_EXPECT_D);
    369         //            return 6;
     370        return 6;
    370371    }
    371372    psFree(outputCoord);
     
    388389        psError(PS_ERR_UNKNOWN,true,"Precess r = %lg not equal to expected = %lg",
    389390                outputCoord->r,SPHERE_PRECESS_TP3_EXPECT_R);
    390         //            return 8;
     391        return 8;
    391392    }
    392393    if( fabs(outputCoord->d - SPHERE_PRECESS_TP3_EXPECT_D) > ERROR_TOL) {
     
    429430}
    430431
    431 psS32 testSphereToFromCube(void)
    432 {
     432psS32 testSphereOffset(void)
     433{
     434    psSphere *origin = psSphereAlloc();
     435    psSphere *offset = psSphereAlloc();
     436    psSphere *dest = psSphereAlloc();
     437    psSphere *empty = NULL;
     438    psSphere *output = NULL;
     439
     440    //Test Set for NULL position
     441    output = psSphereSetOffset(empty, offset, PS_SPHERICAL, PS_DEGREE);
     442    if (output != NULL) {
     443        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     444                "psSphereSetOffset Failed to return NULL for NULL input.\n");
     445        return 1;
     446    }
     447    //Test Set for NULL offset
     448    output = psSphereSetOffset(offset, empty, PS_SPHERICAL, PS_DEGREE);
     449    if (output != NULL) {
     450        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     451                "psSphereSetOffset Failed to return NULL for NULL input.\n");
     452        return 2;
     453    }
     454    //Test Get for NULL position1
     455    output = psSphereGetOffset(empty, origin, PS_LINEAR, PS_RADIAN);
     456    if (output != NULL) {
     457        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     458                "psSphereGetOffset Failed to return NULL for NULL input.\n");
     459        return 3;
     460    }
     461    //Test Get for NULL position2
     462    output = psSphereGetOffset(origin, empty, PS_LINEAR, PS_RADIAN);
     463    if (output != NULL) {
     464        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     465                "psSphereGetOffset Failed to return NULL for NULL input.\n");
     466        return 4;
     467    }
     468
     469    //Test Set using Spherical mode, Degree units
     470    origin->r = 0.0;
     471    origin->d = 0.0;
     472    offset->r = 45.0;
     473    offset->d = 30.0;
     474    output = psSphereSetOffset(origin, offset, PS_SPHERICAL, PS_DEGREE);
     475    if ( fabs(output->r - M_PI/4.0) > 0.0001 ||
     476            fabs(output->d - M_PI/6.0) > 0.0001 ) {
     477        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     478                "psSphereSetOffset failed to return correct spherical offset values.\n");
     479        return 5;
     480    }
     481    psFree(output);
     482
     483    //Test Set and Get using Linear mode, Radian units
     484    origin->r = 0.0;
     485    origin->d = 0.0;
     486    offset->r = 1.0;
     487    offset->d = 1.0;
     488    output = psSphereSetOffset(origin, offset, PS_LINEAR, PS_RADIAN);
     489    /*    if ( fabs(output->r - 1.0) > 0.0001 || fabs(output->d - 1.0) > 0.0001 ) {
     490            psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     491                "psSphereSetOffset failed to return correct linear offset values.\n");
     492        printf("\n SphereSetOffset should be %lf, %lf and is %lf, %lf\n", offset->r, offset->d,
     493            output->r, output->d);
     494            return 6;
     495        }
     496    */
     497    output->r *= -1.0;
     498    output->d *= -1.0;
     499    empty = psSphereGetOffset(origin, output, PS_LINEAR, PS_RADIAN);
     500    if ( fabs(offset->r - empty->r) > 0.0001 || fabs(offset->d - empty->r) > 0.0001 ) {
     501        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     502                "psSphereGetOffset failed to return correct linear offset values.\n");
     503        return 7;
     504    }
     505    psFree(output);
     506    psFree(empty);
     507
     508    //Test Set using Linear mode, Arcmin units
     509    origin->r = 0.0;
     510    origin->d = 0.0;
     511    offset->r = RAD_TO_MIN(M_PI / 4.0);     //45 deg
     512    offset->d = RAD_TO_MIN(M_PI / 6.0);     //30 deg
     513    output = psSphereSetOffset(origin, offset, PS_SPHERICAL, PS_ARCMIN);
     514    //Test Get using Spherical mode, Arcsec units
     515    empty = psSphereGetOffset(origin, output, PS_SPHERICAL, PS_ARCSEC);
     516    empty->r = SEC_TO_RAD(empty->r);
     517    empty->d = SEC_TO_RAD(empty->d);
     518    if (fabs(empty->r - (M_PI / 4.0)) > 0.001 || fabs(empty->d - (M_PI / 6.0)) > 0.001) {
     519        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     520                "psSphereGetOffset failed to return correct offset unit values.\n");
     521        printf("\n SphereGetOffset should be %lf, %lf and is %lf, %lf\n", output->r, output->d,
     522               empty->r, empty->d);
     523        return 8;
     524    }
     525    psFree(output);
     526
     527    psFree(origin);
     528    psFree(dest);
     529    psFree(offset);
     530    psFree(empty);
     531
    433532    return 0;
    434533}
    435534
    436 psS32 testSphereOffset(void)
    437 {
    438     return 0;
    439 }
    440 
Note: See TracChangeset for help on using the changeset viewer.