aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandreas128 <Andreas>2017-05-19 11:02:13 +0100
committerandreas128 <Andreas>2017-05-19 11:02:13 +0100
commit3dfe0a526a21093b864b99f113eb49ab84e3b377 (patch)
tree8232712672c448d123f7406c87150d40e1d88b51
parentea934695d10c165b37099c70255927d5165bddf0 (diff)
downloadODR-StaticPrecorrection-3dfe0a526a21093b864b99f113eb49ab84e3b377.tar.gz
ODR-StaticPrecorrection-3dfe0a526a21093b864b99f113eb49ab84e3b377.tar.bz2
ODR-StaticPrecorrection-3dfe0a526a21093b864b99f113eb49ab84e3b377.zip
Add dabconst, fix import fftconvolve
-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