GPLIB++
AbsVelRecObjective.cpp
Go to the documentation of this file.
1 #include "AbsVelRecObjective.h"
2 
3 namespace gplib
4  {
6  {
7  }
8 
9  //constructor including absolute velocities
11  const SeismicDataComp> TheRecData, SurfaceWaveData &AbsVel,
12  const int myshift, const double mysigma, const double myc,
13  const double myslowness, const RecCalc::trfmethod method,
14  const bool normalized) :
15  C1DRecObjective(TheRecData, myshift, mysigma, myc, myslowness, method,
16  normalized), CalcAbsVel(mysigma, myc, method), MeasuredAbsVel(AbsVel)
17  {
18  recweight = 1;
19  absvelweight = 1;
20  }
21 
23  C1DRecObjective(Old), CalcAbsVel(Old.CalcAbsVel), MeasuredAbsVel(
24  Old.MeasuredAbsVel), SynthAbsVel(Old.SynthAbsVel)
25  {
26  recweight = Old.recweight;
27  absvelweight = Old.absvelweight;
28  }
29 
31  const AbsVelRecObjective& source)
32  {
33  if (this == &source)
34  return *this;
36  CalcAbsVel = source.CalcAbsVel;
37  MeasuredAbsVel = source.MeasuredAbsVel;
38  SynthAbsVel = source.SynthAbsVel;
39  recweight = source.recweight;
40  absvelweight = source.absvelweight;
41  return *this;
42  }
43 
45  {
46  //call inherited version to calculate receiver function misfit
48  // calculate raw misfit from RMS
49  double returnvalue = std::pow(GetRMS(), GetFitExponent())
50  * GetMisfit().size();
51  // and multiply by weight
52  returnvalue *= recweight;
53  //if we include absolute velocity information and have data
54  if (absvelweight > 0.0 && !MeasuredAbsVel.GetPhaseVelocities().empty())
55  {
56  //calculate synthetic absolute velocity data
57  SynthAbsVel.SetPeriods() = MeasuredAbsVel.GetPeriods();
58  SeismicDataComp Rad(RecCalculator.GetRadComp()), Ver(
59  RecCalculator.GetVerComp());
60  CalcAbsVel.CalcRFVel(slowness, Rad, Ver,
61  SynthAbsVel.SetPhaseVelocities());
62 
63  assert(SynthAbsVel.GetPhaseVelocities().size() == MeasuredAbsVel.GetPhaseVelocities().size());
64  const unsigned int nvel = SynthAbsVel.GetPhaseVelocities().size();
65  const unsigned int nrec = GetMisfit().size(); // the number of previous receiver function points
66 
67  //we have to copy the old misfit values from the base class
68  //so we create local copties
69  tmisfit LocalMisfit(nrec + nvel); // we need vectors of the right size for misfit, this is for levmarq
70  tdata LocalData(nrec + nvel); // and data, levmarq needs to know the size before, so we do not consider weights for the size
71  copy(GetMisfit().begin(), GetMisfit().end(), LocalMisfit.begin());
72  copy(GetSynthData().begin(), GetSynthData().end(),
73  LocalData.begin());
74  //after reserving the right amount of memory, we can copy back
75  SetMisfit(LocalMisfit);
76  SetSynthData(LocalData);
77 
78  for (unsigned int i = 0; i < nvel; ++i)
79  {
80  //we add up the misfit for each velocity estimate
81  //we have not stored any measurement error, so we only
82  //use the relative error floor, we store the misfit and data after the normal receiver function
83  returnvalue += CalcMisfit(
84  MeasuredAbsVel.GetPhaseVelocities().at(i),
85  SynthAbsVel.GetPhaseVelocities().at(i), 0.0, errorlevel, i
86  + nrec);
87  }
88 
89  unsigned int ndata = 0;
90  double divisor = 1.0;
91  if (recweight > 0) // we have to divide by the right amount of datapoints
92  {
93  ndata = nrec + nvel;
94  divisor = nrec * recweight + nvel * absvelweight;
95  }
96  else
97  {
98  ndata = nvel;
99  divisor = ndata * absvelweight;
100  }
101  SetRMS(std::pow(returnvalue / divisor, 1.0 / GetFitExponent())); //store new misfit in local class
102  }
103  return GetRMS();
104  }
105  }
const trealdata & GetPeriods() const
Read-only access to the vector of periods for the phase velocities.
trfmethod
There are several ways to calculate receiver functions.
Definition: RecCalc.h:18
ublas::vector< double > ttranscribed
Definition: gentypes.h:21
virtual double PostParallel(const ttranscribed &member)
We also clean up files serially.
AbsVelRecObjective & operator=(const AbsVelRecObjective &source)
AbsVelRecObjective(const AbsVelRecObjective &Old)
const trealdata & GetPhaseVelocities() const
Read-only access to the vector of phase velocities.
A class to read, write and store fundamental mode surface wave dispersion data.
int GetFitExponent()
Get the Fit exponent.
const tdata & GetSynthData()
Return the current synthetic data.
double CalcMisfit(const double measured, const double predicted, const double measerror, const double errorlevel, const int index)
virtual double PostParallel(const ttranscribed &member)
We also clean up files serially.
void CalcRFVel(const double slowness, const SeismicDataComp &RadComp, const SeismicDataComp &VerComp, ttsdata &AppVel)
Calculate absolute velocities from the radial and vertical components of the seismogram.
Definition: RFVelCalc.cpp:97
trealdata & SetPeriods()
Read-write access to periods, the format might be changed in the future.
double GetRMS()
Get the current RMS.
ublas::vector< double > tmisfit
Definition: gentypes.h:18
const tmisfit & GetMisfit()
Return the misfit vector.
tdata & SetSynthData()
Only derived classes can write access the Synthetic data.
tmisfit & SetMisfit()
Only derived classes can write access the Misfit.
This objective function calculates the weighted misfit for a receiver function and the corresponding ...
ublas::vector< double > tdata
Definition: gentypes.h:19
Calculate the misfit between observed receiver function for a given 1D model by calculating a synthet...
C1DRecObjective & operator=(const C1DRecObjective &source)
void SetRMS(const double x)
trealdata & SetPhaseVelocities()
Read-write access to phase velocities, the format might be changed in the future. ...