diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python/dpd/ExtractStatistic.py | 2 | ||||
-rw-r--r-- | python/dpd/Model_Poly.py | 26 | ||||
-rwxr-xr-x | python/dpdce.py | 22 | ||||
-rw-r--r-- | python/gui/static/js/odr-predistortion.js | 13 | ||||
-rw-r--r-- | python/gui/templates/predistortion.html | 13 |
6 files changed, 36 insertions, 41 deletions
@@ -24,3 +24,4 @@ __pycache__/ python/gui/logs/access.log python/gui/logs/error.log +python/gui/static/dpd/*png diff --git a/python/dpd/ExtractStatistic.py b/python/dpd/ExtractStatistic.py index a23fa1a..25647a6 100644 --- a/python/dpd/ExtractStatistic.py +++ b/python/dpd/ExtractStatistic.py @@ -115,7 +115,7 @@ class ExtractStatistic: i_sub += 1 ax = plt.subplot(sub_rows, sub_cols, i_sub) ax.plot(num) - ax.set_xlabel("TX Amplitude") + ax.set_xlabel("TX Amplitude bin") ax.set_ylabel("Number of Samples") ax.set_ylim(0, self.n_per_bin * 1.2) diff --git a/python/dpd/Model_Poly.py b/python/dpd/Model_Poly.py index 5722531..7ab6aa1 100644 --- a/python/dpd/Model_Poly.py +++ b/python/dpd/Model_Poly.py @@ -42,18 +42,19 @@ class Poly: self.reset_coefs() - def plot(self, am_plot_location, pm_plot_location, title): - if self._am_plot_data is not None: + def plot(self, plot_location, title): + if self._am_plot_data is not None and self._pm_plot_data is not None: tx_dpd, rx_received, coefs_am, coefs_am_new = self._am_plot_data tx_range, rx_est = self._am_calc_line(coefs_am, 0, 0.6) tx_range_new, rx_est_new = self._am_calc_line(coefs_am_new, 0, 0.6) - sub_rows = 1 + sub_rows = 2 sub_cols = 1 fig = plt.figure(figsize=(sub_cols * 6, sub_rows / 2. * 6)) i_sub = 0 + # AM subplot i_sub += 1 ax = plt.subplot(sub_rows, sub_cols, i_sub) ax.plot(tx_range, rx_est, @@ -67,27 +68,18 @@ class Poly: label="Binned Data", color="blue", s=1) - ax.set_title("Model AM {}".format(title)) + ax.set_title("Model AM and PM {}".format(title)) ax.set_xlabel("TX Amplitude") ax.set_ylabel("RX Amplitude") - ax.set_xlim(-0.5, 1.5) + ax.set_xlim(0, 1.0) ax.legend(loc=4) - fig.tight_layout() - fig.savefig(am_plot_location) - plt.close(fig) - - if self._pm_plot_data is not None: + # PM sub plot tx_dpd, phase_diff, coefs_pm, coefs_pm_new = self._pm_plot_data tx_range, phase_diff_est = self._pm_calc_line(coefs_pm, 0, 0.6) tx_range_new, phase_diff_est_new = self._pm_calc_line(coefs_pm_new, 0, 0.6) - sub_rows = 1 - sub_cols = 1 - fig = plt.figure(figsize=(sub_cols * 6, sub_rows / 2. * 6)) - i_sub = 0 - i_sub += 1 ax = plt.subplot(sub_rows, sub_cols, i_sub) ax.plot(tx_range, phase_diff_est, @@ -101,13 +93,13 @@ class Poly: label="Binned Data", color="blue", s=1) - ax.set_title("Model PM {}".format(title)) ax.set_xlabel("TX Amplitude") ax.set_ylabel("Phase DIff") + ax.set_xlim(0, 1.0) ax.legend(loc=4) fig.tight_layout() - fig.savefig(pm_plot_location) + fig.savefig(plot_location) plt.close(fig) def reset_coefs(self): diff --git a/python/dpdce.py b/python/dpdce.py index 18e628b..f76b0f6 100755 --- a/python/dpdce.py +++ b/python/dpdce.py @@ -143,8 +143,8 @@ internal_data = { } results = { 'statplot': None, - 'amplot': None, - 'pmplot': None, + 'modelplot': None, + 'modeldata': "", 'tx_median': 0, 'rx_median': 0, 'state': 'Idle', @@ -159,8 +159,7 @@ agc = Agc(meas, adapt, c) def clear_pngs(results): results['statplot'] = None - results['amplot'] = None - results['pmplot'] = None + results['modelplot'] = None pngs = glob.glob(os.path.join(plot_path, "*.png")) for png in pngs: try: @@ -206,14 +205,15 @@ def engine_worker(): results['stateprogress'] = 100 results['summary'] = summary + ["Calibration done"] elif cmd == "reset": + model.reset_coefs() with lock: internal_data['n_runs'] = 0 results['state'] = 'Idle' results['stateprogress'] = 0 results['summary'] = ["Reset"] + results['modeldata'] = repr(model.get_dpd_data()) clear_pngs(results) extStat = None - model.reset_coefs() elif cmd == "trigger_run": with lock: results['state'] = 'Capture + Model' @@ -246,7 +246,7 @@ def engine_worker(): with lock: results['statplot'] = "dpd/" + plot_file results['stateprogress'] += 5 - results['summary'] += ["Extracted Statistics".format(tx_median, rx_median), + results['summary'] += ["Extracted Statistics: TX median={} RX median={}".format(tx_median, rx_median), "Runs: {}/{}".format(extStat.n_meas, n_meas)] internal_data['n_runs'] += 1 if extStat.n_meas >= n_meas: @@ -266,16 +266,13 @@ def engine_worker(): model.train(tx, rx, phase_diff, lr=Heuristics.get_learning_rate(n_runs)) time = datetime.datetime.utcnow() - am_plot_file = "model_am_{}.png".format(time.strftime("%s")) - pm_plot_file = "model_pm_{}.png".format(time.strftime("%s")) + model_plot_file = "model_{}.png".format(time.strftime("%s")) model.plot( - os.path.join(plot_path, am_plot_file), - os.path.join(plot_path, pm_plot_file), + os.path.join(plot_path, model_plot_file), time.strftime("%Y-%m-%dT%H%M%S")) with lock: - results['amplot'] = "dpd/" + am_plot_file - results['pmplot'] = "dpd/" + pm_plot_file + results['modelplot'] = "dpd/" + model_plot_file results['state'] = 'Capture + Model' results['stateprogress'] = 85 results['summary'] += ["Getting DPD data"] @@ -285,6 +282,7 @@ def engine_worker(): internal_data['dpddata'] = dpddata internal_data['n_runs'] = 0 + results['modeldata'] = repr(dpddata) results['state'] = 'Capture + Model' results['stateprogress'] = 90 results['summary'] += ["Reset statistics"] diff --git a/python/gui/static/js/odr-predistortion.js b/python/gui/static/js/odr-predistortion.js index 59dcd82..f46219c 100644 --- a/python/gui/static/js/odr-predistortion.js +++ b/python/gui/static/js/odr-predistortion.js @@ -43,18 +43,13 @@ function resultrefresh() { $('#dpdcapturestats').attr('src', ""); } - if (data['amplot']) { - $('#dpdamplot').attr('src', data['amplot']); - } - else { - $('#dpdamplot').attr('src', ""); - } + $('#dpdmodeldata').html(data['modeldata']); - if (data['pmplot']) { - $('#dpdpmplot').attr('src', data['pmplot']); + if (data['modelplot']) { + $('#dpdmodelplot').attr('src', data['modelplot']); } else { - $('#dpdpmplot').attr('src', ""); + $('#dpdmodelplot').attr('src', ""); } }); diff --git a/python/gui/templates/predistortion.html b/python/gui/templates/predistortion.html index d953dff..d102101 100644 --- a/python/gui/templates/predistortion.html +++ b/python/gui/templates/predistortion.html @@ -47,8 +47,17 @@ <div class="panel panel-default"> <div class="panel-heading">AM/AM and AM/PM Model</div> <div class="panel-body"> - <img id="dpdamplot" /> - <img id="dpdpmplot" /> + <div class="container-fluid"> + <div class="row"> + <div class="col-sm-2"> + <p>Model data:</p> + </div> + <div class="col-sm-10"> + <pre id="dpdmodeldata"></pre> + </div> + </div> + </div> + <img id="dpdmodelplot" /> </div> </div> |