IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 26507


Ignore:
Timestamp:
Jan 4, 2010, 10:07:31 AM (16 years ago)
Author:
eugene
Message:

allow EXT or DBL to fail more gracefully

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20091201/psphot/src/psphotSourceFits.c

    r25755 r26507  
    219219    double chiTrend;
    220220    pmModel *ONE = NULL;
     221    pmSource *tmpSrc = NULL;
     222    pmModel *EXT = NULL;
     223    psArray *DBL = NULL;
    221224
    222225    // skip the source if we don't think it is extended
     
    240243
    241244    // this temporary source is used as a place-holder by the psphotEval functions below
    242     pmSource *tmpSrc = pmSourceAlloc ();
     245    tmpSrc = pmSourceAlloc ();
    243246
    244247    // XXX need to handle failures better here
    245     pmModel *EXT = psphotFitEXT (readout, source, modelTypeEXT, maskVal, markVal);
    246     if (!isfinite(EXT->params->data.F32[PM_PAR_I0])) psAbort("nan in fit");
     248    EXT = psphotFitEXT (readout, source, modelTypeEXT, maskVal, markVal);
     249    if (!EXT) goto escape;
     250    if (!isfinite(EXT->params->data.F32[PM_PAR_I0])) goto escape;
    247251
    248252    okEXT = psphotEvalEXT (tmpSrc, EXT);
     
    250254
    251255    // DBL will always be defined, but DBL->data[n] might not
    252     psArray *DBL = psphotFitDBL (readout, source, maskVal, markVal);
     256    DBL = psphotFitDBL (readout, source, maskVal, markVal);
     257    if (!DBL) goto escape;
     258    if (!DBL->n) goto escape;
     259
    253260    okDBL  = psphotEvalDBL (tmpSrc, DBL->data[0]);
    254261    okDBL &= psphotEvalDBL (tmpSrc, DBL->data[1]);
     
    362369    psFree (DBL);
    363370    return true;
     371
     372escape:
     373    psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal));
     374    psFree (tmpSrc);
     375    psFree (EXT);
     376    psFree (DBL);
     377    return false;
    364378}
    365379
     
    425439    // use the source moments, etc to guess basic model parameters
    426440    pmModel *EXT = pmSourceModelGuess (source, modelType);
    427     PS_ASSERT (EXT, NULL);
     441    if (!EXT) {
     442        psTrace ("psphot", 5, "failed to generate a model for source: moments: %f %f\n", source->moments->Mxx, source->moments->Myy);
     443        return NULL;
     444    }
    428445
    429446    if ((source->moments->Mxx < 1e-3) || (source->moments->Myy < 1e-3)) {
Note: See TracChangeset for help on using the changeset viewer.