STFINV library: seek source wavelet correction filter

◆ taperstf()

void stfinv::STFFourierDomainEngine::taperstf ( )
private

apply a time domain taper to the correction filter response.

Apply a time domain taper to the impulse response of the source time function correction filter.

Definition at line 577 of file stfinvfourier.cc.

References stfinv::STFBaseEngine::dt(), Mapplystftaper, stfinv::STFBaseEngine::Mdebug, Mfftenginestf, Mtt1, Mtt2, Mtt3, Mtt4, stfinv::STFBaseEngine::nsamples(), STFINV_assert, STFINV_debug, STFINV_value, stfseries(), and stfspec().

Referenced by fftoutput().

578  {
579  STFINV_debug(Mdebug&16, "STFFourierDomainEngine::taperstf()",
581  if (this->Mapplystftaper)
582  {
583  // transform correction filter to time domain
584  Mfftenginestf.c2r();
585  Tfftengine::TAseries thestfseries=this->stfseries();
586  thestfseries *= Mfftenginestf.scale_series(this->dt());
587  // apply taper
588  /*
589  * Concept of application to periodic time series allowing for negative
590  * values of taper times:
591  *
592  * All samples between t2 and t3 remain unaltered. It is reasonable to
593  * process the taper starting at t3 passing t4 to t1 and then ending at
594  * t2. Behind this is the concept that time series are implicitely
595  * periodic in discrete Fourier transform.
596  */
597  // samples in series
598  int nsamples=thestfseries.size(0);
599  // duration of time series
600  double T=this->dt()*nsamples;
601  // make sure taper definition is not longer than time series.
602  STFINV_assert((this->Mtt4-this->Mtt1)<T,
603  "Taper width is larger than length of time series");
604  // set taper time values under conpect of periodic series
605  double tt3=this->Mtt3;
606  double tt4=this->Mtt4;
607  double tt1=this->Mtt1+T;
608  double tt2=this->Mtt2+T;
609  // sample to start at
610  int l3=int(std::floor(tt3/this->dt()));
611  int l2=int(std::ceil(tt2/this->dt()));
612  STFINV_debug(Mdebug&16, "STFFourierDomainEngine::taperstf()",
613  STFINV_value(T) << "\n " <<
614  STFINV_value(this->dt()) << "\n " <<
615  STFINV_value(nsamples) << "\n " <<
616  STFINV_value(tt3) << "\n " <<
617  STFINV_value(tt4) << "\n " <<
618  STFINV_value(tt1) << "\n " <<
619  STFINV_value(tt2) << "\n " <<
620  STFINV_value(l3) << "\n " <<
621  STFINV_value(l2));
622  for (int l=l3; l<=l2; ++l)
623  {
624  // time of sample
625  double t=l*this->dt();
626  // index to series
627  int rl = l%nsamples;
628  if (rl < 0) { rl += nsamples; }
629  STFINV_assert(((rl >= thestfseries.f(0)) &&
630  (rl <= thestfseries.l(0))),
631  "Index out of range. Internal programming error! "
632  "Report as bug!")
633  // taper factor
634  double factor=1.;
635  if ( (t>=tt3) && (t<=tt4) && (tt4>tt3) )
636  {
637  factor=0.5+0.5*cos(M_PI*(t-tt3)/(tt4-tt3));
638  }
639  else if ( (t>tt4) && (t<tt1) )
640  {
641  factor=0.;
642  }
643  else if ( (t>=tt1) && (t<=tt2) && (tt2>tt1) )
644  {
645  factor=0.5-0.5*cos(M_PI*(t-tt1)/(tt2-tt1));
646  }
647  // apply to series
648  thestfseries(rl) = thestfseries(rl)*factor;
649  STFINV_debug(Mdebug&16, "STFFourierDomainEngine::taperstf()",
650  STFINV_value(t) << " " <<
651  STFINV_value(l) << " " <<
652  STFINV_value(rl) << " " <<
653  STFINV_value(factor));
654  }
655  // transform correction filter to Fourier domain
656  Mfftenginestf.r2c();
657  this->stfspec() *= Mfftenginestf.scale_spectrum(this->dt());
658  } // if (this->Mapplystftaper)
659  } // void STFFourierDomainEngine::taperstf()
double Mtt4
time values defining taper.
double Mtt2
time values defining taper.
Tfftengine Mfftenginestf
FFT processor for source time function correction filter.
double Mtt3
time values defining taper.
double Mtt1
time values defining taper.
unsigned int nsamples() const
return number of samples used in time series
Definition: stfinvbase.h:256
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
double dt() const
return sampling interval
Definition: stfinvbase.h:265
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: