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

added normalization

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: 3011
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent e4c32a88
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: gatherdiff.cc,v 1.1 2005-03-15 18:36:20 tforb Exp $
* $Id: gatherdiff.cc,v 1.2 2010-03-09 20:51:48 tforb Exp $
* \author Thomas Forbriger
* \date 15/03/2005
*
......@@ -19,7 +19,7 @@
#define GATHERDIFF_VERSION \
"GATHERDIFF V1.0 calculate difference between shot gathers"
#define GATHERDIFF_CVSID \
"$Id: gatherdiff.cc,v 1.1 2005-03-15 18:36:20 tforb Exp $"
"$Id: gatherdiff.cc,v 1.2 2010-03-09 20:51:48 tforb Exp $"
#include <fstream>
#include <iostream>
......@@ -30,6 +30,7 @@
#include <datreadxx/sff.h>
#include <aff/series.h>
#include <aff/seriesoperators.h>
#include <aff/functions/absmax.h>
using std::cout;
using std::cerr;
......@@ -38,7 +39,7 @@ using std::endl;
/*----------------------------------------------------------------------*/
struct Options {
bool verbose, debug;
bool verbose, debug, normalize;
}; // struct Options
typedef aff::Series<double> Tseries;
......@@ -52,7 +53,7 @@ int main(int iargc, char* argv[])
char usage_text[]=
{
GATHERDIFF_VERSION "\n"
"usage: gatherdiff infile1 infile2 outfile [-v]" "\n"
"usage: gatherdiff infile1 infile2 outfile [-v] [-n]" "\n"
" or: gatherdiff --help|-h" "\n"
};
......@@ -72,6 +73,7 @@ int main(int iargc, char* argv[])
"outfile name of output file (outfile=infile1-infile2)" "\n"
"\n"
"-v be verbose"
"-n normalize input time series to their absolute maximum" "\n"
"\n"
GATHERDIFF_CVSID
};
......@@ -86,6 +88,8 @@ int main(int iargc, char* argv[])
{"v",arg_no,"-"},
// 2: debug mode
{"DEBUG",arg_no,"-"},
// 3: normalize
{"n",arg_no,"-"},
{NULL}
};
......@@ -134,6 +138,7 @@ int main(int iargc, char* argv[])
Options opt;
opt.verbose=cmdline.optset(1);
opt.debug=cmdline.optset(2);
opt.normalize=cmdline.optset(3);
TFXX_assert(cmdline.extra(), "ERROR: missing parameter: infile1!");
std::string infile1=cmdline.next();
......@@ -213,6 +218,21 @@ int main(int iargc, char* argv[])
"ERROR: coordinates do not match!");
wid2out=wid2in1;
wid2out.channel="dif";
if (opt.normalize)
{
outtracefree.append("input series are normalized to their absolute maximum of 1");
double max1=aff::func::absmax(series1);
double max2=aff::func::absmax(series2);
if (opt.verbose)
{
cout << "normalize input time series to absolute maximum of 1" <<
endl;
cout << "absolute maximum of first input series: " << max1 << endl;
cout << "absolute maximum of second input series: " << max2 << endl;
}
series1 /= max1;
series2 /= max2;
}
Tseries outseries=series1-series2;
os << outseries;
os << wid2out;
......
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