import numpy as np
import matplotlib.pyplot as plt
import scipy.signal as signal
dir = "/home/burak/Documents/Dropbox/Public/data"
= np.fromfile(dir + "/fm1.dat",dtype="uint8")
extract_data = extract_data[0::2] + 1j*extract_data[1::2] interleavedData
"SpectoGram of 'signal' loaded from file")
plt.title("Time")
plt.xlabel("Frequency")
plt.ylabel(=1024, Fs=1140000)
plt.specgram(interleavedData, NFFT 'compscieng_app60wave_07.png') plt.savefig(
"PSD of interleaved Data")
plt.title(=1024, Fs=1140000)
plt.psd(interleavedData, NFFT'compscieng_app60wave_08.png') plt.savefig(
= max(interleavedData) - min(interleavedData);
calculate_range = (interleavedData - min(interleavedData))/ calculate_range
data = (data*2) - 1
x1 "SpectoGram of signal post normalization")
plt.title("Time")
plt.xlabel("Frequency")
plt.ylabel(=1024, Fs=1140000)
plt.specgram(x1, NFFT 'compscieng_app60wave_09.png') plt.savefig(
"PSD of normalized signal")
plt.title(=1024, Fs=1140000)
plt.psd(x1, NFFT'compscieng_app60wave_10.png') plt.savefig(
= 1140000
Fs = np.exp(-1.0j*2.0*np.pi* 250000/Fs*np.arange(len(x1)))
fc = x1*fc
x2 =200000
f_bw=1140000
Fs=64
n_taps= signal.remez(n_taps, [0, f_bw, f_bw +(Fs/2-f_bw)/4,Fs/2], [1,0], Hz=Fs)
lpf'log')
plt.xscale('Filter Frequency Response')
plt.title('Frequency')
plt.xlabel('Amplitude')
plt.ylabel(0,1)
plt.margins(='both',axis='both')
plt.grid(which20*np.log10(abs(h)))
plt.plot(w, 'compscieng_app60wave_11.png') plt.savefig(
= signal.freqz(lpf)
w,h = signal.lfilter(lpf, 1.0, x2)
x3 =1024, Fs=1140000, color="blue") # original
plt.psd(x2, NFFT=1024, Fs=1140000, color="green") # filtered
plt.psd(x3, NFFT"PSD of output signal from LPF Vs Original Signal")
plt.title('compscieng_app60wave_12.png') plt.savefig(
= int(Fs/f_bw)
dec_rate = signal.decimate(x3, dec_rate)
x4 = Fs/dec_rate
Fs_x4 =1024, Fs=Fs_x4, color="blue")
plt.psd(x4, NFFT"PSD of deimated signal")
plt.title('compscieng_app60wave_13.png') plt.savefig(
= x4[1:] * np.conj(x4[:-1])
y = np.angle(y)
x5 =1024, Fs=Fs_x4, color="blue")
plt.psd(x5, NFFT"PSD of Post Frequency Discrimination")
plt.title('compscieng_app60wave_14.png') plt.savefig(
= Fs_x4 * 75e-6 # Calculate the # of samples to hit the -3dB point
d = np.exp(-1/d) # Calculate the decay between each sample
r = [1-r] # Create the filter coefficients
b = [1,-r]
a = signal.lfilter(b,a,x5)
x6 =1024, Fs=Fs_x4, color="blue")
plt.psd(x6, NFFT"PSD of signal Post DeEmphasis")
plt.title('compscieng_app60wave_15.png') plt.savefig(
= Fs_x4 * 75e-6 # Calculate the # of samples to hit the -3dB point
d = np.exp(-1/d) # Calculate the decay between each sample
r = [1-r] # Create the filter coefficients
b = [1,-r]
a = int(Fs/f_bw)
dec_rate =signal.decimate(x6,dec_rate)
x7*= 10000 / np.max(np.abs(x7)) # scale so it's audible
x7"int16").tofile("radio.raw") x7.astype(
aplay radio.raw -r 100000.0 -f S16_LE -t raw -c 1
aplay radio.raw -r 45600 -f S16_LE -t raw -c 1
Kaynaklar
[1] The Basic Facts About Radio Signals, https://www.windows2universe.org/spaceweather/wave_modulation.html
[2] https://drive.google.com/uc?export=view&id=1oevS3Dxy-ksVEQrulxI57R-mHcwFI-Tk
[3] https://drive.google.com/uc?export=view&id=1B65C4v4m8TUx4R__CQ58Jzyw7fnWYDDK
[4] Scher, How to capture raw IQ data from a RTL-SDR dongle and FM demodulate with MATLAB,http://www.aaronscher.com/wireless_com_SDR/RTL_SDR_AM_spectrum_demod.html
[5] EE123: Digital Signal Processing, http://inst.eecs.berkeley.edu/~ee123/sp14/
[6] Fund, Capture and decode FM radio, https://witestlab.poly.edu/blog/capture-and-decode-fm-radio/
[7] Fund, Lab 1: Working with IQ data in Python, http://witestlab.poly.edu/~ffund/el9043/labs/lab1.html
[9] Swiston, pyFmRadio - A Stereo FM Receiver For Your PC, http://davidswiston.blogspot.de/2014/10/pyfmradio-stereo-fm-receiver-for-your-pc.html