STFINV library: seek source wavelet correction filter
stfinvany.cc
Go to the documentation of this file.
1 
38 #define STFINV_STFINVANY_CC_VERSION \
39  "STFINV_STFINVANY_CC V1.3"
40 
41 #include <stfinv/stfinvany.h>
43 #include <stfinv/stfinvfixedstf.h>
44 #include <stfinv/stfinvidentity.h>
50 #include <stfinv/error.h>
51 #include <stfinv/tools.h>
52 
53 namespace stfinv {
54 
57  const stfinv::Waveform& stf,
58  const std::string& parameters)
59  {
61  pairs.clear();
62  this->initialize(triples, stf, pairs, parameters);
63  }
64 
65  /*----------------------------------------------------------------------*/
68  const stfinv::Waveform& stf,
69  const stfinv::Tvectorofpairs& pairs,
70  const std::string& parameters)
71  {
72  this->initialize(triples, stf, pairs, parameters);
73  }
74 
75  /*----------------------------------------------------------------------*/
76 
78  const stfinv::Waveform& stf,
79  const stfinv::Tvectorofpairs& pairs,
80  const std::string& parameters)
81  {
82  std::string para=parameters;
83  std::string id=stfinv::tools::clipstring(para, ":");
84  if (id == std::string(stfinv::STFEngineIdentity::ID))
85  {
86  Mengine=new stfinv::STFEngineIdentity(triples, stf, para);
87  }
88  /*
89  else if (id == std::string(stfinv::STFEngineFixedWavelet::ID))
90  {
91  STFINV_assert(pairs.size()==0,
92  "ERROR: engine does not support additional time series pairs");
93  Mengine=new stfinv::STFEngineFixedWavelet(triples, stf, para);
94  }
95  */
96  else if ((id == std::string(stfinv::STFEngineFDLeastSquares::ID))
97  || (id == std::string("fbd")))
98  {
100  "The ID \"fbd\" for this engine is deprecated",
101  "The correct ID of the Fourier domain least "
102  "squares engine is \"" <<
104  "\".\n"
105  "The former ID \"fbd\" may vanish in the future "
106  "and should no longer be used.");
107  if (pairs.size()>0)
108  {
109  Mengine=new stfinv::STFEngineFDLeastSquares(triples, stf,
110  pairs, para);
111  }
112  else
113  {
114  Mengine=new stfinv::STFEngineFDLeastSquares(triples, stf, para);
115  }
116  }
117  else
118  {
119  std::cerr << "ERROR: engine ID " << id << " is unkown!" << std::endl;
120  STFINV_abort("aborting since engine ID is not recognized");
121  }
122  STFINV_assert(Mengine!=0, "engine was not created correctly");
123  }
124 
125  /*----------------------------------------------------------------------*/
126 
128  {
129  delete Mengine;
130  } // STFEngine::~STFEngine()
131 
132  /*----------------------------------------------------------------------*/
133 
134  void STFEngine::engines(std::ostream& os)
135  {
136  os << "Available procedures:" << std::endl;
137  os << "---------------------" << std::endl;
138  tools::report_engine<STFEngineIdentity>(os);
139  // tools::report_engine<STFEngineFixedWavelet>(os);
140  tools::report_engine<STFEngineFDLeastSquares>(os);
141  } // void STFEngine::help(std::ostream& os=std::cout)
142 
143  /*----------------------------------------------------------------------*/
144 
145  void STFEngine::help(std::ostream& os)
146  {
147  os << stfinv_summary_usage;
148  os << std::endl;
149  STFEngine::engines(os);
150  os << std::endl;
152  os << std::endl;
154  os << std::endl;
156  os << std::endl;
158  os << std::endl;
160  } // void STFEngine::help(std::ostream& os=std::cout)
161 
162  /*----------------------------------------------------------------------*/
163 
164  void STFEngine::usage(const std::string& id, std::ostream& os)
165  {
167  os << std::endl;
168  if (id == std::string(stfinv::STFEngineIdentity::ID))
169  {
171  }
172  else if ((id == std::string(stfinv::STFEngineFDLeastSquares::ID)))
173  {
175  }
176  else
177  {
178  std::cerr << "ERROR: engine ID " << id << " is unkown!" << std::endl;
179  STFINV_abort("aborting since engine ID is not recognized");
180  }
181  os << std::endl;
183  } // void STFEngine::help(std::ostream& os=std::cout)
184 
185  /*======================================================================*/
186 
187  void engines(std::ostream& os)
188  {
189  STFEngine::engines(os);
190  } // void engines(std::ostream& os)
191 
192  void help(std::ostream& os)
193  {
194  STFEngine::help(os);
195  } // void help(std::ostream& os=std::cout)
196 
197  void usage(const std::string& id, std::ostream& os)
198  {
199  STFEngine::usage(id, os);
200  } // void usage(const std::string& id, std::ostream& os)
201 
202 } // namespace stfinv
203 
204 /* ----- END OF stfinvany.cc ----- */
static const char *const ID
ID used to select thsi engine.
std::vector< stfinv::WaveformPair > Tvectorofpairs
Vector of pairs.
Definition: stfinvbase.h:125
void initialize(const stfinv::Tvectoroftriples &triples, const stfinv::Waveform &stf, const stfinv::Tvectorofpairs &pairs, const std::string &parameters)
initialize engine.
Definition: stfinvany.cc:77
static void classhelp(std::ostream &os=std::cout)
print online help
static void classhelp(std::ostream &os=std::cout)
print online help
Definition: stfinvbase.cc:213
always return a fixed stf as read from file (prototypes)
Root namespace of library.
Definition: doxygen.txt:43
char stfinvany_summary_usage[]
static void engines(std::ostream &os=std::cout)
List procedures (engines) currently recognized.
Definition: stfinvany.cc:134
static void classusage(std::ostream &os=std::cout)
print detailed description
handle a parameter configuration string (prototypes)
#define STFINV_report_assert(C, M, V)
Check an assertion and report only.
Definition: error.h:164
STFEngine(const stfinv::Tvectoroftriples &triples, const stfinv::Waveform &stf, const std::string &parameters)
Constructor.
Definition: stfinvany.cc:56
Engine to apply a scalar factor.
handle error conditions in libstfinv (prototypes)
char stfinvany_description_usage[]
Fourier domain least squares engine.
#define STFINV_assert(C, M)
Check an assertion and report by throwing an exception.
Definition: error.h:140
least squares in the frequency domain (prototypes)
A class to store a single waveform. This will be used to pass the source correction filter...
Definition: stfinvbase.h:111
static void usage(const std::string &id, std::ostream &os=std::cout)
Print detailed usage description.
Definition: stfinvany.cc:164
static const char *const ID
ID used to select this engine.
just find a scaling factor (prototypes)
void engines(std::ostream &os)
Definition: stfinvany.cc:187
#define STFINV_abort(M)
Abort and give a message.
Definition: error.h:147
static void help(std::ostream &os=std::cout)
List engines currently recognized and print summary.
Definition: stfinvany.cc:145
void help(std::ostream &os)
Definition: stfinvany.cc:192
static void classusage(std::ostream &os=std::cout)
print detailed description
~STFEngine()
Destructor must remove engine.
Definition: stfinvany.cc:127
tools and utilities (prototypes)
char stfinv_description_usage[]
std::vector< stfinv::WaveformTriple > Tvectoroftriples
Vector of triples.
Definition: stfinvbase.h:132
std::string clipstring(std::string &s, const std::string &delim=":")
static void classhelp(std::ostream &os=std::cout)
print online help
char stfinv_summary_usage[]
a wrapper to any STF engine in the library (prototypes)
stfinv::STFBaseEngine * Mengine
Pointer to actual engine.
Definition: stfinvany.h:140
static void classhelp(std::ostream &os=std::cout)
print online help
void usage(const std::string &id, std::ostream &os)
Definition: stfinvany.cc:197