anisomt.cpp

Go to the documentation of this file.
00001 #include <iostream>
00002 #include <string>
00003 #include "Util.h"
00004 #include "C1DAnisoMTSynthData.h"
00005 #include "MTStation.h"
00006 #include "PTensorMTStation.h"
00007 #include <iterator>
00008 
00009 using namespace std;
00010 using namespace gplib;
00011 
00012 int main(int argc, char *argv[])
00013   {
00014     try
00015       {
00016         if (argc == 1) //if we have no additional command line arguments, output some info
00017 
00018           {
00019             string version =
00020                 "$Id: anisomt.cpp 1816 2009-09-07 11:28:35Z mmoorkamp $";
00021             cout << endl << endl;
00022             cout << "Program " << version << endl;
00023             cout
00024                 << "Calculates 1D MT Responses with Anisotropy from input models "
00025                 << endl;
00026             cout << "Based on Pek and Santos code. " << endl;
00027             cout << "You can give up to 3 command line parameters: " << endl;
00028             cout << "  anisomt modelfilename outfilebase masterfile " << endl
00029                 << endl;
00030             cout
00031                 << "  Modelfilename: The name of the file containing the model"
00032                 << endl << endl;
00033             cout
00034                 << "  Outfilebase: The name of the outputfiles without ending,"
00035                 << endl;
00036             cout
00037                 << "  the code will produce 2 files with additional endings .mtt and .ptensor"
00038                 << endl << endl;
00039             cout
00040                 << "  Masterfile: A regular MT data file, the frequencies in this files "
00041                 << endl;
00042             cout
00043                 << "  will be used as the frequencies for the forward calculation "
00044                 << endl << endl;
00045             cout
00046                 << "If not command line parameters are given the program will ask for the first two parameters"
00047                 << endl;
00048             cout << "and use a standard set of frequencies. " << endl << endl;
00049           }
00050 
00051         C1DAnisoMTSynthData Synthetic; // create Object for Calculation of Synthetics
00052 
00053         string modelfilename, mttfilename;
00054 
00055         if (argc > 1) // if we have at least one additional command line parameter
00056 
00057           {
00058             modelfilename = argv[1]; // interpret the first one as a model file name
00059           }
00060         else //ask for model file interactively
00061 
00062           {
00063             modelfilename = AskFilename("Model filename: ");
00064           }
00065 
00066         Synthetic.ReadModel(modelfilename); // read in model
00067         if (argc > 2)//if we have at least two command line parameters
00068 
00069           {
00070             mttfilename = argv[2]; //interpret the second one as the name of the output file
00071           }
00072         else
00073           {
00074             cout << "Output Format is .mtt ! Do not append ending. " << endl;
00075             mttfilename = AskFilename("Output Filename: ");
00076           }
00077         if (argc > 3) //if we have 3 command line parameters
00078 
00079           {
00080             MTStation Masterfile(argv[3]); //read data from filename 
00081             Synthetic.SetFrequencies(Masterfile.GetFrequencies()); //set the calculation frequencies to master frequencies
00082           }
00083         Synthetic.GetData(); // Calculate Model
00084         Synthetic.WriteAsMtt(mttfilename); // Write out Mtt file
00085         PTensorMTStation Tensor;
00086         Tensor = Synthetic;
00087         Tensor.WriteData(mttfilename);
00088       } catch (FatalException &e)
00089       {
00090         cerr << e.what() << endl;
00091         return -1;
00092       } catch (...)
00093       {
00094         cerr << "Fatal Error, aborting !" << endl;
00095         return 100;
00096       }
00097   }

Generated on Tue May 4 16:52:14 2010 for GPLIB++ by  doxygen 1.5.8