suncasa.utils.signalsmooth

cookb_signalsmooth.py

from: http://scipy.org/Cookbook/SignalSmooth

Attributes

Z

Functions

smooth(x[, window_len, window])

smooth the data using a window with requested size.

gauss_kern(size[, sizey])

Returns a normalized 2D gauss kernel array for convolutions

blur_image(im, n[, ny])

blurs the image by convolving with a gaussian kernel of typical

smooth_demo()

Module Contents

suncasa.utils.signalsmooth.smooth(x, window_len=10, window='hanning')[source]

smooth the data using a window with requested size.

This method is based on the convolution of a scaled window with the signal. The signal is prepared by introducing reflected copies of the signal (with the window size) in both ends so that transient parts are minimized in the begining and end part of the output signal.

input:

x: the input signal window_len: the dimension of the smoothing window window: the type of window from ‘flat’, ‘hanning’, ‘hamming’, ‘bartlett’, ‘blackman’

flat window will produce a moving average smoothing.

output:

the smoothed signal

example:

import numpy as np t = np.linspace(-2,2,0.1) x = np.sin(t)+np.random.randn(len(t))*0.1 y = smooth(x)

see also:

numpy.hanning, numpy.hamming, numpy.bartlett, numpy.blackman, numpy.convolve scipy.signal.lfilter

NOTE from B. Chen: slightly modified the reflected copies: window_len-1 points are added to both ends. Previous one is not exactly the reflection, the indices are off by one pixel

suncasa.utils.signalsmooth.gauss_kern(size, sizey=None)[source]

Returns a normalized 2D gauss kernel array for convolutions

suncasa.utils.signalsmooth.blur_image(im, n, ny=None)[source]

blurs the image by convolving with a gaussian kernel of typical size n. The optional keyword argument ny allows for a different size in the y direction.

suncasa.utils.signalsmooth.smooth_demo()[source]
suncasa.utils.signalsmooth.Z[source]