IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 3, 2013, 2:37:22 PM (13 years ago)
Author:
eugene
Message:

deprecate KiiOpen,KiiClose (now KapaOpen,etc); major rework of psEllipse translations : use common functions pmModelAxesToParams and pmModelParamsToAxes ; use new convergence method in pmPCM_MinimizeChisq; add convergence crerition options to psMinimization; threaded versions of pmPSFtryFitEXT and pmPSFtryFitPSF

Location:
trunk/psModules
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules

  • trunk/psModules/src/objects/models/pmModel_QGAUSS.c

    r35560 r35768  
    11/******************************************************************************
    2  * this file defines the QGAUSS source shape model (XXX need a better name!).  Note that these
    3  * model functions are loaded by pmModelClass.c using 'include', and thus need no 'include'
    4  * statements of their own.  The models use a psVector to represent the set of parameters, with
    5  * the sequence used to specify the meaning of the parameter.  The meaning of the parameters
    6  * may thus vary depending on the specifics of the model.  All models which are used a PSF
    7  * representations share a few parameters, for which # define names are listed in pmModel.h:
     2 * this file defines the QGAUSS source shape model.  Note that these model functions are
     3 * loaded by pmModelClass.c using 'include', and thus need no 'include' statements of
     4 * their own.  The models use a psVector to represent the set of parameters, with the
     5 * sequence used to specify the meaning of the parameter.  The meaning of the parameters
     6 * may thus vary depending on the specifics of the model.  All models which are used as a
     7 * PSF representations share a few parameters, for which # define names are listed in
     8 * pmModel.h:
    89
    910   power-law with fitted linear term
     
    1415   * PM_PAR_XPOS 2  - X center of object
    1516   * PM_PAR_YPOS 3  - Y center of object
    16    * PM_PAR_SXX 4   - X^2 term of elliptical contour (sqrt(2) / SigmaX)
    17    * PM_PAR_SYY 5   - Y^2 term of elliptical contour (sqrt(2) / SigmaY)
     17   * PM_PAR_SXX 4   - X^2 term of elliptical contour (SigmaX / sqrt(2))
     18   * PM_PAR_SYY 5   - Y^2 term of elliptical contour (SigmaY / sqrt(2))
    1819   * PM_PAR_SXY 6   - X*Y term of elliptical contour
    1920   * PM_PAR_7   7   - amplitude of the linear component (k)
     
    138139# define AR_MAX 20.0
    139140# define AR_RATIO 0.99
    140 
    141141bool PM_MODEL_LIMITS (psMinConstraintMode mode, int nParam, float *params, float *beta)
    142142{
     
    149149    float q2 = NAN;
    150150    if (nParam == PM_PAR_SXY) {
    151         float f1 = 1.0 / PS_SQR(params[PM_PAR_SYY]) + 1.0 / PS_SQR(params[PM_PAR_SXX]);
    152         float f2 = 1.0 / PS_SQR(params[PM_PAR_SYY]) - 1.0 / PS_SQR(params[PM_PAR_SXX]);
     151        // NOTE: the factor of 2 is needed to convert par[SXX,SYY] to shape.sx,sy
     152        float f1 = 2.0 / PS_SQR(params[PM_PAR_SYY]) + 2.0 / PS_SQR(params[PM_PAR_SXX]);
     153        float f2 = 2.0 / PS_SQR(params[PM_PAR_SYY]) - 2.0 / PS_SQR(params[PM_PAR_SXX]);
    153154        float q1 = PS_SQR(f1)*AR_RATIO - PS_SQR(f2);
    154155        q1 = (q1 < 0.0) ? 0.0 : q1;
     
    203204          return true;
    204205      }
    205     default:
     206      default:
    206207        psAbort("invalid choice for limits");
    207208    }
     
    221222
    222223    // set the shape parameters
    223     if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments)) {
     224    if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments, false)) {
    224225      return false;
    225226    }
     
    245246{
    246247    float z, norm;
    247     psEllipseShape shape;
    248248
    249249    psF32 *PAR = params->data.F32;
    250250
    251     shape.sx  = PAR[PM_PAR_SXX] / M_SQRT2;
    252     shape.sy  = PAR[PM_PAR_SYY] / M_SQRT2;
    253     shape.sxy = PAR[PM_PAR_SXY];
    254 
    255     psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0);
     251    psEllipseAxes axes;
     252    pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], false);
    256253    float AspectRatio = axes.minor / axes.major;
    257254
     
    285282{
    286283    psF64 z;
    287     psEllipseShape shape;
    288284
    289285    psF32 *PAR = params->data.F32;
     
    293289    if (flux >= PAR[PM_PAR_I0]) return 1.0;
    294290
    295     // if (PAR[PM_PAR_7] == 0.0) return powf(PAR[PM_PAR_I0] / flux - 1.0, 1.0 / ALPHA);
    296 
    297     shape.sx  = PAR[PM_PAR_SXX] / M_SQRT2;
    298     shape.sy  = PAR[PM_PAR_SYY] / M_SQRT2;
    299     shape.sxy = PAR[PM_PAR_SXY];
    300 
    301     psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0);
     291    psEllipseAxes axes;
     292    pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], false);
    302293    psF64 sigma = axes.major;
    303294
     
    307298        return ( sigma * sqrt (2.0 * z) );
    308299    }
    309 
    310300    psF64 limit = flux / PAR[PM_PAR_I0];
    311301
     
    367357    // the 2D PSF model fits polarization terms (E0,E1,E2)
    368358    // convert to shape terms (SXX,SYY,SXY)
    369     if (!pmPSF_FitToModel (out, 0.1)) {
     359    bool useReff = pmModelUseReff (modelPSF->type);
     360    if (!pmPSF_FitToModel (out, 0.1, useReff)) {
    370361        psTrace("psModules.objects", 5, "Failed to fit object at (r,c) = (%.1f,%.1f)", in[PM_PAR_YPOS], in[PM_PAR_XPOS]);
    371362        return false;
     
    424415    // the 2D PSF model fits polarization terms (E0,E1,E2)
    425416    // convert to shape terms (SXX,SYY,SXY)
    426     // XXX user-defined value for limit?
    427     if (!pmPSF_FitToModel (PAR, 0.1)) {
     417    bool useReff = pmModelUseReff (model->type);
     418    if (!pmPSF_FitToModel (PAR, 0.1, useReff)) {
    428419        psTrace ("psModules.objects", 3, "Failed to fit object at (r,c) = (%.1f,%.1f)", Xo, Yo);
    429420        return false;
Note: See TracChangeset for help on using the changeset viewer.