Changeset 32347 for trunk/psModules/src/objects/pmPCMdata.c
- Timestamp:
- Sep 6, 2011, 1:02:53 PM (15 years ago)
- Location:
- trunk/psModules/src/objects
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
pmPCMdata.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects
- Property svn:ignore
-
old new 5 5 *.la 6 6 *.lo 7 pmSourceIO_CMF_PS1_V1.c 8 pmSourceIO_CMF_PS1_V2.c 9 pmSourceIO_CMF_PS1_V3.c
-
- Property svn:ignore
-
trunk/psModules/src/objects/pmPCMdata.c
r31451 r32347 41 41 #include "pmPCMdata.h" 42 42 43 # define USE_DELTA_PSF 0 44 # define USE_1D_GAUSS 1 45 43 46 static void pmPCMdataFree (pmPCMdata *pcm) { 44 47 … … 88 91 pcm->constraint = NULL; 89 92 pcm->nDOF = 0; 93 94 // full convolution with the PSF is expensive. if we have to save time, we can do a 1D 95 // convolution with a Gaussian approximation to the kernel 96 pcm->use1Dgauss = false; 97 pcm->nsigma = 3.0; 98 pcm->sigma = 1.0; // this should be set to something sensible when the psf is known 90 99 91 100 return pcm; … … 257 266 pcm->nDOF = nPix - nParams; 258 267 268 # if (USE_1D_GAUSS) 269 pmModel *modelPSF = source->modelPSF; 270 psAssert (modelPSF, "psf model must be defined"); 271 272 psEllipseShape shape; 273 psEllipseAxes axes; 274 275 shape.sx = modelPSF->params->data.F32[PM_PAR_SXX]; 276 shape.sy = modelPSF->params->data.F32[PM_PAR_SYY]; 277 shape.sxy = modelPSF->params->data.F32[PM_PAR_SXY]; 278 axes = psEllipseShapeToAxes (shape, 20.0); 279 280 float FWHM_MAJOR = 2*modelPSF->modelRadius (modelPSF->params, 0.5*modelPSF->params->data.F32[PM_PAR_I0]); 281 float FWHM_MINOR = FWHM_MAJOR * (axes.minor / axes.major); 282 283 pcm->use1Dgauss = true; 284 pcm->sigma = 0.5 * (FWHM_MAJOR + FWHM_MINOR) / 2.35; 285 pcm->nsigma = 2.0; 286 # endif 287 259 288 return pcm; 260 289 } … … 368 397 return true; 369 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
Note:
See TracChangeset
for help on using the changeset viewer.
