From 81e297b48f0ed9abfb3e45b8bc79ef0e40a2458c Mon Sep 17 00:00:00 2001
From: Eric Kooistra <kooistra@astron.nl>
Date: Tue, 7 May 2024 15:08:39 +0200
Subject: [PATCH] Improve comments.

---
 applications/lofar2/model/pfb_os/dsp.py | 27 ++++++++++++++-----------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/applications/lofar2/model/pfb_os/dsp.py b/applications/lofar2/model/pfb_os/dsp.py
index f3722a2476..02f366ec1b 100644
--- a/applications/lofar2/model/pfb_os/dsp.py
+++ b/applications/lofar2/model/pfb_os/dsp.py
@@ -118,7 +118,7 @@ def impulse_at_zero_crossing(x):
 
 
 ###############################################################################
-# Window design
+# Windowed sinc filter design
 ###############################################################################
 
 def raised_cosine_response(Ntaps, Tsymbol, beta):
@@ -139,7 +139,7 @@ def raised_cosine_response(Ntaps, Tsymbol, beta):
     t = tIndices - tCenter
 
     # sinc term, can use array assignment because sinc(1 / 0) = 1
-    hRc = 1 / Tsymbol * np.sinc(t / Tsymbol)
+    hRc = 1 / Tsymbol * np.sinc(t / Tsymbol)  # np.sinc(x) = sin(pi x) / (pi x)
 
     # apply cos term, use for loop instead of array assignment, to detect divide by 0
     for tI in tIndices:
@@ -150,15 +150,18 @@ def raised_cosine_response(Ntaps, Tsymbol, beta):
 
 
 def square_root_raised_cosine_response(Ntaps, Tsymbol, beta):
-    """Generate a square root raised cosine (RC) FIR filter impulse response.
+    """Generate a square root raised cosine (SRRC) FIR filter impulse response.
+
+    Reference:
+    . [HARRIS section 4.3]
+    . https://en.wikipedia.org/wiki/Root-raised-cosine_filter
 
-    Reference: [HARRIS section 4.3]
     Input:
     . Ntaps : FIR filter length
     . Tsymbol: symbol period in number of samples per symbol
     . beta : Roll off factor in [0, 1.0]
     Return:
-    . hSrrc : impulse response of the square root raised cosine filter.
+    . hSrRc : impulse response of the square root raised cosine filter.
     """
     # time axis
     tIndices = np.arange(Ntaps)
@@ -166,21 +169,21 @@ def square_root_raised_cosine_response(Ntaps, Tsymbol, beta):
     t = tIndices - tCenter
 
     # numerator term, using array assignment
-    hSrrc = 1 / Tsymbol * (4 * beta * t / Tsymbol * np.cos(np.pi * (1 + beta) * t / Tsymbol) +
-                                                    np.sin(np.pi * (1 - beta) * t / Tsymbol))
+    hSrRc = 1 / Tsymbol * (np.cos(np.pi * (1 + beta) * t / Tsymbol) * 4 * beta * t / Tsymbol +
+                           np.sin(np.pi * (1 - beta) * t / Tsymbol))
 
     # apply denumerator term, use for loop instead of array assignment, to detect divide by 0
     for tI in tIndices:
         t = tI - tCenter
         if t == 0.0:
-            hSrrc[tI] = 1 / Tsymbol * (1 + beta * (4 / np.pi - 1))
+            hSrRc[tI] = 1 / Tsymbol * (1 + beta * (4 / np.pi - 1))
         elif np.abs(t) == Tsymbol / (4 * beta):
-            hSrrc[tI] = 1 / Tsymbol * beta / np.sqrt(2) * \
-                ((1 + 2 / np.pi) * np.sin(np.pi / (4 * beta)) + \
+            hSrRc[tI] = 1 / Tsymbol * beta / np.sqrt(2) * \
+                ((1 + 2 / np.pi) * np.sin(np.pi / (4 * beta)) +
                  (1 - 2 / np.pi) * np.cos(np.pi / (4 * beta)))
         else:
-            hSrrc[tI] /= (1 - (4 * beta * t / Tsymbol)**2) * (np.pi * t / Tsymbol)
-    return hSrrc
+            hSrRc[tI] /= (1 - (4 * beta * t / Tsymbol)**2) * (np.pi * t / Tsymbol)
+    return hSrRc
 
 
 ###############################################################################
-- 
GitLab