mtucut.cpp
Go to the documentation of this file.00001 #include <iostream>
00002 #include <string>
00003 #include "Util.h"
00004 #include "TimeSeriesData.h"
00005 #include <boost/date_time/posix_time/posix_time.hpp>
00006
00007 using namespace std;
00008 using namespace gplib;
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 string version = "$Id: mtucut.cpp 1816 2009-09-07 11:28:35Z mmoorkamp $";
00019
00020 int main(int argc, char *argv[])
00021 {
00022 string infilename;
00023 size_t newlength, startindex;
00024
00025 cout << "This is mtucut: Cut Phoenix time series to a give lengthi" << endl
00026 << endl;
00027 cout
00028 << "Ending .cut + ending [ts3,ts4,ts5] will be automatically assigned to outfilename"
00029 << endl << endl;
00030 cout << "This is Version: " << version << endl << endl;
00031
00032 if (argc == 2)
00033 {
00034 infilename = argv[1];
00035 }
00036 else
00037 {
00038 infilename = AskFilename("Mtu-Filename: ");
00039 }
00040
00041 TimeSeriesData Data;
00042 Data.GetData(infilename);
00043 cout << "Old length: " << Data.GetData().GetEx().GetData().size() << endl;
00044 cout << "Old Start time: " << Data.GetData().GetTime().front() << endl;
00045 cout << "Old End time: " << Data.GetData().GetTime().back() << endl;
00046 cout << "New length: ";
00047 cin >> newlength;
00048 cout << "Startindex: ";
00049 cin >> startindex;
00050
00051 const size_t length = Data.GetData().GetEx().GetData().size();
00052 if (newlength + startindex > length)
00053 {
00054 cerr << "Selected segment is partially outside time series !";
00055 return 100;
00056 }
00057 else
00058 {
00059
00060 Data.GetData().erase(0, startindex);
00061
00062 Data.GetData().erase(Data.GetData().Size() - (Data.GetData().Size()
00063 - newlength), Data.GetData().Size());
00064 Data.WriteAsMtu(infilename + ".cut");
00065 }
00066
00067 cout << "New Start time: " << Data.GetData().GetTime().front() << endl;
00068 cout << "New End time: " << Data.GetData().GetTime().back() << endl;
00069
00070 }
00071