From a8daf080dd1301a8bc4d1ea02a058a18657046a1 Mon Sep 17 00:00:00 2001
From: Tammo Jan Dijkema <dijkema@astron.nl>
Date: Mon, 12 Oct 2015 08:23:28 +0000
Subject: [PATCH] Task #8617: BBS now checks that channels are evenly spaced

---
 CEP/Calibration/BBSKernel/src/MeasurementAIPS.cc | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/CEP/Calibration/BBSKernel/src/MeasurementAIPS.cc b/CEP/Calibration/BBSKernel/src/MeasurementAIPS.cc
index 8622e859e0c..65109874380 100644
--- a/CEP/Calibration/BBSKernel/src/MeasurementAIPS.cc
+++ b/CEP/Calibration/BBSKernel/src/MeasurementAIPS.cc
@@ -719,9 +719,19 @@ void MeasurementAIPS::initDimensions()
 
     ASSERT(frequency.nelements() == nFreq);
     ASSERT(width.nelements() == nFreq);
-    // TODO: Technically, checking for equal channel widths is not enough,
-    // because there could still be gaps between channels even though the
-    // widths are all equal (this is not prevented by the MS 2.0 standard).
+
+    // Check that channels have no gaps and are evenly spaced
+    // (this is not prevented by the MS 2.0 standard).
+    if (frequency.nelements()>1) {
+      Vector<Double> upFreq = frequency(Slicer(IPosition(1,1),
+                                               IPosition(1,frequency.nelements()-1)));
+      Vector<Double> lowFreq = frequency(Slicer(IPosition(1,0),
+                                                IPosition(1,frequency.nelements()-1)));
+      Double freqstep0=upFreq(0)-lowFreq(0);
+      ASSERTSTR(allEQ(upFreq-lowFreq,freqstep0),
+                "Channels are not evenly spaced. This is not supported.");
+    }
+
     ASSERTSTR(allEQ(width, width(0)),
         "Channels width is not the same for all channels. This is not supported"
         " yet.");
-- 
GitLab