IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 27, 2008, 2:59:07 PM (18 years ago)
Author:
Paul Price
Message:

Adding count and sigma files as outputs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/pap_branch_080320/ppMerge/src/ppMergeScaleZero.c

    r17140 r17157  
    2323    psMaskType maskVal = psMetadataLookupU8(NULL, config->arguments, "MASKVAL"); // Value to mask
    2424    int shutterSize = psMetadataLookupS32(NULL, config->arguments, "SHUTTER.SIZE"); // Size of shutter region
    25     int sample = psMetadataLookupS32(NULL, config->arguments, "SAMPLE"); // Maximum size of sample
    26     bool chipStats = false;             // Do statistics on full chip instead of cell?
    2725
    2826    psVector *gains = NULL;             // Gains for each cell
     
    4745        break;
    4846      case PPMERGE_TYPE_MASK:
    49         stats = psStatsAlloc(meanStat | stdevStat);
    5047      default:
    5148        break;
     
    5350    psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS, 0); // Random number generator
    5451    pmFPAview *view = NULL;             // View into FPA
    55 
    56     psVector *values = psVectorAlloc(sample, PS_TYPE_F32); // Values for statistics
    5752
    5853    for (int i = 0; i < numInputs; i++) {
     
    7469                goto ERROR;
    7570            }
    76 
    77             int valueIndex = 0;         // Index into values vector
    7871
    7972            pmCell *cell;               // Cell of interest
     
    138131                      break;
    139132                  }
    140                   case PPMERGE_TYPE_MASK: {
    141                       psImage *image = readout->image, *mask = readout->mask; // Image and mask
    142                       int numCols = readout->image->numCols, numRows = readout->image->numRows; // Image size
    143                       int numPix = numCols * numRows; // Number of pixels
    144                       int numCells = chipStats ? readout->parent->parent->cells->n : 1; // Number of cells
    145                       int num = PS_MIN(numPix, sample / numCells); // Number of values to add
    146                       if (!chipStats) {
    147                           valueIndex = 0;
    148                       }
    149                       for (int i = 0; i < num; i++) {
    150                           int pixel = numPix * psRandomUniform(rng);
    151                           int x = pixel % numCols;
    152                           int y = pixel / numCols;
    153                           if ((mask && (mask->data.PS_TYPE_MASK_DATA[y][x] & maskVal)) ||
    154                               !isfinite(image->data.F32[y][x])) {
    155                               continue;
    156                           }
    157 
    158                           values->data.F32[valueIndex++] = image->data.F32[y][x];
    159                       }
    160 
    161                       if (!chipStats) {
    162                           if (!psVectorStats(stats, values, NULL, NULL, 0)) {
    163                               psError(PS_ERR_UNKNOWN, false, "Unable to do statistics on readout.");
    164                               goto ERROR;
    165                           }
    166 
    167                           psMetadataAddF32(cell->analysis, PS_LIST_TAIL, PM_MASK_ANALYSIS_MEAN, 0,
    168                                            "Mean value of readout", psStatsGetValue(stats, meanStat));
    169                           psMetadataAddF32(cell->analysis, PS_LIST_TAIL, PM_MASK_ANALYSIS_STDEV, 0,
    170                                            "Stdev value of readout", psStatsGetValue(stats, stdevStat));
    171                       }
    172                       break;
    173                   }
     133                  case PPMERGE_TYPE_MASK:
    174134                  default:
    175135                    psAbort("Should never get here.");
     
    178138                cellNum++;
    179139
    180                 if ((type != PPMERGE_TYPE_MASK || !chipStats) &&
    181                     !pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
     140                if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
    182141                    goto ERROR;
    183                 }
    184             }
    185 
    186             // Additional run through cells if we want chip-level statistics for masks
    187             if (type == PPMERGE_TYPE_MASK && chipStats) {
    188                 if (!psVectorStats(stats, values, NULL, NULL, 0)) {
    189                     psError(PS_ERR_UNKNOWN, false, "Unable to do statistics on chip.");
    190                     goto ERROR;
    191                 }
    192                 while ((cell = pmFPAviewNextCell(view, fpa, 1))) {
    193                     if (!cell->data_exists) {
    194                         continue;
    195                     }
    196                     psMetadataAddF32(cell->analysis, PS_LIST_TAIL, PM_MASK_ANALYSIS_MEAN, 0,
    197                                      "Mean value of chip", psStatsGetValue(stats, meanStat));
    198                     psMetadataAddF32(cell->analysis, PS_LIST_TAIL, PM_MASK_ANALYSIS_STDEV, 0,
    199                                      "Stdev value of chip", psStatsGetValue(stats, stdevStat));
    200                     if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
    201                         goto ERROR;
    202                     }
    203142                }
    204143            }
     
    256195                           "Shutter data", shutters);
    257196        break;
     197      case PPMERGE_TYPE_MASK:
    258198      default:
    259199        psAbort("Should never get here.");
Note: See TracChangeset for help on using the changeset viewer.