- Timestamp:
- Nov 22, 2013, 2:43:04 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20130904/psphot/src/psphotGalaxyShape.c
r36247 r36304 253 253 } 254 254 255 float fRmajorBest = NAN; 256 float fRminorBest = NAN; 257 float chisqBest = NAN; 255 258 for (float fRmajor = opt->fRmajorMin; fRmajor < opt->fRmajorMax + 0.5*opt->fRmajorDel; fRmajor += opt->fRmajorDel) { 256 259 for (float fRminor = opt->fRminorMin; fRminor < opt->fRminorMax + 0.5*opt->fRminorDel; fRminor += opt->fRminorDel) { … … 262 265 pmPSF_AxesToModel (PAR, testAxes, modelType); 263 266 264 // where do the results go?? 265 psphotGalaxyShapeSource (pcm, source, maskVal, psfSize); 267 psphotGalaxyShapeSource (pcm, source, maskVal, psfSize, true); 268 269 int i = source->galaxyFits->chisq->n - 1; 270 float thisChisq = source->galaxyFits->chisq->data.F32[i]; 271 if (isfinite(thisChisq) && (!isfinite(chisqBest) || thisChisq < chisqBest)) { 272 chisqBest = thisChisq; 273 fRmajorBest = fRmajor; 274 fRminorBest = fRminor; 275 } 266 276 } 277 } 278 279 if (isfinite(chisqBest)) { 280 // now save the best fitting model as the source's extended model 281 psEllipseAxes testAxes = guessAxes; 282 testAxes.major = guessAxes.major * fRmajorBest; 283 testAxes.minor = guessAxes.minor * fRminorBest; 284 285 pmPSF_AxesToModel (PAR, testAxes, modelType); 286 287 psphotGalaxyShapeSource (pcm, source, maskVal, psfSize, false); 288 289 psFree (source->modelEXT); 290 291 source->modelEXT = psMemIncrRefCounter (pcm->modelConv); 292 source->type = PM_SOURCE_TYPE_EXTENDED; 293 source->mode |= PM_SOURCE_MODE_EXTMODEL; 294 source->mode |= PM_SOURCE_MODE_NONLINEAR_FIT; 295 296 // adjust the window so the subtraction covers the faint wings 297 // psphotSetRadiusMoments(&fitRadius, &windowRadius, readout, source, markVal); 298 299 // cache the model flux 300 pmPCMCacheModel (source, maskVal, psfSize); 267 301 } 268 302 … … 273 307 // fit the given model to the source and find chisq & normalization 274 308 // XXX is this a single-component model? sersic with a supplied index, Reff, axis ratio, and theta? 275 bool psphotGalaxyShapeSource (pmPCMdata *pcm, pmSource *source, psImageMaskType maskVal, int psfSize ) {309 bool psphotGalaxyShapeSource (pmPCMdata *pcm, pmSource *source, psImageMaskType maskVal, int psfSize, bool saveResults) { 276 310 277 311 PS_ASSERT_PTR_NON_NULL(source, false); … … 326 360 float dflux = flux * (dIo / Io); 327 361 328 // Set this to be the model of choice. 329 // XXX: Maybe: figure out which is the best and save that one. 330 { 331 psFree (source->modelEXT); 332 333 source->modelEXT = psMemIncrRefCounter (pcm->modelConv); 334 source->type = PM_SOURCE_TYPE_EXTENDED; 335 source->mode |= PM_SOURCE_MODE_EXTMODEL; 336 source->mode |= PM_SOURCE_MODE_NONLINEAR_FIT; 337 338 // adjust the window so the subtraction covers the faint wings 339 // psphotSetRadiusMoments(&fitRadius, &windowRadius, readout, source, markVal); 340 341 // cache the model flux 342 pmPCMCacheModel (source, maskVal, psfSize); 343 } 344 345 psVectorAppend (source->galaxyFits->Flux, flux); 346 psVectorAppend (source->galaxyFits->dFlux, dflux); 347 psVectorAppend (source->galaxyFits->chisq, Chisq); 348 source->galaxyFits->nPix = nPix; 362 363 if (saveResults) { 364 psVectorAppend (source->galaxyFits->Flux, flux); 365 psVectorAppend (source->galaxyFits->dFlux, dflux); 366 psVectorAppend (source->galaxyFits->chisq, Chisq); 367 source->galaxyFits->nPix = nPix; 368 } 349 369 350 370 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
