diff options
-rwxr-xr-x | dpd/main.py | 8 | ||||
-rw-r--r-- | dpd/src/Dab_Util.py | 17 | ||||
-rw-r--r-- | dpd/src/Model.py | 9 | ||||
-rw-r--r-- | dpd/src/phase_align.py | 9 | ||||
-rwxr-xr-x | dpd/src/subsample_align.py | 11 |
5 files changed, 35 insertions, 19 deletions
diff --git a/dpd/main.py b/dpd/main.py index ae18182..72026dc 100755 --- a/dpd/main.py +++ b/dpd/main.py @@ -10,10 +10,16 @@ This engine calculates and updates the parameter of the digital predistortion module of ODR-DabMod.""" +import datetime +import os + import logging +dt = datetime.datetime.now().isoformat() +logging_path = "/tmp/dpd_{}".format(dt).replace(".","_").replace(":","-") +os.makedirs(logging_path) logging.basicConfig(format='%(asctime)s - %(module)s - %(levelname)s - %(message)s', datefmt='%Y-%m-%d %H:%M:%S', - filename='/tmp/dpd.log', + filename='{}/dpd.log'.format(logging_path), filemode='w', level=logging.DEBUG) diff --git a/dpd/src/Dab_Util.py b/dpd/src/Dab_Util.py index 1f88ae4..175b744 100644 --- a/dpd/src/Dab_Util.py +++ b/dpd/src/Dab_Util.py @@ -1,15 +1,18 @@ # -*- coding: utf-8 -*- +import datetime +import os +import logging +logging_path = os.path.dirname(logging.getLoggerClass().root.handlers[0].baseFilename) + import numpy as np import scipy import matplotlib matplotlib.use('agg') import matplotlib.pyplot as plt -import datetime import src.subsample_align as sa import src.phase_align as pa from scipy import signal -import logging class Dab_Util: """Collection of methods that can be applied to an array @@ -35,7 +38,7 @@ class Dab_Util: if logging.getLogger().getEffectiveLevel() == logging.DEBUG: dt = datetime.datetime.now().isoformat() - corr_path = ("/tmp/" + dt + "_tx_rx_corr.pdf") + corr_path = (logging_path + "/" + dt + "_tx_rx_corr.pdf") plt.plot(c, label="corr") plt.legend() plt.savefig(corr_path) @@ -89,7 +92,7 @@ class Dab_Util: if logging.getLogger().getEffectiveLevel() == logging.DEBUG: dt = datetime.datetime.now().isoformat() - fig_path = "/tmp/" + dt + "_sync_raw.pdf" + fig_path = logging_path + "/" + dt + "_sync_raw.pdf" fig, axs = plt.subplots(2) axs[0].plot(np.abs(sig1[:128]), label="TX Frame") @@ -127,7 +130,7 @@ class Dab_Util: if logging.getLogger().getEffectiveLevel() == logging.DEBUG: dt = datetime.datetime.now().isoformat() - fig_path = "/tmp/" + dt + "_sync_sample_aligned.pdf" + fig_path = logging_path + "/" + dt + "_sync_sample_aligned.pdf" fig, axs = plt.subplots(2) axs[0].plot(np.abs(sig1[:128]), label="TX Frame") @@ -152,7 +155,7 @@ class Dab_Util: if logging.getLogger().getEffectiveLevel() == logging.DEBUG: dt = datetime.datetime.now().isoformat() - fig_path = "/tmp/" + dt + "_sync_subsample_aligned.pdf" + fig_path = logging_path + "/" + dt + "_sync_subsample_aligned.pdf" fig, axs = plt.subplots(2) axs[0].plot(np.abs(sig1[:128]), label="TX Frame") @@ -176,7 +179,7 @@ class Dab_Util: if logging.getLogger().getEffectiveLevel() == logging.DEBUG: dt = datetime.datetime.now().isoformat() - fig_path = "/tmp/" + dt + "_sync_phase_aligned.pdf" + fig_path = logging_path + "/" + dt + "_sync_phase_aligned.pdf" fig, axs = plt.subplots(2) axs[0].plot(np.abs(sig1[:128]), label="TX Frame") diff --git a/dpd/src/Model.py b/dpd/src/Model.py index 014b5ef..7664dd3 100644 --- a/dpd/src/Model.py +++ b/dpd/src/Model.py @@ -1,8 +1,11 @@ # -*- coding: utf-8 -*- -import numpy as np import datetime +import os import logging +logging_path = os.path.dirname(logging.getLoggerClass().root.handlers[0].baseFilename) + +import numpy as np import matplotlib matplotlib.use('agg') import matplotlib.pyplot as plt @@ -55,9 +58,9 @@ class Model: )) dt = datetime.datetime.now().isoformat() - fig_path = "/tmp/" + dt + "_Model.pdf" + fig_path = logging_path + "/" + dt + "_Model.pdf" - fig, axs = plt.subplots(5, figsize=(6,2*6)) + fig, axs = plt.subplots(4, figsize=(6,2*6)) ax = axs[0] ax.plot(np.abs(txframe_aligned[:128]), label="TX Frame") diff --git a/dpd/src/phase_align.py b/dpd/src/phase_align.py index bea0b82..f03184b 100644 --- a/dpd/src/phase_align.py +++ b/dpd/src/phase_align.py @@ -1,9 +1,12 @@ +import datetime +import os +import logging +logging_path = os.path.dirname(logging.getLoggerClass().root.handlers[0].baseFilename) + import numpy as np from scipy import signal, optimize import sys import matplotlib.pyplot as plt -import datetime -import logging def phase_align(sig, ref_sig): @@ -19,7 +22,7 @@ def phase_align(sig, ref_sig): if logging.getLogger().getEffectiveLevel() == logging.DEBUG: dt = datetime.datetime.now().isoformat() - fig_path = "/tmp/" + dt + "_phase_align.pdf" + fig_path = logging_path + "/" + dt + "_phase_align.pdf" plt.subplot(511) plt.hist(angle_diff, bins=60, label="Angle Diff") diff --git a/dpd/src/subsample_align.py b/dpd/src/subsample_align.py index 0dc78c1..0a51593 100755 --- a/dpd/src/subsample_align.py +++ b/dpd/src/subsample_align.py @@ -1,8 +1,11 @@ +import datetime +import os +import logging +logging_path = os.path.dirname(logging.getLoggerClass().root.handlers[0].baseFilename) + 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: @@ -59,15 +62,13 @@ def subsample_align(sig, ref_sig): if optim_result.success: best_tau = optim_result.x - #print("Found subsample delay = {}".format(best_tau)) - if 1: corr = np.vectorize(correlate_for_delay) ixs = np.linspace(-1, 1, 100) taus = corr(ixs) dt = datetime.datetime.now().isoformat() - tau_path = ("/tmp/" + dt + "_tau.pdf") + tau_path = (logging_path + "/" + dt + "_tau.pdf") plt.plot(ixs, taus) plt.title("Subsample correlation, minimum is best: {}".format(best_tau)) plt.savefig(tau_path) |