Python 使用numpy.fft的时间带宽乘积(高斯宽度)

Python 使用numpy.fft的时间带宽乘积(高斯宽度),python,numpy,math,physics,Python,Numpy,Math,Physics,我想用Python将模拟的激光脉冲从时域傅里叶变换到频域。我从高斯函数开始,因为已知“时间带宽积”(时域中的宽度乘以频域中的宽度)是,当宽度定义为高斯函数最大值一半处的全宽度时 然而,当使用numpy.fft.fft时,我发现时间带宽乘积是0.88,是它应该的两倍 这是我的代码(在前几行中是最小的示例,其余的只是绘制图): 编辑2:看来魔鬼在物理上,而不是数学上,见丹的自我回答。平方高斯确实会将半极大值的位置移动1/sqrt(2)倍,因此一切都很好。我要向RP Photonics公司诚恳无保留

我想用Python将模拟的激光脉冲从时域傅里叶变换到频域。我从高斯函数开始,因为已知“时间带宽积”(时域中的宽度乘以频域中的宽度)是,当宽度定义为高斯函数最大值一半处的全宽度时

然而,当使用
numpy.fft.fft
时,我发现时间带宽乘积是0.88,是它应该的两倍

这是我的代码(在前几行中是最小的示例,其余的只是绘制图):


编辑2:看来魔鬼在物理上,而不是数学上,见丹的自我回答。平方高斯确实会将半极大值的位置移动1/sqrt(2)倍,因此一切都很好。我要向RP Photonics公司诚恳无保留地道歉。编辑2结束

我很确定你要找的“bug”是0.44版本的,你链接的引用看起来不是100%可靠

所以,让我们来计算一下我们的预期。傅里叶变换有不同的定义;似乎是numpy所坚持的。在本惯例中,高斯及其傅里叶变换的标准偏差的乘积为1/(2pi)。具有标准差西格玛的零均值高斯函数的半最大值为+/-西格玛sqrt(2 log 2)。因此,半高宽的乘积为1/(2pi)8log2=4/pi log2=0.8825

换句话说:你所观察到的是正确的


编辑:公平地说,RP Photonics并不一定是错的,他们可能只是使用了傅里叶变换的另一种定义。

@PaulPanzer走上了正确的道路!当比较两个高斯函数的半高宽时,我们确实希望找到0.88作为时间带宽积

但为什么大多数参考文献都说0.44是激光脉冲的时间带宽积?关键是我们实际观察到的是电场的强度,其中I=E^2。因此,实际上,最有意义的是比较强度分布的宽度,而不是电场分布。当我们比较强度分布时,我们发现时间-带宽乘积确实是0.44

修订守则:

import numpy as np
import matplotlib.pyplot as plt

fwhm = 40e-15 # using a 40 femtosecond pulse

t  = np.linspace(-1000e-15, 1000e-15, 4000)
It = np.exp( -t**2 / (2*(fwhm / 2.35482)**2) ) # Intensity in the time domain
Et = np.sqrt(It)                               # E-field in the time domain

Ef = np.abs(np.fft.fftshift( np.fft.fft(Et) )) # FT to get E-field in frequency domain
If = Ef**2                                     # Intensity in the frequnecy domain
f  = np.fft.fftshift( np.fft.fftfreq(Ef.shape[0],t[1]-t[0]) ) # generate the frequencies

fwhm_fft = 2 * np.abs( f[ np.argmin(np.abs(0.5*np.max(If)-If)) ] ) # find the fwhm of the frequency-domain signal

print 'Observed time-bandwidth product: %.3f'%(fwhm*fwhm_fft)


# just making plots from here onwards:
fig, axs = plt.subplots(2,1, figsize=(6,8))

axs[0].set_title('Time domain')
axs[0].plot(t,It)
axs[0].axvline(-fwhm*0.5, color='r', alpha=0.5, label='Full-width at half-maximum (FWHM) = %.1f fs'%(fwhm*1e15))
axs[0].axvline( fwhm*0.5, color='r', alpha=0.5)

axs[0].set_xlim(-150e-15, 150e-15)
axs[0].set_ylim(0,1.3)
axs[0].set_xlabel('Time (sec)')

