简体   繁体   English

IFFT比FFT高出几个数量级

[英]IFFT taking orders of magnitude more than FFT

I'm trying to resample a 1-D signal using an FFT method (basically, the one from scipy.signal). 我正在尝试使用FFT方法(基本上是scipy.signal的方法)对一维信号进行重采样。 However, the code is taking forever to run, even though my input signal is a power of two in length. 但是,即使我的输入信号的长度为2的幂,该代码也将永远运行。 After looking at profiling, I found the root of the problem. 在查看分析后,我发现了问题的根源。

Basically, this method takes an FFT, then removes part of the fourier spectrum, then takes an IFFT to bring it back to the time domain at a lower sampling rate. 基本上,此方法采用FFT,然后去除傅立叶频谱的一部分,然后采用IFFT以较低的采样率将其带回时域。

The problem is that that the IFFT is taking far longer to run than the FFT: 问题是,该IFFT正在长得比FFT运行:

ncalls tottime percall cumtime percall filename:lineno(function) 1 6263.996 6263.996 6263.996 6263.996 basic.py:272(ifft) 1 1.076 1.076 1.076 1.076 basic.py:169(fft)

I assume that this has something to do with the amount of fourier points remaining after the cutoff. 我认为这与截止后剩余的傅立叶点数有关。 That said, this is an incredible slowdown so I want to make sure that: 就是说,这是一个令人难以置信的速度下降,所以我要确保:

A. This behavior is semi-reasonable and isn't definitely a bug. 答:这种行为是半合理的,并且绝对不是错误。 B. What could I do to avoid this problem and still downsample effectively. B.我该怎么做才能避免此问题并仍然有效地降低采样率。

Right now I can pad my input signal to a power of two in order to make the FFT run really quickly, but not sure how to do the same kind of thing for the reverse operation. 现在,我可以将输入信号填充为2的幂,以使FFT真正快速地运行,但不确定如何对反向操作执行相同的操作。 I didn't even realize that this was an issue for IFFTs :P 我什至没有意识到这对于IFFT是一个问题:P

If your IFFT's length is different from that of the FFT, and the length of the IFFT isn't composed of only very small prime factors (2,3,etc.), then the efficiency can drop off significantly. 如果您的IFFT的长度与FFT的长度不同,并且IFFT的长度不仅仅由很小的质数(2、3等)组成,那么效率可能会大大下降。

Thus, this method of resampling is only efficient if the two sample rates are different by ratios with small prime factors, such as 2, 3 and 7 (hint). 因此,仅当两个采样率之间的比率具有较小的主要因子(例如2、3和7)时,这种重采样方法才有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM