Commit 469cbdb2 authored by thomas.forbriger's avatar thomas.forbriger
Browse files

resaseda [FEATURE]: provide shrink option

a new option for resaseda provides the shrink option in the resample function
of the interpolator
parent 72436495
......@@ -4,11 +4,11 @@
* ----------------------------------------------------------------------------
*
* \author Thomas Forbriger
* \date 13/07/2005
* \date 07/11/2017
*
* resample seismic data
*
* Copyright (c) 2005 by Thomas Forbriger (BFO Schiltach)
* Copyright (c) 2005, 2017 by Thomas Forbriger (BFO Schiltach)
*
* ----
* RESASEDA is free software; you can redistribute it and/or modify
......@@ -34,11 +34,12 @@
* - 03/08/2011 V1.3 implement delay option
* - 14/09/2011 V1.4 implement sample offset windows
* - 21/11/2012 V1.5 provide different output formats
* - 07/11/2017 V1.6 provide option shrink
*
* ============================================================================
*/
#define RESASEDA_VERSION \
"RESASEDA V1.5 resample seismic data"
"RESASEDA V1.6 resample seismic data"
#include <fstream>
#include <iostream>
......@@ -61,7 +62,7 @@ using libtime::TAbsoluteTime;
using libtime::TRelativeTime;
struct Options {
bool verbose, overwrite, debug, delay;
bool verbose, overwrite, debug, delay, shrink;
bool timefirstset, timelastset, timespanset, dtset, nset;
TAbsoluteTime timefirst, timelast;
TRelativeTime timespan, edge;
......@@ -85,7 +86,7 @@ int main(int iargc, char* argv[])
"usage: resaseda [-tf time] [-tl time] [-n n] [-dt dt] [-ts time]" "\n"
" [-v] [-o] [-sf time] [-sl time] [-edge s]" "\n"
" [-delay d] [-type type] [-Type type]\n"
" [-sof n] [-sol n]" "\n"
" [-sof n] [-sol n] [-shrink]" "\n"
" outfile infile [t:T] [infile [t:T] ...]" "\n"
" or: resaseda --help|-h" "\n"
" or: resaseda --xhelp" "\n"
......@@ -122,6 +123,11 @@ int main(int iargc, char* argv[])
"-sol n define last sample index by offset n\n"
" positive sample index: define by offset from last sample\n"
" negative sample index: define by offset from first sample\n"
"-shrink if defined output time window is larger than time span\n"
" for which input data is available, reduce output time\n"
" window approrpiate for each input trace while maintaining\n"
" the defined ѕampling raster (useful for input data\n"
" containing gaps)\n"
};
// define commandline options
......@@ -164,6 +170,8 @@ int main(int iargc, char* argv[])
{"Type",arg_yes,"sff"},
// 17: extended help
{"xhelp",arg_no,"-"},
// 18: use shrink option with resample function
{"shrink",arg_no,"-"},
{NULL}
};
......@@ -233,6 +241,7 @@ int main(int iargc, char* argv[])
opt.sampleoffsetbegin=cmdline.int_arg(14);
opt.sampleoffsetend=cmdline.int_arg(15);
opt.outputformat=cmdline.string_arg(16);
opt.shrink=cmdline.optset(18);
// check options consistency
{
......@@ -425,6 +434,14 @@ int main(int iargc, char* argv[])
<< " prior to resampling!"
<< endl;
}
if (opt.shrink)
{
cout << " shrink output time window to available input" <<
endl
<< " data while maintaining the defined sampling" <<
endl
<< " raster" << endl;
}
}
// go for interpolation
......@@ -455,15 +472,31 @@ int main(int iargc, char* argv[])
bool hot=true;
try
{
outseries=ts::ipo::resample(*hipo, firstsample, newdt, nsamples);
outseries=ts::ipo::resample(*hipo, firstsample, newdt, nsamples,
opt.shrink);
}
catch (ts::ipo::ExceptionTimeWindowOutside)
{
cout << "NOTICE: skipping this trace silently..." << endl;
hot=false;
}
catch (ts::ipo::ExceptionTimeWindowEmpty)
{
cout << "NOTICE: skipping this trace silently..." << endl;
hot=false;
}
if (hot)
{
if (opt.shrink && opt.verbose)
{
cout << " time window returned from interpolator:" << endl
<< " begin: "
<< outseries.header.date.timestring() << endl
<< " end: "
<< sff::wid2lastsample(outseries.header).timestring() << endl
<< " number of samples: "
<< outseries.header.nsamples << endl;
}
TFXX_debug(opt.debug, "main",
" series is resampled");
os << outseries.header;
......
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