IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 27, 2007, 12:14:08 PM (19 years ago)
Author:
magnier
Message:

converting the PSF model fits to the polariation terms (replacing Sx,Sy,Sxy)

File:
1 edited

Legend:

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

    r13034 r13064  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-04-26 01:20:29 $
     8 *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-04-27 22:14:08 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    236236}
    237237
     238// New Concept: the PSF modelling function fits the polarization terms e0, e1, e2:
     239
     240// convert the parameters used in the fitted source model
     241// to the parameters used in the 2D PSF model
     242bool pmPSF_FitToModel (psF32 *fittedPar, float minMinorAxis)
     243{
     244    psEllipsePol pol;
     245
     246    pol.e0 = fittedPar[PM_PAR_E0];
     247    pol.e1 = fittedPar[PM_PAR_E1];
     248    pol.e2 = fittedPar[PM_PAR_E2];
     249
     250    psEllipseAxes axes = psEllipsePolToAxes (pol, minMinorAxis);
     251    psEllipseShape shape = psEllipseAxesToShape (axes);
     252
     253    fittedPar[PM_PAR_SXX] = shape.sx * M_SQRT2;
     254    fittedPar[PM_PAR_SYY] = shape.sy * M_SQRT2;
     255    fittedPar[PM_PAR_SXY] = shape.sxy;
     256
     257    return true;
     258}
     259
     260// convert the PSF parameters used in the 2D PSF model fit into the
     261// parameters used in the source model
     262psEllipsePol pmPSF_ModelToFit (psF32 *modelPar)
     263{
     264    psEllipseShape shape;
     265
     266    shape.sx  = modelPar[PM_PAR_SXX] / M_SQRT2;
     267    shape.sy  = modelPar[PM_PAR_SYY] / M_SQRT2;
     268    shape.sxy = modelPar[PM_PAR_SXY];
     269   
     270    psEllipsePol pol = psEllipseShapeToPol (shape);
     271   
     272    return pol;
     273}
     274
     275// convert the parameters used in the fitted source model to the psEllipseAxes representation
     276// (major,minor,theta)
     277psEllipseAxes pmPSF_ModelToAxes (psF32 *modelPar, double maxAR)
     278{
     279    psEllipseShape shape;
     280    psEllipseAxes axes;
     281
     282    shape.sx  = modelPar[PM_PAR_SXX] / M_SQRT2;
     283    shape.sy  = modelPar[PM_PAR_SYY] / M_SQRT2;
     284    shape.sxy = modelPar[PM_PAR_SXY];
     285
     286    if ((shape.sx == 0) || (shape.sy == 0)) {
     287        axes.major = 0.0;
     288        axes.minor = 0.0;
     289        axes.theta = 0.0;
     290    } else {
     291        // XXX this is not really consistent with the model fit range above
     292        axes = psEllipseShapeToAxes (shape, maxAR);
     293    }
     294   
     295    return axes;
     296}
     297
     298// convert the psEllipseAxes representation (major,minor,theta) to the parameters used in the
     299// fitted source model
     300bool pmPSF_AxesToModel (psF32 *modelPar, psEllipseAxes axes)
     301{
     302    if ((axes.major <= 0) || (axes.minor <= 0)) {
     303        modelPar[PM_PAR_SXX] = 0.0;
     304        modelPar[PM_PAR_SYY] = 0.0;
     305        modelPar[PM_PAR_SXY] = 0.0;
     306        return true;
     307    }   
     308   
     309    psEllipseShape shape = psEllipseAxesToShape (axes);
     310
     311    modelPar[PM_PAR_SXX] = shape.sx * M_SQRT2;
     312    modelPar[PM_PAR_SYY] = shape.sy * M_SQRT2;
     313    modelPar[PM_PAR_SXY] = shape.sxy;
     314
     315    return true;
     316}
     317
    238318// generate a psf model of the requested type, with fixed shape
    239319pmPSF *pmPSFBuildSimple (char *typeName, float sxx, float syy, float sxy, ...)
     
    247327    pmPSF *psf = pmPSFAlloc (type, true, psfTrend);
    248328
     329    psVector *par = psVectorAlloc (psf->params_NEW->n, PS_TYPE_F32);
     330    par->data.F32[PM_PAR_SXX] = sxx;
     331    par->data.F32[PM_PAR_SYY] = syy;
     332    par->data.F32[PM_PAR_SXY] = sxy;
     333
     334    psEllipsePol pol = pmPSF_ModelToFit(par->data.F32);
     335
    249336    // set the psf shape parameters
    250     psPolynomial2D *poly = psf->params_NEW->data[PM_PAR_SXX];
    251     poly->coeff[0][0] = M_SQRT2*sxx;
    252 
    253     poly = psf->params_NEW->data[PM_PAR_SYY];
    254     poly->coeff[0][0] = M_SQRT2*syy;
    255 
    256     poly = psf->params_NEW->data[PM_PAR_SXY];
    257     poly->coeff[0][0] = sxy;
     337    psPolynomial2D *poly = NULL;
     338    poly = psf->params_NEW->data[PM_PAR_E0];
     339    poly->coeff[0][0] = pol.e0;
     340
     341    poly = psf->params_NEW->data[PM_PAR_E1];
     342    poly->coeff[0][0] = pol.e1;
     343
     344    poly = psf->params_NEW->data[PM_PAR_E2];
     345    poly->coeff[0][0] = pol.e2;
    258346
    259347    for (int i = PM_PAR_SXY + 1; i < psf->params_NEW->n; i++) {
     
    263351    va_end(ap);
    264352
     353    psFree (par);
    265354    psFree (psfTrend);
    266355    return psf;
Note: See TracChangeset for help on using the changeset viewer.