stfinvbase.h 7.28 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*! \file stfinvbase.h
 * \brief C++ interface and abstract base class (prototypes)
 * 
 * ----------------------------------------------------------------------------
 * 
 * $Id$
 * \author Thomas Forbriger
 * \date 06/05/2011
 * 
 * C++ interface and abstract base class (prototypes)
 * 
 * Copyright (c) 2011 by Thomas Forbriger (BFO Schiltach) 
 *
 * ----
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version. 
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 * ----
 *
 * 
 * REVISIONS and CHANGES 
 *  - 06/05/2011   V1.0   Thomas Forbriger
 * 
 * ============================================================================
 */

// include guard
#ifndef STFINV_STFINVBASE_H_VERSION

#define STFINV_STFINVBASE_H_VERSION \
  "STFINV_STFINVBASE_H   V1.0   "
#define STFINV_STFINVBASE_H_CVSID \
  "$Id$"

45
#include<stfinv/waveformheader.h>
46
#include<stfinv/parameterhandler.h>
47
#include<stfinv/error.h>
thomas.forbriger's avatar
thomas.forbriger committed
48
#include<aff/series.h>
49
#include<iostream>
50
#include<vector>
thomas.forbriger's avatar
thomas.forbriger committed
51

52
53
namespace stfinv {

thomas.forbriger's avatar
thomas.forbriger committed
54
  /*! \brief Type of sample values.
thomas.forbriger's avatar
thomas.forbriger committed
55
   * \ingroup cxxinterface
thomas.forbriger's avatar
thomas.forbriger committed
56
57
58
59
60
61
   */
  typedef aff::Series<Tvalue> Tseries;

  /*----------------------------------------------------------------------*/

  /*! \brief A class to store the time series for a waveform triple.
thomas.forbriger's avatar
thomas.forbriger committed
62
   * \ingroup cxxinterface
thomas.forbriger's avatar
thomas.forbriger committed
63
  */
64
  struct WaveformTriple {
thomas.forbriger's avatar
thomas.forbriger committed
65
66
67
68
    /*! \brief The header is expected to be the same for all three time series.
     * In particular the number of samples must be appropriate for the memory
     * allocated for all three time series arrays.
     */
69
    CTripleHeader header;
thomas.forbriger's avatar
thomas.forbriger committed
70
71
    /*! \brief Time series of recorded data.
    */
72
    Tseries::Tcoc data;
thomas.forbriger's avatar
thomas.forbriger committed
73
74
75
    /*! \brief Time series of synthetic data.
     * This is understood as the impulse response of the subsurface.
     */
76
    Tseries::Tcoc synthetics;
thomas.forbriger's avatar
thomas.forbriger committed
77
78
79
80
81
82
83
84
85
86
87
    /*! \brief Time series of convolved synthetic data.
     * This will contain the synthetic data convolved with the obtained source
     * time function as a result of a call to the library functions.
     */
    Tseries convolvedsynthetics;
  }; // class WaveformTriple

  /*----------------------------------------------------------------------*/

  /*! \brief A class to store a single waveform.
   * This will be used to pass the source time function.
thomas.forbriger's avatar
thomas.forbriger committed
88
   * \ingroup cxxinterface
thomas.forbriger's avatar
thomas.forbriger committed
89
   */
90
  struct Waveform {
thomas.forbriger's avatar
thomas.forbriger committed
91
92
    /*! \brief Temporal sampling
    */
93
    CWaveformHeader sampling;
thomas.forbriger's avatar
thomas.forbriger committed
94
95
96
97
98
99
100
101
    /*! \brief Time series of waveform.
    */
    Tseries series;
  }; // class Waveform

  /*----------------------------------------------------------------------*/

  /*! \brief List of triples.
thomas.forbriger's avatar
thomas.forbriger committed
102
   * \ingroup cxxinterface
thomas.forbriger's avatar
thomas.forbriger committed
103
   */
104
  typedef std::vector<stfinv::WaveformTriple> Tvectoroftriples;
thomas.forbriger's avatar
thomas.forbriger committed
105
106
107

  /*----------------------------------------------------------------------*/

108
109
110
111
112
//! \brief Abort upon illegal call of base class function.
#define STFINV_baseillegal STFINV_abort("illegal call to abstract base class!")

