diff options
-rwxr-xr-x | dpd/main.py | 9 | ||||
-rw-r--r-- | dpd/src/Model.py | 37 | ||||
-rw-r--r-- | dpd/src/TX_Agc.py | 8 |
3 files changed, 32 insertions, 22 deletions
diff --git a/dpd/main.py b/dpd/main.py index eef1eb8..03520f5 100755 --- a/dpd/main.py +++ b/dpd/main.py @@ -14,6 +14,9 @@ import datetime import os import time +import matplotlib +matplotlib.use('GTKAgg') + import logging dt = datetime.datetime.now().isoformat() @@ -61,7 +64,7 @@ parser.add_argument('--samplerate', default='8192000', parser.add_argument('--coefs', default='poly.coef', help='File with DPD coefficients, which will be read by ODR-DabMod', required=False) -parser.add_argument('--txgain', default=70, +parser.add_argument('--txgain', default=74, help='TX Gain', required=False, type=int) @@ -104,9 +107,9 @@ meas = Measure.Measure(samplerate, port, num_req) adapt = Adapt.Adapt(port_rc, coef_path) coefs_am, coefs_pm = adapt.get_coefs() if cli_args.load_poly: - model = Model.Model(coefs_am, coefs_pm, plot=True) + model = Model.Model(c, SA, MER, coefs_am, coefs_pm, plot=True) else: - model = Model.Model([1.0, 0, 0, 0, 0], [0, 0, 0, 0, 0], plot=True) + model = Model.Model(c, SA, MER, [1.0, 0, 0, 0, 0], [0, 0, 0, 0, 0], plot=True) adapt.set_coefs(model.coefs_am, model.coefs_pm) adapt.set_digital_gain(digital_gain) adapt.set_txgain(txgain) 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 |