STFINV library: seek source wavelet correction filter
stfinv.cc
Go to the documentation of this file.
1 
38 #define STFINV_STFINV_C_VERSION \
39  "STFINV_STFINV_C V1.3"
40 
41 #include <stfinv/stfinv.h>
42 #include <stfinv/error.h>
43 #include <stfinv/stfinvany.h>
44 
53 namespace stfinv {
54 
58  namespace capi {
59 
64 
65  } // namespace capi
66 
67 } // namespace stfinv
68 
69 /*======================================================================*/
70 
71 void initstfinvenginewithpairs(struct CTriples triples,
72  struct CWaveform stf,
73  struct CPairs pairs,
74  char* parameters)
75 {
76  // remove existing engine if has previously been initialized
78 
79  // convert parameter string
80  std::string cxxparameters(parameters);
81 
82  // convert pointer to source correction filter array
83  stfinv::Waveform cxxstf;
84  cxxstf.sampling=stf.sampling;
85  aff::LinearShape shape(0, cxxstf.sampling.n-1, 0);
86  cxxstf.series
87  =stfinv::Tseries(shape,
88  aff::SharedHeap<Tvalue>(stf.series,
89  cxxstf.sampling.n));
90 
91  // convert pointer triples
92  // notice: it is not required to check consistency here; all header fields
93  // are transferred to the C++ containers; the C++ engine will check
94  // consistency during its initialization
95  STFINV_assert(triples.n>0, "no triples provided");
96  stfinv::Tvectoroftriples cxxtriples(triples.n);
97  for (int i=0; i<triples.n; ++i)
98  {
99  CWaveformTriple ctriple=triples.triples[i];
100  cxxtriples[i].header=ctriple.header;
101  const int& n=cxxtriples[i].header.sampling.n;
102  shape=aff::LinearShape(0, n-1, 0);
103  cxxtriples[i].data
104  =stfinv::Tseries::Tcoc(shape,
105  aff::SharedHeap<Tvalue>::Tcoc(ctriple.data, n));
106  cxxtriples[i].synthetics
107  =stfinv::Tseries::Tcoc(shape,
108  aff::SharedHeap<Tvalue>::Tcoc(ctriple.synthetics, n));
109  cxxtriples[i].convolvedsynthetics
110  =stfinv::Tseries(shape,
111  aff::SharedHeap<Tvalue>(ctriple.convolvedsynthetics, n));
112  }
113 
114  // convert pointer pairs
115  // notice: it is not required to check consistency here; all header fields
116  // are transferred to the C++ containers; the C++ engine will check
117  // consistency during its initialization
118  stfinv::Tvectorofpairs cxxpairs(pairs.n);
119  for (int i=0; i<pairs.n; ++i)
120  {
121  CWaveformPair cpair=pairs.pairs[i];
122  cxxpairs[i].sampling=cpair.sampling;
123  const int& n=cxxpairs[i].sampling.n;
124  shape=aff::LinearShape(0, n-1, 0);
125  cxxpairs[i].synthetics
126  =stfinv::Tseries::Tcoc(shape,
127  aff::SharedHeap<Tvalue>::Tcoc(cpair.synthetics, n));
128  cxxpairs[i].convolvedsynthetics
129  =stfinv::Tseries(shape,
130  aff::SharedHeap<Tvalue>(cpair.convolvedsynthetics, n));
131  }
132 
133  // create engine
134  stfinv::capi::Pengine=new stfinv::STFEngine(cxxtriples, cxxstf,
135  cxxpairs,
136  cxxparameters);
137 } // void initstfinvenginewithpairs
138 
139 /*----------------------------------------------------------------------*/
140 
141 void initstfinvengine(struct CTriples triples,
142  struct CWaveform stf,
143  char* parameters)
144 {
145  struct CPairs pairs;
146  pairs.n=0;
147  initstfinvenginewithpairs(triples, stf, pairs, parameters);
148 } // void initstfinvengine
149 
150 /*----------------------------------------------------------------------*/
151 
153 {
155  "runstfinvengine(): engine is not initialized!");
157 } // void runstfinvengine()
158 
159 /*----------------------------------------------------------------------*/
160 
162 {
163  if (stfinv::capi::Pengine != 0) { delete stfinv::capi::Pengine; }
164 } // void freestfinvengine()
165 
166 /*----------------------------------------------------------------------*/
167 
169 {
170  stfinv::engines();
171 } // void printengines()
172 
173 /*----------------------------------------------------------------------*/
174 
175 void printhelp()
176 {
177  stfinv::help();
178 } // void printhelp()
179 
180 /*----------------------------------------------------------------------*/
181 
182 void printusage(char* id)
183 {
184  std::string selectid(id);
185  stfinv::usage(selectid);
186 } // void printhelp(age(char* id)
187 
188 /* ----- END OF stfinv.cc ----- */
struct CWaveformHeader sampling
Temporal sampling of all three waveforms.
C API to library (prototypes)
std::vector< stfinv::WaveformPair > Tvectorofpairs
Vector of pairs.
Definition: stfinvbase.h:125
A struct to store the time series for a pair of waveforms.This struct provides references to the user...
Definition: stfinv.h:104
stfinv::Waveform run()
Start engine and return source correction filter.
Definition: stfinvany.h:122
int n
Number of triples (i.e. receivers) in the array.
Definition: stfinv.h:166
Root namespace of library.
Definition: doxygen.txt:43
Tvalue * synthetics
Time series of synthetic data. This field actually is a pointer (C array) to the workspace where the ...
Definition: stfinv.h:81
void printengines()
List procedures (engines) on stdout.
Definition: stfinv.cc:168
stfinv::STFEngine * Pengine
Pointer to engine to work with.
Definition: stfinv.cc:63
CWaveformHeader sampling
Temporal sampling.
Definition: stfinvbase.h:114
Tvalue * convolvedsynthetics
Time series of convolved synthetic data. This field actually is a pointer (C array) to the workspace ...
Definition: stfinv.h:128
void freestfinvengine()
Free the engine.
Definition: stfinv.cc:161
A struct to store the time series for a waveform triple.This struct provides references to the users ...
Definition: stfinv.h:59
Tseries series
Time series of waveform.
Definition: stfinvbase.h:117
handle error conditions in libstfinv (prototypes)
unsigned int n
Number of samples in time series array.
Tvalue * data
Time series of recorded data. This field actually is a pointer (C array) to the workspace where the u...
Definition: stfinv.h:72
Array of waveform triples.This is used to pass data for a complete profile. A profile consists of CTr...
Definition: stfinv.h:163
#define STFINV_assert(C, M)
Check an assertion and report by throwing an exception.
Definition: error.h:140
void runstfinvengine()
Run the engine.
Definition: stfinv.cc:152
A class to store a single waveform. This will be used to pass the source correction filter...
Definition: stfinvbase.h:111
void printhelp()
Print usage summary to stdout.
Definition: stfinv.cc:175
int n
Number of pairs in the array.
Definition: stfinv.h:190
A struct to store a single waveform.
Definition: stfinv.h:139
Tvalue * convolvedsynthetics
Time series of convolved synthetic data. This field actually is a pointer (C array) to the workspace ...
Definition: stfinv.h:93
void engines(std::ostream &os)
Definition: stfinvany.cc:187
void printusage(char *id)
Print detailed description for engine "id" to stdout.
Definition: stfinv.cc:182
struct CWaveformPair * pairs
Pointer to array of waveform pairs. This actually is a C array for elements of type struct CWaveformP...
Definition: stfinv.h:196
struct CWaveformHeader sampling
Temporal sampling parameters. The header is expected to be the same for both time series...
Definition: stfinv.h:110
void help(std::ostream &os)
Definition: stfinvany.cc:192
Array of waveform pairs.This is used to pass data for a set of synthetic time series, which should be convolved with the new source correction filter on the fly. A collection of time series consists of CPairs::n waveform pairs. For each waveform pair this struct holds a reference to a struct CWaveformPair which itself provides a reference to the users workspace for time series.
Definition: stfinv.h:187
Tvalue * synthetics
Time series of synthetic data. This field actually is a pointer (C array) to the workspace where the ...
Definition: stfinv.h:117
Tvalue * series
Time series of waveform. This field actually is a pointer (C array) to the workspace where the user w...
Definition: stfinv.h:150
std::vector< stfinv::WaveformTriple > Tvectoroftriples
Vector of triples.
Definition: stfinvbase.h:132
void initstfinvengine(struct CTriples triples, struct CWaveform stf, char *parameters)
Initialize the engine.
Definition: stfinv.cc:141
void initstfinvenginewithpairs(struct CTriples triples, struct CWaveform stf, struct CPairs pairs, char *parameters)
Initialize the engine and pass additional time series to be convolved on the fly. ...
Definition: stfinv.cc:71
a wrapper to any STF engine in the library (prototypes)
Class to access any engine in the library.
Definition: stfinvany.h:60
aff::Series< Tvalue > Tseries
Type of sample values.
Definition: stfinvbase.h:56
struct CWaveformHeader sampling
Temporal sampling.
Definition: stfinv.h:142
struct CTripleHeader header
Temporal and spatial sampling parameters. The header is expected to be the same for all three time se...
Definition: stfinv.h:65
void usage(const std::string &id, std::ostream &os)
Definition: stfinvany.cc:197
struct CWaveformTriple * triples
Pointer to array of waveform triples. This actually is a C array for elements of type struct CWavefor...
Definition: stfinv.h:172