Changeset 21363 for trunk/psModules/src/imcombine/pmReadoutCombine.c
- Timestamp:
- Feb 5, 2009, 4:31:25 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/imcombine/pmReadoutCombine.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/pmReadoutCombine.c
r21183 r21363 37 37 params->iter = 1; 38 38 params->rej = INFINITY; 39 params-> weights = false;39 params->variances = false; 40 40 41 41 return params; … … 75 75 psStringAppend(&comment, "Combining using statistic: %x", params->combine); 76 76 if (!hdu->header) { 77 hdu->header = psMetadataAlloc();77 hdu->header = psMetadataAlloc(); 78 78 } 79 79 psMetadataAddStr(hdu->header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, comment, ""); … … 82 82 // note the clipping parameters, if used 83 83 if (params->combine == PS_STAT_CLIPPED_MEAN) { 84 psString comment = NULL; // Comment to add to header85 psStringAppend(&comment, "Combination clipping: %d iterations, rejection at %f sigma", params->iter, params->rej);86 psMetadataAddStr(hdu->header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, comment, "");87 psFree(comment);88 } 89 90 // note the use of weights91 if (params-> weights) {84 psString comment = NULL; // Comment to add to header 85 psStringAppend(&comment, "Combination clipping: %d iterations, rejection at %f sigma", params->iter, params->rej); 86 psMetadataAddStr(hdu->header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, comment, ""); 87 psFree(comment); 88 } 89 90 // note the use of variances 91 if (params->variances) { 92 92 psMetadataAddStr(hdu->header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, 93 "Using input weights to combine images", "");93 "Using input variances to combine images", ""); 94 94 } 95 95 … … 121 121 122 122 // generate the required output images based on the specified sizes 123 pmReadoutStackDefineOutput(output, col0, row0, numCols, numRows, true, params-> weights, params->blank);123 pmReadoutStackDefineOutput(output, col0, row0, numCols, numRows, true, params->variances, params->blank); 124 124 psTrace("psModules.imcombine", 7, "Output minimum: %d,%d\n", output->col0, output->row0); 125 125 … … 177 177 return false; 178 178 } 179 if (params-> weights && !readout->weight) {179 if (params->variances && !readout->variance) { 180 180 psError(PS_ERR_UNEXPECTED_NULL, true, 181 "Rejection based on weights requested, but no weights supplied for image %d.\n", i);181 "Rejection based on variances requested, but no variances supplied for image %d.\n", i); 182 182 return false; 183 183 } … … 190 190 } 191 191 192 // pthread_t id = pthread_self(); 193 // char name[64]; 194 // sprintf (name, "%x", (unsigned int) id); 195 // psTimerStart (name); 196 197 psStatsOptions combineStdev = 0; // Statistics option for weights 192 #if 0 193 pthread_t id = pthread_self(); 194 char name[64]; 195 sprintf(name, "%x", (unsigned int)id); 196 psTimerStart(name); 197 #endif 198 199 psStatsOptions combineStdev = 0; // Statistics option for variances 198 200 switch (params->combine) { 199 201 case PS_STAT_SAMPLE_MEAN: … … 250 252 psVectorMaskType *maskData = mask->data.PS_TYPE_VECTOR_MASK_DATA; // Dereference mask 251 253 252 psVector * weights = NULL; // Stack of weights253 psVector *errors = NULL; // Stack of errors (sqrt of variance /weights), for psVectorStats254 psF32 * weightsData = NULL; // Dereference weights255 if (params-> weights) {256 weights = psVectorAlloc(inputs->n, PS_TYPE_F32); // Stack of weights257 weightsData = weights->data.F32;254 psVector *variances = NULL; // Stack of variances 255 psVector *errors = NULL; // Stack of errors (sqrt of variance), for psVectorStats 256 psF32 *variancesData = NULL; // Dereference variances 257 if (params->variances) { 258 variances = psVectorAlloc(inputs->n, PS_TYPE_F32); // Stack of variances 259 variancesData = variances->data.F32; 258 260 } 259 261 psVector *index = NULL; // The indices to sort the pixels … … 279 281 psF32 **outputImage = output->image->data.F32; // Output image 280 282 psImageMaskType **outputMask = output->mask->data.PS_TYPE_IMAGE_MASK_DATA; // Output mask 281 psF32 **output Weight = NULL; // Output weightmap282 if (output-> weight) {283 output Weight = output->weight->data.F32;283 psF32 **outputVariance = NULL; // Output variance map 284 if (output->variance) { 285 outputVariance = output->variance->data.F32; 284 286 } 285 287 … … 323 325 } 324 326 325 if (params-> weights) {326 weightsData[r] = readout->weight->data.F32[yIn][xIn];327 if (params->variances) { 328 variancesData[r] = readout->variance->data.F32[yIn][xIn]; 327 329 } 328 330 … … 332 334 if (scale) { 333 335 pixelsData[r] *= invScale->data.F32[r]; 334 if (params-> weights) {335 weightsData[r] *= invScale->data.F32[r] * invScale->data.F32[r];336 if (params->variances) { 337 variancesData[r] *= invScale->data.F32[r] * invScale->data.F32[r]; 336 338 } 337 339 } … … 376 378 377 379 // XXXXX this step probably is very expensive : convert errors to variance everywhere? 378 if (params-> weights) {379 errors = (psVector*)psUnaryOp(errors, weights, "sqrt");380 if (params->variances) { 381 errors = (psVector*)psUnaryOp(errors, variances, "sqrt"); 380 382 } 381 383 … … 386 388 outputImage[yOut][xOut] = NAN; 387 389 outputMask[yOut][xOut] = params->blank; 388 if (params-> weights) {389 output Weight[yOut][xOut] = NAN;390 if (params->variances) { 391 outputVariance[yOut][xOut] = NAN; 390 392 } 391 393 sigma->data.F32[yOut][xOut] = NAN; … … 393 395 outputImage[yOut][xOut] = psStatsGetValue(stats, params->combine); 394 396 outputMask[yOut][xOut] = isfinite(outputImage[yOut][xOut]) ? 0 : params->blank; 395 if (params-> weights) {397 if (params->variances) { 396 398 float stdev = psStatsGetValue(stats, combineStdev); 397 output Weight[yOut][xOut] = PS_SQR(stdev); // Variance399 outputVariance[yOut][xOut] = PS_SQR(stdev); // Variance 398 400 // XXXX this is not the correct formal error. 399 401 // also, the weighted mean is not obviously the correct thing here … … 412 414 psFree(pixels); 413 415 psFree(mask); 414 psFree( weights);416 psFree(variances); 415 417 psFree(errors); 416 418 psFree(stats);
Note:
See TracChangeset
for help on using the changeset viewer.
