IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 2, 2023, 2:58:41 PM (3 years ago)
Author:
eugene
Message:

only skip sources with large centroid swings or with negative sums if the sources are NOT injected / externally supplied

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/objects/pmSourceMoments.c

    r38873 r42481  
    231231    }
    232232
     233    // we only update the centroid if the position is not supplied from elsewhere
     234    bool skipCentroid = false;
     235    skipCentroid |= (source->mode  & PM_SOURCE_MODE_EXTERNAL); // skip externally supplied positions
     236    skipCentroid |= (source->mode2 & PM_SOURCE_MODE2_MATCHED); // skip sources defined by other image positions
     237
    233238    // if we have less than (1/4) of the possible pixels (in circle or box), force a retry
    234239    int minPixels = PS_MIN(0.75*R2, source->pixels->numCols*source->pixels->numRows/4.0);
    235240
    236241    // XXX EAM - the limit is a bit arbitrary.  make it user defined?
    237     if ((numPixels < minPixels) || (Sum <= 0)) {
     242    if (numPixels < minPixels) {
    238243        psTrace ("psModules.objects", 3, "insufficient valid pixels (%d vs %d; %f) for source\n", numPixels, minPixels, Sum);
     244        return (false);
     245    }
     246
     247    // only skip negative sum sources if the sources are not forced
     248    if (!skipCentroid && (Sum <= 0)) {
     249        psTrace ("psModules.objects", 3, "insufficient significant pixels (%d vs %d; %f) for source\n", numPixels, minPixels, Sum);
    239250        return (false);
    240251    }
     
    243254    float Mx = X1/Sum;
    244255    float My = Y1/Sum;
    245     if ((fabs(Mx) > radius) || (fabs(My) > radius)) {
    246         psTrace ("psModules.objects", 3, "extreme centroid swing; invalid peak %d, %d\n", source->peak->x, source->peak->y);
    247         return (false);
    248     }
    249256    if ((fabs(Mx) > 2.0) || (fabs(My) > 2.0)) {
    250257        psTrace ("psModules.objects", 3, " big centroid swing; ok peak? %d, %d\n", source->peak->x, source->peak->y);
    251258    }
    252 
    253259    psTrace ("psModules.objects", 5, "id: %d, sky: %f  Mx: %f  My: %f  Sum: %f  X1: %f  Y1: %f  Npix: %d\n", source->id, sky, Mx, My, Sum, X1, Y1, numPixels);
    254260
     
    258264    // 0.5 PIX: moments are calculated using the pixel index and converted here to pixel coords
    259265
    260     // we only update the centroid if the position is not supplied from elsewhere
    261     bool skipCentroid = false;
    262     skipCentroid |= (source->mode  & PM_SOURCE_MODE_EXTERNAL); // skip externally supplied positions
    263     skipCentroid |= (source->mode2 & PM_SOURCE_MODE2_MATCHED); // skip sources defined by other image positions
    264 
    265266    if (skipCentroid) {
    266267        source->moments->Mx = source->peak->xf;
    267268        source->moments->My = source->peak->yf;
    268269    } else {
     270        if ((fabs(Mx) > radius) || (fabs(My) > radius)) {
     271            psTrace ("psModules.objects", 3, "extreme centroid swing; invalid peak %d, %d\n", source->peak->x, source->peak->y);
     272            return (false);
     273        }
    269274        source->moments->Mx = Mx + xGuess;
    270275        source->moments->My = My + yGuess;
Note: See TracChangeset for help on using the changeset viewer.