GPLIB++
mtt2ptensor.cpp
Go to the documentation of this file.
1 #include <iostream>
2 #include <string>
3 #include "MTStationList.h"
4 #include "PTensorMTStation.h"
5 #include "Adaptors.h"
6 #include "Jacknife.h"
7 #include "MTSampleGenerator.h"
8 #include "Util.h"
9 
10 using namespace std;
11 using namespace gplib;
12 
13 /*!
14  * \addtogroup UtilProgs Utility Programs
15  *@{
16  * \file mtt2ptensor.cpp
17  * Take a file containing impedances in one of the standard formats and convert it to phase tensor values with errors.
18  * This is useful for inverting phase tensor quantities and processing different files based on phase tensor information.
19  */
20 
21 
22 int main(int argc, char* argv[])
23  {
24  MTStationList MTSites;
25  string infilename;
26  string version =
27  "$Id: mtt2ptensor.cpp 1849 2010-05-07 11:53:45Z mmoorkamp $";
28  cout << endl << endl;
29  cout << "Program " << version << endl;
30  cout << " Convert MT data files in .mtt .j .edi format to .ptensor format"
31  << endl;
32  cout << " This is needed in conjunction with the program ptselect " << endl;
33  cout << " to select similar sites." << endl;
34  cout << endl << endl;
35 
36  if (argc == 2)
37  {
38  infilename = argv[1];
39  }
40  else
41  {
42  infilename = AskFilename("Input Filename: ");
43  }
44  MTSites.GetData(infilename);
45  const unsigned int nsites = MTSites.GetList().size();
46  const unsigned int ntestcases = 10000;
47  for (unsigned int i = 0; i < nsites; ++i)
48  {
49  cout << "Writing site " << MTSites.GetList().at(i).GetName();
50  PTensorMTStation PTData;
51  const unsigned int nfreq = MTSites.at(i).GetMTData().size();
52  for (unsigned j = 0; j < nfreq; ++j)
53  {
54  double JackMean, Phi11Var, Phi12Var, Phi21Var, Phi22Var;
56  &MTTensor::GetPhi11, MTSites.at(i).at(j))).CalcErrors(JackMean,
57  Phi11Var);
59  &MTTensor::GetPhi21, MTSites.at(i).at(j))).CalcErrors(JackMean,
60  Phi12Var);
62  &MTTensor::GetPhi12, MTSites.at(i).at(j))).CalcErrors(JackMean,
63  Phi21Var);
65  &MTTensor::GetPhi22, MTSites.at(i).at(j))).CalcErrors(JackMean,
66  Phi22Var);
67 
68  PTData.GetTensor().push_back(PTensorMTData(
69  MTSites.at(i).at(j).GetFrequency(),
70  MTSites.at(i).at(j).GetPhi11(), MTSites.at(i).at(j).GetPhi12(),
71  MTSites.at(i).at(j).GetPhi21(), MTSites.at(i).at(j).GetPhi22(),
72  sqrt(Phi11Var), sqrt(Phi12Var), sqrt(Phi21Var), sqrt(Phi22Var)));
73  PTData.WriteData(MTSites.GetList().at(i).GetName());
74  }
75  cout << " ... done" << endl;
76  }
77  }
78 /*@}*/
This class is for the special case where we only have phase tensor data and errors, but not the full impedance.
Definition: PTensorMTData.h:12
MTStation & at(int loc)
Get a reference to a site at a given index.
double GetPhi11() const
All the following quantities are defined in Caldwell GJI 158, 457-469, the phase tensor elements...
Definition: MTTensor.h:422
const MTTensor & at(const unsigned int i) const
direct acces to a tensor at a given index
Definition: MTStation.h:114
std::vector< PTensorMTData > & GetTensor()
void CalcErrors(double &m, double &v)
The main function, calculates the error, by generating samples and calling the derived function...
Definition: StatErrEst.h:44
double GetPhi21() const
Definition: MTTensor.h:438
double GetFrequency() const
Get the frequency for the impedance.
Definition: MTTensor.h:113
double GetPhi12() const
Definition: MTTensor.h:430
double GetPhi22() const
Definition: MTTensor.h:446
void WriteData(const std::string &filename)
MTStationList holds a number of MTSites, usually associated with a single project, line, etc.
Definition: MTStationList.h:16
Implements the Jacknifing method of error estimation.
Definition: Jacknife.h:20
Generate random elements of a calculated quantity for MT impedance data.
int main()
Definition: angleavg.cpp:12
tStationList & GetList()
Access to the complete vector of Stations.
Definition: MTStationList.h:31
void GetData(const std::string filename)
Read a list of filenames and the associated data in those files to fill the list. ...
string version
Definition: makeinput.cpp:16
const std::vector< MTTensor > & GetMTData() const
Get the full vector of Tensor elements read only.
Definition: MTStation.h:119