Changeset 21219 for branches/pap_branch_20090128/ppMerge/src/ppMergeMask.c
- Timestamp:
- Jan 28, 2009, 5:24:09 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/pap_branch_20090128/ppMerge/src/ppMergeMask.c
r18756 r21219 26 26 float smoothScale = psMetadataLookupF32(&mdok, config->arguments, "MASK.SMOOTH.SCALE"); // Radius to grow mask 27 27 28 psMaskType markVal; 29 psMaskType maskValRaw; 30 if (!pmConfigMaskSetBits (&maskValRaw, &markVal, config)) { 31 psError (PS_ERR_UNKNOWN, true, "Unable to define the mask bit values"); 32 return false; 28 psImageMaskType markVal, maskValRaw; 29 if (!pmConfigMaskSetBits(&maskValRaw, &markVal, config)) { 30 psError (PS_ERR_UNKNOWN, true, "Unable to define the mask bit values"); 31 return false; 33 32 } 34 33 … … 36 35 psMaskType maskValOut = pmConfigMaskGet (maskOutName, config); 37 36 if (!maskValOut) { 38 psError (PS_ERR_UNKNOWN, true, "Undefined output mask bit value");39 return false;40 } 41 37 psError (PS_ERR_UNKNOWN, true, "Undefined output mask bit value"); 38 return false; 39 } 40 42 41 psStats *statistics = psStatsAlloc(meanStat | stdevStat); // Statistics for background 43 42 … … 45 44 pmChip *outChip = pmFPAfileThisChip(config->files, view, outName); // Output chip 46 45 psFree(outName); 47 46 48 47 int numCells = 1; 49 48 if (chipStats) { 50 // count the number of active cells for this chip:51 numCells = 0;52 for (int i = 0; i < outChip->cells->n; i++) {53 pmCell *cell = outChip->cells->data[i];54 if (!cell->process) continue;55 numCells ++;56 }49 // count the number of active cells for this chip: 50 numCells = 0; 51 for (int i = 0; i < outChip->cells->n; i++) { 52 pmCell *cell = outChip->cells->data[i]; 53 if (!cell->process) continue; 54 numCells ++; 55 } 57 56 } 58 57 … … 73 72 while ((inCell = pmFPAviewNextCell(inView, inFPA, 1))) { 74 73 75 // the output FPA structure carries the information about which cells to process74 // the output FPA structure carries the information about which cells to process 76 75 pmCell *outCell = pmFPAfileThisCell(config->files, inView, "PPMERGE.OUTPUT.MASK"); // Output cell 77 if (!outCell->process) continue;76 if (!outCell->process) continue; 78 77 79 78 pmHDU *hdu = pmHDUFromCell(inCell); // HDU for cell … … 138 137 int y = pixel / numCols; 139 138 if (mask && (mask->data.PS_TYPE_MASK_DATA[y][x] & maskValRaw)) continue; 140 if (outMask && (outMask->data.PS_TYPE_MASK_DATA[y][x] & maskValOut)) continue;141 if (!isfinite(image->data.F32[y][x])) continue;139 if (outMask && (outMask->data.PS_TYPE_MASK_DATA[y][x] & maskValOut)) continue; 140 if (!isfinite(image->data.F32[y][x])) continue; 142 141 143 142 values->data.F32[valueIndex++] = image->data.F32[y][x]; … … 153 152 } 154 153 155 float mean = psStatsGetValue(statistics, meanStat);156 float stdev = psStatsGetValue(statistics, stdevStat);157 158 // this function increments the count for each suspect pixel in each input plane159 // maskValRaw is used to test for valid input pixels154 float mean = psStatsGetValue(statistics, meanStat); 155 float stdev = psStatsGetValue(statistics, stdevStat); 156 157 // this function increments the count for each suspect pixel in each input plane 158 // maskValRaw is used to test for valid input pixels 160 159 if (!pmMaskFlagSuspectPixels(outRO, readout, mean, stdev, maskSuspect, maskValRaw)) { 161 160 psError(PS_ERR_UNKNOWN, false, "Unable to find suspect values in file %d", i); … … 186 185 while ((inCell = pmFPAviewNextCell(inView, inFPA, 1))) { 187 186 188 // the output FPA structure carries the information about which cells to process189 pmCell *outCell = pmFPAfileThisCell(config->files, inView, "PPMERGE.OUTPUT.MASK"); // Output cell190 if (!outCell->process) continue;187 // the output FPA structure carries the information about which cells to process 188 pmCell *outCell = pmFPAfileThisCell(config->files, inView, "PPMERGE.OUTPUT.MASK"); // Output cell 189 if (!outCell->process) continue; 191 190 192 191 pmHDU *hdu = pmHDUFromCell(inCell); // HDU for cell … … 198 197 pmReadout *outRO = pmFPAfileThisReadout(config->files, inView, "PPMERGE.OUTPUT.MASK"); 199 198 200 float mean = psStatsGetValue(statistics, meanStat);201 float stdev = psStatsGetValue(statistics, stdevStat);202 203 if (!pmMaskFlagSuspectPixels(outRO, readout, mean, stdev, maskSuspect, maskValRaw)) {199 float mean = psStatsGetValue(statistics, meanStat); 200 float stdev = psStatsGetValue(statistics, stdevStat); 201 202 if (!pmMaskFlagSuspectPixels(outRO, readout, mean, stdev, maskSuspect, maskValRaw)) { 204 203 psError(PS_ERR_UNKNOWN, false, "Unable to find suspect values in file %d", i); 205 204 goto MERGE_MASK_ERROR; … … 231 230 while ((outCell = pmFPAviewNextCell(outView, outFPA, 1))) { 232 231 233 // skip inactive cells234 if (!outCell->process) continue;232 // skip inactive cells 233 if (!outCell->process) continue; 235 234 236 235 pmHDU *hdu = pmHDUFromCell(outCell); // HDU for cell … … 242 241 pmReadout *outRO = outCell->readouts->data[0]; // Output readout 243 242 244 if (smoothSuspect) {245 // XXX test output of suspect pixel image246 psImage *suspects = psMetadataLookupPtr(NULL, outRO->analysis, PM_MASK_ANALYSIS_SUSPECT); // Suspect img247 assert (suspects);248 psImageSmooth (suspects, smoothScale, 3); // extend smoothing region to 3-sigma249 }250 251 // set the bad pixels to the value 'maskVal'243 if (smoothSuspect) { 244 // XXX test output of suspect pixel image 245 psImage *suspects = psMetadataLookupPtr(NULL, outRO->analysis, PM_MASK_ANALYSIS_SUSPECT); // Suspect img 246 assert (suspects); 247 psImageSmooth (suspects, smoothScale, 3); // extend smoothing region to 3-sigma 248 } 249 250 // set the bad pixels to the value 'maskVal' 252 251 if (!pmMaskIdentifyBadPixels(outRO, maskValOut, maskBad, maskMode)) { 253 252 psError(PS_ERR_UNKNOWN, false, "Unable to mask bad pixels"); … … 343 342 int numFiles = psMetadataLookupS32(NULL, config->arguments, "INPUTS.NUM"); // Number of inputs 344 343 bool haveMasks = psMetadataLookupBool(&mdok, config->arguments, "INPUTS.MASKS"); // Do we have masks? 345 bool have Weights = psMetadataLookupBool(&mdok, config->arguments, "INPUTS.WEIGHTS"); // Do we have weights?344 bool haveVariances = psMetadataLookupBool(&mdok, config->arguments, "INPUTS.VARIANCES"); // Got variances? 346 345 int iter = psMetadataLookupS32(NULL, config->arguments, "ITER"); // Number of rejection iterations 347 346 … … 363 362 psFree(masks); 364 363 } 365 if (have Weights) {366 psArray * weights = ppMergeFileDataLevel(config, "PPMERGE.INPUT.WEIGHT", PM_FPA_LEVEL_READOUT);367 psFree( weights);364 if (haveVariances) { 365 psArray *variances = ppMergeFileDataLevel(config, "PPMERGE.INPUT.VARIANCE", PM_FPA_LEVEL_READOUT); 366 psFree(variances); 368 367 } 369 368 … … 405 404 } 406 405 407 if (outChip->data_exists) {408 psList *inChips = psListAlloc(NULL);409 for (int i=0; i < numFiles; i++) {410 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT", i); // Input file411 pmChip *chip = pmFPAviewThisChip(view, file->fpa);412 psListAdd(inChips, PS_LIST_TAIL, chip);413 }414 415 // XXX I need to call pmConfigMaskWriteHeader for the PHU somewhere, after it is created!416 417 if (!pmConceptsAverageChips(outChip, inChips, true)) {418 psError(PS_ERR_UNKNOWN, false, "Unable to average Chip concepts.");419 psFree(inChips);420 goto PPMERGE_MASK_ERROR;421 }422 psFree(inChips);423 }406 if (outChip->data_exists) { 407 psList *inChips = psListAlloc(NULL); 408 for (int i=0; i < numFiles; i++) { 409 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT", i); // Input file 410 pmChip *chip = pmFPAviewThisChip(view, file->fpa); 411 psListAdd(inChips, PS_LIST_TAIL, chip); 412 } 413 414 // XXX I need to call pmConfigMaskWriteHeader for the PHU somewhere, after it is created! 415 416 if (!pmConceptsAverageChips(outChip, inChips, true)) { 417 psError(PS_ERR_UNKNOWN, false, "Unable to average Chip concepts."); 418 psFree(inChips); 419 goto PPMERGE_MASK_ERROR; 420 } 421 psFree(inChips); 422 } 424 423 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { 425 424 goto PPMERGE_MASK_ERROR;
Note:
See TracChangeset
for help on using the changeset viewer.
