calcrec.cpp

Go to the documentation of this file.
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 /*! \file 
00011  * This program calculates a receiver function from single radial and vertical components.
00012  * When started the program only asks for the name of the files for these two components. 
00013  * The output receiver function has the same name as the radial component with .rec appended.
00014  * All other aspects of the calculation are specified in the file calcrec.conf in the directory
00015  * in which the program is executed.
00016  * 
00017  * The parameters for that file are as follows:
00018  * 
00019  * <TABLE>
00020  * <TR> <TD> <B>Name </B></TD> <TD> <B>Description </B></TD></TR>
00021  * <TR> <TD> recmethod </TD>  <TD> Can be specdiv for spectral division method or iterdecon for iterative deconvolution. </TD></TR>
00022  * <TR> <TD> omega </TD>  <TD>The center of the gaussian used to filter the receiver function during estimation. </TD> </TR>
00023  * <TR> <TD> sigma </TD>  <TD>The width of the gaussian used to filter the receiver function during estimation. 
00024  *    Larger values mean a more broad band reciever function that contains more detailed structure but is also susceptible to noise.</TD> </TR>
00025  * <TR> <TD> shift </TD>  <TD>The shift in seconds of the initial correlation peak. This is purely used for display purposes. </TD> </TR>
00026  * <TR> <TD> cc </TD>  <TD>(only specdiv) The waterlevel relative to the maximum autopower of the vertical component. </TD> </TR>
00027  * </TABLE> 
00028  * More details about these parameters can be found for example in 
00029  * Langston, 1979, JGR 84(B9) 4749-4762
00030  * Liggoria, 1999, BSSA 89(5), 1395-1400
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; // write some info
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; // if something fails print error
00083                 return -1; // and stop execution
00084         }
00085 }

Generated on Fri Jul 4 15:30:20 2008 for GPLIB++ by  doxygen 1.5.5