GPLIB++
C1DMTObjective.h
Go to the documentation of this file.
1 #ifndef C1DMTOBJECTIVE_H
2 #define C1DMTOBJECTIVE_H
3 
4 #include "PlottableObjective.h"
5 #include "MTStation.h"
6 #include <boost/function.hpp>
7 #include <boost/shared_ptr.hpp>
8 namespace gplib
9  {
10  //! C1DMTObjective is the base class for MT misfit calculations from 1D models, it provides common functionality to calculate the misfit of various MT parameters
12  {
13  public:
14  // We have to declare some public typedefs that are needed below
15  //! A function that returns a real valued quantity calculated from an MT impedance tensor
16  typedef boost::function<double(const MTTensor* const )> datafunc_t;
17  //! A vector of MT data functions. This is used to store the types of data to fit
18  typedef std::vector<datafunc_t> datafuncvector_t;
19  private:
20  //! A vector of member functions to MTTensor that return the data to fit
21  datafuncvector_t DataFunctions;
22  //! A vector of member functions that return the errors associated with the functions in DataFunctions
23  datafuncvector_t ErrorFunctions;
24  //! A vector of doubles that cotains the errorlevels associated with the functions in DataFunctions
25  std::vector<double> ErrorLevels;
26  //! have the fit parameters been set or do we use default values
27  bool FitparametersSet;
28  //! A copy of the data to fit
29  MTStation MTData;
30  //! This abstract function has to calculate the Synthetic data and fill the MTSynth object with it
31  virtual void CalcSynthData(const ttranscribed &member) = 0;
32  protected:
33  virtual MTStation &GetMTSynth() = 0;
34  public:
35  //! function to set the parameters that determine the type of fit
36  void SetFitParameters(const datafuncvector_t TheDataV,
37  const datafuncvector_t TheErrorV,
38  const std::vector<double> TheErrLevel);
39  void AppendFitParameters(const datafunc_t TheDataFunc,
40  const datafunc_t TheErrorFunc, const double TheErrLevel);
41  //! Calc misfit for a model given by member
42  virtual void SafeParallel(const ttranscribed &member);
43  virtual double PostParallel(const ttranscribed &member);
44  //! return a vector with pointers to the functions used to calculate the errors
46  {
47  return ErrorFunctions;
48  }
49  //! write the current model to a file
50  virtual void WriteModel(const std::string &filename)=0;
51  //! write the current model for plotting to a file
52  virtual void WritePlot(const std::string &filename)=0;
53  //! Write current data to a file
54  virtual void WriteData(const std::string &filename)=0;
55  //! We need data to fit for any objective function, so we want it as constructor parameter, but no implicit conversion
56  C1DMTObjective(const MTStation &LocalMTData);
57  C1DMTObjective(const C1DMTObjective &Old);
58  virtual ~C1DMTObjective();
59  C1DMTObjective& operator=(const C1DMTObjective& source);
60  };
61  }
62 #endif
void AppendFitParameters(const datafunc_t TheDataFunc, const datafunc_t TheErrorFunc, const double TheErrLevel)
virtual void WriteModel(const std::string &filename)=0
write the current model to a file
boost::function< double(const MTTensor *const )> datafunc_t
A function that returns a real valued quantity calculated from an MT impedance tensor.
ublas::vector< double > ttranscribed
Definition: gentypes.h:21
This only adds a few plotting functions to GeneralObjective to define a common interface.
C1DMTObjective(const MTStation &LocalMTData)
We need data to fit for any objective function, so we want it as constructor parameter, but no implicit conversion.
The class MTStation is used to store the transfer functions and related information for a MT-site...
Definition: MTStation.h:17
virtual void WriteData(const std::string &filename)=0
Write current data to a file.
C1DMTObjective & operator=(const C1DMTObjective &source)
std::vector< datafunc_t > datafuncvector_t
A vector of MT data functions. This is used to store the types of data to fit.
virtual void WritePlot(const std::string &filename)=0
write the current model for plotting to a file
void SetFitParameters(const datafuncvector_t TheDataV, const datafuncvector_t TheErrorV, const std::vector< double > TheErrLevel)
function to set the parameters that determine the type of fit
virtual MTStation & GetMTSynth()=0
virtual double PostParallel(const ttranscribed &member)
All calculation has been done in SafeParallel we only return the stored result.
const datafuncvector_t & GetErrorFunctions() const
return a vector with pointers to the functions used to calculate the errors
virtual void SafeParallel(const ttranscribed &member)
Calc misfit for a model given by member.
C1DMTObjective is the base class for MT misfit calculations from 1D models, it provides common functi...