Changeset 8004 for trunk/psModules/src/detrend
- Timestamp:
- Jul 27, 2006, 5:21:19 PM (20 years ago)
- Location:
- trunk/psModules/src/detrend
- Files:
-
- 2 edited
-
pmSubtractBias.c (modified) (9 diffs)
-
pmSubtractSky.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/detrend/pmSubtractBias.c
r7604 r8004 11 11 * @author GLG, MHPCC 12 12 * 13 * @version $Revision: 1. 5$ $Name: not supported by cvs2svn $14 * @date $Date: 2006-0 6-21 03:21:16$13 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2006-07-28 03:21:19 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 165 165 } 166 166 167 168 /******************************************************************************169 GenNewStatOptions(): this routine will take as input the options member of the170 stat data structure, determine if multiple options have been specified, issue171 a warning message if so, and return the highest priority option (according to172 the order of the if-statements in this code). The higher priority options are173 listed lower in the code.174 *****************************************************************************/175 static psStatsOptions GenNewStatOptions(const psStats *stat)176 {177 assert(stat);178 179 psS32 numOptions = 0;180 psStatsOptions opt = 0;181 182 if (stat->options & PS_STAT_ROBUST_MEDIAN) {183 if (numOptions == 0) {184 opt = PS_STAT_ROBUST_MEDIAN;185 }186 numOptions++;187 }188 189 if (stat->options & PS_STAT_CLIPPED_MEAN) {190 if (numOptions == 0) {191 opt = PS_STAT_CLIPPED_MEAN;192 }193 numOptions++;194 }195 196 if (stat->options & PS_STAT_SAMPLE_MEDIAN) {197 if (numOptions == 0) {198 opt = PS_STAT_SAMPLE_MEDIAN;199 }200 numOptions++;201 }202 203 if (stat->options & PS_STAT_SAMPLE_MEAN) {204 numOptions++;205 opt = PS_STAT_SAMPLE_MEAN;206 }207 208 209 if (numOptions == 0) {210 psError(PS_ERR_UNKNOWN,true, "No statistics options have been specified.\n");211 }212 if (numOptions != 1) {213 psLogMsg(__func__, PS_LOG_WARN,214 "WARNING: pmSubtractBias.c: GenNewStatOptions(): Too many statistics options "215 "have been specified\n");216 }217 return opt;218 }219 220 221 167 // Produce an overscan vector from an array of pixels 222 168 static psVector *overscanVector(pmOverscanOptions *overscanOpts, // Overscan options … … 228 174 assert(pixels); 229 175 assert(myStats); 176 177 psStatsOptions statistic = psStatsSingleOption(myStats->options); // Statistic to use 178 assert(statistic != 0); 230 179 231 180 // Reduce the overscans … … 241 190 ordinate->data.F32[i] = 2.0*(float)i/(float)pixels->n - 1.0; // Scale to [-1,1] 242 191 psVectorStats(myStats, values, NULL, NULL, 0); 243 double reducedVal = NAN; // Result of statistics 244 if (! p_psGetStatValue(myStats, &reducedVal)) { 245 psError(PS_ERR_UNKNOWN, false, "p_psGetStatValue(): could not determine result " 246 "of statistics on row %d.\n", i); 247 return NULL; 248 } 249 reduced->data.F32[i] = reducedVal; 192 reduced->data.F32[i] = psStatsGetValue(myStats, statistic); 250 193 } else if (overscanOpts->fitType == PM_FIT_NONE) { 251 194 psError(PS_ERR_UNKNOWN, true, "The overscan is not supplied for all points on the " … … 344 287 psList *overscans = in->bias; // List of the overscan images 345 288 346 psStats *myStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN); // A new psStats, to avoid clobbering original 347 myStats->options = GenNewStatOptions(overscanOpts->stat); 289 psStatsOptions statistic = psStatsSingleOption(overscanOpts->stat->options); // Statistic to use 290 if (statistic == 0) { 291 psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Multiple or no statistics options set: %x\n", 292 overscanOpts->stat); 293 return false; 294 } 295 psStats *stats = psStatsAlloc(statistic); // A new psStats, to avoid clobbering original 348 296 349 297 // Reduce all overscan pixels to a single value … … 365 313 psFree(iter); 366 314 367 (void)psVectorStats(myStats, pixels, NULL, NULL, 0); 368 double reduced = NAN; // Result of statistics 369 if (! p_psGetStatValue(myStats, &reduced)) { 370 psError(PS_ERR_UNKNOWN, false, "p_psGetStatValue(): could not determine result from requested statistical operation. Returning input image.\n"); 371 return false; 372 } 315 (void)psVectorStats(stats, pixels, NULL, NULL, 0); 316 double reduced = psStatsGetValue(stats, statistic); // Result of statistics 373 317 (void)psBinaryOp(image, image, "-", psScalarAlloc((float)reduced, PS_TYPE_F32)); 374 318 } else { … … 408 352 409 353 // Reduce the overscans 410 psVector *reduced = overscanVector(overscanOpts, pixels, myStats);354 psVector *reduced = overscanVector(overscanOpts, pixels, stats); 411 355 psFree(pixels); 412 356 if (! reduced) { … … 452 396 453 397 // Reduce the overscans 454 psVector *reduced = overscanVector(overscanOpts, pixels, myStats);398 psVector *reduced = overscanVector(overscanOpts, pixels, stats); 455 399 psFree(pixels); 456 400 if (! reduced) { … … 467 411 } 468 412 } 469 psFree( myStats);413 psFree(stats); 470 414 } // End of overscan subtraction 471 415 -
trunk/psModules/src/detrend/pmSubtractSky.c
r7769 r8004 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $9 * @date $Date: 2006-0 6-30 23:59:49 $8 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2006-07-28 03:21:19 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 90 90 requirements change and we might need a custom reBin function. 91 91 *****************************************************************************/ 92 /* 92 #if 0 93 93 static psImage *binImage(psImage *origImage, 94 94 int binFactor, … … 96 96 { 97 97 psTrace("SubtractSky.binImage", 4, "Calling binImage(%d)\n", binFactor); 98 98 99 99 if (binFactor <= 0) { 100 100 psLogMsg(__func__, PS_LOG_WARN, … … 105 105 return(origImage); 106 106 } 107 107 108 108 psVector *binVector = psVectorAlloc(binFactor * binFactor, PS_TYPE_F32); 109 109 psVector *binMask = psVectorAlloc(binFactor * binFactor, PS_TYPE_U8); 110 110 psStats *myStats = psStatsAlloc(statOptions); 111 111 112 112 for (psS32 row = 0; row < origImage->numRows ; row+=binFactor) { 113 113 for (psS32 col = 0; col < origImage->numCols ; col+=binFactor) { … … 134 134 psF64 statValue; 135 135 psBool rc = p_psGetStatValue(rc1, &statValue); 136 136 137 137 if (rc == true) { 138 138 origImage->data.F32[row][col] = (psF32) statValue; … … 147 147 psFree(binMask); 148 148 psFree(myStats); 149 149 150 150 psTrace("SubtractSky.binImage", 4, "Exiting binImage(%d)\n", binFactor); 151 151 return(origImage); 152 152 } 153 */ 153 #endif 154 154 155 155 /****************************************************************************** … … 601 601 } else { 602 602 // Determine the mean and standard deviation of the binned image. 603 psF64 binnedMean; 604 psF64 binnedStdev; 605 psStats *myStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN); 606 psStats *rc = psImageStats(myStats, binnedImage, NULL, 0); 607 if (rc == NULL) { 608 psError(PS_ERR_UNKNOWN, false, "psImageStats(): could not perform requested statistical operation. Returning in image.\n"); 609 return(in); 610 } 611 if (false == p_psGetStatValue(rc, &binnedMean)) { 612 psError(PS_ERR_UNKNOWN, false, "p_psGetStatValue(): could not determine requested statistical operation. Returning in image.\n"); 613 return(in); 614 } 615 psTrace(".psModule.pmSubtractSky", 6, 616 "binned Mean is %f\n", binnedMean); 617 618 myStats->options = PS_STAT_SAMPLE_STDEV; 619 rc = psImageStats(myStats, binnedImage, NULL, 0); 620 if (rc == NULL) { 621 psError(PS_ERR_UNKNOWN, false, "psImageStats(): could not perform requested statistical operation. Returning in image.\n"); 622 return(in); 623 } 624 if (false == p_psGetStatValue(myStats, &binnedStdev)) { 625 psError(PS_ERR_UNKNOWN, false, "p_psGetStatValue(): could not determine requested statistical operation. Returning in image.\n"); 626 return(in); 627 } 603 psStats *myStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_STDEV); 604 if (!psImageStats(myStats, binnedImage, NULL, 0)) { 605 psError(PS_ERR_UNEXPECTED_NULL, false, "Couldn't get statistics for image.\n"); 606 return NULL; 607 } 608 psF64 binnedMean = myStats->sampleMean; 609 psF64 binnedStdev = myStats->sampleStdev; 628 610 psFree(myStats); 629 611 psTrace(".psModule.pmSubtractSky", 6,
Note:
See TracChangeset
for help on using the changeset viewer.
