cag++.cpp

Go to the documentation of this file.
00001 /*! 
00002  * \file 
00003  * This is the cagniard algorithm to calculate synthetic 1D forward responses for MT.
00004  *  It reads in model files in the following simple format:
00005  * <TABLE>
00006  * <TR> <TD> No. of layers </TD> </TR>
00007  * <TR> <TD> Thickness in km </TD>  <TD> Resistivity in \f$\Omega m\f$  </TD></TR>
00008  * </TABLE>
00009  * 
00010  * The user has to specify the output filename without the ending. ".mtt" will be appended
00011  * automatically to indicate that this file is in Goettingen .mtt format.
00012  * 
00013  * There are two different modes: In standard mode (mode 0)
00014  * the frequencies at which the responses are 
00015  * calculated are based on some realistic frequencies used in deep MT surveys (300Hz - 10.000s).
00016  * In mode 1 the user can specify a window length and sampling rate and the output frequencies are
00017  * based on the fft of a windows with those parameters. This is only useful for some special 
00018  * processing applications and might be removed in the future.
00019  */
00020 
00021 #include <iostream>
00022 #include <string>
00023 #include "Util.h"
00024 #include "C1DMTSynthData.h"
00025 #include <iterator>
00026 
00027 using namespace std;
00028 
00029 int main(int argc, char *argv[]) {
00030         string version =
00031                         "$Id: cag++.cpp 20 2005-11-11 12:57:01 +0100 (Fr, 11 Nov 2005) max $";
00032         cout << endl << endl;
00033         cout << "Program " << version << endl;
00034         cout << "Calculates 1D MT Responses from input models " << endl;
00035         cout
00036                         << "Based on Cagniard algorithm, with stability enhancements taken from A. Avdeeva "
00037                         << endl;
00038 
00039         C1DMTSynthData Synthetic; // create Object for Calculation of Synthetics
00040 
00041 
00042         double samplerate, freqstep;
00043         int samplelength;
00044         const double eps = 1e-5;
00045         string modelfilename, mttfilename;
00046         int mode = 0;
00047         try
00048         {
00049                 if (argc == 2)
00050                 {
00051                         modelfilename = argv[1];
00052                         mttfilename = modelfilename;
00053                         mode = 0;
00054                 }
00055                 else
00056                 {
00057                         modelfilename = AskFilename("Model filename: ");
00058 
00059                         cout << "Output Format is .mtt ! Do not append ending. " << endl;
00060                         mttfilename = AskFilename("Output filename: ");
00061 
00062                         cout << "Use Mode = 0 for standard calculation" << endl;
00063                         cout << "Use Mode = 1 if you want frequencies to be calculated from sample rate and window length." << endl;
00064                         cout << "Mode: ";
00065                         cin >> mode;
00066                 }
00067                 Synthetic.ReadModel(modelfilename); // read in model
00068                 if (mode == 1) //if we want frequencies for a certain window length and sampling rate
00069                 {
00070                         cout << "Sampling rate: "; //ask
00071                         cin >> samplerate;
00072                         cout << "Length for continuous sample: ";
00073                         cin >> samplelength;
00074                         freqstep = samplerate/samplelength;
00075                         trealdata frequency;
00076                         frequency.push_back(eps); //zero frequency means not valid so we use a small value for the static
00077                         for (int i = 1; i < samplelength/2; ++i) // add frequencies
00078                         {
00079                                 frequency.push_back(freqstep * i);
00080                         }
00081                         Synthetic.SetFrequencies(frequency);//copy them to forward calculation object
00082                 }
00083 
00084                 Synthetic.GetData(); // Calculate Model
00085                 Synthetic.WriteAsMtt(mttfilename); // Write out Mtt file
00086         }
00087         catch(CFatalException &e)
00088         {
00089                 cerr << e.what() << endl;
00090                 return -1;
00091         }
00092 }

Generated on Tue May 20 14:12:34 2008 for GPLIB++ by  doxygen 1.5.3