Changeset 17228 for trunk/psModules/src/imcombine/pmReadoutCombine.c
- Timestamp:
- Mar 28, 2008, 5:10:17 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/imcombine/pmReadoutCombine.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/pmReadoutCombine.c
r17137 r17228 18 18 19 19 //#define SHOW_BUSY 1 // Show that the function is busy 20 20 21 21 22 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// … … 94 95 } 95 96 96 psStats *stats = psStatsAlloc(params->combine); // The statistics to use in the combination 97 psStatsOptions combineStdev = 0; // Statistics option for weights 98 switch (params->combine) { 99 case PS_STAT_SAMPLE_MEAN: 100 case PS_STAT_SAMPLE_MEDIAN: 101 combineStdev = PS_STAT_SAMPLE_STDEV; 102 break; 103 case PS_STAT_ROBUST_MEDIAN: 104 combineStdev = PS_STAT_ROBUST_STDEV; 105 break; 106 case PS_STAT_FITTED_MEAN: 107 combineStdev = PS_STAT_FITTED_STDEV; 108 break; 109 case PS_STAT_CLIPPED_MEAN: 110 combineStdev = PS_STAT_CLIPPED_STDEV; 111 break; 112 default: 113 psAbort("Should never get here --- checked params->combine before.\n"); 114 } 115 116 psStats *stats = psStatsAlloc(params->combine | combineStdev); // The statistics to use in the combination 97 117 if (params->combine == PS_STAT_CLIPPED_MEAN) { 98 118 stats->clipSigma = params->rej; … … 107 127 } 108 128 } 129 if (params->weights && first) { 130 psMetadataAddStr(hdu->header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, 131 "Using input weights to combine images", ""); 132 } 109 133 110 134 int minInputCols, maxInputCols, minInputRows, maxInputRows; // Smallest and largest values to combine … … 120 144 psTrace("psModules.imcombine", 7, "Output minimum: %d,%d\n", output->col0, output->row0); 121 145 122 psStatsOptions combineStdev = 0; // Statistics option for weights 123 if (params->weights) { 124 if (first) { 125 psMetadataAddStr(hdu->header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, 126 "Using input weights to combine images", ""); 127 } 128 129 // Get the correct statistics option for weights 130 switch (params->combine) { 131 case PS_STAT_SAMPLE_MEAN: 132 case PS_STAT_SAMPLE_MEDIAN: 133 combineStdev = PS_STAT_SAMPLE_STDEV; 134 break; 135 case PS_STAT_ROBUST_MEDIAN: 136 combineStdev = PS_STAT_ROBUST_STDEV; 137 break; 138 case PS_STAT_FITTED_MEAN: 139 combineStdev = PS_STAT_FITTED_STDEV; 140 break; 141 case PS_STAT_CLIPPED_MEAN: 142 combineStdev = PS_STAT_CLIPPED_STDEV; 143 break; 144 default: 145 psAbort("Should never get here --- checked params->combine before.\n"); 146 } 147 stats->options |= combineStdev; 148 } 146 psImage *counts = pmReadoutAnalysisImage(output, PM_READOUT_STACK_ANALYSIS_COUNT, xSize, ySize, 147 PS_TYPE_U16, 0); 148 if (!counts) { 149 return false; 150 } 151 psImage *sigma = pmReadoutAnalysisImage(output, PM_READOUT_STACK_ANALYSIS_SIGMA, xSize, ySize, 152 PS_TYPE_F32, NAN); 153 if (!sigma) { 154 psFree(counts); 155 return false; 156 } 157 158 stats->options |= combineStdev; 149 159 150 160 // We loop through each pixel in the output image. We loop through each input readout. We determine if … … 273 283 outputMask[yOut][xOut] = params->blank; 274 284 outputImage[yOut][xOut] = NAN; 285 counts->data.U16[yOut][xOut] = 0; 286 sigma->data.F32[yOut][xOut] = NAN; 275 287 continue; 276 288 } … … 288 300 maskData[indexData[k]] = 1; 289 301 numMasked++; 302 numValid--; 290 303 } 291 304 } … … 293 306 for (int k = pixels->n - 1, numMasked = 0; numMasked < numHigh && k >= 0; k--) { 294 307 // Don't count the ones that are already masked 295 if (! maskData[indexData[k]]) {308 if (!maskData[indexData[k]]) { 296 309 maskData[indexData[k]] = 1; 297 310 numMasked++; 311 numValid--; 298 312 } 299 313 } 300 314 } 315 counts->data.U16[yOut][xOut] = numValid; 301 316 302 317 // XXXXX this step probably is very expensive : convert errors to variance everywhere? … … 314 329 outputWeight[yOut][xOut] = NAN; 315 330 } 331 sigma->data.F32[yOut][xOut] = NAN; 316 332 } else { 317 333 outputImage[yOut][xOut] = psStatsGetValue(stats, params->combine); … … 323 339 // also, the weighted mean is not obviously the correct thing here 324 340 } 341 sigma->data.F32[yOut][xOut] = psStatsGetValue(stats, combineStdev); 325 342 } 326 343 } … … 338 355 psFree(stats); 339 356 psFree(invScale); 357 psFree(counts); 358 psFree(sigma); 340 359 341 360 // Update the "concepts"
Note:
See TracChangeset
for help on using the changeset viewer.
