- Timestamp:
- Aug 21, 2011, 10:44:17 AM (15 years ago)
- Location:
- branches/eam_branches/ipp-20110710/psphot/src
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
psphotExtendedSourceFits.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20110710/psphot/src
- Property svn:ignore
-
old new 22 22 psphotMakePSF 23 23 psphotStack 24 psphotModelTest
-
- Property svn:ignore
-
branches/eam_branches/ipp-20110710/psphot/src/psphotExtendedSourceFits.c
r32023 r32157 316 316 Next ++; 317 317 318 // set the radius based on the first radial moment (also sets the mask pixels) 319 if (!psphotSetRadiusMoments(&fitRadius, &windowRadius, readout, source, markVal)) { 320 fprintf (stderr, "skipping (1) %f, %f\n", source->peak->xf, source->peak->yf); 321 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 322 // XXX raise an error of some kind or set a flag bit 323 continue; 324 } 318 // set the fit radius based on the first radial moment (also sets the mask pixels) 319 psphotSetRadiusMomentsExact(&fitRadius, &windowRadius, readout, source, markVal); 325 320 326 321 // Recalculate the source moments using the larger extended-source moments radius. At … … 332 327 fprintf (stderr, "skipping (2) %f, %f\n", source->peak->xf, source->peak->yf); 333 328 *source->moments = psfMoments; 329 330 // probably need to bump up the size for subtraction 334 331 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 335 332 // XXX raise an error flag of some kind 336 333 continue; 337 334 } 338 339 // save the PSF-based modelFlux here in case we need to subtract it (for failure). If340 // it does not exist, attempt to generate it. Give up if we cannot even do that.341 psImage *modelFluxStart = psMemIncrRefCounter (source->modelFlux);342 if (!modelFluxStart) {343 pmSourceCacheModel (source, maskVal);344 modelFluxStart = psMemIncrRefCounter (source->modelFlux);345 if (!modelFluxStart) {346 fprintf (stderr, "skipping (3) %f, %f\n", source->peak->xf, source->peak->yf);347 *source->moments = psfMoments;348 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);349 // XXX raise an error of some kind?350 continue;351 }352 }353 354 // array to store the pointers to the model flux images while the models are being fitted355 psArray *modelFluxes = psArrayAllocEmpty (models->list->n);356 335 357 336 // allocate the array to store the model fits … … 417 396 continue; 418 397 } 419 pmSourceCacheModel (source, maskVal);420 398 psTrace ("psphot", 4, "fit plain model for %f, %f : %s chisq = %f (npix: %d, niter: %d)\n", 421 399 source->moments->Mx, source->moments->My, pmModelClassGetName (modelFit->type), modelFit->chisq, modelFit->nPix, modelFit->nIter); … … 426 404 } 427 405 } 428 429 // save each of the model flux images for now, and (below) store the best430 psArrayAdd (modelFluxes, 4, source->modelFlux);431 406 432 407 pmSourceExtFitPars *extFitPars = pmSourceExtFitParsAlloc(); … … 477 452 psTrace ("psphot", 5, "failed to fit extended source model to object at %f, %f", source->moments->Mx, source->moments->My); 478 453 479 // replace original model, subtract it 480 psFree (source->modelFlux); 481 source->modelFlux = modelFluxStart; 454 // ensure the modelEXT is cached 455 pmSourceCacheModel (source, maskVal); 482 456 483 457 *source->moments = psfMoments; 484 458 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 485 486 psFree (modelFluxes);487 459 488 460 continue; … … 493 465 source->modelEXT = psMemIncrRefCounter (source->modelFits->data[minModel]); 494 466 495 // save the modelFlux for the best model 496 psFree (source->modelFlux); 497 source->modelFlux = psMemIncrRefCounter (modelFluxes->data[minModel]); 467 // adjust the window so the subtraction covers the faint wings 468 psphotSetRadiusMoments(&fitRadius, &windowRadius, readout, source, markVal); 469 470 // cache the model flux 471 if (source->modelEXT->isPCM) { 472 pmPCMCacheModel (source, maskVal, psfSize); 473 } else { 474 pmSourceCacheModel (source, maskVal); 475 } 498 476 499 477 // replace the original moments … … 502 480 // subtract the best fit from the object, leave local sky 503 481 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 504 505 // the initial model flux is no longer needed506 psFree (modelFluxStart);507 psFree (modelFluxes);508 482 509 483 psTrace ("psphot", 4, "best ext model for %f, %f : %s chisq = %f\n", source->moments->Mx, source->moments->My, pmModelClassGetName (source->modelEXT->type), source->modelEXT->chisq);
Note:
See TracChangeset
for help on using the changeset viewer.
