Changeset 28687 for branches/eam_branches/ipp-20100621/psphot
- Timestamp:
- Jul 18, 2010, 2:59:19 PM (16 years ago)
- Location:
- branches/eam_branches/ipp-20100621/psphot/src
- Files:
-
- 2 edited
-
psphotExtendedSourceFits.c (modified) (1 diff)
-
psphotSourceFits.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20100621/psphot/src/psphotExtendedSourceFits.c
r28643 r28687 210 210 pmModel *modelFit = NULL; 211 211 if (convolved) { 212 modelFit = psphot PSFConvModel (readout, source, modelType, maskVal, markVal, psfSize);212 modelFit = psphotFitPCM (readout, source, fitOptions, modelType, maskVal, markVal, psfSize); 213 213 if (!modelFit) { 214 214 psTrace ("psphot", 5, "failed to fit psf-conv model for object at %f, %f", source->moments->Mx, source->moments->My); -
branches/eam_branches/ipp-20100621/psphot/src/psphotSourceFits.c
r28677 r28687 476 476 } 477 477 478 pmModel *psphotFitPCM (pmReadout *readout, pmSource *source, pmSourceFitOptions *fitOptions, pmModelType modelType, psImageMaskType maskVal, psImageMaskType markVal) { 479 480 pmSourceFitOptions options = *fitOptions; 481 482 NfitPCM ++; 483 484 // maskVal is used to test for rejected pixels, and must include markVal 485 maskVal |= markVal; 486 487 // psTraceSetLevel("psLib.math.psMinimizeLMChi2", 5); 488 489 // use the source moments, etc to guess basic model parameters 490 pmModel *EXT = pmSourceModelGuess (source, modelType); 491 if (!EXT) { 492 psTrace ("psphot", 5, "failed to generate a model for source: moments: %f %f\n", source->moments->Mxx, source->moments->Myy); 493 return NULL; 494 } 495 496 if ((source->moments->Mxx < 1e-3) || (source->moments->Myy < 1e-3)) { 497 psTrace ("psphot", 5, "problem source: moments: %f %f\n", source->moments->Mxx, source->moments->Myy); 498 } 499 500 // for sersic models, use a grid search to choose an index, then float the params there 501 if (modelType == pmModelClassGetType("PS_MODEL_SERSIC")) { 502 psphotFitSersicIndexPCM (source, EXT, fitOptions, maskVal); 503 } 504 505 if (modelType == pmModelClassGetType("PS_MODEL_SERSIC")) { 506 options.mode = PM_SOURCE_FIT_NO_INDEX; 507 } else { 508 options.mode = PM_SOURCE_FIT_EXT; 509 } 510 pmSourceFitPCM (source, EXT, &options, maskVal); 511 512 // psTraceSetLevel("psLib.math.psMinimizeLMChi2", 0); 513 return (EXT); 514 } 515 478 516 // note that these should be 1/2n of the standard sersic index 479 517 float indexGuess[] = {0.5, 0.33, 0.25, 0.167, 0.125, 0.083}; 518 define N_INDEX_GUESS 6 480 519 481 520 // A sersic model is very sensitive to the index. attempt to find the index first by grid search in just the index … … 491 530 options.nIter = 3; 492 531 493 float xMin, chiSquare[ 3];532 float xMin, chiSquare[N_INDEX_GUESS]; 494 533 int iMin; 495 534 496 for (int i = 0; i < 3; i++) {535 for (int i = 0; i < N_INDEX_GUESS; i++) { 497 536 model->params->data.F32[PM_PAR_7] = indexGuess[i]; 498 537 model->modelGuess(model, source); … … 516 555 return true; 517 556 } 557 558 // A sersic model is very sensitive to the index. attempt to find the index first by grid search in just the index 559 // for a sersic model, attempt to fit just the index and normalization with a modest number of iterations 560 bool psphotFitSersicIndexPCM (pmSource *source, pmModel *model, pmSourceFitOptions *fitOptions, psImageMaskType maskVal) { 561 562 assert (model->type == pmModelClassGetType("PS_MODEL_SERSIC")); 563 564 pmSourceFitOptions options = *fitOptions; 565 566 // fit EXT (not PSF) model (set/unset the pixel mask) 567 options.mode = PM_SOURCE_FIT_NO_INDEX; 568 options.nIter = 3; 569 570 float xMin, chiSquare[N_INDEX_GUESS]; 571 int iMin; 572 573 for (int i = 0; i < N_INDEX_GUESS; i++) { 574 model->params->data.F32[PM_PAR_7] = indexGuess[i]; 575 model->modelGuess(model, source); 576 pmSourceFitPCM (source, model, &options, maskVal); 577 chiSquare[i] = model->chisq; 578 if (i == 0) { 579 xMin = chiSquare[i]; 580 iMin = i; 581 } else { 582 if (chiSquare[i] < xMin) { 583 xMin = chiSquare[i]; 584 iMin = i; 585 } 586 } 587 } 588 589 model->flags = PM_MODEL_STATUS_NONE; // do not attempt to handle failures here, let the next iteration deal with it 590 model->params->data.F32[PM_PAR_7] = indexGuess[iMin]; 591 model->modelGuess(model, source); 592 593 return true; 594 }
Note:
See TracChangeset
for help on using the changeset viewer.
