From 27d1b5ff174964efcca8f5472e789afaaba5e002 Mon Sep 17 00:00:00 2001
From: Ger van Diepen <diepen@astron.nl>
Date: Thu, 15 Mar 2012 15:26:53 +0000
Subject: [PATCH] Task #2699 Fixed problem if convfunc > image

---
 CEP/Imager/LofarFT/src/LofarConvolutionFunction.cc | 10 +++++++---
 CEP/Imager/LofarFT/src/awimager.cc                 |  1 -
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/CEP/Imager/LofarFT/src/LofarConvolutionFunction.cc b/CEP/Imager/LofarFT/src/LofarConvolutionFunction.cc
index 663be1f1ddc..ce0d49a41cb 100644
--- a/CEP/Imager/LofarFT/src/LofarConvolutionFunction.cc
+++ b/CEP/Imager/LofarFT/src/LofarConvolutionFunction.cc
@@ -1209,9 +1209,13 @@ namespace LOFAR
               istart += 0.5; //If number of pixel odd then 0th order at the center, shifted by one otherwise
             }
             for (Int jj=0; jj<Npix_out2; ++jj) {
-              for (Int ii=0; ii<Npix_out2; ++ii) {
-                Complex gain = result_non_padded[0][i][j](ii,jj);
-                Stack_PB_CF(istart+ii,istart+jj) += gain*weight_sqsq;
+	      if (istart+jj>=0 && istart+jj<m_shape[0]) {
+		for (Int ii=0; ii<Npix_out2; ++ii) {
+		  if (istart+ii>=0 && istart+ii<m_shape[0]) {
+		    Complex gain = result_non_padded[0][i][j](ii,jj);
+		    Stack_PB_CF(istart+ii,istart+jj) += gain*weight_sqsq;
+		  }
+		}
               }
             }
             sum_weight_square += weight_sqsq;
diff --git a/CEP/Imager/LofarFT/src/awimager.cc b/CEP/Imager/LofarFT/src/awimager.cc
index 062065020d4..21d77bf790b 100644
--- a/CEP/Imager/LofarFT/src/awimager.cc
+++ b/CEP/Imager/LofarFT/src/awimager.cc
@@ -685,7 +685,6 @@ int main (Int argc, char** argv)
     // cout<<"timerange"<<timerange.timerange()<<endl;
     Vector<Int> wind(window.nrow());
     for(uInt iii=0;iii<window.nrow();++iii){wind(iii)=iii;};
-    cout<<"... Windows is shit"<<endl;
 
     ROArrayColumn<Double> chfreq(window.chanFreq());
 
-- 
GitLab