STFINV library: seek source wavelet correction filter

◆ initialize()

void stfinv::STFFourierDomainEngine::initialize ( )
private

initialize work space

Create FFT engines.

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:
  1. Option 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.
  2. Option fpow2: If set, the next power of two larger than the fpad*nsamples is used.
  3. Option fdiv specifies a divisor. If set and if fpow2 is not set the number of samples will be the next integer multiple of the divisor larger than fpad*nsamples.
Workspace
Two FFT engines will be created. They are only used one-way, since input data is not altered during processing input time series only have to be transformed once to Fourier domain. Results of processing have to be transformed to time domain.
  1. One engine (STFFourierDomainEngine::Mfftengineinput) being shared by recorded data and synthetic data, because both have to be transformed to Fourier domain at once. Transformation to Fourier domain takes place in STFFourierDomainEngine::fftinput.
  2. One engine (STFFourierDomainEngine::Mfftengineoutput) being shared by the stf and the convolved synthetics, because both have to be transformed to the time domain at once. Transformation to time domain takes place in STFFourierDomainEngine::fftoutput.

Definition at line 191 of file stfinvfourier.cc.

References Mapplyshift, Mapplystftaper, stfinv::STFBaseEngine::Mdebug, Mfftengineinput, Mfftengineoutput, Mfftenginestf, Mtshift, Mtt1, Mtt2, Mtt3, Mtt4, stfinv::STFBaseEngine::npairs(), stfinv::STFBaseEngine::nreceivers(), stfinv::STFBaseEngine::nsamples(), stfinv::STFBaseEngine::parameter(), stfinv::STFBaseEngine::parameterisset(), stfinv::tools::secomtospace(), STFINV_assert, STFINV_debug, STFINV_value, stfseries(), and stfspec().

Referenced by STFFourierDomainEngine().

192  {
193  // extract parameter values
194  // ------------------------
195  // padding factor
196  double padfactor;
197  {
198  std::istringstream is(this->parameter("fpad","1.5"));
199  is >> padfactor;
200  }
201  STFINV_assert(padfactor >= 1.,
202  "ERROR: parameter for option \"fpad\" not larger or equal 1");
203  // flag: use power of two
204  bool poweroftwo=(this->parameter("fpow2","false")=="true");
205  // flag: use integer multiples of divisor
206  bool divisorset=this->parameterisset("fdiv");
207  // number of samples shall be integer power of divisor
208  unsigned int divisor=1;
209  if (divisorset)
210  {
211  std::istringstream is (this->parameter("fdiv","100"));
212  is >> divisor;
213  STFINV_assert(divisor > 0,
214  "ERROR: parameter for option \"fdiv\" not larger than 0");
215  }
216 
217  // define number of samples to be used by Fourier engine
218  // -----------------------------------------------------
219  // use at least the number of samples sepcified by the padfactor
220  unsigned int nsamples=padfactor*this->nsamples();
221  if (nsamples<this->nsamples()) { nsamples=this->nsamples(); }
222  // power of two has precendence
223  if (poweroftwo)
224  {
225  unsigned int n=2;
226  while (n<nsamples) { n *= 2; }
227  nsamples=n;
228  }
229  else if (divisorset)
230  {
231  unsigned int rest=nsamples % divisor;
232  nsamples -= rest;
233  nsamples += divisor;
234  } // if (poweroftwo) or (divisorset)
235 
236  // allocate workspace by creating engines
237  // --------------------------------------
238  Mfftengineinput=fourier::fft::DRFFTWAFFArrayEngine(
239  2*this->nreceivers()+this->npairs(),
240  nsamples);
241  Mfftengineoutput=fourier::fft::DRFFTWAFFArrayEngine(
242  1+this->nreceivers()+this->npairs(),
243  nsamples);
244  Mfftenginestf=fourier::fft::DRFFTWAFFArrayEngine(this->stfseries(),
245  this->stfspec());
246 
247  // set time shift for STF if requested
248  // -----------------------------------
249  {
250  std::istringstream is(this->parameter("tshift","0."));
251  is >> Mtshift;
252  }
253  Mapplyshift=this->parameterisset("tshift");
254 
255  // taper definition
256  // ----------------
257  {
258  std::istringstream is(stfinv::tools::secomtospace(
259  this->parameter("irtap","0.,1.,2.,3.")));
260  is >> Mtt1 >> Mtt2 >> Mtt3 >> Mtt4;
261  }
262  Mapplystftaper=this->parameterisset("irtap");
263  STFINV_assert((Mtt1<=Mtt2) && (Mtt2<=Mtt3) && (Mtt3<=Mtt4),
264  "ERROR: taper definition times not in increasing order");
265 
266  STFINV_debug(Mdebug&1, "STFFourierDomainEngine::initialize()",
267  STFINV_value(this->nsamples()) << "\n " <<
268  STFINV_value(padfactor) << "\n " <<
269  STFINV_value(divisor) << "\n " <<
270  STFINV_value(nsamples) << "\n " <<
271  STFINV_value(Mapplyshift) << "\n " <<
272  STFINV_value(Mtshift) << "\n " <<
273  STFINV_value(Mapplystftaper) << "\n " <<
274  STFINV_value(Mtt1) << "\n " <<
275  STFINV_value(Mtt2) << "\n " <<
276  STFINV_value(Mtt3) << "\n " <<
277  STFINV_value(Mtt4));
278  } // void STFFourierDomainEngine::initialize()
bool parameterisset(const std::string &key) const
check is parameter was set by user
Definition: stfinvbase.cc:266
unsigned int npairs() const
return number of additional signals to be convolved
Definition: stfinvbase.h:262
double Mtt4
time values defining taper.
double Mtt2
time values defining taper.
unsigned int nreceivers() const
return number of receiver signals in use
Definition: stfinvbase.h:259
Tfftengine Mfftenginestf
FFT processor for source time function correction filter.
double Mtt3
time values defining taper.
double Mtt1
time values defining taper.
bool Mapplyshift
true if shift must be applied
double Mtshift
time shift to be applied to STF in order to expose acausal parts
unsigned int nsamples() const
return number of samples used in time series
Definition: stfinvbase.h:256
std::string parameter(const std::string &key, const std::string &defvalue="false") const
return the value of a parameters
Definition: stfinvbase.cc:279
TAseries stfseries() const
return reference to time series container of stf
#define STFINV_value(P)
report value in a sequence of output operators
Definition: debug.h:62
#define STFINV_assert(C, M)
Check an assertion and report by throwing an exception.
Definition: error.h:140
TAspectrum stfspec() const
return reference to Fourier transform of stf
int Mdebug
debug level
Definition: stfinvbase.h:336
std::string secomtospace(std::string s)
int n
Number of pairs in the array.
Definition: stfinv.h:190
Tfftengine Mfftengineinput
combined FFT engine for recorded data and synthetics and additional time series
Tfftengine Mfftengineoutput
combined FFT engine for stf and convolved synthetics and additional convolved time series ...
bool Mapplystftaper
true if time domain taper should be applied to filter response.
#define STFINV_debug(C, N, M)
produce debug output
Definition: debug.h:49
Here is the call graph for this function:
Here is the caller graph for this function: