GPLIB++
modelcorr.cpp
Go to the documentation of this file.
1 #include <iostream>
2 #include "C1DMTSynthData.h"
3 #include "ResPkModel.h"
4 #include <string>
5 #include <numeric>
6 
7 using namespace std;
8 using namespace gplib;
9 
10 string version = "$Id: modelcorr.cpp 1816 2009-09-07 11:28:35Z mmoorkamp $";
11 
12 int main()
13  {
15  C1DMTSynthData MTModel;
16  string inputbase;
17 
18  cout
19  << " This is modelcorr: Calculate 'correlation' of seismic and MT model"
20  << endl; // write some info
21  cout
22  << " Input files are assumed to be have the name inputbase+_rec.mod and inputbase+_mt.mod"
23  << endl;
24  cout << " for seismic and MT models, respectively. " << endl;
25  cout << " This is Version: " << version << endl << endl;
26 
27  cout << "Inputbase: ";
28  cin >> inputbase;
29  SeismicModel.ReadModel(inputbase + "_rec.mod");
30  MTModel.ReadModel(inputbase + "_mt.mod");
31 
32  trealdata mtthickness(MTModel.GetThicknesses());
33  trealdata seismicthickness(SeismicModel.GetThickness());
34  trealdata mtdepth(mtthickness.size()),
35  seismicdepth(seismicthickness.size());
36  trealdata resistivity(MTModel.GetResistivities());
37  trealdata svelocity(SeismicModel.GetSVelocity());
38  partial_sum(mtthickness.begin(), mtthickness.end(), mtdepth.begin());
39  partial_sum(seismicthickness.begin(), seismicthickness.end(),
40  seismicdepth.begin());
41  mtthickness.back() += 10000.0;
42  seismicthickness.back() += 10000.0;
43  bool finished = false;
44  size_t mtindex = 0;
45  size_t seismicindex = 0;
46  const double depththreshold = 0.05;
47  double mtdifferencemeasure = 0.0;
48  double seismicdifferencemeasure = 0.0;
49  int mtinterfaces = 0;
50  int seismicinterfaces = 0;
51  int corrinterfaces = 0;
52  while (!finished)
53  {
54  double reldepthdiff = (mtdepth.at(mtindex) - seismicdepth.at(
55  seismicindex)) / min(mtdepth.at(mtindex), seismicdepth.at(
56  seismicindex));
57  if (reldepthdiff > depththreshold && seismicindex < svelocity.size()
58  - 1) //mt layer deeper
59  {
60  seismicdifferencemeasure += abs(svelocity.at(seismicindex)
61  - svelocity.at(seismicindex + 1));
62  ++seismicindex;
63  ++seismicinterfaces;
64  }
65  else if (reldepthdiff < -depththreshold && mtindex < resistivity.size()
66  - 1) //seismic layer deeper
67  {
68  mtdifferencemeasure += abs(resistivity.at(mtindex)
69  - resistivity.at(mtindex + 1));
70  ++mtindex;
71  ++mtinterfaces;
72  }
73  else //both about the same
74  {
75  ++mtindex;
76  ++seismicindex;
77  ++corrinterfaces;
78  }
79  if (mtindex >= resistivity.size() || seismicindex >= svelocity.size())
80  {
81  finished = true;
82  }
83  }
84  cout << "Seismic depths: ";
85  copy(seismicdepth.begin(), seismicdepth.end(), ostream_iterator<double> (
86  cout, " "));
87  cout << endl;
88  cout << "MT depths: ";
89  copy(mtdepth.begin(), mtdepth.end(), ostream_iterator<double> (cout, " "));
90  cout << endl;
91  cout << "MT difference: " << mtdifferencemeasure << " Seismic difference: "
92  << seismicdifferencemeasure << endl;
93  cout << "MT only interfaces: " << mtinterfaces
94  << " Seismic only interfaces: " << seismicinterfaces
95  << " Common interfaces: " << corrinterfaces << endl;
96  }
virtual void ReadModel(const std::string filename)
Read the model in its native format from a file.
Definition: ResPkModel.cpp:92
int main()
Definition: modelcorr.cpp:12
string version
Definition: modelcorr.cpp:10
void ReadModel(std::string filename)
Read the model from a file.
The class SeismicModel is the base class for some of the model format for seismic codes...
Definition: SeismicModel.h:17
const trealdata & GetSVelocity() const
Read-only access to the vector of S-velocities in km/s in each layer.
Definition: SeismicModel.h:81
const trealdata & GetThicknesses()
Read only access to the vector of layer thicknesses for the 1D model from top to bottom in km...
Calculate synthetic MT data for a 1D model using Cagniard's algorithm.
const trealdata & GetResistivities()
Read only access to the vector of resistivities for the 1D model from top to bottom in Ohmm...
This class stores and writes model for the respktn 1D seismic code that we use for receiver function ...
Definition: ResPkModel.h:18
const trealdata & GetThickness() const
Read-only access to the vector of thicknesses in km in each layer.
Definition: SeismicModel.h:101