summaryrefslogtreecommitdiffstats
path: root/dpd/src/subsample_align.py
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2017-12-29 08:32:58 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2017-12-29 08:32:58 +0100
commitbc25ed90fb34398f9fd3066b7237d1306628b16f (patch)
treede9c96d45728e96b6157e1554503e5d90f229495 /dpd/src/subsample_align.py
parent740d4815fda8737cc7f021999d30aeacd851b032 (diff)
downloaddabmod-bc25ed90fb34398f9fd3066b7237d1306628b16f.tar.gz
dabmod-bc25ed90fb34398f9fd3066b7237d1306628b16f.tar.bz2
dabmod-bc25ed90fb34398f9fd3066b7237d1306628b16f.zip
Transform Const into a global config structure, avoid depending on logging for plot location
Diffstat (limited to 'dpd/src/subsample_align.py')
-rwxr-xr-xdpd/src/subsample_align.py12
1 files changed, 3 insertions, 9 deletions
diff --git a/dpd/src/subsample_align.py b/dpd/src/subsample_align.py
index a5e9f8c..20ae56b 100755
--- a/dpd/src/subsample_align.py
+++ b/dpd/src/subsample_align.py
@@ -7,16 +7,10 @@
import datetime
import logging
import os
-try:
- logging_path = os.path.dirname(logging.getLoggerClass().root.handlers[0].baseFilename)
-except AttributeError:
- logging_path = None
-
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.")
@@ -34,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
@@ -74,13 +68,13 @@ def subsample_align(sig, ref_sig, plot=False):
if optim_result.success:
best_tau = optim_result.x
- if plot and logging_path is not None:
+ 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)