3 #include "CUniformRNG.h"
10 using namespace gplib;
15 std::string radname, tangname, vername;
17 std::cout <<
"Radial Component: ";
19 std::cout <<
"Tangential Component: ";
21 std::cout <<
"Vertical Component: ";
28 const size_t nobs = Radial.
GetData().size();
29 const size_t nchan = 3;
30 gplib::rmat input(nchan, nobs);
31 gplib::cmat evec(nchan, nchan);
32 gplib::cvec eval(nchan);
34 for (
int i = 0; i < nobs; ++i)
36 input(0, i) = Radial.
GetData().at(i);
37 input(1, i) = Tangential.
GetData().at(i);
38 input(2, i) = Vertical.
GetData().at(i);
41 PCA(input, evec, eval);
43 gplib::cmat wmat(
WhiteMat(evec, eval));
44 std::cout <<
"pca evec: " << evec << std::endl;
45 std::cout <<
"pca eval: " << eval << std::endl;
46 std::cout <<
"pca WhM: " << wmat << std::endl;
47 std::cout <<
"pca DeWhM: " <<
DeWhiteMat(evec, eval) << std::endl;
49 gplib::cmat output(nchan, nobs);
50 axpy_prod(wmat, input, output);
52 for (
int i = 0; i < nobs; ++i)
54 RadOut.GetData().at(i) = output(0, i).real();
55 TangOut.GetData().at(i) = output(1, i).real();
56 VerOut.
GetData().at(i) = output(2, i).real();
58 RadOut.WriteAsSac(
"pc1.out");
59 TangOut.WriteAsSac(
"pc2.out");
gplib::cmat WhiteMat(gplib::cmat &evectors, gplib::cvec &evalues)
Calculate the Whitening Matrix.
int ReadData(const std::string &filename, tseismicdataformat format=sac)
Read in data from a file, as we cannot determine the type from the ending we have to provide it...
std::vector< double > & GetData()
Access for data vector, for ease of use and efficiency we return a reference.
void PCA(const UblasMatrix &observations, gplib::cmat &evectors, gplib::cvec &evalues)
This template function calculates the principal component rotation matrix from a matrix of observatio...
gplib::cmat DeWhiteMat(gplib::cmat &evectors, gplib::cvec &evalues)
Calculate the Dewhitening Matrix.
int WriteAsSac(const std::string &filename) const
Write the data in sac binary format.