您可以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