summaryrefslogtreecommitdiffstats
path: root/dpd/src/Model.py
diff options
context:
space:
mode:
authorandreas128 <Andreas>2017-09-08 16:22:23 +0200
committerandreas128 <Andreas>2017-09-08 16:22:23 +0200
commit086348ab4d788f8453ca78fed4f3f837779c9916 (patch)
tree47232eda6c57ebeacfc190cbe8840b32a6d02dfa /dpd/src/Model.py
parent691591cd7e14e4ed576675b178917f3ae7fe5863 (diff)
downloaddabmod-086348ab4d788f8453ca78fed4f3f837779c9916.tar.gz
dabmod-086348ab4d788f8453ca78fed4f3f837779c9916.tar.bz2
dabmod-086348ab4d788f8453ca78fed4f3f837779c9916.zip
Cleanup, Add MER logging to Model
Diffstat (limited to 'dpd/src/Model.py')
-rw-r--r--dpd/src/Model.py37
1 files changed, 22 insertions, 15 deletions
diff --git a/dpd/src/Model.py b/dpd/src/Model.py
index bf52287..61c487e 100644
--- a/dpd/src/Model.py
+++ b/dpd/src/Model.py
@@ -11,20 +11,23 @@ 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
-from sklearn.linear_model import Ridge
class Model:
"""Calculates new coefficients using the measurement and the old
coefficients"""
- def __init__(self, coefs_am, coefs_pm, plot=False):
+ def __init__(self, c, SA, MER, coefs_am, coefs_pm, plot=False):
+ self.c = c
+ self.SA = SA
+ self.MER = MER
+
self.coefs_am = coefs_am
self.coefs_history = [coefs_am, ]
- self.mses = [0, ]
- self.errs = [0, ]
+ self.mses = []
+ self.errs = []
+ self.tx_mers = []
+ self.rx_mers = []
self.coefs_pm = coefs_pm
self.coefs_pm_history = [coefs_pm, ]
@@ -57,10 +60,10 @@ class Model:
def amplitude_predistortion(self, sig):
sig_abs = np.abs(sig)
A_sig = np.vstack([np.ones(sig_abs.shape),
+ sig_abs ** 1,
sig_abs ** 2,
+ sig_abs ** 3,
sig_abs ** 4,
- sig_abs ** 6,
- sig_abs ** 8,
]).T
sig_dpd = sig * np.sum(A_sig * self.coefs_am, axis=1)
return sig_dpd, A_sig
@@ -120,6 +123,13 @@ class Model:
new_coefs))
if logging.getLogger().getEffectiveLevel() == logging.DEBUG and self.plot:
+ off = self.SA.calc_offset(tx_dpd)
+ tx_mer = self.MER.calc_mer(tx_dpd[off:off + self.c.T_U])
+ rx_mer = self.MER.calc_mer(rx_received[off:off + self.c.T_U], debug=True)
+ self.tx_mers.append(tx_mer)
+ self.rx_mers.append(rx_mer)
+
+ if logging.getLogger().getEffectiveLevel() == logging.DEBUG and self.plot:
dt = datetime.datetime.now().isoformat()
fig_path = logging_path + "/" + dt + "_Model.svg"
@@ -182,15 +192,12 @@ class Model:
ax.set_ylabel("Coefficient Value")
ax = plt.subplot(2,3,5)
- coefs_history = np.array(self.coefs_pm_history)
- for idx, coef_hist in enumerate(coefs_history.T):
- ax.plot(coef_hist,
- label="Coef {}".format(idx),
- linewidth=0.5)
+ ax.plot(self.tx_mers, label="TX MER")
+ ax.plot(self.rx_mers, label="RX MER")
ax.legend(loc=4)
- ax.set_title("AM/PM Coefficient History")
+ ax.set_title("MER History")
ax.set_xlabel("Iterations")
- ax.set_ylabel("Coefficient Value")
+ ax.set_ylabel("MER")
ax = plt.subplot(2,3,6)
ax.plot(self.mses, label="MSE")