GPLIB++
PTensor1DMTObjective.cpp
Go to the documentation of this file.
1 #include "PTensor1DMTObjective.h"
2 #include "Member2Aniso.h"
3 #include <cassert>
4 #include <numeric>
5 using namespace std;
6 
7 namespace gplib
8  {
9  PTensor1DMTObjective::PTensor1DMTObjective(
10  const PTensorMTStation &LocalMTData) :
11  errorlevel(0.01), // we set a standard error level of 1%
12  MeasuredData(LocalMTData)
13  {
14  }
15 
17  {
18  }
19 
21  PlottableObjective(Old), errorlevel(Old.errorlevel), MeasuredData(
22  Old.MeasuredData), AnisoMTSynth(Old.AnisoMTSynth)
23  {
24  }
25 
27  const PTensor1DMTObjective& source)
28  {
29  if (this == &source)
30  return *this;
32  errorlevel = source.errorlevel;
33  MeasuredData = source.MeasuredData;
34  AnisoMTSynth = source.AnisoMTSynth;
35  return *this;
36  }
37 
39  {
40  if (AnisoMTSynth.GetFrequencies().empty()) //if we didn't set the frequencies before
41  {
42  AnisoMTSynth.SetFrequencies(MeasuredData.GetFrequencies());
43  }
44  Member2Aniso(member, AnisoMTSynth);
45  AnisoMTSynth.GetData();
46 
47  double returnvalue = 0; // init misfit value
48 
49  const unsigned int nelements = 4;
50  const unsigned int ndata = nelements * MeasuredData.GetTensor().size(); //we fit 4 real phase tensor elements
51  SetMisfit().resize(ndata); //make sure Misfit in base class can hold enough elements
52  SetSynthData().resize(ndata); // and same for data
53 
54  for (unsigned int i = 0; i < ndata; i += nelements) //we do the 4 elements in one block
55  {
56  returnvalue += CalcMisfit(
57  MeasuredData.at(i / nelements).GetPhi11(), AnisoMTSynth.at(i
58  / nelements).GetPhi11(),
59  MeasuredData.at(i / nelements).GetdPhi11(), errorlevel, i);
60  returnvalue += CalcMisfit(
61  MeasuredData.at(i / nelements).GetPhi12(), AnisoMTSynth.at(i
62  / nelements).GetPhi12(),
63  MeasuredData.at(i / nelements).GetdPhi12(), errorlevel, i + 1);
64  returnvalue += CalcMisfit(
65  MeasuredData.at(i / nelements).GetPhi21(), AnisoMTSynth.at(i
66  / nelements).GetPhi21(),
67  MeasuredData.at(i / nelements).GetdPhi21(), errorlevel, i + 2);
68  returnvalue += CalcMisfit(
69  MeasuredData.at(i / nelements).GetPhi22(), AnisoMTSynth.at(i
70  / nelements).GetPhi22(),
71  MeasuredData.at(i / nelements).GetdPhi22(), errorlevel, i + 3);
72  }
73  SetRMS(std::pow(returnvalue / ndata, 1.0 / GetFitExponent()));
74  }
75 
77  {
78  return GetRMS();
79  }
80  }
ublas::vector< double > ttranscribed
Definition: gentypes.h:21
double GetPhi11() const
All the following quantities are defined in Caldwell GJI 158, 457-469, the phase tensor elements...
Definition: MTTensor.h:422
double GetPhi22() const
Definition: PTensorMTData.h:49
const MTTensor & at(const unsigned int i) const
direct acces to a tensor at a given index
Definition: MTStation.h:114
This is a special objective function to fit phase tensor MT data.
std::vector< PTensorMTData > & GetTensor()
double GetPhi21() const
Definition: MTTensor.h:438
This only adds a few plotting functions to GeneralObjective to define a common interface.
virtual void SafeParallel(const ttranscribed &member)
Calc misfit for a model given by member.
double GetPhi12() const
Definition: MTTensor.h:430
virtual void GetData()
Calculate the synthetic data given the previously set parameters.
const PTensorMTData & at(const unsigned int i) const
const trealdata GetFrequencies() const
void Member2Aniso(const ttranscribed &member, C1DAnisoMTSynthData &Synth)
This function sets the properties for the 1D MT anisotropic forward calculation, from the variable me...
Definition: Member2Aniso.h:10
double GetPhi11() const
Definition: PTensorMTData.h:25
int GetFitExponent()
Get the Fit exponent.
double GetPhi22() const
Definition: MTTensor.h:446
double CalcMisfit(const double measured, const double predicted, const double measerror, const double errorlevel, const int index)
double GetdPhi22() const
Definition: PTensorMTData.h:81
double GetdPhi12() const
Definition: PTensorMTData.h:65
double GetRMS()
Get the current RMS.
tdata & SetSynthData()
Only derived classes can write access the Synthetic data.
tmisfit & SetMisfit()
Only derived classes can write access the Misfit.
double GetdPhi21() const
Definition: PTensorMTData.h:73
double GetPhi12() const
Definition: PTensorMTData.h:33
PTensor1DMTObjective & operator=(const PTensor1DMTObjective &source)
PlottableObjective & operator=(const PlottableObjective &source)
virtual double PostParallel(const ttranscribed &member)
Some operations cannot be done in parallel, these are done after, returns the misfit value...
PTensor1DMTObjective(const PTensorMTStation &LocalMTData)
trealdata GetFrequencies() const
return the available frequencies in a single vector
Definition: MTStation.cpp:136
double GetdPhi11() const
Definition: PTensorMTData.h:57
void SetRMS(const double x)
void SetFrequencies(const trealdata &freqs)
Set the frequencies of the tensor elements, invalidates the previously stored impedance data...
Definition: MTStation.cpp:144
double GetPhi21() const
Definition: PTensorMTData.h:41