Commit df746752 authored by laura.gassner's avatar laura.gassner
Browse files

Merge branch 'thof/DENISE-import_Seitosh'

parents aca39e8a 628f7bb8
......@@ -3,7 +3,6 @@
*
* ----------------------------------------------------------------------------
*
* $Id: parameterhandler.h 3973 2011-05-28 14:40:41Z tforb $
* \author Thomas Forbriger
* \date 06/05/2011
*
......@@ -38,9 +37,7 @@
#ifndef STFINV_PARAMETERHANDLER_H_VERSION
#define STFINV_PARAMETERHANDLER_H_VERSION \
"STFINV_PARAMETERHANDLER_H V1.0 "
#define STFINV_PARAMETERHANDLER_H_CVSID \
"$Id: parameterhandler.h 3973 2011-05-28 14:40:41Z tforb $"
"STFINV_PARAMETERHANDLER_H V1.0"
#include <string>
#include <map>
......
......@@ -3,8 +3,6 @@
*
* ----------------------------------------------------------------------------
*
* $Id: stfinv.cc 4968 2013-02-01 13:58:05Z lrehor $
*
* ----
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -33,13 +31,12 @@
* - 30/09/2011 V1.1 implemented handling of additional time series pairs
* - 05/10/2011 V1.2 correction: initstfinvenginewithpairs was named
* incorrectly initstfinvenginepairs
* - 14/10/2015 V1.3 new end-user usage functions
*
* ============================================================================
*/
#define STFINV_STFINV_C_VERSION \
"STFINV_STFINV_C V1.2"
#define STFINV_STFINV_C_CVSID \
"$Id: stfinv.cc 4968 2013-02-01 13:58:05Z lrehor $"
"STFINV_STFINV_C V1.3"
#include <stfinv/stfinv.h>
#include <stfinv/error.h>
......@@ -168,10 +165,24 @@ void freestfinvengine()
/*----------------------------------------------------------------------*/
void printengines()
{
stfinv::engines();
} // void printengines()
/*----------------------------------------------------------------------*/
void printhelp()
{
stfinv::STFEngine::help();
stfinv::help();
} // void printhelp()
/*----------------------------------------------------------------------*/
void printusage(char* id)
{
std::string selectid(id);
stfinv::usage(selectid);
} // void printhelp(age(char* id)
/* ----- END OF stfinv.cc ----- */
......@@ -4,7 +4,6 @@
* \ingroup cinterface
* ----------------------------------------------------------------------------
*
* $Id: stfinv.h 4968 2013-02-01 13:58:05Z lrehor $
* \author Thomas Forbriger
* \date 06/05/2011
*
......@@ -34,6 +33,7 @@
* - 28/06/2011 V1.1 requires extern declaration for C++ since binary
* code is compiled by C++ compiler, not C compiler
* - 30/09/2011 V1.2 implemented handling of additional time series pairs
* - 14/10/2015 V1.3 new end-user usage functions
*
* ============================================================================
*/
......@@ -42,9 +42,7 @@
#ifndef STFINV_STFINV__H_VERSION
#define STFINV_STFINV__H_VERSION \
"STFINV_STFINV__H V1.2"
#define STFINV_STFINV__H_CVSID \
"$Id: stfinv.h 4968 2013-02-01 13:58:05Z lrehor $"
"STFINV_STFINV__H V1.3"
#include <stfinv/waveformheader.h>
......@@ -219,7 +217,7 @@ struct CPairs {
* \param parameters
* Parameters to select one of the engines as well as to control the engines
* are passed in a character sequence.
* See also \ref main_subsec_parameters
* See also \ref page_eu_subsec_parameters
*/
void initstfinvengine(struct CTriples triples,
struct CWaveform stf,
......@@ -259,7 +257,7 @@ void initstfinvengine(struct CTriples triples,
* \param parameters
* Parameters to select one of the engines as well as to control the engines
* are passed in a character sequence.
* See also \ref main_subsec_parameters
* See also \ref page_eu_subsec_parameters
*/
void initstfinvenginewithpairs(struct CTriples triples,
struct CWaveform stf,
......@@ -278,12 +276,26 @@ void runstfinvengine();
*/
void freestfinvengine();
/*! \brief Print online help to stdout
/*! \brief List procedures (engines) on stdout
*
* \ingroup cinterface
*/
void printengines();
/*! \brief Print usage summary to stdout
*
* \ingroup cinterface
*/
void printhelp();
/*! \brief Print detailed description for engine "id" to stdout
*
* \param id character string selecting a specific engine
*
* \ingroup cinterface
*/
void printusage(char* id);
#ifdef __cplusplus
} // extern "C"
#endif
......
......@@ -3,7 +3,6 @@
*
* ----------------------------------------------------------------------------
*
* $Id: stfinvany.cc 4968 2013-02-01 13:58:05Z lrehor $
* \author Thomas Forbriger
* \date 06/05/2011
*
......@@ -32,20 +31,24 @@
* - 06/05/2011 V1.0 Thomas Forbriger
* - 30/09/2011 V1.1 implemented handling of additional time series pairs
* - 04/10/2011 V1.2 renamed Fourier domain least squares engine
* - 14/10/2015 V1.3 new end-user usage functions
*
* ============================================================================
*/
#define STFINV_STFINVANY_CC_VERSION \
"STFINV_STFINVANY_CC V1.1"
#define STFINV_STFINVANY_CC_CVSID \
"$Id: stfinvany.cc 4968 2013-02-01 13:58:05Z lrehor $"
"STFINV_STFINVANY_CC V1.3"
#include <stfinv/stfinvany.h>
#include <stfinv/stfinvfdleastsquares.h>
#include <stfinv/stfinvfixedstf.h>
#include <stfinv/stfinvidentity.h>
#include <stfinv/parameterhandler.h>
#include <stfinv/stfinvany_summary_usage.h>
#include <stfinv/stfinvany_description_usage.h>
#include <stfinv/stfinv_summary_usage.h>
#include <stfinv/stfinv_description_usage.h>
#include <stfinv/error.h>
#include <stfinv/tools.h>
namespace stfinv {
......@@ -80,16 +83,16 @@ namespace stfinv {
std::string id=stfinv::tools::clipstring(para, ":");
if (id == std::string(stfinv::STFEngineIdentity::ID))
{
STFINV_assert(pairs.size()==0,
"ERROR: engine does not support additional time series pairs");
Mengine=new stfinv::STFEngineIdentity(triples, stf, para);
}
/*
else if (id == std::string(stfinv::STFEngineFixedWavelet::ID))
{
STFINV_assert(pairs.size()==0,
"ERROR: engine does not support additional time series pairs");
Mengine=new stfinv::STFEngineFixedWavelet(triples, stf, para);
}
*/
else if ((id == std::string(stfinv::STFEngineFDLeastSquares::ID))
|| (id == std::string("fbd")))
{
......@@ -128,82 +131,74 @@ namespace stfinv {
/*----------------------------------------------------------------------*/
void STFEngine::help(std::ostream& os)
void STFEngine::engines(std::ostream& os)
{
os << "Currently the following engines are available:" << std::endl;
os << "---------------------------------------------" << std::endl;
os << std::endl;
const int width1=10;
/*----------------------------------------------------------------------*/
os.width(width1);
os << STFEngineIdentity::ID;
os.width(0);
os << ": " << STFEngineIdentity::description << std::endl;
/*----------------------------------------------------------------------*/
os.width(width1);
os << STFEngineFixedWavelet::ID;
os.width(0);
os << ": " << STFEngineFixedWavelet::description << std::endl;
/*----------------------------------------------------------------------*/
os.width(width1);
os << STFEngineFDLeastSquares::ID;
os.width(0);
os << ": " << STFEngineFDLeastSquares::description << std::endl;
os << "Available procedures:" << std::endl;
os << "---------------------" << std::endl;
tools::report_engine<STFEngineIdentity>(os);
// tools::report_engine<STFEngineFixedWavelet>(os);
tools::report_engine<STFEngineFDLeastSquares>(os);
} // void STFEngine::help(std::ostream& os=std::cout)
/*======================================================================*/
/*----------------------------------------------------------------------*/
void help(std::ostream& os)
void STFEngine::help(std::ostream& os)
{
os << "Details descriptions of available engines:" << std::endl;
os << "------------------------------------------" << std::endl;
os << stfinv_summary_usage;
os << std::endl;
STFEngineIdentity::classhelp(os);
STFEngine::engines(os);
os << std::endl;
STFEngineFixedWavelet::classhelp(os);
STFEngineIdentity::classhelp(os);
os << std::endl;
STFEngineFDLeastSquares::classhelp(os);
os << std::endl;
STFFourierDomainEngine::classhelp(os);
os << std::endl;
STFBaseEngine::classhelp(os);
os << std::endl;
os << stfinvany_summary_usage;
} // void STFEngine::help(std::ostream& os=std::cout)
// parameter strings
os << "\n";
os << "How to construct parameter strings" << std::endl;
os << "----------------------------------" << std::endl;
os << "A specific engine is selected by passing a parameter string.\n"
<< "This parameter string may further contain parameters to control\n"
<< "the execution mode of the engine.\n";
os << "The parameter string starts with an ID-sequence identifying\n"
<< "the desired engine. See the list below for available engines.\n"
<< "In the parameter string the ID-sequence is terminated by a\n"
<< "colon (:).\n";
os << "After selecting the desired engine, the interface function\n"
<< "strips of the ID-sequence as well as the colon from the\n"
<< "parameter string and initializes the engine and passes the\n"
<< "remainder of the parameter string to the engine. This\n"
<< "remainder may consist of several control parameters being\n"
<< "separated by colons (:). Each control parameter may just be\n"
<< "a flag (switch to turn an option on) or may come along with\n"
<< "a parameter value. The value of the parameter is separated\n"
<< "by an equal sign (=).\n";
os << "\n";
os << "Examples:\n";
os << "- To select Fourier domain least squares and shift\n"
<< " the returned source correction filter wavelet by 0.4s and\n"
<< " switch on verbose mode, pass the following parameter string:\n";
os << " fdlsq:tshift=0.4:verbose\n";
os << "- To select the identity engine and to switch on debug level 4:\n";
os << " ident:DEBUG=4\n";
os << "- To select Fourier domain least squares, apply offset\n"
<< " dependent weights and use a power of two to speed up the FFT:\n";
os << " fdlsq:pow2:exp=1.4\n";
/*----------------------------------------------------------------------*/
void STFEngine::usage(const std::string& id, std::ostream& os)
{
os << stfinv_description_usage;
os << std::endl;
if (id == std::string(stfinv::STFEngineIdentity::ID))
{
stfinv::STFEngineIdentity::classusage(os);
}
else if ((id == std::string(stfinv::STFEngineFDLeastSquares::ID)))
{
stfinv::STFEngineFDLeastSquares::classusage(os);
}
else
{
std::cerr << "ERROR: engine ID " << id << " is unkown!" << std::endl;
STFINV_abort("aborting since engine ID is not recognized");
}
os << std::endl;
os << stfinvany_description_usage;
} // void STFEngine::help(std::ostream& os=std::cout)
/*======================================================================*/
void engines(std::ostream& os)
{
STFEngine::engines(os);
} // void engines(std::ostream& os)
void help(std::ostream& os)
{
STFEngine::help(os);
} // void help(std::ostream& os=std::cout)
void usage(const std::string& id, std::ostream& os)
{
STFEngine::usage(id, os);
} // void usage(const std::string& id, std::ostream& os)
} // namespace stfinv
/* ----- END OF stfinvany.cc ----- */
......@@ -3,7 +3,6 @@
*
* ----------------------------------------------------------------------------
*
* $Id: stfinvany.h 4968 2013-02-01 13:58:05Z lrehor $
* \author Thomas Forbriger
* \date 06/05/2011
*
......@@ -31,6 +30,7 @@
* REVISIONS and CHANGES
* - 06/05/2011 V1.0 Thomas Forbriger
* - 30/09/2011 V1.1 implemented handling of additional time series pairs
* - 14/10/2015 V1.2 new end-user usage functions
*
* ============================================================================
*/
......@@ -39,9 +39,7 @@
#ifndef STFINV_STFINVANY_H_VERSION
#define STFINV_STFINVANY_H_VERSION \
"STFINV_STFINVANY_H V1.1"
#define STFINV_STFINVANY_H_CVSID \
"$Id: stfinvany.h 4968 2013-02-01 13:58:05Z lrehor $"
"STFINV_STFINVANY_H V1.2"
#include<stfinv/stfinvbase.h>
......@@ -55,6 +53,9 @@ namespace stfinv {
* abstract base class stfinv::STFBaseEngine except that the first prefix
* (up to the first colon) in the parameter string is understood to identify
* the selected engine.
*
* It serves as a kind of handle to provide user selectable engines to
* application programs.
*/
class STFEngine {
public:
......@@ -74,7 +75,7 @@ namespace stfinv {
* \param parameters
* Parameters to select one of the engines as well as to control the
* engines are passed in a character sequence.
* See also \ref main_subsec_parameters
* See also \ref page_eu_subsec_parameters
*/
STFEngine(const stfinv::Tvectoroftriples& triples,
const stfinv::Waveform& stf,
......@@ -107,7 +108,7 @@ namespace stfinv {
* \param parameters
* Parameters to select one of the engines as well as to control the
* engines are passed in a character sequence.
* See also \ref main_subsec_parameters
* See also \ref page_eu_subsec_parameters
*/
STFEngine(const stfinv::Tvectoroftriples& triples,
const stfinv::Waveform& stf,
......@@ -119,8 +120,16 @@ namespace stfinv {
stfinv::STFBaseEngine& STFBaseEngine() { return (*Mengine); }
//! \brief Start engine and return source correction filter.
stfinv::Waveform run() { return(Mengine->run()); }
//! \brief List engines currently recognized
//! \brief List procedures (engines) currently recognized
static void engines(std::ostream& os=std::cout);
//! \brief List engines currently recognized and print summary
static void help(std::ostream& os=std::cout);
/*! \brief Print detailed usage description.
*
* \param id ID of procedure (engine) to be described.
* \param os stream to send output to
*/
static void usage(const std::string& id, std::ostream& os=std::cout);
private:
//! \brief initialize engine.
void initialize(const stfinv::Tvectoroftriples& triples,
......@@ -133,11 +142,27 @@ namespace stfinv {
/*----------------------------------------------------------------------*/
/*! print online help of the whole implemented system of engines
/*! print list available procedures (engines)
* \ingroup cxxinterface
*
* Just delegates to STFEngine::engines()
*/
void engines(std::ostream& os=std::cout);
/*! print print usage summary
* \ingroup cxxinterface
*
* Just delegates to STFEngine::help()
*/
void help(std::ostream& os=std::cout);
/*! print print detailed description for selected engine
* \ingroup cxxinterface
*
* Just delegates to STFEngine::usage()
*/
void usage(const std::string& id, std::ostream& os=std::cout);
} // namespace stfinv
#endif // STFINV_STFINVANY_H_VERSION (includeguard)
......
......@@ -3,7 +3,6 @@
*
* ----------------------------------------------------------------------------
*
* $Id: stfinvbase.cc 4161 2011-10-01 08:00:43Z tforb $
* \author Thomas Forbriger
* \date 06/05/2011
*
......@@ -31,21 +30,26 @@
* REVISIONS and CHANGES
* - 06/05/2011 V1.0 Thomas Forbriger
* - 30/09/2011 V1.1 implemented handling of additional time series pairs
* - 14/10/2015 V1.2 new end-user usage functions
*
* ============================================================================
*/
#define STFINV_STFINVBASE_CC_VERSION \
"STFINV_STFINVBASE_CC V1.1"
#define STFINV_STFINVBASE_CC_CVSID \
"$Id: stfinvbase.cc 4161 2011-10-01 08:00:43Z tforb $"
"STFINV_STFINVBASE_CC V1.2"
#include <sstream>
#include <cmath>
#include <stfinv/stfinvbase.h>
#include <stfinv/stfinvbase_summary_usage.h>
#include <stfinv/stfinvbase_description_usage.h>
#include <stfinv/debug.h>
namespace stfinv {
/*!
* Constructor stores all references to time series data passed by the
* caller.
*/
STFBaseEngine::STFBaseEngine(const stfinv::Tvectoroftriples& triples,
const stfinv::Waveform& stf,
const stfinv::Tvectorofpairs& pairs,
......@@ -58,6 +62,10 @@ namespace stfinv {
/*----------------------------------------------------------------------*/
/*!
* Constructor stores all references to time series data passed by the
* caller.
*/
STFBaseEngine::STFBaseEngine(const stfinv::Tvectoroftriples& triples,
const stfinv::Waveform& stf,
const std::string& parameters)
......@@ -69,6 +77,17 @@ namespace stfinv {
/*----------------------------------------------------------------------*/
/*!
* -# The STFBaseEngine::initialize() function parses the parameter string.
* Parsed values are stored in Mparamap.
* -# Extract settings for parameters:
* - DEBUG: set debug output level
* - verbose: activate verbose output
* - exp: set power-law exponent and store weights in member data Mweights
* -# Check consistency of data
* -# Align index ranges of aff::Series objects such that the first element
* (sample) has index zero
*/
void STFBaseEngine::initialize(const std::string& parameters)
{
this->parseparameters(parameters);
......@@ -130,6 +149,13 @@ namespace stfinv {
/*----------------------------------------------------------------------*/
/*!
* Check consistency of time series data passed to the STFBaseEngine
* with respect to
* -# number of samples
* -# sampling interval
*
*/
void STFBaseEngine::checkconsistency() const
{
const unsigned int& n=Mstf.sampling.n;
......@@ -186,18 +212,32 @@ namespace stfinv {
void STFBaseEngine::classhelp(std::ostream& os)
{
os << "Options and parameters in common for all engines:\n"
<< "verbose produce verbose output (if implemented)\n"
<< "DEBUG=l produce debug output with level l\n"
<< "exp=k apply offset dependent weights to signals\n"
<< "If implemented in the engine in use then setting the parameter\n"
<< "exp=k will give a weight factor of ((r/1m)**k) to each signal\n"
<< "in order to compensate the decrease in signal energy."
<< std::endl;
os << stfinvbase_summary_usage;
} // void STFBaseEngine::classhelp(std::ostream& os)
/*----------------------------------------------------------------------*/
void STFBaseEngine::usage(std::ostream& os) const
{
STFBaseEngine::classusage(os);
} // void STFBaseEngine::usage(std::ostream& os) const
/*----------------------------------------------------------------------*/
void STFBaseEngine::classusage(std::ostream& os)
{
os << stfinvbase_description_usage;
} // void STFBaseEngine::classusage(std::ostream& os)
/*----------------------------------------------------------------------*/
/*!
* Pass the parameter string (as usually passed along the chain of
* constructors to the constructor and initialize() function of
* STFBaseEngine).
* The values are stored in the member data
* STFBaseEngine::Mparamap
*/
void STFBaseEngine::parseparameters(std::string parameters)
{
while (parameters.length()>0)
......
......@@ -3,7 +3,6 @@
*
* ----------------------------------------------------------------------------
*
* $Id: stfinvbase.h 4968 2013-02-01 13:58:05Z lrehor $
* \author Thomas Forbriger
* \date 06/05/2011
*
......@@ -31,6 +30,7 @@
* REVISIONS and CHANGES
* - 06/05/2011 V1.0 Thomas Forbriger
* - 30/09/2011 V1.1 implemented handling of additional time series pairs
* - 14/10/2015 V1.2 new end-user usage functions
*
* ============================================================================
*/
......@@ -39,9 +39,7 @@
#ifndef STFINV_STFINVBASE_H_VERSION
#define STFINV_STFINVBASE_H_VERSION \
"STFINV_STFINVBASE_H V1.1"
#define STFINV_STFINVBASE_H_CVSID \
"$Id: stfinvbase.h 4968 2013-02-01 13:58:05Z lrehor $"
"STFINV_STFINVBASE_H V1.2"
#include<stfinv/waveformheader.h>
#include<stfinv/parameterhandler.h>
......@@ -185,8 +183,23 @@ namespace stfinv {
* See STFBaseEngine::parameter() and STFBaseEngine::parameterisset()
* for a description on how parameters are handled within engine classes.
*
* \par Data
* - recordings are understood as recorded waveforms.
* The number of available traces is returned by nreceivers()
* - synthetics are understood as synthetic waveforms generated with a
* generic source time function.
* For each trace of recordings there must be a matching trace of
* synthetics and vice versa.
* - convolvedsynthetics are produced from synthetics as a result of the
* application of the source wavelet correction filter.
* - series are additional synthetic time series, not used to construct the
* source-wavelet correction filter. The number of additional series
* traces is returned by npairs().
* - convolvedseries are produced from series as a result of the
* application of the source wavelet correction filter.
*
* \sa
* \ref sec_page_design_initialization
* \ref page_i_subsec_design_initialization
*
* \todo
* The base class should provide a "log to file" option such that applied
......@@ -215,7 +228,7 @@ namespace stfinv {
virtual ~STFBaseEngine() { }
/*! \name Basic interface for users
* \sa \ref main_sec_users
* \sa \ref page_users
*/
//@{
//! \brief Start engine and return reference to source correction filter.
......@@ -226,10 +239,14 @@ namespace stfinv {
}
//! \brief print online help
virtual void help(std::ostream& os=std::cout) const;
//! \brief print detailed description
virtual void usage(std::ostream& os=std::cout) const;
//! \brief return name of engine
virtual const char* name() const;
//! \brief print online help
static void classhelp(std::ostream& os=std::cout);
//! \brief print detailed description
static void classusage(std::ostream& os=std::cout);
//@}
/*! \name Shape query functions
......@@ -285,6 +302,9 @@ namespace stfinv {
//! \brief return weight for signal at receiver i
double weight(const unsigned int& i) const
{ return(Mweights(i)); }
//! \brief return weights array
aff::Series<double> weights() const
{ return(Mweights); }
//@}
private:
......@@ -293,7 +313,7 @@ namespace stfinv {
//@{
//! \brief initialize base class
void initialize(const std::string& parameters);
//! \brief parse parameters in Mparameters
//! \brief parse parameters and store them in Mparamap
void parseparameters(std::string parameters);