aboutsummaryrefslogtreecommitdiffstats
path: root/dpd
diff options
context:
space:
mode:
authorandreas128 <Andreas>2017-09-27 17:45:12 +0200
committerandreas128 <Andreas>2017-09-27 17:45:12 +0200
commit09a9dcf3f857e912c099806bece452bcf96722cb (patch)
tree55afe62780e66b629a170ac1a6e330c886d57cde /dpd
parent5db7642424ddb5c6c304899efd4e8f74a8351a65 (diff)
downloaddabmod-09a9dcf3f857e912c099806bece452bcf96722cb.tar.gz
dabmod-09a9dcf3f857e912c099806bece452bcf96722cb.tar.bz2
dabmod-09a9dcf3f857e912c099806bece452bcf96722cb.zip
Cleanup
Diffstat (limited to 'dpd')
-rw-r--r--dpd/environment.yml1
-rwxr-xr-xdpd/main.py62
-rw-r--r--dpd/src/Adapt.py8
-rw-r--r--dpd/src/Const.py2
-rw-r--r--dpd/src/Model_AM.py1
-rw-r--r--dpd/src/Model_PM.py1
-rw-r--r--dpd/src/Model_Poly.py6
7 files changed, 42 insertions, 39 deletions
diff --git a/dpd/environment.yml b/dpd/environment.yml
index 2d7f260..5c19258 100644
--- a/dpd/environment.yml
+++ b/dpd/environment.yml
@@ -84,7 +84,6 @@ dependencies:
- readline=6.2=2
- requests=2.14.2=py27_0
- scandir=1.5=py27_0
-- scikit-learn=0.18.1=np112py27_1
- scipy=0.19.0=np112py27_0
- setuptools=27.2.0=py27_0
- simplegeneric=0.8.1=py27_1
diff --git a/dpd/main.py b/dpd/main.py
index 3424572..d71fd2d 100755
--- a/dpd/main.py
+++ b/dpd/main.py
@@ -123,7 +123,6 @@ MS = Measure_Shoulders(c)
meas = Measure.Measure(samplerate, port, num_req)
extStat = ExtractStatistic.ExtractStatistic(c)
adapt = Adapt.Adapt(port_rc, coef_path)
-dpddata = adapt.get_predistorter()
if cli_args.lut:
model = Model.Lut(c)
@@ -181,41 +180,43 @@ i = 0
while i < num_iter:
try:
# Measure
- if state == "measure":
+ if state == 'measure':
+ # Get Samples and check gain
txframe_aligned, tx_ts, rxframe_aligned, rx_ts, rx_median = meas.get_samples()
- rxframe_aligned.tofile("/tmp/rxframe_aligned.np")
- txframe_aligned.tofile("/tmp/txframe_aligned.np")
if tx_agc.adapt_if_necessary(txframe_aligned):
continue
+ # Extract usable data from measurement
tx, rx, phase_diff, n_per_bin = extStat.extract(txframe_aligned, rxframe_aligned)
if extStat.n_meas >= c.n_meas:
- state = "model"
+ state = 'model'
else:
- state = "measure"
+ state = 'measure'
# Model
- elif state == "model":
- dpddata = model.train(tx, rx, phase_diff)
+ elif state == 'model':
+ # Calculate new model parameters and delete old measurements
+ model.train(tx, rx, phase_diff)
dpddata = model.get_dpd_data()
extStat = ExtractStatistic.ExtractStatistic(c)
- state = "adapt"
+ state = 'adapt'
# Adapt
- elif state == "adapt":
+ elif state == 'adapt':
adapt.set_predistorter(dpddata)
- state = "report"
+ state = 'report'
# Report
- elif state == "report":
+ elif state == 'report':
try:
- i += 1
- path = adapt.dump()
+ # Store all settings for pre-distortion, tx and rx
+ adapt.dump()
+ # Collect logging data
off = SA.calc_offset(txframe_aligned)
- 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")
+ 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()
@@ -224,36 +225,35 @@ while i < num_iter:
rx_shoulder_tuple = MS.average_shoulders(rxframe_aligned) if c.MS_enable else None
tx_shoulder_tuple = MS.average_shoulders(txframe_aligned) if c.MS_enable else None
+ # Generic logging
logging.info(list((name, eval(name)) for name in
['i', 'tx_mer', 'tx_shoulder_tuple', 'rx_mer',
'rx_shoulder_tuple', 'mse', 'tx_gain',
'digital_gain', 'rx_gain', 'rx_median',
'tx_median']))
- if dpddata[0] == "poly":
+
+ # Model specific logging
+ if dpddata[0] == 'poly':
coefs_am = dpddata[1]
coefs_pm = dpddata[2]
- logging.info("It {}: coefs_am {}".
+ logging.info('It {}: coefs_am {}'.
format(i, coefs_am))
- logging.info("It {}: coefs_pm {}".
+ logging.info('It {}: coefs_pm {}'.
format(i, coefs_pm))
- if dpddata[0] == "lut":
+ elif dpddata[0] == 'lut':
scalefactor = dpddata[1]
lut = dpddata[2]
- logging.info("It {}: LUT scalefactor {}, LUT {}".
+ logging.info('It {}: LUT scalefactor {}, LUT {}'.
format(i, scalefactor, lut))
- if tx_gain < 89:
- adapt.set_txgain(tx_gain)
- else:
- break
- state = "measure"
except:
- logging.warning("Iteration {}: Report failed.".format(i))
- logging.warning(traceback.format_exc())
- state = "measure"
+ logging.error('Iteration {}: Report failed.'.format(i))
+ logging.error(traceback.format_exc())
+ i += 1
+ state = 'measure'
except Exception as e:
- logging.warning("Iteration {} failed.".format(i))
- logging.warning(traceback.format_exc())
+ logging.error('Iteration {} failed.'.format(i))
+ logging.error(traceback.format_exc())
# The MIT License (MIT)
#
diff --git a/dpd/src/Adapt.py b/dpd/src/Adapt.py
index 84b65f6..b17f059 100644
--- a/dpd/src/Adapt.py
+++ b/dpd/src/Adapt.py
@@ -137,7 +137,8 @@ class Adapt:
def get_predistorter(self):
"""Load the coefficients from the file in the format given in the README,
- return ("poly", [AM coef], [PM coef]) or ("lut", scalefactor, [LUT entries])"""
+ return ("poly", [AM coef], [PM coef]) or ("lut", scalefactor, [LUT entries])
+ """
f = open(self.coef_path, 'r')
lines = f.readlines()
predistorter_format = int(lines[0])
@@ -155,7 +156,7 @@ class Adapt:
else:
raise ValueError(
"Incorrect coef file format: too many coefficients in {}, should be {}, coefs are {}"
- .format(path, n_coefs, coefs))
+ .format(self.coef_path, n_coefs, coefs))
i += 1
f.close()
return ("poly", coefs_am_out, coefs_pm_out)
@@ -206,8 +207,7 @@ class Adapt:
self.send_receive("set memlesspoly coeffile {}".format(self.coef_path))
def dump(self, path=None):
- if path is None:
- dt = datetime.datetime.now().isoformat()
+ dt = datetime.datetime.now().isoformat()
path = logging_path + "/" + dt + "_adapt.pkl"
d = {
"txgain":self.get_txgain(),
diff --git a/dpd/src/Const.py b/dpd/src/Const.py
index 2504c1e..2f9e151 100644
--- a/dpd/src/Const.py
+++ b/dpd/src/Const.py
@@ -10,6 +10,8 @@ class Const:
self.sample_rate = sample_rate
self.n_meas = n_meas
+ self.tx_gain_max = 89
+
# Time domain
self.T_F = sample_rate / 2048000 * 196608 # Transmission frame duration
self.T_NULL = sample_rate / 2048000 * 2656 # Null symbol duration
diff --git a/dpd/src/Model_AM.py b/dpd/src/Model_AM.py
index 2704255..4b88e08 100644
--- a/dpd/src/Model_AM.py
+++ b/dpd/src/Model_AM.py
@@ -13,7 +13,6 @@ logging_path = os.path.dirname(logging.getLoggerClass().root.handlers[0].baseFil
import numpy as np
import matplotlib.pyplot as plt
-from sklearn import linear_model
def check_input_get_next_coefs(tx_dpd, rx_received):
diff --git a/dpd/src/Model_PM.py b/dpd/src/Model_PM.py
index eab5ec5..75fb055 100644
--- a/dpd/src/Model_PM.py
+++ b/dpd/src/Model_PM.py
@@ -13,7 +13,6 @@ logging_path = os.path.dirname(logging.getLoggerClass().root.handlers[0].baseFil
import numpy as np
import matplotlib.pyplot as plt
-from sklearn import linear_model
def check_input_get_next_coefs(tx_dpd, phase_diff):
diff --git a/dpd/src/Model_Poly.py b/dpd/src/Model_Poly.py
index 6a74bea..78bab91 100644
--- a/dpd/src/Model_Poly.py
+++ b/dpd/src/Model_Poly.py
@@ -62,7 +62,11 @@ class Poly:
return self.coefs_am, self.coefs_pm
def train(self, tx_abs, rx_abs, phase_diff):
- # type: (np.ndarray, np.ndarray, np.ndarray) -> (str, np.ndarray, np.ndarray)
+ """
+ :type tx_abs: np.ndarray
+ :type rx_abs: np.ndarray
+ :type phase_diff: np.ndarray
+ """
_check_input_get_next_coefs(tx_abs, rx_abs, phase_diff)
coefs_am_new = self.model_am.get_next_coefs(tx_abs, rx_abs, self.coefs_am)