[Numpy-discussion] 2D Fourier Transform with 1D functions

Stéfan van der Walt stefan at sun.ac.za
Tue May 24 09:28:42 EDT 2011


Hi Chris

On Tue, May 24, 2011 at 9:29 AM, Goo Creations <goocreations at gmail.com> wrote:
> At this point I'm stuck, since I'm not sure how to do the row based
> transform on ownRes.
> Is there anyone out there who knows how to do this?

NumPy's FFT supports an "axis" argument, so you can do

In [29]: own = np.array([[1+0j, 2+0j], [3+0j, 4+0j]])

In [30]: fft_step1 = np.fft.fft(own, axis=0)

In [31]: fft_step2 = np.fft.fft(fft_step1, axis=1)

In [32]: fft_step2
Out[32]:
array([[ 10.+0.j,  -2.+0.j],
       [ -4.+0.j,   0.+0.j]])

In [33]: np.fft.fft2(own)
Out[33]:
array([[ 10.+0.j,  -2.+0.j],
       [ -4.+0.j,   0.+0.j]])

Cheers
Stéfan



More information about the NumPy-Discussion mailing list