Changeset 31926
- Timestamp:
- Jul 22, 2011, 5:08:37 PM (15 years ago)
- Location:
- branches/eam_branches/ipp-20110710/psModules/src/objects
- Files:
-
- 4 edited
-
pmPCM_MinimizeChisq.c (modified) (5 diffs)
-
pmPCMdata.c (modified) (3 diffs)
-
pmPCMdata.h (modified) (1 diff)
-
pmSourceFitPCM.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20110710/psModules/src/objects/pmPCM_MinimizeChisq.c
r29012 r31926 45 45 # define USE_FFT 1 46 46 # define PRE_CONVOLVE 1 47 # define TESTCOPY 0 47 48 48 49 bool pmPCM_MinimizeChisq ( … … 93 94 psFree (pcm->psfFFT); 94 95 } 95 pcm->psfFFT = psImageConvolveKernelInit(pcm->modelFlux, pcm->psf); 96 # if (!TESTCOPY) 97 if (!pcm->use1Dgauss) { 98 pcm->psfFFT = psImageConvolveKernelInit(pcm->modelFlux, pcm->psf); 99 } 100 # endif 96 101 # endif 97 102 … … 309 314 # if (PRE_CONVOLVE) 310 315 // convolve model image and derivative images with pre-convolved kernel 311 psImageConvolveKernel (pcm->modelConvFlux, pcm->modelFlux, NULL, 0, pcm->psfFFT); 316 317 // XXX for a test, just copy, rather than convolve 318 # if (TESTCOPY) 319 psImageCopy (pcm->modelConvFlux, pcm->modelFlux, pcm->modelFlux->type.type); 320 # else 321 if (pcm->use1Dgauss) { 322 // do not use the threaded, mask-aware version of this code (psImageSmoothMaskPixelsThread): 323 // * the model flux is not masked 324 // * threading takes place above this level 325 pcm->modelConvFlux = psImageCopy (pcm->modelConvFlux, pcm->modelFlux, pcm->modelFlux->type.type); 326 psImageSmooth (pcm->modelConvFlux, pcm->sigma, pcm->nsigma); 327 } else { 328 psImageConvolveKernel (pcm->modelConvFlux, pcm->modelFlux, NULL, 0, pcm->psfFFT); 329 } 330 # endif 331 312 332 for (int n = 0; n < pcm->dmodelsFlux->n; n++) { 313 333 if (pcm->dmodelsFlux->data[n] == NULL) continue; … … 315 335 psImage *dmodel = pcm->dmodelsFlux->data[n]; 316 336 psImage *dmodelConv = pcm->dmodelsConvFlux->data[n]; 317 psImageConvolveKernel (dmodelConv, dmodel, NULL, 0, pcm->psfFFT); 337 # if (TESTCOPY) 338 psImageCopy (dmodelConv, dmodel, dmodel->type.type); 339 # else 340 if (pcm->use1Dgauss) { 341 // do not use the threaded, mask-aware version of this code (psImageSmoothMaskPixelsThread): 342 // * the model flux is not masked 343 // * threading takes place above this level 344 dmodelConv = psImageCopy (dmodelConv, dmodel, dmodel->type.type); 345 psImageSmooth (dmodelConv, pcm->sigma, pcm->nsigma); 346 } else { 347 psImageConvolveKernel (dmodelConv, dmodel, NULL, 0, pcm->psfFFT); 348 } 349 # endif 318 350 } 319 351 # else … … 325 357 psImage *dmodel = pcm->dmodelsFlux->data[n]; 326 358 psImage *dmodelConv = pcm->dmodelsConvFlux->data[n]; 327 psImageConvolveFFT (dmodelConv, dmodel, NULL, 0, pcm->psf); 359 360 if (pcm->use1Dgauss) { 361 // do not use the threaded, mask-aware version of this code (psImageSmoothMaskPixelsThread): 362 // * the model flux is not masked 363 // * threading takes place above this level 364 dmodelConv = psImageCopy (dmodelConv, dmodel, dmodel->type.type); 365 psImageSmooth (dmodelConv, pcm->sigma, pcm->nsigma); 366 } else { 367 psImageConvolveFFT (dmodelConv, dmodel, NULL, 0, pcm->psf); 368 } 328 369 } 329 370 # endif // PRE-CONVOLVE -
branches/eam_branches/ipp-20110710/psModules/src/objects/pmPCMdata.c
r31451 r31926 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 } -
branches/eam_branches/ipp-20110710/psModules/src/objects/pmPCMdata.h
r31153 r31926 35 35 int nPar; 36 36 int nDOF; 37 38 bool use1Dgauss; 39 float sigma; 40 float nsigma; 37 41 } pmPCMdata; 38 42 -
branches/eam_branches/ipp-20110710/psModules/src/objects/pmSourceFitPCM.c
r31153 r31926 50 50 bool pmSourceFitPCM (pmPCMdata *pcm, pmSource *source, pmSourceFitOptions *fitOptions, psImageMaskType maskVal, psImageMaskType markVal, int psfSize) { 51 51 52 psTimerStart ("pmSourceFitPCM"); 53 52 54 psVector *params = pcm->modelConv->params; 53 55 psVector *dparams = pcm->modelConv->dparams; … … 64 66 psImage *covar = psImageAlloc (params->n, params->n, PS_TYPE_F32); 65 67 68 float t1 = psTimerMark ("pmSourceFitPCM"); 69 66 70 bool fitStatus = pmPCM_MinimizeChisq (myMin, covar, params, source, pcm); 71 float t2 = psTimerMark ("pmSourceFitPCM"); 72 67 73 for (int i = 0; i < dparams->n; i++) { 68 74 if ((pcm->constraint->paramMask != NULL) && pcm->constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) … … 76 82 } 77 83 psTrace ("psphot", 4, "niter: %d, chisq: %f", myMin->iter, myMin->value); 84 float t3 = psTimerMark ("pmSourceFitPCM"); 78 85 79 86 // renormalize output model image (generated by fitting process) … … 97 104 pmSourceChisqUnsubtracted (source, pcm->modelConv, maskVal); 98 105 } 106 float t4 = psTimerMark ("pmSourceFitPCM"); 99 107 100 108 // set the model success or failure status … … 114 122 115 123 source->mode |= PM_SOURCE_MODE_FITTED; // XXX is this needed? 124 float t5 = psTimerMark ("pmSourceFitPCM"); 125 126 if (0) { 127 fprintf (stderr, "nIter: %2d, npix: %5d, t1: %6.4f, t2: %6.4f, t3: %6.4f, t4: %6.4f, t5: %6.4f\n", myMin->iter, pcm->nPix, t1, t2, t3, t4, t5); 128 } 116 129 117 130 psFree(myMin);
Note:
See TracChangeset
for help on using the changeset viewer.
