rolling_window_sigma_clip (function)

rolling_window_sigma_clip(log, array, clippingSigma, windowSize)[source]

given a sorted list of values, median sigma-clip values based on a window of values either side of each value (rolling window) and return the array mask

Key Arguments:

  • log – logger

  • array – the array to clean up (arrays of length < 5 are not clipped but returned unmasked)

  • clippingSigma – the minimum sigma to clip (using median-absolute distribution as sigma proxy)

  • windowSize – the size of the window to use when calculating the median distribution (window of 11 will use 5 values each side of the value in question)

Usage:

from fundamentals.stats import rolling_window_sigma_clip
arrayMask = rolling_window_sigma_clip(
    log=self.log,
    array=myArray,
    clippingSigma=2.2,
    windowSize=11)

## JUST KEEP UNMASKED VALUES
try:
    myArray = [e for e, m in zip(
        myArray, arrayMask) if m == False]
except:
    myArray = []