[英]np.arange object is not callable
Hi I'm trying to create a Lorentz function that takes an array input called "freq", the center of the profile as "freq0" and the deviation of the function as "gamma", (scale parameter half width at half maximum).您好,我正在尝试创建一个 Lorentz function,它采用名为“freq”的数组输入,配置文件的中心为“freq0”,function 的偏差为“gamma”,(比例参数半宽度半最大值)。
I've created the function as following我创建了 function 如下
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)
And testing the function I did:并测试我所做的 function:
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()
Which gives me the error TypeError: 'numpy.ndarray' object is not callable'
I don't understand why np.arange is not callable?这给我错误
TypeError: 'numpy.ndarray' object is not callable'
我不明白为什么 np.arange 不可调用?
return Lorentz
Lorentz
is not a function. That's why numpy
complained. Lorentz
不是 function。这就是numpy
抱怨的原因。 ( Lorentz
is a numpy array) (
Lorentz
是一个 numpy 数组)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.