Changeset 18365
- Timestamp:
- Jun 29, 2008, 2:55:44 PM (18 years ago)
- Location:
- trunk/ppMerge/src
- Files:
-
- 3 edited
-
ppMergeArguments.c (modified) (2 diffs)
-
ppMergeCamera.c (modified) (2 diffs)
-
ppMergeMask.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppMerge/src/ppMergeArguments.c
r18112 r18365 162 162 psMetadataAddBool(arguments, PS_LIST_TAIL, "-mask-chip", 0, "Measure mask statistics by chip?", false); 163 163 164 psMetadataAddBool(arguments, PS_LIST_TAIL, "-mask-smooth-suspect", 0, "smooth suspect pixels?", false); 165 psMetadataAddF32(arguments, PS_LIST_TAIL, "-mask-smooth-scale", 0, "smoothing sigma for suspect pixels", NAN); 166 167 // chip & cell selections are used to limit chips to be processed 168 int argnum; 169 if ((argnum = psArgumentGet (argc, argv, "-chip"))) { 170 psArgumentRemove (argnum, &argc, argv); 171 psMetadataAddStr (config->arguments, PS_LIST_TAIL, "CHIP_SELECTIONS", PS_DATA_STRING, "", argv[argnum]); 172 psArgumentRemove (argnum, &argc, argv); 173 } 174 if ((argnum = psArgumentGet (argc, argv, "-cell"))) { 175 psArgumentRemove (argnum, &argc, argv); 176 psMetadataAddStr (config->arguments, PS_LIST_TAIL, "CELL_SELECTIONS", PS_DATA_STRING, "", argv[argnum]); 177 psArgumentRemove (argnum, &argc, argv); 178 } 179 164 180 if (argc == 1 || !psArgumentParse(arguments, &argc, argv) || argc != 3) { 165 181 usage(argv[0], arguments); … … 269 285 VALUE_ARG_RECIPE_BOOL("-mask-chip", "MASK.CHIPSTATS"); 270 286 287 VALUE_ARG_RECIPE_BOOL("-mask-smooth-suspect", "MASK.SMOOTH.SUSPECT"); 288 VALUE_ARG_RECIPE_FLOAT("-mask-smooth-scale", "MASK.SMOOTH.SCALE", F32); 271 289 272 290 const char *maskModeStr = psMetadataLookupStr(NULL, arguments, "-mask-mode"); // Mode to identify bad pix -
trunk/ppMerge/src/ppMergeCamera.c
r17929 r18365 30 30 return false; 31 31 } 32 33 // Chip selection: turn on only the chips specified. 34 bool status; 35 char *chipLine = psMetadataLookupStr(&status, config->arguments, "CHIP_SELECTIONS"); 36 psArray *chips = psStringSplitArray (chipLine, ",", false); 37 if (chips->n > 0) { 38 pmFPASelectChip (fpa, -1, true); // deselect all chips 39 for (int i = 0; i < chips->n; i++) { 40 int chipNum = atoi(chips->data[i]); 41 if (! pmFPASelectChip(fpa, chipNum, false)) { 42 psError(PS_ERR_IO, false, "Chip number %d doesn't exist in camera.\n", chipNum); 43 psFree (chips); 44 return false; 45 } 46 } 47 } 48 psFree (chips); 49 50 // Cell selection: turn on only the cells specified. Note that this affects the same cell 51 // for all chips 52 char *cellLine = psMetadataLookupStr(&status, config->arguments, "CELL_SELECTIONS"); 53 psArray *cells = psStringSplitArray (cellLine, ",", false); 54 if (cells->n > 0) { 55 for (int i = 0; i < fpa->chips->n; i++) { 56 pmChip *chip = fpa->chips->data[i]; 57 pmChipSelectCell (chip, -1, true); // deselect all cells 58 for (int j = 0; j < cells->n; j++) { 59 int cellNum = atoi(cells->data[j]); 60 if (! pmChipSelectCell(chip, cellNum, false)) { 61 psError(PS_ERR_IO, false, "Cell number %d doesn't exist in camera.\n", cellNum); 62 psFree (cells); 63 return false; 64 } 65 } 66 } 67 } 68 psFree (cells); 32 69 33 70 pmFPAfile *output = pmFPAfileDefineOutput(config, fpa, name); … … 229 266 pmHDU *hdu = pmHDUGetLowest(fpa, chip, cell); // HDU for cell 230 267 if (!hdu || hdu->blankPHU) { 231 psFree(cell->concepts);232 cell->concepts = NULL;233 268 cell->data_exists = false; 234 269 cell->file_exists = false; 235 270 culled++; 271 if (cell->concepts) { 272 psFree(cell->concepts); 273 cell->concepts = NULL; 274 } 236 275 } 237 276 } 238 277 if (culled == cells->n) { 239 psFree(chip->concepts);240 chip->concepts = NULL;241 278 chip->data_exists = false; 242 279 chip->file_exists = false; 280 if (chip->concepts) { 281 psFree(chip->concepts); 282 chip->concepts = NULL; 283 } 243 284 } 244 285 } -
trunk/ppMerge/src/ppMergeMask.c
r17430 r18365 37 37 psMaskType maskGrowVal = psMetadataLookupU8(NULL, config->arguments, "MASK.GROWVAL"); // Value for grown mask 38 38 39 bool smoothSuspect = psMetadataLookupBool(&mdok, config->arguments, "MASK.SMOOTH.SUSPECT"); // Radius to grow mask 40 float smoothScale = psMetadataLookupF32(&mdok, config->arguments, "MASK.SMOOTH.SCALE"); // Radius to grow mask 41 39 42 psStats *statistics = psStatsAlloc(meanStat | stdevStat); // Statistics for background 40 43 … … 42 45 pmChip *outChip = pmFPAfileThisChip(config->files, view, outName); // Output chip 43 46 psFree(outName); 47 48 int numCells = 1; 49 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 } 57 } 44 58 45 59 // For each input file, get the statistics, which can be calculated at the chip or cell levels … … 58 72 pmCell *inCell; // Input cell 59 73 while ((inCell = pmFPAviewNextCell(inView, inFPA, 1))) { 74 75 // the output FPA structure carries the information about which cells to process 76 pmCell *outCell = pmFPAfileThisCell(config->files, inView, "PPMERGE.OUTPUT.MASK"); // Output cell 77 if (!outCell->process) continue; 78 60 79 pmHDU *hdu = pmHDUFromCell(inCell); // HDU for cell 61 80 if (!hdu || hdu->blankPHU) { … … 99 118 } 100 119 101 pmCell *outCell = pmFPAfileThisCell(config->files, inView, "PPMERGE.OUTPUT.MASK"); // Output cell102 120 pmReadout *outRO = NULL; // Output readout 103 121 if (outCell->readouts && outCell->readouts->n == 1) { … … 111 129 int numCols = readout->image->numCols, numRows = readout->image->numRows; // Image size 112 130 int numPix = numCols * numRows; // Number of pixels 113 int numCells = chipStats ? readout->parent->parent->cells->n : 1; // Number of cells114 131 int num = PS_MIN(numPix, sample / numCells); // Number of values to add 115 132 if (!chipStats) { … … 166 183 inView->cell = -1; 167 184 while ((inCell = pmFPAviewNextCell(inView, inFPA, 1))) { 185 186 // the output FPA structure carries the information about which cells to process 187 pmCell *outCell = pmFPAfileThisCell(config->files, inView, "PPMERGE.OUTPUT.MASK"); // Output cell 188 if (!outCell->process) continue; 189 168 190 pmHDU *hdu = pmHDUFromCell(inCell); // HDU for cell 169 191 if (!hdu || hdu->blankPHU) { … … 206 228 *outView = *view; 207 229 while ((outCell = pmFPAviewNextCell(outView, outFPA, 1))) { 230 231 // skipp inactive cells 232 if (!outCell->process) continue; 233 208 234 pmHDU *hdu = pmHDUFromCell(outCell); // HDU for cell 209 235 if (!hdu || hdu->blankPHU) { … … 216 242 assert(outCell->readouts && outCell->readouts->n == 1); 217 243 pmReadout *outRO = outCell->readouts->data[0]; // Output readout 244 245 if (smoothSuspect) { 246 // XXX test output of suspect pixel image 247 psImage *suspects = psMetadataLookupPtr(NULL, outRO->analysis, PM_MASK_ANALYSIS_SUSPECT); // Suspect img 248 assert (suspects); 249 psImageSmooth (suspects, smoothScale, 3); // extend smoothing region to 3-sigma 250 } 251 218 252 if (!pmMaskIdentifyBadPixels(outRO, maskVal, maskBad, maskMode)) { 219 253 psError(PS_ERR_UNKNOWN, false, "Unable to mask bad pixels"); … … 359 393 pmChip *outChip; // Chip of interest 360 394 while ((outChip = pmFPAviewNextChip(view, outFPA, 1))) { 395 396 if (!outChip->process) continue; 397 361 398 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 362 399 goto PPMERGE_MASK_ERROR; … … 370 407 } 371 408 372 psList *inChips = psListAlloc(NULL); 373 for (int i=0; i < numFiles; i++) { 374 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT", i); // Input file 375 pmChip *chip = pmFPAviewThisChip(view, file->fpa); 376 psListAdd(inChips, PS_LIST_TAIL, chip); 377 } 378 if (!pmConceptsAverageChips(outChip, inChips, true)) { 379 psError(PS_ERR_UNKNOWN, false, "Unable to average Chip concepts."); 380 psFree(inChips); 381 goto PPMERGE_MASK_ERROR; 382 } 383 psFree(inChips); 409 if (outChip->data_exists) { 410 psList *inChips = psListAlloc(NULL); 411 for (int i=0; i < numFiles; i++) { 412 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT", i); // Input file 413 pmChip *chip = pmFPAviewThisChip(view, file->fpa); 414 psListAdd(inChips, PS_LIST_TAIL, chip); 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 } 384 423 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { 385 424 goto PPMERGE_MASK_ERROR;
Note:
See TracChangeset
for help on using the changeset viewer.
