您好我正在嘗試創建一個洛倫茲函式,該函式接受一個名為“freq”的陣列輸入,輪廓的中心為“freq0”,函式的偏差為“gamma”,(半最大值處的比例引數半寬度)。
我創建了如下功能
def LorentzProfileFreq(freq, freq0, gamma):
'''
Return a Lorentz profile on a given frequency grid
Parameters
----------
freq: array_like
Frequency grid
freq0: float
Center of the profile
gamma: float
Scale parameter gamma (hald-width at half-maximum)
Returns
-------
LorentzProfileFreq: ndarray
Lorentz profile
'''
Lorentz=1/np.pi*((gamma/2)/((freq-freq0)**2 (gamma/2)**2))
return Lorentz(freq,freq0,gamma)
并測驗我所做的功能:
def test_LorentzProfileFreq():
x=np.arange(-5,5,0.1)
y=LorentzProfileFreq(np.arange(-5,5,0.1),0,1)
plt.plot(x,y)
plt.show()
這給了我錯誤
TypeError: 'numpy.ndarray' object is not callable'
,我不明白為什么 np.arange 不可呼叫?
uj5u.com熱心網友回復:
return Lorentz
Lorentz不是函式。這就是為什么numpy抱怨。(Lorentz是一個numpy陣列)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/470307.html
上一篇:BASH:輸入任何條件后控制退出CASE邏輯-無法理解原因
下一篇:在python中重新排列串列串列
