IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 18, 2009, 10:23:28 AM (17 years ago)
Author:
eugene
Message:

updated vysos branch from trunk

Location:
branches/eam_branches/20090820
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20090820

  • branches/eam_branches/20090820/ppMerge/src/ppMergeLoop.c

    r24908 r25870  
    104104            goto ERROR;
    105105        }
    106         // the zeros vector is passed to pmReadoutCombine for each set of inputs per cell
    107         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);
    108108        // Flow through
    109109      case PPMERGE_TYPE_FLAT:
     
    150150        goto ERROR;
    151151    }
     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
    152169    pmChip *outChip;                    ///< Chip of interest
    153170    while ((outChip = pmFPAviewNextChip(view, outFPA, 1))) {
     
    158175            goto ERROR;
    159176        }
     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
    160193        pmCell *outCell;                ///< Cell of interest
    161194
    162         // XXX TEST : force a single loop
     195        // XXX TEST : force a single loop
    163196        // outCell = pmFPAviewNextCell(view, outFPA, 1); {
    164197
    165198        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            }
    169202            if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
    170203                goto ERROR;
     
    206239            }
    207240
    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             }
     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            }
    219252
    220253            ppMergeFileGroup *fileGroup = NULL;
     
    227260                    pmFPAfile *input = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT", j);
    228261                    pmCell *inCell = pmFPAviewThisCell(view, input->fpa); ///< Input cell
    229                     pmReadout *readout = pmReadoutAlloc(inCell);
    230                     readout->process = true; // until proven otherwise, attempt to process this readout
     262                    pmReadout *readout = pmReadoutAlloc(inCell);
     263                    readout->process = true; // until proven otherwise, attempt to process this readout
    231264                    readouts->data[j] = readout;
    232265                }
     
    361394
    362395            psFree(fileGroups);
    363             psFree(zeros);
     396            psFree(zeros);
    364397
    365398            // XXX eventually need to keep both the shutter and the pattern, as we do with dark
     
    424457            // Put the new readout into the cell after the existing readouts.
    425458            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                }
    435468
    436469                pmFringeRegions *regions = pmFringeRegionsAlloc(fringeNum, fringeSize, fringeSize, fringeSmoothX, fringeSmoothY);
     
    447480
    448481                // 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                }
    453486                psFree(fringes);        // Drop reference
    454487            }
     
    472505                psImageMaskType cteMaskValue = pmConfigMaskGet(cteMaskName, config);
    473506
    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                }
    484517
    485518                psF32 **outputImage = outRO->image->data.F32;
     
    493526                }
    494527
    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                }
    501534
    502535            }
     
    510543        }
    511544
    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         }
    525545        if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
    526546            goto ERROR;
    527547        }
    528548    }
    529 
    530     // Get list of FPAs for concepts averaging
    531     psList *inFPAs = psListAlloc(NULL); ///< List of FPAs
    532     for (int i = 0; i < numFiles; i++) {
    533         pmFPAfile *input = inputs->data[i]; ///< Input file
    534         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 
    543549
    544550    if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
Note: See TracChangeset for help on using the changeset viewer.