aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNao Pross <np@0hm.ch>2021-12-16 14:16:51 +0100
committerNao Pross <np@0hm.ch>2021-12-16 14:16:51 +0100
commit18f2ebc5ff3eb2d4edfb0cc4bd2cf930c30af6e5 (patch)
tree5ed053edf74002a8a01eeb51913eef02c5bc6f64
parentConclude non modulated access codes issue (diff)
downloadFading-18f2ebc5ff3eb2d4edfb0cc4bd2cf930c30af6e5.tar.gz
Fading-18f2ebc5ff3eb2d4edfb0cc4bd2cf930c30af6e5.zip
Fix bug in phasecorrection.py
-rw-r--r--doc/thesis/chapters/implementation.tex6
-rw-r--r--src/gr-fadingui/python/phasecorrection.py6
2 files changed, 10 insertions, 2 deletions
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}
diff --git a/src/gr-fadingui/python/phasecorrection.py b/src/gr-fadingui/python/phasecorrection.py
index 9acf563..e30824d 100644
--- a/src/gr-fadingui/python/phasecorrection.py
+++ b/src/gr-fadingui/python/phasecorrection.py
@@ -65,7 +65,11 @@ class phasecorrection(gr.sync_block):
ephase = pmt.to_python(end.value)
# compute frequency offset between start and end
- phasediff = (ephase - sphase) % (2 * np.pi)
+ phasediff = (ephase - sphase) # % (2 * np.pi)
+ if phasediff > np.pi:
+ phasediff -= np.pi
+ elif phasediff < -np.pi:
+ phasediff += np.pi
freq = phasediff / nsamples
if freq < 1e-3: