Commit d87886ce 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: 2143
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 17e012a4
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* ---------------------------------------------------------------------------- * ----------------------------------------------------------------------------
* *
* $Id: noisymize.cc,v 1.1 2006-06-29 07:11:44 tforb Exp $ * $Id: noisymize.cc,v 1.2 2006-06-29 12:59:21 tforb Exp $
* \author Thomas Forbriger * \author Thomas Forbriger
* \date 27/06/2006 * \date 27/06/2006
* *
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#define NOISYMIZE_VERSION \ #define NOISYMIZE_VERSION \
"NOISYMIZE V1.0 program reads a set of SFF traces, convolves them with white noise and stacks" "NOISYMIZE V1.0 program reads a set of SFF traces, convolves them with white noise and stacks"
#define NOISYMIZE_CVSID \ #define NOISYMIZE_CVSID \
"$Id: noisymize.cc,v 1.1 2006-06-29 07:11:44 tforb Exp $" "$Id: noisymize.cc,v 1.2 2006-06-29 12:59:21 tforb Exp $"
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <tsxx/tsxx.h> #include <tsxx/tsxx.h>
#include <tsxx/convolve.h> #include <tsxx/convolve.h>
#include <tsxx/sffheaders.h> #include <tsxx/sffheaders.h>
#include <tsxx/noise.h>
#include <datreadxx/readany.h> #include <datreadxx/readany.h>
using std::cout; using std::cout;
...@@ -38,7 +39,8 @@ using std::endl; ...@@ -38,7 +39,8 @@ using std::endl;
// put all commandline settings into a struct // put all commandline settings into a struct
struct Options { struct Options {
bool verbose; bool verbose, setnoiselength;
int noiselength;
std::string inputformat; std::string inputformat;
}; // struct Options }; // struct Options
...@@ -67,7 +69,7 @@ int main(int iargc, char* argv[]) ...@@ -67,7 +69,7 @@ int main(int iargc, char* argv[])
{ {
NOISYMIZE_VERSION "\n" NOISYMIZE_VERSION "\n"
"usage: noisymize Zin Rin Zout Rout" "\n" "usage: noisymize Zin Rin Zout Rout" "\n"
"usage: noisymize [-v] [-type t]" "\n" "usage: noisymize [-v] [-type t] [-n n]" "\n"
" or: noisymize --help|-h" "\n" " or: noisymize --help|-h" "\n"
}; };
...@@ -83,6 +85,7 @@ int main(int iargc, char* argv[]) ...@@ -83,6 +85,7 @@ int main(int iargc, char* argv[])
"\n" "\n"
"-v be verbose" "\n" "-v be verbose" "\n"
"-type t input file type" "\n" "-type t input file type" "\n"
"-n n number of noise samples to use" "\n"
}; };
// define commandline options // define commandline options
...@@ -95,6 +98,8 @@ int main(int iargc, char* argv[]) ...@@ -95,6 +98,8 @@ int main(int iargc, char* argv[])
{"v",arg_no,"-"}, {"v",arg_no,"-"},
// 2: input format // 2: input format
{"type",arg_yes,"sff"}, {"type",arg_yes,"sff"},
// 3: number of noise samples
{"n",arg_yes,"1"},
{NULL} {NULL}
}; };
...@@ -147,6 +152,8 @@ int main(int iargc, char* argv[]) ...@@ -147,6 +152,8 @@ int main(int iargc, char* argv[])
Options opt; Options opt;
opt.verbose=cmdline.optset(1); opt.verbose=cmdline.optset(1);
opt.inputformat=cmdline.string_arg(2); opt.inputformat=cmdline.string_arg(2);
opt.setnoiselength=cmdline.optset(3);
opt.noiselength=cmdline.int_arg(3);
Filenames filename; Filenames filename;
TFXX_assert(cmdline.extra(), "ERROR: missing filename Zin!"); TFXX_assert(cmdline.extra(), "ERROR: missing filename Zin!");
...@@ -214,6 +221,33 @@ int main(int iargc, char* argv[]) ...@@ -214,6 +221,33 @@ int main(int iargc, char* argv[])
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
// go and noisymize data // go and noisymize data
// --------------------- // ---------------------
//
Tfile::Tbase::const_iterator Zit=Zindata.begin();
Tfile::Tbase::const_iterator Rit=Rindata.begin();
Tseries Zseries(Zit->size()), Rseries(Zit->size());
if (!opt.setnoiselength)
{
opt.noiselength=Zit->size();
}
if (opt.verbose)
{
cout << "convolve " << Zit->size() " data samples (each trace) "
<< "with" << endl
<< opt.noiselength << " samples of uniform gaussian noise"
<< " and stack." << endl;
}
while((Zit!=Zindata.end()) && (Rit!=Rindata.end()))
{
Tseries noise=ts::rnd::dugauss(opt.noiselength);
Tseries fac=ts::rnd::dugauss(1);
Zseries += fac(1)*ts::convolve(*Zit, noise);
Rseries += fac(1)*ts::convolve(*Rit, noise);
++Zit;
++Rit;
}
/*----------------------------------------------------------------------*/
// write result
} }
......
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