plotmtt.cpp

Go to the documentation of this file.
00001 /*! 
00002  * \addtogroup UtilProgs Utility Programs
00003  *@{
00004  * \file
00005  * Calculate apparent resistivity and phase from a .mtt, .edi or .j file and write 
00006  * one file with error information for each component to use for plotting. The program
00007  * will automatically append .rxx, .rxy, .ryx and .ryy for the four apparent resistivities and
00008  * .pxx, .pxy, .pyx and .pyy for the four phases respectively. It also outputs the apparent resistivity and phases of the 
00009  * Berdichevskiy invariant in the files .rberd and .pberd, respectively.
00010  * Each file contains lines with Period in seconds, the respective datum and its error.
00011  */
00012 #include "MTStation.h"
00013 #include <boost/function.hpp>
00014 #include "Util.h"
00015 #include <iostream>
00016 #include <iomanip>
00017 #include <fstream>
00018 
00019 using namespace std;
00020 using namespace gplib;
00021 
00022 void WriteToFile(string filename,
00023     boost::function<double(const MTTensor*)> datafunc, boost::function<double(
00024         const MTTensor*)> errfunc, const MTStation &Data)
00025   {
00026     ofstream outfile(filename.c_str());
00027     const size_t ndata = Data.GetMTData().size();
00028     for (size_t i = 0; i < ndata; ++i)
00029       {
00030         outfile << setw(15) << setfill(' ') << setprecision(4) << 1. / Data.at(
00031             i).GetFrequency();
00032         outfile << setw(15) << setfill(' ') << setprecision(4) << datafunc(
00033             &Data.at(i));
00034         outfile << setw(15) << setfill(' ') << setprecision(4) << errfunc(
00035             &Data.at(i)) << endl;
00036       }
00037   }
00038 
00039 int main(int argc, char *argv[])
00040   {
00041     string version = "$Id: plotmtt.cpp 1816 2009-09-07 11:28:35Z mmoorkamp $";
00042     cout << endl << endl;
00043     cout << "Program " << version << endl;
00044     cout
00045         << "Write out impedance phase and apparent resistivity for plotting.  "
00046         << endl;
00047     cout
00048         << "Will create 8 files starting with Infilename and endings r** for apparent resistivity components  "
00049         << endl;
00050     cout << " and p** for phase components." << endl << endl;
00051     string infilename;
00052     MTStation Data;
00053     if (argc == 2)
00054       {
00055         infilename = argv[1];
00056       }
00057     else
00058       {
00059         infilename = AskFilename("Infilename: ");
00060       }
00061     Data.GetData(infilename);
00062     WriteToFile(infilename + ".rxx", &MTTensor::GetRhoxx, &MTTensor::GetdRhoxx,
00063         Data);
00064     WriteToFile(infilename + ".rxy", &MTTensor::GetRhoxy, &MTTensor::GetdRhoxy,
00065         Data);
00066     WriteToFile(infilename + ".ryx", &MTTensor::GetRhoyx, &MTTensor::GetdRhoyx,
00067         Data);
00068     WriteToFile(infilename + ".ryy", &MTTensor::GetRhoyy, &MTTensor::GetdRhoyy,
00069         Data);
00070     WriteToFile(infilename + ".pxx", &MTTensor::GetPhi90xx,
00071         &MTTensor::GetdPhixx, Data);
00072     WriteToFile(infilename + ".pxy", &MTTensor::GetPhi90xy,
00073         &MTTensor::GetdPhixy, Data);
00074     WriteToFile(infilename + ".pyx", &MTTensor::GetPhi90yx,
00075         &MTTensor::GetdPhiyx, Data);
00076     WriteToFile(infilename + ".pyy", &MTTensor::GetPhi90yy,
00077         &MTTensor::GetdPhiyy, Data);
00078     WriteToFile(infilename + ".rberd", &MTTensor::GetRhoBerd,
00079         &MTTensor::GetdRhoBerd, Data);
00080     WriteToFile(infilename + ".pberd", &MTTensor::GetPhi90Berd,
00081         &MTTensor::GetdPhi90Berd, Data);
00082 
00083   }
00084 /*@}*/

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