summaryrefslogtreecommitdiffstats
path: root/dpd
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2017-08-18 17:33:37 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2017-08-18 17:33:37 +0200
commit8696ebf0d58e0e2b9b362497e6c1b778de4a20b6 (patch)
tree546a4d9c708c59355c792c496feb9f3faacfd0fd /dpd
parentfb15a5b87f80512748640cb810057204ee1f0968 (diff)
downloaddabmod-8696ebf0d58e0e2b9b362497e6c1b778de4a20b6.tar.gz
dabmod-8696ebf0d58e0e2b9b362497e6c1b778de4a20b6.tar.bz2
dabmod-8696ebf0d58e0e2b9b362497e6c1b778de4a20b6.zip
DPDCE: Change subsample correlation to use complex correlation
Diffstat (limited to 'dpd')
-rwxr-xr-xdpd/src/subsample_align.py21
1 files changed, 15 insertions, 6 deletions
diff --git a/dpd/src/subsample_align.py b/dpd/src/subsample_align.py
index c30af7c..eda1dce 100755
--- a/dpd/src/subsample_align.py
+++ b/dpd/src/subsample_align.py
@@ -2,6 +2,7 @@ import numpy as np
from scipy import signal, optimize
import sys
import matplotlib.pyplot as plt
+import datetime
def gen_omega(length):
if (length % 2) == 1:
@@ -51,20 +52,28 @@ def subsample_align(sig, ref_sig):
corr_sig = np.fft.ifft(rotate_vec * fft_sig)
- # TODO why do we only look at the real part? Because it's faster than
- # a complex cross-correlation? Clarify!
- return -np.sum(np.real(corr_sig) * np.real(ref_sig.real))
+ return -np.abs(np.sum(corr_sig * ref_sig))
optim_result = optimize.minimize_scalar(correlate_for_delay, bounds=(-1,1), method='bounded', options={'disp': True})
if optim_result.success:
- #print("x:")
- #print(optim_result.x)
-
best_tau = optim_result.x
#print("Found subsample delay = {}".format(best_tau))
+ if 0:
+ corr = np.vectorize(correlate_for_delay)
+ ixs = np.linspace(-1, 1, 100)
+ taus = corr(ixs)
+
+ tau_path = ('/tmp/tau_' +
+ datetime.datetime.now().isoformat() +
+ '.pdf')
+ plt.plot(ixs, taus)
+ plt.title("Subsample correlation, minimum is best: {}".format(best_tau))
+ plt.savefig(tau_path)
+ plt.clf()
+
# Prepare rotate_vec = fft_sig with rotated phase
rotate_vec = np.exp(1j * best_tau * omega)
rotate_vec[halflen] = np.cos(np.pi * best_tau)