diff --git a/LCS/MSLofar/include/MSLofar/BeamTables.h b/LCS/MSLofar/include/MSLofar/BeamTables.h index 0e911fee44ee76242fd5359d2845c51ad87c3ce7..23f5bc0d75d80fb87c355930e1ea5cdbcd9cc16a 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 0fd9334f9fa3091cd9c8eaf5666ea2886b427a78..55718389d181b5d1ab2240f8755099b866f1aeb6 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 36d59d8901a1c4b3bffec9dfdd22e7bbab1b2584..bbd85498b95bf07213c99c105e444dde2c56e855 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;