Commit 92774783 authored by thomas.forbriger's avatar thomas.forbriger Committed by thomas.forbriger
Browse files

proceeding with tidofi

This is a legacy commit from before 2015-03-01.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/trunk
SVN Revision: 1827
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 578c6d92
# ---------------------------------------
#
# $Id: Makefile,v 1.25 2005-03-15 18:36:20 tforb Exp $
# $Id: Makefile,v 1.26 2005-07-06 14:10:02 tforb Exp $
#
# Makefile fuer tools /src/ts/wf
#
......@@ -58,8 +58,8 @@ phasedsignals hamres siggen smoos dise: %: %.o
newprog $@
gatherdiff autocorr cross tidofi fredofi sigfit: %: %.o
$(CXX) -o $@ $^ -I$(LOCINCLUDEDIR) -lsffxx -llinearxx -lgsexx -laff \
-ltsxx -ldatreadxx -ltfxx -ltime++ \
$(CXX) -o $@ $^ -I$(LOCINCLUDEDIR) -ldatreadxx -llinearxx \
-ltsxx -ltfxx -lsffxx -lgsexx -ltime++ -laff \
-llapack -lblas -lg2c -lm\
-L$(LOCLIBDIR) $(CXXFLAGS) $(FLAGS)
newprog $@
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: tidofi.cc,v 1.2 2005-06-30 12:47:54 tforb Exp $
* $Id: tidofi.cc,v 1.3 2005-07-06 14:10:03 tforb Exp $
* \author Thomas Forbriger
* \date 17/02/2004
*
......@@ -19,12 +19,17 @@
#define TIDOFI_VERSION \
"TIDOFI V1.0 time domain filter"
#define TIDOFI_CVSID \
"$Id: tidofi.cc,v 1.2 2005-06-30 12:47:54 tforb Exp $"
"$Id: tidofi.cc,v 1.3 2005-07-06 14:10:03 tforb Exp $"
#include <iostream>
#include <fstream>
#include <string>
#include <tfxx/commandline.h>
#include <tfxx/xcmdline.h>
#include <tfxx/error.h>
#include <tfxx/stringfunc.h>
#include <datreadxx/readany.h>
#include <sffxx.h>
using std::cout;
using std::cerr;
......@@ -38,6 +43,7 @@ struct Options {
bool readcommandfile;
std::string commandfile;
bool readstdin;
std::string inputformat;
}; // struct Options
/*======================================================================*/
......@@ -49,7 +55,7 @@ int main(int iargc, char* argv[])
char usage_text[]=
{
TIDOFI_VERSION "\n"
"usage: tidofi [-v] [-o] [-cf file] [-cs]" "\n"
"usage: tidofi [-v] [-o] [-cf file] [-cs] [-t type]" "\n"
" outfile infile [t:T] [infile [t:T] ... ]" "\n"
" or: tidofi --help|-h" "\n"
};
......@@ -67,6 +73,11 @@ int main(int iargc, char* argv[])
"-o overwrite output" "\n"
"-cf file read filter commands from \"file\"" "\n"
"-cs read filter commands from stdin" "\n"
"-t type choose input file format (default: sff)" "\n"
"\n"
"In command files comment lines may either commence with \"rem\" like" "\n"
"in seife command files or with \'#\'. The seife command \"end\" is" "\n"
"simply ignored (like a comment line)."
};
// define commandline options
......@@ -83,10 +94,12 @@ int main(int iargc, char* argv[])
{"cf",arg_yes,"-"},
// 4: stdin mode
{"cs",arg_no,"-"},
// 5: input file format
{"t",arg_no,"sff"},
{NULL}
};
// define commandlien argument modifier keys
// define commandline argument modifier keys
static const char* cmdlinekeys[]={"t", 0};
// no arguments? print usage...
......@@ -104,6 +117,7 @@ int main(int iargc, char* argv[])
{
cerr << usage_text << endl;
cerr << help_text << endl;
datread::supported_data_types(cerr);
exit(0);
}
......@@ -114,12 +128,141 @@ int main(int iargc, char* argv[])
opt.readcommandfile=cmdline.optset(3);
opt.commandfile=cmdline.string_arg(3);
opt.readstdin=cmdline.optset(4);
opt.inputformat=cmdline.string_arg(5);
if (opt.verbose)
{ cout << TIDOFI_VERSION << endl << TIDOFI_CVSID << endl; }
// extract commandline arguments
TFXX_assert(cmdline.extra(), "missing output file");
std::string outfile=cmdline.next();
TFXX_assert(cmdline.extra(), "missing input file");
tfxx::cmdline::Tparsed arguments=parse_cmdline(cmdline, cmdlinekeys);
if ((arguments.size()>1) && opt.verbose)
{
cout << "NOTICE: file specific information (SRCE line and file FREE)" <<
endl
<< " will be taken from first file only!" << endl;
}
/*----------------------------------------------------------------------*/
// first of all read the filter commands
// we use an sff FREE block to store the lines - its so easy
sff::FREE filtercommands;
if (opt.readcommandfile)
{
if (opt.verbose)
{
cout << "read filter commands from file \""
<< opt.commandfile << "\"" << endl;
}
std::ifstream ifs(opt.commandfile.c_str());
while (ifs.good())
{
std::string line;
getline(ifs, line);
line=tfxx::string::trimws(line);
if (line.size() > 0)
{
filtercommands.append(line);
if (opt.verbose)
{ cout << ">> " << line << endl; }
}
}
}
// read commands from stdin
if (opt.readstdin)
{
if (opt.verbose)
{
cout << "read filter commands from stdin (terminate with ctrl-D)"
<< endl;
}
while (std::cin.good())
{
std::string line;
getline(std::cin, line);
line=tfxx::string::trimws(line);
if (line.size() > 0)
{
filtercommands.append(line);
if (opt.verbose)
{ cout << ">> " << line << endl; }
}
}
}
/*----------------------------------------------------------------------*/
// strip comments etc from filter commands
sff::FREE commands;
{
sff::FREE::Tlines::const_iterator line=filtercommands.lines.begin();
while (line != filtercommands.lines.end())
{
// skip comments
bool skip=false;
skip |= (line->substr(0,1)=="#");
skip |= (line->substr(0,3)=="rem");
skip |= (line->substr(0,3)=="end");
if (!skip) {
std::string command=(*line);
// replace comma by space
std::string::size_type i=command.find(",",i);
while (i!=std::string::npos)
{
command.replace(i,1," ");
i=command.find(",",i+1);
}
commands.append(command);
}
++line;
}
}
/*----------------------------------------------------------------------*/
// prepare file FREE block
sff::FREE filefree;
{
filefree.append(TIDOFI_VERSION);
filefree.append(TIDOFI_CVSID);
std::string line;
line="commands are read from";
if (opt.readstdin)
{
line += " stdin";
if (opt.readcommandfile)
{
line += " (first) and";
}
}
filefree.append(line);
line.clear();
if (opt.readcommandfile)
{
line += "file \"" + opt.commandfile + "\"";
filefree.append(line);
}
filefree.append("read commands:");
filefree.append(filtercommands);
filefree.append("output file name:");
filefree.append(outfile);
filefree.append("input file selection:");
tfxx::cmdline::Tparsed::const_iterator file=arguments.begin();
while (file != arguments.end())
{
filefree.append(" " + file->name);
line=" ";
tfxx::cmdline::Toptionlist::const_iterator option=file->options.begin();
while (option != file->options.end())
{
line += " " + option->key + ":" + option->value;
++option;
}
if (line.size()>2) { filefree.append(line); }
++file;
}
cout << filefree;
}
/* ----- END OF tidofi.cc ----- */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment