简体   繁体   中英

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).

I've created the function as following

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:

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?

return Lorentz

Lorentz is not a function. That's why numpy complained. ( Lorentz is a numpy array)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM