aboutsummaryrefslogtreecommitdiffstats
path: root/python/dpd/Model_PM.py
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2018-12-18 16:53:56 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2018-12-18 16:53:56 +0100
commit9d2c85f7a2a23fcf9ce3c842d86227afed43a153 (patch)
treefe3961130d308212047381eb23a8d2b6e2065dfe /python/dpd/Model_PM.py
parente83e1324a50055a4b972b78e26383df7ee290fee (diff)
downloaddabmod-9d2c85f7a2a23fcf9ce3c842d86227afed43a153.tar.gz
dabmod-9d2c85f7a2a23fcf9ce3c842d86227afed43a153.tar.bz2
dabmod-9d2c85f7a2a23fcf9ce3c842d86227afed43a153.zip
GUI: Automatically iterate captures and show model plots
Diffstat (limited to 'python/dpd/Model_PM.py')
-rw-r--r--python/dpd/Model_PM.py23
1 files changed, 10 insertions, 13 deletions
diff --git a/python/dpd/Model_PM.py b/python/dpd/Model_PM.py
index 7b80bf3..40fa1d4 100644
--- a/python/dpd/Model_PM.py
+++ b/python/dpd/Model_PM.py
@@ -28,22 +28,18 @@ class Model_PM:
"""Calculates new coefficients using the measurement and the previous
coefficients"""
- def __init__(self,
- c,
- learning_rate_pm=1,
- plot=False):
+ def __init__(self, c, learning_rate_pm=1):
self.c = c
-
self.learning_rate_pm = learning_rate_pm
- self.plot = plot
+ self._plot_data = None
+
+ def plot(self, plot_location, title):
+ if self._plot_data is not None:
+ tx_dpd, phase_diff, coefs_pm, coefs_pm_new = self._plot_data
- def _plot(self, tx_dpd, phase_diff, coefs_pm, coefs_pm_new):
- if self.plot and self.c.plot_location is not None:
tx_range, phase_diff_est = self.calc_line(coefs_pm, 0, 0.6)
tx_range_new, phase_diff_est_new = self.calc_line(coefs_pm_new, 0, 0.6)
- dt = datetime.datetime.now().isoformat()
- fig_path = self.c.plot_location + "/" + dt + "_Model_PM.png"
sub_rows = 1
sub_cols = 1
fig = plt.figure(figsize=(sub_cols * 6, sub_rows / 2. * 6))
@@ -62,13 +58,13 @@ class Model_PM:
label="Binned Data",
color="blue",
s=1)
- ax.set_title("Model_PM")
+ ax.set_title("Model_PM {}".format(title))
ax.set_xlabel("TX Amplitude")
ax.set_ylabel("Phase DIff")
ax.legend(loc=4)
fig.tight_layout()
- fig.savefig(fig_path)
+ fig.savefig(plot_location)
plt.close(fig)
def _discard_small_values(self, tx_dpd, phase_diff):
@@ -97,13 +93,14 @@ class Model_PM:
coefs_pm_new = self.fit_poly(tx_dpd, phase_diff)
coefs_pm_new = coefs_pm + self.learning_rate_pm * (coefs_pm_new - coefs_pm)
- self._plot(tx_dpd, phase_diff, coefs_pm, coefs_pm_new)
+ self._plot_data = (tx_dpd, phase_diff, coefs_pm, coefs_pm_new)
return coefs_pm_new
# The MIT License (MIT)
#
# Copyright (c) 2017 Andreas Steger
+# Copyright (c) 2018 Matthias P. Braendli
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal