您可以numpy.convolve()
平滑与numpy的数据,也可以使用以下功能:
import numpy
def smooth(x,window_len=11,window='hanning'):
if x.ndim != 1:
raise ValueError, "smooth only accepts 1 dimension arrays."
if x.size < window_len:
raise ValueError, "Input vector needs to be bigger than window size."
if window_len<3:
return x
if not window in ['flat', 'hanning', 'hamming', 'bartlett', 'blackman']:
raise ValueError, "Window is on of 'flat', 'hanning', 'hamming', 'bartlett', 'blackman'"
s=numpy.r_[x[window_len-1:0:-1],x,x[-2:-window_len-1:-1]]
#print(len(s))
if window == 'flat': #moving average
w=numpy.ones(window_len,'d')
else:
w=eval('numpy.'+window+'(window_len)')
y=numpy.convolve(w/w.sum(),s,mode='valid')
return y
还请看看在SciPy的文档:
如果你是一维数组a
比他们的邻居小中寻找所有条目,你可以尝试
numpy.r_[True, a[1:] < a[:-1]] & numpy.r_[a[:-1] < a[1:], True]
在SciPy的> = 0.11,你可以使用以下命令:
import numpy as np
from scipy.signal import argrelextrema
x = np.random.random(12)
# for local minima
argrelextrema(x, np.less)
请附上您的图像内的问题,而不是作为外部网站的链接 – AK47
我不能包括图片,因为我是新的,并没有足够高的声誉得分。我上传了图片,但系统将它们添加为链接。 – zubro