Changeset 4541
- Timestamp:
- Jul 12, 2005, 9:27:28 AM (21 years ago)
- Location:
- trunk/psLib
- Files:
-
- 5 added
- 7 edited
-
Makefile.am (modified) (1 diff)
-
configure.ac (modified) (3 diffs)
-
psParseErrorCodes (added)
-
src/astro/psEarthOrientation.c (added)
-
src/astro/psEarthOrientation.h (added)
-
src/astro/psSphere.c (added)
-
src/psErrorText.h (added)
-
src/sys/psErrorCodes.c (modified) (1 diff)
-
swig/Makefile.am (modified) (3 diffs)
-
swig/pslib.i (modified) (3 diffs)
-
test/astronomy/tst_psCoord.c (modified) (39 diffs)
-
test/image/tst_psImageGeomManip.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/Makefile.am
r3682 r4541 1 1 SUBDIRS = $(SUBDIR) 2 2 3 bin_SCRIPTS = pslib-config 3 bin_SCRIPTS = pslib-config psParseErrorCodes 4 4 5 5 pkgconfigdir = $(libdir)/pkgconfig -
trunk/psLib/configure.ac
r4209 r4541 13 13 14 14 SUBDIR="etc src test" dnl don't include 'swig', as it is optional 15 16 SRCDIRS="sys astro db fft fits imageops math mathtypes types xml" 15 17 16 18 AC_DISABLE_STATIC … … 70 72 AC_FUNC_VPRINTF 71 73 AC_CHECK_FUNCS([floor gethostname gettimeofday memmove memset mkdir pow regcomp sqrt strchr strcspn strerror strrchr strstr strtol strtoul strtoull]) 74 75 dnl Add the src directories to the include path 76 SRCPATH="`pwd`/src" 77 SRCINC=`echo "${SRCDIRS=}" | sed "s|\(\\w\+\)|-I\${SRCPATH=}/\1|g"` 78 SRCSUBLIBS=`echo "${SRCDIRS=}" | sed "s|\(\\w\+\)|\1/libpslib\1.la|g"` 79 AC_SUBST(SRCSUBLIBS,${SRCSUBLIBS=}) 80 CFLAGS="${CFLAGS=} -I${SRCPATH=} ${SRCINC=}" 81 AC_SUBST(SRCINC,${SRCINC=}) 82 72 83 73 84 dnl ----------------- MYSQL options -------------------- … … 238 249 239 250 AC_SUBST(SUBDIR,[$SUBDIR]) 251 AC_SUBST(SRCDIRS,[$SRCDIRS]) 240 252 AC_SUBST(PSLIB_LIBS,[$PSLIB_LIBS]) 241 253 AC_SUBST(PSLIB_CFLAGS,[$PSLIB_CFLAGS]) 254 255 AC_SUBST(LANG,[en]) 242 256 243 257 AC_CONFIG_FILES([ 244 258 Makefile 245 259 src/Makefile 246 src/astronomy/Makefile 247 src/collections/Makefile 248 src/dataManip/Makefile 249 src/dataIO/Makefile 250 src/image/Makefile 251 src/sysUtils/Makefile 260 src/astro/Makefile 261 src/db/Makefile 262 src/fft/Makefile 263 src/fits/Makefile 264 src/imageops/Makefile 265 src/math/Makefile 266 src/mathtypes/Makefile 267 src/sys/Makefile 268 src/types/Makefile 269 src/xml/Makefile 252 270 test/FullUnitTest 253 271 test/Makefile -
trunk/psLib/src/sys/psErrorCodes.c
r4540 r4541 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1.2 0$ $Name: not supported by cvs2svn $10 * @date $Date: 2005-07-12 19: 12:01$9 * @version $Revision: 1.21 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2005-07-12 19:27:27 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii -
trunk/psLib/swig/Makefile.am
r3937 r4541 6 6 7 7 SRCDIR = $(shell cd $(top_srcdir) && pwd) 8 INCLUDES = -I$(SRCDIR)/src \9 -I$(SRCDIR)/src/astronomy \10 -I$(SRCDIR)/src/collections \11 -I$(SRCDIR)/src/dataManip \12 -I$(SRCDIR)/src/dataIO \13 -I$(SRCDIR)/src/image \14 -I$(SRCDIR)/src/sysUtils \15 -I/usr/include \16 -I/usr/local/include17 8 18 9 #################################################### … … 27 18 psLibModule/setup.txt: 28 19 if [ ! -d psLibModule ]; then mkdir psLibModule; fi 29 echo "includes=$( INCLUDES)" > psLibModule/setup.txt20 echo "includes=$(SRCINC)" > psLibModule/setup.txt 30 21 echo "ldflags=-L$(top_builddir)/src $(PSLIB_LIBS)" >> psLibModule/setup.txt 31 22 echo "cflags=$(CFLAGS) -std=c99 -Wno-unused -Wno-strict-aliasing" >> psLibModule/setup.txt … … 33 24 psLibModule/pslib_wrap.c: $(srcdir)/pslib.i 34 25 if [ ! -d psLibModule ]; then mkdir psLibModule; fi 35 $(SWIG) -perl $( INCLUDES) -w451 -o $@ $(srcdir)/pslib.i26 $(SWIG) -perl $(SRCINC) -w451 -o $@ $(srcdir)/pslib.i 36 27 37 28 psLibModule/Makefile:psLibModule/Makefile.PL psLibModule/setup.txt -
trunk/psLib/swig/pslib.i
r3684 r4541 2 2 3 3 %{ 4 #define PS_ALLOW_MALLOC 4 #define PS_ALLOW_MALLOC 5 5 #define SWIG 6 6 #include "pslib.h" 7 7 8 8 /* SWIG uses malloc/free - make it use the pslib memory functions instead. */ 9 /* 9 /* 10 10 #define malloc(S) psAlloc(S) 11 11 #define realloc(P,S) psRealloc(P,S) … … 36 36 #if defined(SWIGPERL) 37 37 if (!SvOK($input)) { 38 $1 = NULL; 38 $1 = NULL; 39 39 } else { 40 40 $1 = PerlIO_findFILE(IoIFP(sv_2io($input))); … … 58 58 59 59 /* the actual including of headers are found in each of the directories. */ 60 %include "sysUtils.i" 61 %include "image.i" 62 %include "dataIO.i" 63 %include "dataManip.i" 64 %include "collections.i" 65 %include "astronomy.i" 60 %include "astro.i" 61 %include "db.i" 62 %include "fft.i" 63 %include "fits.i" 64 %include "imageops.i" 65 %include "math.i" 66 %include "mathtypes.i" 67 %include "sys.i" 68 %include "types.i" 69 %include "xml.i" -
trunk/psLib/test/astronomy/tst_psCoord.c
r4422 r4541 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1. 29$ $Name: not supported by cvs2svn $9 * @date $Date: 2005-0 6-29 00:43:46$8 * @version $Revision: 1.30 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2005-07-12 19:27:28 $ 10 10 * 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 14 14 #include "psTest.h" 15 15 #include "pslib_strict.h" 16 static psS32 testSphere TransformAlloc(void);16 static psS32 testSphereRotAlloc(void); 17 17 static psS32 testPlaneTransformAlloc(void); 18 18 static psS32 testPlaneDistortAlloc(void); 19 19 static psS32 testPlaneTransformApply(void); 20 20 static psS32 testPlaneDistortApply(void); 21 static psS32 testSphere TransformApply1(void);22 static psS32 testSphere TransformApply2(void);23 static psS32 testSphere TransformApply3(void);24 static psS32 testSphere TransformApply4(void);25 static psS32 testSphere TransformApply5(void);26 static psS32 testSphere TransformICRSToEcliptic(void);27 static psS32 testSphere TransformEclipticToICRS(void);28 static psS32 testSphere TransformICRSToGalactic(void);29 static psS32 testSphere TransformGalacticToICRS(void);30 static psS32 testSphere TransformPrecess(void);21 static psS32 testSphereRotApply1(void); 22 static psS32 testSphereRotApply2(void); 23 static psS32 testSphereRotApply3(void); 24 static psS32 testSphereRotApply4(void); 25 static psS32 testSphereRotApply5(void); 26 static psS32 testSphereRotICRSToEcliptic(void); 27 static psS32 testSphereRotEclipticToICRS(void); 28 static psS32 testSphereRotICRSToGalactic(void); 29 static psS32 testSphereRotGalacticToICRS(void); 30 static psS32 testSphereRotPrecess(void); 31 31 testDescription tests[] = { 32 {testSphere TransformAlloc, 819, "psSphereTransformAlloc()", 0, false},32 {testSphereRotAlloc, 819, "psSphereRotAlloc()", 0, false}, 33 33 {testPlaneTransformAlloc, 826, "psPlaneTransformAlloc()", 0, false}, 34 34 {testPlaneDistortAlloc, 827, "psPlaneDistortAlloc()", 0, false}, 35 35 {testPlaneTransformApply, 831, "psPlaneTransformApply()", 0, false}, 36 36 {testPlaneDistortApply, 832, "psPlaneDistortApply()", 0, false}, 37 {testSphere TransformApply1, 820, "psSphereTransformApply()", 0, false},38 {testSphere TransformApply2, 820, "psSphereTransformApply()", 0, false},39 {testSphere TransformApply3, 820, "psSphereTransformApply()", 0, false},40 {testSphere TransformApply4, 820, "psSphereTransformApply()", 0, false},41 {testSphere TransformApply5, 820, "psSphereTransformApply()", 0, false},42 {testSphere TransformICRSToEcliptic, 821, "psSphereTransformICRSToEcliptic()", 0, false},43 {testSphere TransformEclipticToICRS, 822, "psSphereTransformEclipticToICRS()", 0, false},44 {testSphere TransformICRSToGalactic, 824, "psSphereTransformICRSToGalactic()", 0, false},45 {testSphere TransformGalacticToICRS, 823, "psSphereTransformGalacticToICRS()", 0, false},46 {testSphere TransformPrecess, 825, "psSphereTransformPrecess()", 0, false},37 {testSphereRotApply1, 820, "psSphereRotApply()", 0, false}, 38 {testSphereRotApply2, 820, "psSphereRotApply()", 0, false}, 39 {testSphereRotApply3, 820, "psSphereRotApply()", 0, false}, 40 {testSphereRotApply4, 820, "psSphereRotApply()", 0, false}, 41 {testSphereRotApply5, 820, "psSphereRotApply()", 0, false}, 42 {testSphereRotICRSToEcliptic, 821, "psSphereRotICRSToEcliptic()", 0, false}, 43 {testSphereRotEclipticToICRS, 822, "psSphereRotEclipticToICRS()", 0, false}, 44 {testSphereRotICRSToGalactic, 824, "psSphereRotICRSToGalactic()", 0, false}, 45 {testSphereRotGalacticToICRS, 823, "psSphereRotGalacticToICRS()", 0, false}, 46 {testSphereRotPrecess, 825, "psSphereRotPrecess()", 0, false}, 47 47 {NULL} 48 48 }; … … 67 67 #define PHI_P 3.0 68 68 69 psS32 testSphere TransformAlloc( void )69 psS32 testSphereRotAlloc( void ) 70 70 { 71 71 // Allocate data structure 72 psSphereTransform *myST = psSphereTransformAlloc(ALPHA_P, DELTA_P, PHI_P); 72 psSphereRot* myST = psSphereRotAlloc(ALPHA_P, DELTA_P, PHI_P); 73 73 74 // Verify null not returned 74 75 if(myST == NULL) { … … 77 78 } 78 79 // Verify sin member is updated 79 psF32 sinDeltaP = sin(DELTA_P); 80 if (FLT_EPSILON < fabs(sinDeltaP - myST->sinDeltaP)) { 81 psError(PS_ERR_UNKNOWN,true,"myST->sinDeltaP is %f, should be %f\n", myST->sinDeltaP, sinDeltaP); 80 double vx = cos(DELTA_P)*cos(ALPHA_P); 81 double vy = cos(DELTA_P)*sin(ALPHA_P); 82 double vz = sin(DELTA_P); 83 double q0 = vx * sin(PHI_P/2.0); 84 double q1 = vy * sin(PHI_P/2.0); 85 double q2 = vz * sin(PHI_P/2.0); 86 double q3 = cos(PHI_P/2.0); 87 88 if (FLT_EPSILON < fabs(q0 - myST->q0)) { 89 psError(PS_ERR_UNKNOWN,true,"myST->q0 is %f, should be %f\n", myST->q0, q0); 82 90 return 2; 83 91 } 84 // Verify cos member is update 85 psF32 cosDeltaP = cos(DELTA_P); 86 if (FLT_EPSILON < fabs(cosDeltaP - myST->cosDeltaP)) { 87 psError(PS_ERR_UNKNOWN,true,"myST->cosDeltaP is %f, should be %f\n", myST->cosDeltaP, cosDeltaP); 92 if (FLT_EPSILON < fabs(q1 - myST->q1)) { 93 psError(PS_ERR_UNKNOWN,true,"myST->q1 is %f, should be %f\n", myST->q1, q1); 88 94 return 3; 89 95 } 90 // Verify alpha is updated 91 if (FLT_EPSILON < fabs(ALPHA_P - myST->alphaP)) { 92 psError(PS_ERR_UNKNOWN,true,"myST->alphaP is %f, should be %f\n", myST->alphaP, ALPHA_P); 96 if (FLT_EPSILON < fabs(q2 - myST->q2)) { 97 psError(PS_ERR_UNKNOWN,true,"myST->q2 is %f, should be %f\n", myST->q2, q2); 93 98 return 4; 94 99 } 95 // Verify phi is updated 96 if (FLT_EPSILON < fabs(PHI_P - myST->phiP)) { 97 psError(PS_ERR_UNKNOWN,true,"myST->phiP is %f, should be %f\n", myST->phiP, PHI_P); 100 if (FLT_EPSILON < fabs(q3 - myST->q3)) { 101 psError(PS_ERR_UNKNOWN,true,"myST->q0 is %f, should be %f\n", myST->q3, q3); 98 102 return 5; 99 103 } 104 100 105 // Free data structure 101 106 psFree(myST); … … 441 446 442 447 // We do a simple identity transformation on a few RA, DEC pairs. 443 psS32 testSphere TransformApply1( void )448 psS32 testSphereRotApply1( void ) 444 449 { 445 450 psSphere *in = psSphereAlloc(); … … 447 452 psSphere *temp = NULL; 448 453 psSphere *rc = NULL; 449 psSphere Transform *myST = psSphereTransformAlloc(0.0, 0.0, 0.0);454 psSphereRot *myST = psSphereRotAlloc(0.0, 0.0, 0.0); 450 455 451 456 for (float r=0.0;r<180.0;r+=DEG_INC) { … … 456 461 in->dErr = 0.0; 457 462 458 if(psSphere TransformApply(out, myST, in) != out) {463 if(psSphereRotApply(out, myST, in) != out) { 459 464 psError(PS_ERR_UNKNOWN,true,"Did not return output pointer."); 460 465 return 1; … … 472 477 473 478 // Verify new sphere object is created if out parameter NULL 474 temp = psSphere TransformApply(NULL, myST, in);479 temp = psSphereRotApply(NULL, myST, in); 475 480 if ( temp == NULL) { 476 481 psError(PS_ERR_UNKNOWN,true,"Returned NULL when out parameter was null"); … … 481 486 // Verify NULL returned if transform structure null 482 487 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error"); 483 rc = psSphere TransformApply(NULL, NULL, in);488 rc = psSphereRotApply(NULL, NULL, in); 484 489 if (rc != NULL) { 485 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply() did not return NULL.");490 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply() did not return NULL."); 486 491 return 5; 487 492 } … … 489 494 // Verify NULL returned when input sphere is NULL 490 495 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error"); 491 rc = psSphere TransformApply(NULL, myST, NULL);496 rc = psSphereRotApply(NULL, myST, NULL); 492 497 if (rc != NULL) { 493 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply() did not return NULL");498 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply() did not return NULL"); 494 499 return 6; 495 500 } … … 503 508 504 509 /****************************************************************************** 505 testSphere TransformApply2(): This test verifies that psSphereTransformApply()506 works properly. We create two psSphere Transforms: a forward transform and a510 testSphereRotApply2(): This test verifies that psSphereRotApply() 511 works properly. We create two psSphereRots: a forward transform and a 507 512 reverse transform (which is the mathematical inverse of the forward transform). 508 513 We apply both transforms to several spherical coordinates and ensure that the … … 512 517 test them both concurrently failed. Determine why this is. Are the following 513 518 spherical transforms not mathematical inverses? 514 psSphere TransformAlloc(X, Y, 0.0)515 psSphere TransformAlloc(-X, -Y, 0.0)519 psSphereRotAlloc(X, Y, 0.0) 520 psSphereRotAlloc(-X, -Y, 0.0) 516 521 *****************************************************************************/ 517 522 #define ERROR_PERCENT 0.01 518 psS32 testSphere TransformApply2( void )523 psS32 testSphereRotApply2( void ) 519 524 { 520 525 psS32 testStatus = 0; … … 522 527 psSphere out; 523 528 psSphere out2; 524 psSphere Transform *mySphereTransformForward = NULL;525 psSphere Transform *mySphereTransformReverse = NULL;526 527 528 mySphere TransformForward = psSphereTransformAlloc(DEG_TO_RAD(22.0),529 0.0,530 0.0);531 mySphere TransformReverse = psSphereTransformAlloc(DEG_TO_RAD(-22.0),532 0.0,533 0.0);529 psSphereRot *mySphereRotForward = NULL; 530 psSphereRot *mySphereRotReverse = NULL; 531 532 533 mySphereRotForward = psSphereRotAlloc(DEG_TO_RAD(22.0), 534 0.0, 535 0.0); 536 mySphereRotReverse = psSphereRotAlloc(DEG_TO_RAD(-22.0), 537 0.0, 538 0.0); 534 539 535 540 for (float r=0.1;r<180.0;r+=(DEG_INC/5.0)) { … … 540 545 in.dErr = 0.0; 541 546 542 psSphere TransformApply(&out, mySphereTransformForward, &in);543 psSphere TransformApply(&out2, mySphereTransformReverse, &out);547 psSphereRotApply(&out, mySphereRotForward, &in); 548 psSphereRotApply(&out2, mySphereRotReverse, &out); 544 549 545 550 if ((fabs((in.r - out2.r) / in.r) > ERROR_PERCENT) || … … 552 557 } 553 558 } 554 psFree(mySphere TransformForward);555 psFree(mySphere TransformReverse);556 557 mySphere TransformForward = psSphereTransformAlloc(0.0,558 DEG_TO_RAD(33.0),559 0.0);560 mySphere TransformReverse = psSphereTransformAlloc(0.0,561 DEG_TO_RAD(-33.0),562 0.0);559 psFree(mySphereRotForward); 560 psFree(mySphereRotReverse); 561 562 mySphereRotForward = psSphereRotAlloc(0.0, 563 DEG_TO_RAD(33.0), 564 0.0); 565 mySphereRotReverse = psSphereRotAlloc(0.0, 566 DEG_TO_RAD(-33.0), 567 0.0); 563 568 for (float r=0.1;r<180.0;r+=(DEG_INC/5.0)) { 564 569 for (float d=0.1;d<90.0;d+=(DEG_INC/5.0)) { … … 568 573 in.dErr = 0.0; 569 574 570 psSphere TransformApply(&out, mySphereTransformForward, &in);571 psSphere TransformApply(&out2, mySphereTransformReverse, &out);575 psSphereRotApply(&out, mySphereRotForward, &in); 576 psSphereRotApply(&out2, mySphereRotReverse, &out); 572 577 573 578 if ((fabs((in.r - out2.r) / in.r) > ERROR_PERCENT) || … … 580 585 } 581 586 } 582 psFree(mySphere TransformForward);583 psFree(mySphere TransformReverse);587 psFree(mySphereRotForward); 588 psFree(mySphereRotReverse); 584 589 585 590 return(testStatus); … … 613 618 #define SPHERE_COORD_TP3_INVERSE_D 0.523599 // 30.0 degrees 614 619 615 psS32 testSphere TransformApply3( void)616 { 617 618 psSphere Transform* testTransform;620 psS32 testSphereRotApply3( void) 621 { 622 623 psSphereRot* testTransform; 619 624 psSphere* inputCoord = psSphereAlloc(); 620 625 psSphere* outputCoord = NULL; … … 630 635 631 636 // Create transform ICRS to Galactic 632 testTransform = psSphere TransformICRSToGalactic();637 testTransform = psSphereRotICRSToGalactic(); 633 638 634 639 // Perform transform from ICRS to Galactic 635 outputCoord = psSphere TransformApply(outputCoord,testTransform,inputCoord);640 outputCoord = psSphereRotApply(outputCoord,testTransform,inputCoord); 636 641 // Verify output not NULL and member values set correctly 637 642 if(outputCoord == NULL) { 638 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply returned NULL");643 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply returned NULL"); 639 644 return 1; 640 645 } 641 646 if(fabs(outputCoord->r - SPHERE_COORD_TP1_GAL_R) > ERROR_TOL) { 642 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply return coord r %lg not as expected %lg",647 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply return coord r %lg not as expected %lg", 643 648 outputCoord->r, SPHERE_COORD_TP1_GAL_R); 644 649 return 2; 645 650 } 646 651 if(fabs(outputCoord->d - SPHERE_COORD_TP1_GAL_D) > ERROR_TOL) { 647 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply return coord d %ld not as expected %lg",652 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply return coord d %ld not as expected %lg", 648 653 outputCoord->d, SPHERE_COORD_TP1_GAL_D); 649 654 return 3; … … 652 657 653 658 // Create inverse transform Galactic to ICRS 654 testTransform = psSphere TransformGalacticToICRS();659 testTransform = psSphereRotGalacticToICRS(); 655 660 656 661 // Perform transform from Galactic to ICRS 657 inverseOutputCoord = psSphere TransformApply(inverseOutputCoord,testTransform,outputCoord);662 inverseOutputCoord = psSphereRotApply(inverseOutputCoord,testTransform,outputCoord); 658 663 // Verify output not NULL and member values set correctly 659 664 if(inverseOutputCoord == NULL) { 660 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply returned NULL");665 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply returned NULL"); 661 666 return 4; 662 667 } 663 668 664 669 if(fabs(inverseOutputCoord->r - SPHERE_COORD_TP1_INVERSE_R) > ERROR_TOL) { 665 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply return coord r %lg not as expected %lg",670 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply return coord r %lg not as expected %lg", 666 671 inverseOutputCoord->r, SPHERE_COORD_TP1_INVERSE_R); 667 672 return 5; 668 673 } 669 674 if(fabs(inverseOutputCoord->d - SPHERE_COORD_TP1_INVERSE_D) > ERROR_TOL) { 670 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply return coord d %ld not as expected %lg",675 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply return coord d %ld not as expected %lg", 671 676 inverseOutputCoord->d, SPHERE_COORD_TP1_INVERSE_D); 672 677 return 6; … … 675 680 676 681 // Create transform ICRS to Ecliptic 677 testTransform = psSphere TransformICRSToEcliptic(testDateTime);682 testTransform = psSphereRotICRSToEcliptic(testDateTime); 678 683 679 684 // Perform transform from ICRS to Ecliptic 680 outputCoord = psSphere TransformApply(outputCoord,testTransform,inputCoord);685 outputCoord = psSphereRotApply(outputCoord,testTransform,inputCoord); 681 686 // Verify output not NULL and member values set correctly 682 687 if(outputCoord == NULL) { 683 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply returned NULL");688 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply returned NULL"); 684 689 return 7; 685 690 } 686 691 if(fabs(outputCoord->r - SPHERE_COORD_TP1_ECL_R) > ERROR_TOL) { 687 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply return coord r %lg not as expected %lg",692 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply return coord r %lg not as expected %lg", 688 693 outputCoord->r, SPHERE_COORD_TP1_ECL_R); 689 694 return 8; 690 695 } 691 696 if(fabs(outputCoord->d - SPHERE_COORD_TP1_ECL_D) > ERROR_TOL) { 692 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply return coord d %ld not as expected %lg",697 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply return coord d %ld not as expected %lg", 693 698 outputCoord->d, SPHERE_COORD_TP1_ECL_D); 694 699 return 9; … … 697 702 698 703 // Create inverse transform Ecliptic to ICRS 699 testTransform = psSphere TransformEclipticToICRS(testDateTime);704 testTransform = psSphereRotEclipticToICRS(testDateTime); 700 705 701 706 // Perform transform from Ecliptic to ICRS 702 inverseOutputCoord = psSphere TransformApply(inverseOutputCoord,testTransform,outputCoord);707 inverseOutputCoord = psSphereRotApply(inverseOutputCoord,testTransform,outputCoord); 703 708 // Verify output not NULL and member values set correctly 704 709 if(inverseOutputCoord == NULL) { 705 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply returned NULL");710 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply returned NULL"); 706 711 return 10; 707 712 } 708 713 if(fabs(inverseOutputCoord->r - SPHERE_COORD_TP1_INVERSE_R) > ERROR_TOL) { 709 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply return coord r %lg not as expected %lg",714 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply return coord r %lg not as expected %lg", 710 715 inverseOutputCoord->r, SPHERE_COORD_TP1_INVERSE_R); 711 716 return 11; 712 717 } 713 718 if(fabs(inverseOutputCoord->d - SPHERE_COORD_TP1_INVERSE_D) > ERROR_TOL) { 714 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply return coord d %ld not as expected %lg",719 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply return coord d %ld not as expected %lg", 715 720 inverseOutputCoord->d, SPHERE_COORD_TP1_INVERSE_D); 716 721 return 12; … … 726 731 } 727 732 728 psS32 testSphere TransformApply4( void)729 { 730 731 psSphere Transform* testTransform;733 psS32 testSphereRotApply4( void) 734 { 735 736 psSphereRot* testTransform; 732 737 psSphere* inputCoord = psSphereAlloc(); 733 738 psSphere* outputCoord = NULL; … … 743 748 744 749 // Create transform ICRS to Galactic 745 testTransform = psSphere TransformICRSToGalactic();750 testTransform = psSphereRotICRSToGalactic(); 746 751 747 752 // Perform transform from ICRS to Galactic 748 outputCoord = psSphere TransformApply(outputCoord,testTransform,inputCoord);753 outputCoord = psSphereRotApply(outputCoord,testTransform,inputCoord); 749 754 // Verify output not NULL and member values set correctly 750 755 if(outputCoord == NULL) { 751 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply returned NULL");756 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply returned NULL"); 752 757 return 1; 753 758 } 754 759 if(fabs(outputCoord->r - SPHERE_COORD_TP2_GAL_R) > ERROR_TOL) { 755 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply return coord r %lg not as expected %lg",760 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply return coord r %lg not as expected %lg", 756 761 outputCoord->r, SPHERE_COORD_TP2_GAL_R); 757 762 return 2; 758 763 } 759 764 if(fabs(outputCoord->d - SPHERE_COORD_TP2_GAL_D) > ERROR_TOL) { 760 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply return coord d %ld not as expected %lg",765 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply return coord d %ld not as expected %lg", 761 766 outputCoord->d, SPHERE_COORD_TP2_GAL_D); 762 767 return 3; … … 765 770 766 771 // Create inverse transform Galactic to ICRS 767 testTransform = psSphere TransformGalacticToICRS();772 testTransform = psSphereRotGalacticToICRS(); 768 773 769 774 // Perform transform from Galactic to ICRS 770 inverseOutputCoord = psSphere TransformApply(inverseOutputCoord,testTransform,outputCoord);775 inverseOutputCoord = psSphereRotApply(inverseOutputCoord,testTransform,outputCoord); 771 776 // Verify output not NULL and member values set correctly 772 777 if(inverseOutputCoord == NULL) { 773 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply returned NULL");778 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply returned NULL"); 774 779 return 4; 775 780 } 776 781 // atan2 function introduces some error with y close to zero, increased error tolerance 777 782 if(fabs(inverseOutputCoord->r - SPHERE_COORD_TP2_INVERSE_R) > ERROR_TOL+0.1) { 778 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply return coord r %lg not as expected %lg",783 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply return coord r %lg not as expected %lg", 779 784 inverseOutputCoord->r, SPHERE_COORD_TP2_INVERSE_R); 780 785 return 5; 781 786 } 782 787 if(fabs(inverseOutputCoord->d - SPHERE_COORD_TP2_INVERSE_D) > ERROR_TOL) { 783 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply return coord d %ld not as expected %lg",788 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply return coord d %ld not as expected %lg", 784 789 inverseOutputCoord->d, SPHERE_COORD_TP2_INVERSE_D); 785 790 return 6; … … 788 793 789 794 // Create transform ICRS to Ecliptic 790 testTransform = psSphere TransformICRSToEcliptic(testDateTime);795 testTransform = psSphereRotICRSToEcliptic(testDateTime); 791 796 792 797 // Perform transform from ICRS to Ecliptic 793 outputCoord = psSphere TransformApply(outputCoord,testTransform,inputCoord);798 outputCoord = psSphereRotApply(outputCoord,testTransform,inputCoord); 794 799 // Verify output not NULL and member values set correctly 795 800 if(outputCoord == NULL) { 796 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply returned NULL");801 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply returned NULL"); 797 802 return 7; 798 803 } 799 804 if(fabs(outputCoord->r - SPHERE_COORD_TP2_ECL_R) > ERROR_TOL) { 800 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply return coord r %lg not as expected %lg",805 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply return coord r %lg not as expected %lg", 801 806 outputCoord->r, SPHERE_COORD_TP2_ECL_R); 802 807 return 8; 803 808 } 804 809 if(fabs(outputCoord->d - SPHERE_COORD_TP2_ECL_D) > ERROR_TOL) { 805 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply return coord d %ld not as expected %lg",810 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply return coord d %ld not as expected %lg", 806 811 outputCoord->d, SPHERE_COORD_TP2_ECL_D); 807 812 return 9; … … 810 815 811 816 // Create inverse transform Ecliptic to ICRS 812 testTransform = psSphere TransformEclipticToICRS(testDateTime);817 testTransform = psSphereRotEclipticToICRS(testDateTime); 813 818 814 819 // Perform transform from Ecliptic to ICRS 815 inverseOutputCoord = psSphere TransformApply(inverseOutputCoord,testTransform,outputCoord);820 inverseOutputCoord = psSphereRotApply(inverseOutputCoord,testTransform,outputCoord); 816 821 // Verify output not NULL and member values set correctly 817 822 if(inverseOutputCoord == NULL) { 818 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply returned NULL");823 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply returned NULL"); 819 824 return 10; 820 825 } 821 826 if(fabs(inverseOutputCoord->r - SPHERE_COORD_TP2_INVERSE_R) > ERROR_TOL) { 822 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply return coord r %lg not as expected %lg",827 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply return coord r %lg not as expected %lg", 823 828 inverseOutputCoord->r, SPHERE_COORD_TP2_INVERSE_R); 824 829 return 11; 825 830 } 826 831 if(fabs(inverseOutputCoord->d - SPHERE_COORD_TP2_INVERSE_D) > ERROR_TOL) { 827 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply return coord d %ld not as expected %lg",832 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply return coord d %ld not as expected %lg", 828 833 inverseOutputCoord->d, SPHERE_COORD_TP2_INVERSE_D); 829 834 return 12; … … 839 844 } 840 845 841 psS32 testSphere TransformApply5( void)842 { 843 psSphere Transform* testTransform;846 psS32 testSphereRotApply5( void) 847 { 848 psSphereRot* testTransform; 844 849 psSphere* inputCoord = psSphereAlloc(); 845 850 psSphere* outputCoord = NULL; … … 855 860 856 861 // Create transform ICRS to Galactic 857 testTransform = psSphere TransformICRSToGalactic();862 testTransform = psSphereRotICRSToGalactic(); 858 863 859 864 // Perform transform from ICRS to Galactic 860 outputCoord = psSphere TransformApply(outputCoord,testTransform,inputCoord);865 outputCoord = psSphereRotApply(outputCoord,testTransform,inputCoord); 861 866 // Verify output not NULL and member values set correctly 862 867 if(outputCoord == NULL) { 863 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply returned NULL");868 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply returned NULL"); 864 869 return 1; 865 870 } 866 871 if(fabs(outputCoord->r - SPHERE_COORD_TP3_GAL_R) > ERROR_TOL) { 867 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply return coord r %lg not as expected %lg",872 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply return coord r %lg not as expected %lg", 868 873 outputCoord->r, SPHERE_COORD_TP3_GAL_R); 869 874 return 2; 870 875 } 871 876 if(fabs(outputCoord->d - SPHERE_COORD_TP3_GAL_D) > ERROR_TOL) { 872 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply return coord d %ld not as expected %lg",877 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply return coord d %ld not as expected %lg", 873 878 outputCoord->d, SPHERE_COORD_TP3_GAL_D); 874 879 return 3; … … 877 882 878 883 // Create inverse transform Galactic to ICRS 879 testTransform = psSphere TransformGalacticToICRS();884 testTransform = psSphereRotGalacticToICRS(); 880 885 881 886 // Perform transform from Galactic to ICRS 882 inverseOutputCoord = psSphere TransformApply(inverseOutputCoord,testTransform,outputCoord);887 inverseOutputCoord = psSphereRotApply(inverseOutputCoord,testTransform,outputCoord); 883 888 // Verify output not NULL and member values set correctly 884 889 if(inverseOutputCoord == NULL) { 885 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply returned NULL");890 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply returned NULL"); 886 891 return 4; 887 892 } 888 893 if(fabs(inverseOutputCoord->r - SPHERE_COORD_TP3_INVERSE_R) > ERROR_TOL+0.1) { 889 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply return coord r %lg not as expected %lg",894 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply return coord r %lg not as expected %lg", 890 895 inverseOutputCoord->r, SPHERE_COORD_TP3_INVERSE_R); 891 896 return 5; 892 897 } 893 898 if(fabs(inverseOutputCoord->d - SPHERE_COORD_TP3_INVERSE_D) > ERROR_TOL) { 894 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply return coord d %ld not as expected %lg",899 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply return coord d %ld not as expected %lg", 895 900 inverseOutputCoord->d, SPHERE_COORD_TP3_INVERSE_D); 896 901 return 6; … … 899 904 900 905 // Create transform ICRS to Ecliptic 901 testTransform = psSphere TransformICRSToEcliptic(testDateTime);906 testTransform = psSphereRotICRSToEcliptic(testDateTime); 902 907 903 908 // Perform transform from ICRS to Ecliptic 904 outputCoord = psSphere TransformApply(outputCoord,testTransform,inputCoord);909 outputCoord = psSphereRotApply(outputCoord,testTransform,inputCoord); 905 910 // Verify output not NULL and member values set correctly 906 911 if(outputCoord == NULL) { 907 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply returned NULL");912 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply returned NULL"); 908 913 return 7; 909 914 } 910 915 if(fabs(outputCoord->r - SPHERE_COORD_TP3_ECL_R) > ERROR_TOL) { 911 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply return coord r %lg not as expected %lg",916 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply return coord r %lg not as expected %lg", 912 917 outputCoord->r, SPHERE_COORD_TP3_ECL_R); 913 918 return 8; 914 919 } 915 920 if(fabs(outputCoord->d - SPHERE_COORD_TP3_ECL_D) > ERROR_TOL) { 916 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply return coord d %ld not as expected %lg",921 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply return coord d %ld not as expected %lg", 917 922 outputCoord->d, SPHERE_COORD_TP3_ECL_D); 918 923 return 9; … … 921 926 922 927 // Create inverse transform Ecliptic to ICRS 923 testTransform = psSphere TransformEclipticToICRS(testDateTime);928 testTransform = psSphereRotEclipticToICRS(testDateTime); 924 929 925 930 // Perform transform from Ecliptic to ICRS 926 inverseOutputCoord = psSphere TransformApply(inverseOutputCoord,testTransform,outputCoord);931 inverseOutputCoord = psSphereRotApply(inverseOutputCoord,testTransform,outputCoord); 927 932 // Verify output not NULL and member values set correctly 928 933 if(inverseOutputCoord == NULL) { 929 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply returned NULL");934 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply returned NULL"); 930 935 return 10; 931 936 } 932 937 if(fabs(inverseOutputCoord->r - SPHERE_COORD_TP3_INVERSE_R) > ERROR_TOL) { 933 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply return coord r %lg not as expected %lg",938 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply return coord r %lg not as expected %lg", 934 939 inverseOutputCoord->r, SPHERE_COORD_TP3_INVERSE_R); 935 940 return 11; 936 941 } 937 942 if(fabs(inverseOutputCoord->d - SPHERE_COORD_TP3_INVERSE_D) > ERROR_TOL) { 938 psError(PS_ERR_UNKNOWN,true,"psSphere TransformApply return coord d %ld not as expected %lg",943 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply return coord d %ld not as expected %lg", 939 944 inverseOutputCoord->d, SPHERE_COORD_TP3_INVERSE_D); 940 945 return 12; … … 963 968 #define SPHERE_PRECESS_TP3_EXPECT_D 0.543024 // 31.113 degrees 964 969 965 psS32 testSphere TransformPrecess( void )970 psS32 testSphereRotPrecess( void ) 966 971 { 967 972 psSphere* inputCoord = psSphereAlloc(); … … 1080 1085 } 1081 1086 1082 // Thes values calculated from ADD-09 equations 1083 #define EXPECT_COS_DELTAP_2000 0.917482 1084 #define EXPECT_SIN_DELTAP_2000 0.397777 1085 #define EXPECT_COS_DELTAP_2100 0.917572 1086 #define EXPECT_SIN_DELTAP_2100 0.397567 1087 1088 psS32 testSphereTransformICRSToEcliptic( void ) 1087 psS32 testSphereRotICRSToEcliptic( void ) 1088 { 1089 psF64 expectedQ0 = 0.0; 1090 psF64 expectedQ1 = 0.0; 1091 psF64 expectedQ2 = 0.0; 1092 psF64 expectedQ3 = 0.0; 1093 1094 // Set test date time to 1/1/2000 00:00:00 1095 psTime* testDateTime = psTimeFromMJD(MJD_2000); 1096 1097 // Invoke function to set psSphereRota objec 1098 psSphereRot *myST = psSphereRotICRSToEcliptic(testDateTime); 1099 1100 // Verify expected values for the specified time 1101 if (ERROR_TOL < fabs(expectedQ0 - myST->q0)) { 1102 psError(PS_ERR_UNKNOWN,true,"myST->q0 is %f, should be %f", 1103 myST->q0, expectedQ0); 1104 return 1; 1105 } 1106 if (ERROR_TOL < fabs(expectedQ1 - myST->q1)) { 1107 psError(PS_ERR_UNKNOWN,true,"myST->q1 is %f, should be %f", 1108 myST->q1, expectedQ1); 1109 return 2; 1110 } 1111 if (ERROR_TOL < fabs(expectedQ2 - myST->q2)) { 1112 psError(PS_ERR_UNKNOWN,true,"myST->q2 is %f, should be %f", 1113 myST->q2, expectedQ2); 1114 return 3; 1115 } 1116 if (ERROR_TOL < fabs(expectedQ3 - myST->q3)) { 1117 psError(PS_ERR_UNKNOWN,true,"myST->q3 is %f, should be %f", 1118 myST->q3, expectedQ3); 1119 return 4; 1120 } 1121 psFree(myST); 1122 psFree(testDateTime); 1123 1124 // Set test date time to 1/1/2100 00:00:00 1125 testDateTime = psTimeFromMJD(MJD_2100); 1126 1127 // Invoke function to set psSphereRota objec 1128 myST = psSphereRotICRSToEcliptic(testDateTime); 1129 1130 // Verify expected values for the specified time 1131 // Verify expected values for the specified time 1132 if (ERROR_TOL < fabs(expectedQ0 - myST->q0)) { 1133 psError(PS_ERR_UNKNOWN,true,"myST->q0 is %f, should be %f", 1134 myST->q0, expectedQ0); 1135 return 5; 1136 } 1137 if (ERROR_TOL < fabs(expectedQ1 - myST->q1)) { 1138 psError(PS_ERR_UNKNOWN,true,"myST->q1 is %f, should be %f", 1139 myST->q1, expectedQ1); 1140 return 6; 1141 } 1142 if (ERROR_TOL < fabs(expectedQ2 - myST->q2)) { 1143 psError(PS_ERR_UNKNOWN,true,"myST->q2 is %f, should be %f", 1144 myST->q2, expectedQ2); 1145 return 7; 1146 } 1147 if (ERROR_TOL < fabs(expectedQ3 - myST->q3)) { 1148 psError(PS_ERR_UNKNOWN,true,"myST->q3 is %f, should be %f", 1149 myST->q3, expectedQ3); 1150 return 8; 1151 } 1152 psFree(myST); 1153 psFree(testDateTime); 1154 1155 // Verify if argument psTime is NULL, function returns NULL and error message generated 1156 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message"); 1157 myST = psSphereRotICRSToEcliptic(NULL); 1158 if (myST != NULL) { 1159 psError(PS_ERR_UNKNOWN,true,"psSphereRotICRSToEcliptic() did not return NULL."); 1160 return 9; 1161 } 1162 1163 // Verify if argument psTime is less than 1900, function return NULL and error msg generated 1164 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message"); 1165 testDateTime = psTimeFromMJD(MJD_1900 - 1.0); 1166 myST = psSphereRotICRSToEcliptic(testDateTime); 1167 if (myST != NULL) { 1168 psError(PS_ERR_UNKNOWN,true,"psSphereRotICRSToEcliptic() did not return NULL."); 1169 return 10; 1170 } 1171 psFree(testDateTime); 1172 1173 return 0; 1174 } 1175 1176 1177 psS32 testSphereRotEclipticToICRS( void ) 1089 1178 { 1090 1179 psF64 expectedPhiP = 0.0; 1091 1180 psF64 expectedAlphaP = 0.0; 1092 psF64 expectedCosDeltaP = EXPECT_COS_DELTAP_2000;1093 psF64 expectedSinDeltaP = EXPECT_SIN_DELTAP_2000;1181 psF64 expectedCosDeltaP = 0.0; 1182 psF64 expectedSinDeltaP = 0.0; 1094 1183 1095 1184 // Set test date time to 1/1/2000 00:00:00 1096 1185 psTime* testDateTime = psTimeFromMJD(MJD_2000); 1097 1186 1098 // Invoke function to set psSphere Transforma objec1099 psSphere Transform *myST = psSphereTransformICRSToEcliptic(testDateTime);1187 // Invoke function to set psSphereRota object 1188 psSphereRot *myST = psSphereRotEclipticToICRS(testDateTime); 1100 1189 1101 1190 // Verify expected values for the specified time … … 1124 1213 1125 1214 expectedCosDeltaP = EXPECT_COS_DELTAP_2100; 1126 expectedSinDeltaP = EXPECT_SIN_DELTAP_2100;1215 expectedSinDeltaP = -EXPECT_SIN_DELTAP_2100; 1127 1216 1128 1217 // Set test date time to 1/1/2100 00:00:00 1129 1218 testDateTime = psTimeFromMJD(MJD_2100); 1130 1219 1131 // Invoke function to set psSphere Transforma objec1132 myST = psSphere TransformICRSToEcliptic(testDateTime);1220 // Invoke function to set psSphereRota objec 1221 myST = psSphereRotEclipticToICRS(testDateTime); 1133 1222 1134 1223 // Verify expected values for the specified time … … 1158 1247 // Verify if argument psTime is NULL, function returns NULL and error message generated 1159 1248 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message"); 1160 myST = psSphere TransformICRSToEcliptic(NULL);1249 myST = psSphereRotEclipticToICRS(NULL); 1161 1250 if (myST != NULL) { 1162 psError(PS_ERR_UNKNOWN,true,"psSphere TransformICRSToEcliptic() did not return NULL.");1251 psError(PS_ERR_UNKNOWN,true,"psSphereRotEclipticICRS() did not return NULL."); 1163 1252 return 9; 1164 1253 } … … 1167 1256 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message"); 1168 1257 testDateTime = psTimeFromMJD(MJD_1900 - 1.0); 1169 myST = psSphere TransformICRSToEcliptic(testDateTime);1258 myST = psSphereRotEclipticToICRS(testDateTime); 1170 1259 if (myST != NULL) { 1171 psError(PS_ERR_UNKNOWN,true,"psSphereTransformICRSToEcliptic() did not return NULL."); 1172 return 10; 1173 } 1174 psFree(testDateTime); 1175 1176 return 0; 1177 } 1178 1179 1180 psS32 testSphereTransformEclipticToICRS( void ) 1181 { 1182 psF64 expectedPhiP = 0.0; 1183 psF64 expectedAlphaP = 0.0; 1184 psF64 expectedCosDeltaP = EXPECT_COS_DELTAP_2000; 1185 psF64 expectedSinDeltaP = -EXPECT_SIN_DELTAP_2000; 1186 1187 // Set test date time to 1/1/2000 00:00:00 1188 psTime* testDateTime = psTimeFromMJD(MJD_2000); 1189 1190 // Invoke function to set psSphereTransforma object 1191 psSphereTransform *myST = psSphereTransformEclipticToICRS(testDateTime); 1192 1193 // Verify expected values for the specified time 1194 if (ERROR_TOL < fabs(expectedSinDeltaP - myST->sinDeltaP)) { 1195 psError(PS_ERR_UNKNOWN,true,"myST->sinDeltaP is %f, should be %f", 1196 myST->sinDeltaP, expectedSinDeltaP); 1197 return 1; 1198 } 1199 if (ERROR_TOL < fabs(expectedCosDeltaP - myST->cosDeltaP)) { 1200 psError(PS_ERR_UNKNOWN,true,"myST->cosDeltaP is %f, should be %f", 1201 myST->cosDeltaP, expectedCosDeltaP); 1202 return 2; 1203 } 1204 if (ERROR_TOL < fabs(expectedAlphaP - myST->alphaP)) { 1205 psError(PS_ERR_UNKNOWN,true,"myST->alphaP is %f, should be %f", 1206 myST->alphaP, expectedAlphaP); 1207 return 3; 1208 } 1209 if (ERROR_TOL < fabs(expectedPhiP - myST->phiP)) { 1210 psError(PS_ERR_UNKNOWN,true,"myST->phiP is %f, should be %f", 1211 myST->phiP, expectedPhiP); 1212 return 4; 1213 } 1214 psFree(myST); 1215 psFree(testDateTime); 1216 1217 expectedCosDeltaP = EXPECT_COS_DELTAP_2100; 1218 expectedSinDeltaP = -EXPECT_SIN_DELTAP_2100; 1219 1220 // Set test date time to 1/1/2100 00:00:00 1221 testDateTime = psTimeFromMJD(MJD_2100); 1222 1223 // Invoke function to set psSphereTransforma objec 1224 myST = psSphereTransformEclipticToICRS(testDateTime); 1225 1226 // Verify expected values for the specified time 1227 if (ERROR_TOL < fabs(expectedSinDeltaP - myST->sinDeltaP)) { 1228 psError(PS_ERR_UNKNOWN,true,"myST->sinDeltaP is %f, should be %f", 1229 myST->sinDeltaP, expectedSinDeltaP); 1230 return 5; 1231 } 1232 if (ERROR_TOL < fabs(expectedCosDeltaP - myST->cosDeltaP)) { 1233 psError(PS_ERR_UNKNOWN,true,"myST->cosDeltaP is %f, should be %f", 1234 myST->cosDeltaP, expectedCosDeltaP); 1235 return 6; 1236 } 1237 if (ERROR_TOL < fabs(expectedAlphaP - myST->alphaP)) { 1238 psError(PS_ERR_UNKNOWN,true,"myST->alphaP is %f, should be %f", 1239 myST->alphaP, expectedAlphaP); 1240 return 7; 1241 } 1242 if (ERROR_TOL < fabs(expectedPhiP - myST->phiP)) { 1243 psError(PS_ERR_UNKNOWN,true,"myST->phiP is %f, should be %f", 1244 myST->phiP, expectedPhiP); 1245 return 8; 1246 } 1247 psFree(myST); 1248 psFree(testDateTime); 1249 1250 // Verify if argument psTime is NULL, function returns NULL and error message generated 1251 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message"); 1252 myST = psSphereTransformEclipticToICRS(NULL); 1253 if (myST != NULL) { 1254 psError(PS_ERR_UNKNOWN,true,"psSphereTransformEclipticICRS() did not return NULL."); 1255 return 9; 1256 } 1257 1258 // Verify if argument psTime is less than 1900, function return NULL and error msg generated 1259 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message"); 1260 testDateTime = psTimeFromMJD(MJD_1900 - 1.0); 1261 myST = psSphereTransformEclipticToICRS(testDateTime); 1262 if (myST != NULL) { 1263 psError(PS_ERR_UNKNOWN,true,"psSphereTransformEclipticToICRS() did not return NULL."); 1260 psError(PS_ERR_UNKNOWN,true,"psSphereRotEclipticToICRS() did not return NULL."); 1264 1261 return 10; 1265 1262 } … … 1274 1271 #define ITG_EXPECT_PHIP 0.57477 1275 1272 1276 psS32 testSphere TransformICRSToGalactic( void )1273 psS32 testSphereRotICRSToGalactic( void ) 1277 1274 { 1278 1275 // Invoke function 1279 psSphere Transform *myST = psSphereTransformICRSToGalactic();1276 psSphereRot *myST = psSphereRotICRSToGalactic(); 1280 1277 1281 1278 // Verify did not return NULL 1282 1279 if(myST == NULL) { 1283 psError(PS_ERR_UNKNOWN,true,"psSphere TransformICRSToGalactic returned NULL");1280 psError(PS_ERR_UNKNOWN,true,"psSphereRotICRSToGalactic returned NULL"); 1284 1281 return 1; 1285 1282 } … … 1316 1313 #define GTI_EXPECT_ALPHAP 0.57477 1317 1314 1318 psS32 testSphere TransformGalacticToICRS( void )1315 psS32 testSphereRotGalacticToICRS( void ) 1319 1316 { 1320 1317 // Invoke function 1321 psSphere Transform *myST = psSphereTransformGalacticToICRS();1318 psSphereRot *myST = psSphereRotGalacticToICRS(); 1322 1319 1323 1320 // Verify did not return NULL 1324 1321 if(myST == NULL) { 1325 psError(PS_ERR_UNKNOWN,true,"psSphere TransformGalacticToICRS returned NULL");1322 psError(PS_ERR_UNKNOWN,true,"psSphereRotGalacticToICRS returned NULL"); 1326 1323 return 1; 1327 1324 } -
trunk/psLib/test/image/tst_psImageGeomManip.c
r4308 r4541 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $9 * @date $Date: 2005-0 6-17 23:44:22$8 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2005-07-12 19:27:28 $ 10 10 * 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 1085 1085 1086 1086 psImage* in = psImageAlloc(cols,rows,PS_TYPE_F32); 1087 psImage* mask = psImageAlloc(cols,rows,PS_TYPE_MASK); 1087 1088 for (psS32 row=0;row<rows;row++) { 1088 1089 psF32* inRow = in->data.F32[row]; 1090 psMaskType* maskRow = mask->data.PS_TYPE_MASK_DATA[row]; 1089 1091 for (psS32 col=0;col<cols;col++) { 1090 1092 inRow[col] = (psF32)row+(psF32)col/1000.0f; 1091 } 1092 } 1093 maskRow[col] = 0; 1094 } 1095 } 1096 1097 1098 // ********** check psImageTransform with minimum specified inputs. 1093 1099 1094 1100 psImage* out = psImageTransform(NULL, … … 1138 1144 } 1139 1145 1146 // zero out buffer 1147 memset(out->rawDataBuffer, 0, sizeof(psF32)*out->numRows*out->numCols); 1148 1149 psPixels* blanks = psPixelsAlloc(10); 1150 psPixels* mask = psPixelsAlloc(10); 1151 1152 // perform the same transform, but this time, supply a psImage to recycle and a mask 1153 out = psImageTransform(out, 1154 blanks, 1155 in, 1156 mask, 1157 1, 1158 trans, 1159 psRegionSet(0,0,0,0), 1160 NULL, 1161 PS_INTERPOLATE_FLAT, 1162 -1); 1163 1164 if (out == NULL) { 1165 psError(PS_ERR_UNKNOWN, false, 1166 "out == NULL"); 1167 return 1; 1168 } 1169 if (out->type.type != PS_TYPE_F32) { 1170 psError(PS_ERR_UNKNOWN, false, 1171 "out->type.type != PS_TYPE_F32, out->type.type == %d", 1172 out->type.type); 1173 return 2; 1174 } 1175 if (out->numRows != rows*2 || out->numCols != cols*2) { 1176 psError(PS_ERR_UNKNOWN, false, 1177 "out size is %dx%d, not %dx%d", 1178 out->numCols, out->numRows, cols*2, rows); 1179 return 3; 1180 } 1181 1182 for (psS32 row=0;row<out->numRows;row++) { 1183 psF32* outRow = out->data.F32[row]; 1184 for (psS32 col=0;col<cols;col++) { 1185 float inValue = p_psImagePixelInterpolateFLAT_F32(in, 1186 col*trans->x->coeff[1][0]+trans->x->coeff[0][0], 1187 row*trans->y->coeff[0][1]+trans->y->coeff[0][0], 1188 NULL, 0, 1189 -1); 1190 if (fabsf(outRow[col] - inValue) > FLT_EPSILON*10) { 1191 psError(PS_ERR_UNKNOWN, false, 1192 "out at %d,%d was %g, expected %g", 1193 col,row,outRow[col], inValue); 1194 return 4; 1195 } 1196 } 1197 } 1198 1199 1140 1200 psFree(out); 1141 1201 psFree(in);
Note:
See TracChangeset
for help on using the changeset viewer.
