Changeset 21365 for trunk/ppMerge/src/ppMergeMask.c
- Timestamp:
- Feb 5, 2009, 4:47:00 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/ppMerge/src/ppMergeMask.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppMerge/src/ppMergeMask.c
r21244 r21365 6 6 * 7 7 * @author IfA 8 * @version $Revision: 1.1 7$ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02-0 1 21:43:05$8 * @version $Revision: 1.18 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-06 02:44:31 $ 10 10 * Copyright 2009 Institute for Astronomy, University of Hawaii 11 11 */ … … 38 38 float smoothScale = psMetadataLookupF32(&mdok, config->arguments, "MASK.SMOOTH.SCALE"); ///< Radius to grow mask 39 39 40 psImageMaskType markVal; 41 psImageMaskType maskValRaw; 42 if (!pmConfigMaskSetBits (&maskValRaw, &markVal, config)) { 43 psError (PS_ERR_UNKNOWN, true, "Unable to define the mask bit values"); 44 return false; 40 psImageMaskType markVal, maskValRaw; 41 if (!pmConfigMaskSetBits(&maskValRaw, &markVal, config)) { 42 psError(PS_ERR_UNKNOWN, true, "Unable to define the mask bit values"); 43 return false; 45 44 } 46 45 … … 48 47 psImageMaskType maskValOut = pmConfigMaskGet (maskOutName, config); 49 48 if (!maskValOut) { 50 psError (PS_ERR_UNKNOWN, true, "Undefined output mask bit value");51 return false;52 } 53 54 psStats *statistics = psStatsAlloc(meanStat | stdevStat); // /<Statistics for background49 psError (PS_ERR_UNKNOWN, true, "Undefined output mask bit value"); 50 return false; 51 } 52 53 psStats *statistics = psStatsAlloc(meanStat | stdevStat); // Statistics for background 55 54 56 55 psString outName = ppMergeOutputFile(config); ///< Name of output file 57 56 pmChip *outChip = pmFPAfileThisChip(config->files, view, outName); ///< Output chip 58 57 psFree(outName); 59 58 60 59 int numCells = 1; 61 60 if (chipStats) { 62 // count the number of active cells for this chip:63 numCells = 0;64 for (int i = 0; i < outChip->cells->n; i++) {65 pmCell *cell = outChip->cells->data[i];66 if (!cell->process) continue;67 numCells ++;68 }61 // count the number of active cells for this chip: 62 numCells = 0; 63 for (int i = 0; i < outChip->cells->n; i++) { 64 pmCell *cell = outChip->cells->data[i]; 65 if (!cell->process) continue; 66 numCells ++; 67 } 69 68 } 70 69 … … 85 84 while ((inCell = pmFPAviewNextCell(inView, inFPA, 1))) { 86 85 87 // the output FPA structure carries the information about which cells to process88 pmCell *outCell = pmFPAfileThisCell(config->files, inView, "PPMERGE.OUTPUT.MASK"); // /<Output cell89 if (!outCell->process) continue;86 // the output FPA structure carries the information about which cells to process 87 pmCell *outCell = pmFPAfileThisCell(config->files, inView, "PPMERGE.OUTPUT.MASK"); // Output cell 88 if (!outCell->process) continue; 90 89 91 90 pmHDU *hdu = pmHDUFromCell(inCell); ///< HDU for cell … … 150 149 int y = pixel / numCols; 151 150 if (mask && (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskValRaw)) continue; 152 if (outMask && (outMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskValOut)) continue;153 if (!isfinite(image->data.F32[y][x])) continue;151 if (outMask && (outMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskValOut)) continue; 152 if (!isfinite(image->data.F32[y][x])) continue; 154 153 155 154 values->data.F32[valueIndex++] = image->data.F32[y][x]; … … 165 164 } 166 165 167 float mean = psStatsGetValue(statistics, meanStat);168 float stdev = psStatsGetValue(statistics, stdevStat);169 170 // this function increments the count for each suspect pixel in each input plane171 // maskValRaw is used to test for valid input pixels166 float mean = psStatsGetValue(statistics, meanStat); 167 float stdev = psStatsGetValue(statistics, stdevStat); 168 169 // this function increments the count for each suspect pixel in each input plane 170 // maskValRaw is used to test for valid input pixels 172 171 if (!pmMaskFlagSuspectPixels(outRO, readout, mean, stdev, maskSuspect, maskValRaw)) { 173 172 psError(PS_ERR_UNKNOWN, false, "Unable to find suspect values in file %d", i); … … 197 196 inView->cell = -1; 198 197 while ((inCell = pmFPAviewNextCell(inView, inFPA, 1))) { 199 200 // the output FPA structure carries the information about which cells to process 201 pmCell *outCell = pmFPAfileThisCell(config->files, inView, "PPMERGE.OUTPUT.MASK"); ///< Output cell 202 if (!outCell->process) continue; 198 // the output FPA structure carries the information about which cells to process 199 pmCell *outCell = pmFPAfileThisCell(config->files, inView, "PPMERGE.OUTPUT.MASK"); // Output cell 200 if (!outCell->process) continue; 203 201 204 202 pmHDU *hdu = pmHDUFromCell(inCell); ///< HDU for cell … … 210 208 pmReadout *outRO = pmFPAfileThisReadout(config->files, inView, "PPMERGE.OUTPUT.MASK"); 211 209 212 float mean = psStatsGetValue(statistics, meanStat);213 float stdev = psStatsGetValue(statistics, stdevStat);214 215 if (!pmMaskFlagSuspectPixels(outRO, readout, mean, stdev, maskSuspect, maskValRaw)) {210 float mean = psStatsGetValue(statistics, meanStat); 211 float stdev = psStatsGetValue(statistics, stdevStat); 212 213 if (!pmMaskFlagSuspectPixels(outRO, readout, mean, stdev, maskSuspect, maskValRaw)) { 216 214 psError(PS_ERR_UNKNOWN, false, "Unable to find suspect values in file %d", i); 217 215 goto MERGE_MASK_ERROR; … … 243 241 while ((outCell = pmFPAviewNextCell(outView, outFPA, 1))) { 244 242 245 // skip inactive cells246 if (!outCell->process) continue;243 // skip inactive cells 244 if (!outCell->process) continue; 247 245 248 246 pmHDU *hdu = pmHDUFromCell(outCell); ///< HDU for cell … … 254 252 pmReadout *outRO = outCell->readouts->data[0]; ///< Output readout 255 253 256 if (smoothSuspect) {257 // XXX test output of suspect pixel image258 psImage *suspects = psMetadataLookupPtr(NULL, outRO->analysis, PM_MASK_ANALYSIS_SUSPECT); ///<Suspect img259 assert (suspects);260 psImageSmooth (suspects, smoothScale, 3); ///<extend smoothing region to 3-sigma261 }262 263 // set the bad pixels to the value 'maskVal'254 if (smoothSuspect) { 255 // XXX test output of suspect pixel image 256 psImage *suspects = psMetadataLookupPtr(NULL, outRO->analysis, PM_MASK_ANALYSIS_SUSPECT); // Suspect img 257 assert (suspects); 258 psImageSmooth (suspects, smoothScale, 3); // extend smoothing region to 3-sigma 259 } 260 261 // set the bad pixels to the value 'maskVal' 264 262 if (!pmMaskIdentifyBadPixels(outRO, maskValOut, maskBad, maskMode)) { 265 263 psError(PS_ERR_UNKNOWN, false, "Unable to mask bad pixels"); … … 352 350 assert(config); 353 351 354 bool mdok; // /<Status of MD lookup355 int numFiles = psMetadataLookupS32(NULL, config->arguments, "INPUTS.NUM"); // /<Number of inputs356 bool haveMasks = psMetadataLookupBool(&mdok, config->arguments, "INPUTS.MASKS"); // /<Do we have masks?357 bool have Weights = psMetadataLookupBool(&mdok, config->arguments, "INPUTS.WEIGHTS"); ///< Do we have weights?358 int iter = psMetadataLookupS32(NULL, config->arguments, "ITER"); // /<Number of rejection iterations352 bool mdok; // Status of MD lookup 353 int numFiles = psMetadataLookupS32(NULL, config->arguments, "INPUTS.NUM"); // Number of inputs 354 bool haveMasks = psMetadataLookupBool(&mdok, config->arguments, "INPUTS.MASKS"); // Do we have masks? 355 bool haveVariances = psMetadataLookupBool(&mdok, config->arguments, "INPUTS.VARIANCES"); // Got variances? 356 int iter = psMetadataLookupS32(NULL, config->arguments, "ITER"); // Number of rejection iterations 359 357 360 358 PS_ASSERT_INT_POSITIVE(iter, false); … … 375 373 psFree(masks); 376 374 } 377 if (have Weights) {378 psArray * weights = ppMergeFileDataLevel(config, "PPMERGE.INPUT.WEIGHT", PM_FPA_LEVEL_READOUT);379 psFree( weights);375 if (haveVariances) { 376 psArray *variances = ppMergeFileDataLevel(config, "PPMERGE.INPUT.VARIANCE", PM_FPA_LEVEL_READOUT); 377 psFree(variances); 380 378 } 381 379 … … 417 415 } 418 416 419 if (outChip->data_exists) {420 psList *inChips = psListAlloc(NULL);421 for (int i=0; i < numFiles; i++) {422 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT", i); ///<Input file423 pmChip *chip = pmFPAviewThisChip(view, file->fpa);424 psListAdd(inChips, PS_LIST_TAIL, chip);425 }426 427 // XXX I need to call pmConfigMaskWriteHeader for the PHU somewhere, after it is created!428 429 if (!pmConceptsAverageChips(outChip, inChips, true)) {430 psError(PS_ERR_UNKNOWN, false, "Unable to average Chip concepts.");431 psFree(inChips);432 goto PPMERGE_MASK_ERROR;433 }434 psFree(inChips);435 }417 if (outChip->data_exists) { 418 psList *inChips = psListAlloc(NULL); 419 for (int i=0; i < numFiles; i++) { 420 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT", i); // Input file 421 pmChip *chip = pmFPAviewThisChip(view, file->fpa); 422 psListAdd(inChips, PS_LIST_TAIL, chip); 423 } 424 425 // XXX I need to call pmConfigMaskWriteHeader for the PHU somewhere, after it is created! 426 427 if (!pmConceptsAverageChips(outChip, inChips, true)) { 428 psError(PS_ERR_UNKNOWN, false, "Unable to average Chip concepts."); 429 psFree(inChips); 430 goto PPMERGE_MASK_ERROR; 431 } 432 psFree(inChips); 433 } 436 434 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { 437 435 goto PPMERGE_MASK_ERROR;
Note:
See TracChangeset
for help on using the changeset viewer.
