ptavg.cpp

Go to the documentation of this file.
00001 #include <iostream>
00002 #include <iomanip>
00003 #include <fstream>
00004 #include "MTStationList.h"
00005 #include "PTensorMTStation.h"
00006 #include "VecMat.h"
00007 #include "statutils.h"
00008 using namespace std;
00009 
00010 int main()
00011   {
00012     MTStationList MTSites;
00013     PTensorMTStation PTStation;
00014     string infilename;
00015 
00016     string version = "$Id: ptavg.cpp 1572 2007-12-17 18:20:43Z mmoorkamp $";
00017     cout << endl << endl;
00018     cout << "Program " << version << endl;
00019     cout << "Average MT phase tensor elements from a list of files  " << endl;
00020     cout
00021         << "The average phase tensor will be written in a file called avg.ptensor "
00022         << endl;
00023     cout << "List filename:";
00024     cin >> infilename;
00025 
00026     MTSites.GetData(infilename);
00027     const size_t nfreq = MTSites.at(0).GetFrequencies().size();
00028     const size_t nsites = MTSites.GetList().size();
00029     const double errorfloor = 0.02;
00030     const double absolutemin = 1e-4; // have to find a better solution to avoid strong weighting of 0 values
00031     for (size_t j = 0; j < nfreq; ++j)
00032       {
00033         gplib::rvec xxvalues(nsites);
00034         gplib::rvec xyvalues(nsites);
00035         gplib::rvec yxvalues(nsites);
00036         gplib::rvec yyvalues(nsites);
00037 
00038         for (size_t i = 0; i < nsites; ++i)
00039           {
00040             xxvalues(i) = MTSites.at(i).GetMTData().at(j).GetPhi11();
00041             xyvalues(i) = MTSites.at(i).GetMTData().at(j).GetPhi12();
00042             yxvalues(i) = MTSites.at(i).GetMTData().at(j).GetPhi21();
00043             yyvalues(i) = MTSites.at(i).GetMTData().at(j).GetPhi22();
00044 
00045           }
00046         double phi11 = Mean(xxvalues.begin(), xxvalues.end());
00047         double phi12 = Mean(xyvalues.begin(), xyvalues.end());
00048         double phi21 = Mean(yxvalues.begin(), yxvalues.end());
00049         double phi22 = Mean(yyvalues.begin(), yyvalues.end());
00050 
00051         double varphi11 = Variance(xxvalues.begin(), xxvalues.end());
00052         double varphi12 = Variance(xyvalues.begin(), xyvalues.end());
00053         double varphi21 = Variance(yxvalues.begin(), yxvalues.end());
00054         double varphi22 = Variance(yyvalues.begin(), yyvalues.end());
00055 
00056         PTStation.GetTensor().push_back(PTensorMTData(MTSites.at(0).GetFrequencies().at(j), phi11, phi12, phi21, phi22, sqrt(varphi11),
00057             sqrt(varphi12), sqrt(varphi21), sqrt(varphi22)));
00058       }
00059     PTStation.WriteData("avg.ptensor");
00060   }
00061 

Generated on Fri Jul 4 15:30:21 2008 for GPLIB++ by  doxygen 1.5.5