scipy 快速 Hankel 变换在 python 中的使用

问题描述 投票:0回答:1

尽管付出了一些努力,我还是无法理解 SciPy.fft.fht(Python 中的快速汉克尔变换)的用法。例如,当我尝试转换 exp(-ar) 时,它给了我一些奇怪的结果。我也不明白如何选择合适的偏移量。这是我的简单代码。

from scipy import fft
import numpy as np
import matplotlib.pyplot as plt

mu = 1.0 # Order of Bessel function
r = np.logspace(-7, 1, 128)  # Input evaluation points
dln = np.log(r[1]/r[0])      # Step size
offset = fft.fhtoffset(dln, initial=-6.*log(10), mu=mu)
k = np.exp(offset)/r[::-1]   # Output evaluation points

a = 0.5
f = np.exp(-a*r)             # This is what I want to transform
fk = k/np.sqrt((k**2+a**2)**3) # This is what I expect analytically (I looked it up from a table)
f_fht = fft.fht(f, dln, offset=offset, mu=mu) # This is the numerical result

plt.plot(k,fk,k,f_fht,'--')
plt.show()

看来f_fht 与fk 不一致。我不明白出了什么问题。 谁能用一些例子解释我应该如何使用 fht ?非常感谢。

python scipy fft
1个回答
0
投票

这个问题是一个常见问题:SciPy 中的数值 FHT 是使用

k dr
的积分定义的,而数学 Hankel 变换的定义使用
r dr
(参见 scipy/scipy#19573)。要计算您期望的 Hankel 变换,您需要将输入乘以
r
(以添加缺失的因子),并将输出除以
k
(以删除额外的因子)。

...
f_fht = fft.fht(f*r, dln, offset=offset, mu=mu)/k

plt.loglog(k,fk,k,f_fht,'--')
plt.show()

如您所见,这让您更接近,但结果存在明显的混叠。我们可以对变换进行偏置以获得更好的结果:

...
offset = fft.fhtoffset(dln, initial=-6.*np.log(10), mu=mu, bias=-1.5)
...
f_fht = fft.fht(f*r, dln, offset=offset, mu=mu, bias=-1.5)/k
...

您可能仍然想调查为什么这里的协议不完美,但我希望这能演示 SciPy 的 FHT 是如何工作的。

© www.soinside.com 2019 - 2024. All rights reserved.