Why am I getting this error? AttributeError: the 'module' object does not have the 'periodogram' attribute

I copied the following lines

from scipy import signal
import matplotlib.pyplot as plt
import numpy as np

fs = 10e3
N = 1e5
amp = 2*np.sqrt(2)
freq = 1234.0
noise_power = 0.001 * fs / 2
time = np.arange(N) / fs
x = amp*np.sin(2*np.pi*freq*time)
x += np.random.normal(scale=np.sqrt(noise_power), size=time.shape)
# Compute and plot the power spectral density.

f, Pxx_den = signal.periodogram(x, fs)
plt.semilogy(f, Pxx_den)
plt.xlabel('frequency [Hz]')
plt.ylabel('PSD [V**2/Hz]')
plt.show()

from ** http://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.periodogram.html#scipy.signal.periodogram , but when I try to run the code, I get this error:

f, Pxx_den = signal.periodogram(x, fs)
AttributeError: 'module' object has no attribute 'periodogram'

I am using Scipy version 0.12 Thank you for your help. Sincerely. Ivo

+1
source share
1 answer
>>>from scipy import signal

>>>print [x for x in dir(signal) if x == 'periodogram'] #just list comprehension to limit the amount of methods displayed
['periodogram']

- scipy. http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy , , , , , , .

- 100% , , .

+2

Source: https://habr.com/ru/post/1680243/


All Articles