  /*----------------------------------------------------------------------*/

thomas.forbriger's avatar
thomas.forbriger committed
113
  /*! \brief Abstract base class for engines to derive source time functions
thomas.forbriger's avatar
thomas.forbriger committed
114
   * \ingroup cxxinterface
115
   *
thomas.forbriger's avatar
thomas.forbriger committed
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
   * \par Initialization of engines
   * The following happens in a sequence, when engines are initialized:
   * -# The desired engine ins initialized either by the user directly
   *    or within the frame of STFEngine.
   * -# The constructor of this engine immediatly calls teh constructor of its
   *    base class.
   *    This again calls the constructor of its base class such passing down
   *    initialization to STFBaseEngine::STFBaseEngine
   * -# The constructor of STFBaseEngine takes the references to the storage
   *    locations for signal data as well as a parameter string.
   *    -# It fills its own references to the data storage locations and checks
   *       the consistency of parameters passed (size of arrays, sampling rates,
   *       etc).
   *    -# It then parses the parameter string and places its contents in the
   *       Mparamap parameter map.
   *    -# Then the base class parameters are set either from defaults or form
   *       values in the parameter map.
   * -# Initialization then continues at the next higher level in the class
   *    hierarchy.
   *    -# In the next level constructor additional workspace can be allocated
   *       based on the already available references to signal data and 
   *       parameter values.
   *    -# Further level specific parameters are set due to defaults or
   *       values passed in the parameter string.
   *
   * \par Handling of parameters
   * See STFBaseEngine::parameter() and STFBaseEngine::parameterisset()
   * for a description on how parameters are handled within engine classes.
   *
145
146
   * \sa
   * \ref sec_page_design_initialization
thomas.forbriger's avatar
thomas.forbriger committed
147
   */
148
  class STFBaseEngine {
149
    protected:
thomas.forbriger's avatar
thomas.forbriger committed
150
151
      /*! \brief Constructor.
       */
152
      STFBaseEngine(const stfinv::Tvectoroftriples& triples,
153
                    const stfinv::Waveform& stf,
thomas.forbriger's avatar
thomas.forbriger committed
154
                    const std::string& parameters);
155
    public:
156
157
      //! \brief abstract base requires virtual destructor
      virtual ~STFBaseEngine() { }
thomas.forbriger's avatar
thomas.forbriger committed
158
      //! \brief Start engine and return source time function.
159
      virtual stfinv::Waveform run() { STFINV_baseillegal; }
160
161
      //! \brief print online help
      virtual void help(std::ostream& os=std::cout) const;
162
163
      //! \brief return name of engine
      virtual const char* name() const;
164
165
166
167
168
169
      //! \brief return number of samples used in time series
      unsigned int nsamples() const
      { return (Mstf.sampling.n); }
      //! \brief return number of receiver signals in use
      unsigned int nreceivers() const
      { return (Mtriples.size()); }
170
171
172
173
    protected:
      //! \brief return the value of a parameters
      std::string parameter(const std::string& key,
                            const std::string& defvalue="false") const;
thomas.forbriger's avatar
thomas.forbriger committed
174
175
      //! \brief check is parameter was set by user
      bool parameterisset(const std::string& key) const;
thomas.forbriger's avatar
thomas.forbriger committed
176
    private:
177
178
      //! \brief parse parameters in Mparameters
      void parseparameters(std::string parameters);
thomas.forbriger's avatar
thomas.forbriger committed
179
180
      //! \brief Check consistency of data members.
      void checkconsistency() const;
181
      
thomas.forbriger's avatar
thomas.forbriger committed
182
183
184
    // member data
    // -----------

185
186
    protected:
      // protected members are accessed directly from derived classes
thomas.forbriger's avatar
thomas.forbriger committed
187
      //! \brief Waveform triples.
188
      stfinv::Tvectoroftriples Mtriples;
thomas.forbriger's avatar
thomas.forbriger committed
189
190
      //! \brief Source time function.
      stfinv::Waveform Mstf;
thomas.forbriger's avatar
thomas.forbriger committed
191
192
193
194
      //! \brief debug level
      int Mdebug;
      //! \brief verbose level
      int Mverbose;
195
    private:
thomas.forbriger's avatar
thomas.forbriger committed
196
197
198
199
200
      /*! \brief Parameter map
       * \note must be declared mutable, since std::map does not provide a
       * const read function.
       */
      mutable stfinv::tools::Tparamap Mparamap;
201
  }; // class STFBaseEngine
thomas.forbriger's avatar
thomas.forbriger committed
202

203
204
205
206
207
} // namespace stfinv

#endif // STFINV_STFINVBASE_H_VERSION (includeguard)

/* ----- END OF stfinvbase.h ----- */