Changeset 2812
- Timestamp:
- Dec 23, 2004, 1:16:36 PM (22 years ago)
- Location:
- trunk/psModules
- Files:
-
- 3 edited
-
src/pmReadoutCombine.c (modified) (12 diffs)
-
src/pmSubtractSky.c (modified) (2 diffs)
-
test/tst_pmReadoutCombine.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/pmReadoutCombine.c
r2810 r2812 5 5 * @author GLG, MHPCC 6 6 * 7 * @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $8 * @date $Date: 2004-12-23 2 0:27:51$7 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2004-12-23 23:16:36 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 27 27 psCombineParams; 28 28 29 30 int p_psDetermineNumBits(unsigned int data) 29 /****************************************************************************** 30 p_psDetermineNumBits(data): This routine takes an enum psStatsOptions as an 31 argument and returns the number of non-zero bits. 32 *****************************************************************************/ 33 psStatsOptions p_psDetermineNumBits(psStatsOptions data) 31 34 { 32 inti;33 unsigned inttmpData = data;34 intnumBits = 0;35 36 for (i=0;i< sizeof(unsigned int);i++) {37 if (0x0001 & &tmpData) {35 psS32 i; 36 psU64 tmpData = data; 37 psS32 numBits = 0; 38 39 for (i=0;i<4 * sizeof(psStatsOptions);i++) { 40 if (0x0001 & tmpData) { 38 41 numBits++; 39 42 } … … 43 46 } 44 47 48 // XXX: Whats this? 45 49 #define MAX_INT 10000 46 50 psImage *pmReadoutCombine(psImage *output, … … 55 59 PS_PTR_CHECK_NULL(inputs, NULL); 56 60 PS_PTR_CHECK_NULL(params, NULL); 61 PS_PTR_CHECK_NULL(params->stats, NULL); 62 if (zero != NULL) { 63 PS_VECTOR_CHECK_TYPE(zero, PS_TYPE_F32, NULL); 64 } 65 if (scale != NULL) { 66 PS_VECTOR_CHECK_TYPE(scale, PS_TYPE_F32, NULL); 67 } 68 if ((zero != NULL) && (scale != NULL)) { 69 PS_VECTOR_CHECK_TYPE_EQUAL(zero, scale, NULL); 70 // XXX: Currently only type F32 is implemented. 71 // PS_VECTOR_CHECK_TYPE_S16_S32_F32(scale, NULL); 72 } 73 57 74 psStats *stats = params->stats; 58 75 int i; … … 66 83 int numInputs = 0; 67 84 int tmpI; 85 psElemType outputType = PS_TYPE_F32; 86 87 if (1 < p_psDetermineNumBits(params->stats->options)) { 88 psError(PS_ERR_UNKNOWN, true, 89 "Multiple statistical options have been requested.\n"); 90 return(NULL); 91 } 68 92 69 93 // … … 86 110 PS_READOUT_CHECK_EMPTY(tmpReadout, output); 87 111 PS_READOUT_CHECK_TYPE(tmpReadout, PS_TYPE_F32, output); 112 outputType = tmpReadout->image->type.type; 88 113 89 114 minInputRows = PS_MIN(minInputRows, … … 105 130 106 131 // We ensure that the zero vector is of the proper size. 132 107 133 if (zero != NULL) { 108 134 PS_VECTOR_CHECK_TYPE(zero, PS_TYPE_F32, NULL); 109 135 if (numInputs > zero->n) { 110 // XXX: ERROR: the zero vector does not have enough elements.136 psError(PS_ERR_UNKNOWN, true, "zero vector has incorrect size (%d)\n", zero->n); 111 137 return(NULL); 112 138 } else if (numInputs < zero->n) { 113 // XXX: WARNING: the zero vector too many elements. 139 psLogMsg(__func__, PS_LOG_WARN, 140 "WARNING: the zero vector too many elements (%d)\n", zero->n); 114 141 } 115 142 } … … 119 146 PS_VECTOR_CHECK_TYPE(scale, PS_TYPE_F32, NULL); 120 147 if (numInputs > scale->n) { 121 // XXX: ERROR: the scale vector does not have enough elements.148 psError(PS_ERR_UNKNOWN, true, "scale vector has incorrect size (%d)\n", scale->n); 122 149 return(NULL); 123 150 } else if (numInputs < scale->n) { 124 // XXX: WARNING: the scale vector too many elements. 151 psLogMsg(__func__, PS_LOG_WARN, 152 "WARNING: the scale vector too many elements (%d)\n", scale->n); 125 153 } 126 154 } … … 134 162 if (output == NULL) { 135 163 output = psImageAlloc(maxInputCols-minInputCols, 136 maxInputRows-minInputRows, PS_TYPE_F32);164 maxInputRows-minInputRows, outputType); 137 165 *(int *) &(output->col0) = minInputCols; 138 166 *(int *) &(output->row0) = minInputRows; … … 140 168 if (((output->col0 + output->numCols) < maxInputCols) || 141 169 ((output->row0 + output->numRows) < maxInputRows)) { 142 //XXX ERROR: "Output image (%d, %d) is too small to hold combined images.\n", 143 // output->row0 + output->numRows, 144 // output->col0 + output->numCols); 170 psError(PS_ERR_UNKNOWN, true, 171 "Output image (%d, %d) is too small to hold combined images.\n", 172 output->row0 + output->numRows, 173 output->col0 + output->numCols); 145 174 return(NULL); 146 175 } … … 150 179 return(NULL); 151 180 } 152 }153 154 if (1 < p_psDetermineNumBits(params->stats->options)) {155 //XXX psError(PS_ERR_UNKNOWN,true, "Multiple statistical options have been requested.\n");156 return(NULL);157 181 } 158 182 … … 254 278 // XXX: Is this correct? 255 279 // We add the zero vector, if non-NULL. 280 256 281 if (zero != NULL) { 257 282 for (int r = 0; r < numInputs ; r++) { -
trunk/psModules/src/pmSubtractSky.c
r2810 r2812 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1.1 1$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-12-23 2 0:27:51$8 * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-12-23 23:16:36 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 12 *12 xd * 13 13 */ 14 14 … … 20 20 21 21 /****************************************************************************** 22 p_psDetermineNumBits(data): This routine takes an insigned int as an argument23 a nd returns the number of non-zero bits.24 *****************************************************************************/ 25 psS 32 p_psDetermineNumBits(psU32data)22 p_psDetermineNumBits(data): This routine takes an enum psStatsOptions as an 23 argument and returns the number of non-zero bits. 24 *****************************************************************************/ 25 psStatsOptions p_psDetermineNumBits(psStatsOptions data) 26 26 { 27 27 psS32 i; 28 psU 32tmpData = data;28 psU64 tmpData = data; 29 29 psS32 numBits = 0; 30 30 31 for (i=0;i< sizeof(psU32);i++) {32 if (0x0001 & &tmpData) {31 for (i=0;i<4 * sizeof(psStatsOptions);i++) { 32 if (0x0001 & tmpData) { 33 33 numBits++; 34 34 } -
trunk/psModules/test/tst_pmReadoutCombine.c
r2590 r2812 5 5 * @author GLG, MHPCC 6 6 * 7 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $8 * @date $Date: 2004-12- 01 22:08:32$7 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2004-12-23 23:16:36 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 15 15 #include "pmReadoutCombine.h" 16 16 static int test00(void); 17 static int test01(void); 17 18 testDescription tests[] = { 18 19 {test00, 000, "pmSubtractBias", 0, false}, 20 {test01, 000, "pmSubtractBias(): input parameter error conditions", 0, false}, 19 21 {NULL} 20 22 }; … … 34 36 int doit() 35 37 { 38 return(0); 36 39 int i; 37 40 int j; … … 238 241 return(testStatus); 239 242 } 243 244 psS32 VerifyTheOutput(psImage *output) 245 { 246 bool testStatus = true; 247 248 for (psS32 i = 0 ; i < output->numRows ; i++) { 249 for (psS32 j = 0 ; j < output->numCols ; j++) { 250 if (output->data.F32[i][j] != 45.0) { 251 printf("ERROR: output[%d][%d] is %.2f, should be 45.0\n", i, j, output->data.F32[i][j]); 252 testStatus = false; 253 } 254 } 255 } 256 return(testStatus); 257 } 258 259 260 int test01() 261 { 262 int i; 263 int j; 264 int r; 265 psList *list = NULL; 266 int baseRowsReadout[NUM_READOUTS]; 267 int baseColsReadout[NUM_READOUTS]; 268 int baseRows[NUM_READOUTS]; 269 int baseCols[NUM_READOUTS]; 270 int numRows[NUM_READOUTS]; 271 int numCols[NUM_READOUTS]; 272 int minOutRow = 10000; 273 int minOutCol = 10000; 274 int maxOutRow = -1; 275 int maxOutCol = -1; 276 psImage *output = NULL; 277 psImage *rc = NULL; 278 psCombineParams *params = (psCombineParams *) psAlloc(sizeof(psCombineParams)); 279 psVector *zero = psVectorAlloc(NUM_READOUTS, PS_TYPE_F32); 280 psVector *zeroHalf = psVectorAlloc(NUM_READOUTS/2, PS_TYPE_F32); 281 psVector *zeroBig = psVectorAlloc(NUM_READOUTS+1, PS_TYPE_F32); 282 psVector *zeroF64 = psVectorAlloc(NUM_READOUTS, PS_TYPE_F64); 283 psVector *scale = psVectorAlloc(NUM_READOUTS, PS_TYPE_F32); 284 psVector *scaleHalf = psVectorAlloc(NUM_READOUTS/2, PS_TYPE_F32); 285 psVector *scaleBig = psVectorAlloc(NUM_READOUTS*2, PS_TYPE_F32); 286 psVector *scaleF64 = psVectorAlloc(NUM_READOUTS, PS_TYPE_F64); 287 int testStatus = true; 288 for (i=0;i<NUM_READOUTS;i++) { 289 zero->data.F32[i] = 3.0; 290 zeroBig->data.F32[i] = 3.0; 291 } 292 for (i=0;i<NUM_READOUTS;i++) { 293 scale->data.F32[i] = 6.0; 294 scaleBig->data.F32[i] = 6.0; 295 } 296 297 params->stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN); 298 params->maskVal = 1; 299 params->fracLow = 0.0; 300 params->fracHigh = 10000.0; 301 params->nKeep = 0; 302 303 for (r=0;r<NUM_READOUTS;r++) { 304 baseRowsReadout[r] = r + 40; 305 baseColsReadout[r] = r + 42; 306 baseRows[r] = r; 307 baseCols[r] = r+2; 308 numRows[r] = 4 + (2 * r); 309 numCols[r] = 8 + (2 * r); 310 311 baseRowsReadout[r] = 0; 312 baseColsReadout[r] = 0; 313 baseRows[r] = 0; 314 baseCols[r] = 0; 315 numRows[r] = 10; 316 numCols[r] = 10; 317 318 psImage *tmpImage = psImageAlloc(numCols[r], numRows[r], PS_TYPE_F32); 319 for (i=0;i<numRows[r];i++) { 320 for (j=0;j<numCols[r];j++) { 321 tmpImage->data.F32[i][j] = (float) (i + j); 322 tmpImage->data.F32[i][j] = 1.0; 323 tmpImage->data.F32[i][j] = (float) r; 324 } 325 } 326 327 *(int *) (& (tmpImage->row0)) = baseRows[r]; 328 *(int *) (& (tmpImage->col0)) = baseCols[r]; 329 psReadout *tmpReadout = psReadoutAlloc(baseColsReadout[r], 330 baseRowsReadout[r], 331 tmpImage); 332 minOutRow = PS_MIN(minOutRow, (baseRowsReadout[r] + baseRows[r])); 333 minOutCol = PS_MIN(minOutCol, (baseColsReadout[r] + baseCols[r])); 334 maxOutRow = PS_MAX(maxOutRow, (baseRowsReadout[r] + baseRows[r] + numRows[r])); 335 maxOutCol = PS_MAX(maxOutCol, (baseColsReadout[r] + baseCols[r] + numCols[r])); 336 337 if (r == 0) { 338 list = psListAlloc(tmpReadout); 339 } else { 340 psListAdd(list, PS_LIST_HEAD, tmpReadout); 341 } 342 } 343 344 printf("----------------------------------------------------------------------------\n"); 345 printf("Calling pmReadoutCombine() with NULL zero vector.\n"); 346 rc = pmReadoutCombine(NULL, list, params, NULL, scale, true, 1.0, 0.0); 347 if (rc == NULL) { 348 //XXX: We should verify the output image here. 349 printf("ERROR: pmReadoutCombine() returned NULL\n"); 350 testStatus = false; 351 } 352 if (rc->type.type != scale->type.type) { 353 printf("ERROR: output readout->image has incorrect type.\n"); 354 testStatus = false; 355 } 356 psFree(rc); 357 358 printf("----------------------------------------------------------------------------\n"); 359 printf("Calling pmReadoutCombine() with incorrect length zero vector (too small). Should generate error.\n"); 360 rc = pmReadoutCombine(NULL, list, params, zeroHalf, scale, true, 1.0, 0.0); 361 if (rc != NULL) { 362 printf("ERROR: pmReadoutCombine() did not return NULL\n"); 363 testStatus = false; 364 } 365 366 printf("----------------------------------------------------------------------------\n"); 367 printf("Calling pmReadoutCombine() with incorrect type zero vector. Should generate error.\n"); 368 rc = pmReadoutCombine(NULL, list, params, zeroF64, scale, true, 1.0, 0.0); 369 if (rc != NULL) { 370 printf("ERROR: pmReadoutCombine() did not return NULL\n"); 371 testStatus = false; 372 } 373 374 printf("----------------------------------------------------------------------------\n"); 375 printf("Calling pmReadoutCombine() with incorrect length zero vector (too big). Should generate warning.\n"); 376 rc = pmReadoutCombine(output, list, params, zeroBig, scale, true, 1.0, 0.0); 377 if (rc != NULL) { 378 if (false == VerifyTheOutput(rc)) { 379 testStatus = false; 380 } 381 psFree(rc); 382 rc = NULL; 383 } else { 384 printf("ERROR: pmReadoutCombine() returned NULL\n"); 385 testStatus = false; 386 } 387 388 printf("----------------------------------------------------------------------------\n"); 389 printf("Calling pmReadoutCombine() with NULL scale vector.\n"); 390 rc = pmReadoutCombine(output, list, params, zero, NULL, true, 1.0, 0.0); 391 if (rc == NULL) { 392 //XXX: We should verify the output image here. 393 printf("ERROR: pmReadoutCombine() returned NULL\n"); 394 testStatus = false; 395 } 396 psFree(rc); 397 398 printf("----------------------------------------------------------------------------\n"); 399 printf("Calling pmReadoutCombine() with incorrect length scale vector (too small). Should generate error.\n"); 400 rc = pmReadoutCombine(output, list, params, zero, scaleHalf, true, 1.0, 0.0); 401 if (rc != NULL) { 402 printf("ERROR: pmReadoutCombine() did not return NULL\n"); 403 testStatus = false; 404 } 405 406 printf("----------------------------------------------------------------------------\n"); 407 printf("Calling pmReadoutCombine() with incorrect type scale vector. Should generate error.\n"); 408 rc = pmReadoutCombine(output, list, params, zero, scaleF64, true, 1.0, 0.0); 409 if (rc != NULL) { 410 printf("ERROR: pmReadoutCombine() did not return NULL\n"); 411 testStatus = false; 412 } 413 414 printf("----------------------------------------------------------------------------\n"); 415 printf("Calling pmReadoutCombine() with incorrect length scale vector (too big). Should generate warning.\n"); 416 rc = pmReadoutCombine(output, list, params, zero, scaleBig, true, 1.0, 0.0); 417 if (rc != NULL) { 418 if (false == VerifyTheOutput(rc)) { 419 testStatus = false; 420 } 421 psFree(rc); 422 rc = NULL; 423 } else { 424 printf("ERROR: pmReadoutCombine() returned NULL\n"); 425 testStatus = false; 426 } 427 428 printf("----------------------------------------------------------------------------\n"); 429 printf("Calling pmReadoutCombine() insufficient size output image. Should generate error, return NULL.\n"); 430 output = psImageAlloc(1, 1, PS_TYPE_F32); 431 rc = pmReadoutCombine(output, list, params, zero, scale, true, 1.0, 0.0); 432 if (rc != NULL) { 433 printf("ERROR: pmReadoutCombine() did not return NULL\n"); 434 testStatus = false; 435 } 436 psFree(output); 437 output = NULL; 438 439 printf("----------------------------------------------------------------------------\n"); 440 printf("Calling pmReadoutCombine() with NULL input list. Should generate error, return NULL.\n"); 441 rc = pmReadoutCombine(output, NULL, params, zero, scale, true, 1.0, 0.0); 442 if (rc != NULL) { 443 printf("ERROR: pmReadoutCombine() did not return NULL\n"); 444 testStatus = false; 445 } 446 447 printf("----------------------------------------------------------------------------\n"); 448 printf("Calling pmReadoutCombine() with NULL params. Should generate error, return NULL.\n"); 449 rc = pmReadoutCombine(output, list, NULL, zero, scale, true, 1.0, 0.0); 450 if (rc != NULL) { 451 printf("ERROR: pmReadoutCombine() did not return NULL\n"); 452 testStatus = false; 453 } 454 455 printf("----------------------------------------------------------------------------\n"); 456 psStatsOptions oldStatsOpts = params->stats->options |= PS_STAT_MIN; 457 printf("Calling pmReadoutCombine() with multiple stats->options. Should generate error, return NULL.\n"); 458 rc = pmReadoutCombine(output, list, params, zero, scale, true, 1.0, 0.0); 459 if (rc != NULL) { 460 printf("ERROR: pmReadoutCombine() did not return NULL\n"); 461 testStatus = false; 462 } 463 params->stats->options = oldStatsOpts; 464 465 printf("----------------------------------------------------------------------------\n"); 466 psStats *oldStats = params->stats; 467 printf("Calling pmReadoutCombine() with NULL param->stats. Should generate error, return NULL.\n"); 468 rc = pmReadoutCombine(output, list, params, zero, scale, true, 1.0, 0.0); 469 if (rc != NULL) { 470 printf("ERROR: pmReadoutCombine() did not return NULL\n"); 471 testStatus = false; 472 } 473 params->stats = oldStats; 474 475 printf("----------------------------------------------------------------------------\n"); 476 printf("============================================================================\n"); 477 478 psFree(params->stats); 479 psFree(params); 480 // psFree(output); 481 // psFree(rc); 482 psFree(zero); 483 psFree(zeroHalf); 484 psFree(zeroBig); 485 psFree(zeroF64); 486 psFree(scale); 487 psFree(scaleHalf); 488 psFree(scaleBig); 489 psFree(scaleF64); 490 psListElem *tmpInput = (psListElem *) list->head; 491 while (NULL != tmpInput) { 492 psReadout *tmpReadout = (psReadout *) tmpInput->data; 493 psFree(tmpReadout); 494 tmpInput = tmpInput->next; 495 } 496 psFree(list); 497 498 return(!testStatus); 499 } 500 // This code will
Note:
See TracChangeset
for help on using the changeset viewer.
