IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 19, 2007, 4:22:26 PM (19 years ago)
Author:
Paul Price
Message:

Extensive changes to APIs to allow use of a nominated value to mask
against (the maskVal). Previously, the mask values were either
hard-coded (e.g., PM_MASK_SAT) or taken as anything non-zero. The
code is tested under psphot (which has similar changes) and does not
crash, but neither is it successful in marking all bad pixels (EAM
will investigate). For this reason, I have left the "gutter" pixels
(cell gaps) set to 0 instead of NAN in pmFPAMosaic.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/objects/pmPSF.c

    r13803 r13898  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-06-13 23:41:51 $
     8 *  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-06-20 02:22:26 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    8181/*****************************************************************************
    8282 pmPSFAlloc (type): allocate a pmPSF.
    83  
     83
    8484 NOTE: PSF model parameters which are not modeled on an image are set to NULL in psf->params.
    85  
     85
    8686 These are normally:
    87  
     87
    8888 X-center
    8989 Y-center
     
    180180    // set model parameters for this source based on PSF information
    181181    if (!modelFromPSFFunc (modelPSF, modelEXT, psf)) {
    182         psError(PM_ERR_PSF, false, "Failed to set model params from PSF");
    183         psFree(modelPSF);
    184         return NULL;
     182        psError(PM_ERR_PSF, false, "Failed to set model params from PSF");
     183        psFree(modelPSF);
     184        return NULL;
    185185    }
    186186    // XXX note that model->residuals is just a reference
     
    245245// New Concept: the PSF modelling function fits the polarization terms e0, e1, e2:
    246246
    247 // convert the parameters used in the fitted source model 
     247// convert the parameters used in the fitted source model
    248248// to the parameters used in the 2D PSF model
    249249bool pmPSF_FitToModel (psF32 *fittedPar, float minMinorAxis)
     
    257257    psEllipseAxes axes;
    258258    if (psEllipsePolToAxes (pol, minMinorAxis, &axes) != PS_ERR_NONE) {
    259         psError(PM_ERR_PSF, false, "Failed to convert e[012] (%g,%g,%g) to axes",
    260                 pol.e0, pol.e1, pol.e2);
    261         return false;
     259        psError(PM_ERR_PSF, false, "Failed to convert e[012] (%g,%g,%g) to axes",
     260                pol.e0, pol.e1, pol.e2);
     261        return false;
    262262    }
    263263    psEllipseShape shape = psEllipseAxesToShape (axes);
     
    279279    shape.sy  = modelPar[PM_PAR_SYY] / M_SQRT2;
    280280    shape.sxy = modelPar[PM_PAR_SXY];
    281    
     281
    282282    psEllipsePol pol = psEllipseShapeToPol (shape);
    283    
     283
    284284    return pol;
    285285}
     
    297297
    298298    if ((shape.sx == 0) || (shape.sy == 0)) {
    299         axes.major = 0.0;
    300         axes.minor = 0.0;
    301         axes.theta = 0.0;
     299        axes.major = 0.0;
     300        axes.minor = 0.0;
     301        axes.theta = 0.0;
    302302    } else {
    303         // XXX this is not really consistent with the model fit range above
    304         axes = psEllipseShapeToAxes (shape, maxAR);
    305     }
    306    
     303        // XXX this is not really consistent with the model fit range above
     304        axes = psEllipseShapeToAxes (shape, maxAR);
     305    }
     306
    307307    return axes;
    308308}
     
    313313{
    314314    if ((axes.major <= 0) || (axes.minor <= 0)) {
    315         modelPar[PM_PAR_SXX] = 0.0;
    316         modelPar[PM_PAR_SYY] = 0.0;
    317         modelPar[PM_PAR_SXY] = 0.0;
    318         return true;
    319     }   
    320    
     315        modelPar[PM_PAR_SXX] = 0.0;
     316        modelPar[PM_PAR_SYY] = 0.0;
     317        modelPar[PM_PAR_SXY] = 0.0;
     318        return true;
     319    }
     320
    321321    psEllipseShape shape = psEllipseAxesToShape (axes);
    322322
     
    478478
    479479// we generate the growth curve for the center of the image with the specified psf model
    480 bool pmGrowthCurveGenerate (pmReadout *readout, pmPSF *psf, bool ignore)
     480bool pmGrowthCurveGenerate (pmReadout *readout, pmPSF *psf, bool ignore, psMaskType maskVal, psMaskType mark)
    481481{
    482482
     
    526526    // no need to mask the source here
    527527    // XXX should we measure this for the analytical model only or the full model?
    528     pmModelAdd (image, NULL, model, PM_MODEL_OP_FULL);
     528    pmModelAdd (image, NULL, model, PM_MODEL_OP_FULL, maskVal);
    529529
    530530    // loop over a range of source fluxes
    531531    // no need to interpolate since we have forced the object center
    532532    // to 0.5, 0.5 above
    533     bool completeGrowthCurve = true;            // do we have a complete curve of growth?
     533    bool completeGrowthCurve = true;            // do we have a complete curve of growth?
    534534    for (int i = 0; i < psf->growth->radius->n; i++) {
    535535
     
    537537
    538538        // mask the given aperture and measure the apMag
    539         psImageKeepCircle (mask, xc, yc, radius, "OR", PM_MASK_MARK);
    540         if (!pmSourcePhotometryAper (&apMag, model, image, mask)) {
    541             psError(PM_ERR_PHOTOM, false, "Measuring apMag for radius == %g", radius);
    542             completeGrowthCurve = false;
    543             break;
    544         }
    545 
    546         // XXX since we re-mask on each pass, this could be dropped.
    547         psImageKeepCircle (mask, xc, yc, radius, "AND", PS_NOT_U8(PM_MASK_MARK));
     539        psImageKeepCircle (mask, xc, yc, radius, "OR", mark);
     540        if (!pmSourcePhotometryAper (&apMag, model, image, mask, maskVal)) {
     541            psError(PM_ERR_PHOTOM, false, "Measuring apMag for radius == %g", radius);
     542            completeGrowthCurve = false;
     543            break;
     544        }
     545
     546        // XXX since we re-mask on each pass, this could be dropped.
     547        psImageKeepCircle (mask, xc, yc, radius, "AND", PS_NOT_U8(mark));
    548548
    549549        // the 'ignore' mode is for testing
     
    556556
    557557    if (completeGrowthCurve) {
    558         psf->growth->apRef = psVectorInterpolate (psf->growth->radius, psf->growth->apMag, psf->growth->refRadius);
    559         psf->growth->apLoss = psf->growth->fitMag - psf->growth->apRef;
     558        psf->growth->apRef = psVectorInterpolate (psf->growth->radius, psf->growth->apMag, psf->growth->refRadius);
     559        psf->growth->apLoss = psf->growth->fitMag - psf->growth->apRef;
    560560    } else {
    561         psf->growth->apRef = NAN;
    562         psf->growth->apLoss = 0;
     561        psf->growth->apRef = NAN;
     562        psf->growth->apLoss = 0;
    563563    }
    564564
Note: See TracChangeset for help on using the changeset viewer.