Skip to content
Snippets Groups Projects
Commit 859a4a06 authored by Adriaan Renting's avatar Adriaan Renting
Browse files

BugId:698

Fixed some bugs
parent 76b78040
No related branches found
No related tags found
No related merge requests found
...@@ -28,7 +28,9 @@ ...@@ -28,7 +28,9 @@
#include "MS_File.h" #include "MS_File.h"
#include "FrequencyFlagger.h" #include "FrequencyFlagger.h"
#define FLAGGER_VERSION "0.10" #define FLAGGER_VERSION "0.20"
// 0.10 initial version
// 0.20 added more algorithms
namespace LOFAR namespace LOFAR
{ {
...@@ -88,18 +90,8 @@ namespace LOFAR ...@@ -88,18 +90,8 @@ namespace LOFAR
cout << string(FLAGGER_VERSION) + string(" autoflagging by Adriaan Renting for LOFAR CS1 data\n") + cout << string(FLAGGER_VERSION) + string(" autoflagging by Adriaan Renting for LOFAR CS1 data\n") +
string("This is experimental software, please report errors or requests to renting@astron.nl\n") + string("This is experimental software, please report errors or requests to renting@astron.nl\n") +
string("Documentation can be found at: www.astron.nl/~renting\n"); string("Documentation can be found at: www.lofar.org/operations/doku.php?id=engineering:software:postprocessing_software\n");
cout << itsMS << endl; cout << itsMS << endl;
if (itsMS == "")
{
cerr << "Usage: WSRT_flagger ms=test.MS crosspol=false window=13 min=5 max=5.5 flagrms=true flagdata=true existing=true" << endl
<< "Where ms [no default] is the Measurementset" << endl
<< " existing [default true] determines if existing flags are kept (no new flag cat. is created)" << endl << endl
<< "Data at point window/2 will be flagged on:" << endl
<< " vis[window/2] - (median(Re(vis[])) + median(Im(vis[]))) " << endl
<< " > (min + (max-min)*baselinelength/maxbaselinelength)*sigma" << endl;
return false;
}
myMS = new MS_File(itsMS); myMS = new MS_File(itsMS);
itsFlagger = new FrequencyFlagger (myMS, itsThreshold); itsFlagger = new FrequencyFlagger (myMS, itsThreshold);
} }
......
...@@ -215,44 +215,41 @@ namespace LOFAR ...@@ -215,44 +215,41 @@ namespace LOFAR
vector<int> RMSCounter(NumPolarizations, 0); vector<int> RMSCounter(NumPolarizations, 0);
bool FlagCompleteRow = true; bool FlagCompleteRow = true;
int flagcount = 0; int flagcount = 0;
for (int i = NumChannels-1; i >= 0; i--) //calculata RMS of unflagged datapoints for (int j = NumPolarizations-1; j >= 0; j--)
{ {
for (int j = NumPolarizations-1; j >= 0; j--) for (int i = NumChannels-1; i >= 0; i--) //calculata RMS of unflagged datapoints
{ {
if (!ExistingFlags || !Flags(j, i)) if (!ExistingFlags || !Flags(j, i))
{ { double temp = pow(abs(Timeslots(j, i)), 2);
MS[j] += pow(abs(Timeslots(j, i)), 2); if (!isNaN(temp))
RMSCounter[j] += 1; {
MS[j] += temp;
RMSCounter[j] += 1;
}
} }
} }
}
for (int j = NumPolarizations-1; j >= 0; j--)
{
if (RMSCounter[j]) if (RMSCounter[j])
{ RMS[j] = sqrt(MS[j] /RMSCounter[j]); { RMS[j] = sqrt(MS[j] /RMSCounter[j]);
} for (int i = NumChannels-1; i >= 0; i--)
}
for (int i = NumChannels-1; i >= 0; i--)
{
bool FlagAllPolarizations = false;
for (int j = NumPolarizations-1; j >= 0; j--)
{ //we need to loop twice, once to determine FlagAllCorrelations
if (!FlagAllPolarizations || !Flags(j, i))
{ {
FlagAllPolarizations |= RMS[j] * FlagThreshold < abs(Timeslots(j, i)); if (!ExistingFlags || !Flags(j, i))
{ double temp = abs(Timeslots(j, i));
bool flag = isNaN(temp) || RMS[j] * FlagThreshold < temp;
//cout << RMS[j] << " " << (RMS[j] * FlagThreshold) << " " << temp << " " << (flag) << endl;
if (flag)
{ flagcount++;
}
else
{ FlagCompleteRow = false;
}
Flags(j, i) = flag || (ExistingFlags && Flags(j, i));
}
} }
} }
for (int j = NumPolarizations-1; j >= 0; j--) else
{ //the second loop we set the flags {
if (FlagAllPolarizations) flagcount += NumChannels;
{ Flags(j, i) = true; Flags.row(j) = true;
flagcount++;
}
else
{
FlagCompleteRow = false;
Flags(j, i) = false; //this can set an existing flag to false if ExistingFlags == False, othewise RMS[j] == 0
}
} }
} }
//these need to be separated out into a different function for clarity //these need to be separated out into a different function for clarity
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment