将傅里叶变换与 FFT 进行比较时翻转 x 轴值

信息处理 fft 自由度
2022-02-17 01:46:32

20 年 6 月 3 日编辑

我有一个洛伦兹线形 where是衰减率,f频率,是峰值频率。

f(z)=1+izR(1+z2)(1)
z=2π(fF0)R(2)
RfF0

时域函数应该是 其中是采样频率(并用作比例因子)。

exp(2πiF0t)exp(Rt)/Fs(3)
Fs

这个 FT 对是从这里的响应中获得的,经过一些简化,我相当确定它是正确的,因为我已经完成并推导出了它,并与洛伦兹 FT 的其他推导进行了核对。

我将解析傅里叶变换与快速傅里叶变换进行比较。当我采用等式 3 的 FFT 时,我希望能够获得原始洛伦兹线形(等式 1)。我知道两者之间存在差异,并且会有错误(截断和/或混叠),但是当我比较它们,分析 FT 结果似乎是镜像的。当比较峰尖时,这很容易看出。在此处输入图像描述我可以编写一个算法来翻转 x 轴值并将峰值移回它应该在的位置,但是我想知道为什么会发生这种翻转。理论依据是什么?有没有办法在不反转和移动每个 x 轴值的情况下解决这个问题?

请在下面找到显示镜像的脚本。

library(SynchWave)
library(RcppFaddeeva)
library(plotly)

# 1) Lineshape parameters
Fs <- 30            # sampling frequency Hz
F0 <-  2            # resonance frequency
f_length <- 27000   # number of samples
A <- 1              # Peak intensity (Amplitude)
R <- 0.03           # Decay rate

# 2) Frequency data ---------------------------------------------
# Creating the frequency axis
f <- seq(0, Fs, length.out = f_length)

# The lorentz frequency lineshape
z <- -2*pi*(f - F0) / R
LL <- complex(r = 1, i = z)/(1+z^2)/R

# 3) Creating Time function ------------------------------------------
# Time axis
t <- seq(0, f_length/Fs, length.out = f_length)

# Ideal lorentz time lineshape
ft <- A*exp(complex(i = 2*pi*F0*t))*exp(-R*t)/Fs

#-------------------------------------------------------------
# 4) Checking for accuracy
x <- list(
  # X axis title
  title = "Frequency",
  titlefont = "f"
)
y <- list(
  # Y axis title
  title = "Intensity",
  titlefont = "f"
)

p <- plot_ly(x = f, y = Re(LL), mode = "lines", type = "scatter", name = "Original Lorentzian") %>%
     add_trace(x = f, y = Re(fft(ft)), mode = "lines", name = "Analytical Algorithm", line = list(color = 'rgb(205, 12, 24)')) %>%
     layout(xaxis = x, yaxis = y)
show(p)

和带有基本翻转的脚本

library(SynchWave)
library(RcppFaddeeva)
library(plotly)

# 1) Lineshape parameters
Fs <- 30            # sampling frequency Hz
F0 <-  2            # resonance frequency
f_length <- 27000   # number of samples
A <- 1              # Peak intensity (Amplitude)
R <- 0.03           # Decay rate

# 2) Frequency data ---------------------------------------------
# Creating the frequency axis
f <- seq(0, Fs, length.out = f_length)

# The lorentz frequency lineshape
z <- -2*pi*(f - F0) / R
LL <- complex(r = 1, i = z)/(1+z^2)/R

# 3) Creating Time function ------------------------------------------
# Time axis
t <- seq(0, f_length/Fs, length.out = f_length)

# Ideal lorentz time lineshape
ftna <- A*exp(complex(i = 2*pi*(Fs-F0)*t))*exp(-R*t)/Fs
ftnew <- fft(ftna)
bot <- (Fs-F0)/Fs*f_length - F0/Fs*f_length
bot <- round(bot) + 2
ft <- ftnew[bot:(f_length-1)]
ft <- append(ft, ftnew[1:bot] , f_length)- min(Re(ftnew[1:bot]))

#-------------------------------------------------------------
# 4) Checking for accuracy
x <- list(
  # X axis title
  title = "Frequency",
  titlefont = "f"
)
y <- list(
  # Y axis title
  title = "Intensity",
  titlefont = "f"
)

p <- plot_ly(x = f, y = Re(LL), mode = "lines", type = "scatter", name = "Original Lorentzian") %>%
  add_trace(x = f, y = Re((ft)), mode = "lines", name = "Analytical Algorithm", line = list(color = 'rgb(205, 12, 24)')) %>%
  layout(xaxis = x, yaxis = y)
show(p)
1个回答

由于您拥有的样本数量有限,这似乎是一个错误。

如果您只是增加样本数量(f_length <- 100000例如制造),您将获得更好的结果。

增加样本数量将提高您在频域中的分辨率。隐含地,您也在更长时间地观察您的信号。

您必须在这两者之间做出权衡。


我运行了一个 Python 脚本来显示相同​​的内容。

f_length是27000。 在此处输入图像描述

f_length是 100000。 在此处输入图像描述


您还可以降低采样频率并保持样本数量相同。由于大部分信号能量都存在于周围,因此您可以制作请记住,即使在这里,您也隐含地以较低的采样率观察连续时间信号的时间更长。fo=2fs=5

f_length是 27000,Fs是 5。 在此处输入图像描述


希望这有帮助。