IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 20234


Ignore:
Timestamp:
Oct 17, 2008, 12:59:40 PM (18 years ago)
Author:
eugene
Message:

calculate FWHM for grid of points; add FWHM sigmas and ranges

File:
1 edited

Legend:

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

    r20082 r20234  
    318318bool psphotPSFstats (pmReadout *readout, psMetadata *recipe, pmPSF *psf) {
    319319
    320     double FWHM_X, FWHM_Y;
    321 
    322320    psEllipseShape shape;
    323321    psEllipseAxes axes;
     
    330328    PS_ASSERT_PTR_NON_NULL(image, false);
    331329
    332     // XXXX A Serious hack: the psf might not be determined in the field center.
    333     // for the moment, just try a few locations until it is defined!
    334 
    335     pmModel *modelPSF = NULL;
    336     for (int ix = -1; ix <= +1; ix ++) {
    337         for (int iy = -1; iy <= +1; iy ++) {
     330    // XXX a minor hack: measure the values for a grid of points across the image, determine mean, UQ, LQ, etc:
     331    psVector *fwhmMajor = psVectorAllocEmpty (100, PS_DATA_F32);
     332    psVector *fwhmMinor = psVectorAllocEmpty (100, PS_DATA_F32);
     333
     334    for (float ix = -0.4; ix <= +0.4; ix += 0.1) {
     335        for (float iy = -0.4; iy <= +0.4; iy += 0.1) {
    338336
    339337            // use the center of the center pixel of the image
    340             float xc = (0.5 + 0.3*ix)*image->numCols + image->col0 + 0.5;
    341             float yc = (0.5 + 0.3*ix)*image->numRows + image->row0 + 0.5;
     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;
    342340
    343341            // create modelPSF from this model
    344             modelPSF = pmModelFromPSFforXY (psf, xc, yc, 1.0);
    345             if (modelPSF) goto got_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);
    346359        }
    347360    }
    348     psAssert (modelPSF, "Failed to estimate PSF model at image center (psf is invalid everywhere?)");
    349 
    350 got_model:
    351     // get the model full-width at half-max
    352     FWHM_X = 2*modelPSF->modelRadius (modelPSF->params, 0.5);
    353 
    354     // XXX make sure this is consistent with the re-definition of PM_PAR_SXX
    355     shape.sx  = modelPSF->params->data.F32[PM_PAR_SXX];
    356     shape.sy  = modelPSF->params->data.F32[PM_PAR_SYY];
    357     shape.sxy = modelPSF->params->data.F32[PM_PAR_SXY];
    358     axes = psEllipseShapeToAxes (shape, 20.0);
    359 
    360     FWHM_Y = FWHM_X * (axes.minor / axes.major);
    361 
    362     psMetadataAddF32 (recipe, PS_LIST_TAIL, "FWHM_X",   PS_META_REPLACE, "PSF FWHM Major axis", FWHM_X);
    363     psMetadataAddF32 (recipe, PS_LIST_TAIL, "FWHM_Y",   PS_META_REPLACE, "PSF FWHM Minor axis", FWHM_Y);
     361
     362    psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_STDEV | PS_STAT_SAMPLE_QUARTILE);
     363    psVectorStats (stats, fwhmMajor, NULL, NULL, 0);
     364    psMetadataAddF32 (recipe, PS_LIST_TAIL, "FWHM_MAJ",   PS_META_REPLACE, "PSF FWHM Major axis (mean)", stats->sampleMean);
     365    psMetadataAddF32 (recipe, PS_LIST_TAIL, "FW_MJ_SG",   PS_META_REPLACE, "PSF FWHM Major axis (sigma)", stats->sampleStdev);
     366    psMetadataAddF32 (recipe, PS_LIST_TAIL, "FW_MJ_LQ",   PS_META_REPLACE, "PSF FWHM Major axis (upper quartile)", stats->sampleLQ);
     367    psMetadataAddF32 (recipe, PS_LIST_TAIL, "FW_MJ_UQ",   PS_META_REPLACE, "PSF FWHM Major axis (lower quartile)", stats->sampleUQ);
     368
     369    psVectorStats (stats, fwhmMinor, NULL, NULL, 0);
     370    psMetadataAddF32 (recipe, PS_LIST_TAIL, "FWHM_MIN",   PS_META_REPLACE, "PSF FWHM Minor axis (mean)", stats->sampleMean);
     371    psMetadataAddF32 (recipe, PS_LIST_TAIL, "FW_MN_SG",   PS_META_REPLACE, "PSF FWHM Minor axis (sigma)", stats->sampleStdev);
     372    psMetadataAddF32 (recipe, PS_LIST_TAIL, "FW_MN_LQ",   PS_META_REPLACE, "PSF FWHM Minor axis (upper quartile)", stats->sampleLQ);
     373    psMetadataAddF32 (recipe, PS_LIST_TAIL, "FW_MN_UQ",   PS_META_REPLACE, "PSF FWHM Minor axis (lower quartile)", stats->sampleUQ);
     374
    364375    psMetadataAddF32 (recipe, PS_LIST_TAIL, "ANGLE",    PS_META_REPLACE, "PSF angle",           axes.theta);
    365376    psMetadataAddS32 (recipe, PS_LIST_TAIL, "NPSFSTAR", PS_META_REPLACE, "Number of stars used to make PSF", psf->nPSFstars);
    366377    psMetadataAddBool(recipe, PS_LIST_TAIL, "PSFMODEL", PS_META_REPLACE, "Valid PSF Model?", true);
    367     psFree (modelPSF);
    368 
     378
     379    psFree (fwhmMajor);
     380    psFree (fwhmMinor);
     381    psFree (stats);
    369382    return true;
    370383}
Note: See TracChangeset for help on using the changeset viewer.