Changeset 15842
- Timestamp:
- Dec 14, 2007, 3:23:18 PM (18 years ago)
- Location:
- trunk/psModules/src/objects
- Files:
-
- 3 edited
-
pmPSFtry.c (modified) (12 diffs)
-
pmPSFtry.h (modified) (3 diffs)
-
pmTrend2D.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmPSFtry.c
r15705 r15842 5 5 * @author EAM, IfA 6 6 * 7 * @version $Revision: 1.5 2$ $Name: not supported by cvs2svn $8 * @date $Date: 2007-1 1-28 00:43:27$7 * @version $Revision: 1.53 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2007-12-15 01:23:18 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 221 221 222 222 // use 3hi/3lo sigma clipping on the chisq fit 223 psStats *stats = psStatsAlloc (PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); 224 stats->clipSigma = 3.0; 225 stats->clipIter = 3; 223 psStats *stats = options->stats; 226 224 227 225 // linear clipped fit of chisq trend vs flux 228 bool result = psVectorClipFitPolynomial1D(psfTry->psf->ChiTrend, stats, mask, 0xff, chisq, NULL, flux); 229 psLogMsg ("pmPSFtry", 4, "chisq vs flux fit: %f +/- %f\n", stats->robustMedian, stats->robustStdev); 230 231 psFree (flux); 232 psFree (stats); 233 psFree (mask); 234 psFree (chisq); 226 bool result = psVectorClipFitPolynomial1D(psfTry->psf->ChiTrend, options->stats, mask, 227 0xff, chisq, NULL, flux); 228 psStatsOptions meanStat = psStatsMeanOption(options->stats->options); // Statistic for mean 229 psStatsOptions stdevStat = psStatsStdevOption(options->stats->options); // Statistic for stdev 230 231 psLogMsg ("pmPSFtry", 4, "chisq vs flux fit: %f +/- %f\n", 232 psStatsGetValue(stats, meanStat), psStatsGetValue(stats, stdevStat)); 233 234 psFree(flux); 235 psFree(mask); 236 psFree(chisq); 235 237 236 238 if (!result) { … … 247 249 248 250 // XXX this function wants aperture radius for pmSourcePhotometry 249 if (!pmPSFtryMetric (psfTry, options ->radius)) {251 if (!pmPSFtryMetric (psfTry, options)) { 250 252 psError(PS_ERR_UNKNOWN, false, "Attempt to fit PSF with model %s failed.", modelName); 251 253 return NULL; … … 258 260 } 259 261 260 bool pmPSFtryMetric (pmPSFtry *psfTry, float RADIUS)262 bool pmPSFtryMetric (pmPSFtry *psfTry, pmPSFOptions *options) 261 263 { 262 264 PS_ASSERT_PTR_NON_NULL(psfTry, false); 265 PS_ASSERT_PTR_NON_NULL(options, false); 263 266 PS_ASSERT_PTR_NON_NULL(psfTry->sources, false); 267 268 float RADIUS = options->radius; 264 269 265 270 // the measured (aperture - fit) magnitudes (dA == psfTry->metric) … … 286 291 // linear, constant-error fitting. Do not reject outliers with excessive vigor here. 287 292 288 // use 3hi/1lo sigma clipping on the r2rflux vs metric fit289 psStats *stats = psStatsAlloc (PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV);290 stats->clipSigma = 3.0;291 stats->clipIter = 3;292 293 293 // fit ApTrend only to r2rflux, ignore x,y,flux variations for now 294 294 // linear clipped fit of ApResid to r2rflux … … 297 297 298 298 // XXX replace this with a psVectorStats call? since we are not fitting the trend 299 bool result = psVectorClipFitPolynomial1D (poly, stats, psfTry->mask, PSFTRY_MASK_ALL, psfTry->metric, psfTry->metricErr, r2rflux); 299 bool result = psVectorClipFitPolynomial1D(poly, options->stats, psfTry->mask, PSFTRY_MASK_ALL, 300 psfTry->metric, psfTry->metricErr, r2rflux); 300 301 if (!result) { 301 302 psError(PS_ERR_UNKNOWN, false, "Failed to fit clipped poly"); … … 303 304 psFree(poly); 304 305 psFree(r2rflux); 305 psFree(stats);306 306 307 307 return false; 308 308 } 309 psLogMsg ("pmPSFtryMetric", 4, "apresid: %f +/- %f; keeping %ld of %ld psf stars\n", poly->coeff[0], stats->robustStdev, stats->clippedNvalues, psfTry->sources->n); 309 psStatsOptions stdevStat = psStatsStdevOption(options->stats->options); // Statistic for stdev 310 psLogMsg ("pmPSFtryMetric", 4, "apresid: %f +/- %f; from statistics of %ld psf stars\n", poly->coeff[0], 311 psStatsGetValue(options->stats, stdevStat), psfTry->sources->n); 312 313 310 314 311 315 // XXX test dump of fitted model (dump when tracing?) … … 335 339 psfTry->psf->skyBias = poly->coeff[1]; 336 340 psfTry->psf->ApResid = poly->coeff[0]; 337 psfTry->psf->dApResid = stats->robustStdev;341 psfTry->psf->dApResid = psStatsGetValue(options->stats, stdevStat); 338 342 339 343 psFree (r2rflux); 340 344 psFree (poly); 341 psFree (stats);342 345 343 346 return true; … … 720 723 // XXX this is a bit arbitrary, but it forces ~3 stars from the bright bin per spatial bin 721 724 int nGroup = PS_MAX (3*Nx*Ny, 10); 722 pmPSFShapeParamsErrors (errorFloor, mag, e0res, e1res, e2res, mask, nGroup); 725 pmPSFShapeParamsErrors (errorFloor, mag, e0res, e1res, e2res, mask, nGroup, 726 psStatsStdevOption(psf->psfTrendStats->options)); 723 727 724 728 *errorTotal = sqrt(PS_SQR(*errorFloor) + mapErrorSum); … … 739 743 740 744 // calculate the minimum scatter of the parameters 741 bool pmPSFShapeParamsErrors (float *errorFloor, psVector *mag, psVector *e0res, psVector *e1res, psVector *e2res, psVector *mask, int nGroup) { 742 743 psStats *statsS = psStatsAlloc (PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); 745 bool pmPSFShapeParamsErrors(float *errorFloor, psVector *mag, psVector *e0res, psVector *e1res, 746 psVector *e2res, psVector *mask, int nGroup, psStatsOptions stdevOpt) 747 { 748 749 psStats *statsS = psStatsAlloc(stdevOpt); 744 750 745 751 // measure the trend in bins with 10 values each; if < 10 total, use them all … … 778 784 psStatsInit (statsS); 779 785 psVectorStats (statsS, dE0subset, NULL, mkSubset, 0xff); 780 dEsquare += PS_SQR( statsS->robustStdev);786 dEsquare += PS_SQR(psStatsGetValue(statsS, stdevOpt)); 781 787 782 788 psStatsInit (statsS); 783 789 psVectorStats (statsS, dE1subset, NULL, mkSubset, 0xff); 784 dEsquare += PS_SQR( statsS->robustStdev);790 dEsquare += PS_SQR(psStatsGetValue(statsS, stdevOpt)); 785 791 786 792 psStatsInit (statsS); 787 793 psVectorStats (statsS, dE2subset, NULL, mkSubset, 0xff); 788 dEsquare += PS_SQR( statsS->robustStdev);794 dEsquare += PS_SQR(psStatsGetValue(statsS, stdevOpt)); 789 795 790 796 dSo->data.F32[i] = sqrt(dEsquare); … … 795 801 psFree (mkSubset); 796 802 797 psStats *stats = psStatsAlloc (PS_STAT_MIN); 798 psVectorStats (stats, dSo, NULL, NULL, 0); 799 800 *errorFloor = stats->min; 801 802 psFree (stats); 803 psFree (index); 804 803 psStats *minStats = psStatsAlloc(PS_STAT_MIN); 804 psVectorStats(minStats, dSo, NULL, NULL, 0); 805 *errorFloor = minStats->min; 806 psFree(minStats); 807 808 psFree(index); 805 809 psFree (dSo); 806 810 -
trunk/psModules/src/objects/pmPSFtry.h
r15697 r15842 6 6 * @author EAM, IfA 7 7 * 8 * @version $Revision: 1.1 8$ $Name: not supported by cvs2svn $9 * @date $Date: 2007-1 1-27 03:14:57$8 * @version $Revision: 1.19 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2007-12-15 01:23:18 $ 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 11 11 */ … … 99 99 bool pmPSFtryMetric( 100 100 pmPSFtry *psfTry, ///< Add comment. 101 float RADIUS ///< Add comment.101 pmPSFOptions *options ///< PSF fitting options 102 102 ); 103 103 … … 129 129 bool pmPSFFitShapeParams (pmPSF *psf, psArray *sources, psVector *x, psVector *y, psVector *srcMask); 130 130 bool pmPSFFitShapeParamsMap (pmPSF *psf, int scale, float *errorFloor, float *errorTotal, psVector *mask, psVector *x, psVector *y, psVector *mag, psVector *e0obs, psVector *e1obs, psVector *e2obs, psVector *dz); 131 bool pmPSFShapeParamsErrors (float *errorFloor, psVector *mag, psVector *e0res, psVector *e1res, psVector *e2res, psVector *mask, int nGroup );131 bool pmPSFShapeParamsErrors (float *errorFloor, psVector *mag, psVector *e0res, psVector *e1res, psVector *e2res, psVector *mask, int nGroup, psStatsOptions stdevOpt); 132 132 133 133 /// @} -
trunk/psModules/src/objects/pmTrend2D.h
r15696 r15842 5 5 * @author EAM, IfA 6 6 * 7 * @version $Revision: 1. 5$ $Name: not supported by cvs2svn $8 * @date $Date: 2007-1 1-27 03:08:38 $7 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2007-12-15 01:23:18 $ 9 9 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 10 10 */ … … 12 12 # ifndef PM_TREND_2D_H 13 13 # define PM_TREND_2D_H 14 15 #include <pslib.h> 14 16 15 17 /// @addtogroup Objects Object Detection / Analysis Functions … … 26 28 psPolynomial2D *poly; 27 29 psImageMap *map; 28 psStats *stats; 30 psStats *stats; // Statistics for clipped fitting 31 psStatsOptions singleMean, singleStdev; // Staistics for mean and stdev when there's a single pixel 29 32 pmTrend2DMode mode; // POLY_ORD, POLY_CHEB, MAP 30 33 } pmTrend2D;
Note:
See TracChangeset
for help on using the changeset viewer.
