5 #include <gsl/gsl_errno.h>
6 #include <gsl/gsl_spline.h>
12 MoveoutCorrection::MoveoutCorrection(
const double refslow,
14 refslowness(refslow), Model(TheModel)
18 void MoveoutCorrection::InterpolateTo(trealdata &oldx, trealdata &y,
19 trealdata &newx, trealdata &newy)
21 gsl_interp_accel *gslacc = gsl_interp_accel_alloc();
22 gsl_spline *spline = gsl_spline_alloc(gsl_interp_linear, oldx.size());
23 cout <<
"Oldx: " << oldx.size() << endl;
24 cout <<
"Newx: " << newx.size() << endl;
25 gsl_spline_init(spline, &oldx[0], &y[0], newx.size());
27 for (
int i = 0; i < newx.size(); ++i)
29 newy.push_back(gsl_spline_eval(spline, newx.at(i), gslacc));
32 gsl_spline_free(spline);
33 gsl_interp_accel_free(gslacc);
57 double MoveoutCorrection::CalcTraveltime(
const double rayparameter,
62 double currdepth = 0.0;
63 const double p2 = rayparameter * rayparameter;
64 for (
int i = 0; i < sourceindex; ++i)
72 deltat += (depth - currdepth) * (sqrt(pow(1. / Model.
GetSVelocity().at(
73 sourceindex), 2) - p2) - sqrt(pow(1. / Model.
GetPVelocity().at(
74 sourceindex), 2) - p2));
79 const double slowness)
81 const double maxdepth = 350;
82 const int nelements = Rec.
GetData().size();
83 const double dt = Rec.
GetDt();
84 std::vector<double> refdeltat, deltat, depths, refdepths, actdepths,
85 times, newtimes, amps, newamps;
86 copy(Rec.
GetData().begin(), Rec.
GetData().end(), back_inserter(amps));
87 cout <<
"Ref slow: " << refslowness <<
" Slow: " << slowness << endl;
88 ofstream depthfile(
"depths");
89 ofstream deltatfile(
"deltat");
90 ofstream timesfile(
"times");
91 for (
double i = 1.0; i < maxdepth; i += 1.0)
94 times.push_back(i * dt + Rec.
GetB());
95 refdeltat.push_back(CalcTraveltime(refslowness, i));
96 deltat.push_back(CalcTraveltime(slowness, i));
97 deltatfile << deltat.at(i) <<
" " << depths.at(i) << endl;
98 cout <<
"Deltat: " << deltat.back() <<
" Ref Deltat: "
99 << refdeltat.back() << endl;
101 InterpolateTo(deltat, depths, times, actdepths);
102 InterpolateTo(depths, refdeltat, actdepths, newtimes);
103 InterpolateTo(newtimes, amps, times, newamps);
111 copy(newamps.begin(), newamps.end(), Rec.
GetData().begin());
std::vector< double > & GetData()
Access for data vector, for ease of use and efficiency we return a reference.
int FindLayer(const double depth)
Returns the index of the layer that correponds to depth in km.
void DoCorrection(SeismicDataComp &Rec, const double slowness)
const trealdata & GetSVelocity() const
Read-only access to the vector of S-velocities in km/s in each layer.
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 ...
const trealdata & GetPVelocity() const
Read-only access to the vector of P-velocities in km/s in each layer.
const trealdata & GetThickness() const
Read-only access to the vector of thicknesses in km in each layer.