10 using namespace gplib;
27 string version =
"$Id: ptavg.cpp 1836 2009-11-27 12:17:24Z mmoorkamp $";
29 cout <<
"Program " << version << endl;
30 cout <<
"Average MT phase tensor elements from a list of files " << endl;
32 <<
"The average phase tensor will be written in a file called avg.ptensor "
34 cout <<
"List filename:";
39 const size_t nsites = MTSites.
GetList().size();
40 const double errorfloor = 0.02;
41 const double absolutemin = 1e-4;
42 for (
size_t j = 0; j < nfreq; ++j)
44 gplib::rvec xxvalues(nsites);
45 gplib::rvec xyvalues(nsites);
46 gplib::rvec yxvalues(nsites);
47 gplib::rvec yyvalues(nsites);
49 for (
size_t i = 0; i < nsites; ++i)
51 xxvalues(i) = MTSites.
at(i).
GetMTData().at(j).GetPhi11();
52 xyvalues(i) = MTSites.
at(i).
GetMTData().at(j).GetPhi12();
53 yxvalues(i) = MTSites.
at(i).
GetMTData().at(j).GetPhi21();
54 yyvalues(i) = MTSites.
at(i).
GetMTData().at(j).GetPhi22();
57 double phi11 =
Mean(xxvalues.begin(), xxvalues.end());
58 double phi12 =
Mean(xyvalues.begin(), xyvalues.end());
59 double phi21 =
Mean(yxvalues.begin(), yxvalues.end());
60 double phi22 =
Mean(yyvalues.begin(), yyvalues.end());
62 double varphi11 =
Variance(xxvalues.begin(), xxvalues.end());
63 double varphi12 =
Variance(xyvalues.begin(), xyvalues.end());
64 double varphi21 =
Variance(yxvalues.begin(), yxvalues.end());
65 double varphi22 =
Variance(yyvalues.begin(), yyvalues.end());
69 sqrt(varphi11), sqrt(varphi12), sqrt(varphi21), sqrt(varphi22)));
This class is for the special case where we only have phase tensor data and errors, but not the full impedance.
MTStation & at(int loc)
Get a reference to a site at a given index.
std::iterator_traits< InputIterator >::value_type Mean(InputIterator begin, InputIterator end)
Calculate the mean for a given range.
std::vector< PTensorMTData > & GetTensor()
void WriteData(const std::string &filename)
MTStationList holds a number of MTSites, usually associated with a single project, line, etc.
tStationList & GetList()
Access to the complete vector of Stations.
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.
std::iterator_traits< InputIterator >::value_type Variance(InputIterator begin, InputIterator end, typename std::iterator_traits< InputIterator >::value_type mv)
Calculate the Variance and give the mean as a third input parameter.
trealdata GetFrequencies() const
return the available frequencies in a single vector