11 using namespace gplib;
13 string version =
"$Id: corrselect.cpp 1816 2009-09-07 11:28:35Z mmoorkamp $";
17 const unsigned int nrf = List.size();
18 gplib::rmat CorrMatrix(nrf, nrf);
20 for (
unsigned int i = 0; i < nrf; ++i)
22 for (
unsigned int j = i; j < nrf; ++j)
24 CorrMatrix(i, j) = Cross(List.at(i)->GetData(),
25 List.at(j)->GetData(), 0, min(List.at(i)->GetData().size(),
26 List.at(j)->GetData().size()));
27 CorrMatrix(j, i) = CorrMatrix(i, j);
36 <<
" This is corrselect: Select receiver functions based on their correlation"
38 cout <<
" Reads in receiver function in SAC format" << endl;
39 cout <<
" This is Version: " <<
version << endl << endl;
43 string reclistname = AskFilename(
"File with list of filenames: ");
48 unsigned int nrf = RF.
GetList().size();
49 cout <<
"Read " << nrf <<
" receiver functions." << endl;
55 for (
unsigned int j = 0; j < nrf; ++j)
56 cout << j <<
" " << CorrMatrix(0, j) << endl;
57 ublas::scalar_vector<double> mul(nrf, 1. / nrf);
58 gplib::rvec AvgCorr = prod(CorrMatrix, mul);
60 cout <<
"Average Correlation: ";
61 copy(AvgCorr.begin(), AvgCorr.end(), ostream_iterator<double> (cout,
64 cout <<
"Threshold: ";
65 double threshold = 0.0;
67 SeismicStationList::tseiscompvector::iterator it = RF.
GetList().begin();
68 for (
unsigned int j = 0; j < nrf; ++j, ++it)
70 if (AvgCorr(j) < threshold)
73 cout <<
"Continue (y/n)";
77 for (
unsigned int j = 0; j < nrf; ++j)
79 cout << RF.
GetList().at(j)->GetName() << endl;
tseiscompvector & GetList()
Return the content of the list for manipulation.
std::vector< boost::shared_ptr< SeismicDataComp > > tseiscompvector
gplib::rmat CalcCorrMatrix(const SeismicStationList::tseiscompvector &List)
Manages a collection of seismic traces, mainly provides functionality to read in data specified in a ...
void ReadList(const std::string filename)
read in a file with names and optionally coordinates