Changeset 28657
- Timestamp:
- Jul 11, 2010, 3:21:36 PM (16 years ago)
- Location:
- branches/eam_branches/ipp-20100621/psphot/src
- Files:
-
- 6 edited
-
psphotBlendFit.c (modified) (2 diffs)
-
psphotChoosePSF.c (modified) (1 diff)
-
psphotEllipticalContour.c (modified) (1 diff)
-
psphotModelWithPSF.c (modified) (2 diffs)
-
psphotPSFConvModel.c (modified) (2 diffs)
-
psphotSourceFits.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20100621/psphot/src/psphotBlendFit.c
r28643 r28657 65 65 assert (status && fitIter > 0); 66 66 67 float fitTol = psMetadataLookupF32 (&status, recipe, "EXT_FIT_TOL"); // Fit tolerance 68 assert (status && isfinite(fitTol) && fitTol > 0); 67 float fitMinTol = psMetadataLookupF32 (&status, recipe, "EXT_FIT_MIN_TOL"); // Fit tolerance 68 assert (status && isfinite(fitMinTol) && fitMinTol > 0); 69 70 float fitMaxTol = psMetadataLookupF32 (&status, recipe, "EXT_FIT_MAX_TOL"); // Fit tolerance 71 assert (status && isfinite(fitMaxTol) && fitMaxTol > 0); 69 72 70 73 bool poisson = psMetadataLookupBool(&status, recipe, "POISSON.ERRORS.PHOT.LMM"); // Poisson errors? 71 74 assert (status); 75 76 float maxChisqDOF = psMetadataLookupF32 (&status, recipe, "EXT_FIT_MAX_CHISQ"); // Fit tolerance 72 77 73 78 float skySig = psMetadataLookupF32(&status, recipe, "SKY_SIG"); … … 77 82 pmSourceFitOptions *fitOptions = pmSourceFitOptionsAlloc(); 78 83 fitOptions->nIter = fitIter; 79 fitOptions->tol = fitTol; 84 fitOptions->minTol = fitMinTol; 85 fitOptions->maxTol = fitMaxTol; 86 fitOptions->maxChisqDOF = maxChisqDOF; 80 87 fitOptions->poissonErrors = poisson; 81 88 fitOptions->weight = PS_SQR(skySig); -
branches/eam_branches/ipp-20100621/psphot/src/psphotChoosePSF.c
r28643 r28657 138 138 return false; 139 139 } 140 float fitTol = psMetadataLookupF32 (&status, recipe, "PSF_FIT_TOL"); // Fit tolerance 141 if (!status || !isfinite(fitTol) || fitTol <= 0) { 142 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "PSF_FIT_TOL is not positive"); 143 return false; 144 } 140 float fitMinTol = psMetadataLookupF32 (&status, recipe, "PSF_FIT_MIN_TOL"); // Fit tolerance 141 if (!status || !isfinite(fitMinTol) || fitMinTol <= 0) { 142 fitMinTol = psMetadataLookupF32 (&status, recipe, "PSF_FIT_TOL"); // Fit tolerance 143 if (!status || !isfinite(fitMinTol) || fitMinTol <= 0) { 144 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "PSF_FIT_MIN_TOL (and PSF_FIT_TOL) not defined or positive"); 145 return false; 146 } 147 } 148 float fitMaxTol = psMetadataLookupF32 (&status, recipe, "PSF_FIT_MAX_TOL"); // Fit tolerance 149 if (!status || !isfinite(fitMaxTol) || fitMaxTol <= 0) { 150 fitMaxTol = 1.0; 151 } 152 float maxChisqDOF = psMetadataLookupF32 (&status, recipe, "PSF_FIT_MAX_CHISQ"); // Fit tolerance 145 153 146 154 // options which modify the behavior of the model fitting 147 155 options->fitOptions = pmSourceFitOptionsAlloc(); 148 156 options->fitOptions->nIter = fitIter; 149 options->fitOptions->tol = fitTol; 157 options->fitOptions->minTol = fitMinTol; 158 options->fitOptions->maxTol = fitMaxTol; 159 options->fitOptions->maxChisqDOF = maxChisqDOF; 150 160 options->fitOptions->poissonErrors = options->poissonErrorsPhotLMM; 151 161 options->fitOptions->weight = PS_SQR(SKY_SIG); -
branches/eam_branches/ipp-20100621/psphot/src/psphotEllipticalContour.c
r27819 r28657 82 82 params->data.F32[PAR_RMIN] = Rmin; 83 83 84 psMinimization *myMin = psMinimizationAlloc (25, 0.0 01);84 psMinimization *myMin = psMinimizationAlloc (25, 0.01, 1.00); 85 85 psImage *covar = psImageAlloc (params->n, params->n, PS_TYPE_F32); 86 86 -
branches/eam_branches/ipp-20100621/psphot/src/psphotModelWithPSF.c
r21366 r28657 73 73 74 74 // iterate until the tolerance is reached, or give up 75 while ((min->iter < min->maxIter) && ((min->lastDelta > min-> tol) || !isfinite(min->lastDelta))) {75 while ((min->iter < min->maxIter) && ((min->lastDelta > min->minTol) || !isfinite(min->lastDelta))) { 76 76 psTrace("psphot", 5, "Iteration number %d. (max iterations is %d).\n", min->iter, min->maxIter); 77 psTrace("psphot", 5, "Last delta is %f. Min-> tol is %f.\n", min->lastDelta, min->tol);77 psTrace("psphot", 5, "Last delta is %f. Min->minTol is %f.\n", min->lastDelta, min->minTol); 78 78 79 79 … … 166 166 psFree(pcm); 167 167 168 if (min->iter == min->maxIter) {169 psTrace("psphot", 3, "---- end (false) ----\n");170 return(false);171 }172 173 psTrace("psphot", 3, "---- end (true) ----\n");174 return( true);168 // if the last improvement was at least as good as maxTol, accept the fit: 169 if (min->lastDelta <= min->maxTol) { 170 psTrace("psphot", 6, "---- end (true) ----\n"); 171 return(true); 172 } 173 psTrace("psphot", 6, "---- end (false) ----\n"); 174 return(false); 175 175 } 176 176 -
branches/eam_branches/ipp-20100621/psphot/src/psphotPSFConvModel.c
r26894 r28657 4 4 // save as static values so they may be set externally 5 5 static psF32 PM_SOURCE_FIT_MODEL_NUM_ITERATIONS = 15; 6 static psF32 PM_SOURCE_FIT_MODEL_TOLERANCE = 0.1; 6 static psF32 PM_SOURCE_FIT_MODEL_MIN_TOL = 0.1; 7 static psF32 PM_SOURCE_FIT_MODEL_MAX_TOL = 2.0; 7 8 8 9 // input source has both modelPSF and modelEXT. on successful exit, we set the … … 90 91 91 92 // set up the minimization process 92 psMinimization *myMin = psMinimizationAlloc (PM_SOURCE_FIT_MODEL_NUM_ITERATIONS, PM_SOURCE_FIT_MODEL_ TOLERANCE);93 psMinimization *myMin = psMinimizationAlloc (PM_SOURCE_FIT_MODEL_NUM_ITERATIONS, PM_SOURCE_FIT_MODEL_MIN_TOL, PM_SOURCE_FIT_MODEL_MAX_TOL); 93 94 94 95 psImage *covar = psImageAlloc (params->n, params->n, PS_TYPE_F32); -
branches/eam_branches/ipp-20100621/psphot/src/psphotSourceFits.c
r28643 r28657 1 1 # include "psphotInternal.h" 2 bool psphotFitSersicIndex (pmSource *source, pmModel *model, pmSourceFitOptions *fitOptions, psImageMaskType maskVal); 2 3 3 4 // given a source with an existing modelPSF, attempt a full PSF fit, subtract if successful … … 460 461 461 462 // for sersic models, get the initial guess more carefully 462 // if (modelType == pmModelClassGetType("PS_MODEL_SERSIC")) { 463 // psphotGuessSersic (); 464 // // test and return NULL on failure? 465 // } 463 if (modelType == pmModelClassGetType("PS_MODEL_SERSIC")) { 464 psphotFitSersicIndex (source, EXT, fitOptions, maskVal); 465 } 466 466 467 467 // fit EXT (not PSF) model (set/unset the pixel mask) … … 473 473 } 474 474 475 float indexGuess[] = {0.5, 0.25, 0.125}; 476 475 477 // A sersic model is very sensitive to the index. attempt to find the index first by grid search in just the index 476 // bool psphotFitSersic (pmReadout *readout, pmSource *source, pmSourceFitOptions *fitOptions, pmModelType modelType, psImageMaskType maskVal, psImageMaskType markVal) { 477 // 478 // assert (model->type == pmModelClassGetType("PS_MODEL_SERSIC")); 479 // 480 // 481 // 482 // if (!model->modelGuess(model, source)) { 483 // } 484 // 485 // 486 // } 478 // for a sersic model, attempt to fit just the index and normalization with a modest number of iterations 479 bool psphotFitSersicIndex (pmSource *source, pmModel *model, pmSourceFitOptions *fitOptions, psImageMaskType maskVal) { 480 481 assert (model->type == pmModelClassGetType("PS_MODEL_SERSIC")); 482 483 pmSourceFitOptions options = *fitOptions; 484 485 // fit EXT (not PSF) model (set/unset the pixel mask) 486 options.mode = PM_SOURCE_FIT_NO_INDEX; 487 options.nIter = 3; 488 489 float xMin, chiSquare[3]; 490 int iMin; 491 492 for (int i = 0; i < 3; i++) { 493 model->params->data.F32[PM_PAR_7] = indexGuess[i]; 494 model->modelGuess(model, source); 495 pmSourceFitModel (source, model, &options, maskVal); 496 chiSquare[i] = model->chisq; 497 if (i == 0) { 498 xMin = chiSquare[i]; 499 iMin = i; 500 } else { 501 if (chiSquare[i] < xMin) { 502 xMin = chiSquare[i]; 503 iMin = i; 504 } 505 } 506 } 507 508 model->flags = PM_MODEL_STATUS_NONE; // do not attempt to handle failures here, let the next iteration deal with it 509 model->params->data.F32[PM_PAR_7] = indexGuess[iMin]; 510 model->modelGuess(model, source); 511 512 return true; 513 }
Note:
See TracChangeset
for help on using the changeset viewer.
