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

new option skip

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: 1578
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 69b1d80d
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: sigfit.cc,v 1.16 2004-03-17 17:30:49 tforb Exp $
* $Id: sigfit.cc,v 1.17 2004-09-24 14:51:43 tforb Exp $
* \author Thomas Forbriger
* \date 28/01/2004
*
......@@ -17,13 +17,15 @@
* more output values
* V1.2 correction: searchfac is a factor!
* - 16/03/2004 V1.3 add trend and offset fit
* - 24/09/2004 V1.4 allow to skip samples if this is helpful to remove
* transient filter loading response
*
* ============================================================================
*/
#define SIGFIT_VERSION \
"SIGFIT V1.3 fit signal by trial-signals"
"SIGFIT V1.4 fit signal by trial-signals"
#define SIGFIT_CVSID \
"$Id: sigfit.cc,v 1.16 2004-03-17 17:30:49 tforb Exp $"
"$Id: sigfit.cc,v 1.17 2004-09-24 14:51:43 tforb Exp $"
#include <fstream>
#include <iostream>
......@@ -60,8 +62,8 @@ struct Options {
double searchrange;
bool usesearchrange;
bool equalsearch;
bool fittrend, fitoffset;
double amptrend, ampoffset;
bool fittrend, fitoffset, doskip;
double amptrend, ampoffset, skip;
}; // struct Options
/*======================================================================*/
......@@ -88,7 +90,7 @@ void removetre(Tseries& s)
jser += i;
jqser += i*i;
}
double a,b;
//double a,b;
sum /= s.size();
for (int i=s.first(); i<=s.last(); ++i) { s(i) -= sum; }
}
......@@ -113,7 +115,7 @@ int main(int iargc, char* argv[])
SIGFIT_VERSION "\n"
"usage: sigfit [-v] [-Tdate v] [-truncate]" "\n"
" [-Sramp[=v]] [-Sconst[=v]] [-residual f]" "\n"
" [-searchrange[=r]] [-equalsearch]" "\n"
" [-searchrange[=r]] [-equalsearch] [-skip n]" "\n"
" signal trial [trial ...]" "\n"
" or: sigfit --help|-h" "\n"
};
......@@ -136,6 +138,7 @@ int main(int iargc, char* argv[])
" the search range r is given in units of" "\n"
" rms(signal)/rms(trial signals)" "\n"
"-equalsearch use same search range for each trial signal" "\n"
"-skip n skip n seconds at beginning of each trace" "\n"
"\n"
"signal signal to by explained by a linear combination" "\n"
" of trial signals" "\n"
......@@ -164,6 +167,8 @@ int main(int iargc, char* argv[])
{"Sramp",arg_opt,"1."},
// 8: fit an offset
{"Sconst",arg_opt,"1."},
// 9: fit an offset
{"skip",arg_yes,"0"},
{NULL}
};
......@@ -223,6 +228,8 @@ int main(int iargc, char* argv[])
opt.fitoffset=cmdline.optset(8);
opt.amptrend=cmdline.double_arg(7);
opt.ampoffset=cmdline.double_arg(8);
opt.skip=cmdline.double_arg(9);
opt.doskip=cmdline.optset(9);
/*----------------------------------------------------------------------*/
......@@ -379,6 +386,45 @@ int main(int iargc, char* argv[])
}
}
/*----------------------------------------------------------------------*/
// skip samples if requested
if (opt.doskip)
{
if (opt.verbose)
{
cout << "skip " << opt.skip << " seconds" << endl;
}
int nskip=int(floor(opt.skip/signal.header.dt));
if (nskip>0)
{
libtime::TRelativeTime add=nskip*libtime::double2time(signal.header.dt);
signal.setfirstindex(signal.first()+nskip);
signal.header.date+=add;
for (Tbundlevec::iterator i=bundlevec.begin();
i!=bundlevec.end(); i++)
{
i->setfirstindex(i->first() + nskip);
i->header.date += add;
}
if (opt.verbose)
{
cout << "skipped " << nskip << " samples ("
<< add.timestring() << ")" << endl;
}
}
else
{
if (opt.verbose)
{
cout << "NOTICE: nothing to skip..." << endl;
cout << " seems like "
<< opt.skip << " seconds to skip < "
<< signal.header.dt << " seconds sampling interval" << endl;
}
}
}
/*----------------------------------------------------------------------*/
double signalrms=ts::rms(signal);
......
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