GPLIB++
rfvel.cpp
Go to the documentation of this file.
1 #include "RFVelCalc.h"
2 #include "CalcRecConf.h"
3 #include "SeismicDataComp.h"
4 #include "FatalException.h"
5 #include <iostream>
6 #include <fstream>
7 #include <string>
8 #include "Util.h"
9 
10 using namespace std;
11 using namespace gplib;
12 
13 string version = "$Id: rfvel.cpp 1839 2010-03-05 17:04:34Z mmoorkamp $";
14 
15 int main()
16  {
17  cout
18  << " This is rfvel: Calculate absolute velocties from receiver functions"
19  << endl; // write some info
20  cout << " Reads in radial and vertical components in SAC format" << endl;
21  cout
22  << " Writes a file with ending .vel containing apparent velocities and corresponding periods"
23  << endl;
24  cout
25  << " The settings for the calculation method, omega, sigma and shift are taken from calcrec.conf"
26  << endl;
27  cout << " This is Version: " << version << endl << endl;
28  string modelfilename;
29 
30  CalcRecConf Config;
31  SeismicDataComp Radial, Vertical;
32  string outfilename;
33  double slowness;
34  try
35  {
36  string radfilename, verfilename;
37  //read the configuration file
38  Config.GetData("calcrec.conf");
39  //the default calculation method is spectral division
40  RecCalc::trfmethod rfmethod = RecCalc::specdiv;
41  if (Config.recmethod == "iterdecon")
42  {
43  rfmethod = RecCalc::iterdecon;
44  }
45  //get the names for the radial and vertical component seismograms
46  radfilename = AskFilename("Radial Component: ");
47  verfilename = AskFilename("Vertical Component: ");
48  outfilename = radfilename + ".vel";
49  //we have to ask for the slowness of the incoming P-wave
50  cout << "Slowness in s/km: ";
51  cin >> slowness;
52  //read in the seismograms
53  Radial.ReadData(radfilename);
54  Vertical.ReadData(verfilename);
55  ofstream outfile(outfilename.c_str());
56  RFVelCalc RFVel(Config.sigma, Config.cc, rfmethod);
57 
58  ttsdata AppVel;
59  //do the calculation and write to a file
60  RFVel.CalcRFVel(slowness, Radial, Vertical, AppVel);
61  RFVel.WriteVelocities(outfilename);
62  } catch (FatalException &e)
63  {
64  cerr << e.what() << endl; // if something fails print error
65  return -1; // and stop execution
66  }
67  }
trfmethod
There are several ways to calculate receiver functions.
Definition: RecCalc.h:18
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::string recmethod
Definition: CalcRecConf.h:37
void GetData(std::string filename)
Definition: CalcRecConf.cpp:32
This class implements the method to calculate absolute S-Wave velocities from Receiver function data ...
Definition: RFVelCalc.h:13
int main()
Definition: rfvel.cpp:15
string version
Definition: rfvel.cpp:13
The basic exception class for all errors that arise in gplib.