IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 19, 2011, 10:33:39 AM (15 years ago)
Author:
eugene
Message:

optionally save the covariance matrix with model fits

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110213/psModules/src/objects/pmSourceFitSet.c

    r29004 r30705  
    296296
    297297// 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)
     298bool pmSourceFitSetValues (pmSourceFitSetData *set,
     299                           const psVector *dparam, const psVector *param, const psImage *covar,
     300                           pmSource *source, psMinimization *myMin, int nPix,
     301                           bool fitStatus, bool saveCovariance)
    301302{
    302303    PS_ASSERT_PTR_NON_NULL(set, false);
     
    311312
    312313    int n = 0;
     314    int nStart = 0;
    313315    for (int i = 0; i < set->paramSet->n; i++) {
    314316
     
    320322            psTrace ("psModules.objects", 4, "%f +/- %f", param->data.F32[n], dparam->data.F32[n]);
    321323        }
     324        if (saveCovariance) {
     325            // we only save the covar matrix for this object with itself (ignore cross terms between objects)
     326            model->covar = psImageAlloc(model->params->n, model->params->n, PS_TYPE_F32);
     327            for (int ix = 0; ix < model->params->n; ix++) {
     328                for (int iy = 0; iy < model->params->n; iy++) {
     329                    model->covar->data.F32[iy][ix] = covar->data.F32[nStart+iy][nStart+ix];
     330                }
     331            }
     332        }
     333        nStart += model->params->n;
    322334        psTrace ("psModules.objects", 4, " src %d", i);
    323335
     
    550562    }
    551563
    552 // parameter errors from the covariance matrix
     564    // parameter errors from the covariance matrix
    553565    psVector *dparams = psVectorAlloc (thisSet->nParamSet, PS_TYPE_F32);
    554566    for (int i = 0; i < dparams->n; i++) {
     
    558570    }
    559571
    560 // get the Gauss-Newton distance for fixed model parameters
     572    // get the Gauss-Newton distance for fixed model parameters
    561573    if (constraint->paramMask != NULL) {
    562574        psVector *delta = psVectorAlloc (params->n, PS_TYPE_F32);
     
    580592    }
    581593
    582     pmSourceFitSetValues (thisSet, dparams, params, source, myMin, y->n, fitStatus);
     594    pmSourceFitSetValues (thisSet, dparams, params, covar, source, myMin, y->n, fitStatus, options->saveCovariance);
    583595    psTrace ("psModules.objects", 5, "onPic: %d, fitStatus: %d, nIter: %d, chisq: %f, nPix: %ld\n", onPic, fitStatus, myMin->iter, myMin->value, y->n);
    584596
Note: See TracChangeset for help on using the changeset viewer.