- Timestamp:
- Mar 5, 2012, 5:19:48 PM (14 years ago)
- Location:
- branches/meh_branches/ppstack_test
- Files:
-
- 4 edited
-
. (modified) (1 prop)
-
psModules (modified) (1 prop)
-
psModules/src/objects (modified) (1 prop)
-
psModules/src/objects/pmPCMdata.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/meh_branches/ppstack_test
- Property svn:mergeinfo changed
-
branches/meh_branches/ppstack_test/psModules
- Property svn:mergeinfo set to
-
branches/meh_branches/ppstack_test/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 10 pmSourceIO_CMF_PS1_V4.c 11 pmSourceIO_CMF_PS1_V3.v1.c 12 pmSourceIO_CMF_PS1_V1.v1.c 13 pmSourceIO_CMF_PS1_V2.v1.c 14
-
- Property svn:ignore
-
branches/meh_branches/ppstack_test/psModules/src/objects/pmPCMdata.c
r31451 r33415 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 … … 54 57 psFree (pcm->psfFFT); 55 58 psFree (pcm->constraint); 59 psFree (pcm->smdata); // pre-allocated data for psImageSmooth_PreAlloc 56 60 return; 57 61 } … … 88 92 pcm->constraint = NULL; 89 93 pcm->nDOF = 0; 94 95 // full convolution with the PSF is expensive. if we have to save time, we can do a 1D 96 // convolution with a Gaussian approximation to the kernel 97 pcm->use1Dgauss = false; 98 pcm->nsigma = 3.0; 99 pcm->sigma = 1.0; // this should be set to something sensible when the psf is known 90 100 91 101 return pcm; … … 257 267 pcm->nDOF = nPix - nParams; 258 268 269 # if (USE_1D_GAUSS) 270 pmModel *modelPSF = source->modelPSF; 271 psAssert (modelPSF, "psf model must be defined"); 272 273 psEllipseShape shape; 274 psEllipseAxes axes; 275 276 shape.sx = modelPSF->params->data.F32[PM_PAR_SXX]; 277 shape.sy = modelPSF->params->data.F32[PM_PAR_SYY]; 278 shape.sxy = modelPSF->params->data.F32[PM_PAR_SXY]; 279 axes = psEllipseShapeToAxes (shape, 20.0); 280 281 float FWHM_MAJOR = 2*modelPSF->modelRadius (modelPSF->params, 0.5*modelPSF->params->data.F32[PM_PAR_I0]); 282 float FWHM_MINOR = FWHM_MAJOR * (axes.minor / axes.major); 283 284 pcm->use1Dgauss = true; 285 pcm->sigma = 0.5 * (FWHM_MAJOR + FWHM_MINOR) / 2.35; 286 pcm->nsigma = 2.0; 287 288 pcm->smdata = psImageSmooth_PreAlloc_DataAlloc (source->pixels, pcm->sigma, pcm->nsigma); 289 # else 290 pcm->smdata = NULL; 291 # endif 292 259 293 return pcm; 260 294 } … … 364 398 pcm->dmodelsConvFlux->data[n] = psImageCopy (pcm->dmodelsConvFlux->data[n], source->pixels, PS_TYPE_F32); 365 399 } 400 psFree(pcm->smdata); 401 pcm->smdata = psImageSmooth_PreAlloc_DataAlloc (source->pixels, pcm->sigma, pcm->nsigma); 366 402 } 367 403 368 404 return true; 369 405 } 406 407 // construct a realization of the source model 408 bool pmPCMCacheModel (pmSource *source, psImageMaskType maskVal, int psfSize) { 409 410 PS_ASSERT_PTR_NON_NULL(source, false); 411 412 // select appropriate model 413 pmModel *model = pmSourceGetModel (NULL, source); 414 if (model == NULL) return false; // model must be defined 415 416 // if we already have a cached image, re-use that memory 417 source->modelFlux = psImageCopy (source->modelFlux, source->pixels, PS_TYPE_F32); 418 psImageInit (source->modelFlux, 0.0); 419 420 // modelFlux always has unity normalization (I0 = 1.0) 421 pmModelAdd (source->modelFlux, source->maskObj, model, PM_MODEL_OP_FULL | PM_MODEL_OP_NORM, maskVal); 422 423 // convolve the model image with the PSF 424 if (USE_1D_GAUSS) { 425 // do not use the threaded, mask-aware version of this code (psImageSmoothMaskPixelsThread): 426 // * the model flux is not masked 427 // * threading takes place above this level 428 429 // define the Gauss parameters from the psf 430 pmModel *modelPSF = source->modelPSF; 431 psAssert (modelPSF, "psf model must be defined"); 432 433 psEllipseShape shape; 434 psEllipseAxes axes; 435 436 shape.sx = modelPSF->params->data.F32[PM_PAR_SXX]; 437 shape.sy = modelPSF->params->data.F32[PM_PAR_SYY]; 438 shape.sxy = modelPSF->params->data.F32[PM_PAR_SXY]; 439 axes = psEllipseShapeToAxes (shape, 20.0); 440 441 float FWHM_MAJOR = 2*modelPSF->modelRadius (modelPSF->params, 0.5*modelPSF->params->data.F32[PM_PAR_I0]); 442 float FWHM_MINOR = FWHM_MAJOR * (axes.minor / axes.major); 443 444 float sigma = 0.5 * (FWHM_MAJOR + FWHM_MINOR) / 2.35; 445 float nsigma = 2.0; 446 447 psImageSmooth (source->modelFlux, sigma, nsigma); 448 } else { 449 // make sure we save a cached copy of the psf flux 450 pmSourceCachePSF (source, maskVal); 451 452 // convert the cached cached psf model for this source to a psKernel 453 psKernel *psf = pmPCMkernelFromPSF (source, psfSize); 454 if (!psf) { 455 // NOTE: this only happens if the source is too close to an edge 456 model->flags |= PM_MODEL_STATUS_BADARGS; 457 return NULL; 458 } 459 460 // XXX not sure if I can place the output on top of the input 461 psImageConvolveFFT (source->modelFlux, source->modelFlux, NULL, 0, psf); 462 } 463 return true; 464 } 465
Note:
See TracChangeset
for help on using the changeset viewer.
