LISOUSI: Line Source Simulation
tdtapertransformation.cc
Go to the documentation of this file.
1 
35 #define TF_TDTAPERTRANSFORMATION_CC_VERSION \
36  "TF_TDTAPERTRANSFORMATION_CC V1.1"
37 
38 #include "lisousi.h"
39 #include "functions.h"
40 
42  Parameters& par,
43  const Options& opt)
44 {
45  /*-------------------------------------*/
46  /* set offset dependent scaling factor */
47 
48  TFXX_debug(opt.debug, "tdtapertransformation",
49  "transformation with time domain taper");
50 
51  if (opt.sqrttaper)
52  {
53  if (opt.verbose)
54  {
55  cout << " apply reflected wave approximation for wave "
56  << "velocity: " << opt.velocity << " km/s" << endl;
57  }
58  par.offsetfactor=opt.velocity*1.e3*sqrt(2.);
59  }
60  else
61  {
62  if (opt.verbose)
63  {
64  cout << " apply direct wave approximation for travel "
65  << "distance: " << par.offset << " m" << endl;
66  }
67  par.offsetfactor=par.offset*sqrt(2.);
68  }
69 
70  /*-------------------------------------------*/
71  /* prepare filter impulse response and taper */
72 
73  // prepare taper
74  if (taper.size() < series.size())
75  {
76  taper=filterresponse(series.size(), par.dt, opt);
77  filter=taper;
78 
79  if (opt.sqrttaper)
80  {
81  if (opt.verbose)
82  {
83  cout << " apply sqrt(t) taper" << endl;
84  }
85  filter=taper.copyout();
86  // prepare alternative taper
87  aff::Iterator<Tseries> I(taper);
88  for (unsigned int i=0; i<taper.size(); ++i)
89  {
90  *I=sqrt(double(i)*par.dt);
91  ++I;
92  }
93  }
94  }
95 
96  // apply taper
97  if (opt.taperfirst)
98  {
99  TFXX_debug(opt.debug, "tdtapertransformation", "apply taper");
100  series=applytaper(series, taper, par.offsetfactor, par.dt, par.offset, opt);
101  }
102 
103  /*-------------------------------------------*/
104  /* apply filter impulse response and taper */
105 
106  Tseries convresult;
107  if (opt.tdfilter)
108  {
109  if (opt.verbose)
110  {
111  cout << " apply 1/sqrt(t) filter in the time domain" << endl;
112  }
113  // time domain convolution
114  convresult=ts::convolve(series, filter) * par.dt;
115  // trim to reasonable index range
116  // see comments in documentation of ts::convolve
117  convresult.setlastindex(convresult.f()+series.size()-1);
118  }
119  else if (opt.fdfilter)
120  {
121  if (opt.verbose)
122  {
123  cout <<
124  " apply 1/sqrt(t) filter from discrete Fourier transform"
125  << endl;
126  }
127 
128  TFourier::Tspectrum scoeff=Fourier(series, par.dt);
129  TFourier::Tspectrum fcoeff=Fourier(filter, par.dt);
130 
131  aff::Browser<TFourier::Tspectrum> IF(fcoeff);
132  aff::Iterator<TFourier::Tspectrum> IS(scoeff);
133  while (IF.valid() && IS.valid())
134  {
135  (*IS) *= (*IF);
136  ++IS;
137  ++IF;
138  }
139 
140  convresult=Fourier(scoeff, par.dt);
141  }
142  else
143  {
144  if (opt.verbose)
145  {
146  cout <<
147  " apply analytic Fourier transform of 1/sqrt(t)"
148  << endl;
149  }
150  // Fourier domain convolution
151  TFourier::Tspectrum coeff=Fourier(series, par.dt);
152  const TFourier::Tcoeff IME(0.,1.);
153  const double df=1./par.T;
154  for (unsigned int i=coeff.f(); i<=coeff.l(); ++i)
155  {
156  double ifre=i-coeff.f();
157  double f=ifre*df;
158  if (f<df) { f=0.1*df; }
159  coeff(i) *= sqrt(M_PI/2.)*(1.-IME)/sqrt(2.*M_PI*f);
160  }
161  convresult=Fourier(coeff, par.dt);
162  }
163 
164  /*---------------------------------------------*/
165 
166  TFourier::Tseries retseries;
167  // apply taper
168  if (!opt.taperfirst)
169  {
170  TFXX_debug(opt.debug, "tdtapertransformation", "apply taper");
171  retseries=applytaper(convresult, taper, par.offsetfactor, par.dt,
172  par.offset, opt);
173  }
174  else
175  {
176  retseries=convresult;
177  }
178  return(retseries);
179 }
180 
181 /* ----- END OF tdtapertransformation.cc ----- */
Ttimeseries::Tseries Tseries
Definition: lisousi.h:71
prototypes and structs for lisousi (prototypes)
double velocity
Definition: lisousi.h:128
const TFourier::Tcoeff IME
Definition: lisousi.h:85
Tseries filterresponse(const int &size, const double &dt, const Options &opt)
double T
duration of total recording.
Definition: lisousi.h:160
Tseries filter
Definition: globaldata.cc:47
time series parameters.
Definition: lisousi.h:138
double offsetfactor
scaling factor to be applied at given offset.
Definition: lisousi.h:145
bool debug
Definition: lisousi.h:117
TFourier::Tseries tdtapertransformation(TFourier::Tseries series, Parameters &par, const Options &opt)
bool tdfilter
Definition: lisousi.h:119
TFourier Fourier
Definition: globaldata.cc:44
bool taperfirst
Definition: lisousi.h:118
bool verbose
Definition: lisousi.h:117
double dt
sampling interval
Definition: lisousi.h:162
lisousi functions (prototypes)
double offset
either epicentral distance or hypocentral distance.
Definition: lisousi.h:150
Tseries taper
Definition: globaldata.cc:47
bool fdfilter
Definition: lisousi.h:119
bool sqrttaper
Definition: lisousi.h:118
Tseries applytaper(const Tseries::Tcoc &input, const Tseries::Tcoc &taper, const double &factor, const double &dt, const double &offset, const Options &opt)
Definition: applytaper.cc:41