IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 30174


Ignore:
Timestamp:
Dec 24, 2010, 3:27:46 PM (15 years ago)
Author:
eugene
Message:

subtract the best source model; ensure the pixels are redefined if requested

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20101205/psphot/src/psphotReplaceUnfit.c

    r30141 r30174  
    159159      float Yo = source->modelPSF->params->data.F32[PM_PAR_YPOS];
    160160      float radius = source->modelPSF->fitRadius;
    161       if (radius < 1) {
    162           fprintf (stderr, "!");
    163       }
    164 
    165       pmSourceRedefinePixels (source, readout, Xo, Yo, radius, true);
     161
     162      // force a redefine to this image
     163      pmSourceFreePixels(source);
     164      pmSourceRedefinePixels (source, readout, Xo, Yo, radius);
    166165    }
    167166    return true;
     
    220219      source = sources->data[i];
    221220
    222       // sources have not yet been subtracted in this image (but this flag may be raised)
    223       source->tmpFlags &= ~PM_SOURCE_TMPF_SUBTRACTED;
    224 
    225       // the guess central intensity comes from the peak:
    226       float Io = source->peak->flux;
    227       float Xo = source->modelPSF->params->data.F32[PM_PAR_XPOS];
    228       float Yo = source->modelPSF->params->data.F32[PM_PAR_YPOS];
    229       float radius = source->modelPSF->fitRadius;
    230 
    231       // generate a model for this object with Io = 1.0
    232       pmModel *modelPSF = pmModelFromPSFforXY(psf, Xo, Yo, Io);
    233       if (modelPSF == NULL) {
    234           psWarning ("Failed to determine PSF model for source at (%f,%f), skipping", Xo, Yo);
    235           continue;
     221      // *** we need to cache the 'best' model, and we have 3 cases:
     222      // 1) model is the psf model --> generate from the new psf
     223      // 2) model is an unconvolved extended model --> just cache the copy (not perfect)
     224      // 3) model is a convolved extended model --> re-generate
     225
     226      // use the 'best' model to cache the model (PSF or EXT : EXT may point at one of modelFits
     227      bool isPSF = false;
     228      pmModel *model = pmSourceGetModel(&isPSF, source);
     229      float radius = model->fitRadius; // save for future use below
     230
     231      // regenerate the PSF if the model is a PSF, or if we need the PSF for a PCM
     232      if (isPSF || model->isPCM) {
     233          // the guess central intensity comes from the peak:
     234          float Io = source->peak->flux;
     235          float Xo = source->modelPSF->params->data.F32[PM_PAR_XPOS];
     236          float Yo = source->modelPSF->params->data.F32[PM_PAR_YPOS];
     237
     238          // generate a model for this object with Io = 1.0
     239          pmModel *modelPSF = pmModelFromPSFforXY(psf, Xo, Yo, Io);
     240          if (modelPSF == NULL) {
     241              psWarning ("Failed to determine PSF model for source at (%f,%f), skipping", Xo, Yo);
     242              continue;
     243          }
     244
     245          // set the source PSF model
     246          psFree (source->modelPSF);
     247          source->modelPSF = modelPSF;
     248          source->modelPSF->fitRadius = radius;
    236249      }
    237250
    238       // set the source PSF model
    239       psFree (source->modelPSF);
    240       source->modelPSF = modelPSF;
    241       source->modelPSF->fitRadius = radius;
     251      if (model->isPCM) {
     252          psAssert(false, "this section is not complete");
     253
     254          pmSourceCachePSF (source, maskVal);
     255
     256# if (0)
     257          psKernel *psfKernel = pmPCMkernelFromPSF(source, psfSize);
     258          if (!psfKernel) {
     259              psWarning ("no psf kernel");
     260          }
     261
     262          psImage *modelFlux = getmodelflux(model);
     263          psImageConvolveFFT (source->modelFlux, modelFlux, NULL, 0, psfKernel);
     264         
     265          psFree (psfKernel);
     266          psFree (modelFlux);
     267# endif
     268      }
    242269
    243270      pmSourceCacheModel (source, maskVal);  // ALLOC x14 (!)
Note: See TracChangeset for help on using the changeset viewer.