8 #include <boost/bind.hpp>
13 #include "NetCDFTools.h"
15 #include "C1dInvGaConf.h"
23 Configuration.GetData(
"1dinvga.conf");
26 cout <<
"Data name base: ";
28 MTData.GetData(datanamebase +
".mtt");
34 cout <<
"Model name base: ";
36 C1DMTSynthData MTModel;
37 MTModel.readmodel(modelnamebase +
"_mt.mod");
39 gplib::rvec MTModelVector = MTModel.GetModelVector();
40 const size_t nmodelparms = MTModelVector.size();
41 gplib::rvec varfactor(nmodelparms);
42 double MTOldRMS = MTObjective.CalcPerformance(MTModelVector);
43 cout <<
"RMS: " << MTOldRMS << endl;
44 gplib::rvec OldData(MTObjective.GetSynthData());
45 for (
size_t i = 0; i < nmodelparms; ++i)
52 ofstream evals(
"mtevals.plot");
54 gplib::rvec svalratios = svals;
55 svalratios /= svals(0);
56 cout <<
"MT Singular Values : " << svals << endl;
61 gplib::rvec modelerrors(nmodelparms);
63 const double errorratio = 0.1;
64 gplib::rvec parameterthresholds = MTModelVector;
65 for (
size_t i = 0; i < nmodelparms / 2; ++i)
66 parameterthresholds(i) = pow(10, parameterthresholds(i));
67 parameterthresholds *= errorratio;
68 size_t eigenvindex = 0;
70 C1DMTObjective::datafuncvector_t ErrorFunctions =
71 MTObjective.GetErrorFunctions();
72 const size_t nerrorfuncs = ErrorFunctions.size();
73 const size_t ndata = MTData.GetMTData().size();
74 gplib::rmat DataCovar(nerrorfuncs * ndata, nerrorfuncs * ndata);
75 fill_n(DataCovar.data().begin(), DataCovar.size1() * DataCovar.size2(), 0.0);
77 for (
size_t e = 0; e < nerrorfuncs; ++e)
79 for (
int i = 0; i < ndata; ++i)
81 DataCovar(i + e * ndata, i + e * ndata) = gplib::pow2(
82 ErrorFunctions.at(e)(&MTData.GetMTData().at(i)));
85 ofstream mterrors(
"mterrors");
87 std::vector<double> reserr(nmodelparms / 2, 0.0), thickerr(nmodelparms / 2,
89 const unsigned int nevals = svalratios.size();
90 while (sum(modelerrors) < sum(parameterthresholds) && eigenvindex < nevals)
92 cout <<
"Accum Model Errors: " << sum(modelerrors) << endl;
93 cout <<
"Accum Threshold Errors: " << sum(parameterthresholds) << endl;
97 for (
size_t i = 0; i < MTModel.GetThicknesses().size(); ++i)
99 currerr = 2.3025 * MTModel.GetResistivities().at(i) * sqrt(
101 mterrors <<
"Res " << i <<
" : " << currerr << endl;
102 reserr.at(i) = currerr;
103 modelerrors(i) = currerr;
105 for (
size_t i = MTModel.GetThicknesses().size(); i < 2
106 * MTModel.GetThicknesses().size(); ++i)
108 currerr = sqrt(ModelCovar(i, i));
109 mterrors <<
"Th " << i - MTModel.GetThicknesses().size() <<
" : "
111 modelerrors(i) = currerr;
112 thickerr.at(i - MTModel.GetThicknesses().size()) = currerr;
116 cout <<
"Final Accum Model Errors: " << sum(modelerrors) << endl;
117 cout <<
"Accum Threshold Errors: " << sum(parameterthresholds) << endl;
118 WriteMatrixAsNetCDF(
"mtcovar.nc", ModelCovar);
124 WriteMatrixAsNetCDF(
"senscheck.nc", prod(
127 MTModel.SetResistivityErrors(reserr);
128 MTModel.SetThicknessErrors(thickerr);
129 MTModel.writeplot(
"mterr.plot");
gplib::rmat GetModelCorrelation(const gplib::rmat &DataCovar)
void SetupMTFitParameters(const tConfObject &Configuration, C1DMTObjective &Objective)
gplib::rmat GetModelNullspace()
void SetVariationFactor(const gplib::rvec varfac)
gplib::rvec GetSingularValues()
boost::shared_ptr< PlottableObjective > MTObjective
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