IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 21, 2011, 10:44:17 AM (15 years ago)
Author:
eugene
Message:

distinguish window used for moment calculation and window used for model fitting more clearly; re-generate the cached model after PCM fitting using new function (instead of caching the fit models); add function to set window which shrinks as well as expands as needed

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

Legend:

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

    • Property svn:ignore
      •  

        old new  
        2222psphotMakePSF
        2323psphotStack
         24psphotModelTest
  • branches/eam_branches/ipp-20110710/psphot/src/psphotExtendedSourceFits.c

    r32023 r32157  
    316316        Next ++;
    317317
    318         // set the radius based on the first radial moment (also sets the mask pixels)
    319         if (!psphotSetRadiusMoments(&fitRadius, &windowRadius, readout, source, markVal)) {
    320             fprintf (stderr, "skipping (1) %f, %f\n", source->peak->xf, source->peak->yf);
    321             pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);
    322             // XXX raise an error of some kind or set a flag bit
    323             continue;
    324         }
     318        // set the fit radius based on the first radial moment (also sets the mask pixels)
     319        psphotSetRadiusMomentsExact(&fitRadius, &windowRadius, readout, source, markVal);
    325320
    326321        // Recalculate the source moments using the larger extended-source moments radius.  At
     
    332327            fprintf (stderr, "skipping (2) %f, %f\n", source->peak->xf, source->peak->yf);
    333328            *source->moments = psfMoments;
     329
     330            // probably need to bump up the size for subtraction
    334331            pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);
    335332            // XXX raise an error flag of some kind
    336333            continue;
    337334        }
    338 
    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.
    341         psImage *modelFluxStart = psMemIncrRefCounter (source->modelFlux);
    342         if (!modelFluxStart) {
    343             pmSourceCacheModel (source, maskVal);
    344             modelFluxStart = psMemIncrRefCounter (source->modelFlux);
    345             if (!modelFluxStart) {
    346                 fprintf (stderr, "skipping (3) %f, %f\n", source->peak->xf, source->peak->yf);
    347                 *source->moments = psfMoments;
    348                 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);
    349                 // XXX raise an error of some kind?
    350                 continue;
    351             }
    352         }
    353        
    354         // array to store the pointers to the model flux images while the models are being fitted
    355         psArray *modelFluxes = psArrayAllocEmpty (models->list->n);
    356335
    357336        // allocate the array to store the model fits
     
    417396                  continue;
    418397              }
    419               pmSourceCacheModel (source, maskVal);
    420398              psTrace ("psphot", 4, "fit plain model for %f, %f : %s chisq = %f (npix: %d, niter: %d)\n",
    421399                       source->moments->Mx, source->moments->My, pmModelClassGetName (modelFit->type), modelFit->chisq, modelFit->nPix, modelFit->nIter);
     
    426404              }
    427405          }
    428 
    429           // save each of the model flux images for now, and (below) store the best
    430           psArrayAdd (modelFluxes, 4, source->modelFlux);
    431406
    432407          pmSourceExtFitPars *extFitPars = pmSourceExtFitParsAlloc();
     
    477452          psTrace ("psphot", 5, "failed to fit extended source model to object at %f, %f", source->moments->Mx, source->moments->My);
    478453
    479           // replace original model, subtract it
    480           psFree (source->modelFlux);
    481           source->modelFlux = modelFluxStart;
     454          // ensure the modelEXT is cached
     455          pmSourceCacheModel (source, maskVal);
    482456
    483457          *source->moments = psfMoments;
    484458          pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);
    485 
    486           psFree (modelFluxes);
    487459
    488460          continue;
     
    493465        source->modelEXT = psMemIncrRefCounter (source->modelFits->data[minModel]);
    494466
    495         // save the modelFlux for the best model
    496         psFree (source->modelFlux);
    497         source->modelFlux = psMemIncrRefCounter (modelFluxes->data[minModel]);
     467        // adjust the window so the subtraction covers the faint wings
     468        psphotSetRadiusMoments(&fitRadius, &windowRadius, readout, source, markVal);
     469
     470        // cache the model flux
     471        if (source->modelEXT->isPCM) {
     472            pmPCMCacheModel (source, maskVal, psfSize);
     473        } else {
     474            pmSourceCacheModel (source, maskVal);
     475        }
    498476
    499477        // replace the original moments
     
    502480        // subtract the best fit from the object, leave local sky
    503481        pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);
    504 
    505         // the initial model flux is no longer needed
    506         psFree (modelFluxStart);
    507         psFree (modelFluxes);
    508482
    509483        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);
Note: See TracChangeset for help on using the changeset viewer.