Changeset 36235
- Timestamp:
- Oct 23, 2013, 10:31:13 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20130904/psModules/src/objects/pmPCMdata.c
r36233 r36235 249 249 } 250 250 251 static int modelType_GAUSS = -1; 252 static int modelType_PS1_V1 = -1; 253 251 254 // generate a Gaussian smoothing kernel for supplied sigma. sigma here does not need to match 252 255 // that used to allocate the structure, but it is recommended … … 279 282 } 280 283 284 psImageSmoothCacheData *psImageSmoothCacheSetKernel (float *sigma, float *kappa, psImage *flux, pmModel *modelPSF) { 285 286 psAssert (modelPSF, "psf model must be defined"); 287 288 psEllipseAxes axes; 289 bool useReff = pmModelUseReff (modelPSF->type); 290 psF32 *PAR = modelPSF->params->data.F32; 291 pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], useReff); 292 293 float nsigma = 2.0; 294 *sigma = NAN; 295 *kappa = NAN; 296 297 if (modelPSF->type == modelType_GAUSS) { 298 float FWHM_MAJOR = 2*modelPSF->modelRadius (modelPSF->params, 0.5*PAR[PM_PAR_I0]); 299 float FWHM_MINOR = FWHM_MAJOR * (axes.minor / axes.major); 300 *sigma = 0.5 * (FWHM_MAJOR + FWHM_MINOR) / 2.35; 301 } 302 if (modelPSF->type == modelType_PS1_V1) { 303 *sigma = 0.5 * (axes.major + axes.minor); 304 *kappa = PAR[PM_PAR_7]; 305 } 306 psAssert (isfinite(*sigma), "invalid model type"); 307 308 // psImageSmoothCacheAlloc generates a structure but does not assign the smoothing vector 309 psImageSmoothCacheData *smdata = psImageSmoothCacheAlloc (flux, *sigma, nsigma); 310 311 if (modelPSF->type == modelType_GAUSS) { 312 psImageSmoothCacheKernel_Gauss (smdata, *sigma); 313 } 314 if (modelPSF->type == modelType_PS1_V1) { 315 psImageSmoothCacheKernel_PS1_V1 (smdata, *sigma, *kappa); 316 } 317 318 return smdata; 319 } 320 281 321 pmPCMdata *pmPCMinit(pmSource *source, pmSourceFitOptions *fitOptions, pmModel *model, psImageMaskType maskVal, float psfSize) { 322 323 modelType_GAUSS = pmModelClassGetType ("PS_MODEL_GAUSS"); 324 modelType_PS1_V1 = pmModelClassGetType ("PS_MODEL_PS1_V1"); 282 325 283 326 // count the number of unmasked pixels: … … 328 371 329 372 # if (USE_1D_GAUSS) 330 pmModel *modelPSF = source->modelPSF; 331 psAssert (modelPSF, "psf model must be defined"); 332 333 psEllipseAxes axes; 334 bool useReff = pmModelUseReff (modelPSF->type); 335 psF32 *PAR = modelPSF->params->data.F32; 336 pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], useReff); 337 373 338 374 pcm->use1Dgauss = true; 339 pcm->nsigma = 2.0; 340 341 // XXX use these lines for a GAUSS kernel: 342 // float FWHM_MAJOR = 2*modelPSF->modelRadius (modelPSF->params, 0.5*PAR[PM_PAR_I0]); 343 // float FWHM_MINOR = FWHM_MAJOR * (axes.minor / axes.major); 344 // pcm->sigma = 0.5 * (FWHM_MAJOR + FWHM_MINOR) / 2.35; 345 346 // XXX use these lines for a PS1_V1 kernel 347 pcm->sigma = 0.5 * (axes.major + axes.minor); 348 pcm->kappa = PAR[PM_PAR_7]; 349 350 // psImageSmoothCacheAlloc generates a structure but does not assign the smoothing vector 351 pcm->smdata = psImageSmoothCacheAlloc (source->pixels, pcm->sigma, pcm->nsigma); 352 353 // XXX use this for GAUSS kernel: 354 // psImageSmoothCacheKernel_Gauss (pcm->smdata, pcm->sigma); 355 356 // XXX use these lines for a PS1_V1 kernel 357 psImageSmoothCacheKernel_PS1_V1 (pcm->smdata, pcm->sigma, pcm->kappa); 375 pcm->smdata = psImageSmoothCacheSetKernel (&pcm->sigma, &pcm->kappa, source->pixels, source->modelPSF); 376 358 377 # else 359 378 // make sure we save a cached copy of the psf flux … … 440 459 pcm->smdata = psImageSmoothCacheAlloc (source->pixels, pcm->sigma, pcm->nsigma); 441 460 442 // XXX use this for GAUSS kernel: 443 // psImageSmoothCacheKernel_Gauss (pcm->smdata, pcm->sigma); 444 445 // XXX use these lines for a PS1_V1 kernel 446 psImageSmoothCacheKernel_PS1_V1 (pcm->smdata, pcm->sigma, pcm->kappa); 461 pmModel *modelPSF = source->modelPSF; 462 if (modelPSF->type == modelType_GAUSS) { 463 psImageSmoothCacheKernel_Gauss (pcm->smdata, pcm->sigma); 464 } 465 if (modelPSF->type == modelType_PS1_V1) { 466 psImageSmoothCacheKernel_PS1_V1 (pcm->smdata, pcm->sigma, pcm->kappa); 467 } 447 468 } 448 469 … … 468 489 // convolve the model image with the PSF 469 490 if (USE_1D_GAUSS) { 470 // do not use the threaded, mask-aware version of this code (psImageSmoothMaskPixelsThread):471 // * the model flux is not masked472 // * threading takes place above this level473 491 474 // define the Gauss parameters from the psf 475 pmModel *modelPSF = source->modelPSF; 476 psAssert (modelPSF, "psf model must be defined"); 477 478 psEllipseAxes axes; 479 bool useReff = pmModelUseReff (modelPSF->type); 480 psF32 *PAR = modelPSF->params->data.F32; 481 pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], useReff); 482 483 float nsigma = 2.0; 484 485 // XXX use these for a GAUSS kernel 486 // float FWHM_MAJOR = 2*modelPSF->modelRadius (modelPSF->params, 0.5*PAR[PM_PAR_I0]); 487 // float FWHM_MINOR = FWHM_MAJOR * (axes.minor / axes.major); 488 // float sigma = 0.5 * (FWHM_MAJOR + FWHM_MINOR) / 2.35; 489 490 float sigma = 0.5 * (axes.major + axes.minor); 491 float kappa = PAR[PM_PAR_7]; 492 493 // psImageSmoothCacheAlloc generates a structure but does not assign the smoothing vector 494 psImageSmoothCacheData *smdata = psImageSmoothCacheAlloc (source->modelFlux, sigma, nsigma); 495 496 psImageSmoothCacheKernel_PS1_V1 (smdata, sigma, kappa); 497 // XXX psImageSmoothCacheKernel_GAUSS (smdata, sigma); 492 float sigma = NAN; 493 float kappa = NAN; 494 psImageSmoothCacheData *smdata = psImageSmoothCacheSetKernel (&sigma, &kappa, source->modelFlux, source->modelPSF); 498 495 499 496 psImageSmoothCache_F32 (source->modelFlux, smdata); 500 psFree(smdata);497 psFree (smdata); 501 498 502 499 // old call: psImageSmooth (source->modelFlux, sigma, nsigma); … … 533 530 // convolve the model image with the PSF 534 531 if (USE_1D_GAUSS) { 535 // do not use the threaded, mask-aware version of this code (psImageSmoothMaskPixelsThread): 536 // * the model flux is not masked 537 // * threading takes place above this level 538 539 // define the Gauss parameters from the psf 540 pmModel *modelPSF = source->modelPSF; 541 psAssert (modelPSF, "psf model must be defined"); 542 543 psEllipseAxes axes; 544 bool useReff = pmModelUseReff (modelPSF->type); 545 psF32 *PAR = modelPSF->params->data.F32; 546 pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], useReff); 547 548 float nsigma = 2.0; 549 550 // float FWHM_MAJOR = 2*modelPSF->modelRadius (modelPSF->params, 0.5*PAR[PM_PAR_I0]); 551 // float FWHM_MINOR = FWHM_MAJOR * (axes.minor / axes.major); 552 // float sigma = 0.5 * (FWHM_MAJOR + FWHM_MINOR) / 2.35; 553 554 float sigma = 0.5 * (axes.major + axes.minor); 555 float kappa = PAR[PM_PAR_7]; 556 557 // psImageSmoothCacheAlloc generates a structure but does not assign the smoothing vector 558 psImageSmoothCacheData *smdata = psImageSmoothCacheAlloc (source->modelFlux, sigma, nsigma); 559 560 psImageSmoothCacheKernel_PS1_V1 (smdata, sigma, kappa); 561 // XXX psImageSmoothCacheKernel_GAUSS (smdata, sigma); 532 533 float sigma = NAN; 534 float kappa = NAN; 535 psImageSmoothCacheData *smdata = psImageSmoothCacheSetKernel (&sigma, &kappa, source->modelFlux, source->modelPSF); 562 536 563 537 psImageSmoothCache_F32 (source->modelFlux, smdata); … … 582 556 return true; 583 557 } 584
Note:
See TracChangeset
for help on using the changeset viewer.
