modelcorr.cpp

Go to the documentation of this file.
00001 #include <iostream>
00002 #include "C1DMTSynthData.h"
00003 #include "ResPkModel.h"
00004 #include <string>
00005 #include <numeric>
00006 
00007 using namespace std;
00008 using namespace gplib;
00009 
00010 string version = "$Id: modelcorr.cpp 1816 2009-09-07 11:28:35Z mmoorkamp $";
00011 
00012 int main()
00013   {
00014     ResPkModel SeismicModel;
00015     C1DMTSynthData MTModel;
00016     string inputbase;
00017 
00018     cout
00019         << " This is modelcorr: Calculate 'correlation' of seismic and MT model"
00020         << endl; // write some info
00021     cout
00022         << " Input files are assumed to be have the name inputbase+_rec.mod and inputbase+_mt.mod"
00023         << endl;
00024     cout << " for seismic and MT models, respectively. " << endl;
00025     cout << " This is Version: " << version << endl << endl;
00026 
00027     cout << "Inputbase: ";
00028     cin >> inputbase;
00029     SeismicModel.ReadModel(inputbase + "_rec.mod");
00030     MTModel.ReadModel(inputbase + "_mt.mod");
00031 
00032     trealdata mtthickness(MTModel.GetThicknesses());
00033     trealdata seismicthickness(SeismicModel.GetThickness());
00034     trealdata mtdepth(mtthickness.size()),
00035         seismicdepth(seismicthickness.size());
00036     trealdata resistivity(MTModel.GetResistivities());
00037     trealdata svelocity(SeismicModel.GetSVelocity());
00038     partial_sum(mtthickness.begin(), mtthickness.end(), mtdepth.begin());
00039     partial_sum(seismicthickness.begin(), seismicthickness.end(),
00040         seismicdepth.begin());
00041     mtthickness.back() += 10000.0;
00042     seismicthickness.back() += 10000.0;
00043     bool finished = false;
00044     size_t mtindex = 0;
00045     size_t seismicindex = 0;
00046     const double depththreshold = 0.05;
00047     double mtdifferencemeasure = 0.0;
00048     double seismicdifferencemeasure = 0.0;
00049     int mtinterfaces = 0;
00050     int seismicinterfaces = 0;
00051     int corrinterfaces = 0;
00052     while (!finished)
00053       {
00054         double reldepthdiff = (mtdepth.at(mtindex) - seismicdepth.at(
00055             seismicindex)) / min(mtdepth.at(mtindex), seismicdepth.at(
00056             seismicindex));
00057         if (reldepthdiff > depththreshold && seismicindex < svelocity.size()
00058             - 1) //mt layer deeper
00059           {
00060             seismicdifferencemeasure += abs(svelocity.at(seismicindex)
00061                 - svelocity.at(seismicindex + 1));
00062             ++seismicindex;
00063             ++seismicinterfaces;
00064           }
00065         else if (reldepthdiff < -depththreshold && mtindex < resistivity.size()
00066             - 1) //seismic layer deeper
00067           {
00068             mtdifferencemeasure += abs(resistivity.at(mtindex)
00069                 - resistivity.at(mtindex + 1));
00070             ++mtindex;
00071             ++mtinterfaces;
00072           }
00073         else //both about the same
00074           {
00075             ++mtindex;
00076             ++seismicindex;
00077             ++corrinterfaces;
00078           }
00079         if (mtindex >= resistivity.size() || seismicindex >= svelocity.size())
00080           {
00081             finished = true;
00082           }
00083       }
00084     cout << "Seismic depths: ";
00085     copy(seismicdepth.begin(), seismicdepth.end(), ostream_iterator<double> (
00086         cout, " "));
00087     cout << endl;
00088     cout << "MT depths: ";
00089     copy(mtdepth.begin(), mtdepth.end(), ostream_iterator<double> (cout, " "));
00090     cout << endl;
00091     cout << "MT difference: " << mtdifferencemeasure << " Seismic difference: "
00092         << seismicdifferencemeasure << endl;
00093     cout << "MT only interfaces: " << mtinterfaces
00094         << " Seismic only interfaces: " << seismicinterfaces
00095         << " Common interfaces: " << corrinterfaces << endl;
00096   }

Generated on Tue May 4 16:52:14 2010 for GPLIB++ by  doxygen 1.5.8