GPLIB++
anisomt.cpp
Go to the documentation of this file.
1 #include <iostream>
2 #include <string>
3 #include "Util.h"
4 #include "C1DAnisoMTSynthData.h"
5 #include "MTStation.h"
6 #include "PTensorMTStation.h"
7 #include <iterator>
8 
9 using namespace std;
10 using namespace gplib;
11 
12 int main(int argc, char *argv[])
13  {
14  try
15  {
16  if (argc == 1) //if we have no additional command line arguments, output some info
17 
18  {
19  string version =
20  "$Id: anisomt.cpp 1816 2009-09-07 11:28:35Z mmoorkamp $";
21  cout << endl << endl;
22  cout << "Program " << version << endl;
23  cout
24  << "Calculates 1D MT Responses with Anisotropy from input models "
25  << endl;
26  cout << "Based on Pek and Santos code. " << endl;
27  cout << "You can give up to 3 command line parameters: " << endl;
28  cout << " anisomt modelfilename outfilebase masterfile " << endl
29  << endl;
30  cout
31  << " Modelfilename: The name of the file containing the model"
32  << endl << endl;
33  cout
34  << " Outfilebase: The name of the outputfiles without ending,"
35  << endl;
36  cout
37  << " the code will produce 2 files with additional endings .mtt and .ptensor"
38  << endl << endl;
39  cout
40  << " Masterfile: A regular MT data file, the frequencies in this files "
41  << endl;
42  cout
43  << " will be used as the frequencies for the forward calculation "
44  << endl << endl;
45  cout
46  << "If not command line parameters are given the program will ask for the first two parameters"
47  << endl;
48  cout << "and use a standard set of frequencies. " << endl << endl;
49  }
50 
51  C1DAnisoMTSynthData Synthetic; // create Object for Calculation of Synthetics
52 
53  string modelfilename, mttfilename;
54 
55  if (argc > 1) // if we have at least one additional command line parameter
56 
57  {
58  modelfilename = argv[1]; // interpret the first one as a model file name
59  }
60  else //ask for model file interactively
61 
62  {
63  modelfilename = AskFilename("Model filename: ");
64  }
65 
66  Synthetic.ReadModel(modelfilename); // read in model
67  if (argc > 2)//if we have at least two command line parameters
68 
69  {
70  mttfilename = argv[2]; //interpret the second one as the name of the output file
71  }
72  else
73  {
74  cout << "Output Format is .mtt ! Do not append ending. " << endl;
75  mttfilename = AskFilename("Output Filename: ");
76  }
77  if (argc > 3) //if we have 3 command line parameters
78 
79  {
80  MTStation Masterfile(argv[3]); //read data from filename
81  Synthetic.SetFrequencies(Masterfile.GetFrequencies()); //set the calculation frequencies to master frequencies
82  }
83  Synthetic.GetData(); // Calculate Model
84  Synthetic.WriteAsMtt(mttfilename); // Write out Mtt file
85  PTensorMTStation Tensor;
86  Tensor = Synthetic;
87  Tensor.WriteData(mttfilename);
88  } catch (FatalException &e)
89  {
90  cerr << e.what() << endl;
91  return -1;
92  } catch (...)
93  {
94  cerr << "Fatal Error, aborting !" << endl;
95  return 100;
96  }
97  }
virtual void GetData()
Calculate the synthetic data given the previously set parameters.
Calculate response of a 1D anisotropic model, code is based on Pek and Santos fortran code...
void WriteData(const std::string &filename)
The class MTStation is used to store the transfer functions and related information for a MT-site...
Definition: MTStation.h:17
void ReadModel(std::string filename)
void WriteAsMtt(const std::string filename)
Write data in goettingen .mtt format.
Definition: MTStation.cpp:681
string version
Definition: makeinput.cpp:16
int main(int argc, char *argv[])
Definition: anisomt.cpp:12
trealdata GetFrequencies() const
return the available frequencies in a single vector
Definition: MTStation.cpp:136
void SetFrequencies(const trealdata &freqs)
Set the frequencies of the tensor elements, invalidates the previously stored impedance data...
Definition: MTStation.cpp:144
The basic exception class for all errors that arise in gplib.