Changeset 25769
- Timestamp:
- Oct 5, 2009, 1:39:21 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/ppMerge/src/ppMergeLoop.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppMerge/src/ppMergeLoop.c
r24908 r25769 104 104 goto ERROR; 105 105 } 106 // the zeros vector is passed to pmReadoutCombine for each set of inputs per cell107 zeros = psVectorAlloc(zeroSet->numRows, PS_TYPE_F32);106 // the zeros vector is passed to pmReadoutCombine for each set of inputs per cell 107 zeros = psVectorAlloc(zeroSet->numRows, PS_TYPE_F32); 108 108 // Flow through 109 109 case PPMERGE_TYPE_FLAT: … … 150 150 goto ERROR; 151 151 } 152 153 154 // Average concepts across inputs 155 { 156 psList *inFPAs = psListAlloc(NULL); ///< List of FPAs 157 for (int i = 0; i < numFiles; i++) { 158 pmFPAfile *input = inputs->data[i]; ///< Input file 159 psListAdd(inFPAs, PS_LIST_TAIL, input->fpa); 160 } 161 if (!pmConceptsAverageFPAs(output->fpa, inFPAs)) { 162 psError(PS_ERR_UNKNOWN, false, "Unable to average FPA concepts."); 163 psFree(inFPAs); 164 goto ERROR; 165 } 166 psFree(inFPAs); 167 } 168 152 169 pmChip *outChip; ///< Chip of interest 153 170 while ((outChip = pmFPAviewNextChip(view, outFPA, 1))) { … … 158 175 goto ERROR; 159 176 } 177 178 // Average concepts across inputs 179 { 180 psList *inChips = psListAlloc(NULL); 181 for (int i=0; i < numFiles; i++) { 182 pmChip *chip = pmFPAviewThisChip(view, ((pmFPAfile *)inputs->data[i])->fpa); 183 psListAdd(inChips, PS_LIST_TAIL, chip); 184 } 185 if (!pmConceptsAverageChips(outChip, inChips, true)) { 186 psError(PS_ERR_UNKNOWN, false, "Unable to average Chip concepts."); 187 psFree(inChips); 188 goto ERROR; 189 } 190 psFree(inChips); 191 } 192 160 193 pmCell *outCell; ///< Cell of interest 161 194 162 // XXX TEST : force a single loop195 // XXX TEST : force a single loop 163 196 // outCell = pmFPAviewNextCell(view, outFPA, 1); { 164 197 165 198 while ((outCell = pmFPAviewNextCell(view, outFPA, 1))) { 166 if (!outCell->process || !outCell->file_exists) {167 continue;168 }199 if (!outCell->process || !outCell->file_exists) { 200 continue; 201 } 169 202 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 170 203 goto ERROR; … … 206 239 } 207 240 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 chunk215 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 }241 if (zeroSet) { 242 for (int i = 0; i < zeroSet->numRows; i++) { 243 zeros->data.F32[i] = zeroSet->data.F32[i][cellNum]; 244 } 245 } 246 247 int rows = psMetadataLookupS32(NULL, config->arguments, "ROWS"); // Number of rows to read per chunk 248 if (!rows && nThreads) { 249 psError(PS_ERR_UNKNOWN, false, "Invalid combination of threads > 0 and ROWS == 0 (ie, multiple threads working on the full array...)"); 250 goto ERROR; 251 } 219 252 220 253 ppMergeFileGroup *fileGroup = NULL; … … 227 260 pmFPAfile *input = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT", j); 228 261 pmCell *inCell = pmFPAviewThisCell(view, input->fpa); ///< Input cell 229 pmReadout *readout = pmReadoutAlloc(inCell);230 readout->process = true; // until proven otherwise, attempt to process this readout262 pmReadout *readout = pmReadoutAlloc(inCell); 263 readout->process = true; // until proven otherwise, attempt to process this readout 231 264 readouts->data[j] = readout; 232 265 } … … 361 394 362 395 psFree(fileGroups); 363 psFree(zeros);396 psFree(zeros); 364 397 365 398 // XXX eventually need to keep both the shutter and the pattern, as we do with dark … … 424 457 // Put the new readout into the cell after the existing readouts. 425 458 if (type == PPMERGE_TYPE_FRINGE && outRO) { 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 }459 if (fringeSmooth) { 460 if (outRO->mask) { 461 psImage *smoothed = psImageSmoothMask (NULL, outRO->image, outRO->mask, maskVal, fringeSmoothSigma, 3, 0.2); 462 psFree (outRO->image); 463 outRO->image = smoothed; 464 } else { 465 psImageSmooth (outRO->image, fringeSmoothSigma, 3); 466 } 467 } 435 468 436 469 pmFringeRegions *regions = pmFringeRegionsAlloc(fringeNum, fringeSize, fringeSize, fringeSmoothX, fringeSmoothY); … … 447 480 448 481 // 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 }482 if (!psMetadataAdd(outCell->analysis, PS_LIST_TAIL, "FRINGE.MEASUREMENTS", PS_DATA_ARRAY, "Fringes", fringes)) { 483 psError(PS_ERR_UNKNOWN, false, "Unable to add fringe to analysis metadata\n"); 484 goto ERROR; 485 } 453 486 psFree(fringes); // Drop reference 454 487 } … … 472 505 psImageMaskType cteMaskValue = pmConfigMaskGet(cteMaskName, config); 473 506 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 }507 if (0) { 508 psFits *fits = NULL; 509 fits = psFitsOpen ("combine.fits", "w"); 510 psFitsWriteImage (fits, NULL, outRO->image, 0, NULL); 511 psFitsClose (fits); 512 513 fits = psFitsOpen ("inmask.fits", "w"); 514 psFitsWriteImage (fits, NULL, outRO->mask, 0, NULL); 515 psFitsClose (fits); 516 } 484 517 485 518 psF32 **outputImage = outRO->image->data.F32; … … 493 526 } 494 527 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 }528 if (0) { 529 psFits *fits = NULL; 530 fits = psFitsOpen ("otmask.fits", "w"); 531 psFitsWriteImage (fits, NULL, outRO->mask, 0, NULL); 532 psFitsClose (fits); 533 } 501 534 502 535 } … … 510 543 } 511 544 512 if (outChip->data_exists) {513 psList *inChips = psListAlloc(NULL);514 for (int i=0; i < numFiles; i++) {515 pmChip *chip = pmFPAviewThisChip(view, ((pmFPAfile *)inputs->data[i])->fpa);516 psListAdd(inChips, PS_LIST_TAIL, chip);517 }518 if (!pmConceptsAverageChips(outChip, inChips, true)) {519 psError(PS_ERR_UNKNOWN, false, "Unable to average Chip concepts.");520 psFree(inChips);521 goto ERROR;522 }523 psFree(inChips);524 }525 545 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { 526 546 goto ERROR; 527 547 } 528 548 } 529 530 // Get list of FPAs for concepts averaging531 psList *inFPAs = psListAlloc(NULL); ///< List of FPAs532 for (int i = 0; i < numFiles; i++) {533 pmFPAfile *input = inputs->data[i]; ///< Input file534 psListAdd(inFPAs, PS_LIST_TAIL, input->fpa);535 }536 if (!pmConceptsAverageFPAs(output->fpa, inFPAs)) {537 psError(PS_ERR_UNKNOWN, false, "Unable to average FPA concepts.");538 psFree(inFPAs);539 goto ERROR;540 }541 psFree(inFPAs);542 543 549 544 550 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
Note:
See TracChangeset
for help on using the changeset viewer.
