From e3c0da82c9c207b019dd1e2bb33aa930e7039fae Mon Sep 17 00:00:00 2001
From: Eric Kooistra <kooistra@astron.nl>
Date: Mon, 19 Aug 2024 08:23:45 +0200
Subject: [PATCH] Clarify SNR.

---
 .../lofar2/model/pfb_bunton_annotated/reconstruct.m  | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/applications/lofar2/model/pfb_bunton_annotated/reconstruct.m b/applications/lofar2/model/pfb_bunton_annotated/reconstruct.m
index c4f1200dcd..2ee768eb6d 100644
--- a/applications/lofar2/model/pfb_bunton_annotated/reconstruct.m
+++ b/applications/lofar2/model/pfb_bunton_annotated/reconstruct.m
@@ -25,7 +25,7 @@ close all
 rng('default')
 
 ImpulseResponse = 0;  % set to 1 to calculate correction filter
-Correct = 1;          % set to 1 to allow correction filter to be applied
+Correct = 0;          % set to 1 to allow correction filter to be applied
 
 % cl is the prototype lowpass filter
 Ncoefs = length(cl);  % = 2304
@@ -112,9 +112,13 @@ diff = outData - inData(1:length(outData));
 % . rng('default'); reconstruct, with Correct = 1: SNR = 62.24 dB
 % Note:
 % . With the impulse data input the SNR = 304.46 dB, so perfect.
-% . For other input data there is still some error, due to the limited stopband
-%   attenuation of the prototype LPF (can be seen using DEVS = 0.003 instead of
-%   0.0003 in Gen_filter12).
+% . For other input data there is still some error when Correct = 1, due to
+%   the limited stopband attenuation of the prototype LPF (can be seen using
+%   DEVS = 0.003 instead of 0.0003 in Gen_filter12).
+% . When Correct = 0 then the error is caused largely by the passband ripple
+%   DEVP = 0.02 and W0 = 1 / 15.3 of the prototype LPF, and db(0.02) = -34 dB.
+%   With DEVP = 0.005 and W0 = 1 / 15.05 then db(0.005) = -46.0 dB and SNR =
+%   38.8 dB, so increased.
 SNR = 10 * log10(sum(abs(inData(10000:70000) .^ 2)) / sum(abs(diff(10000:70000) .^ 2)));
 sprintf('SNR = %6.2f [dB]', SNR)
 
-- 
GitLab