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

Bug 1207:

Improved for real mwimager usage
parent a73a143a
No related branches found
No related tags found
No related merge requests found
...@@ -43,7 +43,8 @@ namespace LOFAR { ...@@ -43,7 +43,8 @@ namespace LOFAR {
public: public:
// Create the description for the given MS and put it in a file // Create the description for the given MS and put it in a file
// with the given name. // with the given name.
static void create (const string& msName, const string& outName); static void create (const string& msName, const string& outName,
const string& clusterDescName);
private: private:
// Get the frequency info for each spectral window in the MS. // Get the frequency info for each spectral window in the MS.
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <lofar_config.h> #include <lofar_config.h>
#include <MS/VdsMaker.h> #include <MS/VdsMaker.h>
#include <MWCommon/VdsPartDesc.h> #include <MWCommon/VdsPartDesc.h>
#include <MWCommon/ClusterDesc.h>
#include <Common/StreamUtil.h> #include <Common/StreamUtil.h>
#include <Common/LofarLogger.h> #include <Common/LofarLogger.h>
...@@ -43,6 +44,7 @@ ...@@ -43,6 +44,7 @@
#include <casa/Utilities/LinearSearch.h> #include <casa/Utilities/LinearSearch.h>
#include <casa/OS/Path.h> #include <casa/OS/Path.h>
#include <casa/OS/RegularFile.h> #include <casa/OS/RegularFile.h>
#include <casa/OS/HostInfo.h>
#include <casa/Exceptions/Error.h> #include <casa/Exceptions/Error.h>
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
...@@ -139,9 +141,29 @@ void VdsMaker::getDataFileInfo (MS& ms, string& name, bool& regular, ...@@ -139,9 +141,29 @@ void VdsMaker::getDataFileInfo (MS& ms, string& name, bool& regular,
} }
} }
string findFileSys (const std::string& fileName, const ClusterDesc& cdesc)
{
// Find the file system by looking for a matching mountpoint.
const std::vector<NodeDesc>& nodes = cdesc.getNodes();
// First find the NodeDesc for this node.
string nodeName = HostInfo::hostName();
uint i=0;
for (; i<nodes.size(); ++i) {
if (nodes[i].getName() == nodeName) {
break;
}
}
ASSERTSTR (i < nodes.size(), "Hostname '" << nodeName << "' not found in "
"ClusterDesc file ");
return nodes[i].findFileSys (fileName);
}
void VdsMaker::create (const string& msName, const string& outName) void VdsMaker::create (const string& msName, const string& outName,
const string& clusterDescName)
{ {
// Open the ClusterDesc parset file.
ClusterDesc cdesc((ParameterSet(clusterDescName)));
// Open the table. // Open the table.
MS ms(msName); MS ms(msName);
// Create and fill the Vds object. // Create and fill the Vds object.
...@@ -149,8 +171,8 @@ void VdsMaker::create (const string& msName, const string& outName) ...@@ -149,8 +171,8 @@ void VdsMaker::create (const string& msName, const string& outName)
ostringstream oss; ostringstream oss;
// Fill in MS path and name. // Fill in MS path and name.
Path mspr(msName); Path mspr(msName);
Path msp(mspr.absoluteName()); string absName = mspr.absoluteName();
msd.setName (msp.originalName(), msp.dirName()); msd.setName (absName, findFileSys(absName, cdesc));
// Get freq info. // Get freq info.
// Fill in correlation info. // Fill in correlation info.
vector<string> corrNames; vector<string> corrNames;
......
...@@ -50,6 +50,7 @@ int main(int argc, const char* argv[]) ...@@ -50,6 +50,7 @@ int main(int argc, const char* argv[])
vpds.reserve (argc-2); vpds.reserve (argc-2);
for (int i=2; i<argc; ++i) { for (int i=2; i<argc; ++i) {
VdsPartDesc* vpd = new VdsPartDesc(ParameterSet(argv[i])); VdsPartDesc* vpd = new VdsPartDesc(ParameterSet(argv[i]));
vpd->setName (argv[i], vpd->getFileSys());
vpds.push_back (vpd); vpds.push_back (vpd);
vpd->clearParms(); vpd->clearParms();
const vector<int>& chans = vpd->getNChan(); const vector<int>& chans = vpd->getNChan();
...@@ -90,6 +91,7 @@ int main(int argc, const char* argv[]) ...@@ -90,6 +91,7 @@ int main(int argc, const char* argv[])
} }
delete vpds[i]; delete vpds[i];
vpds[i] = 0; vpds[i] = 0;
} }
ofstream ostr(argv[1]); ofstream ostr(argv[1]);
gdesc.write (ostr); gdesc.write (ostr);
......
...@@ -31,11 +31,15 @@ using namespace std; ...@@ -31,11 +31,15 @@ using namespace std;
int main(int argc, const char* argv[]) int main(int argc, const char* argv[])
{ {
try { try {
if (argc < 2) { if (argc < 3) {
cout << "Run as: makevds ms" << endl; cout << "Run as: makevds clusterdesc ms [msvds]" << endl;
return 0; return 0;
} }
LOFAR::VdsMaker::create (argv[1], string(argv[1])+".vds"); string msvds = string(argv[2]) + ".vds";
if (argc > 3) {
msvds = argv[3];
}
LOFAR::VdsMaker::create (argv[2], msvds, argv[1]);
} catch (exception& x) { } catch (exception& x) {
cout << "Unexpected expection: " << x.what() << endl; cout << "Unexpected expection: " << x.what() << endl;
return 1; return 1;
......
...@@ -6,7 +6,7 @@ NChan = [8,10,1,4] ...@@ -6,7 +6,7 @@ NChan = [8,10,1,4]
StartFreqs = [10,20,100,110] StartFreqs = [10,20,100,110]
EndFreqs = [20,30,110,150] EndFreqs = [20,30,110,150]
NParts = 2 NParts = 2
Part0.Name = /Users/diepen/LOFAR.MS1 Part0.Name = tcombinevds.in_vds1
Part0.FileSys = /Users/diepen Part0.FileSys = /Users/diepen
Part0.StartTime = 2007/07/27/16:04:49 Part0.StartTime = 2007/07/27/16:04:49
Part0.EndTime = 2007/07/28/16:04:48 Part0.EndTime = 2007/07/28/16:04:48
...@@ -14,7 +14,7 @@ Part0.StepTime = 30.199 ...@@ -14,7 +14,7 @@ Part0.StepTime = 30.199
Part0.NChan = [8,10] Part0.NChan = [8,10]
Part0.StartFreqs = [10,20] Part0.StartFreqs = [10,20]
Part0.EndFreqs = [20,30] Part0.EndFreqs = [20,30]
Part1.Name = /Users/diepen/LOFAR.MS2 Part1.Name = tcombinevds.in_vds2
Part1.FileSys = /Users/diepen Part1.FileSys = /Users/diepen
Part1.StartTime = 2007/07/27/16:04:49 Part1.StartTime = 2007/07/27/16:04:49
Part1.EndTime = 2007/07/28/16:04:48 Part1.EndTime = 2007/07/28/16:04:48
......
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