From a700c0772df4fe120beee5b48aa1bf6910c4d54e Mon Sep 17 00:00:00 2001
From: John Romein <romein@astron.nl>
Date: Thu, 9 Mar 2006 15:07:47 +0000
Subject: [PATCH] BugID: 225 Test input with base frequency of 49975296 Hz,
 which is in LOFAR frequency range.

---
 .../CS1_BGLProc/test/tWH_BGL_Processing.cc    | 24 ++++++++--------
 .../CEP/CS1/CS1_Interface/src/DH_FineDelay.cc |  4 +--
 Appl/CEP/CS1/CS1_Interface/src/DH_Subband.cc  |  4 +--
 .../CS1/CS1_Interface/src/DH_Visibilities.cc  | 28 +++++++++++++++----
 4 files changed, 39 insertions(+), 21 deletions(-)

diff --git a/Appl/CEP/CS1/CS1_BGLProc/test/tWH_BGL_Processing.cc b/Appl/CEP/CS1/CS1_BGLProc/test/tWH_BGL_Processing.cc
index cd12215c905..b7f0909ad19 100644
--- a/Appl/CEP/CS1/CS1_BGLProc/test/tWH_BGL_Processing.cc
+++ b/Appl/CEP/CS1/CS1_BGLProc/test/tWH_BGL_Processing.cc
@@ -52,7 +52,7 @@ AH_BGL_Processing::~AH_BGL_Processing()
 
 void AH_BGL_Processing::define(const KeyValueMap &/*kvm*/)
 {
-  const double baseFrequency =  99950592.0; /* 499th Nyquist zone */
+  const double baseFrequency =  49975296.0; /* 250th Nyquist zone */
 
   ACC::APS::ParameterSet myPset("CS1.cfg");
 
@@ -71,18 +71,10 @@ void AH_BGL_Processing::define(const KeyValueMap &/*kvm*/)
 
 void AH_BGL_Processing::init()
 {
-  double     signalFrequency = 100007824.0; /* channel 73 */
-  const char *env	     = getenv("SIGNAL_FREQUENCY");
-
-  if (env != 0) {
-    signalFrequency = atof(env);
-    std::cerr << "setting signal frequency to " << env << '\n';
-  }
-
   itsWH->basePreprocess();
 
   // Fill inDHs here
-  itsWH->get_DH_Subband()->setTestPattern(signalFrequency);
+  //itsWH->get_DH_Subband()->setTestPattern(signalFrequency);
   itsWH->get_DH_RFI_Mitigation()->setTestPattern();
 
 #if defined DELAY_COMPENSATION
@@ -92,8 +84,18 @@ void AH_BGL_Processing::init()
 
 void AH_BGL_Processing::run(int steps)
 {
+  double     signalFrequency = 50032528.0; /* channel 73 */
+  const char *env	     = getenv("SIGNAL_FREQUENCY");
+
+  if (env != 0) {
+    signalFrequency = atof(env);
+    std::cerr << "setting signal frequency to " << env << '\n';
+  }
+
   for (int i = 0; i < steps; i ++) {
+    itsWH->get_DH_Subband()->setTestPattern(signalFrequency + i);
     itsWH->baseProcess();
+    itsWH->get_DH_Visibilities()->checkCorrelatorTestPattern();
   }
 }
 
@@ -105,7 +107,7 @@ void AH_BGL_Processing::dump() const
 void AH_BGL_Processing::postrun()
 {
   // check result here
-  itsWH->get_DH_Visibilities()->checkCorrelatorTestPattern();
+  //itsWH->get_DH_Visibilities()->checkCorrelatorTestPattern();
 }
 
 void AH_BGL_Processing::undefine()
diff --git a/Appl/CEP/CS1/CS1_Interface/src/DH_FineDelay.cc b/Appl/CEP/CS1/CS1_Interface/src/DH_FineDelay.cc
index 5d0d1da0094..dd32f80cdcc 100644
--- a/Appl/CEP/CS1/CS1_Interface/src/DH_FineDelay.cc
+++ b/Appl/CEP/CS1/CS1_Interface/src/DH_FineDelay.cc
@@ -65,8 +65,8 @@ void DH_FineDelay::setTestPattern()
   memset(itsDelays, 0, sizeof(AllDelaysType));
 
 #if NR_STATIONS >= 2
-  (*itsDelays)[1].delayAtBegin  = 2.499804413e-9;
-  (*itsDelays)[1].delayAfterEnd = 2.499804413e-9;
+  (*itsDelays)[1].delayAtBegin  = 4.996749315e-9;
+  (*itsDelays)[1].delayAfterEnd = 4.996749315e-9;
 #endif
 }
 
diff --git a/Appl/CEP/CS1/CS1_Interface/src/DH_Subband.cc b/Appl/CEP/CS1/CS1_Interface/src/DH_Subband.cc
index 08d775faed6..b6f8caed128 100644
--- a/Appl/CEP/CS1/CS1_Interface/src/DH_Subband.cc
+++ b/Appl/CEP/CS1/CS1_Interface/src/DH_Subband.cc
@@ -98,7 +98,7 @@ void DH_Subband::setTestPattern(double Hz)
 
 #if 1
   const double c = 299792458;
-  const double antennaDistance = 2.997690041 * .25; // meter
+  const double antennaDistance = 5.99195103633380268132 * .25; // meter
 
   double labda = c / Hz;
   double phaseShift = 2 * M_PI * antennaDistance / labda;
@@ -126,7 +126,7 @@ void DH_Subband::setTestPattern(double Hz)
 
   memset(itsFlags, 0, sizeof *itsFlags);
 
-#if NR_INPUT_SAMPLES >= 17000
+#if 0 && NR_INPUT_SAMPLES >= 17000
   (*itsFlags)[4][14000] = true;
   (*itsFlags)[5][17000] = true;
 #endif
diff --git a/Appl/CEP/CS1/CS1_Interface/src/DH_Visibilities.cc b/Appl/CEP/CS1/CS1_Interface/src/DH_Visibilities.cc
index b0d9507e654..eada05be13e 100644
--- a/Appl/CEP/CS1/CS1_Interface/src/DH_Visibilities.cc
+++ b/Appl/CEP/CS1/CS1_Interface/src/DH_Visibilities.cc
@@ -79,31 +79,47 @@ void DH_Visibilities::fillDataPointers()
 
 void DH_Visibilities::checkCorrelatorTestPattern()
 {
+#if 0
+  float sum = 0.0;
+
+  for (int ch = 0; ch < NR_SUBBAND_CHANNELS; ch ++)
+    sum += real((*itsVisibilities)[0][ch][0][0]);
+
+  std::cout << sum << '\n';
+#endif
+  //std::cout << (*itsVisibilities)[0][73][0][0] << ' ' << (*itsVisibilities)[0][74][0][0] << '\n';
+#if 1
   static const int channels[] = { 0, 73, 255 };
 
   for (int stat1 = 0; stat1 < std::min(NR_STATIONS, 8); stat1 ++) {
     for (int stat2 = stat1; stat2 < std::min(NR_STATIONS, 8); stat2 ++) {
-      std::cerr << "S(" << stat1 << ") * ~S(" << stat2 << ") :\n";
+      std::cout << "S(" << stat1 << ") * ~S(" << stat2 << ") :\n";
       int bl = baseline(stat1, stat2);
       for (int pol1 = 0; pol1 < NR_POLARIZATIONS; pol1 ++) {
 	for (int pol2 = 0; pol2 < NR_POLARIZATIONS; pol2 ++) {
-	  std::cerr << " " << (char) ('x' + pol1) << (char) ('x' + pol2) << ':';
+	  std::cout << " " << (char) ('x' + pol1) << (char) ('x' + pol2) << ':';
 	  for (int chidx = 0; chidx < sizeof(channels) / sizeof(int); chidx ++) {
 	    int ch = channels[chidx];
 	    if (ch < NR_SUBBAND_CHANNELS) {
-	      std::cerr << ' ' << (*itsVisibilities)[bl][ch][pol1][pol2] << '/' << (*itsNrValidSamplesCounted)[bl][ch];
+	      std::cout << ' ' << (*itsVisibilities)[bl][ch][pol1][pol2] << '/' << (*itsNrValidSamplesCounted)[bl][ch];
 	    }
 	  }
-	  std::cerr << '\n';
+	  std::cout << '\n';
 	}
       }
     }
   }
 
-  std::cerr << "newgraph yaxis log newcurve linetype solid marktype x pts\n";
+  std::cout << "newgraph yaxis newcurve linetype solid marktype none pts\n";
+  float max = 0.0;
+
+  for (int ch = 0; ch < NR_SUBBAND_CHANNELS; ch ++)
+    if (real((*itsVisibilities)[0][ch][0][0]) > max)
+      max = real((*itsVisibilities)[0][ch][0][0]);
 
   for (int ch = 0; ch < NR_SUBBAND_CHANNELS; ch ++)
-    std::cerr << ch << ' ' << real((*itsVisibilities)[0][ch][0][0]) << '\n';
+    std::cout << ch << ' ' << (10 * std::log10(real((*itsVisibilities)[0][ch][0][0]) / max)) << '\n';
+#endif
 }
 
 void DH_Visibilities::setStorageTestPattern(int factor)
-- 
GitLab