diff options
Diffstat (limited to 'dpd/src')
-rw-r--r-- | dpd/src/Model.py | 37 | ||||
-rw-r--r-- | dpd/src/TX_Agc.py | 8 |
2 files changed, 26 insertions, 19 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") diff --git a/dpd/src/TX_Agc.py b/dpd/src/TX_Agc.py index c3d0698..9274612 100644 --- a/dpd/src/TX_Agc.py +++ b/dpd/src/TX_Agc.py @@ -24,10 +24,10 @@ import src.Adapt as Adapt class TX_Agc: def __init__(self, adapt, - max_txgain=85, - tx_median_target=0.04, - tx_median_threshold_max=0.07, - tx_median_threshold_min=0.02): + max_txgain=89, + tx_median_target=0.1, + tx_median_threshold_max=0.12, + tx_median_threshold_min=0.08): """ In order to avoid digital clipping, this class increases the TX gain and reduces the digital gain. Digital clipping happens |