Search code examples
pythonpython-3.xnumpyfrequency

Detecting frequency of a training set


I am trying to detect the frequency of the x-axis which is referred to (m) training set in my LSTM model

r,time, x, y, z, m, s,l = np.loadtxt('FINALkneeTRAIN.txt', delimiter = ',',
                                     unpack = True)
spectrum = fft.fft(m)
freq = fft.fftfreq(len(spectrum))
plt(freq, abs(spectrum))

but it gives me the following error:

plt(freq, abs(spectrum))
TypeError: 'module' object is not callable

Solution

  • You should provide some more information on your code. But I assume that this line is written somewhere:

    import matplotlib.pyplot as plt
    

    In this case, when you write plt(freq, abs(spectrum)) you are referring to the module plt instead of a plotting function. If you do have the above line you probably want

    plt.plot(freq, abs(spectrum))
    

    In addition, you may find this numpy docpage useful

    https://docs.scipy.org/doc/numpy-1.14.0/reference/generated/numpy.fft.fft.html