IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 21, 2011, 10:21:07 AM (15 years ago)
Author:
eugene
Message:

modifiy pmPSF_AxesToModel to take model type (Sxx,Syy and axes.major,minor are different for Sersic-like models)

Location:
branches/eam_branches/ipp-20110710/psModules/src/objects
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110710/psModules/src/objects/pmPSF.c

    r31451 r32151  
    281281// convert the parameters used in the fitted source model
    282282// to the parameters used in the 2D PSF model
     283// XXX this function may be invalid for SERSIC, DEV, EXP models (SQRT2 not used?)
    283284bool pmPSF_FitToModel (psF32 *fittedPar, float minMinorAxis)
    284285{
     
    307308// convert the PSF parameters used in the 2D PSF model fit into the
    308309// parameters used in the source model
     310// XXX this function may be invalid for SERSIC, DEV, EXP models (SQRT2 not used?)
    309311psEllipsePol pmPSF_ModelToFit (psF32 *modelPar)
    310312{
     
    329331// convert the parameters used in the fitted source model to the psEllipseAxes representation
    330332// (major,minor,theta)
    331 psEllipseAxes pmPSF_ModelToAxes (psF32 *modelPar, double maxAR)
     333psEllipseAxes pmPSF_ModelToAxes (psF32 *modelPar, double maxAR, pmModelType type)
    332334{
    333335    psEllipseShape shape;
     
    336338    axes.minor = NAN;
    337339    axes.theta = NAN;
    338 //   XXX: must assert non-NULL input parameter
     340    //   XXX: must assert non-NULL input parameter
    339341    PS_ASSERT_PTR_NON_NULL(modelPar, axes);
    340342
    341     shape.sx  = modelPar[PM_PAR_SXX] / M_SQRT2;
    342     shape.sy  = modelPar[PM_PAR_SYY] / M_SQRT2;
    343     shape.sxy = modelPar[PM_PAR_SXY];
     343    bool useReff = true;
     344    useReff |= (type == pmModelClassGetType ("PS_MODEL_SERSIC"));
     345    useReff |= (type == pmModelClassGetType ("PS_MODEL_DEV"));
     346    useReff |= (type == pmModelClassGetType ("PS_MODEL_EXP"));
     347
     348    if (useReff) {
     349        shape.sx  = modelPar[PM_PAR_SXX];
     350        shape.sy  = modelPar[PM_PAR_SYY];
     351        shape.sxy = modelPar[PM_PAR_SXY];
     352    } else {
     353        shape.sx  = modelPar[PM_PAR_SXX] / M_SQRT2;
     354        shape.sy  = modelPar[PM_PAR_SYY] / M_SQRT2;
     355        shape.sxy = modelPar[PM_PAR_SXY];
     356    }
    344357
    345358    if ((shape.sx == 0) || (shape.sy == 0)) {
     
    357370// convert the psEllipseAxes representation (major,minor,theta) to the parameters used in the
    358371// fitted source model
    359 bool pmPSF_AxesToModel (psF32 *modelPar, psEllipseAxes axes)
     372bool pmPSF_AxesToModel (psF32 *modelPar, psEllipseAxes axes, pmModelType type)
    360373{
    361374    PS_ASSERT_PTR_NON_NULL(modelPar, false);
     
    370383    psEllipseShape shape = psEllipseAxesToShape (axes);
    371384
    372     modelPar[PM_PAR_SXX] = shape.sx * M_SQRT2;
    373     modelPar[PM_PAR_SYY] = shape.sy * M_SQRT2;
    374     modelPar[PM_PAR_SXY] = shape.sxy;
    375 
     385    bool useReff = true;
     386    useReff |= pmModelClassGetType ("PS_MODEL_SERSIC");
     387    useReff |= pmModelClassGetType ("PS_MODEL_DEV");
     388    useReff |= pmModelClassGetType ("PS_MODEL_EXP");
     389
     390    if (useReff) {
     391        modelPar[PM_PAR_SXX] = shape.sx;
     392        modelPar[PM_PAR_SYY] = shape.sy;
     393        modelPar[PM_PAR_SXY] = shape.sxy;
     394    } else {
     395        modelPar[PM_PAR_SXX] = shape.sx * M_SQRT2;
     396        modelPar[PM_PAR_SYY] = shape.sy * M_SQRT2;
     397        modelPar[PM_PAR_SXY] = shape.sxy;
     398    }
    376399    return true;
    377400}
     
    438461# if (0)
    439462    psF32 *params = model->params->data.F32; // Model parameters
    440     psEllipseAxes axes = pmPSF_ModelToAxes(params, MAX_AXIS_RATIO); // Ellipse axes
     463    psEllipseAxes axes = pmPSF_ModelToAxes(params, MAX_AXIS_RATIO, model->type); // Ellipse axes
    441464
    442465    // Curiously, the minor axis can be larger than the major axis, so need to check.
  • branches/eam_branches/ipp-20110710/psModules/src/objects/pmPSF.h

    r31451 r32151  
    106106pmPSF *pmPSFBuildSimple (char *typeName, float sxx, float syy, float sxy, ...);
    107107
    108 bool pmPSF_AxesToModel (psF32 *modelPar, psEllipseAxes axes);
     108bool pmPSF_AxesToModel (psF32 *modelPar, psEllipseAxes axes, pmModelType type);
    109109bool pmPSF_FitToModel (psF32 *fittedPar, float minMinorAxis);
    110110
    111111psEllipsePol pmPSF_ModelToFit (psF32 *modelPar);
    112 psEllipseAxes pmPSF_ModelToAxes (psF32 *modelPar, double maxAR);
     112psEllipseAxes pmPSF_ModelToAxes (psF32 *modelPar, double maxAR, pmModelType type);
    113113
    114114/// Calculate FWHM value from a PSF
  • branches/eam_branches/ipp-20110710/psModules/src/objects/pmSourceIO_CMF_PS1_DV2.c

    r31451 r32151  
    281281        dPAR[PM_PAR_I0]   = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source->psfMagErr : NAN;
    282282
    283         pmPSF_AxesToModel (PAR, axes);
     283        pmPSF_AxesToModel (PAR, axes, modelType);
    284284
    285285        float peakMag     = psMetadataLookupF32 (&status, row, "PEAK_FLUX_AS_MAG");
     
    572572            yErr = dPAR[PM_PAR_YPOS];
    573573
    574             axes = pmPSF_ModelToAxes (PAR, 20.0);
     574            axes = pmPSF_ModelToAxes (PAR, 20.0, model->type);
    575575
    576576            row = psMetadataAlloc ();
Note: See TracChangeset for help on using the changeset viewer.