aboutsummaryrefslogtreecommitdiffstats
path: root/dpd/src/Measure.py
diff options
context:
space:
mode:
authorandreas128 <Andreas>2017-08-29 11:54:51 +0200
committerandreas128 <Andreas>2017-09-01 17:05:08 +0200
commit5614e7eb9a8a5f8f0b66e0e349f7a30bd9b6f0f5 (patch)
treebc3eac1c74ed1e8a2bd1cc2fa6e5d7b0c7a0a60a /dpd/src/Measure.py
parent26042526ac96cda95d6b0a24b9d62f6979d6f99b (diff)
downloaddabmod-5614e7eb9a8a5f8f0b66e0e349f7a30bd9b6f0f5.tar.gz
dabmod-5614e7eb9a8a5f8f0b66e0e349f7a30bd9b6f0f5.tar.bz2
dabmod-5614e7eb9a8a5f8f0b66e0e349f7a30bd9b6f0f5.zip
Cleanup
Diffstat (limited to 'dpd/src/Measure.py')
-rw-r--r--dpd/src/Measure.py42
1 files changed, 25 insertions, 17 deletions
diff --git a/dpd/src/Measure.py b/dpd/src/Measure.py
index f48d28f..f6644bb 100644
--- a/dpd/src/Measure.py
+++ b/dpd/src/Measure.py
@@ -40,13 +40,7 @@ class Measure:
bufs.append(b)
return b''.join(bufs)
- def get_samples(self):
- """Connect to ODR-DabMod, retrieve TX and RX samples, load
- into numpy arrays, and return a tuple
- (tx_timestamp, tx_samples, rx_timestamp, rx_samples)
- where the timestamps are doubles, and the samples are numpy
- arrays of complex floats, both having the same size
- """
+ def receive_tcp(self):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('localhost', self.port))
@@ -78,24 +72,38 @@ class Measure:
else:
rxframe = np.array([], dtype=np.complex64)
- # Normalize received signal with sent signal
- rx_median = np.median(np.abs(rxframe))
- rxframe = rxframe / rx_median * np.median(np.abs(txframe))
-
if logging.getLogger().getEffectiveLevel() == logging.DEBUG:
logging.debug("txframe: min %f, max %f, median %f" %
- (np.min(np.abs(txframe)),
- np.max(np.abs(txframe)),
- np.median(np.abs(txframe))))
+ (np.min(np.abs(txframe)),
+ np.max(np.abs(txframe)),
+ np.median(np.abs(txframe))))
logging.debug("rxframe: min %f, max %f, median %f" %
- (np.min(np.abs(rxframe)),
- np.max(np.abs(rxframe)),
- np.median(np.abs(rxframe))))
+ (np.min(np.abs(rxframe)),
+ np.max(np.abs(rxframe)),
+ np.median(np.abs(rxframe))))
logging.debug("Disconnecting")
s.close()
+ return txframe, tx_ts, rxframe, rx_ts
+
+
+ def get_samples(self):
+ """Connect to ODR-DabMod, retrieve TX and RX samples, load
+ into numpy arrays, and return a tuple
+ (tx_timestamp, tx_samples, rx_timestamp, rx_samples)
+ where the timestamps are doubles, and the samples are numpy
+ arrays of complex floats, both having the same size
+ """
+
+ txframe, tx_ts, rxframe, rx_ts = self.receive_tcp()
+ txframe_end = txframe[-100:]
+
+ # Normalize received signal with sent signal
+ rx_median = np.median(np.abs(rxframe))
+ rxframe = rxframe / rx_median * np.median(np.abs(txframe))
+
du = DU.Dab_Util(self.samplerate)
txframe_aligned, rxframe_aligned = du.subsample_align(txframe, rxframe)