End sem 7; week 2 winter session 2025
This commit is contained in:
37
7th-Semester-Fall-2024/ECOMMS/final-project/dsp.py
Normal file
37
7th-Semester-Fall-2024/ECOMMS/final-project/dsp.py
Normal file
@@ -0,0 +1,37 @@
|
||||
import scipy as sp
|
||||
import numpy as np
|
||||
|
||||
|
||||
|
||||
def chunk_samples(samples, num_rows):
|
||||
return samples.reshape((samples.shape[0]//num_rows, num_rows))
|
||||
|
||||
|
||||
def db(x):
|
||||
return 10*np.log10(x)
|
||||
|
||||
|
||||
def quad_demod(samples):
|
||||
return 0.5*np.angle(samples[:-1] * np.conj(samples[1:]))
|
||||
|
||||
|
||||
def lowpass(data, f_cutoff, f_s):
|
||||
nyq = 0.5*f_s
|
||||
normal_cutoff = f_cutoff/nyq
|
||||
b, a = sp.signal.butter(2, normal_cutoff, btype="low", analog=False)
|
||||
y = sp.signal.lfilter(b, a, data)
|
||||
return y
|
||||
|
||||
|
||||
def sdr_bandpass(data, f_pass, f_cutoff, extent_MHz):
|
||||
|
||||
lower_extent = extent_MHz[0]*1E6
|
||||
upper_extent = extent_MHz[1]*1E6
|
||||
extent_range = upper_extent - lower_extent
|
||||
|
||||
normal_pass = (f_pass - lower_extent)/extent_range
|
||||
normal_cutoff = (f_cutoff - lower_extent)/extent_range
|
||||
|
||||
b, a = sp.signal.butter(2, (normal_pass, normal_cutoff), btype="bandpass", analog=False)
|
||||
y = sp.signal.lfilter(b, a, data)
|
||||
return y
|
||||
Reference in New Issue
Block a user