Changeset 7331 for trunk/psphot/src/psphotSourceFits.c
- Timestamp:
- Jun 2, 2006, 6:07:30 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphotSourceFits.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotSourceFits.c
r6964 r7331 263 263 264 264 psArray *modelSet = psArrayAlloc (source->blends->n + 1); 265 // DROP modelSet->n = 0;266 265 psArrayAdd (modelSet, 16, PSF); 267 266 268 267 psArray *sourceSet = psArrayAlloc (source->blends->n + 1); 269 // DROP sourceSet->n = 0;270 268 psArrayAdd (sourceSet, 16, source); 271 269 … … 279 277 280 278 // create the model and guess parameters for this blend 281 blend->modelPSF = pmModelAlloc (PSF->type); 282 pmModel *model = blend->modelPSF; 283 279 pmModel *model = pmModelAlloc (PSF->type); 284 280 for (int j = 0; j < model->params->n; j++) { 285 281 model->params->data.F32[j] = PSF->params->data.F32[j]; … … 296 292 psArrayAdd (modelSet, 16, model); 297 293 psArrayAdd (sourceSet, 16, blend); 294 295 // free to avoid double counting model 296 psFree (model); 298 297 } 299 298 … … 309 308 double chiTrend = psPolynomial1DEval (psf->ChiTrend, PSF->params->data.F32[1]); 310 309 PSF->chisqNorm = PSF->chisq / chiTrend; 311 // PSF->chisqNorm = PSF->chisq;312 310 313 311 // evaluate the blend objects, subtract if good, free otherwise 314 312 for (int i = 1; i < modelSet->n; i++) { 315 pmSource * src= sourceSet->data[i];316 pmModel *model = modelSet->data[i];313 pmSource *blend = sourceSet->data[i]; 314 pmModel *model = modelSet->data[i]; 317 315 318 316 // correct model chisq for flux trend 319 317 chiTrend = psPolynomial1DEval (psf->ChiTrend, model->params->data.F32[1]); 320 318 model->chisqNorm = model->chisq / chiTrend; 321 // model->chisqNorm = model->chisq; 322 323 // if we skip this one, free the corresponding blend entry model 324 if (!psphotEvalPSF (src, model)) { 325 pmSource *blend = source->blends->data[i - 1]; 326 psFree (blend->modelPSF); 327 blend->modelPSF = NULL; 319 320 // if this one failed, skip it 321 if (!psphotEvalPSF (blend, model)) { 322 psTrace ("psphot.blend", 5, "failed on blend %d of %d\n", i, modelSet->n); 328 323 continue; 329 324 } 330 325 326 // otherwise, supply the resulting model to the corresponding blend 327 blend->modelPSF = psMemIncrRefCounter (model); 331 328 psTrace ("psphot.blend", 5, "fitted blend as PSF\n"); 332 329 pmModelSub (source->pixels, source->mask, model, false, false); 333 src->mode |= PM_SOURCE_MODE_SUBTRACTED;334 src->mode &= ~PM_SOURCE_MODE_TEMPSUB;330 blend->mode |= PM_SOURCE_MODE_SUBTRACTED; 331 blend->mode &= ~PM_SOURCE_MODE_TEMPSUB; 335 332 } 336 333 psFree (modelSet); … … 339 336 // evaluate the primary object 340 337 if (!psphotEvalPSF (source, PSF)) { 338 psTrace ("psphot.blend", 5, "failed on blend 0 of %d\n", modelSet->n); 341 339 psFree (PSF); 342 340 return false;
Note:
See TracChangeset
for help on using the changeset viewer.
