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

proceeding

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: 1580
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 60ab9483
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: sigfit.cc,v 1.18 2004-09-24 15:15:25 tforb Exp $
* $Id: sigfit.cc,v 1.19 2004-09-24 15:36:33 tforb Exp $
* \author Thomas Forbriger
* \date 28/01/2004
*
......@@ -22,18 +22,20 @@
* transient filter loading response
* - remove correction from synthetics and signal
* and make this process transparent
* - provide exponential decay
*
* ============================================================================
*/
#define SIGFIT_VERSION \
"SIGFIT V1.4 fit signal by trial-signals"
#define SIGFIT_CVSID \
"$Id: sigfit.cc,v 1.18 2004-09-24 15:15:25 tforb Exp $"
"$Id: sigfit.cc,v 1.19 2004-09-24 15:36:33 tforb Exp $"
#include <fstream>
#include <iostream>
#include <list>
#include <vector>
#include <cmath>
#include <tfxx/commandline.h>
#include <tfxx/error.h>
#include <sffxx.h>
......@@ -65,8 +67,8 @@ struct Options {
double searchrange;
bool usesearchrange;
bool equalsearch;
bool fittrend, fitoffset, doskip;
double amptrend, ampoffset, skip;
bool fittrend, fitoffset, doskip, fitexp;
double amptrend, ampoffset, skip, tcexp;
}; // struct Options
/*======================================================================*/
......@@ -117,7 +119,8 @@ int main(int iargc, char* argv[])
{
SIGFIT_VERSION "\n"
"usage: sigfit [-v] [-Tdate v] [-truncate]" "\n"
" [-Sramp[=v]] [-Sconst[=v]] [-residual f]" "\n"
" [-Sramp[=v]] [-Sconst[=v]] [-Sexp[=v]]" "\n"
" [-residual f]" "\n"
" [-searchrange[=r]] [-equalsearch] [-skip n]" "\n"
" signal trial [trial ...]" "\n"
" or: sigfit --help|-h" "\n"
......@@ -131,6 +134,9 @@ int main(int iargc, char* argv[])
"-v be verbose" "\n"
"-Sramp[=v] add a ramp to the set of trial signals with amplitude v" "\n"
"-Sconst[=v] add a constant (of value v) to the set of trial signals" "\n"
"-Sexp[=v] add a exponential decay (with time constant v relative" "\n"
" to the length of the time series) to the set of trial" "\n"
" signals" "\n"
"-Tdate v tolerance for comparison of date of first sample" "\n"
" v give the tolerance in units of the sampling interval" "\n"
"-truncate truncate all series to the same number of samples" "\n"
......@@ -172,6 +178,8 @@ int main(int iargc, char* argv[])
{"Sconst",arg_opt,"1."},
// 9: fit an offset
{"skip",arg_yes,"0"},
// 10: fit an offset
{"Sexp",arg_opt,"1."},
{NULL}
};
......@@ -193,30 +201,6 @@ int main(int iargc, char* argv[])
exit(0);
}
/*
// dummy operation: print option settings
for (int iopt=0; iopt<2; iopt++)
{
cout << "option: '" << options[iopt].opt_string << "'" << endl;
if (cmdline.optset(iopt)) { cout << " option was set"; }
else { cout << "option was not set"; }
cout << endl;
cout << " argument (string): '" << cmdline.string_arg(iopt) << "'" << endl;
cout << " argument (int): '" << cmdline.int_arg(iopt) << "'" << endl;
cout << " argument (long): '" << cmdline.long_arg(iopt) << "'" << endl;
cout << " argument (float): '" << cmdline.float_arg(iopt) << "'" << endl;
cout << " argument (double): '" << cmdline.double_arg(iopt) << "'" << endl;
cout << " argument (bool): '";
if (cmdline.bool_arg(iopt))
{ cout << "true"; } else { cout << "false"; }
cout << "'" << endl;
}
while (cmdline.extra()) { cout << cmdline.next() << endl; }
// dummy operation: print rest of command line
while (cmdline.extra()) { cout << cmdline.next() << endl; }
*/
// read options
Options opt;
opt.verbose=cmdline.optset(1);
......@@ -233,6 +217,8 @@ int main(int iargc, char* argv[])
opt.ampoffset=cmdline.double_arg(8);
opt.skip=cmdline.double_arg(9);
opt.doskip=cmdline.optset(9);
opt.fitexp=cmdline.optset(10);
opt.tcexp=cmdline.double_arg(10);
/*----------------------------------------------------------------------*/
......@@ -341,6 +327,28 @@ int main(int iargc, char* argv[])
bundlevec.push_back(synsignal);
}
if (opt.fitexp)
{
if (opt.verbose)
{
cout << "add exponential decay to trial signals" << endl;
}
Tbundle synsignal;
synsignal.header=signal.header;
synsignal=Tseries(signal.shape());
for (int i=synsignal.first(); i<=synsignal.last(); ++i)
{
double argval=-1.*double(i-synsignal.first())/
(double(synsignal.size())*opt.tcexp);
synsignal(i)=std::exp(argval);
}
synsignal.header.station="NSP";
synsignal.header.channel="exp";
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