I'm using numpy.fft in python to compute Fast Fourier Transforms. In particular, I'm using rfft as I have a real signal and don't need negative frequencies. My question is this: when I go to compute the FFT, does the length of my signal have to be a power of 2? My signal has 184320 points so I'm wondering if I need to truncate my signal at 131072 (2^17) or pad it with zeros so it has length 262144 (2^18)? My next step is to do windowing so I want to make sure I have performed my FFT correctly before I do anything further.
CodePudding user response:
You do not have to pad the signal. The FFT implementation in NumPy is efficient for array lengths that are products of small prime factors, as noted in README.md, which says
Efficient codelets are available for the factors:
- 2, 3, 4, 5, 7, 11 for complex-valued FFTs
- 2, 3, 4, 5 for real-valued FFTs
Your signal has length 184320 = 2**12 * 3**2 * 5
, so the FFT should be able to handle it efficiently.