From 80ae5c80144451706ba00b24046b31d89a7c0165 Mon Sep 17 00:00:00 2001 From: andreas128 Date: Tue, 26 Sep 2017 17:47:51 +0200 Subject: Move plot config in const.py --- dpd/main.py | 14 +++++++------- dpd/src/MER.py | 10 ++++++---- dpd/src/Measure_Shoulders.py | 2 +- dpd/src/Model_Poly.py | 5 ++--- dpd/src/const.py | 8 ++++++++ 5 files changed, 24 insertions(+), 15 deletions(-) (limited to 'dpd') diff --git a/dpd/main.py b/dpd/main.py index 871a404..ddbbfc4 100755 --- a/dpd/main.py +++ b/dpd/main.py @@ -109,17 +109,17 @@ txgain = cli_args.txgain c = src.const.const(samplerate, target_median) SA = src.Symbol_align.Symbol_align(c) MER = src.MER.MER(c) -MS = src.Measure_Shoulders.Measure_Shoulder(c, plot=True) +MS = src.Measure_Shoulders.Measure_Shoulder(c) meas = Measure.Measure(samplerate, port, num_req) -extStat = ExtractStatistic.ExtractStatistic(c, plot=True) +extStat = ExtractStatistic.ExtractStatistic(c) adapt = Adapt.Adapt(port_rc, coef_path) dpddata = adapt.get_predistorter() if cli_args.lut: - model = Model.Lut(c, plot=True) + model = Model.Lut(c) else: - model = Model.Poly(c, plot=True) + model = Model.Poly(c) adapt.set_predistorter(model.get_dpd_data()) adapt.set_digital_gain(digital_gain) @@ -190,7 +190,7 @@ while i < num_iter: elif state == "model": dpddata = model.train(tx, rx, phase_diff) dpddata = model.get_dpd_data() - extStat = ExtractStatistic.ExtractStatistic(c, plot=True) + extStat = ExtractStatistic.ExtractStatistic(c) state = "adapt" # Adapt @@ -205,8 +205,8 @@ while i < num_iter: path = adapt.dump() off = SA.calc_offset(txframe_aligned) - tx_mer = MER.calc_mer(txframe_aligned[off:off+c.T_U], debug=True, debug_name="TX") - rx_mer = MER.calc_mer(rxframe_aligned[off:off+c.T_U], debug=True, debug_name="RX") + tx_mer = MER.calc_mer(txframe_aligned[off:off+c.T_U], debug_name="TX") + rx_mer = MER.calc_mer(rxframe_aligned[off:off+c.T_U], debug_name="RX") mse = np.mean(np.abs((txframe_aligned - rxframe_aligned)**2)) tx_gain = adapt.get_txgain() rx_gain = adapt.get_rxgain() diff --git a/dpd/src/MER.py b/dpd/src/MER.py index 7aea38f..393e55c 100644 --- a/dpd/src/MER.py +++ b/dpd/src/MER.py @@ -23,6 +23,8 @@ class MER: def __init__(self, c): self.c = c + self.plot = c.MER_plot + def _calc_spectrum(self, tx): fft = np.fft.fftshift(np.fft.fft(tx)) return np.delete(fft[self.c.FFT_start:self.c.FFT_end], @@ -69,13 +71,13 @@ class MER: return x_mean, y_mean, U_RMS, U_ERR, MER - def calc_mer(self, tx, debug=False, debug_name=""): + def calc_mer(self, tx, debug_name=""): assert tx.shape[0] == self.c.T_U,\ "Wrong input length" spectrum = self._calc_spectrum(tx) - if debug: + if self.plot: dt = datetime.datetime.now().isoformat() fig_path = logging_path + "/" + dt + "_MER" + debug_name + ".svg" @@ -91,7 +93,7 @@ class MER: x_err = U_ERR * np.sin(tau) + x_mean y_err = U_ERR * np.cos(tau) + y_mean - if debug: + if self.plot: ax = plt.subplot(221 + i) ax.scatter(x, y, s=0.2, color='black') ax.plot(x_mean, y_mean, 'p', color='red') @@ -102,7 +104,7 @@ class MER: ylim = ax.get_ylim() ax.set_ylim(ylim[0] - (ylim[1] - ylim[0]) * 0.1, ylim[1]) - if debug: + if self.plot: plt.tight_layout() plt.savefig(fig_path) plt.show() diff --git a/dpd/src/Measure_Shoulders.py b/dpd/src/Measure_Shoulders.py index 1417613..acb05b4 100644 --- a/dpd/src/Measure_Shoulders.py +++ b/dpd/src/Measure_Shoulders.py @@ -69,7 +69,7 @@ class Measure_Shoulder: c, plot=False): self.c = c - self.plot = plot + self.plot = c.MS_plot def _plot(self, signal): dt = datetime.datetime.now().isoformat() diff --git a/dpd/src/Model_Poly.py b/dpd/src/Model_Poly.py index f6c024c..e799f1e 100644 --- a/dpd/src/Model_Poly.py +++ b/dpd/src/Model_Poly.py @@ -44,8 +44,7 @@ class Poly: def __init__(self, c, learning_rate_am=1.0, - learning_rate_pm=1.0, - plot=False): + learning_rate_pm=1.0): self.c = c self.learning_rate_am = learning_rate_am @@ -56,7 +55,7 @@ class Poly: self.model_am = Model_AM.Model_AM(c, plot=True) self.model_pm = Model_PM.Model_PM(c, plot=True) - self.plot = plot + self.plot = c.MDL_plot def reset_coefs(self): self.coefs_am = np.zeros(5, dtype=np.float32) diff --git a/dpd/src/const.py b/dpd/src/const.py index cbef8af..d95d0bf 100644 --- a/dpd/src/const.py +++ b/dpd/src/const.py @@ -38,6 +38,7 @@ class const: self.phase_offset_per_sample = 1. / sample_rate * 2 * np.pi * 1000 # Constants for ExtractStatistic + self.ES_plot = True self.ES_start = 0.0 self.ES_end = 1.0 self.ES_n_bins = 64 @@ -53,10 +54,17 @@ class const: self.RAGC_min_rxgain = 25 self.RAGC_rx_median_target = self.TAGC_tx_median_target + # Constants for Model + self.MDL_plot = True + + # Constants for MER + self.MER_plot = True + # Constants for Model_PM self.MPM_tx_min = 0.1 # Constants for Measure_Shoulder + self.MS_plot = True assert sample_rate==8192000 meas_offset = 976 # Offset from center frequency to measure shoulder [kHz] meas_width = 100 # Size of frequency delta to measure shoulder [kHz] -- cgit v1.2.3