IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 28, 2009, 5:24:09 PM (18 years ago)
Author:
Paul Price
Message:

Convering 'weight' to 'variance' where appropriate. Mostly just propagating changes from psModules. Fixed some mask types as well.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/pap_branch_20090128/ppMerge/src/ppMergeMask.c

    r18756 r21219  
    2626    float smoothScale = psMetadataLookupF32(&mdok, config->arguments, "MASK.SMOOTH.SCALE"); // Radius to grow mask
    2727
    28     psMaskType markVal;
    29     psMaskType maskValRaw;
    30     if (!pmConfigMaskSetBits (&maskValRaw, &markVal, config)) {
    31         psError (PS_ERR_UNKNOWN, true, "Unable to define the mask bit values");
    32         return false;
     28    psImageMaskType markVal, maskValRaw;
     29    if (!pmConfigMaskSetBits(&maskValRaw, &markVal, config)) {
     30        psError (PS_ERR_UNKNOWN, true, "Unable to define the mask bit values");
     31        return false;
    3332    }
    3433
     
    3635    psMaskType maskValOut = pmConfigMaskGet (maskOutName, config);
    3736    if (!maskValOut) {
    38         psError (PS_ERR_UNKNOWN, true, "Undefined output mask bit value");
    39         return false;
    40     }
    41    
     37        psError (PS_ERR_UNKNOWN, true, "Undefined output mask bit value");
     38        return false;
     39    }
     40
    4241    psStats *statistics = psStatsAlloc(meanStat | stdevStat); // Statistics for background
    4342
     
    4544    pmChip *outChip = pmFPAfileThisChip(config->files, view, outName); // Output chip
    4645    psFree(outName);
    47    
     46
    4847    int numCells = 1;
    4948    if (chipStats) {
    50         // count the number of active cells for this chip:
    51         numCells = 0;
    52         for (int i = 0; i < outChip->cells->n; i++) {
    53             pmCell *cell = outChip->cells->data[i];
    54             if (!cell->process) continue;
    55             numCells ++;
    56         }
     49        // count the number of active cells for this chip:
     50        numCells = 0;
     51        for (int i = 0; i < outChip->cells->n; i++) {
     52            pmCell *cell = outChip->cells->data[i];
     53            if (!cell->process) continue;
     54            numCells ++;
     55        }
    5756    }
    5857
     
    7372        while ((inCell = pmFPAviewNextCell(inView, inFPA, 1))) {
    7473
    75             // the output FPA structure carries the information about which cells to process
     74            // the output FPA structure carries the information about which cells to process
    7675            pmCell *outCell = pmFPAfileThisCell(config->files, inView, "PPMERGE.OUTPUT.MASK"); // Output cell
    77             if (!outCell->process) continue;
     76            if (!outCell->process) continue;
    7877
    7978            pmHDU *hdu = pmHDUFromCell(inCell); // HDU for cell
     
    138137                int y = pixel / numCols;
    139138                if (mask && (mask->data.PS_TYPE_MASK_DATA[y][x] & maskValRaw)) continue;
    140                 if (outMask && (outMask->data.PS_TYPE_MASK_DATA[y][x] & maskValOut)) continue;
    141                 if (!isfinite(image->data.F32[y][x])) continue;
     139                if (outMask && (outMask->data.PS_TYPE_MASK_DATA[y][x] & maskValOut)) continue;
     140                if (!isfinite(image->data.F32[y][x])) continue;
    142141
    143142                values->data.F32[valueIndex++] = image->data.F32[y][x];
     
    153152                }
    154153
    155                 float mean = psStatsGetValue(statistics, meanStat);
    156                 float stdev = psStatsGetValue(statistics, stdevStat);
    157 
    158                 // this function increments the count for each suspect pixel in each input plane
    159                 // maskValRaw is used to test for valid input pixels
     154                float mean = psStatsGetValue(statistics, meanStat);
     155                float stdev = psStatsGetValue(statistics, stdevStat);
     156
     157                // this function increments the count for each suspect pixel in each input plane
     158                // maskValRaw is used to test for valid input pixels
    160159                if (!pmMaskFlagSuspectPixels(outRO, readout, mean, stdev, maskSuspect, maskValRaw)) {
    161160                    psError(PS_ERR_UNKNOWN, false, "Unable to find suspect values in file %d", i);
     
    186185            while ((inCell = pmFPAviewNextCell(inView, inFPA, 1))) {
    187186
    188                 // the output FPA structure carries the information about which cells to process
    189                 pmCell *outCell = pmFPAfileThisCell(config->files, inView, "PPMERGE.OUTPUT.MASK"); // Output cell
    190                 if (!outCell->process) continue;
     187                // the output FPA structure carries the information about which cells to process
     188                pmCell *outCell = pmFPAfileThisCell(config->files, inView, "PPMERGE.OUTPUT.MASK"); // Output cell
     189                if (!outCell->process) continue;
    191190
    192191                pmHDU *hdu = pmHDUFromCell(inCell); // HDU for cell
     
    198197                pmReadout *outRO = pmFPAfileThisReadout(config->files, inView, "PPMERGE.OUTPUT.MASK");
    199198
    200                 float mean = psStatsGetValue(statistics, meanStat);
    201                 float stdev = psStatsGetValue(statistics, stdevStat);
    202 
    203                 if (!pmMaskFlagSuspectPixels(outRO, readout, mean, stdev, maskSuspect, maskValRaw)) {
     199                float mean = psStatsGetValue(statistics, meanStat);
     200                float stdev = psStatsGetValue(statistics, stdevStat);
     201
     202                if (!pmMaskFlagSuspectPixels(outRO, readout, mean, stdev, maskSuspect, maskValRaw)) {
    204203                    psError(PS_ERR_UNKNOWN, false, "Unable to find suspect values in file %d", i);
    205204                    goto MERGE_MASK_ERROR;
     
    231230    while ((outCell = pmFPAviewNextCell(outView, outFPA, 1))) {
    232231
    233         // skip inactive cells
    234         if (!outCell->process) continue;
     232        // skip inactive cells
     233        if (!outCell->process) continue;
    235234
    236235        pmHDU *hdu = pmHDUFromCell(outCell); // HDU for cell
     
    242241        pmReadout *outRO = outCell->readouts->data[0]; // Output readout
    243242
    244         if (smoothSuspect) {
    245             // XXX test output of suspect pixel image
    246             psImage *suspects = psMetadataLookupPtr(NULL, outRO->analysis, PM_MASK_ANALYSIS_SUSPECT); // Suspect img
    247             assert (suspects);
    248             psImageSmooth (suspects, smoothScale, 3); // extend smoothing region to 3-sigma
    249         }
    250 
    251         // set the bad pixels to the value 'maskVal'
     243        if (smoothSuspect) {
     244            // XXX test output of suspect pixel image
     245            psImage *suspects = psMetadataLookupPtr(NULL, outRO->analysis, PM_MASK_ANALYSIS_SUSPECT); // Suspect img
     246            assert (suspects);
     247            psImageSmooth (suspects, smoothScale, 3); // extend smoothing region to 3-sigma
     248        }
     249
     250        // set the bad pixels to the value 'maskVal'
    252251        if (!pmMaskIdentifyBadPixels(outRO, maskValOut, maskBad, maskMode)) {
    253252            psError(PS_ERR_UNKNOWN, false, "Unable to mask bad pixels");
     
    343342    int numFiles = psMetadataLookupS32(NULL, config->arguments, "INPUTS.NUM"); // Number of inputs
    344343    bool haveMasks = psMetadataLookupBool(&mdok, config->arguments, "INPUTS.MASKS"); // Do we have masks?
    345     bool haveWeights = psMetadataLookupBool(&mdok, config->arguments, "INPUTS.WEIGHTS"); // Do we have weights?
     344    bool haveVariances = psMetadataLookupBool(&mdok, config->arguments, "INPUTS.VARIANCES"); // Got variances?
    346345    int iter = psMetadataLookupS32(NULL, config->arguments, "ITER"); // Number of rejection iterations
    347346
     
    363362        psFree(masks);
    364363    }
    365     if (haveWeights) {
    366         psArray *weights = ppMergeFileDataLevel(config, "PPMERGE.INPUT.WEIGHT", PM_FPA_LEVEL_READOUT);
    367         psFree(weights);
     364    if (haveVariances) {
     365        psArray *variances = ppMergeFileDataLevel(config, "PPMERGE.INPUT.VARIANCE", PM_FPA_LEVEL_READOUT);
     366        psFree(variances);
    368367    }
    369368
     
    405404        }
    406405
    407         if (outChip->data_exists) {
    408             psList *inChips = psListAlloc(NULL);
    409             for (int i=0; i < numFiles; i++) {
    410                 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT", i); // Input file
    411                 pmChip *chip = pmFPAviewThisChip(view, file->fpa);
    412                 psListAdd(inChips, PS_LIST_TAIL, chip);
    413             }
    414 
    415             // XXX I need to call pmConfigMaskWriteHeader for the PHU somewhere, after it is created!
    416 
    417             if (!pmConceptsAverageChips(outChip, inChips, true)) {
    418                 psError(PS_ERR_UNKNOWN, false, "Unable to average Chip concepts.");
    419                 psFree(inChips);
    420                 goto PPMERGE_MASK_ERROR;
    421             }
    422             psFree(inChips);
    423         }
     406        if (outChip->data_exists) {
     407            psList *inChips = psListAlloc(NULL);
     408            for (int i=0; i < numFiles; i++) {
     409                pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT", i); // Input file
     410                pmChip *chip = pmFPAviewThisChip(view, file->fpa);
     411                psListAdd(inChips, PS_LIST_TAIL, chip);
     412            }
     413
     414            // XXX I need to call pmConfigMaskWriteHeader for the PHU somewhere, after it is created!
     415
     416            if (!pmConceptsAverageChips(outChip, inChips, true)) {
     417                psError(PS_ERR_UNKNOWN, false, "Unable to average Chip concepts.");
     418                psFree(inChips);
     419                goto PPMERGE_MASK_ERROR;
     420            }
     421            psFree(inChips);
     422        }
    424423        if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
    425424            goto PPMERGE_MASK_ERROR;
Note: See TracChangeset for help on using the changeset viewer.