我正在实现一个filt过滤器,但是我得到了一个MemoryError。我试过用两台不同的电脑,错误仍然存在。你知道吗
File "C:\Users\UserName\lib\site-packages\scipy\signal\signaltools.py", line 3129, in filtfilt
zi = lfilter_zi(b, a)
File "C:\Users\UserName\lib\site-packages\scipy\signal\signaltools.py", line 2689, in lfilter_zi
IminusA = np.eye(n - 1) - linalg.companion(a).T
File "C:\Users\UserName\lib\site-packages\numpy\lib\twodim_base.py", line 201, in eye
m = zeros((N, M), dtype=dtype, order=order)
MemoryError
有什么线索可以解决这个问题吗?我的数据不是那么大(1D数组,长度301723)。我在pythonwin63中使用Pycharm。我将非常感谢你的帮助。你知道吗
这是发生错误的示例代码:
from numpy import arange, random
from scipy.signal import kaiserord, firwin, filtfilt
fs = 1000
data = random.uniform(size=3011723)
nyq_rate = fs / 2.0
# The desired width of the transition from pass to stop, relative to the Nyquist rate
width = 0.1/nyq_rate
# The desired attenuation in the stop band, in dB.
ripple_db = 100.0
# Compute the order and Kaiser parameter for the FIR filter.
N, beta = kaiserord(ripple_db, width)
# Use firwin with a Kaiser window to create a lowpass FIR filter.
taps = firwin(N, 300/nyq_rate, window=('kaiser', beta), pass_zero=True)
# Use lfilter to filter x with the FIR filter.
filtered_data = filtfilt(taps, 1.0, data)
最好的, 德塔克
当
scipy.signal.filtfilt
试图计算伴随矩阵时,问题就出现了。对于中间计算,它创建了一个大小为(3011723, 3011723)
的数组,大约是72563 GB
。很明显,它不能进入记忆。你知道吗除了减少样本量,我没有别的选择。你知道吗
相关问题 更多 >
编程相关推荐