Reputation: 1079
fft2 and fftn provide the axis parameter which allows to specify over which axes to perform the transform. Does the method obey order?
Given a 2-dimensional numpy array
a = np.array([[1,2],[3,4]])
is
fft2(a,axis=(0,1)
different from
fft2(a,axis=(1,0)
I have data which is correlated across lines but not columns...
Upvotes: 0
Views: 244
Reputation: 36765
The DFT is separable, which means calculating the 2D DFT is the same as calculating two individual 1D DFTs along each axis:
import numpy as np
a = np.arange(25).reshape(5, 5)
out1 = np.fft.fft2(a)
tmp = np.fft.fft(a, axis=0)
out2 = np.fft.fft(tmp, axis=1)
np.allclose(out1, out2) # True
And since the nested summations of the DFTs commute, the order of operations does not matter
tmp = np.fft.fft(a, axis=1)
out3 = np.fft.fft(tmp, axis=0)
np.allclose(out1, out3) # True
Which means the order of the axes
parameter does not matter either
out4 = np.fft.fft2(a, axes=(1, 0))
np.allclose(out1, out4) # True
Upvotes: 4