Changeset 25027 for branches/pap/ppMerge/src/ppMergeLoop.c
- Timestamp:
- Aug 7, 2009, 4:08:25 PM (17 years ago)
- Location:
- branches/pap
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ppMerge/src/ppMergeLoop.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/pap
- Property svn:mergeinfo changed
-
branches/pap/ppMerge/src/ppMergeLoop.c
r23609 r25027 36 36 bool mdok; ///< Status of MD lookup 37 37 bool haveMasks = psMetadataLookupBool(&mdok, arguments, "INPUTS.MASKS"); // Do we have masks? 38 bool useMasks = psMetadataLookupBool(&mdok, arguments, "INPUTS.MASKS.USE"); // Do we have masks? 38 39 bool haveVariances = psMetadataLookupBool(&mdok, arguments, "INPUTS.VARIANCES"); // Do we have variances? 39 40 … … 64 65 int fringeSmoothX = psMetadataLookupS32(NULL, arguments, "FRINGE.XSMOOTH"); // Smoothing regions in x 65 66 int fringeSmoothY = psMetadataLookupS32(NULL, arguments, "FRINGE.YSMOOTH"); // Smoothing regions in y 67 bool fringeSmooth = psMetadataLookupBool(NULL, arguments, "FRINGE.SMOOTH"); // Smooth the output image? 68 float fringeSmoothSigma = psMetadataLookupF32(NULL, arguments, "FRINGE.SMOOTH.SIGMA"); // Smooth the output image? 66 69 67 70 // set the mask and mark bit values based on the named masks … … 73 76 74 77 pmCombineParams *combination = pmCombineParamsAlloc(combineStat); ///< Combination parameters 75 combination->maskVal = maskVal;78 combination->maskVal = useMasks ? maskVal : 0; 76 79 combination->blank = pmConfigMaskGet("BLANK", config); 77 80 combination->nKeep = nKeep; … … 93 96 psVector *scales = NULL, *zeros = NULL; ///< Scale and zeroes for combination 94 97 psArray *shutters = NULL; ///< Shutter correction data 98 psImage *zeroSet = NULL; 95 99 switch (type) { 96 100 case PPMERGE_TYPE_FRINGE: 97 zero s= psMetadataLookupPtr(NULL, arguments, "ZEROS");98 if (!zero s) {101 zeroSet = psMetadataLookupPtr(NULL, arguments, "ZEROS"); 102 if (!zeroSet) { 99 103 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find ZEROS"); 100 104 goto ERROR; 101 105 } 106 // the zeros vector is passed to pmReadoutCombine for each set of inputs per cell 107 zeros = psVectorAlloc(zeroSet->numRows, PS_TYPE_F32); 102 108 // Flow through 103 109 case PPMERGE_TYPE_FLAT: … … 139 145 pmFPA *outFPA = output->fpa; ///< Output FPA 140 146 pmHDU *lastHDU = NULL; // Last HDU that was updated 147 141 148 int cellNum = 0; ///< Index of cell 142 149 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { … … 145 152 pmChip *outChip; ///< Chip of interest 146 153 while ((outChip = pmFPAviewNextChip(view, outFPA, 1))) { 154 if (!outChip->process || !outChip->file_exists) { 155 continue; 156 } 147 157 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 148 158 goto ERROR; 149 159 } 150 160 pmCell *outCell; ///< Cell of interest 161 162 // XXX TEST : force a single loop 163 // outCell = pmFPAviewNextCell(view, outFPA, 1); { 164 151 165 while ((outCell = pmFPAviewNextCell(view, outFPA, 1))) { 166 if (!outCell->process || !outCell->file_exists) { 167 continue; 168 } 152 169 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 153 170 goto ERROR; … … 189 206 } 190 207 208 if (zeroSet) { 209 for (int i = 0; i < zeroSet->numRows; i++) { 210 zeros->data.F32[i] = zeroSet->data.F32[i][cellNum]; 211 } 212 } 213 214 int rows = psMetadataLookupS32(NULL, config->arguments, "ROWS"); // Number of rows to read per chunk 215 if (!rows && nThreads) { 216 psError(PS_ERR_UNKNOWN, false, "Invalid combination of threads > 0 and ROWS == 0 (ie, multiple threads working on the full array...)"); 217 goto ERROR; 218 } 219 191 220 ppMergeFileGroup *fileGroup = NULL; 192 221 psArray *fileGroups = psArrayAlloc(nThreads + 1); … … 198 227 pmFPAfile *input = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT", j); 199 228 pmCell *inCell = pmFPAviewThisCell(view, input->fpa); ///< Input cell 200 readouts->data[j] = pmReadoutAlloc(inCell); 229 pmReadout *readout = pmReadoutAlloc(inCell); 230 readout->process = true; // until proven otherwise, attempt to process this readout 231 readouts->data[j] = readout; 201 232 } 202 233 … … 232 263 psAssert (fileGroups->n > 0, "no valid file groups defined"); 233 264 fileGroup = fileGroups->data[0]; 234 if (!pmShutterCorrectionGeneratePrepare(outRO, pattern, fileGroup->readouts, maskVal)) {265 if (!pmShutterCorrectionGeneratePrepare(outRO, pattern, fileGroup->readouts, combination->maskVal)) { 235 266 goto ERROR; 236 267 } … … 330 361 331 362 psFree(fileGroups); 363 psFree(zeros); 332 364 333 365 // XXX eventually need to keep both the shutter and the pattern, as we do with dark … … 392 424 // Put the new readout into the cell after the existing readouts. 393 425 if (type == PPMERGE_TYPE_FRINGE && outRO) { 394 pmFringeRegions *regions = pmFringeRegionsAlloc(fringeNum, fringeSize, fringeSize, 395 fringeSmoothX, fringeSmoothY); 426 if (fringeSmooth) { 427 if (outRO->mask) { 428 psImage *smoothed = psImageSmoothMask (NULL, outRO->image, outRO->mask, maskVal, fringeSmoothSigma, 3, 0.2); 429 psFree (outRO->image); 430 outRO->image = smoothed; 431 } else { 432 psImageSmooth (outRO->image, fringeSmoothSigma, 3); 433 } 434 } 435 436 pmFringeRegions *regions = pmFringeRegionsAlloc(fringeNum, fringeSize, fringeSize, fringeSmoothX, fringeSmoothY); 396 437 pmFringeStats *fringe = pmFringeStatsMeasure(regions, outRO, maskVal); 397 438 psFree(regions); … … 405 446 fringes->data[0] = fringe; 406 447 407 pmFringesFormat(outCell, NULL, fringes); 448 // XXX replaced this : pmFringesFormat(outCell, NULL, fringes); 449 if (!psMetadataAdd(outCell->analysis, PS_LIST_TAIL, "FRINGE.MEASUREMENTS", PS_DATA_ARRAY, "Fringes", fringes)) { 450 psError(PS_ERR_UNKNOWN, false, "Unable to add fringe to analysis metadata\n"); 451 goto ERROR; 452 } 408 453 psFree(fringes); // Drop reference 409 454 } … … 426 471 char *cteMaskName = psMetadataLookupStr (&mdok, config->arguments, "MASK.SET.VALUE"); 427 472 psImageMaskType cteMaskValue = pmConfigMaskGet(cteMaskName, config); 473 474 if (0) { 475 psFits *fits = NULL; 476 fits = psFitsOpen ("combine.fits", "w"); 477 psFitsWriteImage (fits, NULL, outRO->image, 0, NULL); 478 psFitsClose (fits); 479 480 fits = psFitsOpen ("inmask.fits", "w"); 481 psFitsWriteImage (fits, NULL, outRO->mask, 0, NULL); 482 psFitsClose (fits); 483 } 428 484 429 485 psF32 **outputImage = outRO->image->data.F32; … … 436 492 } 437 493 } 494 495 if (0) { 496 psFits *fits = NULL; 497 fits = psFitsOpen ("otmask.fits", "w"); 498 psFitsWriteImage (fits, NULL, outRO->mask, 0, NULL); 499 psFitsClose (fits); 500 } 501 438 502 } 439 503
Note:
See TracChangeset
for help on using the changeset viewer.
