【发布时间】:2019-03-13 17:34:28
【问题描述】:
我一直在尝试通过计算计算评估以下 E 场:
它基本上是给定波长的波的总和,由波长的高斯分布的平方根加权。
我通过 Python 通过包 scipy.integrate.quad 函数对 $x$ 的每个值执行高斯正交积分来计算它。代码如下:
# Imports
import numpy as np
import scipy as sp
from scipy import integrate
# Parameters
mu = 0.635 # mean wavelength
sigma = 0.01 # std dev of wavelength distribution
# wl is wavelength
x_ara = np.arange(0, 1.4, 0.01)
# Limits of Integration
lower, upper = mu - 4*sigma, mu+4*sigma
if lower < 0 :
print('lower limit met')
lower = 1e-15 # cannot evaluate sigma = 0 due to singularity for gaussian function
# Functions
def Iprofile_func(wl, mu, sigma):
profile = np.exp(-( ((wl-mu) / (np.sqrt(2)*sigma))**2))
return profile
def E_func(x_ara, wl, mu, sigma):
return np.sqrt(Iprofile_func(wl, mu, sigma)) * np.cos(2*np.pi/wl * (x_ara))
# Computation
field_ara = np.array([])
for x in x_ara:
def E(wl):
return E_func(x, wl, mu, sigma)
field = sp.integrate.quad(E, lower, upper)[0]
field_ara = np.append(field_ara, field)
我固定了 $\mu$ = 0.635 的值,并对 $\sigma$ 的两个值进行了相同的计算,$\sigma$ = 0.01 和 $\sigma$ = 0.2。我得到的数组,我在下面绘制,上面的图是波长分布,而下面的图是计算场数组:
sigma值增大时,为什么计算域会出现噪声?
【问题讨论】:
-
显示的公式和代码中的方程不一样。该代码以高斯峰值的平方根为第一因子。
-
请注意,Iprofile_func 有一个 sqrt(2) 作为指数参数中的分母,结果是相同的
-
我明白了。那么只有“减号”丢失了。
标签: python graph signal-processing computation