summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandreas128 <Andreas>2017-09-22 16:27:44 +0200
committerandreas128 <Andreas>2017-09-22 16:27:44 +0200
commit7579bd9c1bdc779555895cdcae46dc3361eb9d08 (patch)
tree0ba103e62a0ce75013f7ee3696457a76ef6cf490
parent25cf9065bdd0a7f7630772bb63e0aea32a0903ff (diff)
downloaddabmod-7579bd9c1bdc779555895cdcae46dc3361eb9d08.tar.gz
dabmod-7579bd9c1bdc779555895cdcae46dc3361eb9d08.tar.bz2
dabmod-7579bd9c1bdc779555895cdcae46dc3361eb9d08.zip
Add dump/load for Adapt
-rwxr-xr-xdpd/main.py26
-rw-r--r--dpd/src/Adapt.py30
2 files changed, 48 insertions, 8 deletions
diff --git a/dpd/main.py b/dpd/main.py
index 69d6175..923a7f8 100755
--- a/dpd/main.py
+++ b/dpd/main.py
@@ -66,7 +66,7 @@ parser.add_argument('--samplerate', default=8192000, type=int,
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=78,
help='TX Gain',
required=False,
type=int)
@@ -164,11 +164,8 @@ while i < num_iter:
continue
tx, rx, phase_diff, n_per_bin = extStat.extract(txframe_aligned, rxframe_aligned)
- n_use = int(len(n_per_bin) * 0.35)
- tx = tx[:n_use]
- rx = rx[:n_use]
- phase_diff = phase_diff[:n_use]
- if all(c.ES_n_per_bin == np.array(n_per_bin)[0:n_use]):
+
+ if extStat.n_meas >= 15:
state = "model"
else:
state = "measure"
@@ -189,6 +186,8 @@ while i < num_iter:
# Report
elif state == "report":
try:
+ path = adapt.dump()
+
off = SA.calc_offset(txframe_aligned)
tx_mer = MER.calc_mer(txframe_aligned[off:off+c.T_U], debug=True)
rx_mer = MER.calc_mer(rxframe_aligned[off:off+c.T_U], debug=True)
@@ -208,13 +207,24 @@ while i < num_iter:
if dpddata[0] == "poly":
coefs_am = dpddata[1]
coefs_pm = dpddata[2]
- logging.info("It {}: coefs_am {}, coefs_pm {}".
- format(i, coefs_am, coefs_pm))
+ logging.info("It {}: coefs_am {}".
+ format(i, coefs_am))
+ logging.info("It {}: coefs_pm {}".
+ format(i, coefs_pm))
if dpddata[0] == "lut":
scalefactor = dpddata[1]
lut = dpddata[2]
logging.info("It {}: LUT scalefactor {}, LUT {}".
format(i, scalefactor, lut))
+
+ model.reset_coefs()
+ dpd_data = model.get_dpd_data()
+ adapt.set_predistorter(dpd_data)
+ tx_gain = tx_gain - 1
+ if tx_gain < 89:
+ adapt.set_txgain(tx_gain)
+ else:
+ break
state = "measure"
except:
logging.warning("Iteration {}: Report failed.".format(i))
diff --git a/dpd/src/Adapt.py b/dpd/src/Adapt.py
index f21bb87..84b65f6 100644
--- a/dpd/src/Adapt.py
+++ b/dpd/src/Adapt.py
@@ -12,6 +12,11 @@ the ZMQ remote control socket.
import zmq
import logging
import numpy as np
+import os
+import datetime
+import pickle
+
+logging_path = os.path.dirname(logging.getLoggerClass().root.handlers[0].baseFilename)
LUT_LEN=32
FORMAT_POLY=1
@@ -200,6 +205,31 @@ class Adapt:
raise ValueError("Unknown predistorter '{}'".format(dpddata[0]))
self.send_receive("set memlesspoly coeffile {}".format(self.coef_path))
+ def dump(self, path=None):
+ if path is None:
+ dt = datetime.datetime.now().isoformat()
+ path = logging_path + "/" + dt + "_adapt.pkl"
+ d = {
+ "txgain":self.get_txgain(),
+ "rxgain":self.get_rxgain(),
+ "digital_gain":self.get_digital_gain(),
+ "predistorter":self.get_predistorter()
+ }
+ with open(path, "w") as f:
+ pickle.dump(d,f)
+
+ return path
+
+ def load(self, path):
+ with open(path, "r") as f:
+ d = pickle.load(f)
+
+ self.set_txgain(d["txgain"])
+ self.set_digital_gain(d["digital_gain"])
+ self.set_rxgain(d["rxgain"])
+ self.set_predistorter(d["predistorter"])
+
+
# The MIT License (MIT)
#
# Copyright (c) 2017 Andreas Steger, Matthias P. Braendli