summaryrefslogtreecommitdiffstats
path: root/dpd
diff options
context:
space:
mode:
Diffstat (limited to 'dpd')
-rw-r--r--dpd/dpd.ini3
-rwxr-xr-xdpd/main.py25
-rw-r--r--dpd/poly.coef11
-rw-r--r--dpd/poly_am.coef6
-rw-r--r--dpd/poly_pm.coef6
-rw-r--r--dpd/src/Adapt.py42
6 files changed, 42 insertions, 51 deletions
diff --git a/dpd/dpd.ini b/dpd/dpd.ini
index 54af9ce..1bc51de 100644
--- a/dpd/dpd.ini
+++ b/dpd/dpd.ini
@@ -22,8 +22,7 @@ enabled=1
[poly]
enabled=1
-polycoeffileam=dpd/poly_am.coef
-polycoeffilepm=dpd/poly_pm.coef
+polycoeffile=dpd/poly.coef
# How many threads to use for the predistorter.
# If not set, detect automatically.
diff --git a/dpd/main.py b/dpd/main.py
index 7e1041b..ea570d3 100755
--- a/dpd/main.py
+++ b/dpd/main.py
@@ -38,12 +38,9 @@ parser.add_argument('--rc-port', default='9400',
parser.add_argument('--samplerate', default='8192000',
help='Sample rate',
required=False)
-parser.add_argument('--coefs_am', default='poly_am.coef',
- help='File with DPD Amplitude coefficients, which will be read by ODR-DabMod',
+parser.add_argument('--coefs', default='poly.coef',
+ help='File with DPD coefficients, which will be read by ODR-DabMod',
required=False)
-parser.add_argument('--coefs_pm', default='poly_am.coef',
- help='File with DPD Phase coefficients, which will be read by ODR-DabMod',
- required=False)
parser.add_argument('--samps', default='10240',
help='Number of samples to request from ODR-DabMod',
required=False)
@@ -52,37 +49,33 @@ cli_args = parser.parse_args()
port = int(cli_args.port)
port_rc = int(cli_args.rc_port)
-coef_am_path = cli_args.coefs_am
-coef_pm_path = cli_args.coefs_pm
+coef_path = cli_args.coefs
num_req = int(cli_args.samps)
samplerate = int(cli_args.samplerate)
meas = Measure.Measure(samplerate, port, num_req)
-adapt = Adapt.Adapt(port_rc, coef_am_path, coef_pm_path)
-coefs_am = adapt.get_coefs_am()
-coefs_pm = adapt.get_coefs_pm()
+adapt = Adapt.Adapt(port_rc, coef_path)
+coefs_am, coefs_pm = adapt.get_coefs()
#model = Model.Model(coefs)
-model = Model.Model([2.2, 0, 0, 0, 0], [0, 0, 0, 0, 0])
+model = Model.Model([1, 0, 0, 0, 0], [0, 0, 0, 0, 0])
adapt.set_txgain(70)
adapt.set_rxgain(30)
tx_gain = adapt.get_txgain()
rx_gain = adapt.get_rxgain()
-dpd_coefs_am = adapt.get_coefs_am()
-dpd_coefs_pm = adapt.get_coefs_pm()
+dpd_coefs_am, dpd_coefs_pm = adapt.get_coefs()
logging.info(
"TX gain {}, RX gain {}, dpd_coefs_am {}, dpd_coefs_pm {}".format(
tx_gain, rx_gain, dpd_coefs_am, dpd_coefs_pm
)
)
-for i in range(500):
+for i in range(1):
txframe_aligned, tx_ts, rxframe_aligned, rx_ts = meas.get_samples()
logging.debug("tx_ts {}, rx_ts {}".format(tx_ts, rx_ts))
coefs_am, coefs_pm = model.get_next_coefs(txframe_aligned, rxframe_aligned)
- adapt.set_coefs_am(coefs_am)
- adapt.set_coefs_pm(coefs_pm)
+ adapt.set_coefs(coefs_am, coefs_pm)
# The MIT License (MIT)
#
diff --git a/dpd/poly.coef b/dpd/poly.coef
new file mode 100644
index 0000000..d1e9967
--- /dev/null
+++ b/dpd/poly.coef
@@ -0,0 +1,11 @@
+5
+0.9999999999999999
+0.013989416705029524
+-0.17875129566117912
+1.189037605717911
+-1.7871717414839607
+-0.005118865951385803
+0.06831365867284998
+-0.32196849299538066
+0.6598790120324084
+-0.5099783166759195
diff --git a/dpd/poly_am.coef b/dpd/poly_am.coef
deleted file mode 100644
index ff09e5a..0000000
--- a/dpd/poly_am.coef
+++ /dev/null
@@ -1,6 +0,0 @@
-5
-2.2
-1.16110192544
--13.7895532562
-55.107515965
--53.8583673922
diff --git a/dpd/poly_pm.coef b/dpd/poly_pm.coef
deleted file mode 100644
index ae91b12..0000000
--- a/dpd/poly_pm.coef
+++ /dev/null
@@ -1,6 +0,0 @@
-5
-0.141477421551
--0.654864288614
-1.00568534673
--0.588530075442
-0.0935391293974
diff --git a/dpd/src/Adapt.py b/dpd/src/Adapt.py
index cc4c8c7..2fb596f 100644
--- a/dpd/src/Adapt.py
+++ b/dpd/src/Adapt.py
@@ -23,11 +23,10 @@ class Adapt:
ZMQ remote control.
"""
- def __init__(self, port, coef_am_path, coef_pm_path):
+ def __init__(self, port, coef_path):
logging.info("Instantiate Adapt object")
self.port = port
- self.coef_am_path = coef_am_path
- self.coef_pm_path = coef_pm_path
+ self.coef_path = coef_path
self.host = "localhost"
self._context = zmq.Context()
@@ -112,8 +111,10 @@ class Adapt:
return self.send_receive("get uhd rxgain")
def _read_coef_file(self, path):
- """Load the coefficients from the file in the format given in the README"""
- coefs_out = []
+ """Load the coefficients from the file in the format given in the README,
+ return ([AM coef], [PM coef])"""
+ coefs_am_out = []
+ coefs_pm_out = []
f = open(path, 'r')
lines = f.readlines()
n_coefs = int(lines[0])
@@ -121,35 +122,34 @@ class Adapt:
i = 0
for c in coefs:
if i < n_coefs:
- coefs_out.append(c)
+ coefs_am_out.append(c)
+ elif i < 2*n_coefs:
+ coefs_pm_out.append(c)
else:
raise ValueError(
"Incorrect coef file format: too many coefficients in {}, should be {}, coefs are {}"
.format(path, n_coefs, coefs))
i += 1
f.close()
- return coefs_out
+ return (coefs_am_out, coefs_pm_out)
- def get_coefs_am(self):
- return self._read_coef_file(self.coef_am_path)
+ def get_coefs(self):
+ return self._read_coef_file(self.coef_path)
- def get_coefs_pm(self):
- return self._read_coef_file(self.coef_pm_path)
+ def _write_coef_file(self, coefs_am, coefs_pm, path):
+ assert(len(coefs_am) == len(coefs_pm))
- def _write_coef_file(self, coefs, path):
f = open(path, 'w')
- f.write("{}\n".format(len(coefs)))
- for coef in coefs:
+ f.write("{}\n".format(len(coefs_am)))
+ for coef in coefs_am:
+ f.write("{}\n".format(coef))
+ for coef in coefs_pm:
f.write("{}\n".format(coef))
f.close()
- def set_coefs_am(self, coefs):
- self._write_coef_file(coefs, self.coef_am_path)
- self.send_receive("set memlesspoly coeffile_am {}".format(self.coef_am_path))
-
- def set_coefs_pm(self, coefs):
- self._write_coef_file(coefs, self.coef_pm_path)
- self.send_receive("set memlesspoly coeffile_pm {}".format(self.coef_pm_path))
+ def set_coefs(self, coefs_am, coefs_pm):
+ self._write_coef_file(coefs_am, coefs_pm, self.coef_path)
+ self.send_receive("set memlesspoly coeffile {}".format(self.coef_path))
# The MIT License (MIT)
#