magmean.cpp

Go to the documentation of this file.
00001 /*!
00002  * \addtogroup UtilProgs Utility Programs
00003  *@{
00004  * \file
00005  * This program calculates the mean magnetic time series for several MT sites. The user has to input the number of sites and the
00006  * filename for each site. The program then writes a file 'magmean.out' in birrp ascii format that contains the average Hx,Hy and Hz for the input sites.
00007  */
00008 
00009 #include <iostream>
00010 #include <string>
00011 #include <strstream>
00012 #include <vector>
00013 #include "TimeSeriesData.h"
00014 #include "Util.h"
00015 
00016 using namespace std;
00017 
00018 string version = "$Id: magmean.cpp 1672 2008-04-03 15:03:35Z mmoorkamp $";
00019 
00020 int main(int argc, char *argv[])
00021   {
00022 
00023     unsigned int nfiles = 0;
00024 
00025     cout
00026         << "This is magmean: Calculate the mean magnetic time series from several stations"
00027         << endl<< endl;
00028     cout << "Usage: magmean" << endl;
00029     cout << "There are no command line arguments, only interactive mode"
00030         << endl<< endl;
00031     cout << "This is Version: " << version << endl << endl;
00032     cout << "How many stations: ";
00033     cin >> nfiles;
00034     string infilename;
00035     vector<TimeSeriesData> Sites;
00036     for (unsigned int i = 0; i < nfiles; ++i)
00037       {
00038         strstream prompt;
00039         prompt << "Site File " << i+1 << " :";
00040         TimeSeriesData CurrSite;
00041         infilename = AskFilename(prompt.str());
00042         CurrSite.GetData(infilename);
00043         Sites.push_back(CurrSite);
00044       }
00045     cout << "Calculating mean ... " << endl;
00046 
00047     for (unsigned int i = 1; i < nfiles; ++i)
00048       {
00049         Sites.at(0).GetData().GetHx() += Sites.at(i).GetData().GetHx();
00050         Sites.at(0).GetData().GetHy() += Sites.at(i).GetData().GetHy();
00051         Sites.at(0).GetData().GetHz() += Sites.at(i).GetData().GetHz();
00052       }
00053     Sites.at(0).GetData().GetHx() *= 1./nfiles;
00054     Sites.at(0).GetData().GetHy() *= 1./nfiles;
00055     Sites.at(0).GetData().GetHz() *= 1./nfiles;
00056     Sites.at(0).WriteAsBirrp("magmean.out");
00057     cout << "... done " << endl;
00058   }
00059 /*@}*/
00060 

Generated on Fri Jul 4 15:30:20 2008 for GPLIB++ by  doxygen 1.5.5