stfinvbase.h 5.23 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
116
117
   *
   * \sa
   * \ref sec_page_design_initialization
thomas.forbriger's avatar
thomas.forbriger committed
118
   */
119
  class STFBaseEngine {
120
    protected:
thomas.forbriger's avatar
thomas.forbriger committed
121
122
      /*! \brief Constructor.
       */
123
      STFBaseEngine(const stfinv::Tvectoroftriples& triples,
124
125
                    const stfinv::Waveform& stf,
                    const std::string& parameters)
126
      : Mtriples(triples), Mstf(stf)
thomas.forbriger's avatar
thomas.forbriger committed
127
128
      {
        this->checkconsistency();
129
        this->parseparameters(parameters);
thomas.forbriger's avatar
thomas.forbriger committed
130
      }
131
    public:
132
133
      //! \brief abstract base requires virtual destructor
      virtual ~STFBaseEngine() { }
thomas.forbriger's avatar
thomas.forbriger committed
134
      //! \brief Start engine and return source time function.
135
      virtual stfinv::Waveform run() { STFINV_baseillegal; }
136
137
      //! \brief print online help
      virtual void help(std::ostream& os=std::cout) const;
138
139
140
141
142
143
      //! \brief return name of engine
      virtual const char* name() const;
    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
144
    private:
145
146
      //! \brief parse parameters in Mparameters
      void parseparameters(std::string parameters);
thomas.forbriger's avatar
thomas.forbriger committed
147
148
      //! \brief Check consistency of data members.
      void checkconsistency() const;
149
150
151
      
    protected:
      // protected members are accessed directly from derived classes
thomas.forbriger's avatar
thomas.forbriger committed
152
      //! \brief Waveform triples.
153
      stfinv::Tvectoroftriples Mtriples;
thomas.forbriger's avatar
thomas.forbriger committed
154
155
      //! \brief Source time function.
      stfinv::Waveform Mstf;
156
157
158
    private:
      //! \brief Parameter map
      stfinv::tools::Tparamap Mparamap;
159
  }; // class STFBaseEngine
thomas.forbriger's avatar
thomas.forbriger committed
160

161
162
163
164
165
} // namespace stfinv

#endif // STFINV_STFINVBASE_H_VERSION (includeguard)

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