GNU Radio WX GUI FFT sink peak hold checkbox checked style version:
https://teknokoodiradio.vuodatus.net/lue/2018/02/very-simple-python-rtl-sdr-spectrum-analyzer
No peak hold version:
import matplotlib.pyplot as plt
import matplotlib.pyplot as plts
from rtlsdr import *
sdr = RtlSdr()
ppm = sdr.get_freq_correction()
print 'Frequency correction ' + str(ppm)
tuner_type = sdr.get_tuner_type()
print 'Tuner type ' + str(tuner_type)
sdr.sample_rate = 2.4e6
sdr.center_freq = 393e6
sdr.gain = 4
plts.title('Power spectral density')
plts.xlabel('Frequency (MHz)')
plts.ylabel('Relative power (dB)')
plts.grid(True)
lines, = plts.plot(0, 0)
plts.ion()
fig = plts.figure()
try:
while True:
# remove plt.clf to draw on top of another figure
plt.clf()
samples = sdr.read_samples(256*1024)
plt.psd(samples, NFFT=512, Fs=sdr.sample_rate/1e6, Fc=sdr.center_freq/1e6)
line = plt.gca().lines[0]
lines.set_xdata(line.get_xdata())
lines.set_ydata(line.get_ydata())
fig.canvas.draw()
except KeyboardInterrupt:
plt.close()
Kommentit
Tämän blogin kommentit tarkistetaan ennen julkaisua.