def normalize_mean_power(x):
    '''
    Normalize a vector so that it has energy equal to its length,
    ie. mean power equal to 1.0.
    Useful to normalize the FFT window.

    np.allclose(normalize_window(x), len(x))
    '''
    return x / mean_power(x)
def create_window(size):
    w = scipy.hanning(size)
    w = w / mean_power(w)
    return w