Main Lemma Repository
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

EarthModel.h 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /* This file is part of Lemma, a geophysical modelling and inversion API */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. /**
  6. @file
  7. @author Trevor Irons
  8. @date 03/23/2010
  9. @version $Id: earthmodel.h 198 2014-12-27 06:14:05Z tirons $
  10. **/
  11. #ifndef EARTHMODEL_INC
  12. #define EARTHMODEL_INC
  13. #include "LemmaObject.h"
  14. namespace Lemma {
  15. // ===================================================================
  16. // Class: EarthModel
  17. /// \brief abstract class for Earth models
  18. /// \details
  19. // ===================================================================
  20. class EarthModel : public LemmaObject {
  21. // ==================== FRIENDS ===========================
  22. friend std::ostream &operator<<(std::ostream &stream,
  23. const EarthModel &ob);
  24. public:
  25. // ==================== LIFECYCLE =======================
  26. #ifdef HAVE_YAMLCPP
  27. /** YAML Serializing method
  28. */
  29. YAML::Node Serialize() const;
  30. //static LayeredEarth* DeSerialize(const YAML::Node& node);
  31. #endif
  32. // ==================== OPERATORS =======================
  33. // ==================== OPERATIONS =======================
  34. // ==================== ACCESS =======================
  35. /** Sets the earth's magnetic field, in Tesla
  36. @param[in] bfield contains the x,y, and z components of
  37. the field. EarthModel::Inc, EarthModel::Dec, and
  38. EarthModel::BMag are computed:
  39. \f{eqnarray*}{ \mathrm{Inc} = &
  40. \cos^{-1}( \mathbf{B} \cdot \hat{\mathbf{z}} / B )
  41. \\ \mathrm{Dec} =& \cos^{-1}
  42. (\mathbf{B} \cdot \hat{\mathbf{x}} / B )
  43. \\ \mathrm{Mag} =& \Vert \mathbf{B} \Vert \f}
  44. @param[in] unit specifies the units of bfield.
  45. */
  46. void SetMagneticFieldComponents(const Vector3r &bfield,
  47. const MAGUNITS &unit);
  48. /// Sets the magnetic field using inclination, declination,
  49. /// and magnitude, units of Tesla
  50. /// @param[in] inc is the field's inclination
  51. /// @param[in] dec is the field's declination
  52. /// @param[in] Mag is the field's magnitude
  53. /// @param[in] unit specifies the the units used.
  54. /// The components are set according to
  55. /// \f{eqnarray*} { B_x =& B \cos(inc (\pi/180)) \cos(dec (\pi/180))
  56. /// \\ B_y =& B \cos(inc (\pi/180)) \sin(dec (\pi/180))
  57. /// \\ B_z =& B \sin(inc (\pi/180))
  58. /// \f}
  59. void SetMagneticFieldIncDecMag(const Real& inc, const Real&dec,
  60. const Real& Mag, const MAGUNITS &unit);
  61. // ==================== INQUIRY =======================
  62. /// Gets the magnetic field of the earth, in T
  63. Vector3r GetMagneticField( );
  64. /// Gets the magnetic field of the earth, in T
  65. Vector3r GetMagneticFieldInGauss( );
  66. /// Gets the magnetic field unit vector of the earth
  67. Vector3r GetMagneticFieldUnitVector( );
  68. /// Returns the magnitude of the magnetic field \f$ \Vert
  69. /// \mathbf{B}_0 \Vert \f$
  70. Real GetMagneticFieldMagnitude();
  71. /// Returns the magnitude of the magnetic field \f$ \Vert
  72. /// \mathbf{B}_0 \Vert \f$ in Gauss units
  73. Real GetMagneticFieldMagnitudeInGauss( );
  74. protected:
  75. // ==================== LIFECYCLE =======================
  76. /// Default protected constructor.
  77. EarthModel (const std::string& name);
  78. #ifdef HAVE_YAMLCPP
  79. /** Deserialize constructor */
  80. EarthModel (const YAML::Node& node);
  81. #endif
  82. /// Default protected constructor.
  83. ~EarthModel ();
  84. // ==================== DATA MEMBERS =========================
  85. /// Magnetic field, in units of nT
  86. Vector3r BField;
  87. /// Magnetic field unit vector \f$ \hat{\mathbf{B}_0} \f$
  88. Vector3r BFieldUnit;
  89. /// Inclination of the magnetic field
  90. Real BInc;
  91. /// Declination of the magnetic field
  92. Real BDec;
  93. /// Declination of the magnetic field
  94. Real BMag;
  95. }; // ----- end of class EarthModel -----
  96. //////////////////////////////////////////////////////////////
  97. // Error Classes
  98. /** If the Earth class is NULL valued, throw this
  99. */
  100. class NullEarth : public std::runtime_error {
  101. /** Thrown when an Earth pointer is NULL
  102. */
  103. public: NullEarth ();
  104. };
  105. } // ----- end of Lemma name -----
  106. #endif // ----- #ifndef EARTHMODEL_INC -----