STFINV library: seek source wavelet correction filter
stfinvidentity.cc
Go to the documentation of this file.
1 
39 #define STFINV_STFINVIDENTITY_CC_VERSION \
40  "STFINV_STFINVIDENTITY_CC V1.3"
41 
42 #include <stfinv/stfinvidentity.h>
45 #include <aff/functions/sqrsum.h>
46 #include <aff/seriesoperators.h>
47 #include <cmath>
48 #include <stfinv/tools.h>
49 
50 namespace stfinv {
51 
52  const char* const STFEngineIdentity::ID="ident";
53 
54  const char* const STFEngineIdentity::description
55  ="scale with amplitude factor";
56 
57  /*----------------------------------------------------------------------*/
58 
59  void STFEngineIdentity::help(std::ostream& os) const
60  {
62  } // void STFEngineIdentity::help(std::ostream& os) const
63 
64  /*----------------------------------------------------------------------*/
65 
66  void STFEngineIdentity::usage(std::ostream& os) const
67  {
69  } // void STFEngineIdentity::usage(std::ostream& os) const
70 
71  /*----------------------------------------------------------------------*/
72 
73  const char* STFEngineIdentity::name() const
74  {
75  return("STFEngineIdentity");
76  } // const char const* STFEngineIdentity::name() const
77 
78  /*----------------------------------------------------------------------*/
79 
81  {
82  // scale energy
83  Mscaleenergy=(this->parameter("scaleenergy","false")=="true");
84  } // void STFEngineIdentity::initialize()
85 
86  /*----------------------------------------------------------------------*/
87 
89  {
90  // effective amplitude factor
91  double fac=1.;
92 
93  // scale to reproduce average energy if requested
94  if (Mscaleenergy)
95  {
96  double recording_sqrsum=0.;;
97  double synthetic_sqrsum=0.;;
98  for (unsigned int i=0; i<this->nreceivers(); ++i)
99  {
100  synthetic_sqrsum
101  += aff::func::sqrsum(this->synthetic(i))
102  * this->weight(i) * this->weight(i);
103  recording_sqrsum
104  += aff::func::sqrsum(this->recording(i))
105  * this->weight(i) * this->weight(i);
106  fac = std::sqrt(recording_sqrsum/synthetic_sqrsum);
107  }
108  } // if (Mscaleenergy)
109 
110  Tseries stf=this->stf();
111  stf=0.;
112  stf(0)=fac/this->dt();
113  for (unsigned int i=0; i<this->nreceivers(); ++i)
114  {
115  Tseries::Tcoc synthetic=this->synthetic(i);
118  if (Mscaleenergy) { convolvedsynthetic *= fac; }
119  }
120  for (unsigned int i=0; i<this->npairs(); ++i)
121  {
122  Tseries::Tcoc series=this->series(i);
124  convolvedseries.copyin(series);
125  if (Mscaleenergy) { convolvedseries *= fac; }
126  }
127  } // void STFEngineIdentity::exec()
128 
129  /*----------------------------------------------------------------------*/
130 
131  void STFEngineIdentity::classhelp(std::ostream& os)
132  {
134  os << std::endl;
135  stfinv::tools::report_engine_ID<STFEngineIdentity>(os);
136  } // void STFEngineIdentity::classhelp(std::ostream& os)
137 
138  /*----------------------------------------------------------------------*/
139 
140  void STFEngineIdentity::classusage(std::ostream& os)
141  {
143  os << std::endl;
144  Tbase::classusage(os);
145  os << std::endl;
146  stfinv::tools::report_engine_ID<STFEngineIdentity>(os);
147  } // void STFEngineIdentity::classusage(std::ostream& os)
148 
149 } // namespace stfinv
150 
151 /* ----- END OF stfinvidentity.cc ----- */
bool Mscaleenergy
scale energy
static const char *const ID
ID used to select thsi engine.
unsigned int npairs() const
return number of additional signals to be convolved
Definition: stfinvbase.h:262
unsigned int nreceivers() const
return number of receiver signals in use
Definition: stfinvbase.h:259
virtual const char * name() const
return name of engine
double weight(const unsigned int &i) const
return weight for signal at receiver i
Definition: stfinvbase.h:303
char stfinvidentity_summary_usage[]
Root namespace of library.
Definition: doxygen.txt:43
virtual void usage(std::ostream &os=std::cout) const
print detailed description
static const char *const description
short description of this engine
static void classusage(std::ostream &os=std::cout)
print detailed description
std::string parameter(const std::string &key, const std::string &defvalue="false") const
return the value of a parameters
Definition: stfinvbase.cc:279
Tseries::Tcoc recording(const unsigned int &i) const
return recorded data at receiver i
Definition: stfinvbase.cc:303
Tseries::Tcoc series(const unsigned int &i) const
return synthetic data of pair i
Definition: stfinvbase.cc:327
static void classusage(std::ostream &os=std::cout)
print detailed description
Definition: stfinvbase.cc:227
Tseries::Tcoc synthetic(const unsigned int &i) const
return synthetic data at receiver i
Definition: stfinvbase.cc:311
Tseries convolvedseries(const unsigned int &i) const
return synthetic data convolved with stf for pair i
Definition: stfinvbase.cc:335
char stfinvidentity_description_usage[]
double dt() const
return sampling interval
Definition: stfinvbase.h:265
void initialize()
initialize work space
just find a scaling factor (prototypes)
virtual void help(std::ostream &os=std::cout) const
print online help
tools and utilities (prototypes)
virtual void exec()
Start engine.
Tseries convolvedsynthetic(const unsigned int &i) const
return synthetic data convolved with stf at receiver i
Definition: stfinvbase.cc:319
Tseries stf() const
return source correction filter series
Definition: stfinvbase.h:273
aff::Series< Tvalue > Tseries
Type of sample values.
Definition: stfinvbase.h:56
static void classhelp(std::ostream &os=std::cout)
print online help