GPLIB++
plotmtt.cpp
Go to the documentation of this file.
1 /*!
2  * \addtogroup UtilProgs Utility Programs
3  *@{
4  * \file
5  * Calculate apparent resistivity and phase from a .mtt, .edi or .j file and write
6  * one file with error information for each component to use for plotting. The program
7  * will automatically append .rxx, .rxy, .ryx and .ryy for the four apparent resistivities and
8  * .pxx, .pxy, .pyx and .pyy for the four phases respectively. It also outputs the apparent resistivity and phases of the
9  * Berdichevskiy invariant in the files .rberd and .pberd, respectively.
10  * Each file contains lines with Period in seconds, the respective datum and its error.
11  */
12 #include "MTStation.h"
13 #include <boost/function.hpp>
14 #include "Util.h"
15 #include <iostream>
16 #include <iomanip>
17 #include <fstream>
18 
19 using namespace std;
20 using namespace gplib;
21 
22 void WriteToFile(string filename,
23  boost::function<double(const MTTensor*)> datafunc, boost::function<double(
24  const MTTensor*)> errfunc, const MTStation &Data)
25  {
26  ofstream outfile(filename.c_str());
27  const size_t ndata = Data.GetMTData().size();
28  for (size_t i = 0; i < ndata; ++i)
29  {
30  outfile << setw(15) << setfill(' ') << setprecision(4) << 1. / Data.at(
31  i).GetFrequency();
32  outfile << setw(15) << setfill(' ') << setprecision(4) << datafunc(
33  &Data.at(i));
34  outfile << setw(15) << setfill(' ') << setprecision(4) << errfunc(
35  &Data.at(i)) << endl;
36  }
37  }
38 
39 int main(int argc, char *argv[])
40  {
41  string version = "$Id: plotmtt.cpp 1816 2009-09-07 11:28:35Z mmoorkamp $";
42  cout << endl << endl;
43  cout << "Program " << version << endl;
44  cout
45  << "Write out impedance phase and apparent resistivity for plotting. "
46  << endl;
47  cout
48  << "Will create 8 files starting with Infilename and endings r** for apparent resistivity components "
49  << endl;
50  cout << " and p** for phase components." << endl << endl;
51  string infilename;
52  MTStation Data;
53  if (argc == 2)
54  {
55  infilename = argv[1];
56  }
57  else
58  {
59  infilename = AskFilename("Infilename: ");
60  }
61  Data.GetData(infilename);
62  WriteToFile(infilename + ".rxx", &MTTensor::GetRhoxx, &MTTensor::GetdRhoxx,
63  Data);
64  WriteToFile(infilename + ".rxy", &MTTensor::GetRhoxy, &MTTensor::GetdRhoxy,
65  Data);
66  WriteToFile(infilename + ".ryx", &MTTensor::GetRhoyx, &MTTensor::GetdRhoyx,
67  Data);
68  WriteToFile(infilename + ".ryy", &MTTensor::GetRhoyy, &MTTensor::GetdRhoyy,
69  Data);
70  WriteToFile(infilename + ".pxx", &MTTensor::GetPhi90xx,
71  &MTTensor::GetdPhixx, Data);
72  WriteToFile(infilename + ".pxy", &MTTensor::GetPhi90xy,
73  &MTTensor::GetdPhixy, Data);
74  WriteToFile(infilename + ".pyx", &MTTensor::GetPhi90yx,
75  &MTTensor::GetdPhiyx, Data);
76  WriteToFile(infilename + ".pyy", &MTTensor::GetPhi90yy,
77  &MTTensor::GetdPhiyy, Data);
78  WriteToFile(infilename + ".rberd", &MTTensor::GetRhoBerd,
79  &MTTensor::GetdRhoBerd, Data);
80  WriteToFile(infilename + ".pberd", &MTTensor::GetPhi90Berd,
81  &MTTensor::GetdPhi90Berd, Data);
82 
83  }
84 /*@}*/
const MTTensor & at(const unsigned int i) const
direct acces to a tensor at a given index
Definition: MTStation.h:114
virtual void GetData(const std::string filename)
read in data from file, determines format by ending
Definition: MTStation.cpp:597
double GetFrequency() const
Get the frequency for the impedance.
Definition: MTTensor.h:113
The class MTStation is used to store the transfer functions and related information for a MT-site...
Definition: MTStation.h:17
int main()
Definition: angleavg.cpp:12
void WriteToFile(string filename, boost::function< double(const MTTensor *)> datafunc, boost::function< double(const MTTensor *)> errfunc, const MTStation &Data)
Definition: plotmtt.cpp:22
Stores MT-Tensor components at a single frequency, calculates derived quantities. ...
Definition: MTTensor.h:16
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