- Timestamp:
- Jul 9, 2010, 10:56:32 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20100621/psphot/src/psphotSourceFits.c
r26894 r28643 2 2 3 3 // given a source with an existing modelPSF, attempt a full PSF fit, subtract if successful 4 // XXX this function does not call pmSourceFitModelInit : fix this?5 4 6 5 static int NfitPSF = 0; … … 22 21 } 23 22 24 bool psphotFitBlend (pmReadout *readout, pmSource *source, pmPSF *psf, p sImageMaskType maskVal, psImageMaskType markVal) {23 bool psphotFitBlend (pmReadout *readout, pmSource *source, pmPSF *psf, pmSourceFitOptions *fitOptions, psImageMaskType maskVal, psImageMaskType markVal) { 25 24 26 25 float x, y, dR; 26 27 pmSourceFitOptions options = *fitOptions; 27 28 28 29 // maskVal is used to test for rejected pixels, and must include markVal … … 31 32 // if this source is not a possible blend, just fit as PSF 32 33 if ((source->blends == NULL) || (source->mode & PM_SOURCE_MODE_SATSTAR)) { 33 bool status = psphotFitPSF (readout, source, psf, maskVal, markVal);34 bool status = psphotFitPSF (readout, source, psf, fitOptions, maskVal, markVal); 34 35 return status; 35 36 } … … 91 92 92 93 // fit PSF model 93 pmSourceFitSet (source, modelSet, PM_SOURCE_FIT_PSF, maskVal); 94 options.mode = PM_SOURCE_FIT_PSF; 95 pmSourceFitSet (source, modelSet, &options, maskVal); 94 96 95 97 // clear the circular mask … … 154 156 } 155 157 156 bool psphotFitPSF (pmReadout *readout, pmSource *source, pmPSF *psf, p sImageMaskType maskVal, psImageMaskType markVal) {158 bool psphotFitPSF (pmReadout *readout, pmSource *source, pmPSF *psf, pmSourceFitOptions *fitOptions, psImageMaskType maskVal, psImageMaskType markVal) { 157 159 158 160 double chiTrend; 161 pmSourceFitOptions options = *fitOptions; 159 162 160 163 // maskVal is used to test for rejected pixels, and must include markVal … … 171 174 172 175 // fit PSF model (set/unset the pixel mask) 173 pmSourceFitModel (source, PSF, PM_SOURCE_FIT_PSF, maskVal); 176 options.mode = PM_SOURCE_FIT_PSF; 177 pmSourceFitModel (source, PSF, &options, maskVal); 174 178 175 179 if (!isfinite(PSF->params->data.F32[PM_PAR_I0])) psAbort("nan in fit"); … … 213 217 } 214 218 215 bool psphotFitBlob (pmReadout *readout, pmSource *source, psArray *newSources, pmPSF *psf, p sImageMaskType maskVal, psImageMaskType markVal) {219 bool psphotFitBlob (pmReadout *readout, pmSource *source, psArray *newSources, pmPSF *psf, pmSourceFitOptions *fitOptions, psImageMaskType maskVal, psImageMaskType markVal) { 216 220 217 221 bool okEXT, okDBL; … … 246 250 247 251 // XXX need to handle failures better here 248 EXT = psphotFitEXT (readout, source, modelTypeEXT, maskVal, markVal);252 EXT = psphotFitEXT (readout, source, fitOptions, modelTypeEXT, maskVal, markVal); 249 253 if (!EXT) goto escape; 250 254 if (!isfinite(EXT->params->data.F32[PM_PAR_I0])) goto escape; … … 254 258 255 259 // DBL will always be defined, but DBL->data[n] might not 256 DBL = psphotFitDBL (readout, source, maskVal, markVal);260 DBL = psphotFitDBL (readout, source, fitOptions, maskVal, markVal); 257 261 if (!DBL) goto escape; 258 262 if (!DBL->n) goto escape; … … 379 383 380 384 // fit a double PSF source to an extended blob 381 psArray *psphotFitDBL (pmReadout *readout, pmSource *source, p sImageMaskType maskVal, psImageMaskType markVal) {385 psArray *psphotFitDBL (pmReadout *readout, pmSource *source, pmSourceFitOptions *fitOptions, psImageMaskType maskVal, psImageMaskType markVal) { 382 386 383 387 float dx, dy; … … 387 391 psEllipseMoments moments; 388 392 psArray *modelSet; 393 394 pmSourceFitOptions options = *fitOptions; 389 395 390 396 NfitDBL ++; … … 426 432 427 433 // fit PSF model (set/unset the pixel mask) 428 pmSourceFitSet (source, modelSet, PM_SOURCE_FIT_PSF, maskVal); 434 options.mode = PM_SOURCE_FIT_PSF; 435 pmSourceFitSet (source, modelSet, &options, maskVal); 429 436 return (modelSet); 430 437 } 431 438 432 pmModel *psphotFitEXT (pmReadout *readout, pmSource *source, pmModelType modelType, psImageMaskType maskVal, psImageMaskType markVal) { 439 pmModel *psphotFitEXT (pmReadout *readout, pmSource *source, pmSourceFitOptions *fitOptions, pmModelType modelType, psImageMaskType maskVal, psImageMaskType markVal) { 440 441 pmSourceFitOptions options = *fitOptions; 433 442 434 443 NfitEXT ++; … … 436 445 // maskVal is used to test for rejected pixels, and must include markVal 437 446 maskVal |= markVal; 447 448 psTraceSetLevel("psLib.math.psMinimizeLMChi2", 5); 438 449 439 450 // use the source moments, etc to guess basic model parameters … … 448 459 } 449 460 461 // 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 // } 466 450 467 // fit EXT (not PSF) model (set/unset the pixel mask) 451 pmSourceFitModel (source, EXT, PM_SOURCE_FIT_EXT, maskVal); 468 options.mode = PM_SOURCE_FIT_EXT; 469 pmSourceFitModel (source, EXT, &options, maskVal); 470 471 psTraceSetLevel("psLib.math.psMinimizeLMChi2", 0); 452 472 return (EXT); 453 473 } 474 475 // 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 // }
Note:
See TracChangeset
for help on using the changeset viewer.
