From 7579bd9c1bdc779555895cdcae46dc3361eb9d08 Mon Sep 17 00:00:00 2001 From: andreas128 Date: Fri, 22 Sep 2017 16:27:44 +0200 Subject: Add dump/load for Adapt --- dpd/src/Adapt.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'dpd/src') 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 -- cgit v1.2.3