Changeset 5254
- Timestamp:
- Oct 7, 2005, 5:51:20 PM (21 years ago)
- Location:
- trunk/psLib/test
- Files:
-
- 4 edited
-
astro/tst_psSphereOps.c (modified) (29 diffs)
-
imageops/tst_psImageMaskOps.c (modified) (3 diffs)
-
imageops/verified/tst_psImageMaskOps.stderr (modified) (1 diff)
-
imageops/verified/tst_psImageMaskOps.stdout (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/astro/tst_psSphereOps.c
r5235 r5254 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $9 * @date $Date: 2005-10-0 7 21:27:50 $8 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2005-10-08 03:51:20 $ 10 10 * 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 48 48 #define ERROR_TOL 0.0001 49 49 50 #define ALPHA_P 1.051 #define DELTA_P 2.052 #define PHI_P 3.050 #define ALPHA_P 0.5 * M_PI 51 #define DELTA_P 1.0 * M_PI 52 #define PHI_P 1.5 * M_PI 53 53 54 54 psS32 testSphereRotAlloc( void ) … … 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 double len = sqrt(q0*q0 + q1*q1 + q2*q2 + q3*q3); 73 printf("\nvz = %lf\n", vz); 74 q0 = q0/len; 75 q1 = q1/len; 76 q2 = q2/len; 77 q3 = q3/len; 78 79 if (FLT_EPSILON < fabs(q0 - myST->q0)) { 80 psError(PS_ERR_UNKNOWN,true,"myST->q0 is %f, should be %f\n", myST->q0, q0); 81 return 2; 82 } 83 if (FLT_EPSILON < fabs(q1 - myST->q1)) { 84 psError(PS_ERR_UNKNOWN,true,"myST->q1 is %f, should be %f\n", myST->q1, q1); 85 return 3; 86 } 87 if (FLT_EPSILON < fabs(q2 - myST->q2)) { 88 psError(PS_ERR_UNKNOWN,true,"myST->q2 is %f, should be %f\n", myST->q2, q2); 89 return 4; 90 } 91 if (FLT_EPSILON < fabs(q3 - myST->q3)) { 92 psError(PS_ERR_UNKNOWN,true,"myST->q0 is %f, should be %f\n", myST->q3, q3); 93 return 5; 94 } 95 90 96 // Free data structure 91 97 psFree(myST); … … 103 109 psSphere *rc = NULL; 104 110 psSphereRot *myST = psSphereRotAlloc(0.0, 0.0, 0.0); 105 111 106 112 for (float r=0.0;r<180.0;r+=DEG_INC) { 107 113 for (float d=0.0;d<90.0;d+=DEG_INC) { … … 110 116 in->rErr = 0.0; 111 117 in->dErr = 0.0; 112 118 113 119 if(psSphereRotApply(out, myST, in) != out) { 114 120 psError(PS_ERR_UNKNOWN,true,"Did not return output pointer."); … … 125 131 } 126 132 } 127 133 128 134 // Verify new sphere object is created if out parameter NULL 129 135 temp = psSphereRotApply(NULL, myST, in); … … 133 139 } 134 140 psFree(temp); 135 141 136 142 // Verify NULL returned if transform structure null 137 143 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error"); … … 141 147 return 5; 142 148 } 143 149 144 150 // Verify NULL returned when input sphere is NULL 145 151 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error"); … … 149 155 return 6; 150 156 } 151 157 152 158 psFree(myST); 153 159 psFree(out); … … 180 186 psSphereRot *mySphereRotForward = NULL; 181 187 psSphereRot *mySphereRotReverse = NULL; 182 183 188 189 184 190 mySphereRotForward = psSphereRotAlloc(DEG_TO_RAD(22.0), 185 191 0.0, … … 188 194 0.0, 189 195 0.0); 190 196 191 197 for (float r=0.1;r<180.0;r+=(DEG_INC/5.0)) { 192 198 for (float d=0.1;d<90.0;d+=(DEG_INC/5.0)) { … … 195 201 in.rErr = 0.0; 196 202 in.dErr = 0.0; 197 203 198 204 psSphereRotApply(&out, mySphereRotForward, &in); 199 205 psSphereRotApply(&out2, mySphereRotReverse, &out); 200 206 201 207 if ((fabs((in.r - out2.r) / in.r) > ERROR_PERCENT) || 202 208 (fabs((in.d - out2.d) / in.d) > ERROR_PERCENT)) { … … 210 216 psFree(mySphereRotForward); 211 217 psFree(mySphereRotReverse); 212 218 213 219 mySphereRotForward = psSphereRotAlloc(0.0, 214 220 DEG_TO_RAD(33.0), … … 223 229 in.rErr = 0.0; 224 230 in.dErr = 0.0; 225 231 226 232 psSphereRotApply(&out, mySphereRotForward, &in); 227 233 psSphereRotApply(&out2, mySphereRotReverse, &out); 228 234 229 235 if ((fabs((in.r - out2.r) / in.r) > ERROR_PERCENT) || 230 236 (fabs((in.d - out2.d) / in.d) > ERROR_PERCENT)) { … … 238 244 psFree(mySphereRotForward); 239 245 psFree(mySphereRotReverse); 240 246 241 247 return(testStatus); 242 248 */ … … 257 263 double l[] = { 96.337272, 122.93192, 195.639488}; 258 264 double b[] = {-60.188553, 27.12825, 78.353806}; 259 265 260 266 double t[] = { MJD_2000, MJD_2000, MJD_2100}; 261 267 262 268 double TOLERANCE = 0.001; 263 264 265 269 270 271 266 272 for (int x = 0; x < numTestPoints; x++) { 267 273 268 274 psTime* time = psTimeFromMJD(t[x]); 269 275 psSphereRot* toEcliptic = psSphereRotICRSToEcliptic(time); … … 272 278 psSphereRot* fromGalactic = psSphereRotGalacticToICRS(); 273 279 psFree(time); 274 280 275 281 // set the ICRS coordinate 276 282 psSphere* icrs = psSphereAlloc(); 277 283 icrs->r = DEG_TO_RAD(alpha[x]); 278 284 icrs->d = DEG_TO_RAD(delta[x]); 279 285 280 286 // apply/unapply Ecliptic 281 287 psSphere* ecliptic = psSphereRotApply(NULL, toEcliptic, icrs); 282 288 psSphere* icrsFromEcliptic = psSphereRotApply(NULL, fromEcliptic, ecliptic); 283 289 284 290 // check ecliptic transforms for correctness 285 291 if (abs(RAD_TO_DEG(ecliptic->r) - lambda[x]) > TOLERANCE || … … 301 307 psFree(ecliptic); 302 308 psFree(icrsFromEcliptic); 303 309 304 310 // apply/unapply Galactic 305 311 psSphere* galactic = psSphereRotApply(NULL, toGalactic, icrs); 306 312 psSphere* icrsFromGalactic = psSphereRotApply(NULL, fromGalactic, galactic); 307 313 308 314 // check ecliptic transforms for correctness 309 315 if (abs(RAD_TO_DEG(galactic->r) - l[x]) > TOLERANCE || … … 325 331 psFree(galactic); 326 332 psFree(icrsFromGalactic); 327 333 328 334 psFree(toEcliptic); 329 335 psFree(fromEcliptic); 330 336 psFree(toGalactic); 331 337 psFree(fromGalactic); 332 338 333 339 } 334 340 */ … … 356 362 psTime* fromTime = psTimeFromMJD(MJD_2100); 357 363 psTime* toTime = psTimeFromMJD(MJD_1900); 358 364 359 365 // Set input coordinate 360 366 inputCoord->r = SPHERE_PRECESS_TP1_R; … … 362 368 inputCoord->rErr = 0.0; 363 369 inputCoord->dErr = 0.0; 364 370 365 371 // Calculate precess 366 372 outputCoord = psSpherePrecess(inputCoord, fromTime, toTime); … … 382 388 } 383 389 psFree(outputCoord); 384 390 385 391 // Set input coordinate 386 392 inputCoord->r = SPHERE_PRECESS_TP2_R; … … 388 394 inputCoord->rErr = 0.0; 389 395 inputCoord->dErr = 0.0; 390 396 391 397 // Calculate precess 392 398 outputCoord = psSpherePrecess(inputCoord, fromTime, toTime); … … 408 414 } 409 415 psFree(outputCoord); 410 416 411 417 // Set input coordinate 412 418 inputCoord->r = SPHERE_PRECESS_TP3_R; … … 414 420 inputCoord->rErr = 0.0; 415 421 inputCoord->dErr = 0.0; 416 422 417 423 // Calculate precess 418 424 outputCoord = psSpherePrecess(inputCoord, fromTime, toTime); … … 434 440 } 435 441 psFree(outputCoord); 436 442 437 443 // Invoke precess with invalid parameter 438 444 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message"); … … 442 448 return 10; 443 449 } 444 450 445 451 // Invoke precess with invalid parameter 446 452 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message"); … … 450 456 return 11; 451 457 } 452 458 453 459 // Invoke precess with invalid parameter 454 460 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message"); … … 458 464 return 12; 459 465 } 460 466 461 467 // Free objects 462 468 psFree(fromTime); -
trunk/psLib/test/imageops/tst_psImageMaskOps.c
r5227 r5254 6 6 * @author David Robbins, MHPCC 7 7 * 8 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $9 * @date $Date: 2005-10-0 6 02:41:07$8 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2005-10-08 03:51:20 $ 10 10 * 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 152 152 return 1; 153 153 } 154 in = psImageAlloc( 3, 3, PS_TYPE_MASK);154 in = psImageAlloc(5, 5, PS_TYPE_MASK); 155 155 //return null for incompatible image size 156 156 test = psImageAlloc(2, 2, PS_TYPE_MASK); … … 161 161 return 2; 162 162 } 163 //return null for incompatible image type164 test = psImageRecycle(test, 3, 3, PS_TYPE_F32);163 //return null for incompatible out image type 164 test = psImageRecycle(test, 5, 5, PS_TYPE_F32); 165 165 out = psImageGrowMask(test, in, maskVal, growSize, growVal); 166 166 if (out != NULL) { 167 167 fprintf(stderr, 168 "psImageGrowMask failed to return NULL for incompatible image type.\n");168 "psImageGrowMask failed to return NULL for incompatible output image type.\n"); 169 169 return 3; 170 170 } 171 172 171 //return NULL for input image that doesn't match PS_TYPE_MASK 172 in = psImageRecycle(in, 5, 5, PS_TYPE_F32); 173 out = psImageGrowMask(test, in, maskVal, growSize, growVal); 174 if (out != NULL) { 175 fprintf(stderr, 176 "psImageGrowMask failed to return NULL for incompatible input image type.\n"); 177 return 4; 178 } 179 //Test for valid function (image growth) 180 in = psImageRecycle(in, 5, 5, PS_TYPE_MASK); 181 in->data.PS_TYPE_MASK_DATA[0][0] = 1; 182 in->data.PS_TYPE_MASK_DATA[0][1] = 1; 183 in->data.PS_TYPE_MASK_DATA[0][2] = 1; 184 in->data.PS_TYPE_MASK_DATA[0][3] = 1; 185 in->data.PS_TYPE_MASK_DATA[0][4] = 1; 186 in->data.PS_TYPE_MASK_DATA[1][0] = 1; 187 in->data.PS_TYPE_MASK_DATA[1][1] = 1; 188 in->data.PS_TYPE_MASK_DATA[1][2] = 2; 189 in->data.PS_TYPE_MASK_DATA[1][3] = 1; 190 in->data.PS_TYPE_MASK_DATA[1][4] = 1; 191 in->data.PS_TYPE_MASK_DATA[2][0] = 1; 192 in->data.PS_TYPE_MASK_DATA[2][1] = 1; 193 in->data.PS_TYPE_MASK_DATA[2][2] = 2; 194 in->data.PS_TYPE_MASK_DATA[2][3] = 1; 195 in->data.PS_TYPE_MASK_DATA[2][4] = 1; 196 in->data.PS_TYPE_MASK_DATA[3][0] = 1; 197 in->data.PS_TYPE_MASK_DATA[3][1] = 1; 198 in->data.PS_TYPE_MASK_DATA[3][2] = 1; 199 in->data.PS_TYPE_MASK_DATA[3][3] = 1; 200 in->data.PS_TYPE_MASK_DATA[3][4] = 2; 201 in->data.PS_TYPE_MASK_DATA[4][0] = 1; 202 in->data.PS_TYPE_MASK_DATA[4][1] = 1; 203 in->data.PS_TYPE_MASK_DATA[4][2] = 1; 204 in->data.PS_TYPE_MASK_DATA[4][3] = 1; 205 in->data.PS_TYPE_MASK_DATA[4][4] = 1; 206 maskVal = 2; 207 growSize = 1; 208 growVal = 2; 209 210 out = psImageGrowMask(out, in, maskVal, growSize, growVal); 211 //0,2 1,1 1,3 2,1 2,3 3,2 should all be 3. All other should be unchanged. 212 for (int i = 0; i < 5; i++) { 213 printf("\n "); 214 for (int j = 0; j < 5; j++) { 215 printf(" %d,%d= %d ", i, j, out->data.PS_TYPE_MASK_DATA[i][j]); 216 } 217 } 218 psFree(out); 173 219 psFree(in); 174 220 psFree(test); -
trunk/psLib/test/imageops/verified/tst_psImageMaskOps.stderr
r5227 r5254 24 24 <DATE><TIME>|<HOST>|E|psImageGrowMask (FILE:LINENO) 25 25 Invalid out image. Type of out does not match type of in. 26 <DATE><TIME>|<HOST>|E|psImageGrowMask (FILE:LINENO) 27 Invalid input image. Input image type must match psMaskType. 26 28 27 29 ---> TESTPOINT PASSED (psImage{psImageGrowMask} | tst_psImageMaskOps.c) -
trunk/psLib/test/imageops/verified/tst_psImageMaskOps.stdout
r5227 r5254 40 40 in->data.u8 [i][j] i=2, j=1 = 1 41 41 in->data.u8 [i][j] i=2, j=2 = 2 42 43 0,0= 1 0,1= 1 0,2= 3 0,3= 1 0,4= 1 44 1,0= 1 1,1= 3 1,2= 2 1,3= 3 1,4= 1 45 2,0= 1 2,1= 3 2,2= 2 2,3= 3 2,4= 3 46 3,0= 1 3,1= 1 3,2= 3 3,3= 3 3,4= 2 47 4,0= 1 4,1= 1 4,2= 1 4,3= 1 4,4= 3
Note:
See TracChangeset
for help on using the changeset viewer.
