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

new program

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: 1665
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 5a4cffb1
# --------------------------------------- # ---------------------------------------
# #
# $Id: Makefile,v 1.24 2005-02-01 14:49:52 tforb Exp $ # $Id: Makefile,v 1.25 2005-03-15 18:36:20 tforb Exp $
# #
# Makefile fuer tools /src/ts/wf # Makefile fuer tools /src/ts/wf
# #
...@@ -57,7 +57,7 @@ phasedsignals hamres siggen smoos dise: %: %.o ...@@ -57,7 +57,7 @@ phasedsignals hamres siggen smoos dise: %: %.o
-L$(LOCLIBDIR) -L$(LOCLIBDIR)
newprog $@ newprog $@
autocorr cross tidofi fredofi sigfit: %: %.o gatherdiff autocorr cross tidofi fredofi sigfit: %: %.o
$(CXX) -o $@ $^ -I$(LOCINCLUDEDIR) -lsffxx -llinearxx -lgsexx -laff \ $(CXX) -o $@ $^ -I$(LOCINCLUDEDIR) -lsffxx -llinearxx -lgsexx -laff \
-ltsxx -ldatreadxx -ltfxx -ltime++ \ -ltsxx -ldatreadxx -ltfxx -ltime++ \
-llapack -lblas -lg2c -lm\ -llapack -lblas -lg2c -lm\
......
/*! \file gatherdiff.cc
* \brief calculate difference between shot gathers
*
* ----------------------------------------------------------------------------
*
* $Id: gatherdiff.cc,v 1.1 2005-03-15 18:36:20 tforb Exp $
* \author Thomas Forbriger
* \date 15/03/2005
*
* calculate difference between shot gathers
*
* Copyright (c) 2005 by Thomas Forbriger (BFO Schiltach)
*
* REVISIONS and CHANGES
* - 15/03/2005 V1.0 Thomas Forbriger
*
* ============================================================================
*/
#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 $"
#include <fstream>
#include <iostream>
#include <string>
#include <tfxx/commandline.h>
#include <tfxx/error.h>
#include <sffostream.h>
#include <datreadxx/sff.h>
#include <aff/series.h>
#include <aff/seriesoperators.h>
using std::cout;
using std::cerr;
using std::endl;
/*----------------------------------------------------------------------*/
struct Options {
bool verbose, debug;
}; // struct Options
typedef aff::Series<double> Tseries;
/*======================================================================*/
int main(int iargc, char* argv[])
{
// define usage information
char usage_text[]=
{
GATHERDIFF_VERSION "\n"
"usage: gatherdiff infile1 infile2 outfile [-v]" "\n"
" or: gatherdiff --help|-h" "\n"
};
// define full help text
char help_text[]=
{
"This program takes two SFF data files as input. It is assumed" "\n"
"that both conatin full record gathers with identical recording" "\n"
"parameters. Typically these will be two sets of synthetic" "\n"
"seismograms that were calculated for different subsurface" "\n"
"models. The residual of these two sets is calculated and written" "\n"
"to the output, together with shot an receiver coordinates of" "\n"
"the first input set." "\n"
"\n"
"infile1 name of first SFF input file" "\n"
"infile2 name of second SFF input file" "\n"
"outfile name of output file (outfile=infile1-infile2)" "\n"
"\n"
"-v be verbose"
"\n"
GATHERDIFF_CVSID
};
// define commandline options
using namespace tfxx::cmdline;
static Declare options[]=
{
// 0: print help
{"help",arg_no,"-"},
// 1: verbose mode
{"v",arg_no,"-"},
// 2: debug mode
{"DEBUG",arg_no,"-"},
{NULL}
};
// no arguments? print usage...
if (iargc<4)
{
cerr << usage_text << endl;
exit(0);
}
// collect options from commandline
Commandline cmdline(iargc, argv, options);
// help requested? print full help text...
if (cmdline.optset(0))
{
cerr << usage_text << endl;
cerr << help_text << endl;
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;
opt.verbose=cmdline.optset(1);
opt.debug=cmdline.optset(2);
TFXX_assert(cmdline.extra(), "ERROR: missing parameter: infile1!");
std::string infile1=cmdline.next();
TFXX_assert(cmdline.extra(), "ERROR: missing parameter: infile2!");
std::string infile2=cmdline.next();
TFXX_assert(cmdline.extra(), "ERROR: missing parameter: outfile!");
std::string outfile=cmdline.next();
if (opt.verbose) { cout << "open input file (#1) " << infile1 << endl; }
std::ifstream ifs1(infile1.c_str());
datread::isffstream is1(ifs1, opt.debug);
sff::FREE filefree1;
sff::SRCE source1;
is1 >> filefree1;
is1 >> source1;
if (opt.verbose) { cout << "open input file (#2) " << infile2 << endl; }
std::ifstream ifs2(infile2.c_str());
datread::isffstream is2(ifs2, opt.debug);
sff::FREE filefree2;
sff::SRCE source2;
is2 >> filefree2;
is2 >> source2;
TFXX_assert((source1.cs == source2.cs) &&
(source1.cx == source2.cx) &&
(source1.cy == source2.cy) &&
(source1.cz == source2.cz),
"ERROR: coordinates do not match!");
if (opt.verbose) { cout << "open output file " << outfile << endl; }
std::ofstream ofs(outfile.c_str());
sff::SFFostream<Tseries> os(ofs);
sff::FREE outfilefree;
outfilefree.append(GATHERDIFF_VERSION);
outfilefree.append(GATHERDIFF_CVSID);
outfilefree.append("input file #1: "+infile1);
outfilefree.append("input file #2: "+infile2);
outfilefree.append("input FREE #1:");
outfilefree.append(filefree1);
outfilefree.append("input FREE #2:");
outfilefree.append(filefree2);
os << source1;
os << outfilefree;
int itrace=0;
while (is1.good() && is2.good())
{
if (opt.verbose) { cout << "process trace #" << ++itrace << endl; }
sff::WID2 wid2in1, wid2in2, wid2out;
sff::INFO infoin1, infoin2;
sff::FREE tracefreein1, tracefreein2, outtracefree;
Tseries series1, series2;
is1 >> series1;
is1 >> wid2in1;
is1 >> infoin1;
is1 >> tracefreein1;
is2 >> series2;
is2 >> wid2in2;
is2 >> infoin2;
is2 >> tracefreein2;
outtracefree.append("input FREE #1:");
outtracefree.append(tracefreein1);
outtracefree.append("input FREE #2:");
outtracefree.append(tracefreein2);
TFXX_assert((wid2in1.date-source1.date) == (wid2in2.date-source2.date),
"ERROR: times do not match!");
TFXX_assert(wid2in1.dt == wid2in2.dt,
"ERROR: sampling interval does not match!");
TFXX_assert(wid2in1.nsamples == wid2in2.nsamples,
"ERROR: numer of samples does not match!");
TFXX_assert((infoin1.cs == infoin2.cs) &&
(infoin1.cx == infoin2.cx) &&
(infoin1.cy == infoin2.cy) &&
(infoin1.cz == infoin2.cz),
"ERROR: coordinates do not match!");
wid2out=wid2in1;
wid2out.channel="dif";
Tseries outseries=series1-series2;
os << outseries;
os << wid2out;
os << infoin1;
os << outtracefree;
}
}
/* ----- END OF gatherdiff.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