00001 #include <iostream>
00002 #include <string>
00003 #include <numeric>
00004 #include "TimeSeriesData.h"
00005 #include "CFatalException.h"
00006 #include <boost/date_time/posix_time/posix_time.hpp>
00007 #include "Util.h"
00008 using namespace std;
00009
00010 string version = "$Id: syncts.cpp 1672 2008-04-03 15:03:35Z mmoorkamp $";
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 int main (int argc, char *argv[])
00021 {
00022 string infilename1, infilename2;
00023
00024 cout << "This is syncts: Synchronize the start of two time series" << endl<< endl;
00025 cout << "Usage: syncts filename1 filename2" << endl;
00026 cout << "The outputfiles will have the starttime of whatever starts later" << endl;
00027 cout << "They will have the same name as the input files + .sync "<< endl << endl;
00028 cout << "This is Version: " << version << endl << endl;
00029 if (argc == 3)
00030 {
00031 infilename1 = argv[1];
00032 infilename2 = argv[2];
00033 }
00034 else
00035 {
00036 infilename1 = AskFilename("First Input Filename: ");
00037 infilename2 = AskFilename("Second Input Filename: ");
00038
00039 }
00040 cout << "Synchronizing ... " << endl;
00041 TimeSeriesData Data1, Data2;
00042 try
00043 {
00044 Data1.GetData(infilename1);
00045 Data2.GetData(infilename2);
00046 cout << "Start time file 1: " << Data1.GetData().GetTime().front() << endl;
00047 cout << "Start time file 2: " << Data2.GetData().GetTime().front() << endl << endl;
00048 Synchronize(Data1.GetData(),Data2.GetData());
00049 Data1.WriteAsBirrp(infilename1+".sync");
00050 Data2.WriteAsBirrp(infilename2+".sync");
00051 cout << "New start time file 1: " << Data1.GetData().GetTime().front() << endl;
00052 cout << "New start time file 2: " << Data2.GetData().GetTime().front() << endl;
00053 }
00054 catch(const CFatalException &e)
00055 {
00056 cerr << e.what() << endl;
00057 }
00058 cout << "... done " << endl;
00059 }
00060