- Timestamp:
- Mar 27, 2008, 2:59:07 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/pap_branch_080320/ppMerge/src/ppMergeScaleZero.c
r17140 r17157 23 23 psMaskType maskVal = psMetadataLookupU8(NULL, config->arguments, "MASKVAL"); // Value to mask 24 24 int shutterSize = psMetadataLookupS32(NULL, config->arguments, "SHUTTER.SIZE"); // Size of shutter region 25 int sample = psMetadataLookupS32(NULL, config->arguments, "SAMPLE"); // Maximum size of sample26 bool chipStats = false; // Do statistics on full chip instead of cell?27 25 28 26 psVector *gains = NULL; // Gains for each cell … … 47 45 break; 48 46 case PPMERGE_TYPE_MASK: 49 stats = psStatsAlloc(meanStat | stdevStat);50 47 default: 51 48 break; … … 53 50 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS, 0); // Random number generator 54 51 pmFPAview *view = NULL; // View into FPA 55 56 psVector *values = psVectorAlloc(sample, PS_TYPE_F32); // Values for statistics57 52 58 53 for (int i = 0; i < numInputs; i++) { … … 74 69 goto ERROR; 75 70 } 76 77 int valueIndex = 0; // Index into values vector78 71 79 72 pmCell *cell; // Cell of interest … … 138 131 break; 139 132 } 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: 174 134 default: 175 135 psAbort("Should never get here."); … … 178 138 cellNum++; 179 139 180 if ((type != PPMERGE_TYPE_MASK || !chipStats) && 181 !pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { 140 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { 182 141 goto ERROR; 183 }184 }185 186 // Additional run through cells if we want chip-level statistics for masks187 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 }203 142 } 204 143 } … … 256 195 "Shutter data", shutters); 257 196 break; 197 case PPMERGE_TYPE_MASK: 258 198 default: 259 199 psAbort("Should never get here.");
Note:
See TracChangeset
for help on using the changeset viewer.
