Skip to content
Snippets Groups Projects
Commit 90b37098 authored by Ger van Diepen's avatar Ger van Diepen
Browse files

bug 1660:

Split create into create and fill
parent 4c5cd7b4
No related branches found
No related tags found
No related merge requests found
...@@ -54,14 +54,17 @@ namespace LOFAR { ...@@ -54,14 +54,17 @@ namespace LOFAR {
{ {
public: 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, static void create (casa::Table& ms,
const string& antennaSet,
const string& antennaSetFileName,
const string& antennaFieldDir,
const string& iHBADeltaDir,
bool overwrite = false); 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. // Write an AntennaField entry in the given row.
static void writeAntField (MSAntennaFieldColumns& columns, int rownr, static void writeAntField (MSAntennaFieldColumns& columns, int rownr,
int antennaId, const string& stationName, int antennaId, const string& stationName,
......
...@@ -41,25 +41,8 @@ ...@@ -41,25 +41,8 @@
using namespace LOFAR; using namespace LOFAR;
using namespace casa; using namespace casa;
void BeamTables::create (Table& ms, void BeamTables::create (Table& ms, bool overwrite)
const string& antennaSetName,
const string& antennaSetFileName,
const string& antennaFieldDir,
const string& iHBADeltaDir,
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 no overwrite, check if the subtables already exist.
if (!overwrite) { if (!overwrite) {
ASSERTSTR (!ms.keywordSet().isDefined("LOFAR_ANTENNA_FIELD"), ASSERTSTR (!ms.keywordSet().isDefined("LOFAR_ANTENNA_FIELD"),
...@@ -80,6 +63,31 @@ void BeamTables::create (Table& ms, ...@@ -80,6 +63,31 @@ void BeamTables::create (Table& ms,
ms.rwKeywordSet().defineTable ("LOFAR_STATION", statTab); ms.rwKeywordSet().defineTable ("LOFAR_STATION", statTab);
ms.rwKeywordSet().defineTable ("LOFAR_ANTENNA_FIELD", antfTab); ms.rwKeywordSet().defineTable ("LOFAR_ANTENNA_FIELD", antfTab);
ms.rwKeywordSet().defineTable ("LOFAR_ELEMENT_FAILURE", failTab); 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. // Create the column objects of those tables.
MSStationColumns statCols (statTab); MSStationColumns statCols (statTab);
MSAntennaFieldColumns antfCols (antfTab); MSAntennaFieldColumns antfCols (antfTab);
......
...@@ -62,8 +62,8 @@ int main (int argc, char* argv[]) ...@@ -62,8 +62,8 @@ int main (int argc, char* argv[])
String hbaDeltaDir = inputs.getString("ihbadeltadir"); String hbaDeltaDir = inputs.getString("ihbadeltadir");
Bool overwrite = inputs.getBool ("overwrite"); Bool overwrite = inputs.getBool ("overwrite");
MeasurementSet ms(msName, Table::Update); MeasurementSet ms(msName, Table::Update);
BeamTables::create (ms, antSet, antSetFile, BeamTables::create (ms, overwrite);
antFieldDir, hbaDeltaDir, overwrite); BeamTables::fill (ms, antSet, antSetFile, antFieldDir, hbaDeltaDir);
} catch (std::exception& x) { } catch (std::exception& x) {
cout << "Unexpected exception: " << x.what() << endl; cout << "Unexpected exception: " << x.what() << endl;
return 1; return 1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment