IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.