aboutsummaryrefslogtreecommitdiffstats
path: root/amplitude_ramp.py
diff options
context:
space:
mode:
authorandreas128 <Andreas>2016-11-28 15:11:54 +0100
committerandreas128 <Andreas>2016-11-28 15:11:54 +0100
commit9dea632708cabd666db3f537c32cb175375725d6 (patch)
treed9c0bb87e9d13b16d362ffce129778b2cb8d4b48 /amplitude_ramp.py
parentffae3a0ce36edb00fe1e9b99b63fb155933f9b52 (diff)
downloadODR-StaticPrecorrection-9dea632708cabd666db3f537c32cb175375725d6.tar.gz
ODR-StaticPrecorrection-9dea632708cabd666db3f537c32cb175375725d6.tar.bz2
ODR-StaticPrecorrection-9dea632708cabd666db3f537c32cb175375725d6.zip
Make more robust to failed measurements
Diffstat (limited to 'amplitude_ramp.py')
-rwxr-xr-xamplitude_ramp.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/amplitude_ramp.py b/amplitude_ramp.py
index c757ef8..7672cda 100755
--- a/amplitude_ramp.py
+++ b/amplitude_ramp.py
@@ -30,6 +30,7 @@ import time
import socket
import struct
import threading
+import numpy as np
from Queue import Queue
from dual_tone import dual_tone # our flowgraph!
import tcp_async
@@ -109,17 +110,20 @@ class RampGenerator(threading.Thread):
# Receive and ignore three floats on the socket
sock.recv(12)
+ measurements_new = []
for measurement_ix in range(self.num_meas):
# Receive three floats on the socket
mag_gen, phase_diff, mag_feedback = struct.unpack(
"fff",
sock.recv(12))
+ phase_diff = phase_diff % 720
+
mag_gen_sum += mag_gen
phase_diff_sum += phase_diff
mag_feedback_sum += mag_feedback
- measurements.append((ampl, mag_gen, mag_feedback, phase_diff))
+ measurements_new.append((ampl, mag_gen, mag_feedback, phase_diff))
mag_gen_avg = mag_gen_sum / self.num_meas
mag_feedback_avg = mag_feedback_sum / self.num_meas
@@ -128,6 +132,7 @@ class RampGenerator(threading.Thread):
#Check asynchronous uhd messages for error
has_msg = self.tcpa.has_msg()
if not has_msg:
+ measurements.append([np.mean(meas) for meas in zip(*measurements_new)])
measurement_correct = True
print("Ampl: {} Out: {:10} In: {:10} phase_diff: {:10}".format(
ampl, mag_gen_avg, mag_feedback_avg, phase_diff_avg))