IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 26641


Ignore:
Timestamp:
Jan 20, 2010, 12:57:12 PM (16 years ago)
Author:
eugene
Message:

add additional checks for perverse data cases

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/math/psStats.c

    r26615 r26641  
    751751        psTrace(TRACE, 6, "-------------------- Iterating on Bin size.  Iteration number %d --------------------\n", iterate);
    752752
     753        if (iterate >= PS_ROBUST_MAX_ITERATIONS) {
     754          // This occurs when a large number of the values are identical --- a bin size cannot be found
     755          // that will spread out the distribution.  Therefore, set what we can, and fall over
     756          // gracefully.
     757          COUNT_WARNING(10, 100, "Maximum number of iterations (%d) exceeded.", PS_ROBUST_MAX_ITERATIONS);
     758          goto escape;
     759        }
     760
    753761        // Get the minimum and maximum values
    754762        int numValid = vectorMinMax(myVector, mask, maskVal, statsMinMax); // Number of valid values
     
    835843                if (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskVal) continue;
    836844                bool invalid = false;
    837                 invalid |= (myVector->data.F32[i] < minKeep);
    838                 invalid |= (myVector->data.F32[i] > maxKeep);
     845                invalid |= (myVector->data.F32[i] <= minKeep);
     846                invalid |= (myVector->data.F32[i] >= maxKeep);
    839847                invalid |= (!isfinite(myVector->data.F32[i]));
    840848                if (!invalid) continue;
     
    842850                nInvalid ++;
    843851            }
    844             psTrace(TRACE, 6, "data is concentrated in a single bin, masking %d extreme outliers and retrying\n", nInvalid);
    845             psFree(histogram);
    846             psFree(cumulative);
    847             continue;
     852
     853            if (nInvalid) {
     854              psTrace(TRACE, 6, "data is concentrated in a single bin, masking %d extreme outliers and retrying\n", nInvalid);
     855              psFree(histogram);
     856              psFree(cumulative);
     857              histogram = NULL;
     858              cumulative = NULL;
     859              continue;
     860            }
     861            // if we did not mask anything, give up.
    848862        }
    849863
Note: See TracChangeset for help on using the changeset viewer.