Model of the earth's magnetic field.
More...
#include <MagneticModel.hpp>
|
void | Field (real t, real lat, real lon, real h, bool diffp, real &Bx, real &By, real &Bz, real &Bxt, real &Byt, real &Bzt) const |
|
| MagneticModel (const MagneticModel &) |
|
MagneticModel & | operator= (const MagneticModel &) |
|
void | ReadMetadata (const std::string &name) |
|
|
void | operator() (real t, real lat, real lon, real h, real &Bx, real &By, real &Bz) const |
|
void | operator() (real t, real lat, real lon, real h, real &Bx, real &By, real &Bz, real &Bxt, real &Byt, real &Bzt) const |
|
MagneticCircle | Circle (real t, real lat, real h) const |
|
static void | FieldComponents (real Bx, real By, real Bz, real &H, real &F, real &D, real &I) |
|
static void | FieldComponents (real Bx, real By, real Bz, real Bxt, real Byt, real Bzt, real &H, real &F, real &D, real &I, real &Ht, real &Ft, real &Dt, real &It) |
|
Model of the earth's magnetic field.
Evaluate the earth's magnetic field according to a model. At present only internal magnetic fields are handled. These are due to the earth's code and crust; these vary slowly (over many years). Excluded are the effects of currents in the ionosphere and magnetosphere which have daily and annual variations.
See magnetic for details of how to install the magnetic models and the data format.
See
- General information:
- WMM2010:
- WMM2015:
- IGRF11:
- EMM2010:
- EMM2015:
- EMM2017:
Example of use:
#include <iostream>
#include <exception>
try {
double lat = 27.99, lon = 86.93,
h = 8820,
t = 2012;
double Bx, By, Bz;
mag(
t, lat,lon,
h, Bx, By, Bz);
cout << H << " " << F << " " << D << " " << I << "\n";
}
catch (const exception& e) {
cerr << "Caught exception: " << e.what() << "\n";
return 1;
}
}
MagneticField is a command-line utility providing access to the functionality of MagneticModel and MagneticCircle.
Definition at line 69 of file MagneticModel.hpp.
◆ real
◆ MagneticModel() [1/2]
GeographicLib::MagneticModel::MagneticModel |
( |
const MagneticModel & |
| ) |
|
|
private |
◆ MagneticModel() [2/2]
GeographicLib::MagneticModel::MagneticModel |
( |
const std::string & |
name, |
|
|
const std::string & |
path = "" , |
|
|
const Geocentric & |
earth = Geocentric::WGS84() |
|
) |
| |
|
explicit |
Construct a magnetic model.
- Parameters
-
[in] | name | the name of the model. |
[in] | path | (optional) directory for data file. |
[in] | earth | (optional) Geocentric object for converting coordinates; default Geocentric::WGS84(). |
- Exceptions
-
GeographicErr | if the data file cannot be found, is unreadable, or is corrupt. |
std::bad_alloc | if the memory necessary for storing the model can't be allocated. |
A filename is formed by appending ".wmm" (World Magnetic Model) to the name. If path is specified (and is non-empty), then the file is loaded from directory, path. Otherwise the path is given by the DefaultMagneticPath().
This file contains the metadata which specifies the properties of the model. The coefficients for the spherical harmonic sums are obtained from a file obtained by appending ".cof" to metadata file (so the filename ends in ".wwm.cof").
The model is not tied to a particular ellipsoidal model of the earth. The final earth argument to the constructor specifies an ellipsoid to allow geodetic coordinates to the transformed into the spherical coordinates used in the spherical harmonic sum.
Definition at line 37 of file src/MagneticModel.cpp.
◆ Circle()
Create a MagneticCircle object to allow the geomagnetic field at many points with constant lat, h, and t and varying lon to be computed efficiently.
- Parameters
-
[in] | t | the time (years). |
[in] | lat | latitude of the point (degrees). |
[in] | h | the height of the point above the ellipsoid (meters). |
- Exceptions
-
std::bad_alloc | if the memory necessary for creating a MagneticCircle can't be allocated. |
- Returns
- a MagneticCircle object whose MagneticCircle::operator()(real lon) member function computes the field at particular values of lon.
If the field at several points on a circle of latitude need to be calculated then creating a MagneticCircle and using its member functions will be substantially faster, especially for high-degree models.
Definition at line 212 of file src/MagneticModel.cpp.
◆ DateTime()
const std::string& GeographicLib::MagneticModel::DateTime |
( |
| ) |
const |
|
inline |
- Returns
- date of the model, if available, from the ReleaseDate field in the data file; if absent, return "UNKNOWN".
Definition at line 249 of file MagneticModel.hpp.
◆ DefaultMagneticName()
std::string GeographicLib::MagneticModel::DefaultMagneticName |
( |
| ) |
|
|
static |
- Returns
- the default name for the magnetic model.
This is the value of the environment variable GEOGRAPHICLIB_MAGNETIC_NAME, if set; otherwise, it is "wmm2015". The MagneticModel class does not use this function; it is just provided as a convenience for a calling program when constructing a MagneticModel object.
Definition at line 261 of file src/MagneticModel.cpp.
◆ DefaultMagneticPath()
std::string GeographicLib::MagneticModel::DefaultMagneticPath |
( |
| ) |
|
|
static |
- Returns
- the default path for magnetic model data files.
This is the value of the environment variable GEOGRAPHICLIB_MAGNETIC_PATH, if set; otherwise, it is $GEOGRAPHICLIB_DATA/magnetic if the environment variable GEOGRAPHICLIB_DATA is set; otherwise, it is a compile-time default (/usr/local/share/GeographicLib/magnetic on non-Windows systems and C:/ProgramData/GeographicLib/magnetic on Windows systems).
Definition at line 248 of file src/MagneticModel.cpp.
◆ Description()
const std::string& GeographicLib::MagneticModel::Description |
( |
| ) |
const |
|
inline |
- Returns
- the description of the magnetic model, if available, from the Description file in the data file; if absent, return "NONE".
Definition at line 243 of file MagneticModel.hpp.
◆ Field()
void GeographicLib::MagneticModel::Field |
( |
real |
t, |
|
|
real |
lat, |
|
|
real |
lon, |
|
|
real |
h, |
|
|
bool |
diffp, |
|
|
real & |
Bx, |
|
|
real & |
By, |
|
|
real & |
Bz, |
|
|
real & |
Bxt, |
|
|
real & |
Byt, |
|
|
real & |
Bzt |
|
) |
| const |
|
private |
◆ FieldComponents() [1/2]
Compute various quantities dependent on the magnetic field.
- Parameters
-
[in] | Bx | the x (easterly) component of the magnetic field (nT). |
[in] | By | the y (northerly) component of the magnetic field (nT). |
[in] | Bz | the z (vertical, up positive) component of the magnetic field (nT). |
[out] | H | the horizontal magnetic field (nT). |
[out] | F | the total magnetic field (nT). |
[out] | D | the declination of the field (degrees east of north). |
[out] | I | the inclination of the field (degrees down from horizontal). |
Definition at line 202 of file MagneticModel.hpp.
◆ FieldComponents() [2/2]
void GeographicLib::MagneticModel::FieldComponents |
( |
real |
Bx, |
|
|
real |
By, |
|
|
real |
Bz, |
|
|
real |
Bxt, |
|
|
real |
Byt, |
|
|
real |
Bzt, |
|
|
real & |
H, |
|
|
real & |
F, |
|
|
real & |
D, |
|
|
real & |
I, |
|
|
real & |
Ht, |
|
|
real & |
Ft, |
|
|
real & |
Dt, |
|
|
real & |
It |
|
) |
| |
|
static |
Compute various quantities dependent on the magnetic field and its rate of change.
- Parameters
-
[in] | Bx | the x (easterly) component of the magnetic field (nT). |
[in] | By | the y (northerly) component of the magnetic field (nT). |
[in] | Bz | the z (vertical, up positive) component of the magnetic field (nT). |
[in] | Bxt | the rate of change of Bx (nT/yr). |
[in] | Byt | the rate of change of By (nT/yr). |
[in] | Bzt | the rate of change of Bz (nT/yr). |
[out] | H | the horizontal magnetic field (nT). |
[out] | F | the total magnetic field (nT). |
[out] | D | the declination of the field (degrees east of north). |
[out] | I | the inclination of the field (degrees down from horizontal). |
[out] | Ht | the rate of change of H (nT/yr). |
[out] | Ft | the rate of change of F (nT/yr). |
[out] | Dt | the rate of change of D (degrees/yr). |
[out] | It | the rate of change of I (degrees/yr). |
Definition at line 233 of file src/MagneticModel.cpp.
◆ Flattening()
Math::real GeographicLib::MagneticModel::Flattening |
( |
| ) |
const |
|
inline |
- Returns
- f the flattening of the ellipsoid. This is the value inherited from the Geocentric object used in the constructor.
Definition at line 322 of file MagneticModel.hpp.
◆ MagneticFile()
const std::string& GeographicLib::MagneticModel::MagneticFile |
( |
| ) |
const |
|
inline |
- Returns
- full file name used to load the magnetic model.
Definition at line 254 of file MagneticModel.hpp.
◆ MagneticModelDirectory()
const std::string& GeographicLib::MagneticModel::MagneticModelDirectory |
( |
| ) |
const |
|
inline |
◆ MagneticModelName()
const std::string& GeographicLib::MagneticModel::MagneticModelName |
( |
| ) |
const |
|
inline |
- Returns
- "name" used to load the magnetic model (from the first argument of the constructor, but this may be overridden by the model file).
Definition at line 260 of file MagneticModel.hpp.
◆ MajorRadius()
Math::real GeographicLib::MagneticModel::MajorRadius |
( |
| ) |
const |
|
inline |
- Returns
- a the equatorial radius of the ellipsoid (meters). This is the value of a inherited from the Geocentric object used in the constructor.
Definition at line 316 of file MagneticModel.hpp.
◆ MaxHeight()
Math::real GeographicLib::MagneticModel::MaxHeight |
( |
| ) |
const |
|
inline |
◆ MaxTime()
Math::real GeographicLib::MagneticModel::MaxTime |
( |
| ) |
const |
|
inline |
◆ MinHeight()
Math::real GeographicLib::MagneticModel::MinHeight |
( |
| ) |
const |
|
inline |
◆ MinTime()
Math::real GeographicLib::MagneticModel::MinTime |
( |
| ) |
const |
|
inline |
◆ operator()() [1/2]
Evaluate the components of the geomagnetic field.
- Parameters
-
[in] | t | the time (years). |
[in] | lat | latitude of the point (degrees). |
[in] | lon | longitude of the point (degrees). |
[in] | h | the height of the point above the ellipsoid (meters). |
[out] | Bx | the easterly component of the magnetic field (nanotesla). |
[out] | By | the northerly component of the magnetic field (nanotesla). |
[out] | Bz | the vertical (up) component of the magnetic field (nanotesla). |
Definition at line 140 of file MagneticModel.hpp.
◆ operator()() [2/2]
Evaluate the components of the geomagnetic field and their time derivatives
- Parameters
-
[in] | t | the time (years). |
[in] | lat | latitude of the point (degrees). |
[in] | lon | longitude of the point (degrees). |
[in] | h | the height of the point above the ellipsoid (meters). |
[out] | Bx | the easterly component of the magnetic field (nanotesla). |
[out] | By | the northerly component of the magnetic field (nanotesla). |
[out] | Bz | the vertical (up) component of the magnetic field (nanotesla). |
[out] | Bxt | the rate of change of Bx (nT/yr). |
[out] | Byt | the rate of change of By (nT/yr). |
[out] | Bzt | the rate of change of Bz (nT/yr). |
Definition at line 163 of file MagneticModel.hpp.
◆ operator=()
◆ ReadMetadata()
void GeographicLib::MagneticModel::ReadMetadata |
( |
const std::string & |
name | ) |
|
|
private |
◆ _a
real GeographicLib::MagneticModel::_a |
|
private |
◆ _date
std::string GeographicLib::MagneticModel::_date |
|
private |
◆ _description
std::string GeographicLib::MagneticModel::_description |
|
private |
◆ _dir
std::string GeographicLib::MagneticModel::_dir |
|
private |
◆ _dt0
real GeographicLib::MagneticModel::_dt0 |
|
private |
◆ _earth
◆ _filename
std::string GeographicLib::MagneticModel::_filename |
|
private |
◆ _G
std::vector< std::vector<real> > GeographicLib::MagneticModel::_G |
|
private |
◆ _H
std::vector< std::vector<real> > GeographicLib::MagneticModel::_H |
|
private |
◆ _harm
◆ _hmax
real GeographicLib::MagneticModel::_hmax |
|
private |
◆ _hmin
real GeographicLib::MagneticModel::_hmin |
|
private |
◆ _id
std::string GeographicLib::MagneticModel::_id |
|
private |
◆ _name
std::string GeographicLib::MagneticModel::_name |
|
private |
◆ _Nconstants
int GeographicLib::MagneticModel::_Nconstants |
|
private |
◆ _Nmodels
int GeographicLib::MagneticModel::_Nmodels |
|
private |
◆ _norm
◆ _t0
real GeographicLib::MagneticModel::_t0 |
|
private |
◆ _tmax
real GeographicLib::MagneticModel::_tmax |
|
private |
◆ _tmin
real GeographicLib::MagneticModel::_tmin |
|
private |
◆ idlength_
const int GeographicLib::MagneticModel::idlength_ = 8 |
|
staticprivate |
The documentation for this class was generated from the following files: