rlscancel.cpp
Go to the documentation of this file.00001 #include <fstream>
00002 #include <iostream>
00003 #include <vector>
00004 #include <string>
00005 #include <algorithm>
00006 #include "CRLSCanceller.h"
00007 #include "CTimeSeriesData.h"
00008 #include "CStackedSpectrum.h"
00009 #include "CRLSConfig.h"
00010
00011 using namespace std;
00012
00013 int main()
00014 {
00015 CRLSConfig Config;
00016 CRLSCanceller Canceller;
00017 CTimeSeriesData TsData;
00018 StackedSpectrum WeightSpectrum;
00019
00020
00021 Config.GetData("rls.conf");
00022 const int filterlength = Config.filterlength;
00023
00024 const double delta = Config.delta;
00025 const double lambda = Config.lambda;
00026 const int shift = Config.shift;
00027 int i,j;
00028 string tsfilename, noisefilename;
00029 ifstream noisefile,tsfile;
00030 ofstream outfile, weightfile,epsfile;
00031 double temp;
00032 int ntimeseries,minlength = 1e15;
00033 vector<double> noise, epsilon, output,ts;
00034
00035 cout << "Reference Filename: ";
00036 cin >> noisefilename;
00037 noisefile.open(noisefilename.c_str());
00038 while (noisefile.good())
00039 {
00040 noisefile >> temp;
00041 noise.push_back(temp);
00042 }
00043 noisefile.close();
00044 cout << "Number of Time Series: ";
00045 cin >> ntimeseries;
00046 minlength = noise.size();
00047 for (i=0; i < ntimeseries; ++i)
00048 {
00049 cout << "Time Series Filename: ";
00050 cin >> tsfilename;
00051 Canceller.Input.push_back(new ttsdata);
00052
00053 tsfile.open(tsfilename.c_str());
00054 while (tsfile.good())
00055 {
00056 tsfile >> temp;
00057 Canceller.Input.at(i)->push_back(temp);
00058 }
00059 tsfile.close();
00060 tsfile.clear();
00061 if (Canceller.Input.at(i)->size() < minlength)
00062 minlength = Canceller.Input.at(i)->size();
00063 }
00064 for (i=0; i < ntimeseries; ++i)
00065 Canceller.Input.at(i)->resize(minlength);
00066 cout << "Minlength: " << minlength << endl;
00067 Canceller.filterlength = filterlength;
00068 Canceller.delta = delta;
00069 Canceller.lambda = lambda;
00070
00071 Canceller.FilterOutput = &noise;
00072 Canceller.Epsilon = ε
00073 Canceller.Desired = &output;
00074 Canceller.FilterData(shift);
00075
00076 cout <<endl;
00077 epsfile.open((noisefilename+".eps").c_str());
00078 outfile.open( (noisefilename+".clean").c_str());
00079 for (i = 0; i < output.size(); ++i)
00080 {
00081 outfile << output.at(i) << endl;
00082 epsfile << Canceller.Epsilon->at(i) << endl;
00083 }
00084 outfile.close();
00085 epsfile.close();
00086
00087
00088
00089
00090
00091 weightfile.open((noisefilename+".weights").c_str());
00092 for (i = 0; i < Canceller.WeightHistory.size(); ++i)
00093 {
00094 for (j = 0; j < filterlength * ntimeseries; ++j)
00095 {
00096 weightfile << j << " " << i << " " << Canceller.WeightHistory.at(i).at(j) << " " << endl;
00097 }
00098 }
00099 weightfile.close();
00100 }