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

new features ***judelijudelidudelidu***

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: 1498
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 7f62eb6c
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: sigfit.cc,v 1.11 2004-02-24 20:06:56 tforb Exp $
* $Id: sigfit.cc,v 1.12 2004-03-16 15:10:03 tforb Exp $
* \author Thomas Forbriger
* \date 28/01/2004
*
......@@ -16,13 +16,14 @@
* - 24/02/2004 V1.1 introduced search range stabilization
* more output values
* V1.2 correction: searchfac is a factor!
* - 16/03/2004 V1.3 add trend and offset fit
*
* ============================================================================
*/
#define SIGFIT_VERSION \
"SIGFIT V1.2 fit signal by trial-signals"
"SIGFIT V1.3 fit signal by trial-signals"
#define SIGFIT_CVSID \
"$Id: sigfit.cc,v 1.11 2004-02-24 20:06:56 tforb Exp $"
"$Id: sigfit.cc,v 1.12 2004-03-16 15:10:03 tforb Exp $"
#include <fstream>
#include <iostream>
......@@ -59,6 +60,8 @@ struct Options {
double searchrange;
bool usesearchrange;
bool equalsearch;
bool fittrend;
bool fitoffset;
}; // struct Options
// formatted number output
......@@ -77,6 +80,7 @@ int main(int iargc, char* argv[])
{
SIGFIT_VERSION "\n"
"usage: sigfit [-v] [-Tdate v] [-truncate]" "\n"
" [-Sramp] [-Sconst]" "\n"
" [-searchrange[=r]]" "\n"
" signal trial [trial ...]" "\n"
" or: sigfit --help|-h" "\n"
......@@ -124,6 +128,10 @@ int main(int iargc, char* argv[])
{"searchrange",arg_opt,"100."},
// 6: equal search ranges
{"equalsearch",arg_no,"-"},
// 7: fit a trend
{"Sramp",arg_no,"-"},
// 8: fit an offset
{"Sconst",arg_no,"-"},
{NULL}
};
......@@ -179,6 +187,8 @@ int main(int iargc, char* argv[])
opt.usesearchrange=cmdline.optset(5);
opt.searchrange=cmdline.double_arg(5);
opt.equalsearch=cmdline.optset(6);
opt.fittrend=cmdline.optset(7);
opt.fitoffset=cmdline.optset(8);
/*----------------------------------------------------------------------*/
......@@ -186,7 +196,8 @@ int main(int iargc, char* argv[])
TFXX_assert(cmdline.extra(),"ERROR: missing signal file name!");
std::string signalname=cmdline.next();
TFXX_assert(cmdline.extra(),"ERROR: missing trial signal file name!");
TFXX_assert((cmdline.extra()||opt.fittrend||opt.fitoffset),
"ERROR: missing trial signal file name!");
Tnamelist namelist;
while (cmdline.extra()) { namelist.push_back(cmdline.next()); }
......@@ -244,6 +255,39 @@ int main(int iargc, char* argv[])
}
}
// add synthetic trial files
if (opt.fitoffset)
{
if (opt.verbose) { cout << "add offset to trial signals" << endl; }
Tbundle synsignal;
synsignal.header=signal.header;
synsignal=Tseries(signal.shape());
synsignal.series()=1.;
synsignal.header.station="NSP";
synsignal.header.channel="off";
synsignal.header.auxid="NSP";
synsignal.header.instype="NSP";
bundlevec.push_back(synsignal);
}
if (opt.fittrend)
{
if (opt.verbose) { cout << "add trend to trial signals" << endl; }
Tbundle synsignal;
synsignal.header=signal.header;
synsignal=Tseries(signal.shape());
for (int i=synsignal.first(); i<=synsignal.last(); ++i)
{
synsignal(i)=2.*(i-(0.5*(synsignal.first()+synsignal.last())))/
synsignal.size();
}
synsignal.header.station="NSP";
synsignal.header.channel="ramp";
synsignal.header.auxid="NSP";
synsignal.header.instype="NSP";
bundlevec.push_back(synsignal);
}
/*----------------------------------------------------------------------*/
// truncate length if requested
......
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