LISOUSI: Line Source Simulation
transitionmixer.cc
Go to the documentation of this file.
1 
35 #define TF_TRANSITIONMIXER_CC_VERSION \
36  "TF_TRANSITIONMIXER_CC V1.0"
37 
38 #include "lisousi.h"
39 #include "functions.h"
40 
42  TFourier::Tseries directwaveseries,
43  const Parameters& par,
44  const Options& opt)
45 {
46  TFourier::Tseries series;
47 
48  // trim number of samples
49  if (opt.transition1<=par.offset)
50  {
51  directwaveseries.setlastindex(par.nsamples+
52  directwaveseries.f()-1);
53  }
54  if (opt.transition2>=par.offset)
55  {
56  singlevelocityseries.setlastindex(par.nsamples+
57  singlevelocityseries.f()-1);
58  }
59  // report offset
60  if (opt.verbose)
61  {
62  cout << " offset " << par.offset << "m: ";
63  }
64  // enter mixing operation
65  if (opt.transition1>=par.offset)
66  {
67  series=singlevelocityseries;
68  if (opt.verbose)
69  {
70  cout << "100% single velocity transformation" << endl;
71  }
72  }
73  else if (opt.transition2<=par.offset)
74  {
75  series=directwaveseries;
76  if (opt.verbose)
77  {
78  cout << "100% direct wave transformation" << endl;
79  }
80  }
81  else
82  {
83  const double dwf=(par.offset-opt.transition1)/
84  (opt.transition2-opt.transition1);
85  const double svf=1.-dwf;
86  series=Tseries(par.nsamples);
87  if (opt.verbose)
88  {
89  cout << 100.*svf << "% single velocity and "
90  << 100.*dwf << "% direct wave transformation" << endl;
91  }
92 
93  aff::Browser<Tseries> DWB(directwaveseries);
94  aff::Browser<Tseries> SVB(singlevelocityseries);
95  aff::Iterator<Tseries> SI(series);
96  while (DWB.valid() && SVB.valid() && SI.valid())
97  {
98  (*SI) = dwf*(*DWB) + svf*(*SVB);
99  ++DWB;
100  ++SVB;
101  ++SI;
102  }
103  }
104  return(series);
105 }
106 
107 /* ----- END OF transitionmixer.cc ----- */
Ttimeseries::Tseries Tseries
Definition: lisousi.h:71
prototypes and structs for lisousi (prototypes)
time series parameters.
Definition: lisousi.h:138
double transition2
Definition: lisousi.h:122
TFourier::Tseries transitionmixer(TFourier::Tseries singlevelocityseries, TFourier::Tseries directwaveseries, const Parameters &par, const Options &opt)
bool verbose
Definition: lisousi.h:117
int nsamples
number of samples
Definition: lisousi.h:164
lisousi functions (prototypes)
double offset
either epicentral distance or hypocentral distance.
Definition: lisousi.h:150
double transition1
Definition: lisousi.h:122