Created
June 26, 2019 09:41
-
-
Save HudsonHuang/02866fdd1e587398f82b23b398458860 to your computer and use it in GitHub Desktop.
do ifft using fft
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scipy.fftpack import fft | |
import numpy as np | |
# random complex array of N = 4 | |
a = np.array([11.+11.4j, 2.47+2.3j, 30.89+73.1j, 44.+16.3j]) | |
print(a) | |
# do FFT to a to transform to frequency domain | |
da = fft(a) | |
# do ifft using fft | |
# beacuse the difference of idft and dft is just change of its imaginary part: | |
# see this:(https://www.dsprelated.com/showthread/comp.dsp/31758-1.php) | |
# just do some adjust and normalization and one can use fft for ifft | |
def do_ifft_using_fft(da): | |
# get conjugation of freqency domain data | |
da = np.conjugate(da) | |
print(da) | |
# do fft as ifft | |
da = fft(da) | |
print(da) | |
# normalization by 1/N | |
N = len(a) | |
da = da/ N | |
# get conjugation of time domain data | |
da = np.conjugate(da) | |
print(da) | |
return da | |
do_ifft_using_fft(da) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
关于DFT和IDFT的相似性:
https://www.dsprelated.com/showthread/comp.dsp/31758-1.php
DFT和IDFT本质上相同,只是j前面的符号的不同,因此,IDFT可以在DFT上经过一些调整获得。
在FFT获得频域后,对频域进行共轭,就可以用DFT计算IDFT(指Type1型DFT或者FFT)
换回时域后需要除以1/N归一化,并且再求一次共轭