IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 7, 2009, 4:08:25 PM (17 years ago)
Author:
Paul Price
Message:

Merging trunk (r25026) to get up-to-date on old branch.

Location:
branches/pap
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/pap

  • branches/pap/ppMerge/src/ppMergeLoop.c

    r23609 r25027  
    3636    bool mdok;                          ///< Status of MD lookup
    3737    bool haveMasks = psMetadataLookupBool(&mdok, arguments, "INPUTS.MASKS"); // Do we have masks?
     38    bool useMasks = psMetadataLookupBool(&mdok, arguments, "INPUTS.MASKS.USE"); // Do we have masks?
    3839    bool haveVariances = psMetadataLookupBool(&mdok, arguments, "INPUTS.VARIANCES"); // Do we have variances?
    3940
     
    6465    int fringeSmoothX = psMetadataLookupS32(NULL, arguments, "FRINGE.XSMOOTH"); // Smoothing regions in x
    6566    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?
    6669
    6770    // set the mask and mark bit values based on the named masks
     
    7376
    7477    pmCombineParams *combination = pmCombineParamsAlloc(combineStat); ///< Combination parameters
    75     combination->maskVal = maskVal;
     78    combination->maskVal = useMasks ? maskVal : 0;
    7679    combination->blank = pmConfigMaskGet("BLANK", config);
    7780    combination->nKeep = nKeep;
     
    9396    psVector *scales = NULL, *zeros = NULL; ///< Scale and zeroes for combination
    9497    psArray *shutters = NULL;           ///< Shutter correction data
     98    psImage *zeroSet = NULL;
    9599    switch (type) {
    96100      case PPMERGE_TYPE_FRINGE:
    97         zeros = psMetadataLookupPtr(NULL, arguments, "ZEROS");
    98         if (!zeros) {
     101        zeroSet = psMetadataLookupPtr(NULL, arguments, "ZEROS");
     102        if (!zeroSet) {
    99103            psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find ZEROS");
    100104            goto ERROR;
    101105        }
     106        // the zeros vector is passed to pmReadoutCombine for each set of inputs per cell
     107        zeros = psVectorAlloc(zeroSet->numRows, PS_TYPE_F32);
    102108        // Flow through
    103109      case PPMERGE_TYPE_FLAT:
     
    139145    pmFPA *outFPA = output->fpa;        ///< Output FPA
    140146    pmHDU *lastHDU = NULL;              // Last HDU that was updated
     147
    141148    int cellNum = 0;                    ///< Index of cell
    142149    if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
     
    145152    pmChip *outChip;                    ///< Chip of interest
    146153    while ((outChip = pmFPAviewNextChip(view, outFPA, 1))) {
     154        if (!outChip->process || !outChip->file_exists) {
     155            continue;
     156        }
    147157        if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
    148158            goto ERROR;
    149159        }
    150160        pmCell *outCell;                ///< Cell of interest
     161
     162        // XXX TEST : force a single loop
     163        // outCell = pmFPAviewNextCell(view, outFPA, 1); {
     164
    151165        while ((outCell = pmFPAviewNextCell(view, outFPA, 1))) {
     166            if (!outCell->process || !outCell->file_exists) {
     167                continue;
     168            }
    152169            if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
    153170                goto ERROR;
     
    189206            }
    190207
     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
    191220            ppMergeFileGroup *fileGroup = NULL;
    192221            psArray *fileGroups = psArrayAlloc(nThreads + 1);
     
    198227                    pmFPAfile *input = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT", j);
    199228                    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;
    201232                }
    202233
     
    232263                psAssert (fileGroups->n > 0, "no valid file groups defined");
    233264                fileGroup = fileGroups->data[0];
    234                 if (!pmShutterCorrectionGeneratePrepare(outRO, pattern, fileGroup->readouts, maskVal)) {
     265                if (!pmShutterCorrectionGeneratePrepare(outRO, pattern, fileGroup->readouts, combination->maskVal)) {
    235266                    goto ERROR;
    236267                }
     
    330361
    331362            psFree(fileGroups);
     363            psFree(zeros);
    332364
    333365            // XXX eventually need to keep both the shutter and the pattern, as we do with dark
     
    392424            // Put the new readout into the cell after the existing readouts.
    393425            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);
    396437                pmFringeStats *fringe = pmFringeStatsMeasure(regions, outRO, maskVal);
    397438                psFree(regions);
     
    405446                fringes->data[0] = fringe;
    406447
    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                }
    408453                psFree(fringes);        // Drop reference
    409454            }
     
    426471                char *cteMaskName = psMetadataLookupStr (&mdok, config->arguments, "MASK.SET.VALUE");
    427472                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                }
    428484
    429485                psF32 **outputImage = outRO->image->data.F32;
     
    436492                    }
    437493                }
     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
    438502            }
    439503
Note: See TracChangeset for help on using the changeset viewer.