Skip to content
Snippets Groups Projects
Commit 770dce2a authored by Andre Offringa's avatar Andre Offringa
Browse files

Bug 1491: adding some script creaters

parent 676b0964
No related branches found
No related tags found
No related merge requests found
......@@ -227,10 +227,12 @@ CEP/DP3/AOFlagger/include/AOFlagger/msio/timefrequencydata.h -text
CEP/DP3/AOFlagger/include/AOFlagger/msio/timefrequencyimager.h -text
CEP/DP3/AOFlagger/include/AOFlagger/msio/timefrequencymetadata.h -text
CEP/DP3/AOFlagger/include/AOFlagger/msio/types.h -text
CEP/DP3/AOFlagger/include/AOFlagger/ref/concatenatescript.h -text
CEP/DP3/AOFlagger/include/AOFlagger/ref/copyallscript.h -text
CEP/DP3/AOFlagger/include/AOFlagger/ref/reffile.h -text
CEP/DP3/AOFlagger/include/AOFlagger/ref/reffileentry.h -text
CEP/DP3/AOFlagger/include/AOFlagger/ref/reffileexception.h -text
CEP/DP3/AOFlagger/include/AOFlagger/ref/refmovescript.h -text
CEP/DP3/AOFlagger/include/AOFlagger/rfi/antennaflagcountplot.h -text
CEP/DP3/AOFlagger/include/AOFlagger/rfi/eigenvalue.h -text
CEP/DP3/AOFlagger/include/AOFlagger/rfi/frequencyflagcountplot.h -text
......@@ -323,6 +325,7 @@ CEP/DP3/AOFlagger/include/AOFlagger/util/stopwatch.h -text
CEP/DP3/AOFlagger/include/AOFlagger/util/types.h -text
CEP/DP3/AOFlagger/include/AOFlagger/util/xmlwriter.h -text
CEP/DP3/AOFlagger/include/AOFlagger/vectortypes.h -text
CEP/DP3/AOFlagger/package.dox -text
CEP/DP3/AOFlagger/scripts/CMakeLists-AOFlagger-without-lofarstman.txt -text
CEP/DP3/AOFlagger/scripts/CMakeLists-CEP.txt -text
CEP/DP3/AOFlagger/scripts/CMakeLists-Common-src-without-lofarstman.txt -text
......@@ -351,8 +354,8 @@ CEP/DP3/AOFlagger/scripts/distributed/statistics.rfis -text
CEP/DP3/AOFlagger/scripts/package-without-lofarstman.sh -text
CEP/DP3/AOFlagger/scripts/package.sh -text
CEP/DP3/AOFlagger/src/CMakeLists.txt -text
CEP/DP3/AOFlagger/src/aocopyallscript.cpp -text
CEP/DP3/AOFlagger/src/aofrequencyfilter.cpp -text
CEP/DP3/AOFlagger/src/aorefscript.cpp -text
CEP/DP3/AOFlagger/src/cleaner.cpp -text
CEP/DP3/AOFlagger/src/colormapper.cpp -text
CEP/DP3/AOFlagger/src/createuv.cpp -text
......
/***************************************************************************
* Copyright (C) 2011 by A.R. Offringa *
* offringa@astro.rug.nl *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef AO_CONCATENATESCRIPT_H
#define AO_CONCATENATESCRIPT_H
#include <iostream>
#include <string>
#include <AOFlagger/ref/reffile.h>
namespace AOTools
{
class ConcatenateScript
{
public:
static void Make(std::ostream &stream, const std::string &refFilePath, const std::string &destination)
{
RefFile file(refFilePath);
stream <<
"#!/usr/bin/env python\n\n"
"import pyrap.tables as pt\n\n"
"pt.concatms([";
RefFile::const_iterator i=file.begin();
if(i!=file.end())
{
stream << '\"' << i->Path() << '\"';
++i;
}
while(i!=file.end())
{
stream << ", \"/net/" << i->Node() << i->Path() << '\"';
++i;
}
stream << "], \"" << destination << "\")\n";
}
};
}
#endif // AO_CONCATENATESCRIPT_H
......@@ -39,6 +39,12 @@ namespace AOTools
typedef std::map<std::string, PathList> PathsPerNodeType;
typedef std::pair<std::string, PathList> NodeAndPaths;
std::string correctedDest;
if(*destination.rbegin() == '/')
correctedDest = destination;
else
correctedDest = destination + "/";
RefFile file(refFilePath);
PathsPerNodeType pathsPerNode;
......@@ -58,7 +64,7 @@ namespace AOTools
stream <<
"#! /bin/bash\n"
"# Created by aocopyallscript to move sets in \n# " << refFilePath << "\n"
"# to local path\n# " << destination << "\n"
"# to local path\n# " << correctedDest << "\n"
"# Set contains " << file.Count() << " MS directories\n"
"# Number of nodes: " << pathsPerNode.size() << "\n";
for(PathsPerNodeType::const_iterator i=pathsPerNode.begin(); i!=pathsPerNode.end(); ++i)
......@@ -68,13 +74,13 @@ namespace AOTools
stream
<< "function copy_" << node << " {\n"
<< " mkdir -p " << destination << "\n";
<< " ssh " << node << " -C \"mkdir -p " << correctedDest << "\"\n";
for(PathList::const_iterator p=paths.begin();p!=paths.end();++p)
{
const std::string &path = *p;
stream
<< " echo " << path << " \\(" << node << "\\)\n"
<< " ssh " << node << " -C \"cp -r " << path << " " << destination << "\"\n";
<< " ssh " << node << " -C \"cp -r " << path << " " << correctedDest << "\"\n";
}
stream
<< "}\n\n";
......
......@@ -23,6 +23,7 @@
#include <fstream>
#include <string>
#include <vector>
#include <AOFlagger/ref/reffileentry.h>
#include <AOFlagger/ref/reffileexception.h>
......@@ -55,6 +56,12 @@ namespace AOTools
}
}
void Write(std::ostream &destination) const
{
for(const_iterator i=begin();i!=end();++i)
i->write(destination);
}
size_t Count() const
{
return _entries.size();
......@@ -65,6 +72,11 @@ namespace AOTools
return _entries[index];
}
void Add(const RefFileEntry &entry)
{
_entries.push_back(entry);
}
const_iterator begin() const
{
return _entries.begin();
......@@ -74,7 +86,7 @@ namespace AOTools
{
return _entries.end();
}
private:
RefFile(const RefFile &) // don't allow copy
{
......
......@@ -58,6 +58,7 @@ namespace AOTools
unsigned Size() const { return _size; }
const std::string &Node() const { return _node; }
void SetPath(const std::string &path) { _path = path; }
private:
std::string _path;
std::string _frequency;
......@@ -78,6 +79,11 @@ namespace AOTools
return true;
}
void write(std::ostream &stream) const
{
stream << _path << ' ' << _frequency << ' ' << _size << ' ' << _node << "\n";
}
void assignFromString(const std::string &line)
{
std::string::const_iterator i=line.begin();
......
/***************************************************************************
* Copyright (C) 2011 by A.R. Offringa *
* offringa@astro.rug.nl *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef AO_REFMOVESCRIPT_H
#define AO_REFMOVESCRIPT_H
#include <iostream>
#include <string>
#include <boost/filesystem.hpp>
#include <AOFlagger/ref/reffile.h>
namespace AOTools
{
class RefMoveScript
{
public:
static void Make(std::ostream &stream, const std::string &refFilePath, const std::string &destination)
{
RefFile file(refFilePath);
RefFile destFile;
const boost::filesystem::path destPath(destination);
for(RefFile::const_iterator i=file.begin();i!=file.end();++i)
{
RefFileEntry entry = *i;
boost::filesystem::path entryPath(entry.Path());
entry.SetPath((destPath / entryPath.filename()).directory_string());
destFile.Add(entry);
}
destFile.Write(stream);
}
};
}
#endif // AO_REFMOVESCRIPT_H
// \ingroup DP3
//
// \defgroup AOFlagger AOFlagger (flagger framework based on the
// SumThreshold method)
//
// This package contains several programs related to flagging,
// most important the programs "rficonsole" and "rfigui". See
// the LOFAR cookbook for general info.
//
// @{
// \defgroup AOFlagger AOFlagger
// @}
......@@ -6,7 +6,7 @@ lofar_add_bin_program(rfihistory rfihistory.cpp)
lofar_add_bin_program(aofrequencyfilter aofrequencyfilter.cpp rfi/thresholdtools.cpp util/rng.cpp msio/image2d.cpp msio/fitsfile.cpp util/aologger.cpp)
lofar_add_bin_program(aocopyallscript aocopyallscript.cpp)
lofar_add_bin_program(aorefscript aorefscript.cpp)
set(GUI_PLOT_FILES
gui/plot/horizontalplotscale.cpp
......
......@@ -20,18 +20,29 @@
#include <iostream>
#include <AOFlagger/ref/concatenatescript.h>
#include <AOFlagger/ref/copyallscript.h>
#include <AOFlagger/ref/refmovescript.h>
using namespace std;
int main(int argc, char *argv[])
{
if(argc != 3)
if(argc != 4)
{
cerr << "Syntax: " << argv[0] << " <reffile> <local-destination>\n";
cerr << "Syntax: " << argv[0] << " <scripttype> <reffile> <local-destination>\n"
"script types: concatenate, copyall, refmove\n";
return -1;
} else {
AOTools::CopyAllScript::Make(cout, argv[1], argv[2]);
string type(argv[1]);
if(type == "concatenate")
AOTools::ConcatenateScript::Make(cout, argv[2], argv[3]);
else if(type =="copyall")
AOTools::CopyAllScript::Make(cout, argv[2], argv[3]);
else if(type =="refmove")
AOTools::RefMoveScript::Make(cout, argv[2], argv[3]);
else
cerr << "Incorrect script type given." << "\n";
return 0;
}
}
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