calcrec.cpp
Go to the documentation of this file.00001 #include <iostream>
00002 #include <string>
00003 #include <algorithm>
00004 #include "Util.h"
00005 #include "RecCalc.h"
00006 #include "CalcRecConf.h"
00007 #include "SeismicDataComp.h"
00008 #include "FatalException.h"
00009 #include "FilterFunc.h"
00010 #include "statutils.h"
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 using namespace std;
00037 using namespace gplib;
00038
00039 string version = "$Id: calcrec.cpp 1839 2010-03-05 17:04:34Z mmoorkamp $";
00040
00041 int main(int argc, char *argv[])
00042 {
00043
00044 cout << " This is datarec: Calculate receiver functions from input data"
00045 << endl;
00046 cout << " Reads in radial and vertical components in SAC format" << endl;
00047 cout
00048 << " Outputs a file with the name of the radial component and .rec appended"
00049 << endl;
00050 cout << " Some behaviour can be configured with the file calcrec.conf"
00051 << endl;
00052 cout << " This is Version: " << version << endl << endl;
00053 string modelfilename;
00054
00055 CalcRecConf Config;
00056 SeismicDataComp Radial, Vertical;
00057 ResPkModel Model;
00058 string outfilename;
00059 try
00060 {
00061
00062 Config.GetData("calcrec.conf");
00063
00064 RecCalc::trfmethod rfmethod = RecCalc::specdiv;
00065 if (Config.recmethod == "iterdecon")
00066 {
00067 rfmethod = RecCalc::iterdecon;
00068 }
00069 string radfilename, verfilename;
00070
00071
00072 if (argc == 3)
00073 {
00074 radfilename = argv[1];
00075 verfilename = argv[2];
00076 }
00077 else
00078 {
00079 radfilename = AskFilename("Radial Component: ");
00080 verfilename = AskFilename("Vertical Component: ");
00081 }
00082
00083 outfilename = radfilename + ".rec";
00084
00085 Radial.ReadData(radfilename);
00086 Vertical.ReadData(verfilename);
00087 if (Config.upperfreq > 0.0 && Config.lowerfreq > 0.0
00088 && Config.upperfreq > Config.lowerfreq)
00089 {
00090 const double lowfilfreq = Config.lowerfreq * Radial.GetDt();
00091 const double upfilfreq = Config.upperfreq * Radial.GetDt();
00092 SimpleBp Bandpass(lowfilfreq,upfilfreq);
00093 std::transform(Radial.GetData().begin(),Radial.GetData().end(),Radial.GetData().begin(),Bandpass);
00094 std::transform(Vertical.GetData().begin(),Vertical.GetData().end(),Vertical.GetData().begin(),Bandpass);
00095 }
00096
00097 RecCalc
00098 Receiver(Config.shift, Config.sigma, Config.cc, false, rfmethod);
00099
00100 Receiver.SetNormalize(Config.normalize);
00101 SeismicDataComp RecFunc;
00102
00103 Receiver.CalcRecData(Radial, Vertical, RecFunc);
00104
00105 RecFunc.WriteAsSac(outfilename);
00106 } catch (FatalException &e)
00107 {
00108 cerr << e.what() << endl;
00109 return -1;
00110 }
00111 }