IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 35644


Ignore:
Timestamp:
Jun 11, 2013, 9:15:36 AM (13 years ago)
Author:
eugene
Message:

replace code which converts the PAR[SXX,SXY,SYY] values to shape and then axes with calls to pmModelParamsToAxes : the relationship depends on the model type. placing the code in a single function avoids inconsistent conversions

Location:
branches/eam_branches/ipp-20130509/psModules/src/objects/models
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20130509/psModules/src/objects/models/pmModel_DEV.c

    r35560 r35644  
    123123
    124124        // first, use Rmajor and index to find the central pixel flux (fraction of total flux)
    125         psEllipseShape shape;
    126 
    127         shape.sx  = PAR[PM_PAR_SXX];
    128         shape.sy  = PAR[PM_PAR_SYY];
    129         shape.sxy = PAR[PM_PAR_SXY];
    130 
    131         // for a non-circular Sersic, the flux of the Rmajor equivalent is scaled by the AspectRatio
    132         psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0);
     125        psEllipseAxes axes;
     126        pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], true);
    133127
    134128        // get the central pixel flux from the lookup table
     
    303297
    304298    // set the shape parameters
    305     // XXX adjust this?
    306     if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments)) {
     299    if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments, true)) {
    307300      return false;
    308301    }
     
    330323psF64 PM_MODEL_FLUX (const psVector *params)
    331324{
    332     psEllipseShape shape;
    333 
    334325    psF32 *PAR = params->data.F32;
    335326
    336     shape.sx  = PAR[PM_PAR_SXX];
    337     shape.sy  = PAR[PM_PAR_SYY];
    338     shape.sxy = PAR[PM_PAR_SXY];
    339 
    340     // for a non-circular DeVaucouleur, the flux of the Rmajor equivalent is scaled by the AspectRatio
    341     psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0);
     327    psEllipseAxes axes;
     328    pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], true);
    342329    float AspectRatio = axes.minor / axes.major;
    343330
     
    359346psF64 PM_MODEL_RADIUS (const psVector *params, psF64 flux)
    360347{
    361     psEllipseShape shape;
    362 
    363348    psF32 *PAR = params->data.F32;
    364349
     
    370355        return (1.0);
    371356
    372     shape.sx  = PAR[PM_PAR_SXX];
    373     shape.sy  = PAR[PM_PAR_SYY];
    374     shape.sxy = PAR[PM_PAR_SXY];
    375 
    376     psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0);
     357    psEllipseAxes axes;
     358    pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], true);
    377359
    378360    // f = Io exp(-z^n) -> z^n = ln(Io/f)
     
    382364    psAssert (isfinite(radius), "fix this code: radius should not be nan for Io = %f, flux = %f, major = %f (%f, %f, %f)",
    383365              PAR[PM_PAR_I0], flux, axes.major, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY]);
    384 
    385366    return (radius);
    386367}
     
    407388    // the 2D PSF model fits polarization terms (E0,E1,E2)
    408389    // convert to shape terms (SXX,SYY,SXY)
    409     if (!pmPSF_FitToModel (out, 0.1)) {
     390    bool useReff = pmModelUseReff (modelPSF->type);
     391    if (!pmPSF_FitToModel (out, 0.1, useReff)) {
    410392        psTrace("psModules.objects", 5, "Failed to fit object at (r,c) = (%.1f,%.1f)", in[PM_PAR_YPOS], in[PM_PAR_XPOS]);
    411393        return false;
     
    460442    // convert to shape terms (SXX,SYY,SXY)
    461443    // XXX user-defined value for limit?
    462     if (!pmPSF_FitToModel (PAR, 0.1)) {
     444    bool useReff = pmModelUseReff (model->type);
     445    if (!pmPSF_FitToModel (PAR, 0.1, useReff)) {
    463446        psTrace ("psModules.objects", 3, "Failed to fit object at (r,c) = (%.1f,%.1f)", Xo, Yo);
    464447        return false;
  • branches/eam_branches/ipp-20130509/psModules/src/objects/models/pmModel_EXP.c

    r35560 r35644  
    115115
    116116        // first, use Rmajor and index to find the central pixel flux (fraction of total flux)
    117         psEllipseShape shape;
    118 
    119         shape.sx  = PAR[PM_PAR_SXX];
    120         shape.sy  = PAR[PM_PAR_SYY];
    121         shape.sxy = PAR[PM_PAR_SXY];
    122 
    123         // for a non-circular Sersic, the flux of the Rmajor equivalent is scaled by the AspectRatio
    124         psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0);
     117        psEllipseAxes axes;
     118        pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], true);
    125119
    126120        // get the central pixel flux from the lookup table
     
    295289
    296290    // set the shape parameters
    297     // XXX adjust this?
    298     if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments)) {
     291    if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments, true)) {
    299292      return false;
    300293    }
     
    316309psF64 PM_MODEL_FLUX (const psVector *params)
    317310{
    318     psEllipseShape shape;
    319 
    320311    psF32 *PAR = params->data.F32;
    321312
    322     shape.sx  = PAR[PM_PAR_SXX];
    323     shape.sy  = PAR[PM_PAR_SYY];
    324     shape.sxy = PAR[PM_PAR_SXY];
    325 
    326     // for a non-circular Exponential, the flux of the Rmajor equivalent is scaled by the AspectRatio
    327     psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0);
     313    psEllipseAxes axes;
     314    pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], true);
    328315    float AspectRatio = axes.minor / axes.major;
    329316
     
    345332psF64 PM_MODEL_RADIUS (const psVector *params, psF64 flux)
    346333{
    347     psEllipseShape shape;
    348 
    349334    psF32 *PAR = params->data.F32;
    350335
     
    356341        return (1.0);
    357342
    358     shape.sx  = PAR[PM_PAR_SXX];
    359     shape.sy  = PAR[PM_PAR_SYY];
    360     shape.sxy = PAR[PM_PAR_SXY];
    361 
    362     psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0);
     343    psEllipseAxes axes;
     344    pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], true);
    363345
    364346    // f = Io exp(-sqrt(z)) -> sqrt(z) = ln(Io/f)
     
    392374    // the 2D PSF model fits polarization terms (E0,E1,E2)
    393375    // convert to shape terms (SXX,SYY,SXY)
    394     if (!pmPSF_FitToModel (out, 0.1)) {
     376    bool useReff = pmModelUseReff (modelPSF->type);
     377    if (!pmPSF_FitToModel (out, 0.1, useReff)) {
    395378        psTrace("psModules.objects", 5, "Failed to fit object at (r,c) = (%.1f,%.1f)", in[PM_PAR_YPOS], in[PM_PAR_XPOS]);
    396379        return false;
     
    445428    // convert to shape terms (SXX,SYY,SXY)
    446429    // XXX user-defined value for limit?
    447     if (!pmPSF_FitToModel (PAR, 0.1)) {
     430    bool useReff = pmModelUseReff (model->type);
     431    if (!pmPSF_FitToModel (PAR, 0.1, useReff)) {
    448432        psTrace ("psModules.objects", 3, "Failed to fit object at (r,c) = (%.1f,%.1f)", Xo, Yo);
    449433        return false;
  • branches/eam_branches/ipp-20130509/psModules/src/objects/models/pmModel_GAUSS.c

    r35560 r35644  
    200200
    201201    // set the shape parameters
    202     if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments)) {
     202    if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments, false)) {
    203203      return false;
    204204    }
     
    219219psF64 PM_MODEL_FLUX (const psVector *params)
    220220{
    221 
    222     psEllipseShape shape;
    223 
    224221    psF32 *PAR = params->data.F32;
    225222
    226     shape.sx  = PAR[PM_PAR_SXX] / M_SQRT2;
    227     shape.sy  = PAR[PM_PAR_SYY] / M_SQRT2;
    228     shape.sxy = PAR[PM_PAR_SXY];
     223    psEllipseAxes axes;
     224    pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], false);
    229225
    230226    // Area is equivalent to 2 pi sigma^2
    231     // axes ratio < 20
    232     psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0);
    233227    psF64 Area = 2.0 * M_PI * axes.major * axes.minor;
    234228
     
    242236psF64 PM_MODEL_RADIUS (const psVector *params, psF64 flux)
    243237{
    244     psEllipseShape shape;
    245 
    246238    psF32 *PAR = params->data.F32;
    247239
     
    253245        return (1.0);
    254246
    255     shape.sx  = PAR[PM_PAR_SXX] / M_SQRT2;
    256     shape.sy  = PAR[PM_PAR_SYY] / M_SQRT2;
    257     shape.sxy = PAR[PM_PAR_SXY];
    258 
    259     psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0);
     247    psEllipseAxes axes;
     248    pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], false);
     249
    260250    psF64 radius = axes.major * sqrt (2.0 * log(PAR[PM_PAR_I0] / flux));
    261251    psAssert (isfinite(radius), "fix this code: radius should not be nan for Io = %f, flux = %f, major = %f (%f, %f, %f)",
     
    285275    }
    286276
    287     // the OLD 2D model for SXY actually fitted SXY / (SXX^-2 + SYY^-2); correct here
    288     // out[PM_PAR_SXY] = pmPSF_SXYtoModel (out);
    289 
    290277    // the 2D PSF model fits polarization terms (E0,E1,E2)
    291278    // convert to shape terms (SXX,SYY,SXY)
    292     // XXX user-defined value for limit?
    293     if (!pmPSF_FitToModel (out, 0.1)) {
    294         // psError(PM_ERR_PSF, false, "Failed to fit object at (r,c) = (%.1f,%.1f)", in[PM_PAR_YPOS], in[PM_PAR_XPOS]);
     279    bool useReff = pmModelUseReff (modelPSF->type);
     280    if (!pmPSF_FitToModel (out, 0.1, useReff)) {
    295281        psTrace ("psModules.objects", 3, "Failed to fit object at (r,c) = (%.1f,%.1f)", in[PM_PAR_YPOS], in[PM_PAR_XPOS]);
    296282        return false;
     
    343329    // the 2D PSF model fits polarization terms (E0,E1,E2)
    344330    // convert to shape terms (SXX,SYY,SXY)
    345     // XXX user-defined value for limit?
    346     if (!pmPSF_FitToModel (PAR, 0.1)) {
     331    bool useReff = pmModelUseReff (model->type);
     332    if (!pmPSF_FitToModel (PAR, 0.1, useReff)) {
    347333        psTrace ("psModules.objects", 3, "Failed to fit object at (r,c) = (%.1f,%.1f)", Xo, Yo);
    348334        return false;
  • branches/eam_branches/ipp-20130509/psModules/src/objects/models/pmModel_PGAUSS.c

    r35560 r35644  
    201201
    202202    // set the shape parameters
    203     if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments)) {
     203    if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments, false)) {
    204204      return false;
    205205    }
     
    222222{
    223223    float z, norm;
    224     psEllipseShape shape;
    225224
    226225    psF32 *PAR = params->data.F32;
    227226
    228     shape.sx  = PAR[PM_PAR_SXX] / M_SQRT2;
    229     shape.sy  = PAR[PM_PAR_SYY] / M_SQRT2;
    230     shape.sxy = PAR[PM_PAR_SXY];
    231 
    232     psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0);
     227    psEllipseAxes axes;
     228    pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], false);
     229
    233230    float AspectRatio = axes.minor / axes.major;
    234231
     
    262259{
    263260    psF64 z;
    264     psEllipseShape shape;
    265261
    266262    psF32 *PAR = params->data.F32;
     
    273269        return (1.0);
    274270
    275     shape.sx  = PAR[PM_PAR_SXX] / M_SQRT2;
    276     shape.sy  = PAR[PM_PAR_SYY] / M_SQRT2;
    277     shape.sxy = PAR[PM_PAR_SXY];
    278 
    279     // this estimates the radius assuming f(z) is roughly exp(-z)
    280     psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0);
     271    psEllipseAxes axes;
     272    pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], false);
     273
    281274    psF64 sigma = axes.major;
    282275
     
    347340    }
    348341
    349     // the OLD 2D model for SXY actually fitted SXY / (SXX^-2 + SYY^-2); correct here
    350     // out[PM_PAR_SXY] = pmPSF_SXYtoModel (out);
    351 
    352342    // the 2D PSF model fits polarization terms (E0,E1,E2)
    353343    // convert to shape terms (SXX,SYY,SXY)
    354     if (!pmPSF_FitToModel (out, 0.1)) {
     344    bool useReff = pmModelUseReff (modelPSF->type);
     345    if (!pmPSF_FitToModel (out, 0.1, useReff)) {
    355346        psTrace("psModules.objects", 5, "Failed to fit object at (r,c) = (%.1f,%.1f)", in[PM_PAR_YPOS], in[PM_PAR_XPOS]);
    356347        return false;
     
    403394    // the 2D PSF model fits polarization terms (E0,E1,E2)
    404395    // convert to shape terms (SXX,SYY,SXY)
    405     // XXX user-defined value for limit?
    406     if (!pmPSF_FitToModel (PAR, 0.1)) {
     396    bool useReff = pmModelUseReff (model->type);
     397    if (!pmPSF_FitToModel (PAR, 0.1, useReff)) {
    407398        psTrace ("psModules.objects", 3, "Failed to fit object at (r,c) = (%.1f,%.1f)", Xo, Yo);
    408399        return false;
  • branches/eam_branches/ipp-20130509/psModules/src/objects/models/pmModel_PS1_V1.c

    r35639 r35644  
    221221
    222222    // set the shape parameters
    223     if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments)) {
     223    if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments, false)) {
    224224      return false;
    225225    }
     
    245245{
    246246    float z, norm;
    247     psEllipseShape shape;
    248247
    249248    psF32 *PAR = params->data.F32;
    250249
    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);
     250    psEllipseAxes axes;
     251    pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], false);
    256252    float AspectRatio = axes.minor / axes.major;
    257253
     
    285281{
    286282    psF64 z;
    287     psEllipseShape shape;
    288283
    289284    psF32 *PAR = params->data.F32;
     
    293288    if (flux >= PAR[PM_PAR_I0]) return 1.0;
    294289
    295     shape.sx  = PAR[PM_PAR_SXX] / M_SQRT2;
    296     shape.sy  = PAR[PM_PAR_SYY] / M_SQRT2;
    297     shape.sxy = PAR[PM_PAR_SXY];
    298 
    299     psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0);
     290    psEllipseAxes axes;
     291    pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], false);
    300292    psF64 sigma = axes.major;
    301293
     
    364356    // the 2D PSF model fits polarization terms (E0,E1,E2)
    365357    // convert to shape terms (SXX,SYY,SXY)
    366     if (!pmPSF_FitToModel (out, 0.1)) {
     358    bool useReff = pmModelUseReff (modelPSF->type);
     359    if (!pmPSF_FitToModel (out, 0.1, useReff)) {
    367360        psTrace("psModules.objects", 5, "Failed to fit object at (r,c) = (%.1f,%.1f)", in[PM_PAR_YPOS], in[PM_PAR_XPOS]);
    368361        return false;
     
    417410    // convert to shape terms (SXX,SYY,SXY)
    418411    // XXX user-defined value for limit?
    419     if (!pmPSF_FitToModel (PAR, 0.1)) {
     412    bool useReff = pmModelUseReff (model->type);
     413    if (!pmPSF_FitToModel (PAR, 0.1, useReff)) {
    420414        psTrace ("psModules.objects", 3, "Failed to fit object at (r,c) = (%.1f,%.1f)", Xo, Yo);
    421415        return false;
  • branches/eam_branches/ipp-20130509/psModules/src/objects/models/pmModel_QGAUSS.c

    r35639 r35644  
    221221
    222222    // set the shape parameters
    223     if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments)) {
     223    if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments, false)) {
    224224      return false;
    225225    }
     
    245245{
    246246    float z, norm;
    247     psEllipseShape shape;
    248247
    249248    psF32 *PAR = params->data.F32;
    250249
    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);
     250    psEllipseAxes axes;
     251    pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], false);
    256252    float AspectRatio = axes.minor / axes.major;
    257253
     
    285281{
    286282    psF64 z;
    287     psEllipseShape shape;
    288283
    289284    psF32 *PAR = params->data.F32;
     
    293288    if (flux >= PAR[PM_PAR_I0]) return 1.0;
    294289
    295     shape.sx  = PAR[PM_PAR_SXX] / M_SQRT2;
    296     shape.sy  = PAR[PM_PAR_SYY] / M_SQRT2;
    297     shape.sxy = PAR[PM_PAR_SXY];
    298 
    299     psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0);
     290    psEllipseAxes axes;
     291    pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], false);
    300292    psF64 sigma = axes.major;
    301293
     
    364356    // the 2D PSF model fits polarization terms (E0,E1,E2)
    365357    // convert to shape terms (SXX,SYY,SXY)
    366     if (!pmPSF_FitToModel (out, 0.1)) {
     358    bool useReff = pmModelUseReff (modelPSF->type);
     359    if (!pmPSF_FitToModel (out, 0.1, useReff)) {
    367360        psTrace("psModules.objects", 5, "Failed to fit object at (r,c) = (%.1f,%.1f)", in[PM_PAR_YPOS], in[PM_PAR_XPOS]);
    368361        return false;
     
    421414    // the 2D PSF model fits polarization terms (E0,E1,E2)
    422415    // convert to shape terms (SXX,SYY,SXY)
    423     // XXX user-defined value for limit?
    424     if (!pmPSF_FitToModel (PAR, 0.1)) {
     416    bool useReff = pmModelUseReff (model->type);
     417    if (!pmPSF_FitToModel (PAR, 0.1, useReff)) {
    425418        psTrace ("psModules.objects", 3, "Failed to fit object at (r,c) = (%.1f,%.1f)", Xo, Yo);
    426419        return false;
  • branches/eam_branches/ipp-20130509/psModules/src/objects/models/pmModel_RGAUSS.c

    r35560 r35644  
    210210
    211211    // set the shape parameters
    212     if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments)) {
     212    if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments, false)) {
    213213      return false;
    214214    }
     
    234234{
    235235    float z, norm;
    236     psEllipseShape shape;
    237236
    238237    psF32 *PAR = params->data.F32;
    239238
    240     shape.sx  = PAR[PM_PAR_SXX] / M_SQRT2;
    241     shape.sy  = PAR[PM_PAR_SYY] / M_SQRT2;
    242     shape.sxy = PAR[PM_PAR_SXY];
    243 
    244     psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0);
     239    psEllipseAxes axes;
     240    pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], false);
    245241    float AspectRatio = axes.minor / axes.major;
    246242
     
    274270{
    275271    psF64 z;
    276     psEllipseShape shape;
    277272
    278273    psF32 *PAR = params->data.F32;
     
    285280        return (1.0);
    286281
    287     shape.sx  = PAR[PM_PAR_SXX] / M_SQRT2;
    288     shape.sy  = PAR[PM_PAR_SYY] / M_SQRT2;
    289     shape.sxy = PAR[PM_PAR_SXY];
    290 
    291     psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0);
     282    psEllipseAxes axes;
     283    pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], false);
    292284    psF64 sigma = axes.major;
    293285
     
    357349    // the 2D PSF model fits polarization terms (E0,E1,E2)
    358350    // convert to shape terms (SXX,SYY,SXY)
    359     if (!pmPSF_FitToModel (out, 0.1)) {
     351    bool useReff = pmModelUseReff (modelPSF->type);
     352    if (!pmPSF_FitToModel (out, 0.1, useReff)) {
    360353        psTrace("psModules.objects", 5, "Failed to fit object at (r,c) = (%.1f,%.1f)", in[PM_PAR_YPOS], in[PM_PAR_XPOS]);
    361354        return false;
     
    409402    // the 2D PSF model fits polarization terms (E0,E1,E2)
    410403    // convert to shape terms (SXX,SYY,SXY)
    411     // XXX user-defined value for limit?
    412     if (!pmPSF_FitToModel (PAR, 0.1)) {
     404    bool useReff = pmModelUseReff (model->type);
     405    if (!pmPSF_FitToModel (PAR, 0.1, useReff)) {
    413406        psTrace ("psModules.objects", 3, "Failed to fit object at (r,c) = (%.1f,%.1f)", Xo, Yo);
    414407        return false;
  • branches/eam_branches/ipp-20130509/psModules/src/objects/models/pmModel_SERSIC.c

    r35560 r35644  
    125125
    126126        // first, use Rmajor and index to find the central pixel flux (fraction of total flux)
    127         psEllipseShape shape;
    128 
    129         shape.sx  = PAR[PM_PAR_SXX];
    130         shape.sy  = PAR[PM_PAR_SYY];
    131         shape.sxy = PAR[PM_PAR_SXY];
    132 
    133         // for a non-circular Sersic, the flux of the Rmajor equivalent is scaled by the AspectRatio
    134         psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0);
     127        psEllipseAxes axes;
     128        pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], true);
    135129
    136130        // get the central pixel flux from the lookup table
     
    347341    axes.major = Rmajor;
    348342    axes.minor = Rminor;
    349     psEllipseShape shape = psEllipseAxesToShape (axes);
    350 
    351     if (!isfinite(shape.sx))  return false;
    352     if (!isfinite(shape.sy))  return false;
    353     if (!isfinite(shape.sxy)) return false;
     343
     344    pmModelAxesToParams (&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], axes, true);
    354345
    355346    float bn = 1.9992*index - 0.3271;
     
    357348    float Io = exp(0.5*bn);
    358349
    359     float Sxx = PS_MAX(0.5, shape.sx);
    360     float Syy = PS_MAX(0.5, shape.sy);
    361 
    362     PAR[PM_PAR_SXX]  = Sxx;
    363     PAR[PM_PAR_SYY]  = Syy;
    364     PAR[PM_PAR_SXY]  = shape.sxy;
    365 
    366350    // set the model normalization (adjust for Sersic best guess)
    367351    if (!pmModelSetNorm(&PAR[PM_PAR_I0], source)) {
     
    381365psF64 PM_MODEL_FLUX (const psVector *params)
    382366{
    383     psEllipseShape shape;
    384 
    385367    psF32 *PAR = params->data.F32;
    386368
    387     shape.sx  = PAR[PM_PAR_SXX];
    388     shape.sy  = PAR[PM_PAR_SYY];
    389     shape.sxy = PAR[PM_PAR_SXY];
    390 
    391     // for a non-circular Sersic, the flux of the Rmajor equivalent is scaled by the AspectRatio
    392     psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0);
     369    psEllipseAxes axes;
     370    pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], true);
    393371    float AspectRatio = axes.minor / axes.major;
    394372
     
    410388psF64 PM_MODEL_RADIUS (const psVector *params, psF64 flux)
    411389{
    412     psEllipseShape shape;
    413 
    414390    psF32 *PAR = params->data.F32;
    415391
     
    421397        return (1.0);
    422398
    423     shape.sx  = PAR[PM_PAR_SXX];
    424     shape.sy  = PAR[PM_PAR_SYY];
    425     shape.sxy = PAR[PM_PAR_SXY];
    426 
    427     psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0);
     399    psEllipseAxes axes;
     400    pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], true);
    428401
    429402    // f = Io exp(-z^n) -> z^n = ln(Io/f)
     
    457430    // the 2D PSF model fits polarization terms (E0,E1,E2)
    458431    // convert to shape terms (SXX,SYY,SXY)
    459     if (!pmPSF_FitToModel (out, 0.1)) {
     432    bool useReff = pmModelUseReff (modelPSF->type);
     433    if (!pmPSF_FitToModel (out, 0.1, useReff)) {
    460434        psTrace("psModules.objects", 5, "Failed to fit object at (r,c) = (%.1f,%.1f)", in[PM_PAR_YPOS], in[PM_PAR_XPOS]);
    461435        return false;
     
    510484    // convert to shape terms (SXX,SYY,SXY)
    511485    // XXX user-defined value for limit?
    512     if (!pmPSF_FitToModel (PAR, 0.1)) {
     486    bool useReff = pmModelUseReff (model->type);
     487    if (!pmPSF_FitToModel (PAR, 0.1, useReff)) {
    513488        psTrace ("psModules.objects", 3, "Failed to fit object at (r,c) = (%.1f,%.1f)", Xo, Yo);
    514489        return false;
  • branches/eam_branches/ipp-20130509/psModules/src/objects/models/pmModel_TRAIL.c

    r35639 r35644  
    350350    PAR[PM_PAR_SKY]  = 0.0;
    351351
    352     // XXX test : modify the Io, SXX, SYY terms based on the psf SXX, SYY terms:
    353     psEllipseShape psfShape;
    354     psfShape.sx  = source->modelPSF->params->data.F32[PM_PAR_SXX] / M_SQRT2;
    355     psfShape.sxy = source->modelPSF->params->data.F32[PM_PAR_SXY];
    356     psfShape.sy  = source->modelPSF->params->data.F32[PM_PAR_SYY] / M_SQRT2;
    357     psEllipseAxes psfAxes = psEllipseShapeToAxes (psfShape, 20.0);
     352    psF32 *psfPAR  = source->modelPSF->params->data.F32;
     353    bool useReff = pmModelUseReff (source->modelPSF->type);
     354
     355    psEllipseAxes psfAxes;
     356    pmModelParamsToAxes (&psfAxes, psfPAR[PM_PAR_SXX], psfPAR[PM_PAR_SXY], psfPAR[PM_PAR_SYY], useReff);
    358357
    359358    psEllipseMoments emoments;
Note: See TracChangeset for help on using the changeset viewer.