SeismicModel.h

Go to the documentation of this file.
00001 #ifndef CSEISMICMODEL_H
00002 #define CSEISMICMODEL_H
00003 
00004 #include "types.h"
00005 
00006 namespace gplib
00007   {
00008     /** \addtogroup seistools Seismic data analysis and modeling */
00009     /* @{ */
00010 
00011     //! The class SeismicModel is the base class for some of the model format for seismic codes
00012     /*!
00013      * We store the basic seismic parameters here and implement some of the common functionailty.
00014      *
00015      */
00016     class SeismicModel
00017       {
00018     public:
00019       //! Do we want to calculate the arrival of a direct S-Wave or a P-wave
00020       enum tArrivalType
00021         {
00022         DirectS, DirectP
00023         };
00024     private:
00025       trealdata SVelErrors;
00026       trealdata ThickErrors;
00027       bool
00028       FuzzComp(const double elem1, const double elem2, const double tolerance);
00029       trealdata PVelocity;
00030       trealdata SVelocity;
00031       trealdata Density;
00032       trealdata Thickness;
00033       trealdata Qp;
00034       trealdata Qs;
00035       double SourceDepth;
00036       double dt;
00037       unsigned int npts;
00038     public:
00039       //! Get the number of points for synthetic seismogram calculation
00040       unsigned int GetNpts() const
00041         {
00042           return npts;
00043         }
00044       //! Set the number of points for synthetic seismogram calculation
00045       void SetNpts(const unsigned int s)
00046         {
00047           npts = s;
00048         }
00049       //! Get the depth to the seismic source that generates the wavefield
00050       double GetSourceDepth() const
00051         {
00052           return SourceDepth;
00053         }
00054       //! Set the depth to the seismic source
00055       void SetSourceDepth(const double s)
00056         {
00057           SourceDepth = s;
00058         }
00059       //! Get the time between two samples in s, this is for synthetic forward calculations
00060       double GetDt() const
00061         {
00062           return dt;
00063         }
00064       //! Set the time between two samples in s, this is for synthetic forward calculations
00065       void SetDt(const double s)
00066         {
00067           dt = s;
00068         }
00069       //! Read-only access to the vector of P-velocities in km/s in each layer
00070       const trealdata &GetPVelocity() const
00071         {
00072           return PVelocity;
00073         }
00074       //! Read-write access to the vector of P-velocities in km/s in each layer
00075       trealdata &SetPVelocity()
00076         {
00077           return PVelocity;
00078         }
00079       //! Read-only access to the vector of S-velocities in km/s in each layer
00080       const trealdata &GetSVelocity() const
00081         {
00082           return SVelocity;
00083         }
00084       //! Read-write access to the vector of S-velocities in km/s in each layer
00085       trealdata &SetSVelocity()
00086         {
00087           return SVelocity;
00088         }
00089       //! Read-only access to the vector of densities in g/cm^3 in each layer
00090       const trealdata &GetDensity() const
00091         {
00092           return Density;
00093         }
00094       //! Read-write access to the vector of densities in g/cm^3 in each layer
00095       trealdata &SetDensity()
00096         {
00097           return Density;
00098         }
00099       //! Read-only access to the vector of thicknesses in km in each layer
00100       const trealdata &GetThickness() const
00101         {
00102           return Thickness;
00103         }
00104       //! Read-write access to the vector of thicknesses in km in each layer
00105       trealdata &SetThickness()
00106         {
00107           return Thickness;
00108         }
00109       //! Read-only access to the vector of P quality factors for each layer
00110       const trealdata &GetQp() const
00111         {
00112           return Qp;
00113         }
00114       //! Read-write access to the vector of P quality factors for each layer
00115       trealdata &SetQp()
00116         {
00117           return Qp;
00118         }
00119       //! Read-only access to the vector of S quality factors for each layer
00120       const trealdata &GetQs() const
00121         {
00122           return Qs;
00123         }
00124       //! Read-write access to the vector of S quality factors for each layer
00125       trealdata &SetQs()
00126         {
00127           return Qs;
00128         }
00129       //! Set error bars on S-velocities for plotting
00130       void SetSVelErrors(const trealdata &sve)
00131         {
00132           SVelErrors = sve;
00133         }
00134       //! Set error bars on Thicknesses for plotting
00135       void SetThickErrors(const trealdata &te)
00136         {
00137           ThickErrors = te;
00138         }
00139       //! Returns the index of the layer that correponds to depth in km
00140       int FindLayer(const double depth);
00141       //! Given a slowness in s/km and a wave type calculate the distance that matches this slowness
00142       double MatchSlowness(const double slowness, const tArrivalType mode);
00143       double CalcArrival(const tArrivalType mode, const double recdist);
00144       double CalcTravelTime(const tArrivalType mode, const double sdepth,
00145           const double rdepth, const double p);
00146       //! Read the model in its native format from a file
00147       virtual void ReadModel(const std::string filename)=0;
00148       //! Write the model in its native format to a file
00149       virtual void WriteModel(const std::string filename)=0;
00150       //! Write out a script that performs a forward calculation for the current model
00151       virtual void WriteRunFile(const std::string &filename)=0;
00152       //! Write out an ascii file for plotting with xmgrace etc.
00153       void WritePlot(const std::string &filename);
00154       //! Write out an ascii file with error bars for plotting with xmgrace etc.
00155       void PlotVelWithErrors(const std::string &filename);
00156       //! Init provides a convenient way to allocate memory in all structures for a given number of layers
00157       void Init(const int nlayers);
00158       SeismicModel(const int nlayers = 0);
00159       SeismicModel(const SeismicModel& source);
00160       SeismicModel& operator=(const SeismicModel& source);
00161       virtual ~SeismicModel();
00162       };
00163   /* @} */
00164   }
00165 #endif // CSEISMICMODEL_H

Generated on Tue May 4 16:52:15 2010 for GPLIB++ by  doxygen 1.5.8