def savgol_filter(x, window_length, polyorder, deriv=0, delta=1.0, axis=(-1), mode='interp', cval=0.0):
 if (mode not in ['mirror', 'constant', 'nearest', 'interp', 'wrap']):
  raise ValueError("mode must be 'mirror', 'constant', 'nearest' 'wrap' or 'interp'.")
 x = np.asarray(x)
 if ((x.dtype != np.float64) and (x.dtype != np.float32)):
  x = x.astype(np.float64)
 coeffs = savgol_coeffs(window_length, polyorder, deriv=deriv, delta=delta)
 if (mode == 'interp'):
  y = convolve1d(x, coeffs, axis=axis, mode='constant')
  _fit_edges_polyfit(x, window_length, polyorder, deriv, delta, axis, y)
 else:
  y = convolve1d(x, coeffs, axis=axis, mode=mode, cval=cval)
 return y

def savgol_filter ( x , window_length , polyorder , deriv = 0 , delta = 1.0 , axis = ( - 1 ) , mode = 'interp' , cval = 0.0 ) : if ( mode not in [ 'mirror' , 'constant' , 'nearest' , 'interp' , 'wrap' ] ) : raise ValueError ( "mode must be 'mirror', 'constant', 'nearest' 'wrap' or 'interp'." ) x = np . asarray ( x ) if ( ( x . dtype != np . float64 ) and ( x . dtype != np . float32 ) ) : x = x . astype ( np . float64 ) coeffs = savgol_coeffs ( window_length , polyorder , deriv = deriv , delta = delta ) if ( mode == 'interp' ) : y = convolve1d ( x , coeffs , axis = axis , mode = 'constant' ) _fit_edges_polyfit ( x , window_length , polyorder , deriv , delta , axis , y ) else : y = convolve1d ( x , coeffs , axis = axis , mode = mode , cval = cval ) return y
apply a savitzky-golay filter to an array .