Changeset 31153 for trunk/psModules/src/objects/pmSourceFitSet.c
- Timestamp:
- Apr 4, 2011, 1:04:41 PM (15 years ago)
- Location:
- trunk/psModules
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
src/objects/pmSourceFitSet.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules
- Property svn:ignore
-
old new 28 28 ChangeLog 29 29 psmodules-*.tar.* 30 a.out.dSYM
-
- Property svn:ignore
-
trunk/psModules/src/objects/pmSourceFitSet.c
r29004 r31153 39 39 #include "pmSourceDiffStats.h" 40 40 #include "pmSource.h" 41 #include "pmSourcePhotometry.h" 41 42 42 43 #include "pmSourceFitModel.h" … … 296 297 297 298 // set the model parameters for this fit set 298 bool pmSourceFitSetValues (pmSourceFitSetData *set, const psVector *dparam, 299 const psVector *param, pmSource *source, 300 psMinimization *myMin, int nPix, bool fitStatus) 299 bool pmSourceFitSetValues (pmSourceFitSetData *set, 300 const psVector *dparam, const psVector *param, const psImage *covar, 301 pmSource *source, psMinimization *myMin, int nPix, 302 bool fitStatus, pmSourceFitOptions *options, psImageMaskType maskVal) 301 303 { 302 304 PS_ASSERT_PTR_NON_NULL(set, false); … … 311 313 312 314 int n = 0; 315 int nStart = 0; 313 316 for (int i = 0; i < set->paramSet->n; i++) { 314 317 … … 320 323 psTrace ("psModules.objects", 4, "%f +/- %f", param->data.F32[n], dparam->data.F32[n]); 321 324 } 325 if (options->saveCovariance) { 326 // we only save the covar matrix for this object with itself (ignore cross terms between objects) 327 model->covar = psImageAlloc(model->params->n, model->params->n, PS_TYPE_F32); 328 for (int ix = 0; ix < model->params->n; ix++) { 329 for (int iy = 0; iy < model->params->n; iy++) { 330 model->covar->data.F32[iy][ix] = covar->data.F32[nStart+iy][nStart+ix]; 331 } 332 } 333 } 334 nStart += model->params->n; 322 335 psTrace ("psModules.objects", 4, " src %d", i); 336 337 model->nIter = myMin->iter; 338 // model->nPar is set by pmSourceFitSetMasks 323 339 324 340 // save the resulting chisq, nDOF, nIter 325 341 // these are not unique for any one source 326 model->chisq = myMin->value; 327 model->nIter = myMin->iter; 328 model->nDOF = nPix - model->params->n; 342 if (options->poissonErrors) { 343 model->chisq = myMin->value; 344 model->nPix = nPix; 345 model->nDOF = nPix - model->nPar; 346 model->chisqNorm = model->chisq / model->nDOF; 347 } else { 348 pmSourceChisqUnsubtracted (source, model, maskVal); 349 } 329 350 330 351 // set the model success or failure status … … 380 401 for (int i = 0; i < set->paramSet->n; i++) { 381 402 psVector *paramOne = set->paramSet->data[i]; 403 pmModel *modelOne = set->modelSet->data[i]; 382 404 383 405 switch (mode) { … … 387 409 if (j == PM_PAR_I0) continue; 388 410 constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[n + j] = 1; 411 modelOne->nPar = 1; 389 412 } 390 413 break; … … 396 419 if (j == PM_PAR_I0) continue; 397 420 constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[n + j] = 1; 421 modelOne->nPar = 3; 398 422 } 399 423 break; … … 401 425 // EXT model fits all params (except sky) 402 426 constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[n + PM_PAR_SKY] = 1; 427 modelOne->nPar = paramOne->n - 1; 403 428 break; 404 429 default: … … 550 575 } 551 576 552 // parameter errors from the covariance matrix577 // parameter errors from the covariance matrix 553 578 psVector *dparams = psVectorAlloc (thisSet->nParamSet, PS_TYPE_F32); 554 579 for (int i = 0; i < dparams->n; i++) { … … 558 583 } 559 584 560 // get the Gauss-Newton distance for fixed model parameters585 // get the Gauss-Newton distance for fixed model parameters 561 586 if (constraint->paramMask != NULL) { 562 587 psVector *delta = psVectorAlloc (params->n, PS_TYPE_F32); … … 580 605 } 581 606 582 pmSourceFitSetValues (thisSet, dparams, params, source, myMin, y->n, fitStatus);607 pmSourceFitSetValues (thisSet, dparams, params, covar, source, myMin, y->n, fitStatus, options, maskVal); 583 608 psTrace ("psModules.objects", 5, "onPic: %d, fitStatus: %d, nIter: %d, chisq: %f, nPix: %ld\n", onPic, fitStatus, myMin->iter, myMin->value, y->n); 584 609
Note:
See TracChangeset
for help on using the changeset viewer.
