On Tue, Sep 1, 2015 at 12:06 PM, Oscar Benjamin <oscar.j.benjamin@gmail.com> wrote:

On Tue, 1 Sep 2015 18:43 Phil Hodge <hodge@stsci.edu> wrote:

On 09/01/2015 11:14 AM, Oscar Benjamin wrote:
> Just use the next power of 2. Pure powers of 2 are the most efficient
> for FFT algorithms so it potentially works out better than finding a
> smaller but similarly composite size to pad to. Finding the next power
> of 2 is easy to code and never a bad choice.

It would be better to pad to a power of three or five, or some other
product of small primes, if the pad length would be significantly less
than padding to a power of two.  The obvious problem with padding is
that it's different from the real data, so its presence will affect the
result.  At the least, it would be good to pad with the mean value of
the original data, or to pad with zero after subtracting the mean from
the original data.

I meant performance wise it's not a bad choice. If you're concerned about distortion then use the Bluestein algorithm as I showed.

I don't see the problem with padding. After all, the spectrum is an estimate and the effect of the padding, as well as the use of windowing is well understood. However, I would recommend subtracting the average before padding, as otherwise the DC frequency is likely to be of large amplitude and its side lobes will mask the lower frequencies.


NumPy-Discussion mailing list