syncts.cpp

Go to the documentation of this file.
00001 #include <iostream>
00002 #include <string>
00003 #include <numeric>
00004 #include "TimeSeriesData.h"
00005 #include "FatalException.h"
00006 #include <boost/date_time/posix_time/posix_time.hpp>
00007 #include "Util.h"
00008 
00009 using namespace std;
00010 using namespace gplib;
00011 
00012 string version = "$Id: syncts.cpp 1816 2009-09-07 11:28:35Z mmoorkamp $";
00013 
00014 /*!
00015  * \addtogroup UtilProgs Utility Programs
00016  *@{
00017  * \file
00018  * Synchronize 2 files so that they have exactly the same start time and end time. This program
00019  * does not fix gaps that are only present in one file !
00020  */
00021 
00022 int main(int argc, char *argv[])
00023   {
00024     string infilename1, infilename2;
00025 
00026     cout << "This is syncts: Synchronize the start of two time series" << endl
00027         << endl;
00028     cout << "Usage: syncts filename1 filename2" << endl;
00029     cout << "The outputfiles will have the starttime of whatever starts later"
00030         << endl;
00031     cout << "They will have the same name as the input files + .sync " << endl
00032         << endl;
00033     cout << "This is Version: " << version << endl << endl;
00034     if (argc == 3)
00035       {
00036         infilename1 = argv[1];
00037         infilename2 = argv[2];
00038       }
00039     else
00040       {
00041         infilename1 = AskFilename("First Input Filename: ");
00042         infilename2 = AskFilename("Second Input Filename:  ");
00043 
00044       }
00045     cout << "Synchronizing ... " << endl;
00046     TimeSeriesData Data1, Data2;
00047     try
00048       {
00049         Data1.GetData(infilename1);
00050         Data2.GetData(infilename2);
00051         cout << "Start time file 1: " << Data1.GetData().GetTime().front()
00052             << endl;
00053         cout << "Start time file 2: " << Data2.GetData().GetTime().front()
00054             << endl << endl;
00055         Synchronize(Data1.GetData(), Data2.GetData());
00056         Data1.WriteAsBirrp(infilename1 + ".sync");
00057         Data2.WriteAsBirrp(infilename2 + ".sync");
00058         cout << "New start time file 1: " << Data1.GetData().GetTime().front()
00059             << endl;
00060         cout << "New start time file 2: " << Data2.GetData().GetTime().front()
00061             << endl;
00062       } catch (const FatalException &e)
00063       {
00064         cerr << e.what() << endl;
00065       }
00066     cout << "... done " << endl;
00067   }
00068 /*@}*/

Generated on Tue May 4 16:52:15 2010 for GPLIB++ by  doxygen 1.5.8