aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dab_util.py13
-rw-r--r--src/dab_util_test.py2
-rw-r--r--src/dabconst.py20
3 files changed, 29 insertions, 6 deletions
diff --git a/src/dab_util.py b/src/dab_util.py
index 843f8a5..617bd9a 100644
--- a/src/dab_util.py
+++ b/src/dab_util.py
@@ -1,7 +1,6 @@
import numpy as np
import scipy
import matplotlib.pyplot as plt
-import fftconvolve
import src.dabconst as dabconst
from scipy import signal
@@ -84,9 +83,15 @@ def fftlag(sig_orig, sig_rec, n_upsampling = 1):
sig_orig: The signal that has been sent
sig_rec: The signal that has been recored
"""
- c = np.flipud(fftconvolve.fftconvolve(sig_orig,np.flipud(sig_rec), n_upsampling))
- #plt.plot(c)
- return (np.argmax(c) - sig_orig.shape[0] + 1)
+ #off = sig_rec.shape[0]
+ #fft1 = np.fft.fft(sig_orig, n=sig_orig.shape[0])
+ #fft2 = np.fft.fft(np.flipud(sig_rec), n=sig_rec.shape[0])
+ #fftc = fft1 * fft2
+ #c = np.fft.ifft(fftc)
+ c = signal.convolve(sig_orig, np.flipud(sig_rec))
+ #c = signal.correlate(sig_orig, sig_rec)
+ return c
+ return np.argmax(c) - off + 1
def get_amp_ratio(ampl_1, ampl_2, a_out_abs, a_in_abs):
idxs = (a_in_abs > ampl_1) & (a_in_abs < ampl_2)
diff --git a/src/dab_util_test.py b/src/dab_util_test.py
index 83813a9..be36d53 100644
--- a/src/dab_util_test.py
+++ b/src/dab_util_test.py
@@ -1,9 +1,7 @@
from scipy import signal
import numpy as np
import src.gen_source as gs
-reload(gs)
import src.dab_util as du
-reload(du)
def gen_test_signals(oversampling=4, sample_offset_float=0):
off = int(sample_offset_float)
diff --git a/src/dabconst.py b/src/dabconst.py
new file mode 100644
index 0000000..d978753
--- /dev/null
+++ b/src/dabconst.py
@@ -0,0 +1,20 @@
+class tm1():
+ def __init__(self, rate = 2048000):
+ self.upsampling = rate / 2048000
+ self.L = 76
+ self.K = 1536
+
+ self.S_F = 196608 * self.upsampling
+ self.T_F = float(self.S_F) / rate
+
+ self.S_NULL = 2656 * self.upsampling
+ self.T_NULL = float(self.S_NULL) / rate
+
+ self.S_S = 2552 * self.upsampling
+ self.T_S = float(self.S_S) / rate
+
+ self.S_U = 2048 * self.upsampling
+ self.T_S = float(self.S_U) / rate
+
+ self.S_GUARD = 504 * self.upsampling
+ self.T_GUARD = float(self.S_GUARD) / rate