diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-01-09 12:21:21 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-01-09 12:21:21 +0100 |
commit | 75ba4f064a65ebad77d130f160b9469418e49c9f (patch) | |
tree | 85ab6398ae59159eab0acb1501d206f322aa9449 /python/dpd | |
parent | 8dd12110d63f89eab62097b391fb909478db3d94 (diff) | |
download | dabmod-75ba4f064a65ebad77d130f160b9469418e49c9f.tar.gz dabmod-75ba4f064a65ebad77d130f160b9469418e49c9f.tar.bz2 dabmod-75ba4f064a65ebad77d130f160b9469418e49c9f.zip |
GUI: Add ability to restore previous DPD settings
Diffstat (limited to 'python/dpd')
-rw-r--r-- | python/dpd/Adapt.py | 15 | ||||
-rw-r--r-- | python/dpd/Model_Poly.py | 5 |
2 files changed, 15 insertions, 5 deletions
diff --git a/python/dpd/Adapt.py b/python/dpd/Adapt.py index 9c2c2b6..8023a53 100644 --- a/python/dpd/Adapt.py +++ b/python/dpd/Adapt.py @@ -152,7 +152,7 @@ class Adapt: _write_lut_file(scalefactor, lut, self._coef_path) else: raise ValueError("Unknown predistorter '{}'".format(dpddata[0])) - self._mod_rc.set_param_value("memlesspoly", "coefffile", self._coef_path) + self._mod_rc.set_param_value("memlesspoly", "coeffile", self._coef_path) def dump(self, path: str) -> None: """Backup current settings to a file""" @@ -161,26 +161,31 @@ class Adapt: "txgain": self.get_txgain(), "rxgain": self.get_rxgain(), "digital_gain": self.get_digital_gain(), - "predistorter": self.get_predistorter() + "dpddata": self.get_predistorter() } with open(path, "wb") as f: pickle.dump(d, f) - def load(self, path: str) -> None: + def restore(self, path: str): """Restore settings from a file""" with open(path, "rb") as f: d = pickle.load(f) self.set_txgain(0) + + # If any of the following fail, we will be running + # with the safe value of txgain=0 self.set_digital_gain(d["digital_gain"]) self.set_rxgain(d["rxgain"]) - self.set_predistorter(d["predistorter"]) + self.set_predistorter(d["dpddata"]) self.set_txgain(d["txgain"]) + return d + # The MIT License (MIT) # -# Copyright (c) 2018 Matthias P. Braendli +# Copyright (c) 2019 Matthias P. Braendli # Copyright (c) 2017 Andreas Steger # # Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/python/dpd/Model_Poly.py b/python/dpd/Model_Poly.py index 7ab6aa1..ef3fed3 100644 --- a/python/dpd/Model_Poly.py +++ b/python/dpd/Model_Poly.py @@ -125,6 +125,11 @@ class Poly: def get_dpd_data(self): return "poly", self.coefs_am, self.coefs_pm + def set_dpd_data(self, dpddata): + if dpddata[0] != "poly" or len(dpddata) != 3: + raise ValueError("dpddata is not of 'poly' format") + _, self.coefs_am, self.coefs_pm = dpddata + def _am_calc_line(self, coefs, min_amp, max_amp): rx_range = np.linspace(min_amp, max_amp) tx_est = np.sum(self._am_poly(rx_range) * coefs, axis=1) |