4 #include <boost/math/constants/constants.hpp>
41 using namespace gplib;
43 string version =
"$Id: calcrec.cpp 1881 2014-02-25 16:20:58Z mmoorkamp $";
45 int main(
int argc,
char *argv[])
48 cout <<
" This is datarec: Calculate receiver functions from input data" << endl;
49 cout <<
" Reads in radial and vertical components in SAC format" << endl;
50 cout <<
" Outputs a file with the name of the radial component and .rec appended"
52 cout <<
" Some behaviour can be configured with the file calcrec.conf" << endl;
53 cout <<
" This is Version: " <<
version << endl << endl;
68 rfmethod = RecCalc::iterdecon;
70 string radfilename, verfilename;
72 radfilename = AskFilename(
"Radial Component: ");
73 verfilename = AskFilename(
"Vertical Component: ");
76 outfilename = radfilename +
".rec";
85 SimpleBp Bandpass(lowfilfreq, upfilfreq);
87 Radial.
GetData().begin(), Bandpass);
88 std::transform(Vertical.
GetData().begin(), Vertical.
GetData().end(),
89 Vertical.
GetData().begin(), Bandpass);
98 std::cerr <<
"Need to set ray parameter p " << std::endl;
103 RFVel.
CalcRFVel(p, Radial, Vertical, AppVel);
104 double beta_est = Config.
beta;
105 double alpha_est = beta_est * sqrt(3.0);
107 double qa = sqrt(std::pow(alpha_est, -2) - pow2(p));
108 double qb = sqrt(std::pow(beta_est, -2) - pow2(p));
109 double Vpz = (1.0 - 2.0 * pow2(beta_est) * pow2(p)) / (2.0 * alpha_est * qa);
110 double Vsr = (1.0 - 2.0 * pow2(beta_est) * pow2(p)) / (2.0 * beta_est * qb);
111 double Vpr = p * pow2(beta_est) / alpha_est;
112 double Vsz = -p * beta_est;
113 std::vector<double> VerNew(Vertical.
GetData().size()), RadNew(
115 for (
size_t i = 0; i < Vertical.
GetData().size(); ++i)
117 VerNew.at(i) = Vpr * Radial.
GetData().at(i)
118 + Vpz * Vertical.
GetData().at(i);
119 RadNew.at(i) = Vsr * Radial.
GetData().at(i)
120 + Vsz * Vertical.
GetData().at(i);
122 std::copy(RadNew.begin(), RadNew.end(), SComp.
GetData().begin());
123 std::copy(VerNew.begin(), VerNew.end(), PComp.GetData().begin());
125 PComp.WriteAsSac(
"p.comp");
146 cerr << e.what() << endl;
trfmethod
There are several ways to calculate receiver functions.
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...
This class is used to calculate receiver functions from seismic data.
std::vector< double > & GetData()
Access for data vector, for ease of use and efficiency we return a reference.
void GetData(std::string filename)
void SetNormalize(const bool what)
Change whether the output receiver function is normalized to a maximum amplitude of 1...
void CalcRecData(const SeismicDataComp &RadComp, const SeismicDataComp &VerComp, SeismicDataComp &Receiver)
Calculate Receiver functions from two data components.
This class implements the method to calculate absolute S-Wave velocities from Receiver function data ...
void CalcRFVel(const double slowness, const SeismicDataComp &RadComp, const SeismicDataComp &VerComp, ttsdata &AppVel)
Calculate absolute velocities from the radial and vertical components of the seismogram.
int main(int argc, char *argv[])
double GetDt() const
Return dt in s.
This class stores and writes model for the respktn 1D seismic code that we use for receiver function ...
int WriteAsSac(const std::string &filename) const
Write the data in sac binary format.
The basic exception class for all errors that arise in gplib.