While i executing this code it show's an error, I'm using matplotlib.mlab psd
here's the code,
from matplotlib.mlab import psd
from rtlsdr import *
import matplotlib.pyplot as plt
sdr = RtlSdr()
# configure device
sdr.sample_rate = 2.4e6
p = sdr.center_freq = 95e6
sdr.gain = 'auto'
arr_db = []
arr_fq = []
def plot_graph():
print(len(arr_db))
print(len(arr_fq))
xlabel('Frequency (MHz)')
ylabel('Relative power (dB)')
#plt.plot(arr_db, arr_fq, color='blue')
plt.draw()
plt.pause(0.5)
plt.clf()
while True:
# use matplotlib to estimate and plot the PSD
samples = sdr.read_samples(256*1024)
a = psd(samples.real, NFFT=1024, Fs=sdr.sample_rate/1e6, Fc=p/1e6)
p+= 1000000
for i in range(513):
b = a[0][i]
c = a[1][i]
arr_db.append(b)
arr_fq.append(c)
plot_graph()
sdr.close()
And the error showing like this,
Traceback (most recent call last):
File "c:\Users\DELL\Desktop\Ismail\rtl_sdr\sample.py", line 27, in <module>
a = psd(samples.real, NFFT=1024, Fs=sdr.sample_rate/1e6, Fc=p/1e6)
TypeError: psd() got an unexpected keyword argument 'Fc'
Found Rafael Micro R820T/2 tuner
can anyone help
You've imported the wrong
psdfunction.You're looking for
matplotlib.pyplot.psd; you havematplotlib.mlab.psd, which has a different signature.Change your import to
or just use
plt.psdsince you havepyplotimported asplt.