aboutsummaryrefslogtreecommitdiffstats
path: root/dpd/src/subsample_align.py
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2017-12-29 09:30:47 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2017-12-29 09:30:47 +0100
commit0c0f828c6bccee3aeb3049cb8b5bb480153cd3b6 (patch)
tree520dc4ff15dbc8dba056ea03d762d570b243f27d /dpd/src/subsample_align.py
parent9234155749be0c9ee3ae1269f47c2240d302c21a (diff)
parent8e3338479c180418a05ab030c60ba01c2a8615ca (diff)
downloaddabmod-0c0f828c6bccee3aeb3049cb8b5bb480153cd3b6.tar.gz
dabmod-0c0f828c6bccee3aeb3049cb8b5bb480153cd3b6.tar.bz2
dabmod-0c0f828c6bccee3aeb3049cb8b5bb480153cd3b6.zip
Merge branch 'next' into outputRefactoring
Diffstat (limited to 'dpd/src/subsample_align.py')
-rwxr-xr-xdpd/src/subsample_align.py10
1 files changed, 3 insertions, 7 deletions
diff --git a/dpd/src/subsample_align.py b/dpd/src/subsample_align.py
index 68f3591..20ae56b 100755
--- a/dpd/src/subsample_align.py
+++ b/dpd/src/subsample_align.py
@@ -7,14 +7,10 @@
import datetime
import logging
import os
-
-logging_path = os.path.dirname(logging.getLoggerClass().root.handlers[0].baseFilename)
-
import numpy as np
from scipy import optimize
import matplotlib.pyplot as plt
-
def gen_omega(length):
if (length % 2) == 1:
raise ValueError("Needs an even length array.")
@@ -32,7 +28,7 @@ def gen_omega(length):
return omega
-def subsample_align(sig, ref_sig, plot=False):
+def subsample_align(sig, ref_sig, plot_location=None):
"""Do subsample alignment for sig relative to the reference signal
ref_sig. The delay between the two must be less than sample
@@ -72,13 +68,13 @@ def subsample_align(sig, ref_sig, plot=False):
if optim_result.success:
best_tau = optim_result.x
- if plot:
+ if plot_location is not None:
corr = np.vectorize(correlate_for_delay)
ixs = np.linspace(-1, 1, 100)
taus = corr(ixs)
dt = datetime.datetime.now().isoformat()
- tau_path = (logging_path + "/" + dt + "_tau.svg")
+ tau_path = (plot_location + "/" + dt + "_tau.png")
plt.plot(ixs, taus)
plt.title("Subsample correlation, minimum is best: {}".format(best_tau))
plt.savefig(tau_path)