IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 22, 2010, 6:21:31 PM (16 years ago)
Author:
eugene
Message:

pcm (psf-convolved model) fitting now works (but needs to go faster)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20100621/psModules/src/objects/pmPCMdata.c

    r28692 r28702  
    141141}
    142142
    143 pmPCMdata *pmPCMinit(pmSource *source, pmSourceFitOptions *fitOptions, pmModelType modelType, psImageMaskType maskVal, float psfSize) {
    144 
    145     // make sure we savep a cached copy of the psf flux
     143pmPCMdata *pmPCMinit(pmSource *source, pmSourceFitOptions *fitOptions, pmModel *model, psImageMaskType maskVal, float psfSize) {
     144
     145    // make sure we save a cached copy of the psf flux
    146146    pmSourceCachePSF (source, maskVal);
    147147
    148148    // convert the cached cached psf model for this source to a psKernel
    149149    psKernel *psf = pmPCMkernelFromPSF (source, psfSize);
    150     if (!psf) return NULL;
     150    if (!psf) {
     151        // NOTE: this only happens if the source is too close to an edge
     152        model->flags |= PM_MODEL_STATUS_BADARGS;
     153        return NULL;
     154    }
    151155
    152156# if (USE_DELTA_PSF)
     
    154158    psf->image->data.F32[(int)(0.5*psf->image->numRows)][(int)(0.5*psf->image->numCols)] = 1.0;
    155159# endif
    156 
    157     // allocate the model
    158     pmModel *modelConv = pmModelAlloc(modelType);
    159     if (!modelConv) {
    160         psFree (psf);
    161         return NULL;
    162     }
    163160
    164161    // count the number of unmasked pixels:
     
    183180    }   
    184181
    185     psVector *params  = modelConv->params;
     182    psVector *params  = model->params;
    186183
    187184    // create the minimization constraints
    188185    psMinConstraint *constraint = psMinConstraintAlloc();
    189186    constraint->paramMask = psVectorAlloc (params->n, PS_TYPE_VECTOR_MASK);
    190     constraint->checkLimits = modelConv->modelLimits;
     187    constraint->checkLimits = model->modelLimits;
    191188
    192189    // set parameter mask based on fitting mode
     
    239236    }
    240237
     238    if (nPix <  nParams + 1) {
     239        psTrace ("psModules.objects", 4, "insufficient valid pixels\n");
     240        psFree (psf);
     241        psFree (constraint);
     242        model->flags |= PM_MODEL_STATUS_BADARGS;
     243        return NULL;
     244    }
     245
    241246    // generate PCM data storage structure
    242247    pmPCMdata *pcm = pmPCMdataAlloc (params, constraint->paramMask, source);
    243248
    244     pcm->modelConv = modelConv;
    245249    pcm->psf = psf;
     250    pcm->modelConv = psMemIncrRefCounter(model);
    246251    pcm->constraint = constraint;
    247252
    248     if (nPix <  nParams + 1) {
    249         psTrace ("psModules.objects", 4, "insufficient valid pixels\n");
    250         pcm->modelConv->flags |= PM_MODEL_STATUS_BADARGS;
    251         abort ();
    252         // XXX This should not be an abort!!
    253     }
    254253    pcm->nPix = nPix;
    255254    pcm->nDOF = nPix - nParams - 1;
Note: See TracChangeset for help on using the changeset viewer.