8 #include <boost/bind.hpp>
13 #include "NetCDFTools.h"
15 #include "C1dInvGaConf.h"
26 cout <<
"Data name base: ";
28 RecData.GetData(datanamebase +
".rec");
31 Configuration.GetData(
"1dinvga.conf");
33 C1DRecObjective
RecObjective(RecData, Configuration.shift,
34 Configuration.omega, Configuration.sigma, Configuration.cc,
35 Configuration.slowness);
38 cout <<
"Model name base: ";
41 RecModel.GetData(modelnamebase +
"_rec.mod");
43 const size_t nmodelparms = RecModel.SVelocity.size() * 2;
44 gplib::rvec RecModelVector(nmodelparms);
45 for (
int i = 0; i < nmodelparms / 2; ++i)
47 RecModelVector(i) = RecModel.Thickness.at(i);
48 RecModelVector(i + nmodelparms / 2) = RecModel.SVelocity.at(i);
51 gplib::rvec varfactor(nmodelparms);
52 RecObjective.SetPoisson(Configuration.poisson);
53 RecObjective.SetTimeWindow(Configuration.starttime, Configuration.endtime);
54 RecObjective.SetErrorLevel(Configuration.recerror);
55 RecObjective.SetFitExponent(Configuration.recfitexponent);
56 double RecOldRMS = RecObjective.CalcPerformance(RecModelVector);
57 cout <<
"RMS: " << RecOldRMS << endl;
58 gplib::rvec OldData(RecObjective.GetSynthData());
59 for (
size_t i = 0; i < nmodelparms; ++i)
65 RecAnalyser.
SetModel(RecModelVector);
67 ofstream evals(
"mtevals.plot");
69 gplib::rvec svalratios = svals;
70 svalratios /= svals(0);
71 cout <<
"MT Singular Values : " << svals << endl;
76 gplib::rvec modelerrors(nmodelparms);
77 fill_n(modelerrors.begin(), nmodelparms, 0.0);
78 const double errorratio = 0.1;
79 gplib::rvec parameterthresholds = RecModelVector;
80 for (
size_t i = 0; i < nmodelparms; ++i)
81 parameterthresholds(i) *= varfactor(i);
83 parameterthresholds *= errorratio;
84 size_t eigenvindex = 0;
86 const size_t ndata = RecData.GetData().size();
87 gplib::rmat DataCovar(ndata, ndata);
88 fill_n(DataCovar.data().begin(), DataCovar.size1() * DataCovar.size2(), 0.0);
90 for (
int i = 0; i < ndata; ++i)
92 DataCovar(i, i) = gplib::pow2(RecData.GetData().at(i)
93 * Configuration.recerror);
96 ofstream recerrors(
"recerrors");
99 while (sum(modelerrors) < sum(parameterthresholds))
101 cout <<
"Ratio: " << svalratios(eigenvindex) << endl;
103 cout <<
"Accum Model Errors: " << sum(modelerrors) << endl;
104 cout <<
"Accum Threshold Errors: " << sum(parameterthresholds) << endl;
108 for (
size_t i = 0; i < nmodelparms; ++i)
110 currerr = sqrt(ModelCovar(i, i));
111 recerrors << i <<
" : " << currerr << endl;
112 modelerrors(i) = currerr;
116 std::vector<double> thickerr, svelerr;
117 for (
int i = 0; i < nmodelparms / 2; ++i)
119 thickerr.push_back(modelerrors(i));
120 svelerr.push_back(modelerrors(i + nmodelparms / 2));
122 RecModel.SetThickErrors(thickerr);
123 RecModel.SetSVelErrors(svelerr);
124 cout <<
"Final Accum Model Errors: " << sum(modelerrors) << endl;
125 cout <<
"Accum Threshold Errors: " << sum(parameterthresholds) << endl;
126 WriteMatrixAsNetCDF(
"reccovar.nc", ModelCovar);
127 WriteMatrixAsNetCDF(
"reccorr.nc",
133 RecModel.PlotVelWithErrors(
"recerr.plot");
gplib::rmat GetModelCorrelation(const gplib::rmat &DataCovar)
gplib::rmat GetModelNullspace()
void SetVariationFactor(const gplib::rvec varfac)
gplib::rvec GetSingularValues()
C1DRecObjective RecObjective(RecData, Configuration.shift, Configuration.omega, Configuration.sigma, Configuration.wlevel, Configuration.slowness)
void SetModel(const gplib::rvec &TheModel)
gplib::rmat GetModelCovariance(const gplib::rmat &DataCovar)
The calculation of the Model Covariance is based on Menke, p. 122 formula 7.37.
const gplib::rmat & GetSensitivityMatrix()
void SetRelativeSVDThreshold(const double t)
gplib::rmat GetModelResolution()
The class ModelAnalysis is used to calculate resolution matrix, nullspace and other parameters for mo...
CLevanisoConf Configuration
const gplib::rmat & GetSensitivityInverse() const