Main Lemma Repository
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

EarthModel.h 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. /** YAML Serializing method
  27. */
  28. YAML::Node Serialize() const;
  29. //static LayeredEarth* DeSerialize(const YAML::Node& node);
  30. // ==================== OPERATORS =======================
  31. // ==================== OPERATIONS =======================
  32. // ==================== ACCESS =======================
  33. /** Sets the earth's magnetic field, in Tesla
  34. @param[in] bfield contains the x,y, and z components of
  35. the field. EarthModel::Inc, EarthModel::Dec, and
  36. EarthModel::BMag are computed:
  37. \f{eqnarray*}{ \mathrm{Inc} = &
  38. \cos^{-1}( \mathbf{B} \cdot \hat{\mathbf{z}} / B )
  39. \\ \mathrm{Dec} =& \cos^{-1}
  40. (\mathbf{B} \cdot \hat{\mathbf{x}} / B )
  41. \\ \mathrm{Mag} =& \Vert \mathbf{B} \Vert \f}
  42. @param[in] unit specifies the units of bfield.
  43. */
  44. void SetMagneticFieldComponents(const Vector3r &bfield,
  45. const MAGUNITS &unit);
  46. /// Sets the magnetic field using inclination, declination,
  47. /// and magnitude, units of Tesla
  48. /// @param[in] inc is the field's inclination
  49. /// @param[in] dec is the field's declination
  50. /// @param[in] Mag is the field's magnitude
  51. /// @param[in] unit specifies the the units used.
  52. /// The components are set according to
  53. /// \f{eqnarray*} { B_x =& B \cos(inc (\pi/180)) \cos(dec (\pi/180))
  54. /// \\ B_y =& B \cos(inc (\pi/180)) \sin(dec (\pi/180))
  55. /// \\ B_z =& B \sin(inc (\pi/180))
  56. /// \f}
  57. void SetMagneticFieldIncDecMag(const Real& inc, const Real&dec,
  58. const Real& Mag, const MAGUNITS &unit);
  59. // ==================== INQUIRY =======================
  60. /// Gets the magnetic field of the earth, in T
  61. Vector3r GetMagneticField( );
  62. /// Gets the magnetic field of the earth, in T
  63. Vector3r GetMagneticFieldInGauss( );
  64. /// Gets the magnetic field unit vector of the earth
  65. Vector3r GetMagneticFieldUnitVector( );
  66. /// Returns the magnitude of the magnetic field \f$ \Vert
  67. /// \mathbf{B}_0 \Vert \f$
  68. Real GetMagneticFieldMagnitude();
  69. /// Returns the magnitude of the magnetic field \f$ \Vert
  70. /// \mathbf{B}_0 \Vert \f$ in Gauss units
  71. Real GetMagneticFieldMagnitudeInGauss( );
  72. protected:
  73. // ==================== LIFECYCLE =======================
  74. /// Default protected constructor.
  75. EarthModel ( );
  76. /** Deserialize constructor */
  77. EarthModel (const YAML::Node& node);
  78. /// Default protected constructor.
  79. ~EarthModel ();
  80. // ==================== DATA MEMBERS =========================
  81. private:
  82. /** ASCII string representation of the class name */
  83. static constexpr auto CName = "EarthModel";
  84. /// Magnetic field, in units of nT
  85. Vector3r BField;
  86. /// Magnetic field unit vector \f$ \hat{\mathbf{B}_0} \f$
  87. Vector3r BFieldUnit;
  88. /// Inclination of the magnetic field
  89. Real BInc;
  90. /// Declination of the magnetic field
  91. Real BDec;
  92. /// Declination of the magnetic field
  93. Real BMag;
  94. }; // ----- end of class EarthModel -----
  95. //////////////////////////////////////////////////////////////
  96. // Error Classes
  97. /** If the Earth class is NULL valued, throw this
  98. */
  99. class NullEarth : public std::runtime_error {
  100. /** Thrown when an Earth pointer is NULL
  101. */
  102. public: NullEarth ();
  103. };
  104. } // ----- end of Lemma name -----
  105. #endif // ----- #ifndef EARTHMODEL_INC -----