IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 5, 2009, 4:47:00 PM (17 years ago)
Author:
Paul Price
Message:

Merging pap_branch_20090128. Resolved a small number of conflicts. Compiles, but not tested in detail.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppMerge/src/ppMergeMask.c

    r21244 r21365  
    66 *
    77 *  @author IfA
    8  *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2009-02-01 21:43:05 $
     8 *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2009-02-06 02:44:31 $
    1010 *  Copyright 2009 Institute for Astronomy, University of Hawaii
    1111 */
     
    3838    float smoothScale = psMetadataLookupF32(&mdok, config->arguments, "MASK.SMOOTH.SCALE"); ///< Radius to grow mask
    3939
    40     psImageMaskType markVal;
    41     psImageMaskType maskValRaw;
    42     if (!pmConfigMaskSetBits (&maskValRaw, &markVal, config)) {
    43         psError (PS_ERR_UNKNOWN, true, "Unable to define the mask bit values");
    44         return false;
     40    psImageMaskType markVal, maskValRaw;
     41    if (!pmConfigMaskSetBits(&maskValRaw, &markVal, config)) {
     42        psError(PS_ERR_UNKNOWN, true, "Unable to define the mask bit values");
     43        return false;
    4544    }
    4645
     
    4847    psImageMaskType maskValOut = pmConfigMaskGet (maskOutName, config);
    4948    if (!maskValOut) {
    50         psError (PS_ERR_UNKNOWN, true, "Undefined output mask bit value");
    51         return false;
    52     }
    53    
    54     psStats *statistics = psStatsAlloc(meanStat | stdevStat); ///< Statistics for background
     49        psError (PS_ERR_UNKNOWN, true, "Undefined output mask bit value");
     50        return false;
     51    }
     52
     53    psStats *statistics = psStatsAlloc(meanStat | stdevStat); // Statistics for background
    5554
    5655    psString outName = ppMergeOutputFile(config); ///< Name of output file
    5756    pmChip *outChip = pmFPAfileThisChip(config->files, view, outName); ///< Output chip
    5857    psFree(outName);
    59    
     58
    6059    int numCells = 1;
    6160    if (chipStats) {
    62         // count the number of active cells for this chip:
    63         numCells = 0;
    64         for (int i = 0; i < outChip->cells->n; i++) {
    65             pmCell *cell = outChip->cells->data[i];
    66             if (!cell->process) continue;
    67             numCells ++;
    68         }
     61        // count the number of active cells for this chip:
     62        numCells = 0;
     63        for (int i = 0; i < outChip->cells->n; i++) {
     64            pmCell *cell = outChip->cells->data[i];
     65            if (!cell->process) continue;
     66            numCells ++;
     67        }
    6968    }
    7069
     
    8584        while ((inCell = pmFPAviewNextCell(inView, inFPA, 1))) {
    8685
    87             // the output FPA structure carries the information about which cells to process
    88             pmCell *outCell = pmFPAfileThisCell(config->files, inView, "PPMERGE.OUTPUT.MASK"); ///< Output cell
    89             if (!outCell->process) continue;
     86            // the output FPA structure carries the information about which cells to process
     87            pmCell *outCell = pmFPAfileThisCell(config->files, inView, "PPMERGE.OUTPUT.MASK"); // Output cell
     88            if (!outCell->process) continue;
    9089
    9190            pmHDU *hdu = pmHDUFromCell(inCell); ///< HDU for cell
     
    150149                int y = pixel / numCols;
    151150                if (mask && (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskValRaw)) continue;
    152                 if (outMask && (outMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskValOut)) continue;
    153                 if (!isfinite(image->data.F32[y][x])) continue;
     151                if (outMask && (outMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskValOut)) continue;
     152                if (!isfinite(image->data.F32[y][x])) continue;
    154153
    155154                values->data.F32[valueIndex++] = image->data.F32[y][x];
     
    165164                }
    166165
    167                 float mean = psStatsGetValue(statistics, meanStat);
    168                 float stdev = psStatsGetValue(statistics, stdevStat);
    169 
    170                 // this function increments the count for each suspect pixel in each input plane
    171                 // maskValRaw is used to test for valid input pixels
     166                float mean = psStatsGetValue(statistics, meanStat);
     167                float stdev = psStatsGetValue(statistics, stdevStat);
     168
     169                // this function increments the count for each suspect pixel in each input plane
     170                // maskValRaw is used to test for valid input pixels
    172171                if (!pmMaskFlagSuspectPixels(outRO, readout, mean, stdev, maskSuspect, maskValRaw)) {
    173172                    psError(PS_ERR_UNKNOWN, false, "Unable to find suspect values in file %d", i);
     
    197196            inView->cell = -1;
    198197            while ((inCell = pmFPAviewNextCell(inView, inFPA, 1))) {
    199 
    200                 // the output FPA structure carries the information about which cells to process
    201                 pmCell *outCell = pmFPAfileThisCell(config->files, inView, "PPMERGE.OUTPUT.MASK"); ///< Output cell
    202                 if (!outCell->process) continue;
     198                // the output FPA structure carries the information about which cells to process
     199                pmCell *outCell = pmFPAfileThisCell(config->files, inView, "PPMERGE.OUTPUT.MASK"); // Output cell
     200                if (!outCell->process) continue;
    203201
    204202                pmHDU *hdu = pmHDUFromCell(inCell); ///< HDU for cell
     
    210208                pmReadout *outRO = pmFPAfileThisReadout(config->files, inView, "PPMERGE.OUTPUT.MASK");
    211209
    212                 float mean = psStatsGetValue(statistics, meanStat);
    213                 float stdev = psStatsGetValue(statistics, stdevStat);
    214 
    215                 if (!pmMaskFlagSuspectPixels(outRO, readout, mean, stdev, maskSuspect, maskValRaw)) {
     210                float mean = psStatsGetValue(statistics, meanStat);
     211                float stdev = psStatsGetValue(statistics, stdevStat);
     212
     213                if (!pmMaskFlagSuspectPixels(outRO, readout, mean, stdev, maskSuspect, maskValRaw)) {
    216214                    psError(PS_ERR_UNKNOWN, false, "Unable to find suspect values in file %d", i);
    217215                    goto MERGE_MASK_ERROR;
     
    243241    while ((outCell = pmFPAviewNextCell(outView, outFPA, 1))) {
    244242
    245         // skip inactive cells
    246         if (!outCell->process) continue;
     243        // skip inactive cells
     244        if (!outCell->process) continue;
    247245
    248246        pmHDU *hdu = pmHDUFromCell(outCell); ///< HDU for cell
     
    254252        pmReadout *outRO = outCell->readouts->data[0]; ///< Output readout
    255253
    256         if (smoothSuspect) {
    257             // XXX test output of suspect pixel image
    258             psImage *suspects = psMetadataLookupPtr(NULL, outRO->analysis, PM_MASK_ANALYSIS_SUSPECT); ///< Suspect img
    259             assert (suspects);
    260             psImageSmooth (suspects, smoothScale, 3); ///< extend smoothing region to 3-sigma
    261         }
    262 
    263         // set the bad pixels to the value 'maskVal'
     254        if (smoothSuspect) {
     255            // XXX test output of suspect pixel image
     256            psImage *suspects = psMetadataLookupPtr(NULL, outRO->analysis, PM_MASK_ANALYSIS_SUSPECT); // Suspect img
     257            assert (suspects);
     258            psImageSmooth (suspects, smoothScale, 3); // extend smoothing region to 3-sigma
     259        }
     260
     261        // set the bad pixels to the value 'maskVal'
    264262        if (!pmMaskIdentifyBadPixels(outRO, maskValOut, maskBad, maskMode)) {
    265263            psError(PS_ERR_UNKNOWN, false, "Unable to mask bad pixels");
     
    352350    assert(config);
    353351
    354     bool mdok;                          ///< Status of MD lookup
    355     int numFiles = psMetadataLookupS32(NULL, config->arguments, "INPUTS.NUM"); ///< Number of inputs
    356     bool haveMasks = psMetadataLookupBool(&mdok, config->arguments, "INPUTS.MASKS"); ///< Do we have masks?
    357     bool haveWeights = psMetadataLookupBool(&mdok, config->arguments, "INPUTS.WEIGHTS"); ///< Do we have weights?
    358     int iter = psMetadataLookupS32(NULL, config->arguments, "ITER"); ///< Number of rejection iterations
     352    bool mdok;                          // Status of MD lookup
     353    int numFiles = psMetadataLookupS32(NULL, config->arguments, "INPUTS.NUM"); // Number of inputs
     354    bool haveMasks = psMetadataLookupBool(&mdok, config->arguments, "INPUTS.MASKS"); // Do we have masks?
     355    bool haveVariances = psMetadataLookupBool(&mdok, config->arguments, "INPUTS.VARIANCES"); // Got variances?
     356    int iter = psMetadataLookupS32(NULL, config->arguments, "ITER"); // Number of rejection iterations
    359357
    360358    PS_ASSERT_INT_POSITIVE(iter, false);
     
    375373        psFree(masks);
    376374    }
    377     if (haveWeights) {
    378         psArray *weights = ppMergeFileDataLevel(config, "PPMERGE.INPUT.WEIGHT", PM_FPA_LEVEL_READOUT);
    379         psFree(weights);
     375    if (haveVariances) {
     376        psArray *variances = ppMergeFileDataLevel(config, "PPMERGE.INPUT.VARIANCE", PM_FPA_LEVEL_READOUT);
     377        psFree(variances);
    380378    }
    381379
     
    417415        }
    418416
    419         if (outChip->data_exists) {
    420             psList *inChips = psListAlloc(NULL);
    421             for (int i=0; i < numFiles; i++) {
    422                 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT", i); ///< Input file
    423                 pmChip *chip = pmFPAviewThisChip(view, file->fpa);
    424                 psListAdd(inChips, PS_LIST_TAIL, chip);
    425             }
    426 
    427             // XXX I need to call pmConfigMaskWriteHeader for the PHU somewhere, after it is created!
    428 
    429             if (!pmConceptsAverageChips(outChip, inChips, true)) {
    430                 psError(PS_ERR_UNKNOWN, false, "Unable to average Chip concepts.");
    431                 psFree(inChips);
    432                 goto PPMERGE_MASK_ERROR;
    433             }
    434             psFree(inChips);
    435         }
     417        if (outChip->data_exists) {
     418            psList *inChips = psListAlloc(NULL);
     419            for (int i=0; i < numFiles; i++) {
     420                pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT", i); // Input file
     421                pmChip *chip = pmFPAviewThisChip(view, file->fpa);
     422                psListAdd(inChips, PS_LIST_TAIL, chip);
     423            }
     424
     425            // XXX I need to call pmConfigMaskWriteHeader for the PHU somewhere, after it is created!
     426
     427            if (!pmConceptsAverageChips(outChip, inChips, true)) {
     428                psError(PS_ERR_UNKNOWN, false, "Unable to average Chip concepts.");
     429                psFree(inChips);
     430                goto PPMERGE_MASK_ERROR;
     431            }
     432            psFree(inChips);
     433        }
    436434        if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
    437435            goto PPMERGE_MASK_ERROR;
Note: See TracChangeset for help on using the changeset viewer.