IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 2, 2009, 3:11:32 PM (17 years ago)
Author:
eugene
Message:

check in changes from genes development branch : extensive changes to moments calculation, psf model generation, aperture residuals

Location:
trunk/psModules/src/objects/models
Files:
4 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/objects/models/pmModel_GAUSS.c

    r25738 r25754  
    11/******************************************************************************
    22 * this file defines the GAUSS source shape model.  Note that these model functions are loaded
    3  * by pmModelGroup.c using 'include', and thus need no 'include' statements of their own.  The
     3 * by pmModelClass.c using 'include', and thus need no 'include' statements of their own.  The
    44 * models use a psVector to represent the set of parameters, with the sequence used to specify
    55 * the meaning of the parameter.  The meaning of the parameters may thus vary depending on the
    6  * specifics of the model.  All models which are used a PSF representations share a few
     6 * specifics of the model.  All models which are used as a PSF representations share a few
    77 * parameters, for which # define names are listed in pmModel.h:
    88
     
    5454
    5555// the model is a function of the pixel coordinate (pixcoord[0,1] = x,y)
     56// 0.5 PIX: the parameters are defined in terms of pixel coords, so the incoming pixcoords
     57// values need to be pixel coords
    5658psF32 PM_MODEL_FUNC(psVector *deriv,
    5759                    const psVector *params,
     
    163165
    164166// make an initial guess for parameters
     167// 0.5 PIX: moments and peaks are in pixel coords, thus so are model parameters
    165168bool PM_MODEL_GUESS (pmModel *model, pmSource *source)
    166169{
     
    178181    psEllipseShape shape = psEllipseAxesToShape (axes);
    179182
    180     PAR[PM_PAR_SKY]  = moments->Sky;
     183    PAR[PM_PAR_SKY]  = 0.0;
    181184    PAR[PM_PAR_I0]   = peak->flux;
    182185    PAR[PM_PAR_XPOS] = peak->xf;
     
    230233    psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0);
    231234    psF64 radius = axes.major * sqrt (2.0 * log(PAR[PM_PAR_I0] / flux));
     235    psAssert (isfinite(radius), "fix this code: radius should not be nan for %f", PAR[PM_PAR_I0]);
     236
    232237    return (radius);
    233238}
     
    340345bool PM_MODEL_FIT_STATUS (pmModel *model)
    341346{
    342     psF32 dP;
    343347    bool  status;
    344348
     
    346350    psF32 *dPAR = model->dparams->data.F32;
    347351
    348     dP = 0;
    349     dP += PS_SQR(dPAR[PM_PAR_SXX] / PAR[PM_PAR_SXX]);
    350     dP += PS_SQR(dPAR[PM_PAR_SYY] / PAR[PM_PAR_SYY]);
    351     dP = sqrt (dP);
    352 
    353352    status = true;
    354     status &= (dP < 0.5);
    355353    status &= (PAR[PM_PAR_I0] > 0);
    356354    status &= ((dPAR[PM_PAR_I0]/PAR[PM_PAR_I0]) < 0.5);
    357355
    358     if (status)
    359         return true;
    360     return false;
     356    return status;
    361357}
    362358
  • trunk/psModules/src/objects/models/pmModel_PGAUSS.c

    r25738 r25754  
    11/******************************************************************************
    22 * this file defines the PGAUSS source shape model.  Note that these model functions are loaded
    3  * by pmModelGroup.c using 'include', and thus need no 'include' statements of their own.  The
     3 * by pmModelClass.c using 'include', and thus need no 'include' statements of their own.  The
    44 * models use a psVector to represent the set of parameters, with the sequence used to specify
    55 * the meaning of the parameter.  The meaning of the parameters may thus vary depending on the
    6  * specifics of the model.  All models which are used a PSF representations share a few
     6 * specifics of the model.  All models which are used as a PSF representations share a few
    77 * parameters, for which # define names are listed in pmModel.h:
    88
     
    5454
    5555// the model is a function of the pixel coordinate (pixcoord[0,1] = x,y)
     56// 0.5 PIX: the parameters are defined in terms of pixel coords, so the incoming pixcoords
     57// values need to be pixel coords
    5658psF32 PM_MODEL_FUNC(psVector *deriv,
    5759                    const psVector *params,
     
    165167
    166168// make an initial guess for parameters
     169// 0.5 PIX: moments and peaks are in pixel coords, thus so are model parameters
    167170bool PM_MODEL_GUESS (pmModel *model, pmSource *source)
    168171{
     
    179182    psEllipseShape shape = psEllipseAxesToShape (axes);
    180183
    181     PAR[PM_PAR_SKY]  = moments->Sky;
     184    PAR[PM_PAR_SKY]  = 0.0;
    182185    PAR[PM_PAR_I0]   = peak->flux;
    183186    PAR[PM_PAR_XPOS] = peak->xf;
     
    258261    // choose a z value guaranteed to be beyond our limit
    259262    float z0 = pow((1.0 / limit), (1.0 / 3.0));
     263    psAssert (isfinite(z0), "fix this code: z0 should not be nan for %f", PAR[PM_PAR_I0]);
    260264    float z1 = (1.0 / limit);
     265    psAssert (isfinite(z1), "fix this code: z1 should not be nan for %f", PAR[PM_PAR_I0]);
    261266    z1 = PS_MAX (z0, z1);
    262267    z0 = 0.0;
     
    389394bool PM_MODEL_FIT_STATUS (pmModel *model)
    390395{
    391     psF32 dP;
    392396    bool  status;
    393397
     
    395399    psF32 *dPAR = model->dparams->data.F32;
    396400
    397     dP = 0;
    398     dP += PS_SQR(dPAR[PM_PAR_SXX] / PAR[PM_PAR_SXX]);
    399     dP += PS_SQR(dPAR[PM_PAR_SYY] / PAR[PM_PAR_SYY]);
    400     dP = sqrt (dP);
    401 
    402401    status = true;
    403     status &= (dP < 0.5);
    404402    status &= (PAR[PM_PAR_I0] > 0);
    405403    status &= ((dPAR[PM_PAR_I0]/PAR[PM_PAR_I0]) < 0.5);
  • trunk/psModules/src/objects/models/pmModel_PS1_V1.c

    r25738 r25754  
    11/******************************************************************************
    2  * this file defines the PS1_V1 source shape model (XXX need a better name!).  Note that these
    3  * model functions are loaded by pmModelGroup.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 PS1_V1 source shape model.  Note that these model functions are loaded
     3 * by pmModelClass.c using 'include', and thus need no 'include' statements of their own.  The
     4 * models use a psVector to represent the set of parameters, with the sequence used to specify
     5 * the meaning of the parameter.  The meaning of the parameters may thus vary depending on the
     6 * specifics of the model.  All models which are used as a PSF representations share a few
     7 * parameters, for which # define names are listed in pmModel.h:
    88
    99   power-law with fitted linear term
     
    4242# define ALPHA_M 0.666
    4343
     44// the model is a function of the pixel coordinate (pixcoord[0,1] = x,y)
     45// 0.5 PIX: the parameters are defined in terms of pixel coords, so the incoming pixcoords
     46// values need to be pixel coords
     47
    4448// Lax parameter limits
    4549static float paramsMinLax[] = { -1.0e3, 1.0e-2, -100, -100, 0.5, 0.5, -1.0, -1.0 };
     
    5761
    5862static bool limitsApply = true;         // Apply limits?
    59 
    6063
    6164psF32 PM_MODEL_FUNC (psVector *deriv,
     
    182185
    183186// make an initial guess for parameters
     187// 0.5 PIX: moments and peaks are in pixel coords, thus so are model parameters
    184188bool PM_MODEL_GUESS (pmModel *model, pmSource *source)
    185189{
     
    206210    if (!isfinite(shape.sxy)) return false;
    207211
    208     // XXX turn this off here for now PAR[PM_PAR_SKY]  = moments->Sky;
    209212    PAR[PM_PAR_SKY]  = 0.0;
    210213    PAR[PM_PAR_I0]   = peak->flux;
     
    292295
    293296    // choose a z value guaranteed to be beyond our limit
    294     float z0 = pow((1.0 / limit), (1.0 / ALPHA));
    295     float z1 = (1.0 / limit) / PAR[PM_PAR_7];
    296     z1 = PS_MAX (z0, z1);
    297     z0 = 0.0;
     297    float z0 = 0.0;
     298    float z1 = pow((1.0 / limit), (1.0 / ALPHA));
     299    psAssert (isfinite(z1), "fix this code: z1 should not be nan for %f", PAR[PM_PAR_7]);
     300    if (PAR[PM_PAR_7] < 0.0) z1 *= 2.0;
    298301
    299302    // perform a type of bisection to find the value
     
    420423bool PM_MODEL_FIT_STATUS (pmModel *model)
    421424{
    422 
    423     psF32 dP;
    424425    bool  status;
    425426
     
    427428    psF32 *dPAR = model->dparams->data.F32;
    428429
    429     dP = 0;
    430     dP += PS_SQR(dPAR[PM_PAR_SXX] / PAR[PM_PAR_SXX]);
    431     dP += PS_SQR(dPAR[PM_PAR_SYY] / PAR[PM_PAR_SYY]);
    432     dP = sqrt (dP);
    433 
    434430    status = true;
    435 //    status &= (dP < 0.5);
    436431    status &= (PAR[PM_PAR_I0] > 0);
    437432    status &= ((dPAR[PM_PAR_I0]/PAR[PM_PAR_I0]) < 0.5);
  • trunk/psModules/src/objects/models/pmModel_QGAUSS.c

    r25738 r25754  
    11/******************************************************************************
    22 * this file defines the QGAUSS source shape model (XXX need a better name!).  Note that these
    3  * model functions are loaded by pmModelGroup.c using 'include', and thus need no 'include'
     3 * model functions are loaded by pmModelClass.c using 'include', and thus need no 'include'
    44 * statements of their own.  The models use a psVector to represent the set of parameters, with
    55 * the sequence used to specify the meaning of the parameter.  The meaning of the parameters
     
    3838# define PM_MODEL_FIT_STATUS      pmModelFitStatus_QGAUSS
    3939# define PM_MODEL_SET_LIMITS      pmModelSetLimits_QGAUSS
     40
     41// the model is a function of the pixel coordinate (pixcoord[0,1] = x,y)
     42// 0.5 PIX: the parameters are defined in terms of pixel coords, so the incoming pixcoords
     43// values need to be pixel coords
    4044
    4145// Lax parameter limits
     
    178182
    179183// make an initial guess for parameters
     184// 0.5 PIX: moments and peaks are in pixel coords, thus so are model parameters
    180185bool PM_MODEL_GUESS (pmModel *model, pmSource *source)
    181186{
     
    202207    if (!isfinite(shape.sxy)) return false;
    203208
    204     // XXX turn this off here for now PAR[PM_PAR_SKY]  = moments->Sky;
    205209    PAR[PM_PAR_SKY]  = 0.0;
    206210    PAR[PM_PAR_I0]   = peak->flux;
     
    283287    // choose a z value guaranteed to be beyond our limit
    284288    float z0 = pow((1.0 / limit), (1.0 / 2.25));
     289    psAssert (isfinite(z0), "fix this code: z0 should not be nan for %f", PAR[PM_PAR_7]);
    285290    float z1 = (1.0 / limit) / PAR[PM_PAR_7];
     291    psAssert (isfinite(z1), "fix this code: z1 should not be nan for %f", PAR[PM_PAR_7]);
    286292    z1 = PS_MAX (z0, z1);
    287293    z0 = 0.0;
     
    409415bool PM_MODEL_FIT_STATUS (pmModel *model)
    410416{
    411 
    412     psF32 dP;
    413417    bool  status;
    414418
     
    416420    psF32 *dPAR = model->dparams->data.F32;
    417421
    418     dP = 0;
    419     dP += PS_SQR(dPAR[PM_PAR_SXX] / PAR[PM_PAR_SXX]);
    420     dP += PS_SQR(dPAR[PM_PAR_SYY] / PAR[PM_PAR_SYY]);
    421     dP = sqrt (dP);
    422 
    423422    status = true;
    424 //    status &= (dP < 0.5);
    425423    status &= (PAR[PM_PAR_I0] > 0);
    426424    status &= ((dPAR[PM_PAR_I0]/PAR[PM_PAR_I0]) < 0.5);
  • trunk/psModules/src/objects/models/pmModel_RGAUSS.c

    r25738 r25754  
    11/******************************************************************************
    22 * this file defines the RGAUSS source shape model (XXX need a better name!).  Note that these
    3  * model functions are loaded by pmModelGroup.c using 'include', and thus need no 'include'
     3 * model functions are loaded by pmModelClass.c using 'include', and thus need no 'include'
    44 * statements of their own.  The models use a psVector to represent the set of parameters, with
    55 * 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
     6 * may thus vary depending on the specifics of the model.  All models which are used as a PSF
    77 * representations share a few parameters, for which # define names are listed in pmModel.h:
    88
     
    3939# define PM_MODEL_SET_LIMITS      pmModelSetLimits_RGAUSS
    4040
     41// the model is a function of the pixel coordinate (pixcoord[0,1] = x,y)
     42// 0.5 PIX: the parameters are defined in terms of pixel coords, so the incoming pixcoords
     43// values need to be pixel coords
     44
    4145// Lax parameter limits
    4246static float paramsMinLax[] = { -1.0e3, 1.0e-2, -100, -100, 0.5, 0.5, -1.0, 1.25 };
     
    8791        dPAR[PM_PAR_SXY] = -q*X*Y;
    8892
    89         // this model derivative is undefined at z = 0.0, but is actually 0.0
     93        // this model derivative is undefined at z = 0.0, but the limit is zero as z -> 0.0
    9094        dPAR[PM_PAR_7] = (z == 0.0) ? 0.0 : -5.0*t*log(z)*p*z;
    9195    }
     
    172176
    173177// make an initial guess for parameters
     178// 0.5 PIX: moments and peaks are in pixel coords, thus so are model parameters
    174179bool PM_MODEL_GUESS (pmModel *model, pmSource *source)
    175180{
     
    196201    if (!isfinite(shape.sxy)) return false;
    197202
    198     PAR[PM_PAR_SKY]  = moments->Sky;
     203    PAR[PM_PAR_SKY]  = 0.0;
    199204    PAR[PM_PAR_I0]   = peak->flux;
    200205    PAR[PM_PAR_XPOS] = peak->xf;
     
    276281    // choose a z value guaranteed to be beyond our limit
    277282    float z0 = pow((1.0 / limit), (1.0 / PAR[PM_PAR_7]));
     283    psAssert (isfinite(z0), "fix this code: z0 should not be nan for %f", PAR[PM_PAR_7]);
    278284    float z1 = (1.0 / limit);
     285    psAssert (isfinite(z1), "fix this code: z1 should not be nan for %f", PAR[PM_PAR_7]);
    279286    z1 = PS_MAX (z0, z1);
    280287    z0 = 0.0;
     
    402409bool PM_MODEL_FIT_STATUS (pmModel *model)
    403410{
    404 
    405     psF32 dP;
    406411    bool  status;
    407412
     
    409414    psF32 *dPAR = model->dparams->data.F32;
    410415
    411     dP = 0;
    412     dP += PS_SQR(dPAR[PM_PAR_SXX] / PAR[PM_PAR_SXX]);
    413     dP += PS_SQR(dPAR[PM_PAR_SYY] / PAR[PM_PAR_SYY]);
    414     dP = sqrt (dP);
    415 
    416416    status = true;
    417     status &= (dP < 0.5);
    418417    status &= (PAR[PM_PAR_I0] > 0);
    419418    status &= ((dPAR[PM_PAR_I0]/PAR[PM_PAR_I0]) < 0.5);
  • trunk/psModules/src/objects/models/pmModel_SERSIC.c

    r25738 r25754  
    11/******************************************************************************
    22 * this file defines the SERSIC source shape model.  Note that these model functions are loaded
    3  * by pmModelGroup.c using 'include', and thus need no 'include' statements of their own.  The
     3 * by pmModelClass.c using 'include', and thus need no 'include' statements of their own.  The
    44 * models use a psVector to represent the set of parameters, with the sequence used to specify
    55 * the meaning of the parameter.  The meaning of the parameters may thus vary depending on the
    6  * specifics of the model.  All models which are used a PSF representations share a few
     6 * specifics of the model.  All models which are used as a PSF representations share a few
    77 * parameters, for which # define names are listed in pmModel.h:
    88
     
    4141# define PM_MODEL_FIT_STATUS      pmModelFitStatus_SERSIC
    4242# define PM_MODEL_SET_LIMITS      pmModelSetLimits_SERSIC
     43
     44// the model is a function of the pixel coordinate (pixcoord[0,1] = x,y)
     45// 0.5 PIX: the parameters are defined in terms of pixel coords, so the incoming pixcoords
     46// values need to be pixel coords
    4347
    4448// Lax parameter limits
     
    186190
    187191// make an initial guess for parameters
     192// 0.5 PIX: moments and peaks are in pixel coords, thus so are model parameters
    188193bool PM_MODEL_GUESS (pmModel *model, pmSource *source)
    189194{
     
    210215    if (!isfinite(shape.sxy)) return false;
    211216
    212     // XXX PAR[PM_PAR_SKY]  = moments->Sky;
    213217    PAR[PM_PAR_SKY]  = 0.0;
    214218    PAR[PM_PAR_I0]   = peak->flux;
     
    284288
    285289    psF64 z = pow (-log(limit), (1.0 / PAR[PM_PAR_7]));
     290    psAssert (isfinite(z), "fix this code: z should not be nan for %f", PAR[PM_PAR_7]);
    286291
    287292    psF64 radius = sigma * sqrt (2.0 * z);
     293    psAssert (isfinite(radius), "fix this code: radius should not be nan for %f, %f", PAR[PM_PAR_7], sigma);
    288294
    289295    if (isnan(radius))
     
    392398bool PM_MODEL_FIT_STATUS (pmModel *model)
    393399{
    394 
    395     psF32 dP;
    396400    bool  status;
    397401
     
    399403    psF32 *dPAR = model->dparams->data.F32;
    400404
    401     dP = 0;
    402     dP += PS_SQR(dPAR[PM_PAR_SXX] / PAR[PM_PAR_SXX]);
    403     dP += PS_SQR(dPAR[PM_PAR_SYY] / PAR[PM_PAR_SYY]);
    404     dP = sqrt (dP);
    405 
    406405    status = true;
    407 //    status &= (dP < 0.5);
    408406    status &= (PAR[PM_PAR_I0] > 0);
    409407    status &= ((dPAR[PM_PAR_I0]/PAR[PM_PAR_I0]) < 0.5);
    410408
     409<<<<<<< .working
    411410    fprintf (stderr, "SERSIC status pars: dP: %f, I0: %f, S/N: %f\n",
    412411             dP, PAR[PM_PAR_I0], (dPAR[PM_PAR_I0]/PAR[PM_PAR_I0]));
    413412
     413=======
     414>>>>>>> .merge-right.r25750
    414415    return status;
    415416}
Note: See TracChangeset for help on using the changeset viewer.