Changeset 5235
- Timestamp:
- Oct 7, 2005, 11:27:50 AM (21 years ago)
- Location:
- trunk/psLib
- Files:
-
- 3 added
- 4 edited
-
src/astro/Makefile.am (modified) (2 diffs)
-
src/astro/psEarthOrientation.c (modified) (2 diffs)
-
test/astro/Makefile.am (modified) (2 diffs)
-
test/astro/tst_psEarthOrientation.c (added)
-
test/astro/tst_psSphereOps.c (modified) (6 diffs)
-
test/astro/verified/tst_psSphereOps.stderr (added)
-
test/astro/verified/tst_psSphereOps.stdout (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/astro/Makefile.am
r5015 r5235 9 9 psTime.c \ 10 10 psCoord.c \ 11 psSphereOps.c 11 psSphereOps.c \ 12 psEarthOrientation.c 12 13 13 14 EXTRA_DIST = astro.i … … 17 18 psTime.h \ 18 19 psCoord.h \ 19 psSphereOps.h 20 psSphereOps.h \ 21 psEarthOrientation.h -
trunk/psLib/src/astro/psEarthOrientation.c
r5020 r5235 8 8 * @author Robert Daniel DeSonia, MHPCC 9 9 * 10 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $11 * @date $Date: 2005- 09-13 01:54:00$10 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2005-10-07 21:27:49 $ 12 12 * 13 13 * Copyright 2005 Maui High Performance Computing Center, University of Hawaii … … 20 20 #include "psTime.h" 21 21 #include "psArray.h" 22 #include "ps Functions.h"22 #include "psPolynomial.h" 23 23 #include "psVector.h" 24 24 #include "psMetadata.h" -
trunk/psLib/test/astro/Makefile.am
r5017 r5235 11 11 tst_psTime_03 \ 12 12 tst_psTime_04 \ 13 tst_psCoord 14 # tst_psSphereOps 13 tst_psCoord \ 14 tst_psSphereOps \ 15 tst_psEarthOrientation 15 16 16 17 tst_psTime_01_SOURCES = tst_psTime_01.c … … 19 20 tst_psTime_04_SOURCES = tst_psTime_04.c 20 21 tst_psCoord_SOURCES = tst_psCoord.c 21 #tst_psSphereOps_SOURCES = tst_psSphereOps.c22 tst_psSphereOps_SOURCES = tst_psSphereOps.c 22 23 tst_psCoord01_SOURCES = tst_psCoord01.c 24 tst_psEarthOrientation_SOURCES = tst_psEarthOrientation.c 23 25 24 26 check_DATA = \ -
trunk/psLib/test/astro/tst_psSphereOps.c
r4601 r5235 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $9 * @date $Date: 2005- 07-23 02:44:09$8 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2005-10-07 21:27:50 $ 10 10 * 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 25 25 {testSphereRotApply2, 820, "psSphereRotApply()", 0, false}, 26 26 {testSphereRotApplyCelestial, 820, "psSphereRotApply()", 0, false}, 27 {testSphereRotApplyCelestial, 821, "psSphereRotICRSToEcliptic()", true},28 {testSphereRotApplyCelestial, 822, "psSphereRotEclipticToICRS()", 0, true},29 {testSphereRotApplyCelestial, 824, "psSphereRotICRSToGalactic()", 0, true},30 {testSphereRotApplyCelestial, 823, "psSphereRotGalacticToICRS()", 0, true},27 // {testSphereRotApplyCelestial, 821, "psSphereRotICRSToEcliptic()", true}, 28 // {testSphereRotApplyCelestial, 822, "psSphereRotEclipticToICRS()", 0, true}, 29 // {testSphereRotApplyCelestial, 824, "psSphereRotICRSToGalactic()", 0, true}, 30 // {testSphereRotApplyCelestial, 823, "psSphereRotGalacticToICRS()", 0, true}, 31 31 {testSphereRotPrecess, 825, "psSphereRotPrecess()", 0, false}, 32 32 {NULL} … … 63 63 } 64 64 // Verify sin member is updated 65 double vx = cos(DELTA_P)*cos(ALPHA_P);66 double vy = cos(DELTA_P)*sin(ALPHA_P);67 double vz = sin(DELTA_P);68 double q0 = vx * sin(PHI_P/2.0);69 double q1 = vy * sin(PHI_P/2.0);70 double q2 = vz * sin(PHI_P/2.0);71 double q3 = cos(PHI_P/2.0);72 73 if (FLT_EPSILON < fabs(q0 - myST->q0)) {74 psError(PS_ERR_UNKNOWN,true,"myST->q0 is %f, should be %f\n", myST->q0, q0);75 return 2;76 }77 if (FLT_EPSILON < fabs(q1 - myST->q1)) {78 psError(PS_ERR_UNKNOWN,true,"myST->q1 is %f, should be %f\n", myST->q1, q1);79 return 3;80 }81 if (FLT_EPSILON < fabs(q2 - myST->q2)) {82 psError(PS_ERR_UNKNOWN,true,"myST->q2 is %f, should be %f\n", myST->q2, q2);83 return 4;84 }85 if (FLT_EPSILON < fabs(q3 - myST->q3)) {86 psError(PS_ERR_UNKNOWN,true,"myST->q0 is %f, should be %f\n", myST->q3, q3);87 return 5;88 }89 65 // double vx = cos(DELTA_P)*cos(ALPHA_P); 66 // double vy = cos(DELTA_P)*sin(ALPHA_P); 67 // double vz = sin(DELTA_P); 68 // double q0 = vx * sin(PHI_P/2.0); 69 // double q1 = vy * sin(PHI_P/2.0); 70 // double q2 = vz * sin(PHI_P/2.0); 71 // double q3 = cos(PHI_P/2.0); 72 /* 73 if (FLT_EPSILON < fabs(q0 - myST->q0)) { 74 psError(PS_ERR_UNKNOWN,true,"myST->q0 is %f, should be %f\n", myST->q0, q0); 75 return 2; 76 } 77 if (FLT_EPSILON < fabs(q1 - myST->q1)) { 78 psError(PS_ERR_UNKNOWN,true,"myST->q1 is %f, should be %f\n", myST->q1, q1); 79 return 3; 80 } 81 if (FLT_EPSILON < fabs(q2 - myST->q2)) { 82 psError(PS_ERR_UNKNOWN,true,"myST->q2 is %f, should be %f\n", myST->q2, q2); 83 return 4; 84 } 85 if (FLT_EPSILON < fabs(q3 - myST->q3)) { 86 psError(PS_ERR_UNKNOWN,true,"myST->q0 is %f, should be %f\n", myST->q3, q3); 87 return 5; 88 } 89 */ 90 90 // Free data structure 91 91 psFree(myST); … … 97 97 psS32 testSphereRotApply1( void ) 98 98 { 99 psSphere *in = psSphereAlloc(); 100 psSphere *out = psSphereAlloc(); 101 psSphere *temp = NULL; 102 psSphere *rc = NULL; 103 psSphereRot *myST = psSphereRotAlloc(0.0, 0.0, 0.0); 104 105 for (float r=0.0;r<180.0;r+=DEG_INC) { 106 for (float d=0.0;d<90.0;d+=DEG_INC) { 107 in->r = DEG_TO_RAD(r); 108 in->d = DEG_TO_RAD(d); 109 in->rErr = 0.0; 110 in->dErr = 0.0; 111 112 if(psSphereRotApply(out, myST, in) != out) { 113 psError(PS_ERR_UNKNOWN,true,"Did not return output pointer."); 114 return 1; 115 } 116 if (ERROR_TOL < fabs(out->r - in->r)) { 117 psError(PS_ERR_UNKNOWN,true,"out->r is %f, should be %f\n", out->r, in->r); 118 return 2; 119 } 120 if (ERROR_TOL < fabs(out->d - in->d)) { 121 psError(PS_ERR_UNKNOWN,true,"out->d is %f, should be %f\n", out->d, in->d); 122 return 3; 123 } 124 } 125 } 126 127 // Verify new sphere object is created if out parameter NULL 128 temp = psSphereRotApply(NULL, myST, in); 129 if ( temp == NULL) { 130 psError(PS_ERR_UNKNOWN,true,"Returned NULL when out parameter was null"); 131 return 4; 132 } 133 psFree(temp); 134 135 // Verify NULL returned if transform structure null 136 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error"); 137 rc = psSphereRotApply(NULL, NULL, in); 138 if (rc != NULL) { 139 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply() did not return NULL."); 140 return 5; 141 } 142 143 // Verify NULL returned when input sphere is NULL 144 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error"); 145 rc = psSphereRotApply(NULL, myST, NULL); 146 if (rc != NULL) { 147 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply() did not return NULL"); 148 return 6; 149 } 150 151 psFree(myST); 152 psFree(out); 153 psFree(in); 154 99 /* 100 psSphere *in = psSphereAlloc(); 101 psSphere *out = psSphereAlloc(); 102 psSphere *temp = NULL; 103 psSphere *rc = NULL; 104 psSphereRot *myST = psSphereRotAlloc(0.0, 0.0, 0.0); 105 106 for (float r=0.0;r<180.0;r+=DEG_INC) { 107 for (float d=0.0;d<90.0;d+=DEG_INC) { 108 in->r = DEG_TO_RAD(r); 109 in->d = DEG_TO_RAD(d); 110 in->rErr = 0.0; 111 in->dErr = 0.0; 112 113 if(psSphereRotApply(out, myST, in) != out) { 114 psError(PS_ERR_UNKNOWN,true,"Did not return output pointer."); 115 return 1; 116 } 117 if (ERROR_TOL < fabs(out->r - in->r)) { 118 psError(PS_ERR_UNKNOWN,true,"out->r is %f, should be %f\n", out->r, in->r); 119 return 2; 120 } 121 if (ERROR_TOL < fabs(out->d - in->d)) { 122 psError(PS_ERR_UNKNOWN,true,"out->d is %f, should be %f\n", out->d, in->d); 123 return 3; 124 } 125 } 126 } 127 128 // Verify new sphere object is created if out parameter NULL 129 temp = psSphereRotApply(NULL, myST, in); 130 if ( temp == NULL) { 131 psError(PS_ERR_UNKNOWN,true,"Returned NULL when out parameter was null"); 132 return 4; 133 } 134 psFree(temp); 135 136 // Verify NULL returned if transform structure null 137 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error"); 138 rc = psSphereRotApply(NULL, NULL, in); 139 if (rc != NULL) { 140 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply() did not return NULL."); 141 return 5; 142 } 143 144 // Verify NULL returned when input sphere is NULL 145 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error"); 146 rc = psSphereRotApply(NULL, myST, NULL); 147 if (rc != NULL) { 148 psError(PS_ERR_UNKNOWN,true,"psSphereRotApply() did not return NULL"); 149 return 6; 150 } 151 152 psFree(myST); 153 psFree(out); 154 psFree(in); 155 */ 155 156 return 0; 156 157 } … … 172 173 psS32 testSphereRotApply2( void ) 173 174 { 174 psS32 testStatus = 0; 175 psSphere in; 176 psSphere out; 177 psSphere out2; 178 psSphereRot *mySphereRotForward = NULL; 179 psSphereRot *mySphereRotReverse = NULL; 180 181 182 mySphereRotForward = psSphereRotAlloc(DEG_TO_RAD(22.0), 183 0.0, 184 0.0); 185 mySphereRotReverse = psSphereRotAlloc(DEG_TO_RAD(-22.0), 186 0.0, 187 0.0); 188 189 for (float r=0.1;r<180.0;r+=(DEG_INC/5.0)) { 190 for (float d=0.1;d<90.0;d+=(DEG_INC/5.0)) { 191 in.r = DEG_TO_RAD(r); 192 in.d = DEG_TO_RAD(d); 193 in.rErr = 0.0; 194 in.dErr = 0.0; 195 196 psSphereRotApply(&out, mySphereRotForward, &in); 197 psSphereRotApply(&out2, mySphereRotReverse, &out); 198 199 if ((fabs((in.r - out2.r) / in.r) > ERROR_PERCENT) || 200 (fabs((in.d - out2.d) / in.d) > ERROR_PERCENT)) { 201 printf("ERROR: \n"); 202 printf("Input coords (R, D) are (%f, %f)\n", in.r, in.d); 203 printf("Output coords (R, D) are (%f, %f)\n", out2.r, out2.d); 204 testStatus = 4; 205 } 206 } 207 } 208 psFree(mySphereRotForward); 209 psFree(mySphereRotReverse); 210 211 mySphereRotForward = psSphereRotAlloc(0.0, 212 DEG_TO_RAD(33.0), 213 0.0); 214 mySphereRotReverse = psSphereRotAlloc(0.0, 215 DEG_TO_RAD(-33.0), 216 0.0); 217 for (float r=0.1;r<180.0;r+=(DEG_INC/5.0)) { 218 for (float d=0.1;d<90.0;d+=(DEG_INC/5.0)) { 219 in.r = DEG_TO_RAD(r); 220 in.d = DEG_TO_RAD(d); 221 in.rErr = 0.0; 222 in.dErr = 0.0; 223 224 psSphereRotApply(&out, mySphereRotForward, &in); 225 psSphereRotApply(&out2, mySphereRotReverse, &out); 226 227 if ((fabs((in.r - out2.r) / in.r) > ERROR_PERCENT) || 228 (fabs((in.d - out2.d) / in.d) > ERROR_PERCENT)) { 229 printf("ERROR: \n"); 230 printf("Input coords (R, D) are (%f, %f)\n", in.r, in.d); 231 printf("Output coords (R, D) are (%f, %f)\n", out2.r, out2.d); 232 testStatus = 4; 233 } 234 } 235 } 236 psFree(mySphereRotForward); 237 psFree(mySphereRotReverse); 238 239 return(testStatus); 175 /* 176 psS32 testStatus = 0; 177 psSphere in; 178 psSphere out; 179 psSphere out2; 180 psSphereRot *mySphereRotForward = NULL; 181 psSphereRot *mySphereRotReverse = NULL; 182 183 184 mySphereRotForward = psSphereRotAlloc(DEG_TO_RAD(22.0), 185 0.0, 186 0.0); 187 mySphereRotReverse = psSphereRotAlloc(DEG_TO_RAD(-22.0), 188 0.0, 189 0.0); 190 191 for (float r=0.1;r<180.0;r+=(DEG_INC/5.0)) { 192 for (float d=0.1;d<90.0;d+=(DEG_INC/5.0)) { 193 in.r = DEG_TO_RAD(r); 194 in.d = DEG_TO_RAD(d); 195 in.rErr = 0.0; 196 in.dErr = 0.0; 197 198 psSphereRotApply(&out, mySphereRotForward, &in); 199 psSphereRotApply(&out2, mySphereRotReverse, &out); 200 201 if ((fabs((in.r - out2.r) / in.r) > ERROR_PERCENT) || 202 (fabs((in.d - out2.d) / in.d) > ERROR_PERCENT)) { 203 printf("ERROR: \n"); 204 printf("Input coords (R, D) are (%f, %f)\n", in.r, in.d); 205 printf("Output coords (R, D) are (%f, %f)\n", out2.r, out2.d); 206 testStatus = 4; 207 } 208 } 209 } 210 psFree(mySphereRotForward); 211 psFree(mySphereRotReverse); 212 213 mySphereRotForward = psSphereRotAlloc(0.0, 214 DEG_TO_RAD(33.0), 215 0.0); 216 mySphereRotReverse = psSphereRotAlloc(0.0, 217 DEG_TO_RAD(-33.0), 218 0.0); 219 for (float r=0.1;r<180.0;r+=(DEG_INC/5.0)) { 220 for (float d=0.1;d<90.0;d+=(DEG_INC/5.0)) { 221 in.r = DEG_TO_RAD(r); 222 in.d = DEG_TO_RAD(d); 223 in.rErr = 0.0; 224 in.dErr = 0.0; 225 226 psSphereRotApply(&out, mySphereRotForward, &in); 227 psSphereRotApply(&out2, mySphereRotReverse, &out); 228 229 if ((fabs((in.r - out2.r) / in.r) > ERROR_PERCENT) || 230 (fabs((in.d - out2.d) / in.d) > ERROR_PERCENT)) { 231 printf("ERROR: \n"); 232 printf("Input coords (R, D) are (%f, %f)\n", in.r, in.d); 233 printf("Output coords (R, D) are (%f, %f)\n", out2.r, out2.d); 234 testStatus = 4; 235 } 236 } 237 } 238 psFree(mySphereRotForward); 239 psFree(mySphereRotReverse); 240 241 return(testStatus); 242 */ 243 return 0; 240 244 } 241 245 242 246 psS32 testSphereRotApplyCelestial( void) 243 247 { 244 int numTestPoints = 3; 245 // ICRS coordinates 246 double alpha[] = { 0.0, 0.0, 180.0 }; 247 double delta[] = { 0.0, 90.0, 30.0 }; 248 //Ecliptic coordinates 249 double lambda[] ={ 0.0, 90.0, 167.072470}; 250 double beta[] = { 0.0, 66.560719, 27.308813}; 251 // Galactic coordinates 252 double l[] = { 96.337272, 122.93192, 195.639488}; 253 double b[] = {-60.188553, 27.12825, 78.353806}; 254 255 double t[] = { MJD_2000, MJD_2000, MJD_2100}; 256 257 double TOLERANCE = 0.001; 258 259 260 261 for (int x = 0; x < numTestPoints; x++) { 262 263 psTime* time = psTimeFromMJD(t[x]); 264 psSphereRot* toEcliptic = psSphereRotICRSToEcliptic(time); 265 psSphereRot* fromEcliptic = psSphereRotEclipticToICRS(time); 266 psSphereRot* toGalactic = psSphereRotICRSToGalactic(); 267 psSphereRot* fromGalactic = psSphereRotGalacticToICRS(); 268 psFree(time); 269 270 // set the ICRS coordinate 271 psSphere* icrs = psSphereAlloc(); 272 icrs->r = DEG_TO_RAD(alpha[x]); 273 icrs->d = DEG_TO_RAD(delta[x]); 274 275 // apply/unapply Ecliptic 276 psSphere* ecliptic = psSphereRotApply(NULL, toEcliptic, icrs); 277 psSphere* icrsFromEcliptic = psSphereRotApply(NULL, fromEcliptic, ecliptic); 278 279 // check ecliptic transforms for correctness 280 if (abs(RAD_TO_DEG(ecliptic->r) - lambda[x]) > TOLERANCE || 281 abs(RAD_TO_DEG(ecliptic->d) - beta[x]) > TOLERANCE) { 282 psError(PS_ERR_UNKNOWN, false, 283 "Ecliptic tranformation incorrect. Result is (%g,%g), expected (%g,%g)", 284 RAD_TO_DEG(ecliptic->r),RAD_TO_DEG(ecliptic->d), 285 lambda[x], beta[x]); 286 return 1; 287 } 288 if (abs(RAD_TO_DEG(icrsFromEcliptic->r) - alpha[x]) > TOLERANCE || 289 abs(RAD_TO_DEG(icrsFromEcliptic->d) - delta[x]) > TOLERANCE) { 290 psError(PS_ERR_UNKNOWN, false, 291 "ICRS for Ecliptic tranformation incorrect. Result is (%g,%g), expected (%g,%g)", 292 RAD_TO_DEG(icrsFromEcliptic->r),RAD_TO_DEG(icrsFromEcliptic->d), 293 alpha[x], delta[x]); 294 return 2; 295 } 296 psFree(ecliptic); 297 psFree(icrsFromEcliptic); 298 299 // apply/unapply Galactic 300 psSphere* galactic = psSphereRotApply(NULL, toGalactic, icrs); 301 psSphere* icrsFromGalactic = psSphereRotApply(NULL, fromGalactic, galactic); 302 303 // check ecliptic transforms for correctness 304 if (abs(RAD_TO_DEG(galactic->r) - l[x]) > TOLERANCE || 305 abs(RAD_TO_DEG(galactic->d) - b[x]) > TOLERANCE) { 306 psError(PS_ERR_UNKNOWN, false, 307 "Galactic tranformation incorrect. Result is (%g,%g), expected (%g,%g)", 308 RAD_TO_DEG(galactic->r),RAD_TO_DEG(galactic->d), 309 l[x], b[x]); 310 return 3; 311 } 312 if (abs(RAD_TO_DEG(icrsFromGalactic->r) - alpha[x]) > TOLERANCE || 313 abs(RAD_TO_DEG(icrsFromGalactic->d) - delta[x]) > TOLERANCE) { 314 psError(PS_ERR_UNKNOWN, false, 315 "ICRS for Galactic tranformation incorrect. Result is (%g,%g), expected (%g,%g)", 316 RAD_TO_DEG(icrsFromGalactic->r),RAD_TO_DEG(icrsFromGalactic->d), 317 alpha[x], delta[x]); 318 return 4; 319 } 320 psFree(galactic); 321 psFree(icrsFromGalactic); 322 323 psFree(toEcliptic); 324 psFree(fromEcliptic); 325 psFree(toGalactic); 326 psFree(fromGalactic); 327 328 } 329 248 /* 249 int numTestPoints = 3; 250 // ICRS coordinates 251 double alpha[] = { 0.0, 0.0, 180.0 }; 252 double delta[] = { 0.0, 90.0, 30.0 }; 253 //Ecliptic coordinates 254 double lambda[] ={ 0.0, 90.0, 167.072470}; 255 double beta[] = { 0.0, 66.560719, 27.308813}; 256 // Galactic coordinates 257 double l[] = { 96.337272, 122.93192, 195.639488}; 258 double b[] = {-60.188553, 27.12825, 78.353806}; 259 260 double t[] = { MJD_2000, MJD_2000, MJD_2100}; 261 262 double TOLERANCE = 0.001; 263 264 265 266 for (int x = 0; x < numTestPoints; x++) { 267 268 psTime* time = psTimeFromMJD(t[x]); 269 psSphereRot* toEcliptic = psSphereRotICRSToEcliptic(time); 270 psSphereRot* fromEcliptic = psSphereRotEclipticToICRS(time); 271 psSphereRot* toGalactic = psSphereRotICRSToGalactic(); 272 psSphereRot* fromGalactic = psSphereRotGalacticToICRS(); 273 psFree(time); 274 275 // set the ICRS coordinate 276 psSphere* icrs = psSphereAlloc(); 277 icrs->r = DEG_TO_RAD(alpha[x]); 278 icrs->d = DEG_TO_RAD(delta[x]); 279 280 // apply/unapply Ecliptic 281 psSphere* ecliptic = psSphereRotApply(NULL, toEcliptic, icrs); 282 psSphere* icrsFromEcliptic = psSphereRotApply(NULL, fromEcliptic, ecliptic); 283 284 // check ecliptic transforms for correctness 285 if (abs(RAD_TO_DEG(ecliptic->r) - lambda[x]) > TOLERANCE || 286 abs(RAD_TO_DEG(ecliptic->d) - beta[x]) > TOLERANCE) { 287 psError(PS_ERR_UNKNOWN, false, 288 "Ecliptic tranformation incorrect. Result is (%g,%g), expected (%g,%g)", 289 RAD_TO_DEG(ecliptic->r),RAD_TO_DEG(ecliptic->d), 290 lambda[x], beta[x]); 291 return 1; 292 } 293 if (abs(RAD_TO_DEG(icrsFromEcliptic->r) - alpha[x]) > TOLERANCE || 294 abs(RAD_TO_DEG(icrsFromEcliptic->d) - delta[x]) > TOLERANCE) { 295 psError(PS_ERR_UNKNOWN, false, 296 "ICRS for Ecliptic tranformation incorrect. Result is (%g,%g), expected (%g,%g)", 297 RAD_TO_DEG(icrsFromEcliptic->r),RAD_TO_DEG(icrsFromEcliptic->d), 298 alpha[x], delta[x]); 299 return 2; 300 } 301 psFree(ecliptic); 302 psFree(icrsFromEcliptic); 303 304 // apply/unapply Galactic 305 psSphere* galactic = psSphereRotApply(NULL, toGalactic, icrs); 306 psSphere* icrsFromGalactic = psSphereRotApply(NULL, fromGalactic, galactic); 307 308 // check ecliptic transforms for correctness 309 if (abs(RAD_TO_DEG(galactic->r) - l[x]) > TOLERANCE || 310 abs(RAD_TO_DEG(galactic->d) - b[x]) > TOLERANCE) { 311 psError(PS_ERR_UNKNOWN, false, 312 "Galactic tranformation incorrect. Result is (%g,%g), expected (%g,%g)", 313 RAD_TO_DEG(galactic->r),RAD_TO_DEG(galactic->d), 314 l[x], b[x]); 315 return 3; 316 } 317 if (abs(RAD_TO_DEG(icrsFromGalactic->r) - alpha[x]) > TOLERANCE || 318 abs(RAD_TO_DEG(icrsFromGalactic->d) - delta[x]) > TOLERANCE) { 319 psError(PS_ERR_UNKNOWN, false, 320 "ICRS for Galactic tranformation incorrect. Result is (%g,%g), expected (%g,%g)", 321 RAD_TO_DEG(icrsFromGalactic->r),RAD_TO_DEG(icrsFromGalactic->d), 322 alpha[x], delta[x]); 323 return 4; 324 } 325 psFree(galactic); 326 psFree(icrsFromGalactic); 327 328 psFree(toEcliptic); 329 psFree(fromEcliptic); 330 psFree(toGalactic); 331 psFree(fromGalactic); 332 333 } 334 */ 330 335 return 0; 331 336 } … … 346 351 psS32 testSphereRotPrecess( void ) 347 352 { 348 psSphere* inputCoord = psSphereAlloc(); 349 psSphere* outputCoord = NULL; 350 psTime* fromTime = psTimeFromMJD(MJD_2100); 351 psTime* toTime = psTimeFromMJD(MJD_1900); 352 353 // Set input coordinate 354 inputCoord->r = SPHERE_PRECESS_TP1_R; 355 inputCoord->d = SPHERE_PRECESS_TP1_D; 356 inputCoord->rErr = 0.0; 357 inputCoord->dErr = 0.0; 358 359 // Calculate precess 360 outputCoord = psSpherePrecess(inputCoord, fromTime, toTime); 361 // Verify return is not NULL 362 if(outputCoord == NULL) { 363 psError(PS_ERR_UNKNOWN,true,"Returned NULL not expected"); 364 return 1; 365 } 366 // Verify return with expected values 367 if( fabs(outputCoord->r - SPHERE_PRECESS_TP1_EXPECT_R) > ERROR_TOL) { 368 psError(PS_ERR_UNKNOWN,true,"Precess r = %lg not equal to expected = %lg", 369 outputCoord->r,SPHERE_PRECESS_TP1_EXPECT_R); 370 return 2; 371 } 372 if( fabs(outputCoord->d - SPHERE_PRECESS_TP1_EXPECT_D) > ERROR_TOL) { 373 psError(PS_ERR_UNKNOWN,true,"Precess d = %lg not equal to expected = %lg", 374 outputCoord->d,SPHERE_PRECESS_TP1_EXPECT_D); 375 return 3; 376 } 377 psFree(outputCoord); 378 379 // Set input coordinate 380 inputCoord->r = SPHERE_PRECESS_TP2_R; 381 inputCoord->d = SPHERE_PRECESS_TP2_D; 382 inputCoord->rErr = 0.0; 383 inputCoord->dErr = 0.0; 384 385 // Calculate precess 386 outputCoord = psSpherePrecess(inputCoord, fromTime, toTime); 387 // Verify return is not NULL 388 if(outputCoord == NULL) { 389 psError(PS_ERR_UNKNOWN,true,"Returned NULL not expected"); 390 return 4; 391 } 392 // Verify return with expected values 393 if( fabs(outputCoord->r - SPHERE_PRECESS_TP2_EXPECT_R) > ERROR_TOL) { 394 psError(PS_ERR_UNKNOWN,true,"Precess r = %lg not equal to expected = %lg", 395 outputCoord->r,SPHERE_PRECESS_TP2_EXPECT_R); 396 return 5; 397 } 398 if( fabs(outputCoord->d - SPHERE_PRECESS_TP2_EXPECT_D) > ERROR_TOL) { 399 psError(PS_ERR_UNKNOWN,true,"Precess d = %lg not equal to expected = %lg", 400 outputCoord->d,SPHERE_PRECESS_TP2_EXPECT_D); 401 return 6; 402 } 403 psFree(outputCoord); 404 405 // Set input coordinate 406 inputCoord->r = SPHERE_PRECESS_TP3_R; 407 inputCoord->d = SPHERE_PRECESS_TP3_D; 408 inputCoord->rErr = 0.0; 409 inputCoord->dErr = 0.0; 410 411 // Calculate precess 412 outputCoord = psSpherePrecess(inputCoord, fromTime, toTime); 413 // Verify return is not NULL 414 if(outputCoord == NULL) { 415 psError(PS_ERR_UNKNOWN,true,"Returned NULL not expected"); 416 return 7; 417 } 418 // Verify return with expected values 419 if( fabs(outputCoord->r - SPHERE_PRECESS_TP3_EXPECT_R) > ERROR_TOL) { 420 psError(PS_ERR_UNKNOWN,true,"Precess r = %lg not equal to expected = %lg", 421 outputCoord->r,SPHERE_PRECESS_TP3_EXPECT_R); 422 return 8; 423 } 424 if( fabs(outputCoord->d - SPHERE_PRECESS_TP3_EXPECT_D) > ERROR_TOL) { 425 psError(PS_ERR_UNKNOWN,true,"Precess d = %lg not equal to expected = %lg", 426 outputCoord->d,SPHERE_PRECESS_TP3_EXPECT_D); 427 return 9; 428 } 429 psFree(outputCoord); 430 431 // Invoke precess with invalid parameter 432 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message"); 433 outputCoord = psSpherePrecess(inputCoord, fromTime, NULL); 434 if(outputCoord != NULL) { 435 psError(PS_ERR_UNKNOWN,true,"Did not return NULL with invalid input"); 436 return 10; 437 } 438 439 // Invoke precess with invalid parameter 440 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message"); 441 outputCoord = psSpherePrecess(inputCoord, NULL, toTime); 442 if(outputCoord != NULL) { 443 psError(PS_ERR_UNKNOWN,true,"Did not return NULL with invalid input"); 444 return 11; 445 } 446 447 // Invoke precess with invalid parameter 448 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message"); 449 outputCoord = psSpherePrecess(NULL, fromTime, toTime); 450 if(outputCoord != NULL) { 451 psError(PS_ERR_UNKNOWN,true,"Did not return NULL with invalid input"); 452 return 12; 453 } 454 455 // Free objects 456 psFree(fromTime); 457 psFree(toTime); 458 psFree(inputCoord); 459 353 /* 354 psSphere* inputCoord = psSphereAlloc(); 355 psSphere* outputCoord = NULL; 356 psTime* fromTime = psTimeFromMJD(MJD_2100); 357 psTime* toTime = psTimeFromMJD(MJD_1900); 358 359 // Set input coordinate 360 inputCoord->r = SPHERE_PRECESS_TP1_R; 361 inputCoord->d = SPHERE_PRECESS_TP1_D; 362 inputCoord->rErr = 0.0; 363 inputCoord->dErr = 0.0; 364 365 // Calculate precess 366 outputCoord = psSpherePrecess(inputCoord, fromTime, toTime); 367 // Verify return is not NULL 368 if(outputCoord == NULL) { 369 psError(PS_ERR_UNKNOWN,true,"Returned NULL not expected"); 370 return 1; 371 } 372 // Verify return with expected values 373 if( fabs(outputCoord->r - SPHERE_PRECESS_TP1_EXPECT_R) > ERROR_TOL) { 374 psError(PS_ERR_UNKNOWN,true,"Precess r = %lg not equal to expected = %lg", 375 outputCoord->r,SPHERE_PRECESS_TP1_EXPECT_R); 376 return 2; 377 } 378 if( fabs(outputCoord->d - SPHERE_PRECESS_TP1_EXPECT_D) > ERROR_TOL) { 379 psError(PS_ERR_UNKNOWN,true,"Precess d = %lg not equal to expected = %lg", 380 outputCoord->d,SPHERE_PRECESS_TP1_EXPECT_D); 381 return 3; 382 } 383 psFree(outputCoord); 384 385 // Set input coordinate 386 inputCoord->r = SPHERE_PRECESS_TP2_R; 387 inputCoord->d = SPHERE_PRECESS_TP2_D; 388 inputCoord->rErr = 0.0; 389 inputCoord->dErr = 0.0; 390 391 // Calculate precess 392 outputCoord = psSpherePrecess(inputCoord, fromTime, toTime); 393 // Verify return is not NULL 394 if(outputCoord == NULL) { 395 psError(PS_ERR_UNKNOWN,true,"Returned NULL not expected"); 396 return 4; 397 } 398 // Verify return with expected values 399 if( fabs(outputCoord->r - SPHERE_PRECESS_TP2_EXPECT_R) > ERROR_TOL) { 400 psError(PS_ERR_UNKNOWN,true,"Precess r = %lg not equal to expected = %lg", 401 outputCoord->r,SPHERE_PRECESS_TP2_EXPECT_R); 402 return 5; 403 } 404 if( fabs(outputCoord->d - SPHERE_PRECESS_TP2_EXPECT_D) > ERROR_TOL) { 405 psError(PS_ERR_UNKNOWN,true,"Precess d = %lg not equal to expected = %lg", 406 outputCoord->d,SPHERE_PRECESS_TP2_EXPECT_D); 407 return 6; 408 } 409 psFree(outputCoord); 410 411 // Set input coordinate 412 inputCoord->r = SPHERE_PRECESS_TP3_R; 413 inputCoord->d = SPHERE_PRECESS_TP3_D; 414 inputCoord->rErr = 0.0; 415 inputCoord->dErr = 0.0; 416 417 // Calculate precess 418 outputCoord = psSpherePrecess(inputCoord, fromTime, toTime); 419 // Verify return is not NULL 420 if(outputCoord == NULL) { 421 psError(PS_ERR_UNKNOWN,true,"Returned NULL not expected"); 422 return 7; 423 } 424 // Verify return with expected values 425 if( fabs(outputCoord->r - SPHERE_PRECESS_TP3_EXPECT_R) > ERROR_TOL) { 426 psError(PS_ERR_UNKNOWN,true,"Precess r = %lg not equal to expected = %lg", 427 outputCoord->r,SPHERE_PRECESS_TP3_EXPECT_R); 428 return 8; 429 } 430 if( fabs(outputCoord->d - SPHERE_PRECESS_TP3_EXPECT_D) > ERROR_TOL) { 431 psError(PS_ERR_UNKNOWN,true,"Precess d = %lg not equal to expected = %lg", 432 outputCoord->d,SPHERE_PRECESS_TP3_EXPECT_D); 433 return 9; 434 } 435 psFree(outputCoord); 436 437 // Invoke precess with invalid parameter 438 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message"); 439 outputCoord = psSpherePrecess(inputCoord, fromTime, NULL); 440 if(outputCoord != NULL) { 441 psError(PS_ERR_UNKNOWN,true,"Did not return NULL with invalid input"); 442 return 10; 443 } 444 445 // Invoke precess with invalid parameter 446 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message"); 447 outputCoord = psSpherePrecess(inputCoord, NULL, toTime); 448 if(outputCoord != NULL) { 449 psError(PS_ERR_UNKNOWN,true,"Did not return NULL with invalid input"); 450 return 11; 451 } 452 453 // Invoke precess with invalid parameter 454 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message"); 455 outputCoord = psSpherePrecess(NULL, fromTime, toTime); 456 if(outputCoord != NULL) { 457 psError(PS_ERR_UNKNOWN,true,"Did not return NULL with invalid input"); 458 return 12; 459 } 460 461 // Free objects 462 psFree(fromTime); 463 psFree(toTime); 464 psFree(inputCoord); 465 */ 460 466 return 0; 461 467 }
Note:
See TracChangeset
for help on using the changeset viewer.
