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

STFFourierDomainEngine::initialize() is implemented

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: 3972
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 039ecfbe
...@@ -60,7 +60,7 @@ namespace stfinv { ...@@ -60,7 +60,7 @@ namespace stfinv {
void STFBaseEngine::checkconsistency() const void STFBaseEngine::checkconsistency() const
{ {
const int& n=Mstf.sampling.n; const unsigned int& n=Mstf.sampling.n;
const double& dt=Mstf.sampling.dt; const double& dt=Mstf.sampling.dt;
const double tolerance=1.e-4; const double tolerance=1.e-4;
stfinv::Tvectoroftriples::const_iterator I=Mtriples.begin(); stfinv::Tvectoroftriples::const_iterator I=Mtriples.begin();
......
...@@ -161,6 +161,12 @@ namespace stfinv { ...@@ -161,6 +161,12 @@ namespace stfinv {
virtual void help(std::ostream& os=std::cout) const; virtual void help(std::ostream& os=std::cout) const;
//! \brief return name of engine //! \brief return name of engine
virtual const char* name() const; virtual const char* name() const;
//! \brief return number of samples used in time series
unsigned int nsamples() const
{ return (Mstf.sampling.n); }
//! \brief return number of receiver signals in use
unsigned int nreceivers() const
{ return (Mtriples.size()); }
protected: protected:
//! \brief return the value of a parameters //! \brief return the value of a parameters
std::string parameter(const std::string& key, std::string parameter(const std::string& key,
......
...@@ -72,13 +72,6 @@ namespace stfinv { ...@@ -72,13 +72,6 @@ namespace stfinv {
STFFourierDomainEngine::classhelp(os); STFFourierDomainEngine::classhelp(os);
} // void STFFourierDomainEngine::help(std::ostream& os) const } // void STFFourierDomainEngine::help(std::ostream& os) const
/*----------------------------------------------------------------------*/
void STFFourierDomainEngine::classhelp(std::ostream& os)
{
os << "This class is not yet implemented." << std::endl;
os << "Online help is not yet provided." << std::endl;
} // void STFFourierDomainEngine::classhelp(std::ostream& os)
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
...@@ -86,13 +79,53 @@ namespace stfinv { ...@@ -86,13 +79,53 @@ namespace stfinv {
{ {
return("STFFourierDomainEngine"); return("STFFourierDomainEngine");
} // const char const* STFFourierDomainEngine::name() const } // const char const* STFFourierDomainEngine::name() const
/*----------------------------------------------------------------------*/
/*! \brief online help text giving information on options
*
* This must be kept synchronous with the options used by
* STFFourierDomainEngine::initialize()
*/
void STFFourierDomainEngine::classhelp(std::ostream& os)
{
os << "This class is not yet implemented." << std::endl;
os << "Online help is not yet provided." << std::endl;
} // void STFFourierDomainEngine::classhelp(std::ostream& os)
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
/*! \brief Create FFT engines
*
* \par Number of samples
* For the FFT we usually use a number of samples larger than that of the
* underlying time series.
* This way we at least partially avoid the undesired effect of the cyclic
* discrete Fourier transform, which can lead to wrap-around.
* Currently there are three ways to modify the number of samples actually
* used:
* -# Option \c fpad specifies an padding factor.
* The number of samples simply is larger than the number of samples of
* the underlying time series by this factor.
* -# Option \c fpow2:
* If set, the next power of two larger than the fpad*nsamples is used.
* -# Option \c fdiv specifies a divisor.
* If set and if \c fpow2 is not set the number of samples will be the
* next integer multiple of the divisor larger than fpad*nsamples.
*
* \par Workspace
* Two FFT engines will be created:
* -# One engine (\c Mfftengineinput) being shared by recorded data and
* synthetic data, because both have to be transformed to Fourier domain at
* once.
* -# One engine (\c Mfftengineoutpu) being shared by the stf and the
* convolved synthetics, because both have to be transformed to the time
* domain at once.
*/
void STFFourierDomainEngine::initialize() void STFFourierDomainEngine::initialize()
{ {
STFINV_abort("STFFourierDomainEngine::initialize not yet implemented");
// extract parameter values // extract parameter values
// ------------------------
// padding factor
double padfactor; double padfactor;
{ {
std::istringstream is(this->parameter("fpad","1.5")); std::istringstream is(this->parameter("fpad","1.5"));
...@@ -100,16 +133,44 @@ namespace stfinv { ...@@ -100,16 +133,44 @@ namespace stfinv {
} }
STFINV_assert(padfactor >= 1., STFINV_assert(padfactor >= 1.,
"ERROR: parameter for option \"fpad\" not larger or equal 1"); "ERROR: parameter for option \"fpad\" not larger or equal 1");
// flag: use power of two
bool poweroftwo=(this->parameter("fpow2","false")=="true"); bool poweroftwo=(this->parameter("fpow2","false")=="true");
// flag: use integer multiples of divisor
bool divisorset=this->parameterisset("fdiv"); bool divisorset=this->parameterisset("fdiv");
// number of samples shall be integer power of divisor
unsigned int divisor; unsigned int divisor;
if (divisorset) if (divisorset)
{ {
std::istringstream is (this->parameter("fdiv","100")); std::istringstream is (this->parameter("fdiv","100"));
STFINV_assert(divisor > 0,
"ERROR: parameter for option \"fdiv\" not larger than 0");
} }
// define number of samples to be used by Fourier engine // define number of samples to be used by Fourier engine
// -----------------------------------------------------
// use at least the number of samples sepcified by the padfactor
unsigned int nsamples=padfactor*this->nsamples();
if (nsamples<this->nsamples()) { nsamples=this->nsamples(); }
// power of two has precendence
if (poweroftwo)
{
unsigned int n=2;
while (n<nsamples) { n *= 2; }
nsamples=n;
}
else if (divisorset)
{
unsigned int rest=nsamples % divisor;
nsamples -= rest;
nsamples += divisor;
} // if (poweroftwo) or (divisorset)
// allocate workspace by creating engines
// --------------------------------------
Mfftengineinput=fourier::fft::DRFFTWAFFArrayEngine(2*this->nreceivers(),
nsamples);
Mfftengineoutput=fourier::fft::DRFFTWAFFArrayEngine(1+this->nreceivers(),
nsamples);
} // void STFFourierDomainEngine::initialize() } // void STFFourierDomainEngine::initialize()
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
......
...@@ -64,7 +64,7 @@ extern "C" { ...@@ -64,7 +64,7 @@ extern "C" {
double dt; double dt;
/*! \brief Number of samples in time series array. /*! \brief Number of samples in time series array.
*/ */
int n; unsigned int n;
}; // struct CWaveformHeader }; // struct CWaveformHeader
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
......
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