def movav(y, Dx, dx):
if Dx <= dx:<EOL><INDENT>return y<EOL><DEDENT>else:<EOL><INDENT>ly = len(y)<EOL>r = np.zeros(ly)<EOL>n = np.int(np.round((Dx / dx)))<EOL>r[<NUM_LIT:0>:np.int(n / <NUM_LIT>)] = <NUM_LIT:1.0> / n<EOL>r[-np.int(n / <NUM_LIT>)::] = <NUM_LIT:1.0> / n<EOL>R = np.fft.fft(r)<EOL>Y = np.fft.fft(y)<EOL>yf = np.fft.ifft(Y * R)<EOL>return yf<EOL><DEDENT>
Moving average rectangular window filter:
calculate average of signal y by using sliding rectangular
window of size Dx using binsize dx


Parameters
----------
y : numpy.ndarray
    Signal
Dx : float
    Window length of filter.
dx : float
    Bin size of signal sampling.


Returns
-------
numpy.ndarray
    Filtered signal.