asclmscancel.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 Canceller;
00017         CTimeSeriesData TsData;
00018         StackedSpectrum WeightSpectrum;
00019         //CMTStation Output;
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> noise, epsilon, output,ts;
00028         
00029         Configuration.GetData("lms.conf");
00030         cout << "Reference Filename: ";
00031         cin >> noisefilename;
00032         noisefile.open(noisefilename.c_str());
00033         while (noisefile.good())
00034         {
00035                 noisefile >> temp; 
00036                 if (noisefile.good())
00037                  noise.push_back(temp);
00038         }
00039         noisefile.close();
00040         cout << "Number of Time Series: ";
00041         cin >> ntimeseries;
00042         minlength = noise.size();
00043         for (i=0; i < ntimeseries; ++i)
00044         {
00045                 cout << "Time Series Filename: ";
00046                 cin >> tsfilename;
00047                 Canceller.Input.push_back(new ttsdata);
00048         
00049                 tsfile.open(tsfilename.c_str());
00050                 while (tsfile.good())
00051                 {
00052                         tsfile >> temp; 
00053                         if (tsfile.good())
00054                                 Canceller.Input.at(i)->push_back(temp);
00055                 }
00056                 tsfile.close();
00057                 tsfile.clear();
00058                 if (Canceller.Input.at(i)->size() < minlength)
00059                         minlength = Canceller.Input.at(i)->size();
00060         }
00061         for (i=0; i < ntimeseries; ++i)
00062                 Canceller.Input.at(i)->resize(minlength);
00063         cout << "Minlength: " << minlength << endl; 
00064         Canceller.filterlength = Configuration.filterlength;
00065         Canceller.mu.assign(ntimeseries,Configuration.mu);
00066         Canceller.secfactor = Configuration.secfactor;
00067         //Canceller.input = &TsData.Data->Ex.data;
00068         Canceller.FilterOutput = &noise;
00069         Canceller.Epsilon = &epsilon;
00070         Canceller.Desired = &output;
00071         const int shift = Configuration.shift;
00072         Canceller.FilterData(shift);
00073         
00074         cout << "Mu: " ;
00075         for (i=0 ; i < ntimeseries; ++i) 
00076                 cout << Canceller.mu.at(i) << " ";
00077         cout <<endl;
00078         epsfile.open((noisefilename+".eps").c_str());
00079         outfile.open( (noisefilename+".clean").c_str());
00080         for (i = shift; i < output.size(); ++i)
00081         {
00082                 outfile << output.at(i) << endl;
00083                 epsfile << Canceller.Epsilon->at(i) << endl;
00084         }
00085         outfile.close();
00086         epsfile.close();
00087         
00088         /*WeightSpectrum.TimeSeries.assign(Canceller.Weights.size(),0);
00089         copy(Canceller.Weights.begin(),Canceller.Weights.end(),WeightSpectrum.TimeSeries.begin());
00090         WeightSpectrum.CalcSpectrum(filterlength);*/
00091         
00092         weightfile.open((noisefilename+".weights").c_str());
00093         for (i = 0; i < Canceller.WeightHistory.size(); ++i)
00094         {
00095                 for (j = 0; j < Configuration.filterlength*ntimeseries; ++j)
00096                 {
00097                         weightfile << j << " " << i << " " << Canceller.WeightHistory.at(i).at(j) << " " << endl;
00098                         //weightfile << Canceller.WeightHistory.at(i).at(j) << " ";
00099                 }
00100                 //weightfile << endl;
00101         }
00102         weightfile.close();
00103 }

Generated on Tue Aug 4 16:04:05 2009 for GPLIB++ by  doxygen 1.5.8