IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 31990


Ignore:
Timestamp:
Aug 3, 2011, 10:30:02 AM (15 years ago)
Author:
eugene
Message:

add new window function using first radial moment; use new sersic guess function

Location:
branches/eam_branches/ipp-20110710/psphot/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110710/psphot/src/psphot.h

    r31452 r31990  
    469469psArray *psphotSourceChildrenByObject (pmConfig *config, const pmFPAview *view, const char *filerule, psArray *objectsSrc);
    470470
     471bool psphotSersicModelClassGuessPCM (pmPCMdata *pcm, pmSource *source);
     472void psphotSersicModelClassInit ();
     473void psphotSersicModelClassCleanup ();
     474
     475bool psphotSetRadiusMoments (float *fitRadius, float *windowRadius, pmReadout *readout, pmSource *source, psImageMaskType markVal);
     476
    471477#endif
  • branches/eam_branches/ipp-20110710/psphot/src/psphotExtendedSourceFits.c

    r31867 r31990  
    4545    int Nfail = 0;
    4646
     47    psphotSersicModelClassInit();
     48
    4749    psTimerStart ("psphot.extended");
    4850
     
    103105
    104106      if (item->type != PS_DATA_METADATA) {
     107        // XXX we could cull the bad entries or build a validated model folder
    105108        psAbort ("Invalid type for EXTENDED_SOURCE_MODEL entry %s, not a metadata folder", item->name);
    106         // XXX we could cull the bad entries or build a validated model folder
    107109      }
    108110
     
    247249    psFree(AnalysisRegion);
    248250
     251    psphotSersicModelClassCleanup();
     252
    249253    psLogMsg ("psphot", PS_LOG_INFO, "extended source model fits: %f sec for %d objects\n", psTimerMark ("psphot.extended"), Next);
    250254    psLogMsg ("psphot", PS_LOG_INFO, "  %d convolved models (%d passed)\n", Nconvolve, NconvolvePass);
     
    265269    int Nplain = 0;
    266270    int NplainPass = 0;
    267     bool savePics = false;
    268     float radius;
     271    float fitRadius, windowRadius;
    269272    psScalar *scalar = NULL;
    270273    pmMoments psfMoments;
     
    279282    psImageMaskType markVal = PS_SCALAR_VALUE(job->args->data[6],PS_TYPE_IMAGE_MASK_DATA);
    280283
    281     // pthread_t tid = pthread_self();     // Thread identifier
    282 
    283284    // Define source fitting parameters for extended source fits
    284285    pmSourceFitOptions *fitOptions = pmSourceFitOptionsAlloc();
     
    309310        if (source->peak->y > region->y1) continue;
    310311
    311         // if model is NULL, we don't have a starting guess
    312         // XXX use the parameters guessed from moments
    313         // if (source->modelEXT == NULL) continue;
    314 
    315         // fprintf (stderr, "fit %d,%d in thread %d\n", source->peak->x, source->peak->y, (int) tid);
    316 
    317312        // replace object in image
    318313        if (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED) {
     
    321316        Next ++;
    322317
    323         // set the radius based on the footprint (also sets the mask pixels)
    324         if (!psphotSetRadiusFootprint(&radius, readout, source, markVal, 1.0)) {
     318        // set the radius based on the first radial moment (also sets the mask pixels)
     319        if (!psphotSetRadiusMoments(&fitRadius, &windowRadius, readout, source, markVal)) {
    325320            fprintf (stderr, "skipping (1) %f, %f\n", source->peak->xf, source->peak->yf);
    326321            pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);
    327             // XXX raise an error of some kind
     322            // XXX raise an error of some kind or set a flag bit
    328323            continue;
    329324        }
    330325
    331         // XXX note that this changes the source moments that are published...
    332         // recalculate the source moments using the larger extended-source moments radius
    333         // at this stage, skip Gaussian windowing, and do not clip pixels by S/N
    334         // this uses the footprint to judge both radius and aperture?
    335         // XXX save the psf-based moments for output
     326        // Recalculate the source moments using the larger extended-source moments radius.  At
     327        // this stage, skip Gaussian windowing, and do not clip pixels by S/N.  Save the
     328        // psf-based moments for output
    336329        psfMoments = *source->moments;
    337         if (!pmSourceMoments (source, radius, 0.0, 0.0, 0.0, maskVal)) {
     330        if (!pmSourceMoments (source, windowRadius, 0.0, 0.0, 0.0, maskVal & PS_NOT_IMAGE_MASK(markVal))) {
    338331            // subtract the best fit from the object, leave local sky
    339332            fprintf (stderr, "skipping (2) %f, %f\n", source->peak->xf, source->peak->yf);
     
    344337        }
    345338
    346         // save the modelFlux here in case we need to subtract it (for failure)
     339        // save the PSF-based modelFlux here in case we need to subtract it (for failure).  If
     340        // it does not exist, attempt to generate it.  Give up if we cannot even do that.
    347341        psImage *modelFluxStart = psMemIncrRefCounter (source->modelFlux);
    348342        if (!modelFluxStart) {
     
    358352        }
    359353       
    360         if (savePics) {
    361           psphotSaveImage (NULL, readout->image, "image.xp.fits");
    362         }
    363 
    364354        // array to store the pointers to the model flux images while the models are being fitted
    365355        psArray *modelFluxes = psArrayAllocEmpty (models->list->n);
     
    368358        if (source->modelFits == NULL) {
    369359            source->modelFits = psArrayAllocEmpty (models->list->n);
     360        }
     361        // extFitPars are the non-parametric data measured for this model fit (moments, kron, etc)
     362        if (source->extFitPars == NULL) {
     363            source->extFitPars = psArrayAllocEmpty (models->list->n);
    370364        }
    371365
     
    397391          bool convolved = psMetadataLookupBool (&status, model, "PSF_CONVOLVED_VALUE");
    398392          assert (status);
    399 
    400           // XXX psTraceSetLevel ("psLib.math.psMinimizeLMChi2", 6);
    401           // XXX psTraceSetLevel ("psphot.psphotModelWithPSF_LMM", 6);
    402 
    403           // XXX this does not make sense in a threaded context
    404           psTimerStart ("psphot.extended.fit");
    405393
    406394          // fit the model as convolved or not
     
    439427          }
    440428
    441           psLogMsg ("psphot", PS_LOG_INFO, "model fit: %7.5f sec, %5d npix, %2d iter, %s type\n", psTimerMark ("psphot.extended.fit"), modelFit->nPix, modelFit->nIter, pmModelClassGetName (modelFit->type));
    442 
    443           // save each of the model flux images and store the best
     429          // save each of the model flux images for now, and (below) store the best
    444430          psArrayAdd (modelFluxes, 4, source->modelFlux);
    445431
     432          pmSourceExtFitPars *extFitPars = pmSourceExtFitParsAlloc();
     433          extFitPars->Mxx = source->moments->Mxx;
     434          extFitPars->Mxy = source->moments->Mxy;
     435          extFitPars->Myy = source->moments->Myy;
     436          extFitPars->Mrf = source->moments->Mrf;
     437          extFitPars->Mrh = source->moments->Mrh;
     438          extFitPars->peakMag = (source->peak->rawFlux > 0) ? -2.5*log10(source->peak->rawFlux) : NAN;
     439         
     440          // save kron mag, but assign apMag & psfMag on output (not yet calculated)
     441          extFitPars->krMag = -2.5*log10(source->moments->KronFlux);
     442
     443          psArrayAdd (source->extFitPars, 4, extFitPars);
     444          psFree (extFitPars);
     445
    446446          // test for fit quality / result
    447           modelFit->fitRadius = radius;
     447          modelFit->fitRadius = fitRadius;
    448448          psArrayAdd (source->modelFits, 4, modelFit);
    449449
     
    470470        }
    471471
     472        // clear the circular mask
     473        psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal));
     474
    472475        if (minModel == -1) {
    473           // re-subtract the object, leave local sky
     476          // no valid extended fit; re-subtract the object, leave local sky
    474477          psTrace ("psphot", 5, "failed to fit extended source model to object at %f, %f", source->moments->Mx, source->moments->My);
    475478
     
    483486          psFree (modelFluxes);
    484487
    485           if (savePics) {
    486               psphotSaveImage (NULL, readout->image, "image.xp.fits");
    487               char key[10];
    488               fprintf (stdout, "continue? ");
    489               if (!fgets (key, 8, stdin)) {
    490                   psWarning("Couldn't read anything.");
    491               } else if (key[0] == 'n') {
    492                   savePics = false;
    493               }
    494           }
    495488          continue;
    496489        }
     
    516509        psTrace ("psphot", 4, "best ext model for %f, %f : %s chisq = %f\n", source->moments->Mx, source->moments->My, pmModelClassGetName (source->modelEXT->type), source->modelEXT->chisq);
    517510        psTrace ("psphot", 5, "extended source model for source at %7.1f, %7.1f", source->moments->Mx, source->moments->My);
    518 
    519         if (savePics) {
    520           psphotSaveImage (NULL, readout->image, "image.xm.fits");
    521           char key[10];
    522           fprintf (stdout, "continue? ");
    523           if (!fgets (key, 8, stdin)) {
    524               psWarning("Couldn't read anything.");
    525           } else if (key[0] == 'n') {
    526               savePics = false;
    527           }
    528         }
    529511    }
    530512    psFree (fitOptions);
    531 
    532     // fprintf (stderr, "xfit : tried %ld objects\n", sources->n);
    533513
    534514    // change the value of a scalar on the array (wrap this and put it in psArray.h)
  • branches/eam_branches/ipp-20110710/psphot/src/psphotRadiusChecks.c

    r31452 r31990  
    142142}
    143143
     144# define MIN_WINDOW 5.0
     145# define SCALE1 5.0
     146# define SCALE2 12.5
     147
     148// call this function whenever you (re)-define the EXT model
     149bool psphotSetRadiusMoments (float *fitRadius, float *windowRadius, pmReadout *readout, pmSource *source, psImageMaskType markVal) {
     150
     151    psAssert (source, "source not defined??");
     152    psAssert (source->moments, "moments not defined??");
     153
     154    *fitRadius = SCALE1 * source->moments->Mrf;
     155    *fitRadius = PS_MIN (PS_MAX(*fitRadius, MIN_WINDOW), EXT_FIT_MAX_RADIUS);
     156
     157    *windowRadius = SCALE2 * source->moments->Mrf;
     158    *windowRadius = PS_MIN (PS_MAX(*windowRadius, 2.5*MIN_WINDOW), 2.5*EXT_FIT_MAX_RADIUS);
     159
     160    // redefine the pixels if needed
     161    pmSourceRedefinePixels (source, readout, source->peak->xf, source->peak->yf, *windowRadius);
     162
     163    // set the mask to flag the excluded pixels
     164    psImageKeepCircle (source->maskObj, source->peak->xf, source->peak->yf, *fitRadius, "OR", markVal);
     165
     166    return true;
     167}
     168
    144169// call this function whenever you (re)-define the EXT model
    145170bool psphotSetRadiusFootprint (float *radius, pmReadout *readout, pmSource *source, psImageMaskType markVal, float factor) {
  • branches/eam_branches/ipp-20110710/psphot/src/psphotSersicModelClass.c

    r31966 r31990  
    505505}
    506506
    507 void psphotWriteGuess(pmModel *model, float dKronMag, float PSFratio, float ASPratio);
     507# define TIMING false
    508508
    509509bool psphotSersicModelClassGuessPCM (pmPCMdata *pcm, pmSource *source) {
     510
     511    float t1, t2, t4, t5;
     512    if (TIMING) { psTimerStart ("SersicGuess"); }
    510513
    511514    psF32 *PAR = pcm->modelConv->params->data.F32;
     
    549552
    550553    // find the containing model class:
     554
     555    if (TIMING) { t1 = psTimerMark ("SersicGuess"); }
    551556
    552557    psphotSersicModelClass *class = NULL;   
     
    561566    }
    562567       
     568    if (TIMING) { t2 = psTimerMark ("SersicGuess"); }
     569
    563570    psAssert (class, "PSFratio and ASPratio must be in range");
    564571
     
    610617    PAR[PM_PAR_I0]  = 1.0;
    611618
     619    if (TIMING) { t4 = psTimerMark ("SersicGuess"); }
     620
    612621    // set the normalization by linear fit between model and data
    613622    psphotSersicModelNorm (pcm, source);
     623
     624    if (TIMING) { t5 = psTimerMark ("SersicGuess"); }
     625
     626    if (TIMING) {
     627        fprintf (stderr, "guess, t1: %6.4f, t2: %6.4f, t4: %6.4f, t5: %6.4f\n", t1, t2, t4, t5);
     628    }
    614629
    615630    // float flux = pcm->modelConv->modelFlux(pcm->modelConv->params);
     
    617632    // float Io = pow(10.0, -0.4*(totalMag - normMag));
    618633    // PAR[PM_PAR_I0] = Io;
    619 
    620     psphotWriteGuess(pcm->modelConv, dKronMag, PSFratio, ASPratio);
    621634
    622635    return true;
  • branches/eam_branches/ipp-20110710/psphot/src/psphotSourceFits.c

    r31452 r31990  
    211211bool psphotFitBlob (pmReadout *readout, pmSource *source, psArray *newSources, pmPSF *psf, pmSourceFitOptions *fitOptions, psImageMaskType maskVal, psImageMaskType markVal) {
    212212
    213     float radius;
     213    float fitRadius, windowRadius;
    214214    bool okEXT, okDBL;
    215215    pmModel *ONE = NULL;
     
    225225    if (source->type == PM_SOURCE_TYPE_SATURATED) return false;
    226226
     227# define TEST_X -540.0
     228# define TEST_Y 540.0
     229   
     230    if ((fabs(source->peak->xf - TEST_X) < 5) && (fabs(source->peak->yf - TEST_Y) < 5)) {
     231        fprintf (stderr, "test galaxy\n");
     232    }
     233
     234# undef TEST_X
     235# undef TEST_Y
     236
    227237    // set the radius based on the footprint (also sets the mask pixels)
    228     if (!psphotSetRadiusFootprint(&radius, readout, source, markVal, 1.0)) return false;
     238    if (!psphotSetRadiusMoments(&fitRadius, &windowRadius, readout, source, markVal)) return false;
     239    // fprintf (stderr, "rad: %6.1f %6.1f  | %5.2f %5.2f %5.2f  ", source->peak->xf, source->peak->yf, source->moments->Mrf, fitRadius, windowRadius);
    229240
    230241    // XXX note that this changes the source moments that are published...
     
    234245    // this uses the footprint to judge both radius and aperture?
    235246    // XXX save the psf-based moments for output
     247    // XXX do not limit to pixels in the marked circle
    236248    psfMoments = *source->moments;
    237     if (!pmSourceMoments (source, radius, 0.0, 0.5, 0.0, maskVal)) {
     249    if (!pmSourceMoments (source, windowRadius, 0.0, 0.5, 0.0, maskVal & PS_NOT_IMAGE_MASK(markVal))) {
    238250      *source->moments = psfMoments;
     251      fprintf (stderr, "skip (bad moments)\n");
    239252      return false;
    240253    }
     254    // fprintf (stderr, "r1: %f\n", source->moments->Mrf);
     255
     256    // XXX note that we do not re-try to measure the moments if the resulting Mrf is large compared
     257    // to the initial value
    241258
    242259    psTrace ("psphot", 5, "trying blob...\n");
     
    263280        ONE = DBL->data[0];
    264281        if (ONE) {
    265             if (!isfinite(ONE->params->data.F32[PM_PAR_I0])) psAbort("nan in fit");
     282            psAssert (isfinite(ONE->params->data.F32[PM_PAR_I0]), "nan in fit");
    266283            chiDBL = ONE->chisqNorm; // save chisq for double-star/galaxy comparison
    267             ONE->fitRadius = radius;
     284            ONE->fitRadius = fitRadius;
    268285        }
    269286
     
    271288        ONE = DBL->data[1];
    272289        if (ONE) {
    273             if (!isfinite(ONE->params->data.F32[PM_PAR_I0])) psAbort("nan in fit");
    274             ONE->fitRadius = radius;
     290            psAssert (isfinite(ONE->params->data.F32[PM_PAR_I0]), "nan in fit");
     291            ONE->fitRadius = fitRadius;
    275292        }
    276293    }
     
    284301        okEXT = psphotEvalEXT (tmpSrc, EXT);
    285302        chiEXT = EXT ? EXT->chisqNorm : NAN;
     303        EXT->fitRadius = fitRadius;
    286304    }
    287305
     
    476494    // for sersic models, use a grid search to choose an index, then float the params there
    477495    if (modelType == pmModelClassGetType("PS_MODEL_SERSIC")) {
    478         // for the test fits, use a somewhat smaller radius
    479         psphotSetRadiusFootprint(&model->fitRadius, readout, source, markVal, 0.5);
    480496        psphotFitSersicIndex (model, readout, source, fitOptions, maskVal, markVal);
    481     }
    482 
    483     if (!psphotSetRadiusModel (model, readout, source, markVal, true)) {
    484         psphotSetRadiusFootprint(&model->fitRadius, readout, source, markVal, 1.0);
    485497    }
    486498
     
    499511}
    500512
     513# define TIMING 0
     514
    501515pmModel *psphotFitPCM (pmReadout *readout, pmSource *source, pmSourceFitOptions *fitOptions, pmModelType modelType, psImageMaskType maskVal, psImageMaskType markVal, int psfSize) {
    502516
     
    517531        return NULL;
    518532    }
     533
     534# define TEST_X -540.0
     535# define TEST_Y 540.0
     536   
     537    if ((fabs(source->peak->xf - TEST_X) < 5) && (fabs(source->peak->yf - TEST_Y) < 5)) {
     538        psTraceSetLevel("psModules.objects.pmPCM_MinimizeChisq", 5);
     539    }
     540
     541    float t1, t2, t4, t5;
     542    if (TIMING) { psTimerStart ("psphotFitPCM"); }
    519543
    520544    pmPCMdata *pcm = pmPCMinit (source, &options, model, maskVal, psfSize);
     
    524548        return model;
    525549    }
    526 
    527     // use the source moments, etc to guess basic model parameters
    528     if (!pmSourceModelGuessPCM (pcm, source, maskVal, markVal)) {
    529         psFree (pcm);
    530         model->flags |= PM_MODEL_STATUS_BADARGS;
    531         return model;
    532     }
    533 
    534     // for sersic models, use a grid search to choose an index, then float the params there
     550    if (TIMING) { t1 = psTimerMark ("psphotFitPCM"); }
     551
     552    // get the guess for sersic models
    535553    if (modelType == pmModelClassGetType("PS_MODEL_SERSIC")) {
    536         // for the test fits, use a somewhat smaller radius
    537         psphotSetRadiusFootprint(&model->fitRadius, readout, source, markVal, 0.5);
    538 
    539         if (!psphotFitSersicIndexPCM (pcm, readout, source, fitOptions, maskVal, markVal, psfSize)) {
     554        // use the source moments, etc to guess basic model parameters
     555        if (!psphotSersicModelClassGuessPCM (pcm, source)) {
    540556            psFree (pcm);
    541557            model->flags |= PM_MODEL_STATUS_BADARGS;
    542558            return model;
    543559        }
    544     }
    545 
    546     if (!psphotSetRadiusModel (model, readout, source, markVal, true)) {
    547         psphotSetRadiusFootprint(&model->fitRadius, readout, source, markVal, 1.0);
    548     }
     560    } else {
     561        // use the source moments, etc to guess basic model parameters
     562        if (!pmSourceModelGuessPCM (pcm, source, maskVal, markVal)) {
     563            psFree (pcm);
     564            model->flags |= PM_MODEL_STATUS_BADARGS;
     565            return model;
     566        }
     567    }
     568
     569    if (TIMING) { t2 = psTimerMark ("psphotFitPCM"); }
    549570
    550571    if (modelType == pmModelClassGetType("PS_MODEL_SERSIC")) {
     
    555576    // update the pcm elements if we have changed the circumstance (options.mode or source->pixels)
    556577    pmPCMupdate(pcm, source, &options, model);
     578    if (TIMING) { t4 = psTimerMark ("psphotFitPCM"); }
    557579
    558580    // psTraceSetLevel("psLib.math.psMinimizeLMChi2", 5);
    559581    pmSourceFitPCM (pcm, source, &options, maskVal, markVal, psfSize);
    560     // fprintf (stderr, "chisq: %f, nIter: %d, radius: %f, npix: %d\n", model->chisqNorm, model->nIter, model->fitRadius, model->nPix);
     582    if (TIMING) { t5 = psTimerMark ("psphotFitPCM"); }
     583
     584    if (TIMING) {
     585        fprintf (stderr, "psphotFitPCM : nIter: %2d, radius: %6.1f, npix: %5d, t1: %6.4f, t2: %6.4f, t4: %6.4f, t5: %6.4f\n", model->nIter, model->fitRadius, model->nPix, t1, t2, t4, t5);
     586    }
     587
     588    if ((fabs(source->peak->xf - TEST_X) < 5) && (fabs(source->peak->yf - TEST_Y) < 5)) {
     589        psTraceSetLevel("psModules.objects.pmPCM_MinimizeChisq", 0);
     590    }
    561591
    562592    // psTraceSetLevel("psLib.math.psMinimizeLMChi2", 0);
     
    566596}
    567597
     598# undef TEST_X
     599# undef TEST_Y
     600
    568601// note that these should be 1/2n of the standard sersic index
    569 float indexGuess[] = {0.5, 0.33, 0.25, 0.167, 0.125, 0.083};
    570 # define N_INDEX_GUESS 6
     602// float indexGuess[] = {0.8, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0};
     603// float indexGuess[] = {0.5, 0.33, 0.25, 0.167, 0.125, 0.083};
     604float indexGuess[] = {1.0, 2.0, 3.0, 4.0};
     605# define N_INDEX_GUESS 4
    571606
    572607// A sersic model is very sensitive to the index.  attempt to find the index first by grid search in just the index
     
    586621    float chiSquare[N_INDEX_GUESS];
    587622
     623# define TEST_X -540.0
     624# define TEST_Y 540.0
     625   
     626    if ((fabs(source->peak->xf - TEST_X) < 5) && (fabs(source->peak->yf - TEST_Y) < 5)) {
     627        psTraceSetLevel("psModules.objects.pmPCM_MinimizeChisq", 5);
     628    }
     629
    588630    for (int i = 0; i < N_INDEX_GUESS; i++) {
    589         model->params->data.F32[PM_PAR_7] = indexGuess[i];
     631        model->params->data.F32[PM_PAR_7] = 0.5/indexGuess[i];
    590632
    591633        if (!model->modelGuess(model, source)) {
     
    594636        }
    595637
    596         // each time we change the model guess, we need to adjust the radius
    597         // XXX this did not work : we do not need such a large radius -- just uses moments-based radius
    598         if (false && !psphotSetRadiusModel (model, readout, source, markVal, false)) {
    599             psphotSetRadiusFootprint(&model->fitRadius, readout, source, markVal, 0.5);
    600         }
    601        
    602638        pmSourceFitModel (source, model, &options, maskVal);
    603         // fprintf (stderr, "chisq: %f, nIter: %d, radius: %f, npix: %d\n", model->chisqNorm, model->nIter, model->fitRadius, model->nPix);
     639        fprintf (stderr, "index: %f, chisq: %f, nIter: %d, radius: %f, npix: %d\n", indexGuess[i], model->chisqNorm, model->nIter, model->fitRadius, model->nPix);
    604640
    605641        chiSquare[i] = model->chisqNorm;
     
    616652    assert (iMin >= 0);
    617653
     654    if ((fabs(source->peak->xf - TEST_X) < 5) && (fabs(source->peak->yf - TEST_Y) < 5)) {
     655        psTraceSetLevel("psModules.objects.pmPCM_MinimizeChisq", 0);
     656    }
     657
    618658    model->flags = PM_MODEL_STATUS_NONE; // do not attempt to handle failures here, let the next iteration deal with it
    619     model->params->data.F32[PM_PAR_7] = indexGuess[iMin];
     659    model->params->data.F32[PM_PAR_7] = 0.5/indexGuess[iMin];
    620660    model->modelGuess(model, source);
    621 
    622     // each time we change the model guess, we need to adjust the radius
    623     // if (!psphotSetRadiusModel (model, readout, source, markVal, true)) {
    624     //  psphotSetRadiusFootprint(&model->fitRadius, readout, source, markVal);
    625     // }
    626661
    627662    return true;
     
    648683    float xMin = NAN;
    649684    float chiSquare[N_INDEX_GUESS];
     685
     686    if ((fabs(source->peak->xf - TEST_X) < 5) && (fabs(source->peak->yf - TEST_Y) < 5)) {
     687        psTraceSetLevel("psModules.objects.pmPCM_MinimizeChisq", 5);
     688    }
    650689
    651690    for (int i = 0; i < N_INDEX_GUESS; i++) {
     
    657696        }
    658697
    659         // each time we change the model guess, we need to adjust the radius
    660         // XXX this did not work : we do not need such a large radius -- just uses moments-based radius
    661         if (false && !psphotSetRadiusModel (model, readout, source, markVal, false)) {
    662             psphotSetRadiusFootprint(&model->fitRadius, readout, source, markVal, 0.5);
    663         }
    664        
    665698# if (0)
     699        // this block is to test the relative speed of straight and PCM fits
    666700        pmSourceFitModel (source, model, &options, maskVal);
    667701# else
     
    669703        pmSourceFitPCM (pcm, source, &options, maskVal, markVal, psfSize);
    670704# endif
     705        fprintf (stderr, "index: %f, chisq: %f, nIter: %d, radius: %f, npix: %d\n", indexGuess[i], model->chisqNorm, model->nIter, model->fitRadius, model->nPix);
    671706        // fprintf (stderr, "chisq: %f, nIter: %d, radius: %f, npix: %d\n", model->chisqNorm, model->nIter, model->fitRadius, model->nPix);
    672707
     
    684719    assert (iMin >= 0);
    685720   
     721    if ((fabs(source->peak->xf - TEST_X) < 5) && (fabs(source->peak->yf - TEST_Y) < 5)) {
     722        psTraceSetLevel("psModules.objects.pmPCM_MinimizeChisq", 0);
     723    }
     724
    686725    model->flags = PM_MODEL_STATUS_NONE; // do not attempt to handle failures here, let the next iteration deal with it
    687726    model->params->data.F32[PM_PAR_7] = indexGuess[iMin];
Note: See TracChangeset for help on using the changeset viewer.