IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38560


Ignore:
Timestamp:
Jul 2, 2015, 7:36:29 AM (11 years ago)
Author:
bills
Message:

Sometimes sources fit with a saturated star profile have the center of
the model too far off of the image. These cause the code that sets up the
source's pixels and other images to be left NULL. Handle this case.

Location:
trunk/psphot/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphotDeblendSatstars.c

    r38395 r38560  
    136136        source = sources->data[N];
    137137
     138        if (!source->pixels) continue;
    138139#ifndef DEBLEND_PASS2_SOURCES
    139140        // XXX: Need to define this if we want to rerun the satstar stuff again on the pass2 sources
  • trunk/psphot/src/psphotMergeSources.c

    r38543 r38560  
    10131013                        } else {
    10141014                            // What to do here?
    1015                             psAssert (pcm, "pmPCMinit failed!");
     1015                            // psAssert (pcm, "pmPCMinit failed!");
     1016                            psFree (sourceOut->modelEXT);
     1017                            sourceOut->modelEXT = NULL;
    10161018                        }
    10171019                    } else {
  • trunk/psphot/src/psphotReplaceUnfit.c

    r38556 r38560  
    378378
    379379        if (model->isPCM) {
    380 #if 0
    381             psAssert(false, "this section is not complete");
    382 
    383             pmSourceCachePSF (source, maskVal);
    384 
    385             psKernel *psfKernel = pmPCMkernelFromPSF(source, psfSize);
    386             if (!psfKernel) {
    387                 psWarning ("no psf kernel");
    388             }
    389 
    390             // generate an image of the right size
    391             psImage *rawModelFlux = psImageCopy (NULL, source->pixels, PS_TYPE_F32);
    392             psImageInit (rawModelFlux, 0.0);
    393          
    394             // insert the model image normalized to 1.0
    395             pmModelAdd (rawModelFlux, NULL, model, PM_MODEL_OP_FULL | PM_MODEL_OP_NORM, maskVal);
    396 
    397             psImageConvolveFFT (source->modelFlux, rawModelFlux, NULL, 0, psfKernel);
    398             psFree (psfKernel);
    399             psFree (rawModelFlux);
    400 #endif
    401            pmPCMdata *pcm = pmPCMinit (source, fitOptions, model, maskVal, psfSize);
     380            pmPCMdata *pcm = pmPCMinit (source, fitOptions, model, maskVal, psfSize);
    402381            if (pcm) {
    403382                pmPCMCacheModel (source, maskVal, psfSize, pcm->nsigma);
    404383                psFree(pcm);
    405384            } else {
    406                 psAssert (pcm, "pmPCMinit failed!");
     385                psFree(source->modelEXT);
     386                source->modelEXT = NULL;
    407387            }
    408388         
  • trunk/psphot/src/psphotStackUpdateReadout.c

    r38531 r38560  
    362362            source->modelPSF->residuals = psf->residuals;
    363363        }
     364
    364365        if (!(source->mode & PM_SOURCE_MODE_PSFMODEL)) {
    365366            // The cmf loaders unconditionallly create psf models even if the source did not have one.
     
    372373        }
    373374
    374         // make sure that the window radius is large enough. Should we do this regardless of whether
    375         // or not the source is extended?
     375        // make sure that the window radius is large enough.
     376        // Should we do this regardless of whether or not the source is extended?
    376377        float fitRadius = NAN;
    377378        float windowRadius = NAN;
    378         if (1 || source->modelEXT) {
    379             if (!psphotSetRadiusMoments (&fitRadius, &windowRadius, readout, source, markVal)) {
    380                 psError (PSPHOT_ERR_UNKNOWN, false, "failed to set radius for ext source");
    381                 return false;
    382             }
    383         }
     379        if (!psphotSetRadiusMoments (&fitRadius, &windowRadius, readout, source, markVal)) {
     380            psError (PSPHOT_ERR_UNKNOWN, false, "failed to set radius for ext source");
     381            return false;
     382        }
     383        // We are getting some sources near the edge of skycells which are marked as having
     384        // been fit with saturated star model but have peak coordinates far outside the
     385        // image. When this happens an error is left on the stack.
     386        psErrorClear();
    384387       
    385388        // If we find a good model we will cache it below.
     
    431434                // I Should be getting that information from the recipe.
    432435                pmPCMdata *pcm = pmPCMinit (source, fitOptions, model, maskVal, psfSize);
    433                 if (!pcm) {
    434                     psError (PSPHOT_ERR_UNKNOWN, false, "failed to to initialize PCM for model");
    435                     return false;
     436                if (pcm) {
     437                    model->params->data.F32[PM_PAR_I0] = 1.0;
     438                    float normFlux = model->class->modelFlux(model->params);
     439                    float I0 = modelFlux / normFlux;
     440                    if (isfinite(I0)) {
     441                        model->params->data.F32[PM_PAR_I0] = I0;
     442                        goodModel = true;
     443                        // Usually this it is set when doing the fit. Since we are instantiating the model we
     444                        // set it explicitly here.
     445                        model->isPCM = true;
     446                    }
     447                    psFree(pcm);
     448                } else {
     449                    // psError (PSPHOT_ERR_UNKNOWN, false, "failed to to initialize PCM for model");
     450                    // return false;
     451                    // fall through
    436452                }
    437                 model->params->data.F32[PM_PAR_I0] = 1.0;
    438                 // XXX: this duplicates work that pmPCMCacheModel does
    439                 // pmPCMMakeModel (source, model, pcm->nsigma, maskVal, psfSize);
    440                 float normFlux = model->class->modelFlux(model->params);
    441                 float I0 = modelFlux / normFlux;
    442                 if (isfinite(I0)) {
    443                     model->params->data.F32[PM_PAR_I0] = I0;
    444                     goodModel = true;
    445                     // Usually this it is set when doing the fit. Since we are instantiating the model we
    446                     // set it explicitly here.
    447                     model->isPCM = true;
    448                 }
    449                 psFree(pcm);
    450453            }
    451454            if (!goodModel) {
     
    458461                // XXX However we aren't going to cache it below so...
    459462                source->type = PM_SOURCE_TYPE_STAR;
     463                psFree(source->modelEXT);
     464                source->modelEXT = NULL;
    460465                model = NULL;
    461466            }
Note: See TracChangeset for help on using the changeset viewer.