Changeset 23989 for trunk/psModules
- Timestamp:
- Apr 28, 2009, 11:21:56 AM (17 years ago)
- Location:
- trunk/psModules/src
- Files:
-
- 17 edited
-
astrom/pmAstrometryDistortion.c (modified) (1 diff)
-
camera/pmFPAMaskWeight.c (modified) (1 diff)
-
detrend/pmFringeStats.c (modified) (2 diffs)
-
detrend/pmOverscan.c (modified) (4 diffs)
-
detrend/pmRemnance.c (modified) (1 diff)
-
detrend/pmShutterCorrection.c (modified) (1 diff)
-
extras/pmVisual.c (modified) (1 diff)
-
imcombine/pmImageCombine.c (modified) (3 diffs)
-
imcombine/pmReadoutCombine.c (modified) (1 diff)
-
imcombine/pmSubtraction.c (modified) (1 diff)
-
imcombine/pmSubtractionMatch.c (modified) (1 diff)
-
objects/models/pmModel_SGAUSS.c (modified) (1 diff)
-
objects/pmGrowthCurveGenerate.c (modified) (2 diffs)
-
objects/pmPSFtry.c (modified) (5 diffs)
-
objects/pmSource.c (modified) (3 diffs)
-
objects/pmSourceFitModel.c (modified) (1 diff)
-
objects/pmSourceMatch.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/astrom/pmAstrometryDistortion.c
r23487 r23989 151 151 152 152 // also measure the L and M median positions as a representative coordinate 153 psVectorStats (stats, L, NULL, NULL, 0); 153 if (!psVectorStats (stats, L, NULL, NULL, 0)) { 154 psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); 155 goto skip; 156 } 154 157 grad->FP.x = stats->sampleMedian; 155 158 156 psVectorStats (stats, M, NULL, NULL, 0); 159 if (!psVectorStats (stats, M, NULL, NULL, 0)) { 160 psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); 161 goto skip; 162 } 157 163 grad->FP.y = stats->sampleMedian; 158 164 -
trunk/psModules/src/camera/pmFPAMaskWeight.c
r23259 r23989 482 482 return false; 483 483 } 484 float stdev = psStatsGetValue(stdevStats, stdevStat); // Sta dard deviation of fluxes484 float stdev = psStatsGetValue(stdevStats, stdevStat); // Standard deviation of fluxes 485 485 psFree(stdevStats); 486 486 psFree(noise); -
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); -
trunk/psModules/src/extras/pmVisual.c
r23242 r23989 281 281 psStats *statsX = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV); 282 282 psStats *statsY = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV); 283 psVectorStats (statsX, xVec, NULL, NULL, 0); 284 psVectorStats (statsY, yVec, NULL, NULL, 0); 283 if (!psVectorStats (statsX, xVec, NULL, NULL, 0)) { 284 psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); 285 return false; 286 } 287 if (!psVectorStats (statsY, yVec, NULL, NULL, 0)) { 288 psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); 289 return false; 290 } 285 291 286 292 float xhi = statsX->sampleMedian + 3 *statsX->sampleStdev; -
trunk/psModules/src/imcombine/pmImageCombine.c
r21183 r23989 132 132 // Combine all the pixels, using the specified stat. 133 133 if (!psVectorStats(stats, pixelData, pixelErrors, pixelMasks, 0xff)) { 134 psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); 135 return false; 136 } 137 if (isnan(stats->sampleMean)) { 134 138 combine->data.F32[y][x] = NAN; 135 139 psFree(buffer); … … 137 141 } 138 142 float combinedPixel = stats->sampleMean; // Value of the combination 139 143 140 144 if (iter == 0) { 141 145 // Save the value produced with no rejection, since it may be useful later … … 364 368 // Get the median 365 369 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN); 366 psVectorStats(stats, pixels, NULL, mask, 1); 370 if (!psVectorStats(stats, pixels, NULL, mask, 1)) { 371 psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); 372 } 367 373 float median = stats->sampleMedian; 368 374 psFree(stats); -
trunk/psModules/src/imcombine/pmReadoutCombine.c
r21363 r23989 384 384 // Combination 385 385 if (!psVectorStats(stats, pixels, errors, mask, 1)) { 386 // Can't do much about it, but it's not worth worrying about 387 psErrorClear(); 386 psError(PS_ERR_UNKNOWN, false, "error in pixel stats"); 387 return false; 388 } 389 390 outputImage[yOut][xOut] = psStatsGetValue(stats, params->combine); 391 392 if (isnan(outputImage[yOut][xOut])) { 388 393 outputImage[yOut][xOut] = NAN; 389 394 outputMask[yOut][xOut] = params->blank; 395 sigma->data.F32[yOut][xOut] = NAN; 390 396 if (params->variances) { 391 397 outputVariance[yOut][xOut] = NAN; 392 398 } 393 sigma->data.F32[yOut][xOut] = NAN; 394 } else { 395 outputImage[yOut][xOut] = psStatsGetValue(stats, params->combine); 396 outputMask[yOut][xOut] = isfinite(outputImage[yOut][xOut]) ? 0 : params->blank; 397 if (params->variances) { 398 float stdev = psStatsGetValue(stats, combineStdev); 399 outputVariance[yOut][xOut] = PS_SQR(stdev); // Variance 400 // XXXX this is not the correct formal error. 401 // also, the weighted mean is not obviously the correct thing here 402 } 403 sigma->data.F32[yOut][xOut] = psStatsGetValue(stats, combineStdev); 404 } 399 continue; 400 } 401 outputMask[yOut][xOut] = 0; 402 sigma->data.F32[yOut][xOut] = psStatsGetValue(stats, combineStdev); 403 if (params->variances) { 404 float stdev = psStatsGetValue(stats, combineStdev); 405 outputVariance[yOut][xOut] = PS_SQR(stdev); // Variance 406 // XXXX this is not the correct formal error. 407 // also, the weighted mean is not obviously the correct thing here 408 } 405 409 } 406 410 } -
trunk/psModules/src/imcombine/pmSubtraction.c
r23839 r23989 822 822 psFree(mask); 823 823 824 // XXX raise an error? 825 if (isnan(stats->sampleMean)) { 826 psFree(stats); 827 return -1; 828 } 829 824 830 double mean, rms; // Mean and RMS of deviations 825 831 if (numStamps < MIN_SAMPLE_STATS) { -
trunk/psModules/src/imcombine/pmSubtractionMatch.c
r23944 r23989 830 830 psFree(mask); 831 831 832 // XXX raise an error here or not? 833 if (isnan(stats->robustMedian)) { 834 psFree(stats); 835 return PM_SUBTRACTION_MODE_ERR; 836 } 837 832 838 psLogMsg("psModules.imcombine", PS_LOG_INFO, "Median width ratio: %lf", stats->robustMedian); 833 839 pmSubtractionMode mode = (stats->robustMedian <= 1.0 ? PM_SUBTRACTION_MODE_1 : PM_SUBTRACTION_MODE_2); 834 840 psFree(stats); 835 841 836 // XXX EAM : I think Paul left some test code in here. I've commented these lines out837 // return PM_SUBTRACTION_MODE_2;838 // exit(1);839 840 842 return mode; 841 843 } -
trunk/psModules/src/objects/models/pmModel_SGAUSS.c
r15834 r23989 325 325 326 326 psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN); 327 psVectorStats (stats, contour, NULL, NULL, 0); 327 if (!psVectorStats (stats, contour, NULL, NULL, 0)) { 328 psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); 329 return false; 330 } 328 331 value = stats->sampleMedian; 329 332 -
trunk/psModules/src/objects/pmGrowthCurveGenerate.c
r21183 r23989 89 89 psVectorAppend (values, growth->fitMag); 90 90 } 91 psVectorStats (stats, values, NULL, NULL, 0); 91 if (!psVectorStats (stats, values, NULL, NULL, 0)) { 92 psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); 93 return false; 94 } 92 95 psf->growth->fitMag = stats->sampleMedian; 93 96 … … 104 107 psVectorAppend (values, growth->apMag->data.F32[i]); 105 108 } 106 psVectorStats (stats, values, NULL, NULL, 0); 109 if (!psVectorStats (stats, values, NULL, NULL, 0)) { 110 psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); 111 return false; 112 } 107 113 psf->growth->apMag->data.F32[i] = stats->sampleMedian; 108 114 } -
trunk/psModules/src/objects/pmPSFtry.c
r21183 r23989 211 211 212 212 if (Next == 0) { 213 psError(PS_ERR_UNKNOWN, true, "No sources with good extended fits from which to determine PSF.");213 psError(PS_ERR_UNKNOWN, false, "No sources with good extended fits from which to determine PSF."); 214 214 psFree(psfTry); 215 215 return NULL; … … 282 282 283 283 if (Npsf == 0) { 284 psError(PS_ERR_UNKNOWN, true, "No sources with good PSF fits after model is built.");284 psError(PS_ERR_UNKNOWN, false, "No sources with good PSF fits after model is built."); 285 285 psFree(psfTry); 286 286 return NULL; … … 643 643 } 644 644 if (entryMin == -1) { 645 psError (PS_ERR_UNKNOWN, true, "failed to find image map for shape params");645 psError (PS_ERR_UNKNOWN, false, "failed to find image map for shape params"); 646 646 return false; 647 647 } … … 958 958 float dEsquare = 0.0; 959 959 psStatsInit (stats); 960 psVectorStats (stats, e0res, NULL, mask, maskValue); 960 if (!psVectorStats (stats, e0res, NULL, mask, maskValue)) { 961 psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); 962 return false; 963 } 961 964 dEsquare += PS_SQR(psStatsGetValue(stats, stdevOpt)); 962 965 963 966 psStatsInit (stats); 964 psVectorStats (stats, e1res, NULL, mask, maskValue); 967 if (!psVectorStats (stats, e1res, NULL, mask, maskValue)) { 968 psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); 969 return false; 970 } 965 971 dEsquare += PS_SQR(psStatsGetValue(stats, stdevOpt)); 966 972 967 973 psStatsInit (stats); 968 psVectorStats (stats, e2res, NULL, mask, maskValue); 974 if (!psVectorStats (stats, e2res, NULL, mask, maskValue)) { 975 psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); 976 return false; 977 } 969 978 dEsquare += PS_SQR(psStatsGetValue(stats, stdevOpt)); 970 979 … … 1018 1027 float dEsquare = 0.0; 1019 1028 psStatsInit (statsS); 1020 psVectorStats (statsS, dE0subset, NULL, mkSubset, 0xff); 1029 if (!psVectorStats (statsS, dE0subset, NULL, mkSubset, 0xff)) { 1030 } 1021 1031 dEsquare += PS_SQR(psStatsGetValue(statsS, stdevOpt)); 1022 1032 1023 1033 psStatsInit (statsS); 1024 psVectorStats (statsS, dE1subset, NULL, mkSubset, 0xff); 1025 dEsquare += PS_SQR(psStatsGetValue(statsS, stdevOpt)); 1034 if (!psVectorStats (statsS, dE1subset, NULL, mkSubset, 0xff)) { 1035 psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); 1036 return false; 1037 } 1038 dEsquare += PS_SQR(psStatsGetValue(statsS, stdevOpt)); 1026 1039 1027 1040 psStatsInit (statsS); 1028 psVectorStats (statsS, dE2subset, NULL, mkSubset, 0xff); 1041 if (!psVectorStats (statsS, dE2subset, NULL, mkSubset, 0xff)) { 1042 psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); 1043 return false; 1044 } 1029 1045 dEsquare += PS_SQR(psStatsGetValue(statsS, stdevOpt)); 1030 1046 -
trunk/psModules/src/objects/pmSource.c
r23187 r23989 479 479 stats = psStatsAlloc (PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV); 480 480 481 psVectorStats (stats, tmpSx, NULL, NULL, 0); 481 if (!psVectorStats (stats, tmpSx, NULL, NULL, 0)) { 482 psError(PS_ERR_UNKNOWN, false, "failed to measure Sx stats"); 483 return (emptyClump); 484 } 482 485 psfClump.X = stats->clippedMean; 483 486 psfClump.dX = stats->clippedStdev; 484 487 485 psVectorStats (stats, tmpSy, NULL, NULL, 0); 488 if (!psVectorStats (stats, tmpSy, NULL, NULL, 0)) { 489 psError(PS_ERR_UNKNOWN, false, "failed to measure Sy stats"); 490 return (emptyClump); 491 } 486 492 psfClump.Y = stats->clippedMean; 487 493 psfClump.dY = stats->clippedStdev; … … 636 642 637 643 if (!psVectorStats (stats, starsn_moments, NULL, NULL, 0)) { 638 // Don't care about this error 639 psErrorClear(); 644 psError(PS_ERR_UNKNOWN, false, "failed to measure SN / moments stats"); 645 psFree (stats); 646 psFree (starsn_peaks); 647 return false; 640 648 } 641 649 psLogMsg ("pmObjects", 3, "SN range (moments): %f - %f\n", stats->min, stats->max); … … 648 656 stats = psStatsAlloc (PS_STAT_MIN | PS_STAT_MAX); 649 657 if (!psVectorStats (stats, starsn_peaks, NULL, NULL, 0)) { 650 // Don't care about this error 651 psErrorClear(); 658 psError(PS_ERR_UNKNOWN, false, "failed to measure SN / moments stats"); 659 psFree (stats); 660 psFree (starsn_peaks); 661 return false; 652 662 } 653 663 psLogMsg ("psModules.objects", 3, "SN range (peaks) : %f - %f (%ld)\n", -
trunk/psModules/src/objects/pmSourceFitModel.c
r23187 r23989 172 172 fitStatus = psMinimizeLMChi2(myMin, covar, params, constraint, x, y, yErr, model->modelFunc); 173 173 for (int i = 0; i < dparams->n; i++) { 174 if (psTraceGetLevel("psModules.objects") >= 4) {175 fprintf (stderr, "%f ", params->data.F32[i]);176 }177 174 if ((constraint->paramMask != NULL) && constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) 178 175 continue; 179 176 dparams->data.F32[i] = sqrt(covar->data.F32[i][i]); 177 if (psTraceGetLevel("psModules.objects") >= 4) { 178 fprintf (stderr, "%f +/- %f\n", params->data.F32[i], dparams->data.F32[i]); 179 } 180 180 } 181 181 psTrace ("psModules.objects", 4, "niter: %d, chisq: %f", myMin->iter, myMin->value); -
trunk/psModules/src/objects/pmSourceMatch.c
r23241 r23989 473 473 return -1; 474 474 } 475 // XXX handle this case better: 476 if (isnan(stats->clippedMean)) { 477 psError(PS_ERR_UNKNOWN, false, "Unable to perform statistics on transparencies."); 478 psFree(stats); 479 return -1; 480 } 475 481 476 482 float thresh = stats->clippedMean + photoLevel * stats->clippedStdev; // Threshold for clouds
Note:
See TracChangeset
for help on using the changeset viewer.
