DataPipeline/Processing.py
def savitzkygolayfilter(self, x, y, windowsize=11, order=3, deriv=0):
        """Smooth (and optionally differentiate) data with a Savitzky-Golay filter.
        The Savitzky-Golay filter removes high frequency noise from data.
        It has the advantage of preserving the original shape and
        features of the signal better than other types of filtering
        approaches, such as moving averages techhniques.
        The main idea behind this
        approach is to make for each point a least-square fit with a
        polynomial of high order over a odd-sized window centered at
        the point.
        """

        try:
            windowsize = np.abs(np.int(windowsize))
            order = np.abs(np.int(order))
        except ValueError, msg:
            raise ValueError("window_size and order have to be of type int")
        if windowsize % 2 != 1 or windowsize < 1:
            raise TypeError("window_size size must be a positive odd number")
        if windowsize < order + 2:
            raise TypeError("window_size is too small for the polynomials order")
        order_range = range(order+1)
        half_window = (windowsize -1) // 2
        # precompute coefficients
        b = np.mat([[k**i for i in order_range] for k in range(-half_window, half_window+1)])
        m = np.linalg.pinv(b).A[deriv]
        # pad the signal at the extremes with
        # values taken from the signal itself
        y=np.array(y)
        firstvals = y[0] - np.abs( y[1:half_window+1][::-1] - y[0] )
        lastvals = y[-1] + np.abs(y[-half_window-1:-1][::-1] - y[-1])
        y = np.concatenate((firstvals, y, lastvals))
        return x, np.convolve( m, y, mode='valid')
Smooth (and optionally differentiate) data with a Savitzky-Golay filter.
        The Savitzky-Golay filter removes high frequency noise from data.
        It has the advantage of preserving the original shape and
        features of the signal better than other types of filtering
        approaches, such as moving averages techhniques.
        The main idea behind this
        approach is to make for each point a least-square fit with a
        polynomial of high order over a odd-sized window centered at
        the point.
        
Smooth (and optionally differentiate) data with a Savitzky-Golay filter.
The Savitzky-Golay filter removes high frequency noise from data.
It has the advantage of preserving the original shape and
features of the signal better than other types of filtering
approaches, such as moving averages techhniques.
The main idea behind this
approach is to make for each point a least-square fit with a
polynomial of high order over a odd-sized window centered at
the point.
Smooth ( and optionally differentiate ) data with a Savitzky - Golay filter . The Savitzky - Golay filter removes high frequency noise from data . It has the advantage of preserving the original shape and features of the signal better than other types of filtering approaches such as moving averages techhniques . The main idea behind this approach is to make for each point a least - square fit with a polynomial of high order over a odd - sized window centered at the point .
def savitzkygolayfilter(self, x, y, windowsize=11, order=3, deriv=0):
        try:
            windowsize = np.abs(np.int(windowsize))
            order = np.abs(np.int(order))
        except ValueError, msg:
            raise ValueError("window_size and order have to be of type int")
        if windowsize % 2 != 1 or windowsize < 1:
            raise TypeError("window_size size must be a positive odd number")
        if windowsize < order + 2:
            raise TypeError("window_size is too small for the polynomials order")
        order_range = range(order+1)
        half_window = (windowsize -1) // 2
        b = np.mat([[k**i for i in order_range] for k in range(-half_window, half_window+1)])
        m = np.linalg.pinv(b).A[deriv]
        y=np.array(y)
        firstvals = y[0] - np.abs( y[1:half_window+1][::-1] - y[0] )
        lastvals = y[-1] + np.abs(y[-half_window-1:-1][::-1] - y[-1])
        y = np.concatenate((firstvals, y, lastvals))
        return x, np.convolve( m, y, mode='valid')
def savitzkygolayfilter ( self , x , y , windowsize = 11 , order = 3 , deriv = 0 ) : try : windowsize = np . abs ( np . int ( windowsize ) ) order = np . abs ( np . int ( order ) ) except ValueError , msg : raise ValueError ( "window_size and order have to be of type int" ) if windowsize % 2 != 1 or windowsize < 1 : raise TypeError ( "window_size size must be a positive odd number" ) if windowsize < order + 2 : raise TypeError ( "window_size is too small for the polynomials order" ) order_range = range ( order + 1 ) half_window = ( windowsize - 1 ) // 2 b = np . mat ( [ [ k ** i for i in order_range ] for k in range ( - half_window , half_window + 1 ) ] ) m = np . linalg . pinv ( b ) . A [ deriv ] y = np . array ( y ) firstvals = y [ 0 ] - np . abs ( y [ 1 : half_window + 1 ] [ : : - 1 ] - y [ 0 ] ) lastvals = y [ - 1 ] + np . abs ( y [ - half_window - 1 : - 1 ] [ : : - 1 ] - y [ - 1 ] ) y = np . concatenate ( ( firstvals , y , lastvals ) ) return x , np . convolve ( m , y , mode = 'valid' )
Smooth (and optionally differentiate) data with a Savitzky-Golay filter.
Smooth ( and optionally differentiate ) data with a Savitzky - Golay filter .
"""Smooth (and optionally differentiate) data with a Savitzky-Golay filter.
        The Savitzky-Golay filter removes high frequency noise from data.
        It has the advantage of preserving the original shape and
        features of the signal better than other types of filtering
        approaches, such as moving averages techhniques.
        The main idea behind this
        approach is to make for each point a least-square fit with a
        polynomial of high order over a odd-sized window centered at
        the point.
        """ # precompute coefficients # pad the signal at the extremes with # values taken from the signal itself
self
x
y
windowsize
order
deriv