diff --git a/CEP/BB/MS/include/MS/VdsMaker.h b/CEP/BB/MS/include/MS/VdsMaker.h index 95ffe95065eb1c598b0dd457dd2a919ca97a2ad1..41d50daa06aa804d310f053ec8174571387a506c 100644 --- a/CEP/BB/MS/include/MS/VdsMaker.h +++ b/CEP/BB/MS/include/MS/VdsMaker.h @@ -43,7 +43,8 @@ namespace LOFAR { public: // Create the description for the given MS and put it in a file // 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: // Get the frequency info for each spectral window in the MS. diff --git a/CEP/BB/MS/src/VdsMaker.cc b/CEP/BB/MS/src/VdsMaker.cc index 994c0d647c5e92ec88c1abb743da5a9482e4369f..2d645ed284f18f454c8a648204617f41e111b82d 100644 --- a/CEP/BB/MS/src/VdsMaker.cc +++ b/CEP/BB/MS/src/VdsMaker.cc @@ -23,6 +23,7 @@ #include <lofar_config.h> #include <MS/VdsMaker.h> #include <MWCommon/VdsPartDesc.h> +#include <MWCommon/ClusterDesc.h> #include <Common/StreamUtil.h> #include <Common/LofarLogger.h> @@ -43,6 +44,7 @@ #include <casa/Utilities/LinearSearch.h> #include <casa/OS/Path.h> #include <casa/OS/RegularFile.h> +#include <casa/OS/HostInfo.h> #include <casa/Exceptions/Error.h> #include <iostream> #include <fstream> @@ -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. MS ms(msName); // Create and fill the Vds object. @@ -149,8 +171,8 @@ void VdsMaker::create (const string& msName, const string& outName) ostringstream oss; // Fill in MS path and name. Path mspr(msName); - Path msp(mspr.absoluteName()); - msd.setName (msp.originalName(), msp.dirName()); + string absName = mspr.absoluteName(); + msd.setName (absName, findFileSys(absName, cdesc)); // Get freq info. // Fill in correlation info. vector<string> corrNames; diff --git a/CEP/BB/MS/src/combinevds.cc b/CEP/BB/MS/src/combinevds.cc index 4d5d48cb04ab16558725bb144b61b9348f82ceb3..172aae5439c9396f1613a8abb2cd7347bed9e2ff 100644 --- a/CEP/BB/MS/src/combinevds.cc +++ b/CEP/BB/MS/src/combinevds.cc @@ -50,6 +50,7 @@ int main(int argc, const char* argv[]) vpds.reserve (argc-2); for (int i=2; i<argc; ++i) { VdsPartDesc* vpd = new VdsPartDesc(ParameterSet(argv[i])); + vpd->setName (argv[i], vpd->getFileSys()); vpds.push_back (vpd); vpd->clearParms(); const vector<int>& chans = vpd->getNChan(); @@ -90,6 +91,7 @@ int main(int argc, const char* argv[]) } delete vpds[i]; vpds[i] = 0; + } ofstream ostr(argv[1]); gdesc.write (ostr); diff --git a/CEP/BB/MS/src/makevds.cc b/CEP/BB/MS/src/makevds.cc index 4466150f179b3bb5d10245544a13e23cc9637b35..d7ab27b0edd419dfb728278576a547e9da60177c 100644 --- a/CEP/BB/MS/src/makevds.cc +++ b/CEP/BB/MS/src/makevds.cc @@ -31,11 +31,15 @@ using namespace std; int main(int argc, const char* argv[]) { try { - if (argc < 2) { - cout << "Run as: makevds ms" << endl; + if (argc < 3) { + cout << "Run as: makevds clusterdesc ms [msvds]" << endl; 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) { cout << "Unexpected expection: " << x.what() << endl; return 1; diff --git a/CEP/BB/MS/test/tcombinevds.stdout b/CEP/BB/MS/test/tcombinevds.stdout index 5e13d1255e9e14ed1f0de2cf9478931b76a7ab93..256b840d10306948f371fd1cea9e5569fe8d5673 100644 --- a/CEP/BB/MS/test/tcombinevds.stdout +++ b/CEP/BB/MS/test/tcombinevds.stdout @@ -6,7 +6,7 @@ NChan = [8,10,1,4] StartFreqs = [10,20,100,110] EndFreqs = [20,30,110,150] NParts = 2 -Part0.Name = /Users/diepen/LOFAR.MS1 +Part0.Name = tcombinevds.in_vds1 Part0.FileSys = /Users/diepen Part0.StartTime = 2007/07/27/16:04:49 Part0.EndTime = 2007/07/28/16:04:48 @@ -14,7 +14,7 @@ Part0.StepTime = 30.199 Part0.NChan = [8,10] Part0.StartFreqs = [10,20] Part0.EndFreqs = [20,30] -Part1.Name = /Users/diepen/LOFAR.MS2 +Part1.Name = tcombinevds.in_vds2 Part1.FileSys = /Users/diepen Part1.StartTime = 2007/07/27/16:04:49 Part1.EndTime = 2007/07/28/16:04:48