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/ppMergeMask.c

    r23259 r25027  
    3131    int sample = psMetadataLookupS32(NULL, config->arguments, "SAMPLE"); ///< Size of sample for statistics
    3232    bool chipStats = psMetadataLookupBool(&mdok, config->arguments, "MASK.CHIPSTATS"); ///< Statistics on chip?
    33     float maskSuspect = psMetadataLookupF32(NULL, config->arguments, "MASK.SUSPECT"); ///< Threshold for suspect pixels
     33
     34    char *maskSuspectMode  = psMetadataLookupStr(NULL, config->arguments, "MASK.SUSPECT.MODE"); ///< Threshold for suspect pixels
     35    if (strcasecmp(maskSuspectMode, "SIGMA") && strcasecmp(maskSuspectMode, "VALUE")) {
     36        psError (PS_ERR_UNKNOWN, true, "Invalid choice for MASK.SUSPECT.MODE: %s\n", maskSuspectMode);
     37        return false;
     38    }
     39    float maskSuspectSigma = psMetadataLookupF32(NULL, config->arguments, "MASK.SUSPECT.SIGMA"); ///< Threshold for suspect pixels
     40    float maskSuspectMin   = psMetadataLookupF32(NULL, config->arguments, "MASK.SUSPECT.MIN"); ///< Threshold for suspect pixels
     41    float maskSuspectMax   = psMetadataLookupF32(NULL, config->arguments, "MASK.SUSPECT.MAX"); ///< Threshold for suspect pixels
     42
    3443    float maskBad = psMetadataLookupF32(NULL, config->arguments, "MASK.BAD"); ///< Threshold for bad pixels
    3544    pmMaskIdentifyMode maskMode = psMetadataLookupS32(NULL, config->arguments, "MASK.MODE"); ///< Mode for identifying bad pixels
     
    111120            }
    112121
    113             if (!ppMergeFileOpenInput(config, view, i)) {
     122            if (!ppMergeFileOpenInput(config, inView, i)) {
    114123                psError(PS_ERR_UNKNOWN, false, "Unable to open file %d", i);
    115124                psFree(inView);
     
    154163                valueIndex = 0;
    155164            }
    156             for (int i = 0; i < num; i++) {
    157                 int pixel = numPix * psRandomUniform(rng);
    158                 int x = pixel % numCols;
    159                 int y = pixel / numCols;
    160                 if (mask && (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskValRaw)) continue;
    161                 if (outMask && (outMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskValOut)) continue;
    162                 if (!isfinite(image->data.F32[y][x])) continue;
    163 
    164                 values->data.F32[valueIndex++] = image->data.F32[y][x];
    165             }
    166 
    167             if (!chipStats) {
    168                 values->n = valueIndex;
    169                 if (!psVectorStats(statistics, values, NULL, NULL, 0)) {
    170                     psError(PS_ERR_UNKNOWN, false, "Unable to do statistics on readout.");
    171                     psFree(inView);
    172                     psFree(readout);
    173                     goto MERGE_MASK_ERROR;
    174                 }
    175 
    176                 float mean = psStatsGetValue(statistics, meanStat);
    177                 float stdev = psStatsGetValue(statistics, stdevStat);
    178 
    179                 // this function increments the count for each suspect pixel in each input plane
    180                 // maskValRaw is used to test for valid input pixels
    181                 if (!pmMaskFlagSuspectPixels(outRO, readout, mean, stdev, maskSuspect, maskValRaw)) {
    182                     psError(PS_ERR_UNKNOWN, false, "Unable to find suspect values in file %d", i);
    183                     psFree(inView);
    184                     psFree(readout);
    185                     goto MERGE_MASK_ERROR;
    186                 }
    187                 pmCellFreeData(inCell);
    188 
    189                 if (!pmFPAfileIOChecks(config, inView, PM_FPA_AFTER)) {
    190                     psFree(inView);
    191                     psFree(readout);
    192                     goto MERGE_MASK_ERROR;
    193                 }
    194             }
     165
     166            if (!strcasecmp(maskSuspectMode, "VALUE")) {
     167                // this function increments the count for each suspect pixel in each input plane
     168                // maskValRaw is used to test for valid input pixels
     169                if (!pmMaskFlagSuspectPixelsByValue(outRO, readout, maskSuspectMin, maskSuspectMax, maskValRaw)) {
     170                    psError(PS_ERR_UNKNOWN, false, "Unable to find suspect values in file %d", i);
     171                    psFree(inView);
     172                    psFree(readout);
     173                    goto MERGE_MASK_ERROR;
     174                }
     175                pmCellFreeData(inCell);
     176
     177                if (!pmFPAfileIOChecks(config, inView, PM_FPA_AFTER)) {
     178                    psFree(inView);
     179                    psFree(readout);
     180                    goto MERGE_MASK_ERROR;
     181                }
     182            } else {
     183                // extract a subset of pixels for stats measurement -- don't use pixels which are masked for this calculation
     184                for (int i = 0; i < num; i++) {
     185                    int pixel = numPix * psRandomUniform(rng);
     186                    int x = pixel % numCols;
     187                    int y = pixel / numCols;
     188                    if (mask && (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskValRaw)) continue;
     189                    if (outMask && (outMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskValOut)) continue;
     190                    if (!isfinite(image->data.F32[y][x])) continue;
     191
     192                    values->data.F32[valueIndex] = image->data.F32[y][x];
     193                    valueIndex++;
     194                }
     195
     196                // for per-readout stats, measure the stats and find the suspect pixels
     197                if (!chipStats) {
     198                    values->n = valueIndex;
     199                    if (!psVectorStats(statistics, values, NULL, NULL, 0)) {
     200                        psError(PS_ERR_UNKNOWN, false, "Unable to do statistics on readout.");
     201                        psFree(inView);
     202                        psFree(readout);
     203                        goto MERGE_MASK_ERROR;
     204                    }
     205                    float mean = psStatsGetValue(statistics, meanStat);
     206                    float stdev = psStatsGetValue(statistics, stdevStat);
     207
     208                    // this function increments the count for each suspect pixel in each input plane
     209                    // maskValRaw is used to test for valid input pixels
     210                    if (!pmMaskFlagSuspectPixelsBySigma(outRO, readout, mean, stdev, maskSuspectSigma, maskValRaw)) {
     211                        psError(PS_ERR_UNKNOWN, false, "Unable to find suspect values in file %d", i);
     212                        psFree(inView);
     213                        psFree(readout);
     214                        goto MERGE_MASK_ERROR;
     215                    }
     216                    pmCellFreeData(inCell);
     217
     218                    if (!pmFPAfileIOChecks(config, inView, PM_FPA_AFTER)) {
     219                        psFree(inView);
     220                        psFree(readout);
     221                        goto MERGE_MASK_ERROR;
     222                    }
     223                }
     224            }
    195225            psFree(readout);
    196226            psFree(outRO);
     
    198228
    199229        // Additional run through cells if we want chip-level statistics
    200         if (chipStats && valueIndex > 0) {
     230        // only used for MASK.SUSPECT.MODE == SIGMA
     231        if (!strcasecmp(maskSuspectMode, "SIGMA") && chipStats && valueIndex > 0) {
    201232            values->n = valueIndex;
    202233            if (!psVectorStats(statistics, values, NULL, NULL, 0)) {
     
    221252                float stdev = psStatsGetValue(statistics, stdevStat);
    222253
    223                 if (!pmMaskFlagSuspectPixels(outRO, readout, mean, stdev, maskSuspect, maskValRaw)) {
     254                if (!pmMaskFlagSuspectPixelsBySigma(outRO, readout, mean, stdev, maskSuspectSigma, maskValRaw)) {
    224255                    psError(PS_ERR_UNKNOWN, false, "Unable to find suspect values in file %d", i);
    225256                    goto MERGE_MASK_ERROR;
Note: See TracChangeset for help on using the changeset viewer.