IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 20287


Ignore:
Timestamp:
Oct 21, 2008, 9:45:07 AM (18 years ago)
Author:
Paul Price
Message:

Fixing SEGV when !source->moments.

File:
1 edited

Legend:

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

    r20261 r20287  
    99        pmSource *source = sources->data[i];
    1010        if (source->mode & PM_SOURCE_MODE_PSFSTAR) {
    11             nPSF ++;
    12         }
     11            nPSF ++;
     12        }
    1313    }
    1414
     
    289289    // XXX test dump of psf star data and psf-subtracted image
    290290    if (psTraceGetLevel("psphot.psfstars") > 5) {
    291         psphotDumpPSFStars (readout, try, options->radius, maskVal, markVal);
     291        psphotDumpPSFStars (readout, try, options->radius, maskVal, markVal);
    292292    }
    293293
     
    333333
    334334    for (float ix = -0.4; ix <= +0.4; ix += 0.1) {
    335         for (float iy = -0.4; iy <= +0.4; iy += 0.1) {
    336 
    337             // use the center of the center pixel of the image
    338             float xc = ix*image->numCols + 0.5*image->numCols + image->col0 + 0.5;
    339             float yc = iy*image->numRows + 0.5*image->numRows + image->row0 + 0.5;
    340 
    341             // create modelPSF from this model
    342             pmModel *modelPSF = pmModelFromPSFforXY (psf, xc, yc, 1.0);
    343             if (!modelPSF) continue;
    344 
    345             // get the model full-width at half-max
    346             float FWHM_MAJOR = 2*modelPSF->modelRadius (modelPSF->params, 0.5);
    347 
    348             // XXX make sure this is consistent with the re-definition of PM_PAR_SXX
    349             shape.sx  = modelPSF->params->data.F32[PM_PAR_SXX];
    350             shape.sy  = modelPSF->params->data.F32[PM_PAR_SYY];
    351             shape.sxy = modelPSF->params->data.F32[PM_PAR_SXY];
    352             axes = psEllipseShapeToAxes (shape, 20.0);
    353             psFree (modelPSF);
    354 
    355             float FWHM_MINOR = FWHM_MAJOR * (axes.minor / axes.major);
    356             if (!isfinite(FWHM_MAJOR) || !isfinite(FWHM_MINOR)) continue;
    357             psVectorAppend (fwhmMajor, FWHM_MAJOR);
    358             psVectorAppend (fwhmMinor, FWHM_MINOR);
    359         }
     335        for (float iy = -0.4; iy <= +0.4; iy += 0.1) {
     336
     337            // use the center of the center pixel of the image
     338            float xc = ix*image->numCols + 0.5*image->numCols + image->col0 + 0.5;
     339            float yc = iy*image->numRows + 0.5*image->numRows + image->row0 + 0.5;
     340
     341            // create modelPSF from this model
     342            pmModel *modelPSF = pmModelFromPSFforXY (psf, xc, yc, 1.0);
     343            if (!modelPSF) continue;
     344
     345            // get the model full-width at half-max
     346            float FWHM_MAJOR = 2*modelPSF->modelRadius (modelPSF->params, 0.5);
     347
     348            // XXX make sure this is consistent with the re-definition of PM_PAR_SXX
     349            shape.sx  = modelPSF->params->data.F32[PM_PAR_SXX];
     350            shape.sy  = modelPSF->params->data.F32[PM_PAR_SYY];
     351            shape.sxy = modelPSF->params->data.F32[PM_PAR_SXY];
     352            axes = psEllipseShapeToAxes (shape, 20.0);
     353            psFree (modelPSF);
     354
     355            float FWHM_MINOR = FWHM_MAJOR * (axes.minor / axes.major);
     356            if (!isfinite(FWHM_MAJOR) || !isfinite(FWHM_MINOR)) continue;
     357            psVectorAppend (fwhmMajor, FWHM_MAJOR);
     358            psVectorAppend (fwhmMinor, FWHM_MINOR);
     359        }
    360360    }
    361361
     
    405405        if (!source) continue;
    406406        if (!(source->mode & PM_SOURCE_MODE_PSFSTAR)) continue;
     407        if (!source->moments) {
     408            continue;
     409        }
    407410
    408411        moments.x2 = source->moments->Mxx;
Note: See TracChangeset for help on using the changeset viewer.