- Timestamp:
- Jul 11, 2010, 3:21:36 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.
