IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 13607


Ignore:
Timestamp:
Jun 3, 2007, 4:27:58 PM (19 years ago)
Author:
eugene
Message:

added sat_pixel_frac, sat_pixel_num

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppStats/src/ppStatsLoop.c

    r10165 r13607  
    109109    }
    110110
    111     if (!data->doStats) {
     111    if (!data->doStats && psListLength(data->summary)) {
    112112        // Nothing further to do --- don't want to waste our time reading the data
    113113        if (psListLength(cellResults->list) > 0) {
     
    143143    }
    144144
    145     // Do the statistics
     145    // Measure basic image statistics (means, stdevs, etc). 
    146146    if (data->sample <= 0.0) {
    147147        if (!psImageStats(data->stats, readout->image, readout->mask, data->maskVal)) {
    148148            psLogMsg(__func__, PS_LOG_WARN, "Unable to perform statistics on cell %s --- "
    149149                     "ignored.\n", cellName);
    150             goto cellDone;
     150            goto statsDone;
    151151        }
    152152    } else {
     
    175175            psFree(sampleValues);
    176176            psFree(sampleMask);
    177             goto cellDone;
     177            goto statsDone;
    178178        }
    179179        psFree(sampleValues);
     
    201201    WRITE_STAT(PS_STAT_CLIPPED_STDEV,   "CLIPPED_STDEV", clippedStdev);
    202202
     203    // measure other types of statistics tests
     204   
     205statsDone:
     206    // count saturated pixels
     207    if (psListLength(data->summary) > 0)     {
     208        bool get_nSatPixels = false;
     209        bool get_fSatPixels = false;
     210
     211        psListIterator *iterator = psListIteratorAlloc(data->summary, PS_LIST_HEAD, false);
     212        psString choice;
     213        while ((choice = psListGetAndIncrement(iterator))) {
     214            if (!strcasecmp (choice, "SAT_PIXEL_NUM"))  get_nSatPixels = true;
     215            if (!strcasecmp (choice, "SAT_PIXEL_FRAC")) get_fSatPixels = true;
     216        }
     217
     218        if (!get_nSatPixels && !get_fSatPixels) goto cellDone;
     219
     220        // Get the "concepts" of interest
     221        float saturation = psMetadataLookupF32(&mdok, cell->concepts, "CELL.SATURATION"); // Saturation level
     222        if (!mdok || isnan(saturation)) {
     223            psLogMsg(__func__, PS_LOG_WARN, "CELL.SATURATION is not set --- unable to measure N_SAT_PIXELS.\n");
     224            goto cellDone;
     225        }
     226
     227        int nSatPixels = 0;
     228        for (int j = 0; j < readout->image->numRows; j++) {
     229            for (int i = 0; i < readout->image->numCols; i++) {
     230                if (readout->image->data.F32[j][i] >= saturation) {
     231                    nSatPixels ++;
     232                }
     233            }
     234        }
     235        if (get_nSatPixels) psMetadataAddS32(cellResults, PS_LIST_TAIL, "SAT_PIXEL_NUM", 0, NULL, nSatPixels);
     236        if (get_fSatPixels) psMetadataAddF32(cellResults, PS_LIST_TAIL, "SAT_PIXEL_FRAC", 0, NULL, nSatPixels / (double)(readout->image->numRows * readout->image->numCols));
     237    }
     238
    203239cellDone:
    204240    // Add the cell results to the chip
Note: See TracChangeset for help on using the changeset viewer.