From 90b37098c53077c58723e37425e47f2ece3bd8c2 Mon Sep 17 00:00:00 2001 From: Ger van Diepen <diepen@astron.nl> Date: Wed, 23 Mar 2011 09:04:17 +0000 Subject: [PATCH] bug 1660: Split create into create and fill --- LCS/MSLofar/include/MSLofar/BeamTables.h | 13 ++++--- LCS/MSLofar/src/BeamTables.cc | 44 ++++++++++++++---------- LCS/MSLofar/src/makebeamtables.cc | 4 +-- 3 files changed, 36 insertions(+), 25 deletions(-) diff --git a/LCS/MSLofar/include/MSLofar/BeamTables.h b/LCS/MSLofar/include/MSLofar/BeamTables.h index 0e911fee44e..23f5bc0d75d 100644 --- a/LCS/MSLofar/include/MSLofar/BeamTables.h +++ b/LCS/MSLofar/include/MSLofar/BeamTables.h @@ -54,14 +54,17 @@ namespace LOFAR { { public: - // Create and fill the subtables and attach them to the MS. + // Create the subtables and attach them to the MS. static void create (casa::Table& ms, - const string& antennaSet, - const string& antennaSetFileName, - const string& antennaFieldDir, - const string& iHBADeltaDir, bool overwrite = false); + // Fill the subtables. They should be empty. + static void fill (casa::Table& ms, + const string& antennaSet, + const string& antennaSetFileName, + const string& antennaFieldDir, + const string& iHBADeltaDir); + // Write an AntennaField entry in the given row. static void writeAntField (MSAntennaFieldColumns& columns, int rownr, int antennaId, const string& stationName, diff --git a/LCS/MSLofar/src/BeamTables.cc b/LCS/MSLofar/src/BeamTables.cc index 0fd9334f9fa..55718389d18 100644 --- a/LCS/MSLofar/src/BeamTables.cc +++ b/LCS/MSLofar/src/BeamTables.cc @@ -41,25 +41,8 @@ using namespace LOFAR; using namespace casa; -void BeamTables::create (Table& ms, - const string& antennaSetName, - const string& antennaSetFileName, - const string& antennaFieldDir, - const string& iHBADeltaDir, - bool overwrite) +void BeamTables::create (Table& ms, bool overwrite) { - // Open the AntennaSets file. - AntennaSets antennaSet(antennaSetFileName); - // If needed, append a trailing slash to the directory names. - string antFieldPath (antennaFieldDir); - if (!antFieldPath.empty() && antFieldPath[antFieldPath.size()-1] != '/') { - antFieldPath.append ("/"); - } - string hbaDeltaPath (iHBADeltaDir); - if (!hbaDeltaPath.empty() && hbaDeltaPath[hbaDeltaPath.size()-1] != '/') { - hbaDeltaPath.append ("/"); - } - // If no overwrite, check if the subtables already exist. if (!overwrite) { ASSERTSTR (!ms.keywordSet().isDefined("LOFAR_ANTENNA_FIELD"), @@ -80,6 +63,31 @@ void BeamTables::create (Table& ms, ms.rwKeywordSet().defineTable ("LOFAR_STATION", statTab); ms.rwKeywordSet().defineTable ("LOFAR_ANTENNA_FIELD", antfTab); ms.rwKeywordSet().defineTable ("LOFAR_ELEMENT_FAILURE", failTab); +} + +void BeamTables::fill (Table& ms, + const string& antennaSetName, + const string& antennaSetFileName, + const string& antennaFieldDir, + const string& iHBADeltaDir) +{ + // Open the AntennaSets file. + AntennaSets antennaSet(antennaSetFileName); + // If needed, append a trailing slash to the directory names. + string antFieldPath (antennaFieldDir); + if (!antFieldPath.empty() && antFieldPath[antFieldPath.size()-1] != '/') { + antFieldPath.append ("/"); + } + string hbaDeltaPath (iHBADeltaDir); + if (!hbaDeltaPath.empty() && hbaDeltaPath[hbaDeltaPath.size()-1] != '/') { + hbaDeltaPath.append ("/"); + } + + // Open the subtables. + MSStation statTab(ms.keywordSet().asTable("LOFAR_STATION")); + MSAntennaField antfTab(ms.keywordSet().asTable("LOFAR_ANTENNA_FIELD")); + ASSERTSTR (statTab.nrow() == 0 && antfTab.nrow() == 0, + "LOFAR_STATION and LOFAR_ANTENNA_FIELD subtables should be empty"); // Create the column objects of those tables. MSStationColumns statCols (statTab); MSAntennaFieldColumns antfCols (antfTab); diff --git a/LCS/MSLofar/src/makebeamtables.cc b/LCS/MSLofar/src/makebeamtables.cc index 36d59d8901a..bbd85498b95 100644 --- a/LCS/MSLofar/src/makebeamtables.cc +++ b/LCS/MSLofar/src/makebeamtables.cc @@ -62,8 +62,8 @@ int main (int argc, char* argv[]) String hbaDeltaDir = inputs.getString("ihbadeltadir"); Bool overwrite = inputs.getBool ("overwrite"); MeasurementSet ms(msName, Table::Update); - BeamTables::create (ms, antSet, antSetFile, - antFieldDir, hbaDeltaDir, overwrite); + BeamTables::create (ms, overwrite); + BeamTables::fill (ms, antSet, antSetFile, antFieldDir, hbaDeltaDir); } catch (std::exception& x) { cout << "Unexpected exception: " << x.what() << endl; return 1; -- GitLab