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

took up soutifu implementation

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: 3994
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 10930514
......@@ -115,6 +115,14 @@ fidasexx: fidasexx.o
-ltfxx -ltsxx -ldatrwxx -lsffxx -lgsexx -ltime++ -laff \
-L$(LOCLIBDIR) $(CXXFLAGS) $(FLAGS)
soutifu: soutifu.o
$(CXX) -o $@ $^ -I$(LOCINCLUDEDIR) \
-lstfinv \
-lfourierxx -lfftw3 \
-llinearxx -llapack -lblas \
-ltfxx -ltsxx -ldatrwxx -lsffxx -lgsexx -ltime++ -laff \
-L$(LOCLIBDIR) $(CXXFLAGS) $(FLAGS)
#======================================================================
# documentation part
# ------------------
......
......@@ -22,12 +22,30 @@
"$Id$"
#include <iostream>
#include <fstream>
#include <tfxx/error.h>
#include <tfxx/commandline.h>
#include <tsxx/sffheaders.h>
#include <datrwxx/readany.h>
#include <stfinv/stfinvany.h>
/*----------------------------------------------------------------------*/
using std::cout;
using std::cerr;
using std::endl;
/*----------------------------------------------------------------------*/
struct Options {
bool verbose, debug, overwrite;
bool writestf, writeconvolved;
std::string stffilename, convolvedfilename;
datrw::Eformat datafileformat;
}; // struct Options
/*----------------------------------------------------------------------*/
int main(int iargc, char* argv[])
{
......@@ -35,14 +53,32 @@ int main(int iargc, char* argv[])
char usage_text[]=
{
SOUTIFU_VERSION "\n"
"usage: soutifu" "\n"
"usage: soutifu [-v] [-o] [-wc f] [-ws f] [--type f] [--para p]\n"
" parameters data synthetics" "\n"
" or: soutifu --help|-h" "\n"
" or: soutifu --xhelp" "\n"
};
// define full help text
char help_text[]=
{
SOUTIFU_CVSID
SOUTIFU_CVSID "\n"
"\n"
"Calculate optimized source time function to minimize misfit\n"
"between recorded data and synthetic waveforms.\n"
"\n"
"data name of file containing recorded data\n"
"synthetics name of file containing synthetic data\n"
"parameters parameterstring to select STF engine\n"
" The string consists of an ID selecting one of the\n"
" available engines and a set of options an parameters\n"
" to be passed to this engine.\n"
"\n"
"-v be verbose\n"
"-o overwrite existing output files\n"
"--type f use file format type \"f\" for file I/O\n"
"-wc f write convolved synthetics to file \"f\"\n"
"-ws f write source time function to file \"f\"\n"
};
// define commandline options
......@@ -53,6 +89,16 @@ int main(int iargc, char* argv[])
{"help",arg_no,"-"},
// 1: verbose mode
{"v",arg_no,"-"},
// 2: overwrite mode
{"o",arg_no,"-"},
// 3: file format
{"type",arg_yes,"sff"},
// 4: name of convolved synthetics
{"wc",arg_yes,"-"},
// 5: name of source time function
{"ws",arg_yes,"-"},
// 6: present full details
{"xhelp",arg_no,"-"},
{NULL}
};
......@@ -67,34 +113,63 @@ int main(int iargc, char* argv[])
Commandline cmdline(iargc, argv, options);
// help requested? print full help text...
if (cmdline.optset(0))
if (cmdline.optset(0) || cmdline.optset(6))
{
cerr << usage_text << endl;
cerr << help_text << endl;
datrw::supported_input_data_types(cerr);
if (cmdline.optset(6)) { datrw::online_help(cerr); }
cerr << endl;
stfinv::STFEngine::help(cerr);
cerr << endl;
if (cmdline.optset(6)) { stfinv::help(cerr); }
exit(0);
}
// dummy operation: print option settings
for (int iopt=0; iopt<2; iopt++)
/*----------------------------------------------------------------------*/
// read options and parameters
Options opt;
opt.verbose=cmdline.optset(1);
opt.overwrite=cmdline.optset(2);
opt.datafileformat=datrw::anyID(cmdline.string_arg(3));
opt.writeconvolved=cmdline.optset(4);
opt.convolvedfilename=cmdline.string_arg(4);
opt.writestf=cmdline.optset(5);
opt.stffilename=cmdline.string_arg(5);
TFXX_assert(cmdline.extra(), "missing parameter string");
std::string parameters=cmdline.next();
TFXX_assert(cmdline.extra(), "missing recorded data file name");
std::string datafilename=cmdline.next();
TFXX_assert(cmdline.extra(), "missing synthetics data file name");
std::string syntheticsfilename=cmdline.next();
/*----------------------------------------------------------------------*/
// go
// --
// read input data
// ---------------
typedef aff::Series<double> Tseries;
typedef ts::sff::File<Tseries> Tfile;
Tfile recordeddata;
Tfile syntheticdata;
std::ios_base::openmode iopenmode
=datrw::ianystream::openmode(opt.datafileformat);
if (opt.verbose) { cout << "open input file " << datafilename << endl; }
{
cout << "option: '" << options[iopt].opt_string << "'" << endl;
if (cmdline.optset(iopt)) { cout << " option was set"; }
else { cout << "option was not set"; }
cout << endl;
cout << " argument (string): '" << cmdline.string_arg(iopt) << "'" << endl;
cout << " argument (int): '" << cmdline.int_arg(iopt) << "'" << endl;
cout << " argument (long): '" << cmdline.long_arg(iopt) << "'" << endl;
cout << " argument (float): '" << cmdline.float_arg(iopt) << "'" << endl;
cout << " argument (double): '" << cmdline.double_arg(iopt) << "'" << endl;
cout << " argument (bool): '";
if (cmdline.bool_arg(iopt))
{ cout << "true"; } else { cout << "false"; }
cout << "'" << endl;
std::ifstream ifs(datafilename.c_str(), iopenmode);
datrw::ianystream is(ifs, opt.datafileformat);
recordeddata.read(is.idatstream(), opt.verbose);
}
while (cmdline.extra()) { cout << cmdline.next() << endl; }
// dummy operation: print rest of command line
while (cmdline.extra()) { cout << cmdline.next() << endl; }
if (opt.verbose) { cout << "open input file " << syntheticsfilename << endl; }
{
std::ifstream ifs(syntheticsfilename.c_str(), iopenmode);
datrw::ianystream is(ifs, opt.datafileformat);
syntheticdata.read(is.idatstream(), opt.verbose);
}
}
/* ----- END OF soutifu.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