Changeset 27839 for branches/simmosaic_branches/ppMerge/src/ppMergeLoop.c
- Timestamp:
- May 3, 2010, 8:45:22 AM (16 years ago)
- Location:
- branches/simmosaic_branches
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ppMerge/src/ppMergeLoop.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/simmosaic_branches
- Property svn:mergeinfo changed
-
branches/simmosaic_branches/ppMerge/src/ppMergeLoop.c
r24837 r27839 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))) { 171 if (!outChip->process || !outChip->file_exists) { 172 continue; 173 } 154 174 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 155 175 goto ERROR; 156 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 157 193 pmCell *outCell; ///< Cell of interest 158 194 159 // XXX TEST : force a single loop195 // XXX TEST : force a single loop 160 196 // outCell = pmFPAviewNextCell(view, outFPA, 1); { 161 197 162 198 while ((outCell = pmFPAviewNextCell(view, outFPA, 1))) { 199 if (!outCell->process || !outCell->file_exists) { 200 continue; 201 } 163 202 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 164 203 goto ERROR; … … 200 239 } 201 240 202 if (zeroSet) {203 for (int i = 0; i < zeroSet->numRows; i++) {204 zeros->data.F32[i] = zeroSet->data.F32[i][cellNum];205 }206 }207 208 int rows = psMetadataLookupS32(NULL, config->arguments, "ROWS"); // Number of rows to read per chunk209 if (!rows && nThreads) {210 psError(PS_ERR_UNKNOWN, false, "Invalid combination of threads > 0 and ROWS == 0 (ie, multiple threads working on the full array...)");211 goto ERROR;212 }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 } 213 252 214 253 ppMergeFileGroup *fileGroup = NULL; … … 221 260 pmFPAfile *input = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT", j); 222 261 pmCell *inCell = pmFPAviewThisCell(view, input->fpa); ///< Input cell 223 pmReadout *readout = pmReadoutAlloc(inCell);224 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 225 264 readouts->data[j] = readout; 226 265 } … … 355 394 356 395 psFree(fileGroups); 357 psFree(zeros);396 psFree(zeros); 358 397 359 398 // XXX eventually need to keep both the shutter and the pattern, as we do with dark … … 418 457 // Put the new readout into the cell after the existing readouts. 419 458 if (type == PPMERGE_TYPE_FRINGE && outRO) { 420 if (fringeSmooth) {421 if (outRO->mask) {422 psImage *smoothed = psImageSmoothMask (NULL, outRO->image, outRO->mask, maskVal, fringeSmoothSigma, 3, 0.2);423 psFree (outRO->image);424 outRO->image = smoothed;425 } else {426 psImageSmooth (outRO->image, fringeSmoothSigma, 3);427 }428 }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 } 429 468 430 469 pmFringeRegions *regions = pmFringeRegionsAlloc(fringeNum, fringeSize, fringeSize, fringeSmoothX, fringeSmoothY); … … 441 480 442 481 // XXX replaced this : pmFringesFormat(outCell, NULL, fringes); 443 if (!psMetadataAdd(outCell->analysis, PS_LIST_TAIL, "FRINGE.MEASUREMENTS", PS_DATA_ARRAY, "Fringes", fringes)) {444 psError(PS_ERR_UNKNOWN, false, "Unable to add fringe to analysis metadata\n");445 goto ERROR;446 }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 } 447 486 psFree(fringes); // Drop reference 448 487 } … … 466 505 psImageMaskType cteMaskValue = pmConfigMaskGet(cteMaskName, config); 467 506 468 if (0) {469 psFits *fits = NULL;470 fits = psFitsOpen ("combine.fits", "w");471 psFitsWriteImage (fits, NULL, outRO->image, 0, NULL);472 psFitsClose (fits);473 474 fits = psFitsOpen ("inmask.fits", "w");475 psFitsWriteImage (fits, NULL, outRO->mask, 0, NULL);476 psFitsClose (fits);477 }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 } 478 517 479 518 psF32 **outputImage = outRO->image->data.F32; … … 487 526 } 488 527 489 if (0) {490 psFits *fits = NULL;491 fits = psFitsOpen ("otmask.fits", "w");492 psFitsWriteImage (fits, NULL, outRO->mask, 0, NULL);493 psFitsClose (fits);494 }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 } 495 534 496 535 } … … 504 543 } 505 544 506 if (outChip->data_exists) {507 psList *inChips = psListAlloc(NULL);508 for (int i=0; i < numFiles; i++) {509 pmChip *chip = pmFPAviewThisChip(view, ((pmFPAfile *)inputs->data[i])->fpa);510 psListAdd(inChips, PS_LIST_TAIL, chip);511 }512 if (!pmConceptsAverageChips(outChip, inChips, true)) {513 psError(PS_ERR_UNKNOWN, false, "Unable to average Chip concepts.");514 psFree(inChips);515 goto ERROR;516 }517 psFree(inChips);518 }519 545 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { 520 546 goto ERROR; 521 547 } 522 548 } 523 524 // Get list of FPAs for concepts averaging525 psList *inFPAs = psListAlloc(NULL); ///< List of FPAs526 for (int i = 0; i < numFiles; i++) {527 pmFPAfile *input = inputs->data[i]; ///< Input file528 psListAdd(inFPAs, PS_LIST_TAIL, input->fpa);529 }530 if (!pmConceptsAverageFPAs(output->fpa, inFPAs)) {531 psError(PS_ERR_UNKNOWN, false, "Unable to average FPA concepts.");532 psFree(inFPAs);533 goto ERROR;534 }535 psFree(inFPAs);536 537 549 538 550 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
Note:
See TracChangeset
for help on using the changeset viewer.
