GPLIB++
SeismicModel.h
Go to the documentation of this file.
1 #ifndef CSEISMICMODEL_H
2 #define CSEISMICMODEL_H
3 
4 #include "types.h"
5 #include <string>
6 
7 namespace gplib
8  {
9  /** \addtogroup seistools Seismic data analysis and modeling */
10  /* @{ */
11 
12  //! The class SeismicModel is the base class for some of the model format for seismic codes
13  /*!
14  * We store the basic seismic parameters here and implement some of the common functionailty.
15  *
16  */
18  {
19  public:
20  //! Do we want to calculate the arrival of a direct S-Wave or a P-wave
22  {
24  };
25  private:
26  trealdata SVelErrors;
27  trealdata ThickErrors;
28  bool
29  FuzzComp(const double elem1, const double elem2, const double tolerance);
30  trealdata PVelocity;
31  trealdata SVelocity;
32  trealdata Density;
33  trealdata Thickness;
34  trealdata Qp;
35  trealdata Qs;
36  double SourceDepth;
37  double dt;
38  unsigned int npts;
39  public:
40  //! Get the number of points for synthetic seismogram calculation
41  unsigned int GetNpts() const
42  {
43  return npts;
44  }
45  //! Set the number of points for synthetic seismogram calculation
46  void SetNpts(const unsigned int s)
47  {
48  npts = s;
49  }
50  //! Get the depth to the seismic source that generates the wavefield
51  double GetSourceDepth() const
52  {
53  return SourceDepth;
54  }
55  //! Set the depth to the seismic source
56  void SetSourceDepth(const double s)
57  {
58  SourceDepth = s;
59  }
60  //! Get the time between two samples in s, this is for synthetic forward calculations
61  double GetDt() const
62  {
63  return dt;
64  }
65  //! Set the time between two samples in s, this is for synthetic forward calculations
66  void SetDt(const double s)
67  {
68  dt = s;
69  }
70  //! Read-only access to the vector of P-velocities in km/s in each layer
71  const trealdata &GetPVelocity() const
72  {
73  return PVelocity;
74  }
75  //! Read-write access to the vector of P-velocities in km/s in each layer
76  trealdata &SetPVelocity()
77  {
78  return PVelocity;
79  }
80  //! Read-only access to the vector of S-velocities in km/s in each layer
81  const trealdata &GetSVelocity() const
82  {
83  return SVelocity;
84  }
85  //! Read-write access to the vector of S-velocities in km/s in each layer
86  trealdata &SetSVelocity()
87  {
88  return SVelocity;
89  }
90  //! Read-only access to the vector of densities in g/cm^3 in each layer
91  const trealdata &GetDensity() const
92  {
93  return Density;
94  }
95  //! Read-write access to the vector of densities in g/cm^3 in each layer
96  trealdata &SetDensity()
97  {
98  return Density;
99  }
100  //! Read-only access to the vector of thicknesses in km in each layer
101  const trealdata &GetThickness() const
102  {
103  return Thickness;
104  }
105  //! Read-write access to the vector of thicknesses in km in each layer
106  trealdata &SetThickness()
107  {
108  return Thickness;
109  }
110  //! Read-only access to the vector of P quality factors for each layer
111  const trealdata &GetQp() const
112  {
113  return Qp;
114  }
115  //! Read-write access to the vector of P quality factors for each layer
116  trealdata &SetQp()
117  {
118  return Qp;
119  }
120  //! Read-only access to the vector of S quality factors for each layer
121  const trealdata &GetQs() const
122  {
123  return Qs;
124  }
125  //! Read-write access to the vector of S quality factors for each layer
126  trealdata &SetQs()
127  {
128  return Qs;
129  }
130  //! Set error bars on S-velocities for plotting
131  void SetSVelErrors(const trealdata &sve)
132  {
133  SVelErrors = sve;
134  }
135  //! Set error bars on Thicknesses for plotting
136  void SetThickErrors(const trealdata &te)
137  {
138  ThickErrors = te;
139  }
140  //! Returns the index of the layer that correponds to depth in km
141  int FindLayer(const double depth);
142  //! Given a slowness in s/km and a wave type calculate the distance that matches this slowness
143  double MatchSlowness(const double slowness, const tArrivalType mode);
144  double CalcArrival(const tArrivalType mode, const double recdist);
145  double CalcTravelTime(const tArrivalType mode, const double sdepth,
146  const double rdepth, const double p);
147  //! Read the model in its native format from a file
148  virtual void ReadModel(const std::string filename)=0;
149  //! Write the model in its native format to a file
150  virtual void WriteModel(const std::string filename)=0;
151  //! Write out a script that performs a forward calculation for the current model
152  virtual void WriteRunFile(const std::string &filename)=0;
153  //! Write out an ascii file for plotting with xmgrace etc.
154  void WritePlot(const std::string &filename);
155  //! Write out an ascii file with error bars for plotting with xmgrace etc.
156  void PlotVelWithErrors(const std::string &filename);
157  //! Init provides a convenient way to allocate memory in all structures for a given number of layers
158  void Init(const int nlayers);
159  SeismicModel(const int nlayers = 0);
160  SeismicModel(const SeismicModel& source);
161  SeismicModel& operator=(const SeismicModel& source);
162  virtual ~SeismicModel();
163  };
164  /* @} */
165  }
166 #endif // CSEISMICMODEL_H
double CalcArrival(const tArrivalType mode, const double recdist)
void WritePlot(const std::string &filename)
Write out an ascii file for plotting with xmgrace etc.
int FindLayer(const double depth)
Returns the index of the layer that correponds to depth in km.
trealdata & SetDensity()
Read-write access to the vector of densities in g/cm^3 in each layer.
Definition: SeismicModel.h:96
double GetSourceDepth() const
Get the depth to the seismic source that generates the wavefield.
Definition: SeismicModel.h:51
const trealdata & GetDensity() const
Read-only access to the vector of densities in g/cm^3 in each layer.
Definition: SeismicModel.h:91
virtual void WriteRunFile(const std::string &filename)=0
Write out a script that performs a forward calculation for the current model.
trealdata & SetQs()
Read-write access to the vector of S quality factors for each layer.
Definition: SeismicModel.h:126
const trealdata & GetQp() const
Read-only access to the vector of P quality factors for each layer.
Definition: SeismicModel.h:111
trealdata & SetThickness()
Read-write access to the vector of thicknesses in km in each layer.
Definition: SeismicModel.h:106
trealdata & SetQp()
Read-write access to the vector of P quality factors for each layer.
Definition: SeismicModel.h:116
void SetSVelErrors(const trealdata &sve)
Set error bars on S-velocities for plotting.
Definition: SeismicModel.h:131
void SetNpts(const unsigned int s)
Set the number of points for synthetic seismogram calculation.
Definition: SeismicModel.h:46
tArrivalType
Do we want to calculate the arrival of a direct S-Wave or a P-wave.
Definition: SeismicModel.h:21
void SetThickErrors(const trealdata &te)
Set error bars on Thicknesses for plotting.
Definition: SeismicModel.h:136
trealdata & SetPVelocity()
Read-write access to the vector of P-velocities in km/s in each layer.
Definition: SeismicModel.h:76
The class SeismicModel is the base class for some of the model format for seismic codes...
Definition: SeismicModel.h:17
virtual void ReadModel(const std::string filename)=0
Read the model in its native format from a file.
void SetSourceDepth(const double s)
Set the depth to the seismic source.
Definition: SeismicModel.h:56
double GetDt() const
Get the time between two samples in s, this is for synthetic forward calculations.
Definition: SeismicModel.h:61
SeismicModel & operator=(const SeismicModel &source)
const trealdata & GetSVelocity() const
Read-only access to the vector of S-velocities in km/s in each layer.
Definition: SeismicModel.h:81
void Init(const int nlayers)
Init provides a convenient way to allocate memory in all structures for a given number of layers...
trealdata & SetSVelocity()
Read-write access to the vector of S-velocities in km/s in each layer.
Definition: SeismicModel.h:86
unsigned int GetNpts() const
Get the number of points for synthetic seismogram calculation.
Definition: SeismicModel.h:41
virtual void WriteModel(const std::string filename)=0
Write the model in its native format to a file.
SeismicModel(const int nlayers=0)
void PlotVelWithErrors(const std::string &filename)
Write out an ascii file with error bars for plotting with xmgrace etc.
double CalcTravelTime(const tArrivalType mode, const double sdepth, const double rdepth, const double p)
void SetDt(const double s)
Set the time between two samples in s, this is for synthetic forward calculations.
Definition: SeismicModel.h:66
double MatchSlowness(const double slowness, const tArrivalType mode)
Given a slowness in s/km and a wave type calculate the distance that matches this slowness...
const trealdata & GetPVelocity() const
Read-only access to the vector of P-velocities in km/s in each layer.
Definition: SeismicModel.h:71
const trealdata & GetThickness() const
Read-only access to the vector of thicknesses in km in each layer.
Definition: SeismicModel.h:101
const trealdata & GetQs() const
Read-only access to the vector of S quality factors for each layer.
Definition: SeismicModel.h:121