diffangle.cpp

Go to the documentation of this file.
00001 #include "MTStationList.h"
00002 #include "CFatalException.h"
00003 #include <iostream>
00004 #include <string>
00005 #include <fstream>
00006 #include <iomanip>
00007 #include "Jacknife.h"
00008 
00009 using namespace std;
00010 using namespace gplib;
00011 
00012 string version = "$Id: diffangle.cpp 1816 2009-09-07 11:28:35Z mmoorkamp $";
00013 void PromptAndReadStationFile(MTStationList &List, std::string prompt)
00014   {
00015     string listname;
00016     cout << prompt;
00017     cin >> listname;
00018     try
00019       {
00020         List.GetData(listname); //try to read in all station data
00021       } catch (FatalException &e)
00022       {
00023         cerr << e.what() << endl; // if something fails print error
00024         exit(100); // and stop execution
00025       }
00026   }
00027 
00028 int PromptAndReadFreqIndex(MTStationList &List, std::string prompt)
00029   {
00030     cout << prompt << endl << endl;
00031     cout << "Available Periods: " << List.GetCommonFrequencies().size() << endl;
00032 
00033     for (trealdata::const_iterator frequencies =
00034         List.GetCommonFrequencies().begin(); frequencies
00035         != List.GetCommonFrequencies().end(); ++frequencies)
00036       {
00037         cout << setw(9) << setfill(' ') << setprecision(4) << distance(
00038             List.GetCommonFrequencies().begin(), frequencies);
00039         cout << setw(15) << setfill(' ') << setprecision(8) << 1.
00040             / (*frequencies) << endl;
00041       }
00042     int freqindex;
00043     cout << "Select frequency Index: ";
00044     cin >> freqindex;
00045     return freqindex;
00046   }
00047 
00048 int main()
00049   {
00050     string list1, list2; //storing names for input and root of output
00051     cout
00052         << " This is diffangle, calculate the difference in strike angle and phase split"
00053         << endl; // write some info
00054     cout << " for corresponding sites in two different lists. " << endl << endl;
00055 
00056     MTStationList MTSites1; // object for the first station list
00057     PromptAndReadStationFile(MTSites1, "Station List 1:");
00058     MTStationList MTSites2; // object for the second station list
00059     PromptAndReadStationFile(MTSites2, "Station List 2:");
00060     tStatSyncPair StatSync = FindCorrespondingSites(MTSites1.GetList(),
00061         MTSites2.GetList());
00062     const std::vector<tindexvector> freqindices1(MTSites1.GetComFreqIndices());
00063     const std::vector<tindexvector> freqindices2(MTSites2.GetComFreqIndices());
00064     int SelectedFreq1 = PromptAndReadFreqIndex(MTSites1, "List 1");
00065     int SelectedFreq2 = PromptAndReadFreqIndex(MTSites2, "List 2");
00066     ofstream outfile("out");
00067     const int nbootsamples = 10000;
00068     CJacknife ErrEst(nbootsamples); //init error estimation object
00069     for (size_t i = 0; i < StatSync.size(); ++i)
00070       {
00071 
00072         double strikediff = (StatSync.at(i).first->GetMTData().at(
00073             freqindices1.at(i).at(SelectedFreq1)).GetPhiEllip()
00074             - StatSync.at(i).second->GetMTData().at(freqindices2.at(i).at(
00075                 SelectedFreq2)).GetPhiEllip());
00076         double strikeerr, dummy;
00077         ErrEst.CalcErrors(&MTTensor::GetPhiEllip,
00078             StatSync.at(i).first->GetMTData().at(freqindices1.at(i).at(
00079                 SelectedFreq1)), dummy, strikeerr);
00080         double phidiffdiff = (StatSync.at(i).first->GetMTData().at(
00081             freqindices1.at(i).at(SelectedFreq1)).GetBeta_phi()
00082             - StatSync.at(i).second->GetMTData().at(freqindices2.at(i).at(
00083                 SelectedFreq2)).GetBeta_phi());
00084         double phidifferr;
00085         ErrEst.CalcErrors(&MTTensor::GetBeta_phi,
00086             StatSync.at(i).first->GetMTData().at(freqindices1.at(i).at(
00087                 SelectedFreq1)), dummy, phidifferr);
00088         outfile << phidiffdiff * 180. / PI << " " << strikediff << " "
00089             << phidifferr * 180. / PI << " " << strikeerr << endl;
00090       }
00091   }

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