GPLIB++
makeinput.cpp
Go to the documentation of this file.
1 #include <iostream>
2 #include "C1DMTSynthData.h"
3 #include "CResPkModel.h"
4 #include "CRecCalc.h"
5 #include "CUniformRNG.h"
6 #include "MakeInputConf.h"
7 #include "CSeismicDataComp.h"
8 #include "Adaptors.h"
9 #include <vector>
10 #include <boost/bind.hpp>
11 #include <string>
12 
13 using namespace std;
14 using namespace gplib;
15 
16 string version = "$Id: makeinput.cpp 1816 2009-09-07 11:28:35Z mmoorkamp $";
17 
18 int main(int argc, char *argv[])
19  {
20  cout
21  << " This is makeinput: Create MT and receiver function models and data"
22  << endl; // write some info
23  cout << " to be used as input for inversion methods." << endl;
24  cout
25  << " If one argument is given, this argument is taken as the filename base for all output files."
26  << endl;
27  cout
28  << " Otherwise the output file base is read from the configuration file 'makeinput.conf' "
29  << endl;
30  cout << " The configuration file contains all other relevant settings. "
31  << endl;
32  cout << " This is Version: " << version << endl << endl;
33  UniformRNG Random;
34  MakeInputConf Configuration;
35  Configuration.GetData("makeinput.conf");
36 
37  string outputbase;
38  if (argc > 1)
39  outputbase = argv[1];
40  else
41  outputbase = Configuration.outputbase;
42 
43  C1DMTSynthData MTSynth;
44  ResPkModel RecModel;
45  RecCalc RecSynth(Configuration.shift, Configuration.omega,
46  Configuration.sigma, Configuration.cc);
47  SeismicDataComp RecSynthData;
48  const double basevel = 3.2;
49  const double basedens = 2.6;
50  const double baseres = 1.0 + Random.GetNumber();
51  const double basethick = 1.0 + Random.GetNumber() * 10;
52  vector<double> velocities(Configuration.nlayers);
53  vector<double> densities(Configuration.nlayers);
54  vector<double> resistivities(Configuration.nlayers);
55  vector<double> mtthickness(Configuration.nlayers);
56  vector<double> recthickness(Configuration.nlayers);
57  densities.front() = basedens;
58  resistivities.front() = baseres;
59  velocities.front() = basevel;
60  mtthickness.front() = basethick;
61  if (Configuration.correlated)
62  {
63  recthickness.front() = basethick;
64  }
65  else
66  {
67  recthickness.front() = basethick * Random.GetNumber(1.1, 2.0);
68  }
69  for (int i = 1; i < Configuration.nlayers; ++i)
70  {
71  mtthickness.at(i) = mtthickness.at(i - 1) * Random.GetNumber(1.1, 2.0);
72  if (Configuration.correlated)
73  {
74  recthickness.at(i) = mtthickness.at(i);
75  }
76  else
77  {
78  recthickness.at(i) = mtthickness.at(i) * Random.GetNumber(1.1, 2.0);
79 
80  }
81  densities.at(i) = densities.at(i - 1) * Random.GetNumber(1.1, 1.5);
82  resistivities.at(i) = Random.GetNumber(0.0, 3.0);
83  velocities.at(i) = velocities.at(i - 1) * Random.GetNumber(1.05, 1.2);
84  }
85  transform(resistivities.begin(), resistivities.end(),
86  resistivities.begin(), boost::bind(fopow<double, double> (), 10, _1));
87  MTSynth.SetResistivities(resistivities);
88  MTSynth.SetThicknesses(mtthickness);
89  MTSynth.writemodel(outputbase + "_mt.mod");
90  MTSynth.writeplot(outputbase + "_mt.plot");
91  MTSynth.GetData();
92  MTSynth.WriteAsMtt(outputbase);
93 
94  RecModel.Init(Configuration.nlayers); //initialize model
95  RecModel.slowness = Configuration.slowness; //copy slowness
96  copy(recthickness.begin(), recthickness.end(), RecModel.Thickness.begin()); //copy values
97  copy(velocities.begin(), velocities.end(), RecModel.SVelocity.begin());
98  copy(densities.begin(), densities.end(), RecModel.Density.begin());
99  transform(RecModel.SVelocity.begin(), RecModel.SVelocity.end(), //PVelocity is calculated by multiplication of SVel by poisson's ratio
100  RecModel.PVelocity.begin(), boost::bind(multiplies<double> (), _1,
101  Configuration.poisson));
102  RecModel.dt = Configuration.dt; // set dt
103  RecModel.npts = Configuration.npts; //set number of points
104  RecSynth.CalcRecSynth(Configuration.outputbase + "_rec", RecModel,
105  RecSynthData, false); // Calculate forward model
106  RecModel.WritePlot(outputbase + "_rec");
107  RecSynthData.WriteAsSac(outputbase + ".rec");
108  }
This class is used to calculate receiver functions from seismic data.
Definition: RecCalc.h:14
Generate uniformly distributed random numbers, this is basically a wrapper for the boost random numbe...
Definition: UniformRNG.h:19
void WritePlot(const std::string &filename)
Write out an ascii file for plotting with xmgrace etc.
int main(int argc, char *argv[])
Definition: makeinput.cpp:18
virtual void GetData(const std::string filename)
read in data from file, determines format by ending
Definition: MTStation.cpp:597
void CalcRecSynth(const std::string &filename, ResPkModel &Model, SeismicDataComp &Receiver, const bool cleanfiles=false)
Calculate synthetic receiver funtions from a model.
Definition: RecCalc.cpp:195
float GetNumber(const float low, const float high)
Return a random float between low and high.
Definition: UniformRNG.cpp:21
void SetThicknesses(const trealdata &thick)
Read only access to the vector of layer thicknesses for the 1D model from top to bottom in km...
void Init(const int nlayers)
Init provides a convenient way to allocate memory in all structures for a given number of layers...
void WriteAsMtt(const std::string filename)
Write data in goettingen .mtt format.
Definition: MTStation.cpp:681
Calculate synthetic MT data for a 1D model using Cagniard's algorithm.
void SetResistivities(const trealdata &res)
Read-write access to the vector of resistivities for the 1D model from top to bottom in Ohmm...
string version
Definition: makeinput.cpp:16
CLevanisoConf Configuration
Definition: cadianiso.cpp:17
This class stores and writes model for the respktn 1D seismic code that we use for receiver function ...
Definition: ResPkModel.h:18
int WriteAsSac(const std::string &filename) const
Write the data in sac binary format.