GPLIB++
mtufdiff.cpp
Go to the documentation of this file.
1 #include <iostream>
2 #include <string>
3 #include <numeric>
4 #include "Util.h"
5 #include "TimeSeriesData.h"
6 
7 using namespace std;
8 using namespace gplib;
9 string version = "$Id: mtu2birrp.cpp 651 2006-10-10 14:46:53Z max $";
10 
11 /*!
12  * \addtogroup UtilProgs Utility Programs
13  *@{
14  * \file
15  * Calculate the first difference for all components of a MT time-series.
16  */
17 
18 int main(int argc, char *argv[])
19  {
20  string infilename;
21  if (argc == 2)
22  {
23  infilename = argv[1];
24  }
25  else
26  {
27  cout
28  << "This is mtufdiff: Calculate first difference of Phoenix time series"
29  << endl << endl;
30  cout << " Usage: mtufdiff infilename " << endl;
31  cout
32  << " Ending '.fdiff' will be automatically assigned to outfilename"
33  << endl << endl;
34  cout << " This is Version: " << version << endl << endl;
35  infilename = AskFilename(" Mtu-Filename: ");
36  }
37 
38  TimeSeriesData Data;
39 
40  Data.GetData(infilename);
41  adjacent_difference(Data.GetData().GetEx().GetData().begin(),
42  Data.GetData().GetEx().GetData().end(),
43  Data.GetData().GetEx().GetData().begin());
44  adjacent_difference(Data.GetData().GetEy().GetData().begin(),
45  Data.GetData().GetEy().GetData().end(),
46  Data.GetData().GetEy().GetData().begin());
47  adjacent_difference(Data.GetData().GetHx().GetData().begin(),
48  Data.GetData().GetHx().GetData().end(),
49  Data.GetData().GetHx().GetData().begin());
50  adjacent_difference(Data.GetData().GetHy().GetData().begin(),
51  Data.GetData().GetHy().GetData().end(),
52  Data.GetData().GetHy().GetData().begin());
53  Data.WriteBack(infilename + ".fdiff");
54  }
55 /*@}*/
std::vector< double > & GetData()
Access for data vector, for ease of use and efficiency we return a reference.
TimeSeries & GetData()
return a reference to the actual object stored in the pointer
TimeSeriesComponent & GetEx()
Definition: TimeSeries.h:47
TimeSeriesComponent & GetHy()
Definition: TimeSeries.h:39
string version
Definition: mtufdiff.cpp:9
int main()
Definition: angleavg.cpp:12
void WriteBack(std::string filename_base)
Write in the format it was originally read in.
TimeSeriesData stores a pointer to the different components of magnetotelluric data and provides func...
TimeSeriesComponent & GetEy()
Definition: TimeSeries.h:51
TimeSeriesComponent & GetHx()
Access function for Hx, returns reference for efficiency.
Definition: TimeSeries.h:35