- Timestamp:
- Oct 22, 2013, 6:27:11 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20130904/psModules/src/objects/pmPCMdata.c
r36207 r36228 248 248 } 249 249 250 // generate a Gaussian smoothing kernel for supplied sigma. sigma here does not need to match 251 // that used to allocate the structure, but it is recommended 252 bool psImageSmoothCacheKernel_PS1_V1 (psImageSmoothCacheData *smdata, float sigma, float kappa) { 253 // check for NULL structure elements? 254 255 int size = smdata->Nrange + 1; 256 257 smdata->kernel = psVectorAlloc(2 * smdata->Nrange + 1, PS_TYPE_F32); 258 259 double sum = 0.0; // Sum of Gaussian, for normalization 260 double factor = 1.0 / (sigma * M_SQRT2); // Multiplier for i -> z 261 262 // PS1_V1 is a power-law with fitted linear term: 263 // 1 / (1 + kappa z + z^1.666) where z = (r/sigma)^2 264 265 // generate the kernel (not normalized) 266 for (int i = -size, j = 0; i <= size; i++, j++) { 267 float z = i / sigma / M_SQRT2; 268 sum += smdata->kernel->data.F32[j] = 1.0 / (1 + kappa * z + pow(z,1.666)); 269 } 270 271 // renormalize kernel to integral of 1.0 272 for (int i = 0; i < 2 * size + 1; i++) { 273 smdata->kernel->data.F32[i] /= sum; 274 } 275 276 return true; 277 } 278 250 279 pmPCMdata *pmPCMinit(pmSource *source, pmSourceFitOptions *fitOptions, pmModel *model, psImageMaskType maskVal, float psfSize) { 251 280 … … 312 341 pcm->nsigma = 2.0; 313 342 314 pcm->smdata = psImageSmooth_PreAlloc_DataAlloc (source->pixels, pcm->sigma, pcm->nsigma); 343 // psImageSmoothCacheAlloc generates a structure but does not assign the smoothing vector 344 pcm->smdata = psImageSmoothCacheAlloc (source->pixels, pcm->sigma, pcm->nsigma); 345 346 float v1sigma = 0.5 * (axes.major + axes.minor); 347 psImageSmoothCacheKernel_Gauss (pcm->smdata, v1sigma, PAR[PM_PAR_7]); 348 315 349 # else 316 350 // make sure we save a cached copy of the psf flux … … 396 430 psFree(pcm->smdata); 397 431 pcm->smdata = psImageSmooth_PreAlloc_DataAlloc (source->pixels, pcm->sigma, pcm->nsigma); 432 433 // psImageSmoothCacheAlloc generates a structure but does not assign the smoothing vector 434 pcm->smdata = psImageSmoothCacheAlloc (source->pixels, pcm->sigma, pcm->nsigma); 435 436 float v1sigma = 0.5 * (axes.major + axes.minor); 437 psImageSmoothCacheKernel_Gauss (pcm->smdata, v1sigma, PAR[PM_PAR_7]); 398 438 } 399 439 … … 439 479 440 480 psImageSmooth (source->modelFlux, sigma, nsigma); 481 482 // psImageSmoothCacheAlloc generates a structure but does not assign the smoothing vector 483 pcm->smdata = psImageSmoothCacheAlloc (source->pixels, pcm->sigma, pcm->nsigma); 484 485 float v1sigma = 0.5 * (axes.major + axes.minor); 486 psImageSmoothCacheKernel_Gauss (pcm->smdata, v1sigma, PAR[PM_PAR_7]); 487 488 psImageSmoothCache_F32 (source->modelFlux, pcm->smdata); 441 489 } else { 442 490 // make sure we save a cached copy of the psf flux
Note:
See TracChangeset
for help on using the changeset viewer.
