回答(申し訳ありませんが、最初のものは少し短い):
差がfft(2次元のフーリエ変換(FT))fft2以外imnputの引数を取ることです。
あなたの例では、print(f1)
の場合、すべての値がおおよそ0であることがわかります。これは、洞結膜をフーリエ変換するときに疑わしいものになります。
何が起こったかというと、fftルーチンは配列の代わりに入力欄のリストを取得したので、各エントリ(1要素)に対してFTを実行しました。これは定数関数に相当し、そのために数学はFT(const1)= const1を教えてくれます。この4つの理由から、fftの入力と同じ出力が得られます。あなたが正しく使用したfft2ルーチン。
import numpy as np
import copy
x1 = np.linspace(0, 2*np.pi, 10)
x2 = np.reshape(x1, (10, 1))
x1 = np.sin(x1)
x2 = np.sin(x2)
f1 = np.fft.fft(x1)
f2 = np.fft.fft2(x2)
print('input arrays for fft and fft2:')
print(x1)
print(x2)
print('your old output of fft, which is exactly equal to the input x2')
print(np.fft.fft(x2))
print('Now we compare our results:')
for ii in range(0,len(x1)):
print('f1:',f1[ii],'\tf2:',f2[ii,0])
print('and see, they agree')
出力:あなた以下
はポイントを示して修正されたバージョン、であなた例を見つけるFFT2について
input arrays for fft and fft2:
[ 0.00000000e+00 6.42787610e-01 9.84807753e-01 8.66025404e-01
3.42020143e-01 -3.42020143e-01 -8.66025404e-01 -9.84807753e-01
-6.42787610e-01 -2.44929360e-16]
[[ 0.00000000e+00]
[ 6.42787610e-01]
[ 9.84807753e-01]
[ 8.66025404e-01]
[ 3.42020143e-01]
[ -3.42020143e-01]
[ -8.66025404e-01]
[ -9.84807753e-01]
[ -6.42787610e-01]
[ -2.44929360e-16]]
your old output of fft, which is exactly equal to the input x2
[[ 0.00000000e+00+0.j]
[ 6.42787610e-01+0.j]
[ 9.84807753e-01+0.j]
[ 8.66025404e-01+0.j]
[ 3.42020143e-01+0.j]
[ -3.42020143e-01+0.j]
[ -8.66025404e-01+0.j]
[ -9.84807753e-01+0.j]
[ -6.42787610e-01+0.j]
[ -2.44929360e-16+0.j]]
Now we compare our results:
f1: (-1.11022302463e-16+0j) f2: (-1.11022302463e-16+0j)
f1: (1.42837120544-4.39607454395j) f2: (1.42837120544-4.39607454395j)
f1: (-0.485917547994+0.668808127899j) f2: (-0.485917547994+0.668808127899j)
f1: (-0.391335729991+0.284322050566j) f2: (-0.391335729991+0.284322050566j)
f1: (-0.36913281032+0.119938520599j) f2: (-0.36913281032+0.119938520599j)
f1: (-0.363970234266+1.55431223448e-15j) f2: (-0.363970234266+1.55431223448e-15j)
f1: (-0.36913281032-0.119938520599j) f2: (-0.36913281032-0.119938520599j)
f1: (-0.391335729991-0.284322050566j) f2: (-0.391335729991-0.284322050566j)
f1: (-0.485917547994-0.668808127899j) f2: (-0.485917547994-0.668808127899j)
f1: (1.42837120544+4.39607454395j) f2: (1.42837120544+4.39607454395j)
and see, they agree
いくつかの例は、あなたが見つけることができるhere
入力が1次元配列の場合、出力は同じでなければなりません。 – proton
ok、良い点。違いは、fftとfft2が入力をどのように解釈するかです - >書き換えられた答えを見る –