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

first tests with soutifu

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: 4006
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent aafa71b9
......@@ -36,13 +36,17 @@ using std::cout;
using std::cerr;
using std::endl;
/*----------------------------------------------------------------------*/
// debug helper
#define PAROUT( par ) cout << #par << "=" << par << " ";
/*----------------------------------------------------------------------*/
// function to compare double
// is true if relative residual between a and b is smaller than eps
bool sameineps(const double &a, const double& b, const double& eps=1.e-8)
{
double reldif=std::abs(a-b);
return(reldif<(std::abs(b*eps)));
return(reldif<=(std::abs(b*eps)));
}
/*----------------------------------------------------------------------*/
......@@ -50,7 +54,7 @@ bool sameineps(const double &a, const double& b, const double& eps=1.e-8)
struct Options {
bool verbose, debug, overwrite;
bool writestf, writeconvolved;
std::string stffilename, convolvedfilename;
std::string stffilename, convolvedfilename, debuglevel;
datrw::Eformat datafileformat;
}; // struct Options
......@@ -63,7 +67,8 @@ int main(int iargc, char* argv[])
char usage_text[]=
{
SOUTIFU_VERSION "\n"
"usage: soutifu [-v] [-o] [-wc f] [-ws f] [--type f] [--para p]\n"
"usage: soutifu [-v] [-o] [-wc f] [-ws f] [--type f]\n"
" [-DEBUG=level]\n"
" parameters data synthetics" "\n"
" or: soutifu --help|-h" "\n"
" or: soutifu --xhelp" "\n"
......@@ -85,6 +90,7 @@ int main(int iargc, char* argv[])
" to be passed to this engine.\n"
"\n"
"-v be verbose\n"
"-DEBUG=level produce debug output at level \"level\"\n"
"-o overwrite existing output files\n"
"--type f use file format type \"f\" for file I/O\n"
"-wc f write convolved synthetics to file \"f\"\n"
......@@ -113,6 +119,8 @@ int main(int iargc, char* argv[])
{"ws",arg_yes,"-"},
// 6: present full details
{"xhelp",arg_no,"-"},
// 7: present full details
{"DEBUG",arg_yes,"0"},
{NULL}
};
......@@ -150,6 +158,8 @@ int main(int iargc, char* argv[])
opt.convolvedfilename=cmdline.string_arg(4);
opt.writestf=cmdline.optset(5);
opt.stffilename=cmdline.string_arg(5);
opt.debug=cmdline.optset(7);
opt.debuglevel=cmdline.string_arg(7);
TFXX_assert(cmdline.extra(), "missing parameter string");
std::string parameters=cmdline.next();
......@@ -259,6 +269,22 @@ int main(int iargc, char* argv[])
double sdx=sdtseries.header.info().cx-syntheticdata.fileheader.srce().cx;
double sdy=sdtseries.header.info().cy-syntheticdata.fileheader.srce().cy;
double sdz=sdtseries.header.info().cz-syntheticdata.fileheader.srce().cz;
if (opt.debug)
if (!(sameineps(ddx,sdx) && sameineps(ddy,sdy) &&
sameineps(ddz,sdz)))
{
cout << "NOTICE: ";
PAROUT(ddx);
PAROUT(sdx);
PAROUT(ddy);
PAROUT(sdy);
PAROUT(ddz);
PAROUT(sdz);
PAROUT(sameineps(ddx,sdx));
PAROUT(sameineps(ddy,sdy));
PAROUT(sameineps(ddz,sdz));
cout << endl;
}
TFXX_assert((sameineps(ddx,sdx) && sameineps(ddy,sdy) &&
sameineps(ddz,sdz)),
"ERROR: inconsistent receiver positions");
......@@ -286,10 +312,14 @@ int main(int iargc, char* argv[])
stfwaveform.sampling.n=tracetriple.header.sampling.n;
stfwaveform.series=stftseries;
stftseries.header.wid2().nsamples=stfwaveform.sampling.n;
stftseries.header.wid2().dt=stfwaveform.sampling.dt;
stftseries.header.wid2().date=libtime::now();
stffile.fileheader.srce().date=stftseries.header.wid2().date;
::sff::WID2 wid2=stftseries.header.wid2();
wid2.nsamples=stfwaveform.sampling.n;
wid2.dt=stfwaveform.sampling.dt;
wid2.date=libtime::now();
stftseries.header.wid2(wid2);
::sff::SRCE srce=stffile.fileheader.srce();
srce.date=stftseries.header.wid2().date;
stffile.fileheader.srce(srce);
stffile.push_back(stftseries);
} // if (itrace==0)
......@@ -303,6 +333,7 @@ int main(int iargc, char* argv[])
parameters += ":verbose";
cout << "create STF engine" << endl;
}
if (opt.debug) { parameters += ":DEBUG="+opt.debuglevel; }
stfinv::STFEngine engine(vectoroftriples, stfwaveform, parameters);
// run STF engine
......
......@@ -53,6 +53,19 @@ refmetmain.xxx: refmetmain.tpl $(REFMETMOD) $(REFMETSRC) $(REFMETRCV)
seismo.TZ seismo.TR: refmetmain.xxx
refmet -v -4 -o seismo -c $<
# produce seismogram file by windowing such that backpropagating
# cut-off phase is removed
WINLIM=2000
win.fil.xxx: ; echo -e "win 1,$(WINLIM)\nend" > $@
seismo.sff: seismo.TZ win.fil.xxx
stufi $(word 2,$^) -v -o $<; /bin/mv $<.sfi $@
# apply a filter, simulating a source time function
STFPER=0.1
stf.fil.xxx: ; echo -e "lpb $(STFPER),2\nrem dif 0\nend" > $@
%.stf.sff: %.sff stf.fil.xxx
tidofi -v -o -cf $(word 2,$^) $@ $<
# syg
# ---
$(patsubst %.par,%syg.grn,$(MODELS)): %syg.grn: %.par zforce.xxx
......@@ -63,7 +76,18 @@ $(patsubst %.par,%syg.grn,$(MODELS)): %syg.grn: %.par zforce.xxx
%grn.ps: %.grn
grepg $< -W -d $@/ps -p 0.8 -s -f 10 -i
#----------------------------------------------------------------------
# ============================================================================
# apply STF inversion
convseis.sff stf.sff: seismo.stf.sff seismo.sff
soutifu -D=3 -v -o -wc convseis.sff -ws stf.sff \
fbd $^
convseis.ps: seismo.sff seismo.stf.sff convseis.sff
refract -d $@/cps \
-Sm 3 -Se 1.8 -C -Sa 5. -Sc 5. \
$^
# ============================================================================
# plot preview
%.psp: %.ps; gv $<; /bin/rm -vf $<
# ----- END OF Makefile -----
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