Changeset 23989 for trunk/psModules/src/detrend
- Timestamp:
- Apr 28, 2009, 11:21:56 AM (17 years ago)
- Location:
- trunk/psModules/src/detrend
- Files:
-
- 4 edited
-
pmFringeStats.c (modified) (2 diffs)
-
pmOverscan.c (modified) (4 diffs)
-
pmRemnance.c (modified) (1 diff)
-
pmShutterCorrection.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/detrend/pmFringeStats.c
r23259 r23989 882 882 883 883 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_QUARTILE); // Statistics 884 psVectorStats(stats, diffs, NULL, mask, 1); 884 if (!psVectorStats(stats, diffs, NULL, mask, 1)) { 885 psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); 886 return 0; 887 } 885 888 float middle = stats->sampleMedian; // The middle of the distribution 886 889 float thresh = rej * 0.74 * (stats->sampleUQ - stats->sampleLQ); // The rejection threshold … … 969 972 970 973 // Get rid of the extreme outliers by assuming most of the points are somewhat clustered 971 psVectorStats(median, science->f, NULL, NULL, 0); 974 if (!psVectorStats(median, science->f, NULL, NULL, 0)) { 975 psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); 976 return NULL; 977 } 972 978 scale->coeff->data.F32[0] = median->sampleMedian; 973 979 for (int i = 0; i < fringes->n; i++) { 974 980 pmFringeStats *fringe = fringes->data[i]; // The fringe of interest 975 psVectorStats(median, fringe->f, NULL, NULL, 0); 981 if (!psVectorStats(median, fringe->f, NULL, NULL, 0)) { 982 psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); 983 return NULL; 984 } 976 985 scale->coeff->data.F32[0] -= median->sampleMedian; 977 986 scale->coeff->data.F32[i] = 0.0; -
trunk/psModules/src/detrend/pmOverscan.c
r23826 r23989 74 74 mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0; 75 75 ordinate->data.F32[i] = 2.0*(float)i/(float)pixels->n - 1.0; // Scale to [-1,1] 76 psVectorStats(myStats, values, NULL, NULL, 0); 76 if (!psVectorStats(myStats, values, NULL, NULL, 0)) { 77 psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); 78 return false; 79 } 77 80 reduced->data.F32[i] = psStatsGetValue(myStats, statistic); 78 81 } else if (overscanOpts->fitType == PM_FIT_NONE) { … … 275 278 psFree(iter); 276 279 277 (void)psVectorStats(stats, pixels, NULL, NULL, 0); 280 if (!psVectorStats(stats, pixels, NULL, NULL, 0)) { 281 psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); 282 return false; 283 } 278 284 psFree(pixels); 279 285 double reduced = psStatsGetValue(stats, statistic); // Result of statistics … … 349 355 psString comment = NULL; // Comment to add 350 356 psStats *vectorStats = psStatsAlloc (PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_STDEV); 351 psVectorStats (vectorStats, reduced, NULL, NULL, 0); 357 if (!psVectorStats (vectorStats, reduced, NULL, NULL, 0)) { 358 psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); 359 return false; 360 } 352 361 psStringAppend(&comment, "Mean Overscan value: %f", vectorStats->sampleMean); 353 362 psMetadataAddStr(hdu->header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, comment, ""); … … 412 421 psString comment = NULL; // Comment to add 413 422 psStats *vectorStats = psStatsAlloc (PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_STDEV); 414 psVectorStats (vectorStats, reduced, NULL, NULL, 0); 423 if (!psVectorStats (vectorStats, reduced, NULL, NULL, 0)) { 424 psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); 425 return false; 426 } 415 427 psStringAppend(&comment, "Mean Overscan value: %f", vectorStats->sampleMean); 416 428 psMetadataAddStr(hdu->header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, comment, ""); -
trunk/psModules/src/detrend/pmRemnance.c
r23259 r23989 66 66 values->n = numValues; 67 67 if (!psVectorStats(stats, values, NULL, NULL, 0)) { 68 // Can't do anything about it 69 psErrorClear(); 68 psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); 69 return false; 70 } 71 if (isnan(stats->sampleMedian)) { 70 72 maxMask = max; 71 73 continue; -
trunk/psModules/src/detrend/pmShutterCorrection.c
r23487 r23989 350 350 psStats *rawStats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV); 351 351 psStats *resStats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV); 352 psVectorStats (rawStats, counts, NULL, NULL, 0); 353 psVectorStats (resStats, resid, NULL, NULL, 0); 352 if (!psVectorStats (rawStats, counts, NULL, NULL, 0)) { 353 psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); 354 return NULL; 355 } 356 if (!psVectorStats (resStats, resid, NULL, NULL, 0)) { 357 psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); 358 return NULL; 359 } 354 360 355 361 // XXX temporary hard-wired minimum stdev improvement factor 356 362 psTrace("psModules.detrend", 3, "raw scatter %f vs res scatter %f\n", rawStats->sampleStdev, resStats->sampleStdev); 357 363 if (rawStats->sampleStdev / resStats->sampleStdev < 1.5) corr->valid = false; 364 if (isnan(rawStats->sampleStdev) || isnan(resStats->sampleStdev)) corr->valid = false; 358 365 359 366 psFree (rawStats);
Note:
See TracChangeset
for help on using the changeset viewer.
