Changeset 21363 for trunk/psModules/src/detrend/pmShutterCorrection.c
- Timestamp:
- Feb 5, 2009, 4:31:25 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/detrend/pmShutterCorrection.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/detrend/pmShutterCorrection.c
r21183 r21363 383 383 psArray *images = psArrayAlloc(num);// Array of images 384 384 psArray *masks = NULL; // Array of masks 385 psArray * weights = NULL; // Array of weights385 psArray *variances = NULL; // Array of variances 386 386 psVector *exptimes = psVectorAlloc(num, PS_TYPE_F32); // Vector of exposure times 387 387 … … 392 392 masks = psArrayAlloc(num); 393 393 } 394 if (readout-> weight)394 if (readout->variance) 395 395 { 396 weights = psArrayAlloc(num);396 variances = psArrayAlloc(num); 397 397 } 398 398 } … … 472 472 } 473 473 474 psImage * weight = readout->weight; // Weightmap of interest475 if ( weight) {476 if (! weights) {477 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Not all readouts have weights.\n");474 psImage *variance = readout->variance; // Variance map of interest 475 if (variance) { 476 if (!variances) { 477 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Not all readouts have variances.\n"); 478 478 goto MEASURE_ERROR; 479 479 } 480 weights->data[i] = psMemIncrRefCounter(weight);481 482 if ( weight->type.type != PS_TYPE_F32) {483 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Bad type for weights: %x\n", weight->type.type);480 variances->data[i] = psMemIncrRefCounter(variance); 481 482 if (variance->type.type != PS_TYPE_F32) { 483 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Bad type for variances: %x\n", variance->type.type); 484 484 goto MEASURE_ERROR; 485 485 } 486 if ( weight->numRows != numRows || weight->numCols != numCols) {486 if (variance->numRows != numRows || variance->numCols != numCols) { 487 487 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 488 " Weight sizes don't match: %dx%d vs %dx%d\n", weight->numCols, weight->numRows,488 "Variance sizes don't match: %dx%d vs %dx%d\n", variance->numCols, variance->numRows, 489 489 numCols, numRows); 490 490 goto MEASURE_ERROR; 491 491 } 492 } else if ( weights) {493 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Not all readouts have weights.\n");492 } else if (variances) { 493 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Not all readouts have variances.\n"); 494 494 goto MEASURE_ERROR; 495 495 } … … 566 566 psTrace("psModules.detrend", 3, "Mean reference value: %f\n", meanRef); 567 567 568 // Check the weights569 if ( weights && nIter > 1) {570 for (int i = 0; i < weights->n && nIter > 1; i++) {571 psImage * weight = weights->data[i]; // Weightimage572 if (! weight) {573 // We don't have weights, so no realistic errors: turn off iteration568 // Check the variances 569 if (variances && nIter > 1) { 570 for (int i = 0; i < variances->n && nIter > 1; i++) { 571 psImage *variance = variances->data[i]; // Variance image 572 if (!variance) { 573 // We don't have variances, so no realistic errors: turn off iteration 574 574 if (nIter > 0) { 575 psWarning("Not all images have weights --- turning iteration off.\n");575 psWarning("Not all images have variances --- turning iteration off.\n"); 576 576 } 577 577 nIter = 1; … … 594 594 mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = (maskImage->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal); 595 595 } 596 psImage * weight; // Weightimage597 if ( weights && (weight = weights->data[i])) {598 errors->data.F32[i] = sqrtf( weight->data.F32[y][x]) * refs->data.F32[i];596 psImage *variance; // Variance image 597 if (variances && (variance = variances->data[i])) { 598 errors->data.F32[i] = sqrtf(variance->data.F32[y][x]) * refs->data.F32[i]; 599 599 } else { 600 600 errors->data.F32[i] = sqrtf(image->data.F32[y][x]) * refs->data.F32[i]; … … 645 645 psFree(images); 646 646 psFree(masks); 647 psFree( weights);647 psFree(variances); 648 648 psFree(refs); 649 649 psFree(regions); … … 878 878 PS_ASSERT_IMAGE_SIZE(readout->mask, data->numCols, data->numRows, NULL); 879 879 } 880 if (readout-> weight) {881 PS_ASSERT_IMAGE_NON_NULL(readout-> weight, NULL);882 PS_ASSERT_IMAGE_TYPE(readout-> weight, PS_TYPE_F32, NULL);883 PS_ASSERT_IMAGE_SIZE(readout-> weight, data->numCols, data->numRows, NULL);880 if (readout->variance) { 881 PS_ASSERT_IMAGE_NON_NULL(readout->variance, NULL); 882 PS_ASSERT_IMAGE_TYPE(readout->variance, PS_TYPE_F32, NULL); 883 PS_ASSERT_IMAGE_SIZE(readout->variance, data->numCols, data->numRows, NULL); 884 884 } 885 885 … … 1133 1133 mask->data.PS_TYPE_VECTOR_MASK_DATA[r] = (readout->mask->data.PS_TYPE_IMAGE_MASK_DATA[yIn][xIn] & maskVal); 1134 1134 } 1135 if (readout-> weight) {1136 errors->data.F32[r] = sqrtf(readout-> weight->data.F32[yIn][xIn]) * ref;1135 if (readout->variance) { 1136 errors->data.F32[r] = sqrtf(readout->variance->data.F32[yIn][xIn]) * ref; 1137 1137 } else { 1138 1138 // XXX guess that the input data is Poisson distributed; if we go negative, force high
Note:
See TracChangeset
for help on using the changeset viewer.
