Changeset 32152
- Timestamp:
- Aug 21, 2011, 10:26:47 AM (15 years ago)
- Location:
- branches/eam_branches/ipp-20110710/psModules/src/objects
- Files:
-
- 2 edited
-
pmPCMdata.c (modified) (1 diff)
-
pmPCMdata.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20110710/psModules/src/objects/pmPCMdata.c
r31926 r32152 397 397 return true; 398 398 } 399 400 // construct a realization of the source model 401 bool pmPCMCacheModel (pmSource *source, psImageMaskType maskVal, int psfSize) { 402 403 PS_ASSERT_PTR_NON_NULL(source, false); 404 405 // select appropriate model 406 pmModel *model = pmSourceGetModel (NULL, source); 407 if (model == NULL) return false; // model must be defined 408 409 // if we already have a cached image, re-use that memory 410 source->modelFlux = psImageCopy (source->modelFlux, source->pixels, PS_TYPE_F32); 411 psImageInit (source->modelFlux, 0.0); 412 413 // modelFlux always has unity normalization (I0 = 1.0) 414 pmModelAdd (source->modelFlux, source->maskObj, model, PM_MODEL_OP_FULL | PM_MODEL_OP_NORM, maskVal); 415 416 // convolve the model image with the PSF 417 if (USE_1D_GAUSS) { 418 // do not use the threaded, mask-aware version of this code (psImageSmoothMaskPixelsThread): 419 // * the model flux is not masked 420 // * threading takes place above this level 421 422 // define the Gauss parameters from the psf 423 pmModel *modelPSF = source->modelPSF; 424 psAssert (modelPSF, "psf model must be defined"); 425 426 psEllipseShape shape; 427 psEllipseAxes axes; 428 429 shape.sx = modelPSF->params->data.F32[PM_PAR_SXX]; 430 shape.sy = modelPSF->params->data.F32[PM_PAR_SYY]; 431 shape.sxy = modelPSF->params->data.F32[PM_PAR_SXY]; 432 axes = psEllipseShapeToAxes (shape, 20.0); 433 434 float FWHM_MAJOR = 2*modelPSF->modelRadius (modelPSF->params, 0.5*modelPSF->params->data.F32[PM_PAR_I0]); 435 float FWHM_MINOR = FWHM_MAJOR * (axes.minor / axes.major); 436 437 float sigma = 0.5 * (FWHM_MAJOR + FWHM_MINOR) / 2.35; 438 float nsigma = 2.0; 439 440 psImageSmooth (source->modelFlux, sigma, nsigma); 441 } else { 442 // make sure we save a cached copy of the psf flux 443 pmSourceCachePSF (source, maskVal); 444 445 // convert the cached cached psf model for this source to a psKernel 446 psKernel *psf = pmPCMkernelFromPSF (source, psfSize); 447 if (!psf) { 448 // NOTE: this only happens if the source is too close to an edge 449 model->flags |= PM_MODEL_STATUS_BADARGS; 450 return NULL; 451 } 452 453 // XXX not sure if I can place the output on top of the input 454 psImageConvolveFFT (source->modelFlux, source->modelFlux, NULL, 0, psf); 455 } 456 return true; 457 } 458 -
branches/eam_branches/ipp-20110710/psModules/src/objects/pmPCMdata.h
r31926 r32152 94 94 bool pmSourceFitPCM (pmPCMdata *pcm, pmSource *source, pmSourceFitOptions *fitOptions, psImageMaskType maskVal, psImageMaskType markVal, int psfSize); 95 95 96 bool pmPCMCacheModel (pmSource *source, psImageMaskType maskVal, int psfSize); 96 97 97 98 /// @}
Note:
See TracChangeset
for help on using the changeset viewer.
