GPLIB++
randaniso.cpp
Go to the documentation of this file.
1 #include <iostream>
2 #include <string>
3 #include "C1DAnisoMTSynthData.h"
4 #include "UniformRNG.h"
5 #include "convert.h"
6 #include <iterator>
7 
8 using namespace std;
9 using namespace gplib;
10 
11 int main(void)
12  {
13  string version = "$Id: randaniso.cpp 1844 2010-04-12 11:34:25Z mmoorkamp $";
14  cout << endl << endl;
15  cout << "Program " << version << endl;
16  cout
17  << "Generates completely random anisotropic models and writes their response "
18  << endl;
19 
20  C1DAnisoMTSynthData Synthetic; // create Object for Calculation of Synthetics
21  UniformRNG Random;
22 
23  try
24  {
25  const unsigned int nlayers = 15;
26  const unsigned int nmodels = 100;
27  const double minres = -1;
28  const double maxres = 3;
29  const double minthick = 10;
30  const double maxthick = 30;
31  const double minangle = 0;
32  const double maxangle = 90;
33  trealdata currthick(nlayers);
34  trealdata currrho1(nlayers);
35  trealdata currrho2(nlayers);
36  trealdata currstrike(nlayers);
37  trealdata zeros(nlayers);
38  for (unsigned int i = 0; i < nlayers; ++i)
39  zeros.at(i) = 0.0;
40  Synthetic.SetDips(zeros);
41  Synthetic.SetSlants(zeros);
42  string mttfilename = "out";
43  const float ten = 10.0;
44 
45  for (unsigned int i = 0; i < nmodels; ++i)
46  {
47  for (unsigned int j = 0; j < nlayers; ++j)
48  {
49  currthick.at(j) = Random.GetNumber(minthick, maxthick);
50  currrho1.at(j) = std::pow(ten, Random.GetNumber(minres, maxres));
51  currrho2.at(j) = std::pow(ten, Random.GetNumber(minres, maxres));
52  currstrike.at(j) = Random.GetNumber(minangle, maxangle);
53  }
54  Synthetic.SetRho1(currrho1);
55  Synthetic.SetRho2(currrho2);
56  Synthetic.SetRho3(currrho2);
57  Synthetic.SetStrikes(currstrike);
58  Synthetic.SetThicknesses(currthick);
59  Synthetic.GetData();
60  Synthetic.WriteAsMtt(mttfilename + stringify(i)); // Write out Mtt file
61  }
62  } catch (FatalException &e)
63  {
64  cerr << e.what() << endl;
65  return -1;
66  }
67  }
void SetRho1(const trealdata &a)
Set the first principal resistivity for each layer in Ohm.m.
Generate uniformly distributed random numbers, this is basically a wrapper for the boost random numbe...
Definition: UniformRNG.h:19
void SetThicknesses(const trealdata &thick)
Set the thicknes in km.
int main(void)
Definition: randaniso.cpp:11
virtual void GetData()
Calculate the synthetic data given the previously set parameters.
void SetRho2(const trealdata &a)
Set the second principal resistivity for each layer in Ohm.m.
Calculate response of a 1D anisotropic model, code is based on Pek and Santos fortran code...
float GetNumber(const float low, const float high)
Return a random float between low and high.
Definition: UniformRNG.cpp:21
void SetStrikes(const trealdata &a)
Set the anisotropy strike for each layer in degree.
void WriteAsMtt(const std::string filename)
Write data in goettingen .mtt format.
Definition: MTStation.cpp:681
void SetDips(const trealdata &a)
Set the anisotropy dip for each layer in degree.
string version
Definition: makeinput.cpp:16
void SetSlants(const trealdata &a)
Set the anisotropy slant for each layer in degree.
void SetRho3(const trealdata &a)
Set the first principal resistivity for each layer in Ohm.m.
The basic exception class for all errors that arise in gplib.