diff --git a/Appl/CEP/CS1/CS1_DataSquasher/src/DataSquasher.cc b/Appl/CEP/CS1/CS1_DataSquasher/src/DataSquasher.cc index 9359001601ba5b54a86d16f05663abd16346907f..2da755616256dc023e49e845e381bb201989a642 100644 --- a/Appl/CEP/CS1/CS1_DataSquasher/src/DataSquasher.cc +++ b/Appl/CEP/CS1/CS1_DataSquasher/src/DataSquasher.cc @@ -96,7 +96,7 @@ namespace LOFAR int outcounter = 0; bool flagrow = true; Vector<Complex> values(itsNumPolarizations, 0); - //Vector<Float> temp(itsNumPolarizations, ); // a bit bigger to get rounding errors right + Vector<Complex> weights(itsNumPolarizations, 0); while (incounter < NChan) { for (int i = 0; i < itsNumPolarizations; i++) @@ -104,17 +104,22 @@ namespace LOFAR if (!oldFlags(i, Start + incounter)) { //weight is not handled here, maybe sometime in the future? values(i) += oldData(i, Start + incounter); + weights(i) += 1; flagrow = false; } } incounter++; if ((incounter) % Step == 0) { + for (int i = 0; i < itsNumPolarizations; i++) + { values(i) = values(i) / weights(i); + } newData.column(outcounter) = values; for (int i = 0; i < itsNumPolarizations; i++) // I can't get anyGT or something like that to work flagrow = flagrow || (threshold * 1.001 >= abs(values[i])); newFlags.column(outcounter) = flagrow; values = 0; + weights = 0; outcounter++; flagrow = true; } @@ -133,7 +138,7 @@ namespace LOFAR int step = outMS.nrow() / 10 + 1; //not exact but it'll do int row = 0; bool rwFlags = newFlags.nrow() > 0; - if (!rwFlags) + if (!rwFlags) //we are able to re-use the same flags { newFlags.resize(itsNumPolarizations, NChan/Step, itsNumSamples); } diff --git a/Appl/CEP/CS1/CS1_DataSquasher/src/SquasherProcessControl.cc b/Appl/CEP/CS1/CS1_DataSquasher/src/SquasherProcessControl.cc index 02a4e84cdf87a51b15d29ce91b4224eb226aa4e2..cb990bedee371b522b227b9ffbdab0e541dda922 100644 --- a/Appl/CEP/CS1/CS1_DataSquasher/src/SquasherProcessControl.cc +++ b/Appl/CEP/CS1/CS1_DataSquasher/src/SquasherProcessControl.cc @@ -28,12 +28,13 @@ #include <CS1_DataSquasher/SquasherProcessControl.h> #include "DataSquasher.h" -#define SQUASHER_VERSION "0.41" +#define SQUASHER_VERSION "0.42" //0.20 Added handling MODEL and CORRECTED DATA //0.30 Added handling threshold and weights //0.31 Added handing MODEL_DATA and CORRECTED_DATA keywords for imager //0.40 Changed creation mechnism of the destination MS //0.41 Cleaned up the code for readability +//0.42 Fixed the incorect weighting of partially flagged bands namespace LOFAR { @@ -192,7 +193,13 @@ namespace LOFAR { for (int j = 0; j < new_nchan; j++) { inFREQ.get(i, old_temp); - new_temp(j) = old_temp(itsStart + j*itsStep + itsNChan/2); + if (itsStep % 2) //odd number of channels in step + { new_temp(j) = old_temp(itsStart + j*itsStep + (itsStep + 1)/2); + } + else //even number of channels in step + { new_temp(j) = 0.5 * (old_temp(itsStart + j*itsStep + itsStep/2 -1) + + old_temp(itsStart + j*itsStep + itsStep/2)); + } outFREQ.put(i, new_temp); } for (int j = 0; j < new_nchan; j++)