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

proceeding

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: 2367
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 2483eff5
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* ---------------------------------------------------------------------------- * ----------------------------------------------------------------------------
* *
* $Id: tapers.cc,v 1.1 2007-09-06 12:48:08 tforb Exp $ * $Id: tapers.cc,v 1.2 2007-09-07 09:42:34 tforb Exp $
* \author Thomas Forbriger * \author Thomas Forbriger
* \date 06/09/2007 * \date 06/09/2007
* *
...@@ -19,9 +19,10 @@ ...@@ -19,9 +19,10 @@
#define TF_TAPERS_CC_VERSION \ #define TF_TAPERS_CC_VERSION \
"TF_TAPERS_CC V1.0 " "TF_TAPERS_CC V1.0 "
#define TF_TAPERS_CC_CVSID \ #define TF_TAPERS_CC_CVSID \
"$Id: tapers.cc,v 1.1 2007-09-06 12:48:08 tforb Exp $" "$Id: tapers.cc,v 1.2 2007-09-07 09:42:34 tforb Exp $"
#include <tsxx/tapers.h> #include <tsxx/tapers.h>
#include <cmath>
namespace ts { namespace ts {
...@@ -31,7 +32,7 @@ namespace ts { ...@@ -31,7 +32,7 @@ namespace ts {
void Hanning::init(const int& f, const int& l) const void Hanning::init(const int& f, const int& l) const
{ {
Mf=f; Mf=f;
Mfac= Mfac=3.1415926535897931/(l-f);
} // void Hanning::init(const int& f, const int& l) const } // void Hanning::init(const int& f, const int& l) const
double Hanning::value(const int& i) const double Hanning::value(const int& i) const
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* ---------------------------------------------------------------------------- * ----------------------------------------------------------------------------
* *
* $Id: tapers.h,v 1.1 2007-09-06 12:48:08 tforb Exp $ * $Id: tapers.h,v 1.2 2007-09-07 09:42:34 tforb Exp $
* \author Thomas Forbriger * \author Thomas Forbriger
* \date 06/09/2007 * \date 06/09/2007
* *
...@@ -23,34 +23,49 @@ ...@@ -23,34 +23,49 @@
#define TF_TAPERS_H_VERSION \ #define TF_TAPERS_H_VERSION \
"TF_TAPERS_H V1.0 " "TF_TAPERS_H V1.0 "
#define TF_TAPERS_H_CVSID \ #define TF_TAPERS_H_CVSID \
"$Id: tapers.h,v 1.1 2007-09-06 12:48:08 tforb Exp $" "$Id: tapers.h,v 1.2 2007-09-07 09:42:34 tforb Exp $"
namespace ts { namespace ts {
namespace tapers { namespace tapers {
/*! \brief Taper abstract base class.
*
* Use a taper by creating an instance of a derived class, passing the
* appropriate parameters to the constructor.
*
* Then pass any container to function apply.
*/
class Taper { class Taper {
public: public:
virtual ~Taper() { }
//! apply taper to series container c. //! apply taper to series container c.
template<class C> template<class C>
void apply(C c) const; void apply(C c) const;
private: private:
//! will be called prior to value to set ranges. //! will be called prior to value to set ranges.
virtual void init(const int& f, const int& l) const; virtual void init(const int& f, const int& l) const =0;
//! returns taper value for sample index i. //! returns taper value for sample index i.
virtual double value(const int& i) const; virtual double value(const int& i) const =0;
}; // class Taper }; // class Taper
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
/*! \brief Provides a Hanning taper (no parameters):
*/
class Hanning: public Taper { class Hanning: public Taper {
public:
~Hanning() { }
private: private:
void init(const int& f, const int& l) const; void init(const int& f, const int& l) const;
double value(const int& i) const; double value(const int& i) const;
mutable int Mf; //<! first index
mutable double Mfac; //<! sine function argument scaling
}; // class Hanning }; // class Hanning
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
//! inline function for template argument
template<class C> template<class C>
void Taper::apply(C c) const void Taper::apply(C c) const
{ {
...@@ -59,7 +74,7 @@ namespace ts { ...@@ -59,7 +74,7 @@ namespace ts {
{ c(i) *= this->value(i); } { c(i) *= this->value(i); }
} // template<class C> void Taper::apply(C c) } // template<class C> void Taper::apply(C c)
} // namespace } // namespace tapers
} // namespace ts } // namespace ts
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* ---------------------------------------------------------------------------- * ----------------------------------------------------------------------------
* *
* $Id: tstest.cc,v 1.8 2006-11-23 09:47:41 tforb Exp $ * $Id: tstest.cc,v 1.9 2007-09-07 09:42:34 tforb Exp $
* \author Thomas Forbriger * \author Thomas Forbriger
* \date 20/12/2003 * \date 20/12/2003
* *
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
#define TSTEST_VERSION \ #define TSTEST_VERSION \
"TSTEST V1.2 test time series modules" "TSTEST V1.2 test time series modules"
#define TSTEST_CVSID \ #define TSTEST_CVSID \
"$Id: tstest.cc,v 1.8 2006-11-23 09:47:41 tforb Exp $" "$Id: tstest.cc,v 1.9 2007-09-07 09:42:34 tforb Exp $"
#include <iostream> #include <iostream>
#include <tsxx/tsxx.h> #include <tsxx/tsxx.h>
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#include <tsxx/convolve.h> #include <tsxx/convolve.h>
#include <tsxx/random.h> #include <tsxx/random.h>
#include <tsxx/dropcontainer.h> #include <tsxx/dropcontainer.h>
#include <tsxx/tapers.h>
using std::cout; using std::cout;
using std::cerr; using std::cerr;
...@@ -54,7 +55,7 @@ using std::endl; ...@@ -54,7 +55,7 @@ using std::endl;
struct Options { struct Options {
bool convtest1, convtest2; bool convtest1, convtest2;
bool randomnoise; bool randomnoise;
bool droptest; bool droptest, tapertest;
}; // struct Options }; // struct Options
int main(int iargc, char* argv[]) int main(int iargc, char* argv[])
...@@ -64,7 +65,7 @@ int main(int iargc, char* argv[]) ...@@ -64,7 +65,7 @@ int main(int iargc, char* argv[])
char usage_text[]= char usage_text[]=
{ {
TSTEST_VERSION "\n" TSTEST_VERSION "\n"
"usage: tstest [-c1] [-c2] [-r] [-drop]" "\n" "usage: tstest [-c1] [-c2] [-r] [-drop] [-tap]" "\n"
" or: tstest --help|-h" "\n" " or: tstest --help|-h" "\n"
}; };
...@@ -75,6 +76,7 @@ int main(int iargc, char* argv[]) ...@@ -75,6 +76,7 @@ int main(int iargc, char* argv[])
"-c2 convolution test 2" "\n" "-c2 convolution test 2" "\n"
"-r random noise test" "\n" "-r random noise test" "\n"
"-drop drop container test" "\n" "-drop drop container test" "\n"
"-tap test tapers" "\n"
"\n" "\n"
TSTEST_CVSID TSTEST_CVSID
}; };
...@@ -95,6 +97,8 @@ int main(int iargc, char* argv[]) ...@@ -95,6 +97,8 @@ int main(int iargc, char* argv[])
{"r",arg_no,"-"}, {"r",arg_no,"-"},
// 5: drop container test // 5: drop container test
{"drop",arg_no,"-"}, {"drop",arg_no,"-"},
// 6: taper test
{"tap",arg_no,"-"},
{NULL} {NULL}
}; };
...@@ -117,35 +121,12 @@ int main(int iargc, char* argv[]) ...@@ -117,35 +121,12 @@ int main(int iargc, char* argv[])
exit(0); exit(0);
} }
/*
// dummy operation: print option settings
for (int iopt=0; iopt<2; iopt++)
{
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;
}
while (cmdline.extra()) { cout << cmdline.next() << endl; }
// dummy operation: print rest of command line
while (cmdline.extra()) { cout << cmdline.next() << endl; }
*/
Options opt; Options opt;
opt.convtest1=cmdline.optset(2); opt.convtest1=cmdline.optset(2);
opt.convtest2=cmdline.optset(3); opt.convtest2=cmdline.optset(3);
opt.randomnoise=cmdline.optset(4); opt.randomnoise=cmdline.optset(4);
opt.droptest=cmdline.optset(5); opt.droptest=cmdline.optset(5);
opt.tapertest=cmdline.optset(6);
/*======================================================================*/ /*======================================================================*/
...@@ -227,6 +208,29 @@ int main(int iargc, char* argv[]) ...@@ -227,6 +208,29 @@ int main(int iargc, char* argv[])
for (int i=b.f(); i<=b.l(); ++i) { d4.drop(b(i)); } for (int i=b.f(); i<=b.l(); ++i) { d4.drop(b(i)); }
DUMP( d4.container() ); DUMP( d4.container() );
} }
/*======================================================================*/
if (opt.tapertest)
{
cout << "test taper" << endl;
aff::Series<double> a(-5,5);
a=1.;
DUMP( a );
ts::tapers::Hanning h;
h.apply(a);
DUMP( a );
aff::Series<double> b(-50,50);
b=1;
h.apply(b);
for (int i=b.f(); i<=b.l(); ++i)
{
cout << i << " " << b(i) << endl;
}
}
} }
/* ----- END OF tstest.cc ----- */ /* ----- END OF tstest.cc ----- */
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* ---------------------------------------------------------------------------- * ----------------------------------------------------------------------------
* *
* $Id: foutra.cc,v 1.1 2006-07-26 06:17:15 tforb Exp $ * $Id: foutra.cc,v 1.2 2007-09-07 09:42:35 tforb Exp $
* \author Thomas Forbriger * \author Thomas Forbriger
* \date 25/07/2006 * \date 25/07/2006
* *
...@@ -19,20 +19,29 @@ ...@@ -19,20 +19,29 @@
#define FOUTRA_VERSION \ #define FOUTRA_VERSION \
"FOUTRA V1.0 Fourier transforms" "FOUTRA V1.0 Fourier transforms"
#define FOUTRA_CVSID \ #define FOUTRA_CVSID \
"$Id: foutra.cc,v 1.1 2006-07-26 06:17:15 tforb Exp $" "$Id: foutra.cc,v 1.2 2007-09-07 09:42:35 tforb Exp $"
#include <iostream> #include <iostream>
#include <tfxx/commandline.h> #include <tfxx/commandline.h>
#include <aff/series.h> #include <aff/series.h>
#include <tsxx/tsxx.h> #include <tsxx/tsxx.h>
#include <tsxx/sffheaders.h> #include <tsxx/sffheaders.h>
#include <fstream>
#include <tfxx/error.h>
#include <tfxx/rangestring.h>
#include <tfxx/xcmdline.h>
#include <tfxx/misc.h>
#include <tfxx/handle.h>
#include <sffostream.h>
#include <datreadxx/readany.h>
using std::cout; using std::cout;
using std::cerr; using std::cerr;
using std::endl; using std::endl;
struct Options { struct Options {
bool verbose; bool verbose, overwrite, debug;
std::string inputformat;
}; // struct Options }; // struct Options
// values type to be used for samples // values type to be used for samples
...@@ -44,6 +53,9 @@ typedef aff::Series<Tvalue> Tseries; ...@@ -44,6 +53,9 @@ typedef aff::Series<Tvalue> Tseries;
// full featured time series file // full featured time series file
typedef ts::sff::File<Tseries> Tfile; typedef ts::sff::File<Tseries> Tfile;
typedef ts::TDsfftimeseries Ttimeseries;
typedef Ttimeseries::Tseries Tseries;
int main(int iargc, char* argv[]) int main(int iargc, char* argv[])
{ {
...@@ -51,7 +63,8 @@ int main(int iargc, char* argv[]) ...@@ -51,7 +63,8 @@ int main(int iargc, char* argv[])
char usage_text[]= char usage_text[]=
{ {
FOUTRA_VERSION "\n" FOUTRA_VERSION "\n"
"usage: foutra infile outfile [-v]" "\n" "usage: foutra [-v] [-o] [-type type] [-D]" "\n"
" outfile infile [t:T] [infile [t:T] ...]" "\n"
" or: foutra --help|-h" "\n" " or: foutra --help|-h" "\n"
}; };
...@@ -59,6 +72,15 @@ int main(int iargc, char* argv[]) ...@@ -59,6 +72,15 @@ int main(int iargc, char* argv[])
char help_text[]= char help_text[]=
{ {
FOUTRA_CVSID FOUTRA_CVSID
"\n"
"outfile output filename" "\n"
"infile input filename" "\n"
" t:T select traces T, where T may be any range" "\n"
" specification like \'3-4\' or \'5,6,7-12,20\'" "\n"
"-v be verbose" "\n"
"-D debug mode" "\n"
"-o overwrite output" "\n"
"-type type select input file type" "\n"
}; };
// define commandline options // define commandline options
...@@ -69,9 +91,20 @@ int main(int iargc, char* argv[]) ...@@ -69,9 +91,20 @@ int main(int iargc, char* argv[])
{"help",arg_no,"-"}, {"help",arg_no,"-"},
// 1: verbose mode // 1: verbose mode
{"v",arg_no,"-"}, {"v",arg_no,"-"},
// 2: overwrite mode
{"o",arg_no,"-"},
// 3: input format
{"type",arg_yes,"sff"},
// 4: debug mode
{"D",arg_no,"-"},
{NULL} {NULL}
}; };
static const char tracekey[]="t";
// define commandline argument modifier keys
static const char* cmdlinekeys[]={tracekey, 0};
// no arguments? print usage... // no arguments? print usage...
if (iargc<2) if (iargc<2)
{ {
...@@ -87,35 +120,134 @@ int main(int iargc, char* argv[]) ...@@ -87,35 +120,134 @@ int main(int iargc, char* argv[])
{ {
cerr << usage_text << endl; cerr << usage_text << endl;
cerr << help_text << endl; cerr << help_text << endl;
datread::supported_data_types(cerr);
datread::online_help(cerr);
exit(0); exit(0);
} }
/* Options opt;
// dummy operation: print option settings opt.verbose=cmdline.optset(1);
for (int iopt=0; iopt<2; iopt++) opt.overwrite=cmdline.optset(2);
opt.inputformat=cmdline.string_arg(3);
opt.debug=cmdline.optset(4);
if (opt.verbose)
{ cout << FOUTRA_VERSION << endl << FOUTRA_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 << "option: '" << options[iopt].opt_string << "'" << endl; cout << "NOTICE: file specific information (SRCE line and file FREE)" <<
if (cmdline.optset(iopt)) { cout << " option was set"; } endl
else { cout << "option was not set"; } << " will be taken from first file only!" << endl;
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;
} }
while (cmdline.extra()) { cout << cmdline.next() << endl; }
// dummy operation: print rest of command line /*======================================================================*/
while (cmdline.extra()) { cout << cmdline.next() << endl; } // start processing
*/
// open output file
// ----------------
if (opt.verbose) { cout << "open output file " << outfile << endl; }
// check if output file exists and open
if (!opt.overwrite)
{
std::ifstream file(outfile.c_str(),std::ios_base::in);
TFXX_assert((!file.good()),"ERROR: output file exists!");
}
std::ofstream ofs(outfile.c_str());
sff::SFFostream<Tseries> os(ofs, opt.debug);
// prepare file FREE block
sff::FREE filefree;
filefree.append(FOUTRA_VERSION);
// set flag to process header of first input file
bool firstfile=true;
// cycle through all input files
// -----------------------------
tfxx::cmdline::Tparsed::const_iterator infile=arguments.begin();
while (infile != arguments.end())
{
// open input file
if (opt.verbose) { cout << "open input file " << infile->name << endl; }
std::ifstream ifs(infile->name.c_str());
datread::ianystream is(ifs, datread::anyID(opt.inputformat));
// handle file header
if (firstfile)
{
if (is.hasfree())
{
sff::FREE infilefree;
is >> infilefree;
filefree.append("block read from first input file:");
filefree.append(infilefree);
}
os << filefree;
if (is.hassrce())
{
sff::SRCE insrceline;
is >> insrceline;
os << insrceline;
}
}
// cycle through traces of input file
// ----------------------------------
// setup trace selection
typedef tfxx::RangeList<int> Trangelist;
bool doselect=infile->haskey(tracekey);
Trangelist traceranges=
tfxx::string::rangelist<Trangelist::Tvalue>(infile->value(tracekey));
int itrace=0;
while (is.good())
{
++itrace;
if ((!doselect) || traceranges.contains(itrace))
{
TFXX_debug(opt.debug, "main", "process trace #" << itrace );
if (opt.verbose)
{ std::cout << " process trace #" << itrace << std::endl; }
Tseries series;
is >> series;
sff::WID2 wid2;
is >> wid2;
TFXX_debug(opt.debug, "main",
" series and WID2 are read");
Ttimeseries outseries(series, wid2);
os << outseries.series();
os << outseries.header;
TFXX_debug(opt.debug, "main",
" series and WID are written");
if (is.hasinfo()) { sff::INFO info; is >> info; os << info; }
if (is.hasfree() || true)
{
sff::FREE tracefree;
is >> tracefree;
tracefree.append(FOUTRA_VERSION);
tracefree.append("read from file " + infile->name);
os << tracefree;
}
TFXX_debug(opt.debug, "main",
"trace #" << itrace << " successfully processed");
}
else
{
TFXX_debug(opt.debug, "main", "skip trace #" << itrace );
if (opt.verbose)
{ std::cout << " skip trace #" << itrace << std::endl; }
is.skipseries();
}
}
// go to next file
firstfile=false;
++infile;
}
Options opt;
opt.verbose=cmdline.optset(1);
} }
/* ----- END OF foutra.cc ----- */ /* ----- END OF foutra.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