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

new option

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: 2228
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 2c280d74
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: noisymize.cc,v 1.5 2006-07-12 06:14:33 tforb Exp $
* $Id: noisymize.cc,v 1.6 2007-02-26 10:38:59 tforb Exp $
* \author Thomas Forbriger
* \date 27/06/2006
*
......@@ -14,13 +14,14 @@
* REVISIONS and CHANGES
* - 27/06/2006 V1.0 Thomas Forbriger
* - 11/07/2006 V1.1 keep result of full convolution length
* - 26/02/2007 V1.2 report factors
*
* ============================================================================
*/
#define NOISYMIZE_VERSION \
"NOISYMIZE V1.1 program reads a set of SFF traces, convolves them with white noise and stacks"
"NOISYMIZE V1.2 program reads a set of SFF traces, convolves them with white noise and stacks"
#define NOISYMIZE_CVSID \
"$Id: noisymize.cc,v 1.5 2006-07-12 06:14:33 tforb Exp $"
"$Id: noisymize.cc,v 1.6 2007-02-26 10:38:59 tforb Exp $"
#include <fstream>
#include <iostream>
......@@ -41,7 +42,7 @@ using std::endl;
// put all commandline settings into a struct
struct Options {
bool verbose, setnoiselength, overwrite;
bool verbose, setnoiselength, overwrite, reportfactors;
int noiselength;
std::string inputformat;
}; // struct Options
......@@ -71,7 +72,7 @@ int main(int iargc, char* argv[])
{
NOISYMIZE_VERSION "\n"
"usage: noisymize Zin Rin Zout Rout" "\n"
" [-v] [-type t] [-n n] [-o]" "\n"
" [-v] [-type t] [-n n] [-o] [-rf]" "\n"
" or: noisymize --help|-h" "\n"
};
......@@ -89,6 +90,7 @@ int main(int iargc, char* argv[])
"-type t input file type" "\n"
"-n n number of noise samples to use" "\n"
"-o overwrite output" "\n"
"-rf report factors" "\n"
};
// define commandline options
......@@ -103,8 +105,10 @@ int main(int iargc, char* argv[])
{"type",arg_yes,"sff"},
// 3: number of noise samples
{"n",arg_yes,"1"},
// 4: number of noise samples
// 4: overwrite output file
{"o",arg_no,"-"},
// 5: report factors
{"rf",arg_no,"-"},
{NULL}
};
......@@ -160,6 +164,7 @@ int main(int iargc, char* argv[])
opt.setnoiselength=cmdline.optset(3);
opt.noiselength=cmdline.int_arg(3);
opt.overwrite=cmdline.optset(4);
opt.reportfactors=cmdline.optset(5);
Filenames filename;
TFXX_assert(cmdline.extra(), "ERROR: missing filename Zin!");
......@@ -232,6 +237,9 @@ int main(int iargc, char* argv[])
Rit=Rindata.begin();
// results
Tseries Zseries, Rseries;
// scaling factors
Tseries fac=ts::rnd::dugauss(Zindata.size());
//
if (!opt.setnoiselength)
{
opt.noiselength=Zit->size();
......@@ -244,26 +252,35 @@ int main(int iargc, char* argv[])
<< " and stack." << endl;
}
bool initialize_result=true;
unsigned int itrace=0;
while((Zit!=Zindata.end()) && (Rit!=Rindata.end()))
{
if (opt.verbose) { cout << "*"; cout.flush(); }
Tseries noise=ts::rnd::dugauss(opt.noiselength);
Tseries fac=ts::rnd::dugauss(1);
if (opt.verbose) { cout << "+"; cout.flush(); }
if (initialize_result)
{ Zseries = fac(0)*ts::convolve(*Zit, noise); }
{ Zseries = fac(itrace)*ts::convolve(*Zit, noise); }
else
{ Zseries += fac(0)*ts::convolve(*Zit, noise); }
{ Zseries += fac(itrace)*ts::convolve(*Zit, noise); }
if (opt.verbose) { cout << "+"; cout.flush(); }
if (initialize_result)
{ Rseries = fac(0)*ts::convolve(*Rit, noise); }
{ Rseries = fac(itrace)*ts::convolve(*Rit, noise); }
else
{ Rseries += fac(0)*ts::convolve(*Rit, noise); }
{ Rseries += fac(itrace)*ts::convolve(*Rit, noise); }
initialize_result=false;
++Zit;
++Rit;
++itrace;
}
if (opt.verbose) { cout << endl; }
if (opt.reportfactors)
{
cout << "factors used for scaling:" << endl;
for (itrace=0; itrace<Zindata.size(); itrace++)
{
cout << "trace #" << itrace << ": " << fac(itrace) << endl;
}
}
/*----------------------------------------------------------------------*/
// 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