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

new scaling 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: 2232
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 7eb8541d
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: noisymize.cc,v 1.6 2007-02-26 10:38:59 tforb Exp $
* $Id: noisymize.cc,v 1.7 2007-03-02 11:26:47 tforb Exp $
* \author Thomas Forbriger
* \date 27/06/2006
*
......@@ -15,17 +15,19 @@
* - 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
* - 02/03/2007 V1.3 scale with offset
*
* ============================================================================
*/
#define NOISYMIZE_VERSION \
"NOISYMIZE V1.2 program reads a set of SFF traces, convolves them with white noise and stacks"
"NOISYMIZE V1.3 program reads a set of SFF traces, convolves them with white noise and stacks"
#define NOISYMIZE_CVSID \
"$Id: noisymize.cc,v 1.6 2007-02-26 10:38:59 tforb Exp $"
"$Id: noisymize.cc,v 1.7 2007-03-02 11:26:47 tforb Exp $"
#include <fstream>
#include <iostream>
#include <string>
#include <cmath>
#include <tfxx/commandline.h>
#include <tfxx/error.h>
#include <aff/series.h>
......@@ -44,6 +46,7 @@ using std::endl;
struct Options {
bool verbose, setnoiselength, overwrite, reportfactors;
int noiselength;
double offexp;
std::string inputformat;
}; // struct Options
......@@ -72,7 +75,7 @@ int main(int iargc, char* argv[])
{
NOISYMIZE_VERSION "\n"
"usage: noisymize Zin Rin Zout Rout" "\n"
" [-v] [-type t] [-n n] [-o] [-rf]" "\n"
" [-v] [-type t] [-n n] [-o] [-rf] [-s e]" "\n"
" or: noisymize --help|-h" "\n"
};
......@@ -91,6 +94,8 @@ int main(int iargc, char* argv[])
"-n n number of noise samples to use" "\n"
"-o overwrite output" "\n"
"-rf report factors" "\n"
"-s e scale seismograms with offset" "\n"
" the scaling factor is r**e, where r is the offset" "\n"
};
// define commandline options
......@@ -109,6 +114,8 @@ int main(int iargc, char* argv[])
{"o",arg_no,"-"},
// 5: report factors
{"rf",arg_no,"-"},
// 6: report factors
{"s",arg_yes,"0."},
{NULL}
};
......@@ -165,6 +172,7 @@ int main(int iargc, char* argv[])
opt.noiselength=cmdline.int_arg(3);
opt.overwrite=cmdline.optset(4);
opt.reportfactors=cmdline.optset(5);
opt.offexp=cmdline.double_arg(6);
Filenames filename;
TFXX_assert(cmdline.extra(), "ERROR: missing filename Zin!");
......@@ -235,6 +243,9 @@ int main(int iargc, char* argv[])
//
Zit=Zindata.begin();
Rit=Rindata.begin();
// source coordinates
sff::SRCE Zsrce=Zindata.fileheader.srce();
sff::SRCE Rsrce=Rindata.fileheader.srce();
// results
Tseries Zseries, Rseries;
// scaling factors
......@@ -255,6 +266,17 @@ int main(int iargc, char* argv[])
unsigned int itrace=0;
while((Zit!=Zindata.end()) && (Rit!=Rindata.end()))
{
// calculate offset and offset dependend scaling
sff::INFO Zinfo=Zit->header.info();
sff::INFO Rinfo=Rit->header.info();
double Zoffset=sff::offset(Zsrce, Zinfo);
double Roffset=sff::offset(Rsrce, Rinfo);
double offerr=(Zoffset/Roffset)-1.;
if (offerr < 0.) { offerr=-offerr; }
TFXX_assert((offerr < 1.e-4),
"ERROR: offset of R- and Z-component are inconsistent!");
fac(itrace) *= std::pow(Zoffset, opt.offexp);
// go
if (opt.verbose) { cout << "*"; cout.flush(); }
Tseries noise=ts::rnd::dugauss(opt.noiselength);
if (opt.verbose) { cout << "+"; cout.flush(); }
......
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