IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 20035


Ignore:
Timestamp:
Oct 9, 2008, 3:04:50 PM (18 years ago)
Author:
eugene
Message:

handle case of no psf model in image center

File:
1 edited

Legend:

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

    r20002 r20035  
    441441bool psphotPSFstats (pmReadout *readout, psMetadata *recipe, pmPSF *psf) {
    442442
     443    double FWHM_X, FWHM_Y;
     444
    443445    psEllipseShape shape;
    444446    psEllipseAxes axes;
     
    451453    PS_ASSERT_PTR_NON_NULL(image, false);
    452454
    453     // construct a normalized PSF model at this coordinate (Io = 1.0)
    454     pmModel *modelPSF = pmModelFromPSFforXY (psf, 0.5*image->numCols, 0.5*image->numRows, 1.0);
    455     if (modelPSF == NULL) {
    456         psError(PSPHOT_ERR_PSF, false, "Failed to estimate PSF model at image centre");
    457         return false;
    458     }
    459 
     455    // XXXX A Serious hack: the psf might not be determined in the field center.
     456    // for the moment, just try a few locations until it is defined!
     457
     458    pmModel *modelPSF = NULL;
     459    for (int ix = -1; ix <= +1; ix ++) {
     460        for (int iy = -1; iy <= +1; iy ++) {
     461
     462            // use the center of the center pixel of the image
     463            float xc = (0.5 + 0.3*ix)*image->numCols + image->col0 + 0.5;
     464            float yc = (0.5 + 0.3*ix)*image->numRows + image->row0 + 0.5;
     465
     466            // create modelPSF from this model
     467            modelPSF = pmModelFromPSFforXY (psf, xc, yc, 1.0);
     468            if (modelPSF) goto got_model;
     469        }
     470    }
     471    psAssert (modelPSF, "Failed to estimate PSF model at image center (psf is invalid everywhere?)");
     472
     473got_model:
    460474    // get the model full-width at half-max
    461     double FWHM_X = 2*modelPSF->modelRadius (modelPSF->params, 0.5);
     475    FWHM_X = 2*modelPSF->modelRadius (modelPSF->params, 0.5);
    462476
    463477    // XXX make sure this is consistent with the re-definition of PM_PAR_SXX
     
    467481    axes = psEllipseShapeToAxes (shape, 20.0);
    468482
    469     double FWHM_Y = FWHM_X * (axes.minor / axes.major);
     483    FWHM_Y = FWHM_X * (axes.minor / axes.major);
    470484
    471485    psMetadataAddF32 (recipe, PS_LIST_TAIL, "FWHM_X",   PS_META_REPLACE, "PSF FWHM Major axis", FWHM_X);
Note: See TracChangeset for help on using the changeset viewer.