axs[1].set_title('Frequency domain')
axs[1].plot(f,If)

axs[1].axvline(-0.44/fwhm*0.5, color='r', alpha=0.5, label='FWHM should be %.1f THz'%(0.44/fwhm*1e-12) )
axs[1].axvline( 0.44/fwhm*0.5, color='r', alpha=0.5)

axs[1].axvline(-fwhm_fft*0.5, color='g', alpha=0.5, ls='dashed', label='FWHM is actually %.1f THz'%(fwhm_fft*1e-12) )
axs[1].axvline( fwhm_fft*0.5, color='g', alpha=0.5, ls='dashed')

axs[1].set_xlim(-2.0e13,2.0e13)
axs[1].set_ylim(0,30000)
axs[1].set_xlabel('Frequency (Hz)')

for ax in axs:
    ax.legend(fontsize=10)
    ax.set_ylabel('Electric field intensity (arbitrary units)')

plt.tight_layout()
plt.savefig('time-bandwidth-product.png', dpi=200)
plt.show()


PS:RP光子学是一种奇妙的资源。这是激光和光子学领域的主要教科书之一。

您的高斯分布不正常,导致了不同的半高宽,请检查。标准化预因子是1/(sigma*sqrt(2*pi))。您是正确的,它不是标准化的。但是高斯光束的高度不应该影响它的宽度。哈哈,我在我的领域之外太骄傲了,这是对的。你为什么不接受自己的答案呢?这听起来很有道理。谢谢你的回答,保罗!这真的帮我弄明白了。
import numpy as np
import matplotlib.pyplot as plt

fwhm = 40e-15 # using a 40 femtosecond pulse

t  = np.linspace(-1000e-15, 1000e-15, 4000)
It = np.exp( -t**2 / (2*(fwhm / 2.35482)**2) ) # Intensity in the time domain
Et = np.sqrt(It)                               # E-field in the time domain

Ef = np.abs(np.fft.fftshift( np.fft.fft(Et) )) # FT to get E-field in frequency domain
If = Ef**2                                     # Intensity in the frequnecy domain
f  = np.fft.fftshift( np.fft.fftfreq(Ef.shape[0],t[1]-t[0]) ) # generate the frequencies

fwhm_fft = 2 * np.abs( f[ np.argmin(np.abs(0.5*np.max(If)-If)) ] ) # find the fwhm of the frequency-domain signal

print 'Observed time-bandwidth product: %.3f'%(fwhm*fwhm_fft)


# just making plots from here onwards:
fig, axs = plt.subplots(2,1, figsize=(6,8))

axs[0].set_title('Time domain')
axs[0].plot(t,It)
axs[0].axvline(-fwhm*0.5, color='r', alpha=0.5, label='Full-width at half-maximum (FWHM) = %.1f fs'%(fwhm*1e15))
axs[0].axvline( fwhm*0.5, color='r', alpha=0.5)

axs[0].set_xlim(-150e-15, 150e-15)
axs[0].set_ylim(0,1.3)
axs[0].set_xlabel('Time (sec)')

axs[1].set_title('Frequency domain')
axs[1].plot(f,If)

axs[1].axvline(-0.44/fwhm*0.5, color='r', alpha=0.5, label='FWHM should be %.1f THz'%(0.44/fwhm*1e-12) )
axs[1].axvline( 0.44/fwhm*0.5, color='r', alpha=0.5)

axs[1].axvline(-fwhm_fft*0.5, color='g', alpha=0.5, ls='dashed', label='FWHM is actually %.1f THz'%(fwhm_fft*1e-12) )
axs[1].axvline( fwhm_fft*0.5, color='g', alpha=0.5, ls='dashed')

axs[1].set_xlim(-2.0e13,2.0e13)
axs[1].set_ylim(0,30000)
axs[1].set_xlabel('Frequency (Hz)')

for ax in axs:
    ax.legend(fontsize=10)
    ax.set_ylabel('Electric field intensity (arbitrary units)')

plt.tight_layout()
plt.savefig('time-bandwidth-product.png', dpi=200)
plt.show()