aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2018-12-12 10:56:33 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2018-12-12 10:56:33 +0100
commitf409d342c5a314f4aa35382bbdd8daa3882172d1 (patch)
treef50821c8e53652030dc6f3baba19b8dc2c320e3d
parent47242ec7ccbfc60fd14276e102abe119f1766d95 (diff)
downloaddabmod-f409d342c5a314f4aa35382bbdd8daa3882172d1.tar.gz
dabmod-f409d342c5a314f4aa35382bbdd8daa3882172d1.tar.bz2
dabmod-f409d342c5a314f4aa35382bbdd8daa3882172d1.zip
Improve DPD calibration
-rw-r--r--python/dpd/Measure.py20
-rw-r--r--python/dpd/RX_Agc.py16
-rwxr-xr-xpython/dpdce.py3
3 files changed, 34 insertions, 5 deletions
diff --git a/python/dpd/Measure.py b/python/dpd/Measure.py
index eb3c199..e5a72c7 100644
--- a/python/dpd/Measure.py
+++ b/python/dpd/Measure.py
@@ -90,6 +90,26 @@ class Measure:
return txframe, tx_ts, rxframe, rx_ts
+ def get_samples_unaligned(self, short=False):
+ """Connect to ODR-DabMod, retrieve TX and RX samples, load
+ into numpy arrays, and return a tuple
+ (txframe, tx_ts, rxframe, rx_ts, rx_median, tx_median)
+ """
+
+ n_samps = int(self.num_samples_to_request / 4) if short else self.num_samples_to_request
+ txframe, tx_ts, rxframe, rx_ts = self.receive_tcp(n_samps)
+
+ # Normalize received signal with sent signal
+ rx_median = np.median(np.abs(rxframe))
+ tx_median = np.median(np.abs(txframe))
+ rxframe = rxframe / rx_median * tx_median
+
+
+ logging.info(
+ "Measurement done, tx %d %s, rx %d %s" %
+ (len(txframe), txframe.dtype, len(rxframe), rxframe.dtype))
+
+ return txframe, tx_ts, rxframe, rx_ts, rx_median, tx_median
def get_samples(self, short=False):
"""Connect to ODR-DabMod, retrieve TX and RX samples, load
diff --git a/python/dpd/RX_Agc.py b/python/dpd/RX_Agc.py
index bca9643..4700e68 100644
--- a/python/dpd/RX_Agc.py
+++ b/python/dpd/RX_Agc.py
@@ -45,10 +45,15 @@ class Agc:
self.peak_to_median = 1./c.RAGC_rx_median_target
def run(self) -> Tuple[bool, str]:
- self.adapt.set_rxgain(self.rxgain)
+ try:
+ self.adapt.set_rxgain(self.rxgain)
+ except ValueError as e:
+ return (False, "Setting RX gain to {} failed: {}".format(self.rxgain, e))
+ time.sleep(0.5)
+
# Measure
- txframe_aligned, tx_ts, rxframe_aligned, rx_ts, rx_median, tx_median = self.measure.get_samples(short=True)
+ txframe, tx_ts, rxframe, rx_ts, rx_median, tx_median = self.measure.get_samples_unaligned(short=False)
# Estimate Maximum
rx_peak = self.peak_to_median * rx_median
@@ -70,9 +75,12 @@ class Agc:
logging.warning(w)
return (False, "\n".join([measurements, w]))
else:
- self.adapt.set_rxgain(self.rxgain)
+ try:
+ self.adapt.set_rxgain(self.rxgain)
+ except ValueError as e:
+ return (False, "Setting RX gain to {} failed: {}".format(self.rxgain, e))
time.sleep(0.5)
- return (True, measurements)
+ return (True, measurements)
def plot_estimates(self):
"""Plots the estimate of for Max, Median, Mean for different
diff --git a/python/dpdce.py b/python/dpdce.py
index 03bc907..1ceac46 100755
--- a/python/dpdce.py
+++ b/python/dpdce.py
@@ -163,10 +163,11 @@ def engine_worker():
N_ITER = 5
for i in range(N_ITER):
agc_success, agc_summary = agc.run()
- summary = ["calibration run {}:".format(i)] + agc_summary.split("\n")
+ summary += ["calibration run {}:".format(i)] + agc_summary.split("\n")
with lock:
results['stateprogress'] = int((i + 1) * 100/N_ITER)
+ results['summary'] = ["Calibration ongoing:"] + summary
if not agc_success:
break