IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 16, 2011, 1:32:43 PM (15 years ago)
Author:
eugene
Message:

create a single test function (pmSourcePositionUseMoments) to check if we should use the moments or peaks for source positions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110213/psModules/src/objects/pmSourceOutputs.c

    r30865 r30931  
    7777}
    7878
     79// what is the correct postion?
     80// * if we have a PSF model fit, use PM_PAR_XPOS,YPOS for X_PSF,Y_PSF
     81// * if we do not have a model:
     82// ** if we have moments:
     83// *** if the star is saturated, use the moments
     84// *** if the moments and peak agree to < DR, use the moments
     85// *** otherwise, use the peak
     86
    7987bool pmSourceOutputsSetValues (pmSourceOutputs *outputs, pmSource *source, pmChip *chip, float fwhmMajor, float fwhmMinor, float magOffset) {
    8088
     
    112120        outputs->apRadius = source->apRadius;
    113121    } else {
    114         bool useMoments = true;
    115         useMoments = (useMoments && source->moments);          // can't if there are no moments
    116         useMoments = (useMoments && source->moments->nPixels); // can't if the moments were not measured
    117         useMoments = (useMoments && !(source->mode && PM_SOURCE_MODE_MOMENTS_FAILURE)); // can't if the moments failed...
     122        bool useMoments = pmSourcePositionUseMoments(source);
    118123
    119124        if (useMoments) {
     
    175180    return true;
    176181}
     182
     183// this function decides if the source position should be based on the peak or the moments.
     184// this is only used if we know we should not use a model fit position (eg, no model, or no
     185// model yet)
     186bool pmSourcePositionUseMoments(pmSource *source) {
     187
     188    if (!source->moments) return false;          // can't if there are no moments
     189    if (!source->moments->nPixels) return false; // can't if the moments were not measured
     190    if (source->mode && PM_SOURCE_MODE_MOMENTS_FAILURE) return false; // can't if the moments failed...
     191
     192    if (source->mode & PM_SOURCE_MODE_SATSTAR) return true; // moments are best for SATSTARs
     193
     194    float dX = source->moments->Mx - source->peak->xf;
     195    float dY = source->moments->My - source->peak->yf;
     196    float dR = hypot(dX, dY);
     197   
     198    // only use the moments position if the moment-peak offset is small or the star is saturated
     199    if (dR > 1.5) return false
     200
     201    return true;
     202}
Note: See TracChangeset for help on using the changeset viewer.