From 18f2ebc5ff3eb2d4edfb0cc4bd2cf930c30af6e5 Mon Sep 17 00:00:00 2001
From: Nao Pross <np@0hm.ch>
Date: Thu, 16 Dec 2021 14:16:51 +0100
Subject: Fix bug in phasecorrection.py

---
 doc/thesis/chapters/implementation.tex | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

(limited to 'doc/thesis/chapters/implementation.tex')

diff --git a/doc/thesis/chapters/implementation.tex b/doc/thesis/chapters/implementation.tex
index 119fa87..64b4c33 100644
--- a/doc/thesis/chapters/implementation.tex
+++ b/doc/thesis/chapters/implementation.tex
@@ -255,8 +255,12 @@ def block_phase(self, start, end):
 	sphase = pmt.to_python(start.value)
 	ephase = pmt.to_python(end.value)
 	# compute frequency offset between start and end
-	phasediff = (ephase - sphase) % (2 * np.pi)
+	phasediff = (ephase - sphase)
 	freq = phasediff / nsamples
+	if phsediff > np.pi:
+		phasediff -= np.pi
+	elif phasediff < -np.pi:
+		phasediff += np.pi
 	# compute chunk values
 	return sphase * np.ones(nsamples) + freq * np.arange(0, nsamples)
 \end{lstlisting}
-- 
cgit v1.2.1

