IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 36106 for trunk/psModules


Ignore:
Timestamp:
Sep 11, 2013, 10:56:38 AM (13 years ago)
Author:
eugene
Message:

initial guess needs to use kron flux and normalization, not central peak

Location:
trunk/psModules/src/objects/models
Files:
2 edited

Legend:

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

    r36085 r36106  
    117117
    118118    assert (isfinite(q));
    119     assert (isfinite(f0));
    120119
    121120    // only worry about the central pixels at most
     
    129128        f0 = pmModelCP_SersicSubpix (X, Y, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], 4.0, Nsub);
    130129    }   
     130    assert (isfinite(f0));
    131131
    132132    float f1 = PAR[PM_PAR_I0]*f0;
     
    243243bool PM_MODEL_GUESS (pmModel *model, pmSource *source, psImageMaskType maskVal, psImageMaskType markVal)
    244244{
     245    // for the moment, we are going to require moments and KronFlux
     246    if (!source->moments) return false;
     247    pmMoments *moments = source->moments;
     248
     249    if (!isfinite(moments->KronFlux)) return false;
     250    if (!isfinite(moments->Mrf)) return false;
     251    if (moments->Mrf < 0.0) return false;
     252
    245253    psF32 *PAR  = model->params->data.F32;
    246254
     
    248256    PAR[PM_PAR_SKY]  = 0.0;
    249257
    250     // set the shape parameters
    251     if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments, true)) {
    252       return false;
    253     }
    254 
    255     // set the model normalization
    256     if (!pmModelSetNorm(&PAR[PM_PAR_I0], source)) {
    257       return false;
    258     }
     258    psEllipseMoments emoments;
     259    emoments.x2 = moments->Mxx;
     260    emoments.xy = moments->Mxy;
     261    emoments.y2 = moments->Myy;
     262
     263    // force the axis ratio to be < 20.0
     264    psEllipseAxes axes = psEllipseMomentsToAxes (emoments, 20.0);
     265
     266    if (!isfinite(axes.major)) return false;
     267    if (!isfinite(axes.minor)) return false;
     268    if (!isfinite(axes.theta)) return false;
     269
     270    // Mxx, Mxy, Myy define the elliptical shape, but Mrf defines the width
     271    float scale = moments->Mrf / axes.major;
     272    axes.major *= scale;
     273    axes.minor *= scale;
     274
     275    pmModelAxesToParams (&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], axes, true);
     276
     277    // psEllipseAxes axes;
     278    // use the code in SetShape here to avoid doing this 2x
     279    // pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], true);
     280
     281    // float norm = pmSersicNorm (4);  // hardwire
     282    float norm = 0.00168012;
     283    float normFlux = 2.0 * M_PI * axes.major * axes.minor * norm;
     284    PAR[PM_PAR_I0] = moments->KronFlux / normFlux;
    259285
    260286    // set the model position
  • trunk/psModules/src/objects/models/pmModel_EXP.c

    r36085 r36106  
    237237bool PM_MODEL_GUESS (pmModel *model, pmSource *source, psImageMaskType maskVal, psImageMaskType markVal)
    238238{
     239    // for the moment, we are going to require moments and KronFlux
     240    if (!source->moments) return false;
     241    pmMoments *moments = source->moments;
     242
     243    if (!isfinite(moments->KronFlux)) return false;
     244    if (!isfinite(moments->Mrf)) return false;
     245    if (moments->Mrf < 0.0) return false;
     246
    239247    psF32 *PAR  = model->params->data.F32;
    240248
     
    242250    PAR[PM_PAR_SKY]  = 0.0;
    243251
    244     // set the shape parameters
    245     if (!pmModelSetShape(&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], source->moments, true)) {
    246       return false;
    247     }
    248 
    249     // set the model normalization
    250     if (!pmModelSetNorm(&PAR[PM_PAR_I0], source)) {
    251       return false;
    252     }
     252    psEllipseMoments emoments;
     253    emoments.x2 = moments->Mxx;
     254    emoments.xy = moments->Mxy;
     255    emoments.y2 = moments->Myy;
     256
     257    // force the axis ratio to be < 20.0
     258    psEllipseAxes axes = psEllipseMomentsToAxes (emoments, 20.0);
     259
     260    if (!isfinite(axes.major)) return false;
     261    if (!isfinite(axes.minor)) return false;
     262    if (!isfinite(axes.theta)) return false;
     263
     264    // Mxx, Mxy, Myy define the elliptical shape, but Mrf defines the width
     265    float scale = moments->Mrf / axes.major;
     266    axes.major *= scale;
     267    axes.minor *= scale;
     268
     269    pmModelAxesToParams (&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], axes, true);
     270
     271    // psEllipseAxes axes;
     272    // use the code in SetShape here to avoid doing this 2x
     273    // pmModelParamsToAxes (&axes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], true);
     274
     275    // float norm = pmSersicNorm (4);  // hardwire
     276    float norm = 0.34578;
     277    float normFlux = 2.0 * M_PI * axes.major * axes.minor * norm;
     278    PAR[PM_PAR_I0] = moments->KronFlux / normFlux;
    253279
    254280    // set the model position
     
    259285    return(true);
    260286}
    261 
    262287// An exponential model is equivalent to a Sersic with index = 1.0
    263288psF64 PM_MODEL_FLUX (const psVector *params)
Note: See TracChangeset for help on using the changeset viewer.