cascadelmscancel.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 "CLMSCanceller.h"
00007 #include "CTimeSeriesData.h"
00008 #include "CStackedSpectrum.h"
00009 #include "CLmsConfig.h"
00010
00011 using namespace std;
00012
00013 int main()
00014 {
00015 CLmsConfig Configuration;
00016 CLMSCanceller Stage1Canceller, Stage2Canceller;
00017 CTimeSeriesData TsData;
00018 StackedSpectrum WeightSpectrum;
00019
00020
00021 int i,j;
00022 string tsfilename, noisefilename;
00023 ifstream noisefile,tsfile;
00024 ofstream outfile, weightfile,epsfile;
00025 double temp;
00026 int ntimeseries,minlength = 1e15;
00027 vector<double> stage1noise, stage1epsilon, stage1output;
00028 vector<double> stage2noise, stage2epsilon, stage2output;
00029
00030 Configuration.GetData("lms.conf");
00031 cout << "Reference Filename: ";
00032 cin >> noisefilename;
00033 noisefile.open(noisefilename.c_str());
00034 while (noisefile.good())
00035 {
00036 noisefile >> temp;
00037 stage1noise.push_back(temp);
00038 }
00039 noisefile.close();
00040 cout << "Number of Time Series: ";
00041 cin >> ntimeseries;
00042 minlength = stage1noise.size();
00043 for (i=0; i < ntimeseries; ++i)
00044 {
00045 cout << "Time Series Filename: ";
00046 cin >> tsfilename;
00047 Stage1Canceller.Input.push_back(new ttsdata);
00048
00049 tsfile.open(tsfilename.c_str());
00050 while (tsfile.good())
00051 {
00052 tsfile >> temp;
00053 Stage1Canceller.Input.at(i)->push_back(temp);
00054 }
00055 tsfile.close();
00056 tsfile.clear();
00057 if (Stage1Canceller.Input.at(i)->size() < minlength)
00058 minlength = Stage1Canceller.Input.at(i)->size();
00059 }
00060 for (i=0; i < ntimeseries; ++i)
00061 Stage1Canceller.Input.at(i)->resize(minlength);
00062 cout << "Minlength: " << minlength << endl;
00063 Stage1Canceller.filterlength = Configuration.filterlength;
00064 Stage1Canceller.mu.assign(ntimeseries,Configuration.mu);
00065 Stage1Canceller.secfactor = Configuration.secfactor;
00066 Stage2Canceller.filterlength = Configuration.filterlength;
00067 Stage2Canceller.mu.assign(ntimeseries,Configuration.mu);
00068 Stage2Canceller.secfactor = Configuration.secfactor;
00069
00070 Stage1Canceller.FilterOutput = &stage1noise;
00071 Stage1Canceller.Epsilon = &stage1epsilon;
00072 Stage1Canceller.Desired = &stage1output;
00073 Stage2Canceller.FilterOutput = &stage1epsilon;
00074 Stage2Canceller.Desired = &stage2output;
00075 Stage2Canceller.Epsilon = &stage2epsilon;
00076 Stage2Canceller.Input = Stage1Canceller.Input;
00077
00078 Stage1Canceller.FilterData(Configuration.shift);
00079 Stage2Canceller.FilterData(Configuration.shift);
00080 cout << "Mu: " ;
00081 for (i=0 ; i < ntimeseries; ++i)
00082 cout << Stage1Canceller.mu.at(i) << " ";
00083 cout <<endl;
00084 epsfile.open((noisefilename+".eps").c_str());
00085 outfile.open( (noisefilename+".clean").c_str());
00086 for (i = 0; i < stage2output.size(); ++i)
00087 {
00088 outfile << stage2output.at(i) << endl;
00089 epsfile << Stage2Canceller.Epsilon->at(i) << endl;
00090 }
00091 outfile.close();
00092 epsfile.close();
00093
00094 }