summaryrefslogtreecommitdiffstats
path: root/dpd/src
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 /dpd/src
parent25cf9065bdd0a7f7630772bb63e0aea32a0903ff (diff)
downloaddabmod-7579bd9c1bdc779555895cdcae46dc3361eb9d08.tar.gz
dabmod-7579bd9c1bdc779555895cdcae46dc3361eb9d08.tar.bz2
dabmod-7579bd9c1bdc779555895cdcae46dc3361eb9d08.zip
Add dump/load for Adapt
Diffstat (limited to 'dpd/src')
-rw-r--r--dpd/src/Adapt.py30
1 files changed, 30 insertions, 0 deletions
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