86 char usage_text_version[]=
92 using namespace tfxx::cmdline;
93 static Declare options[]=
98 {
"xhelp",arg_opt,
"all"},
100 {
"DEBUG",arg_no,
"-"},
106 {
"type",arg_yes,
"sff"},
108 {
"Type",arg_yes,
"sff"},
110 {
"taperlast",arg_no,
"-"},
112 {
"sqrttaper",arg_no,
"-"},
114 {
"limitlength",arg_no,
"-"},
116 {
"fredomain",arg_no,
"-"},
118 {
"velocity",arg_yes,
"1."},
120 {
"tdfilter",arg_no,
"-"},
122 {
"fdfilter",arg_no,
"-"},
126 {
"tshift",arg_yes,
"1."},
128 {
"tlim",arg_yes,
"0."},
130 {
"tfac",arg_yes,
"0.1"},
132 {
"integshift",arg_yes,
"0.5"},
134 {
"tapdel",arg_yes,
"0."},
136 {
"nointeg",arg_no,
"-"},
138 {
"tapslo",arg_yes,
"0."},
140 {
"transition",arg_yes,
"0.,1."},
143 {
"fdexplosion",arg_no,
"-"},
145 {
"fdzforce",arg_no,
"-"},
147 {
"fdlamb",arg_no,
"-"},
149 {
"vpvsratio",arg_yes,
"1.732"},
151 {
"quality",arg_yes,
"30.,30."},
153 {
"ktrapezoid",arg_yes,
"1000,2.,0.1"},
155 {
"radial",arg_no,
"-"},
157 {
"fdwizforce",arg_no,
"-"},
159 {
"spatialdistance",arg_no,
"-"},
161 {
"listexperimental",arg_no,
"-"},
170 static const char formatkey[]=
"f";
171 static const char tracekey[]=
"t";
179 static const char* cmdlinekeys[]
180 ={formatkey, tracekey, 0};
190 cerr << usage_text_version << endl;
192 cerr << tfxx::seitosh::repository_reference << endl;
197 Commandline cmdline(iargc, argv, options);
200 if (cmdline.optset(0))
202 cerr << usage_text_version << endl;
207 datrw::supported_data_types(cerr);
208 cerr << endl << tfxx::seitosh::repository_reference << endl;
213 if (cmdline.optset(1))
215 cerr << usage_text_version << endl;
218 if (cmdline.string_arg(1) ==
"all")
220 datrw::online_help(cerr);
224 datrw::online_help(cmdline.string_arg(1), cerr);
230 if (cmdline.optset(32))
232 cerr << usage_text_version << endl;
243 std::istringstream iss;
245 opt.
debug=cmdline.optset(2);
254 opt.
velocity=cmdline.double_arg(11);
257 opt.
npad=cmdline.int_arg(14);
258 opt.
tshift=cmdline.double_arg(15);
259 opt.
tlim=cmdline.double_arg(16);
260 opt.
tfac=cmdline.double_arg(17);
262 opt.
tapdel=cmdline.double_arg(19);
263 opt.
nointeg=cmdline.optset(20);
264 opt.
tapslo=cmdline.double_arg(21);
272 args=cmdline.string_arg(27);
273 args.replace(args.find(
","),1,
" ");
276 args=cmdline.string_arg(28);
277 args.replace(args.find(
","),1,
" ");
280 opt.
radial=cmdline.optset(29);
293 cerr <<
"WARNING:" << endl;
294 cerr <<
"You selected an experimental option!" << endl;
295 cerr <<
"This function is not yet properly implemented." << endl;
296 cerr <<
"It is not well tested and is likely to provide" << endl;
297 cerr <<
"false results.\n" << endl;
303 std::istringstream transopt(tfxx::string::patsubst(cmdline.string_arg(22),
307 "transition offsets must be positive");
309 "second transition offset must be larger than first");
313 TFXX_assert(opt.
tshift>=0.,
314 "just positive shifting is allowed");
315 TFXX_assert(opt.
tlim>=0.,
316 "just positive times are allowed");
317 TFXX_assert(opt.
tfac>=0.,
318 "just positive time values are allowed");
320 "just values in [0.,1.) are allowed for -integ parameter");
321 TFXX_assert(opt.
tapslo>=0.,
322 "just positive slowness values are allowed");
330 TFXX_assert(cmdline.extra(),
"missing output file");
331 std::string outfile=cmdline.next();
332 TFXX_assert(cmdline.extra(),
"missing input file");
333 tfxx::cmdline::Tparsed arguments=parse_cmdline(cmdline, cmdlinekeys);
334 if ((arguments.size()>1) && opt.
verbose)
336 cout <<
"NOTICE: file specific information (SRCE line and file FREE)" <<
338 <<
" will be taken from first file only!" << endl;
356 sff::FREE processingreport;
364 filefree.append(
"output file name:");
365 filefree.append(
" " + outfile);
366 filefree.append(
"input file selection:");
367 tfxx::cmdline::Tparsed::const_iterator file=arguments.begin();
368 while (file != arguments.end())
370 filefree.append(
" " + file->name);
372 tfxx::cmdline::Toptionmap::const_iterator option=file->options.begin();
373 while (option != file->options.end())
375 line +=
" " + option->first +
":" + option->second;
378 if (line.size()>2) { filefree.append(line); }
381 if (arguments.size()>1)
383 filefree.append(
"In cases where more than one input file is read,");
384 filefree.append(
"the SRCE line is taken from the first file only (if");
385 filefree.append(
"present there).");
387 filefree.append(processingreport);
390 if (opt.
verbose) { cout << filefree << endl; }
398 Exco expansioncoefficients;
410 expansioncoefficients=
Exco(ec, opt.
ipa);
417 expansioncoefficients=
Exco(ec, opt.
ipa);
422 expansioncoefficients=
Exco(ec, opt.
ipa);
431 if (opt.
verbose) { cout <<
"open output file " << outfile << endl; }
435 std::ifstream file(outfile.c_str(),std::ios_base::in);
436 TFXX_assert((!file.good()),
"ERROR: output file exists!");
438 std::ios_base::openmode oopenmode
440 std::ofstream ofs(outfile.c_str(), oopenmode);
447 tfxx::cmdline::Tparsed::const_iterator infile=arguments.begin();
448 while (infile != arguments.end())
451 if (opt.
verbose) { cout <<
"open input file " << infile->name << endl; }
453 if (infile->haskey(formatkey))
455 inputformat=infile->value(formatkey);
457 std::ios_base::openmode iopenmode
458 =datrw::ianystream::openmode(inputformat);
459 std::ifstream ifs(infile->name.c_str(), iopenmode);
460 datrw::ianystream is(ifs, inputformat);
464 sff::SRCE insrceline;
465 bool srceavailable=
false;
470 sff::FREE infilefree;
472 filefree.append(
"block read from first input file:");
473 filefree.append(infilefree);
475 if (os.handlesfilefree()) { os << filefree; }
480 if (os.handlessrce()) { os << insrceline; }
487 typedef tfxx::RangeList<int> Trangelist;
488 bool doselect=infile->haskey(tracekey);
489 Trangelist traceranges=
490 tfxx::string::rangelist<Trangelist::Tvalue>(infile->value(tracekey));
496 if ((!doselect) || traceranges.contains(itrace))
498 TFXX_debug(opt.
debug,
"main",
"process trace #" << itrace );
500 { std::cout <<
"process trace #" << itrace <<
":"; }
505 TFXX_debug(opt.
debug,
"main",
" series and WID2 are read:\n" << wid2);
507 if (is.hasinfo()) { is >> info; }
511 if ((!doselect) || traceranges.contains(itrace))
523 TFXX_assert(is.hasinfo() && srceavailable,
524 "Source and receiver coordinates are required");
529 par.
offset=::sff::sourcedistance(insrceline, info);
533 par.offset=::sff::offset(insrceline, info);
535 par.t0=libtime::time2double(insrceline.date-wid2.date);
536 par.T=wid2.dt*series.size();
538 par.nsamples=wid2.nsamples;
542 cout <<
" offset=" << par.offset <<
"m" 544 <<
" t0=" << par.t0 <<
"s" 546 <<
" T=" << par.T <<
"s" 548 <<
" dt=" << par.dt <<
"s" 552 TFXX_assert(fabs(par.t0) < 1.e-6,
553 "Cannot handle shift of time origin in data");
556 Tseries singlevelocityseries, directwaveseries;
568 expansioncoefficients,
592 series=singlevelocityseries;
596 series=directwaveseries;
601 series.setlastindex(wid2.nsamples+series.f()-1);
604 TFXX_debug(opt.
debug,
"main",
" series is filtered");
610 if (opt.
verbose) { std::cout <<
" filtered" << std::endl; }
615 if (opt.
verbose) { std::cout <<
" passed unchanged" << std::endl; }
619 if (is.hasinfo()) {
if (os.handlesinfo()) { os << info; } }
620 if (is.hasfree() ||
true)
625 tracefree.append(
"read from file " + infile->name);
626 if ((!doselect) || traceranges.contains(itrace))
628 tracefree.append(processingreport);
632 tracefree.append(
"passed unchanged");
634 if (os.handlestracefree()) { os << tracefree; }
636 TFXX_debug(opt.
debug,
"main",
637 "trace #" << itrace <<
" successfully processed");
639 TFXX_debug(opt.
debug,
"main",
" series and WID are written");
643 TFXX_debug(opt.
debug,
"main",
"skip trace #" << itrace );
645 { std::cout <<
" skip trace #" << itrace << std::endl; }
Ttimeseries::Tseries Tseries
double edge
edge factor at upper limit of wavenumber range
int nsteps
number of steps
double Vs
S-wave propagation velocity.
TFourier::Tseries singlevelocitytransformation(const TFourier::Tseries &series, const Parameters &par, const Exco &ec, const Options &opt)
double Vp
P-wave propagation velocity.
TFourier::Tseries transitionmixer(TFourier::Tseries singlevelocityseries, TFourier::Tseries directwaveseries, const Parameters &par, const Options &opt)
TFourier::Tseries tdtapertransformation(TFourier::Tseries series, Parameters &par, const Options &opt)
TFourier::Tseries padseries(const TFourier::Tseries &series, const Options &opt)
double offset
either epicentral distance or hypocentral distance.
double taper
taper fraction at upper limit of wavenumber range