From eea30a96f1610d7e524b4b69ca06c9d3df649b0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Offringa?= <offringa@astron.nl> Date: Tue, 23 Nov 2010 13:55:54 +0000 Subject: [PATCH] Bug 1491: formatting frequency and antenna statistics somewhat nicer --- .../AOFlagger/rfi/frequencyflagcountplot.h | 8 +++++ .../src/rfi/antennaflagcountplot.cpp | 24 +++++++++----- .../src/rfi/frequencyflagcountplot.cpp | 31 ++++++++++++++++--- 3 files changed, 50 insertions(+), 13 deletions(-) diff --git a/CEP/DP3/AOFlagger/include/AOFlagger/rfi/frequencyflagcountplot.h b/CEP/DP3/AOFlagger/include/AOFlagger/rfi/frequencyflagcountplot.h index d649e4912ef..932f146c09d 100644 --- a/CEP/DP3/AOFlagger/include/AOFlagger/rfi/frequencyflagcountplot.h +++ b/CEP/DP3/AOFlagger/include/AOFlagger/rfi/frequencyflagcountplot.h @@ -50,6 +50,14 @@ class FrequencyFlagCountPlot{ if(number < 10) stream << '0'; stream << number; } + std::string formatIndex(int index) + { + std::stringstream s; + if(index < 100) s << ' '; + if(index < 10) s << ' '; + s << index; + return s.str(); + } // In lofar, the first channel of every subband is flagged, because it overlaps with // the previous subband. bool _ignoreFirstChannel; diff --git a/CEP/DP3/AOFlagger/src/rfi/antennaflagcountplot.cpp b/CEP/DP3/AOFlagger/src/rfi/antennaflagcountplot.cpp index dab04bb7e3d..5af488cfcdc 100644 --- a/CEP/DP3/AOFlagger/src/rfi/antennaflagcountplot.cpp +++ b/CEP/DP3/AOFlagger/src/rfi/antennaflagcountplot.cpp @@ -112,14 +112,22 @@ void AntennaFlagCountPlot::Report() { for(std::map<int, MapItem>::const_iterator i=_counts.begin();i!=_counts.end();++i) { - AOLogger::Info - << "Flagged in autocorrelations of antenna " - << i->second.name << ": " - << formatPercentage(100.0L * (long double) i->second.autoCount / (long double) i->second.autoTotal) - << "%\nFlagged in cross correlations with antenna " - << i->second.name << ": " - << formatPercentage(100.0L * (long double) i->second.crossCount / (long double) i->second.crossTotal) - << "%\n"; + if(i->second.autoTotal != 0) + { + AOLogger::Info + << "Flagged in autocorrelations of antenna " + << i->second.name << ": " + << formatPercentage(100.0L * (long double) i->second.autoCount / (long double) i->second.autoTotal) + << "%\n"; + } + if(i->second.crossTotal != 0) + { + AOLogger::Info + << "Flagged in cross correlations with antenna " + << i->second.name << ": " + << formatPercentage(100.0L * (long double) i->second.crossCount / (long double) i->second.crossTotal) + << "%\n"; + } } } diff --git a/CEP/DP3/AOFlagger/src/rfi/frequencyflagcountplot.cpp b/CEP/DP3/AOFlagger/src/rfi/frequencyflagcountplot.cpp index 0a2e51d138b..f946eb731fe 100644 --- a/CEP/DP3/AOFlagger/src/rfi/frequencyflagcountplot.cpp +++ b/CEP/DP3/AOFlagger/src/rfi/frequencyflagcountplot.cpp @@ -83,15 +83,35 @@ void FrequencyFlagCountPlot::MakePlot() void FrequencyFlagCountPlot::Report() { size_t index = _ignoreFirstChannel ? 1 : 0; + size_t column = 0; + std::stringstream rowStr; + AOLogger::Info + << "Summary of RFI per channel: (" + << formatFrequency(_counts.begin()->first) << " Hz - " + << formatFrequency(_counts.rbegin()->first) << " Hz)\n"; for(std::map<double, struct MapItem>::const_iterator i=_counts.begin();i!=_counts.end();++i) { - AOLogger::Info - << "RFI in channel " << index << " (" - << formatFrequency(i->first) << " Hz):" - << formatPercentage(100.0L * (long double) i->second.count / (long double) i->second.total) - << "%\n"; + if(column == 0) + { + AOLogger::Info << "Channel " << formatIndex(index) << "-"; + } + std::string percString = formatPercentage(100.0L * (long double) i->second.count / (long double) i->second.total); + for(unsigned j=percString.size();j<6;++j) + rowStr << ' '; + rowStr << percString << '%'; + ++column; + if(column >= 8) + { + AOLogger::Info << formatIndex(index) << ":" << rowStr.str() << '\n'; + rowStr.str(std::string()); + column = 0; + } ++index; } + if(column != 0) + { + AOLogger::Info << formatIndex(index-1) << ":" << rowStr.str() << '\n'; + } } std::string FrequencyFlagCountPlot::formatPercentage(double percentage) @@ -103,6 +123,7 @@ std::string FrequencyFlagCountPlot::formatPercentage(double percentage) s << round(percentage*100.0)/100.0; else s << round(percentage*1000.0)/1000.0; + if(s.str().find('.') == std::string::npos) s << ".0"; return s.str(); } -- GitLab