Changeset 28687
- Timestamp:
- Jul 18, 2010, 2:59:19 PM (16 years ago)
- Location:
- branches/eam_branches/ipp-20100621
- Files:
-
- 3 added
- 4 edited
-
ippconfig/recipes/psphot.config (modified) (1 diff)
-
psModules/src/objects/pmPCM_MinimizeChisq.c (added)
-
psModules/src/objects/pmPCMdata.c (added)
-
psModules/src/objects/pmSourceFitPCM.c (added)
-
psModules/src/objects/pmSourcePhotometry.c (modified) (2 diffs)
-
psphot/src/psphotExtendedSourceFits.c (modified) (1 diff)
-
psphot/src/psphotSourceFits.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20100621/ippconfig/recipes/psphot.config
r28658 r28687 92 92 PSF_FIT_MIN_TOL F32 0.01 # Fit tolerance for PSF 93 93 PSF_FIT_MAX_TOL F32 2.00 # Fit tolerance for PSF 94 95 PSF_FIT_MIN_VALID_FLUX F32 1e-8 # minimum allow flux for fitted source 96 PSF_FIT_MAX_VALID_FLUX F32 1e+8 # maximum allow flux for fitted source 94 97 95 98 # the following is used to require a minimum quality of fit before -
branches/eam_branches/ipp-20100621/psModules/src/objects/pmSourcePhotometry.c
r28643 r28687 390 390 # define FLUX_LIMIT 3.0 391 391 392 // return source aperture magnitude393 bool pmSourceMeasureDiffStats (pmSource *source, psImageMaskType maskVal )392 // measure stats that may be using in difference images for distinguishing real sources from bad residuals 393 bool pmSourceMeasureDiffStats (pmSource *source, psImageMaskType maskVal, psImageMaskType markVal) 394 394 { 395 395 PS_ASSERT_PTR_NON_NULL(source, false); … … 411 411 for (int iy = 0; iy < flux->numRows; iy++) { 412 412 for (int ix = 0; ix < flux->numCols; ix++) { 413 // only count up the stats in the unmarked region (ie, the aperture) 414 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] & markVal) { 415 continue; 416 } 413 417 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] & maskVal) { 414 418 nMask ++; -
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.
