23 string version =
"$Id: zavg.cpp 1836 2009-11-27 12:17:24Z mmoorkamp $";
25 cout <<
"Program " << version << endl;
26 cout <<
"Average MT responses from a list of file " << endl;
27 cout <<
"The average response will be written in a file called avg.mtt "
29 cout <<
"List filename:";
40 const size_t nsites = MTSites.
GetList().size();
41 const double errorfloor = 0.02;
42 const double absolutemin = 1e-4;
43 for (
size_t j = 0; j < nfreq; ++j)
53 for (
size_t i = 0; i < nsites; ++i)
55 double minweight = max(
56 abs(MTSites.
at(i).
GetMTData().at(j).GetZxx()) * errorfloor,
58 double currweight = 1. / pow(max(
59 MTSites.
at(i).
GetMTData().at(j).GetdZxx(), minweight), 2);
60 currzxx += MTSites.
at(i).
GetMTData().at(j).GetZxx() * currweight;
61 xxweights += currweight;
63 minweight = max(abs(MTSites.
at(i).
GetMTData().at(j).GetZxy())
64 * errorfloor, absolutemin);
65 currweight = 1. / pow(max(
66 MTSites.
at(i).
GetMTData().at(j).GetdZxy(), minweight), 2);
67 currzxy += MTSites.
at(i).
GetMTData().at(j).GetZxy() * currweight;
68 xyweights += currweight;
70 minweight = max(abs(MTSites.
at(i).
GetMTData().at(j).GetZyx())
71 * errorfloor, absolutemin);
72 currweight = 1. / pow(max(
73 MTSites.
at(i).
GetMTData().at(j).GetdZyx(), minweight), 2);
74 currzyx += MTSites.
at(i).
GetMTData().at(j).GetZyx() * currweight;
75 yxweights += currweight;
77 minweight = max(abs(MTSites.
at(i).
GetMTData().at(j).GetZyy())
78 * errorfloor, absolutemin);
79 currweight = 1. / pow(max(
80 MTSites.
at(i).
GetMTData().at(j).GetdZyy(), minweight), 2);
81 currzyy += MTSites.
at(i).
GetMTData().at(j).GetZyy() * currweight;
82 yyweights += currweight;
84 AvgSite.SetMTData().at(j).SetZxx() = currzxx / xxweights;
85 AvgSite.SetMTData().at(j).SetZxy() = currzxy / xyweights;
86 AvgSite.SetMTData().at(j).SetZyx() = currzyx / yxweights;
87 AvgSite.SetMTData().at(j).SetZyy() = currzyy / yyweights;
88 AvgSite.SetMTData().at(j).SetErrors(sqrt(1. / xxweights), sqrt(1.
89 / xyweights), sqrt(1. / yxweights), sqrt(1. / yyweights));
92 AvgSite.WriteAsMtt(
"avg");
MTStation & at(int loc)
Get a reference to a site at a given index.
The class MTStation is used to store the transfer functions and related information for a MT-site...
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.
trealdata GetFrequencies() const
return the available frequencies in a single vector
void SetFrequencies(const trealdata &freqs)
Set the frequencies of the tensor elements, invalidates the previously stored impedance data...