00001 #include "RecCalc.h"
00002 #include "CCalcRecConf.h"
00003 #include "SeismicDataComp.h"
00004 #include "CFatalException.h"
00005 #include <iostream>
00006 #include <string>
00007 #include <algorithm>
00008 #include "Util.h"
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 using namespace std;
00033
00034 string version = "$Id: calcrec.cpp 1663 2008-02-13 17:24:46Z mmoorkamp $";
00035
00036 int main(int argc, char *argv[]) {
00037 cout << " This is datarec: Calculate receiver functions from input data"
00038 << endl;
00039 cout << " Reads in radial and vertical components in SAC format" << endl;
00040 cout
00041 << " Outputs a file with the name of the radial component and .rec appended"
00042 <<endl;
00043 cout << " Some behaviour can be configured with the file calcrec.conf"
00044 << endl;
00045 cout << " This is Version: " << version << endl << endl;
00046 string modelfilename;
00047
00048 CCalcRecConf Config;
00049 SeismicDataComp Radial, Vertical;
00050 ResPkModel Model;
00051 string outfilename;
00052 try
00053 {
00054
00055 Config.GetData("calcrec.conf");
00056 RecCalc::trfmethod rfmethod = RecCalc::specdiv;
00057 if (Config.recmethod == "iterdecon")
00058 {
00059 rfmethod = RecCalc::iterdecon;
00060 }
00061 string radfilename, verfilename;
00062 if (argc == 3) {
00063 radfilename = argv[1];
00064 verfilename = argv[2];
00065 } else {
00066 radfilename = AskFilename("Radial Component: ");
00067 verfilename = AskFilename("Vertical Component: ");
00068 }
00069 outfilename = radfilename+".rec";
00070 Radial.GetData(radfilename);
00071 Vertical.GetData(verfilename);
00072
00073 RecCalc Receiver(Config.shift,Config.omega,Config.sigma,Config.cc,false,rfmethod);
00074 Receiver.SetNormalize(true);
00075 SeismicDataComp RecFunc;
00076 Receiver.CalcRecData(Radial,Vertical,RecFunc);
00077
00078 RecFunc.WriteAsSac(outfilename);
00079 }
00080 catch (CFatalException &e)
00081 {
00082 cerr << e.what() << endl;
00083 return -1;
00084 }
00085 }