IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7331


Ignore:
Timestamp:
Jun 2, 2006, 6:07:30 PM (20 years ago)
Author:
eugene
Message:

fixed mis-counting on blend fits

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphotSourceFits.c

    r6964 r7331  
    263263
    264264    psArray *modelSet = psArrayAlloc (source->blends->n + 1);
    265     // DROP modelSet->n = 0;
    266265    psArrayAdd (modelSet, 16, PSF);
    267266   
    268267    psArray *sourceSet = psArrayAlloc (source->blends->n + 1);
    269     // DROP sourceSet->n = 0;
    270268    psArrayAdd (sourceSet, 16, source);
    271269
     
    279277
    280278        // 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);
    284280        for (int j = 0; j < model->params->n; j++) {
    285281            model->params->data.F32[j] = PSF->params->data.F32[j];
     
    296292        psArrayAdd (modelSet, 16, model);
    297293        psArrayAdd (sourceSet, 16, blend);
     294
     295        // free to avoid double counting model
     296        psFree (model);
    298297    }
    299298
     
    309308    double chiTrend = psPolynomial1DEval (psf->ChiTrend, PSF->params->data.F32[1]);
    310309    PSF->chisqNorm = PSF->chisq / chiTrend;
    311     // PSF->chisqNorm = PSF->chisq;
    312310
    313311    // evaluate the blend objects, subtract if good, free otherwise
    314312    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];
    317315
    318316        // correct model chisq for flux trend
    319317        chiTrend = psPolynomial1DEval (psf->ChiTrend, model->params->data.F32[1]);
    320318        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);
    328323            continue;
    329324        }
    330325
     326        // otherwise, supply the resulting model to the corresponding blend
     327        blend->modelPSF = psMemIncrRefCounter (model);
    331328        psTrace ("psphot.blend", 5, "fitted blend as PSF\n");
    332329        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;
    335332    }
    336333    psFree (modelSet);
     
    339336    // evaluate the primary object
    340337    if (!psphotEvalPSF (source, PSF)) {
     338        psTrace ("psphot.blend", 5, "failed on blend 0 of %d\n", modelSet->n);
    341339        psFree (PSF);
    342340        return false;
Note: See TracChangeset for help on using the changeset viewer.