12 #include <boost/function.hpp>
13 #include <boost/bind.hpp>
15 #include <boost/progress.hpp>
16 #include <boost/program_options.hpp>
19 using namespace gplib;
22 "$Id: phasetensormap.cpp 1838 2010-03-04 16:19:34Z mmoorkamp $";
38 const int freqindex, boost::function<
double(
T)> adaptor,
int ntestcases = 0)
40 const std::vector<tindexvector>
42 ofstream outfile(filename.c_str());
43 std::cout <<
" Working on file: " << filename << std::endl;
44 boost::progress_display show_progress(StationList.
GetList().size());
46 for (
unsigned int i = 0; i < StationList.
GetList().size(); ++i)
48 outfile << setw(12) << setfill(
' ') << setprecision(4)
50 outfile << setw(12) << setfill(
' ') << setprecision(4)
52 outfile << setw(12) << setfill(
' ') << setprecision(4) << adaptor(
54 realindices.at(i).at(freqindex)))());
58 double JackMean, JackErr;
60 realindices.at(i).at(freqindex)));
63 outfile <<
" " << setw(12) << setfill(
' ') << setprecision(4)
69 std::cout << std::endl << std::endl;
72 namespace po = boost::program_options;
74 int main(
int argc,
char *argv[])
76 string infilename, outfilename;
79 <<
" This is phasetensormap, calculate phasetensor elipses etc. from MT data"
81 cout <<
" Reads in a list of files and outputs files for plotting with gmt"
83 cout <<
" File endings will be automatically appended." << endl;
85 <<
" For error calculation, numbers < 2 will be interpreted as no error calculation."
87 cout <<
" This is Version: " <<
version << endl << endl;
89 int nbootsamples = -1;
90 double scalefactor = 10;
92 po::options_description desc(
"General options");
93 desc.add_options()(
"help",
"produce help message")(
"calcerr",
94 po::value<int>(&nbootsamples)->default_value(-1),
95 "Calculate error estimates")(
"scalefactor", po::value<double>(
96 &scalefactor)->default_value(10.0),
97 "Scalefactor for phase tensor ellipse size in plots.");
100 po::store(po::parse_command_line(argc, argv, desc), vm);
103 if (vm.count(
"help"))
105 std::cout << desc <<
"\n";
109 infilename = AskFilename(
"File with station names: ");
115 cerr <<
"No common frequencies found !";
120 cerr << e.what() << endl;
123 outfilename = AskFilename(
"Output Filename Root: ");
128 for (trealdata::const_iterator frequencies =
132 cout << setw(9) << setfill(
' ') << setprecision(4) << distance(
134 cout << setw(15) << setfill(
' ') << setprecision(8) << 1.
135 / (*frequencies) << endl;
138 cout <<
"Select frequency Index: ";
141 ofstream outfile((outfilename +
".ptensor").c_str());
142 for (vector<MTStation>::iterator it = MTSites.
GetList().begin(); it
143 != MTSites.
GetList().end(); ++it)
146 MTSites.
GetList().begin(), it)).at(freqindex);
147 double rotangle = (it->GetMTData().at(realfreqindex).GetPhiStrike())
151 outfile << setw(12) << setfill(
' ') << setprecision(4)
152 << it->GetLongitude();
153 outfile << setw(12) << setfill(
' ') << setprecision(4)
154 << it->GetLatitude();
155 outfile << setw(12) << setfill(
' ') << setprecision(4)
156 << it->GetMTData().at(realfreqindex).GetBeta_phi() * 180. / PI;
157 outfile << setw(12) << setfill(
' ') << setprecision(4) << 90 - rotangle;
158 outfile << setw(12) << setfill(
' ') << setprecision(4)
159 << it->GetMTData().at(realfreqindex).GetPhiMax() * scalefactor;
160 outfile << setw(12) << setfill(
' ') << setprecision(4)
161 << it->GetMTData().at(realfreqindex).GetPhiMin() * scalefactor
167 PrintComponent<double> ((outfilename +
".ptskew"), &MTTensor::GetBeta_phi,
168 MTSites, freqindex, gplib::absangle(), nbootsamples);
169 PrintComponent<double> ((outfilename +
".ptstrike"),
170 &MTTensor::GetPhiStrike, MTSites, freqindex, boost::bind(multiplies<
171 double> (), _1, -180. / PI), nbootsamples);
172 PrintComponent<double> ((outfilename +
".bstrike"), &MTTensor::GetAlpha,
173 MTSites, freqindex, boost::bind(multiplies<double> (), _1, 180. / PI),
176 MTSites, freqindex, gplib::nomod<double>, nbootsamples);
177 PrintComponent<double> ((outfilename +
".ptmin"), &MTTensor::GetPhiMin,
178 MTSites, freqindex, gplib::nomod<double>, nbootsamples);
179 PrintComponent<double> ((outfilename +
".ptmax"), &MTTensor::GetPhiMax,
180 MTSites, freqindex, gplib::nomod<double>, nbootsamples);
181 PrintComponent<double> ((outfilename +
".ptphi1"), &MTTensor::GetPhi1,
182 MTSites, freqindex, gplib::nomod<double>, nbootsamples);
183 PrintComponent<double> ((outfilename +
".ptphi2"), &MTTensor::GetPhi2,
184 MTSites, freqindex, gplib::nomod<double>, nbootsamples);
186 MTSites, freqindex, gplib::nomod<double>, nbootsamples);
187 PrintComponent<double> ((outfilename +
".ptphi11"), &MTTensor::GetPhi11,
188 MTSites, freqindex, gplib::nomod<double>, nbootsamples);
189 PrintComponent<double> ((outfilename +
".ptphi12"), &MTTensor::GetPhi12,
190 MTSites, freqindex, gplib::nomod<double>, nbootsamples);
191 PrintComponent<double> ((outfilename +
".ptphi21"), &MTTensor::GetPhi21,
192 MTSites, freqindex, gplib::nomod<double>, nbootsamples);
193 PrintComponent<double> ((outfilename +
".ptphi22"), &MTTensor::GetPhi22,
194 MTSites, freqindex, gplib::nomod<double>, nbootsamples);
double GetLatitude() const
access funtion for Latitude
MTStation & at(int loc)
Get a reference to a site at a given index.
void CalcErrors(double &m, double &v)
The main function, calculates the error, by generating samples and calling the derived function...
void f(vector< double > &v1, vector< double > &v2, vector< double > &v3, vector< double > &v4)
const trealdata & GetCommonFrequencies()
Get a vector with frequencies that are common to all sites.
MTStationList holds a number of MTSites, usually associated with a single project, line, etc.
Implements the Jacknifing method of error estimation.
Generate random elements of a calculated quantity for MT impedance data.
int main(int argc, char *argv[])
void PrintComponent(const std::string &filename, boost::function< const T(const MTTensor *)> f, MTStationList &StationList, const int freqindex, boost::function< double(T)> adaptor, int ntestcases=0)
Print out one component of MT data from a list of Stations for plotting with GMT. ...
tStationList & GetList()
Access to the complete vector of Stations.
const float T[frequenzen]
const std::vector< tindexvector > & GetComFreqIndices()
Get a vector that for each site contains the indices to the common frequencies.
Stores MT-Tensor components at a single frequency, calculates derived quantities. ...
void GetData(const std::string filename)
Read a list of filenames and the associated data in those files to fill the list. ...
const std::vector< MTTensor > & GetMTData() const
Get the full vector of Tensor elements read only.
The basic exception class for all errors that arise in gplib.
double GetLongitude() const