IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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;
Note: See TracChangeset for help on using the changeset viewer.