Commit 6494de1b authored by thomas.forbriger's avatar thomas.forbriger
Browse files

teseco [FEATURE]: support scaling of signal traces

Scaling of signal traces is useful if a linear combination of a set of traces
shall be computed rather than the correction of a signal. This kind of
application has to be carried out when predicting disturbances caused by
magnetic field in seismic recordings, for examples.
parent 3ab04c1c
......@@ -4,7 +4,7 @@
* ----------------------------------------------------------------------------
*
* \author Thomas Forbriger
* \date 13/07/2005
* \date 28/11/2016
*
* time series corrections
*
......@@ -30,11 +30,12 @@
* - 13/07/2005 V1.0 Thomas Forbriger
* - 13/11/2012 V1.1 support additional file formats
* - 30/07/2015 V1.2 provide option -datetolerance
* - 28/11/2016 V1.3 allow scaling of signal
*
* ============================================================================
*/
#define TESECO_VERSION \
"TESECO V1.2 time series corrections"
"TESECO V1.3 time series corrections"
#include <fstream>
#include <sstream>
......@@ -71,8 +72,8 @@ int main(int iargc, char* argv[])
TESECO_VERSION "\n"
"usage: teseco [-v] [-o] [-a] [-type type] [-Type type]" "\n"
" [-datetolerance t]" "\n"
" outfile signal [t:T] infile [t:T] [f:F] [infile [t:T] [f:F] ... ]"
"\n"
" outfile signal [t:T] [f:F]\n"
" infile [t:T] [f:F] [infile [t:T] [f:F] ... ]" "\n"
" or: teseco --help|-h" "\n"
" or: teseco --xhelp" "\n"
};
......@@ -86,13 +87,14 @@ int main(int iargc, char* argv[])
"to seismic recordings." "\n"
"\n"
"outfile output filename" "\n"
"signal signal filename (these trace will be corrected)" "\n"
"signal signal filename (multiple traces may be selected;\n"
" each correction will be applied to each of them)\n"
"infile name of file containing correction; scaled traces" "\n"
" will be subtraced from (or added to) the signals" "\n"
" t:T select traces T, where T may be any range" "\n"
" specification like \'3-4\' or \'5,6,7-12,20\'" "\n"
"infile name of file containing correction" "\n"
" each of the traces will be scaled by the factor \'F\'" "\n"
" and be subtraced from (or added to) the signals" "\n"
" (default: F=1.)" "\n"
" f:F each of the traces will be scaled by the factor \'F\'\n"
" (default: F=1.)" "\n"
"\n"
"-v verbose mode" "\n"
"-o overwrite existing output file" "\n"
......@@ -220,6 +222,7 @@ int main(int iargc, char* argv[])
bool doselect=sigfile.haskey(tracekey);
Trangelist traceranges=
tfxx::string::rangelist<Trangelist::Tvalue>(sigfile.value(tracekey));
if (opt.verbose) { cout << "open signal file " << sigfile.name << endl; }
std::ios_base::openmode iopenmode
......@@ -227,14 +230,29 @@ int main(int iargc, char* argv[])
std::ifstream ifs(sigfile.name.c_str(), iopenmode);
datrw::ianystream is(ifs, opt.inputformat);
// read selected traces
if (doselect)
{ signal.read(is.idatstream(), traceranges, opt.verbose); }
else
{ signal.read(is.idatstream(), opt.verbose); }
// apply factor to each of the traces, if selected
if (sigfile.haskey(factorkey))
{
double factor=1.;
std::istringstream sfactor(sigfile.value(factorkey));
sfactor >> factor;
for (Tfile::Ttracevector::iterator isig=signal.begin();
isig != signal.end(); ++isig)
{
*isig *= factor;
}
}
}
TFXX_assert((signal.size()>0), "missing signal");
signal.fileheader.append(filefree);
// SFF WID2 compare
sff::WID2compare compare(sff::Fnsamples | sff::Fdt | sff::Fdate);
compare.setdatetolerance(opt.datetolerance);
......
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