Changeset 18558 for trunk/ppMerge
- Timestamp:
- Jul 15, 2008, 10:29:11 AM (18 years ago)
- Location:
- trunk/ppMerge/src
- Files:
-
- 4 edited
-
ppMergeArguments.c (modified) (4 diffs)
-
ppMergeLoop.c (modified) (3 diffs)
-
ppMergeMask.c (modified) (14 diffs)
-
ppMergeScaleZero.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppMerge/src/ppMergeArguments.c
r18365 r18558 138 138 psMetadataAddS32(arguments, PS_LIST_TAIL, "-nkeep", 0, "Minimum number of pixels in stack to keep", 0); 139 139 psMetadataAddBool(arguments, PS_LIST_TAIL, "-weights", 0, "Use image weights in combination?", false); 140 psMetadataAddStr(arguments, PS_LIST_TAIL, "-maskval", 0, "Mask value for input data", NULL); 140 141 // XXX EAM : not clear this should be allowed on the command line. 142 // psMetadataAddStr(arguments, PS_LIST_TAIL, "-maskval", 0, "Mask value for input data", NULL); 143 141 144 psMetadataAddStr(arguments, PS_LIST_TAIL, "-combine", 0, "Statistic to use for combination", NULL); 142 145 psMetadataAddStr(arguments, PS_LIST_TAIL, "-mean", 0, "Statistic to use to measure the mean", NULL); … … 159 162 psMetadataAddStr(arguments, PS_LIST_TAIL, "-mask-mode", 0, "Mode to identify bad pixels", NULL); 160 163 psMetadataAddS32(arguments, PS_LIST_TAIL, "-mask-grow", 0, "Number of pixels to grow final mask", 0); 161 psMetadataAddStr(arguments, PS_LIST_TAIL, "-mask- growval", 0, "Value to give grownmask pixels", NULL);164 psMetadataAddStr(arguments, PS_LIST_TAIL, "-mask-set-valud",0, "Value to set for output mask pixels", NULL); 162 165 psMetadataAddBool(arguments, PS_LIST_TAIL, "-mask-chip", 0, "Measure mask statistics by chip?", false); 163 166 … … 264 267 VALUE_ARG_RECIPE_INT("-nkeep", "NKEEP", S32, 0); 265 268 VALUE_ARG_RECIPE_BOOL("-weights", "WEIGHTS"); 266 VALUE_ARG_RECIPE_MASK("-maskval", "MASKVAL"); 269 270 // XXX we do not supply this on the command line 271 // VALUE_ARG_RECIPE_MASK("-maskval", "MASKVAL"); 272 267 273 VALUE_ARG_RECIPE_STAT("-combine", "COMBINE"); 268 274 VALUE_ARG_RECIPE_STAT("-mean", "MEAN"); … … 281 287 VALUE_ARG_RECIPE_FLOAT("-mask-suspect", "MASK.SUSPECT", F32); 282 288 VALUE_ARG_RECIPE_FLOAT("-mask-bad", "MASK.BAD", F32); 283 VALUE_ARG_RECIPE_INT("-mask-grow", "MASK.GROW", S32, -1);284 VALUE_ARG_RECIPE_ MASK("-mask-growval", "MASK.GROWVAL");289 VALUE_ARG_RECIPE_INT("-mask-grow", "MASK.GROW", S32, 0); 290 VALUE_ARG_RECIPE_STR("-mask-set-value", "MASK.SET.VALUE"); 285 291 VALUE_ARG_RECIPE_BOOL("-mask-chip", "MASK.CHIPSTATS"); 286 292 -
trunk/ppMerge/src/ppMergeLoop.c
r18166 r18558 39 39 float frachigh = psMetadataLookupF32(NULL, arguments, "FRACHIGH"); // Reject fraction of hi pixels 40 40 int nKeep = psMetadataLookupS32(NULL, arguments, "NKEEP"); // Minimum number of values to keep 41 psMaskType maskVal = psMetadataLookupU8(NULL, arguments, "MASKVAL"); // Value to mask42 41 psStatsOptions combineStat = psMetadataLookupS32(NULL, arguments, "COMBINE"); // Combination statistic 43 42 bool useWeights = psMetadataLookupBool(NULL, arguments, "WEIGHTS"); // Use weights? … … 49 48 int fringeSmoothY = psMetadataLookupS32(NULL, arguments, "FRINGE.YSMOOTH"); // Smoothing regions in y 50 49 50 // set the mask and mark bit values based on the named masks 51 psMaskType maskVal; 52 psMaskType markVal; 53 if (!pmConfigMaskSetBits (&maskVal, &markVal, config)) { 54 psError (PS_ERR_UNKNOWN, true, "Unable to define the mask bit values"); 55 return false; 56 } 57 51 58 pmCombineParams *combination = pmCombineParamsAlloc(combineStat); // Combination parameters 52 59 combination->maskVal = maskVal; 53 combination->blank = pmConfigMask ("BLANK", config);60 combination->blank = pmConfigMaskGet("BLANK", config); 54 61 combination->nKeep = nKeep; 55 62 combination->fracHigh = frachigh; … … 294 301 } 295 302 296 if (!ppStatsFPA(stats, outFPA, view, maskVal | pmConfigMask("BLANK", config), config)) {303 if (!ppStatsFPA(stats, outFPA, view, maskVal, config)) { 297 304 psError(PS_ERR_UNKNOWN, true, "Unable to generate stats for image."); 298 305 goto ERROR; -
trunk/ppMerge/src/ppMergeMask.c
r18365 r18558 18 18 psRandom *rng, // Random number generator 19 19 psMetadata *stats // Statistics output 20 )20 ) 21 21 { 22 22 assert(config); … … 28 28 psStatsOptions meanStat = psMetadataLookupS32(NULL, config->arguments, "MEAN"); // Statistic for mean 29 29 psStatsOptions stdevStat = psMetadataLookupS32(NULL, config->arguments, "STDEV"); // Statistic for stdev 30 psMaskType maskVal = psMetadataLookupU8(NULL, config->arguments, "MASKVAL"); // Value to mask31 30 int sample = psMetadataLookupS32(NULL, config->arguments, "SAMPLE"); // Size of sample for statistics 32 31 bool chipStats = psMetadataLookupBool(&mdok, config->arguments, "MASK.CHIPSTATS"); // Statistics on chip? … … 35 34 pmMaskIdentifyMode maskMode = psMetadataLookupS32(NULL, config->arguments, "MASK.MODE"); // Mode for identifying bad pixels 36 35 int maskGrow = psMetadataLookupS32(NULL, config->arguments, "MASK.GROW"); // Radius to grow mask 37 psMaskType maskGrowVal = psMetadataLookupU8(NULL, config->arguments, "MASK.GROWVAL"); // Value for grown mask38 36 39 37 bool smoothSuspect = psMetadataLookupBool(&mdok, config->arguments, "MASK.SMOOTH.SUSPECT"); // Radius to grow mask 40 38 float smoothScale = psMetadataLookupF32(&mdok, config->arguments, "MASK.SMOOTH.SCALE"); // Radius to grow mask 41 39 40 psMaskType markVal; 41 psMaskType maskValRaw; 42 if (!pmConfigMaskSetBits (&maskValRaw, &markVal, config)) { 43 psError (PS_ERR_UNKNOWN, true, "Unable to define the mask bit values"); 44 return false; 45 } 46 47 char *maskOutName = psMetadataLookupStr (&mdok, config->arguments, "MASK.SET.VALUE"); 48 psMaskType maskValOut = pmConfigMaskGet (maskOutName, config); 49 if (!maskValOut) { 50 psError (PS_ERR_UNKNOWN, true, "Undefined output mask bit value"); 51 return false; 52 } 53 42 54 psStats *statistics = psStatsAlloc(meanStat | stdevStat); // Statistics for background 43 55 … … 137 149 int x = pixel % numCols; 138 150 int y = pixel / numCols; 139 if ((mask && (mask->data.PS_TYPE_MASK_DATA[y][x] & maskVal)) || 140 !isfinite(image->data.F32[y][x]) || 141 (outMask && (outMask->data.PS_TYPE_MASK_DATA[y][x] & maskVal))) { 142 continue; 143 } 151 if (mask && (mask->data.PS_TYPE_MASK_DATA[y][x] & maskValRaw)) continue; 152 if (outMask && (outMask->data.PS_TYPE_MASK_DATA[y][x] & maskValOut)) continue; 153 if (!isfinite(image->data.F32[y][x])) continue; 144 154 145 155 values->data.F32[valueIndex++] = image->data.F32[y][x]; … … 155 165 } 156 166 157 if (!pmMaskFlagSuspectPixels(outRO, readout, psStatsGetValue(statistics, meanStat), 158 psStatsGetValue(statistics, stdevStat), maskSuspect, maskVal)) { 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 plane 171 // maskValRaw is used to test for valid input pixels 172 if (!pmMaskFlagSuspectPixels(outRO, readout, mean, stdev, maskSuspect, maskValRaw)) { 159 173 psError(PS_ERR_UNKNOWN, false, "Unable to find suspect values in file %d", i); 160 174 psFree(inView); … … 189 203 190 204 pmHDU *hdu = pmHDUFromCell(inCell); // HDU for cell 191 if (!hdu || hdu->blankPHU) { 192 // No data here 193 continue; 194 } 205 if (!hdu || hdu->blankPHU) continue; 206 195 207 pmReadout *readout = inCell->readouts->data[0]; // Readout of interest 196 208 … … 198 210 pmReadout *outRO = pmFPAfileThisReadout(config->files, inView, "PPMERGE.OUTPUT.MASK"); 199 211 200 if (!pmMaskFlagSuspectPixels(outRO, readout, psStatsGetValue(statistics, meanStat), 201 psStatsGetValue(statistics, stdevStat), maskSuspect, maskVal)) { 212 float mean = psStatsGetValue(statistics, meanStat); 213 float stdev = psStatsGetValue(statistics, stdevStat); 214 215 if (!pmMaskFlagSuspectPixels(outRO, readout, mean, stdev, maskSuspect, maskValRaw)) { 202 216 psError(PS_ERR_UNKNOWN, false, "Unable to find suspect values in file %d", i); 203 217 goto MERGE_MASK_ERROR; … … 229 243 while ((outCell = pmFPAviewNextCell(outView, outFPA, 1))) { 230 244 231 // skip pinactive cells245 // skip inactive cells 232 246 if (!outCell->process) continue; 233 247 234 248 pmHDU *hdu = pmHDUFromCell(outCell); // HDU for cell 235 if (!hdu || hdu->blankPHU) { 236 // No data here 237 continue; 238 } 249 if (!hdu || hdu->blankPHU) continue; 239 250 240 251 psTrace("ppMerge", 1, "Getting bad pixels for chip %d cell %d", outView->chip, outView->cell); … … 250 261 } 251 262 252 if (!pmMaskIdentifyBadPixels(outRO, maskVal, maskBad, maskMode)) { 263 // set the bad pixels to the value 'maskVal' 264 if (!pmMaskIdentifyBadPixels(outRO, maskValOut, maskBad, maskMode)) { 253 265 psError(PS_ERR_UNKNOWN, false, "Unable to mask bad pixels"); 254 266 goto MERGE_MASK_ERROR; … … 274 286 } 275 287 276 if (maskGrow Val> 0) {277 psImage *grown = psImageGrowMask(NULL, outRO->mask, maskVal , maskGrow, maskGrowVal); // Grown mask288 if (maskGrow > 0) { 289 psImage *grown = psImageGrowMask(NULL, outRO->mask, maskValOut, maskGrow, maskValOut); // Grown mask 278 290 psFree(outRO->mask); 279 291 outRO->mask = grown; … … 307 319 outRO->image = psImageAlloc(outRO->mask->numCols, outRO->mask->numRows, PS_TYPE_F32); 308 320 psImageInit(outRO->image, 1.0); 309 if (!ppStatsFPA(stats, outRO->parent->parent->parent, outView, 310 maskVal | pmConfigMask("BLANK", config), config)) { 321 if (!ppStatsFPA(stats, outRO->parent->parent->parent, outView, maskValOut, config)) { 311 322 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to generate stats for image."); 312 323 psFree(outRO); … … 337 348 } 338 349 339 340 341 342 343 350 bool ppMergeMask(pmConfig *config) 344 351 { … … 381 388 goto PPMERGE_MASK_ERROR; 382 389 } 390 391 // XXX this function should use pmConfigMaskReadHeader () to get the named values defined 392 // for the input masks. 383 393 384 394 psString outName = ppMergeOutputFile(config); // Name of output file … … 414 424 psListAdd(inChips, PS_LIST_TAIL, chip); 415 425 } 426 427 // XXX I need to call pmConfigMaskWriteHeader for the PHU somewhere, after it is created! 428 416 429 if (!pmConceptsAverageChips(outChip, inChips, true)) { 417 430 psError(PS_ERR_UNKNOWN, false, "Unable to average Chip concepts."); -
trunk/ppMerge/src/ppMergeScaleZero.c
r18218 r18558 21 21 psStatsOptions meanStat = psMetadataLookupS32(NULL, config->arguments, "MEAN"); // Statistic for mean 22 22 psStatsOptions stdevStat = psMetadataLookupS32(NULL, config->arguments, "STDEV"); // Statistic for stdev 23 psMaskType maskVal = psMetadataLookupU8(NULL, config->arguments, "MASKVAL"); // Value to mask24 23 int shutterSize = psMetadataLookupS32(NULL, config->arguments, "SHUTTER.SIZE"); // Size of shutter region 24 25 psMaskType maskVal = pmConfigMaskGet("MASK.VALUE", config); // Value to mask 25 26 26 27 psVector *gains = NULL; // Gains for each cell
Note:
See TracChangeset
for help on using the changeset viewer.
