IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 2, 2014, 10:50:14 AM (12 years ago)
Author:
bills
Message:

Merge with ipp-20140401 (The staticsky tag)

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/psphot/src

  • trunk/psphot/src/psphotGalaxyShape.c

    r36441 r36633  
    205205        if (!(source->tmpFlags & PM_SOURCE_TMPF_MOMENTS_MEASURED)) continue;
    206206        if (source->mode & PM_SOURCE_MODE_MOMENTS_FAILURE) continue;
     207        if (!source->modelPSF) continue;
    207208
    208209        // psphotSetRadiusMomentsExact sets the radius based on Mrf
     
    274275
    275276            int i = source->galaxyFits->chisq->n - 1;
    276             float thisChisq = source->galaxyFits->chisq->data.F32[i];
    277             if (isfinite(thisChisq) && (!isfinite(chisqBest) || thisChisq < chisqBest)) {
    278                 chisqBest = thisChisq;
    279                 fRmajorBest = fRmajor;
    280                 fRminorBest = fRminor;
     277            float flux = source->galaxyFits->Flux->data.F32[i];
     278            if (isfinite(flux)) {
     279                float thisChisq = source->galaxyFits->chisq->data.F32[i];
     280                if (isfinite(thisChisq) && isfinite(flux) && (!isfinite(chisqBest) || thisChisq < chisqBest)) {
     281                    chisqBest = thisChisq;
     282                    fRmajorBest = fRmajor;
     283                    fRminorBest = fRminor;
     284                }
    281285            }
     286            // reset I0 to avoid potential problems on the next iteration
     287            PAR[PM_PAR_I0] = 1.0;
    282288        }
    283289    }
    284290
     291#define SAVE_BEST_MODEL
    285292#ifdef SAVE_BEST_MODEL
    286293    // Save model with smallest chisq
     
    301308        psphotGalaxyShapeSource (pcm, source, maskVal, psfSize, false);
    302309
    303         // Replace modelEXT with this model
    304         // XXX: only do this if the model is good
    305         psFree (source->modelEXT);
    306 
    307         source->modelEXT = psMemIncrRefCounter (pcm->modelConv);
    308         source->type = PM_SOURCE_TYPE_EXTENDED;
    309         source->mode |= PM_SOURCE_MODE_EXTMODEL;
    310         source->mode |= PM_SOURCE_MODE_NONLINEAR_FIT;
    311 
    312         // cache the model flux
    313         pmPCMCacheModel (source, maskVal, psfSize, fitOptions->nsigma);
     310        // Replace modelEXT with this model, if the model is good
     311        if (isfinite(PAR[PM_PAR_I0])) {
     312            psFree (source->modelEXT);
     313
     314            source->modelEXT = psMemIncrRefCounter (pcm->modelConv);
     315            source->type = PM_SOURCE_TYPE_EXTENDED;
     316            source->mode |= PM_SOURCE_MODE_EXTMODEL;
     317            source->mode |= PM_SOURCE_MODE_NONLINEAR_FIT;
     318
     319            // cache the model flux
     320            pmPCMCacheModel (source, maskVal, psfSize, fitOptions->nsigma);
     321        }
    314322    }
    315323
Note: See TracChangeset for help on using the changeset viewer.