.NET wrapper for GeographicLib::MagneticModel. More...
#include <NETGeographicLib/MagneticModel.h>
Public Member Functions | |
~MagneticModel () | |
Setting up the magnetic model | |
MagneticModel (System::String^ name, System::String^ path, Geocentric^ earth) | |
MagneticModel (System::String^ name, System::String^ path) | |
Static Public Member Functions | |
static System::String^ | DefaultMagneticPath () |
static System::String^ | DefaultMagneticName () |
Properties | |
Inspector functions | |
System::String^ | Description [get] |
System::String^ | DateTime [get] |
System::String^ | MagneticFile [get] |
System::String^ | MagneticModelName [get] |
System::String^ | MagneticModelDirectory [get] |
double | MinHeight [get] |
double | MaxHeight [get] |
double | MinTime [get] |
double | MaxTime [get] |
double | MajorRadius [get] |
double | Flattening [get] |
Compute the magnetic field | |
| |
void | Field (double t, double lat, double lon, double h,[System::Runtime::InteropServices::Out] double% Bx,[System::Runtime::InteropServices::Out] double% By,[System::Runtime::InteropServices::Out] double% Bz) |
void | Field (double t, double lat, double lon, double h,[System::Runtime::InteropServices::Out] double% Bx,[System::Runtime::InteropServices::Out] double% By,[System::Runtime::InteropServices::Out] double% Bz,[System::Runtime::InteropServices::Out] double% Bxt,[System::Runtime::InteropServices::Out] double% Byt,[System::Runtime::InteropServices::Out] double% Bzt) |
MagneticCircle^ | Circle (double t, double lat, double h) |
static void | FieldComponents (double Bx, double By, double Bz,[System::Runtime::InteropServices::Out] double% H,[System::Runtime::InteropServices::Out] double% F,[System::Runtime::InteropServices::Out] double% D,[System::Runtime::InteropServices::Out] double% I) |
static void | FieldComponents (double Bx, double By, double Bz, double Bxt, double Byt, double Bzt,[System::Runtime::InteropServices::Out] double% H,[System::Runtime::InteropServices::Out] double% F,[System::Runtime::InteropServices::Out] double% D,[System::Runtime::InteropServices::Out] double% I,[System::Runtime::InteropServices::Out] double% Ht,[System::Runtime::InteropServices::Out] double% Ft,[System::Runtime::InteropServices::Out] double% Dt,[System::Runtime::InteropServices::Out] double% It) |
.NET wrapper for GeographicLib::MagneticModel.
This class allows .NET applications to access GeographicLib::MagneticModel.
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 models for details of how to install the magnetic model and the data format.
See
C# Example:
using System; using NETGeographicLib; namespace example_MagneticModel { class Program { static void Main(string[] args) { try { MagneticModel mag = new MagneticModel("wmm2010",""); double lat = 27.99, lon = 86.93, h = 8820, t = 2012; // Mt Everest double Bx, By, Bz; mag.Field(t, lat,lon, h, out Bx, out By, out Bz); double H, F, D, I; MagneticModel.FieldComponents(Bx, By, Bz, out H, out F, out D, out I); Console.WriteLine(String.Format("{0} {1} {2} {3}", H, F, D, I)); } catch (GeographicErr e) { Console.WriteLine(String.Format("Caught exception: {0}", e.Message)); } } } }
Managed C++ Example:
using namespace System; using namespace NETGeographicLib; int main(array<System::String ^> ^/*args*/) { try { MagneticModel^ mag = gcnew MagneticModel("wmm2010",""); double lat = 27.99, lon = 86.93, h = 8820, t = 2012; // Mt Everest double Bx, By, Bz; mag->Field(t, lat,lon, h, Bx, By, Bz); double H, F, D, I; MagneticModel::FieldComponents(Bx, By, Bz, H, F, D, I); Console::WriteLine(String::Format("{0} {1} {2} {3}", H, F, D, I)); } catch (GeographicErr^ e) { Console::WriteLine(String::Format("Caught exception: {0}", e->Message)); return -1; } return 0; }
Visual Basic Example:
Imports NETGeographicLib Module example_MagneticModel Sub Main() Try Dim mag As MagneticModel = New MagneticModel("wmm2010", "") Dim lat As Double = 27.99, lon = 86.93, h = 8820, t = 2012 ' Mt Everest Dim Bx, By, Bz As Double mag.Field(t, lat, lon, H, Bx, By, Bz) Dim bigH, F, D, I As Double MagneticModel.FieldComponents(Bx, By, Bz, bigH, F, D, I) Console.WriteLine(String.Format("{0} {1} {2} {3}", bigH, F, D, I)) Catch ex As GeographicErr Console.WriteLine(String.Format("Caught exception: {0}", ex.Message)) End Try End Sub End Module
INTERFACE DIFFERENCES:
The () operator has been replaced with Field.
The following functions are implemented as properties: Description, DateTime, MagneticFile, MagneticModelName, MagneticModelDirectory, MinHeight, MaxHeight, MinTime, MaxTime, MajorRadius, and Flattening.
Definition at line 60 of file MagneticModel.h.
NETGeographicLib::MagneticModel::MagneticModel | ( | System::String^ | name, | |
System::String^ | path, | |||
Geocentric^ | earth | |||
) |
Construct a magnetic model.
[in] | name | the name of the model. |
[in] | path | (optional) directory for data file. |
[in] | earth | (optional) Geocentric object for converting coordinates. |
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.
Referenced by ~MagneticModel().
NETGeographicLib::MagneticModel::MagneticModel | ( | System::String^ | name, | |
System::String^ | path | |||
) |
Construct a magnetic model that assumes the WGS84 ellipsoid.
[in] | name | the name of the model. |
[in] | path | (optional) directory for data file. |
GeographicErr | if the data file cannot be found, is unreadable, or is corrupt. | |
GeographicErr | 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.
NETGeographicLib::MagneticModel::~MagneticModel | ( | ) | [inline] |
The destructor calls the finalizer.
Definition at line 135 of file MagneticModel.h.
References MagneticModel().
void NETGeographicLib::MagneticModel::Field | ( | double | t, | |
double | lat, | |||
double | lon, | |||
double | h, | |||
[System::Runtime::InteropServices::Out] double% | Bx, | |||
[System::Runtime::InteropServices::Out] double% | By, | |||
[System::Runtime::InteropServices::Out] double% | Bz | |||
) |
Evaluate the components of the geomagnetic field.
[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). |
void NETGeographicLib::MagneticModel::Field | ( | double | t, | |
double | lat, | |||
double | lon, | |||
double | h, | |||
[System::Runtime::InteropServices::Out] double% | Bx, | |||
[System::Runtime::InteropServices::Out] double% | By, | |||
[System::Runtime::InteropServices::Out] double% | Bz, | |||
[System::Runtime::InteropServices::Out] double% | Bxt, | |||
[System::Runtime::InteropServices::Out] double% | Byt, | |||
[System::Runtime::InteropServices::Out] double% | Bzt | |||
) |
Evaluate the components of the geomagnetic field and their time derivatives
[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). |
MagneticCircle ^ NETGeographicLib::MagneticModel::Circle | ( | double | t, | |
double | lat, | |||
double | h | |||
) |
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.
[in] | t | the time (years). |
[in] | lat | latitude of the point (degrees). |
[in] | h | the height of the point above the ellipsoid (meters). |
std::bad_alloc | if the memory necessary for creating a MagneticCircle can't be allocated. |
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.
static void NETGeographicLib::MagneticModel::FieldComponents | ( | double | Bx, | |
double | By, | |||
double | Bz, | |||
[System::Runtime::InteropServices::Out] double% | H, | |||
[System::Runtime::InteropServices::Out] double% | F, | |||
[System::Runtime::InteropServices::Out] double% | D, | |||
[System::Runtime::InteropServices::Out] double% | I | |||
) | [static] |
Compute various quantities dependent on the magnetic field.
[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). |
static void NETGeographicLib::MagneticModel::FieldComponents | ( | double | Bx, | |
double | By, | |||
double | Bz, | |||
double | Bxt, | |||
double | Byt, | |||
double | Bzt, | |||
[System::Runtime::InteropServices::Out] double% | H, | |||
[System::Runtime::InteropServices::Out] double% | F, | |||
[System::Runtime::InteropServices::Out] double% | D, | |||
[System::Runtime::InteropServices::Out] double% | I, | |||
[System::Runtime::InteropServices::Out] double% | Ht, | |||
[System::Runtime::InteropServices::Out] double% | Ft, | |||
[System::Runtime::InteropServices::Out] double% | Dt, | |||
[System::Runtime::InteropServices::Out] double% | It | |||
) | [static] |
Compute various quantities dependent on the magnetic field and its rate of change.
[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). |
static System::String ^ NETGeographicLib::MagneticModel::DefaultMagneticPath | ( | ) | [static] |
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).
static System::String ^ NETGeographicLib::MagneticModel::DefaultMagneticName | ( | ) | [static] |
This is the value of the environment variable GEOGRAPHICLIB_MAGNETIC_NAME, if set, otherwise, it is "wmm2010". The MagneticModel class does not use this function; it is just provided as a convenience for a calling program when constructing a MagneticModel object.
System:: String^ NETGeographicLib::MagneticModel::Description [get] |
Definition at line 261 of file MagneticModel.h.
System:: String^ NETGeographicLib::MagneticModel::DateTime [get] |
Definition at line 267 of file MagneticModel.h.
System:: String^ NETGeographicLib::MagneticModel::MagneticFile [get] |
Definition at line 272 of file MagneticModel.h.
System:: String^ NETGeographicLib::MagneticModel::MagneticModelName [get] |
Definition at line 278 of file MagneticModel.h.
System:: String^ NETGeographicLib::MagneticModel::MagneticModelDirectory [get] |
Definition at line 283 of file MagneticModel.h.
double NETGeographicLib::MagneticModel::MinHeight [get] |
Because the model will typically provide useful results slightly outside the range of allowed heights, no check of t argument is made by MagneticModel::Field() or MagneticModel::Circle.
Definition at line 294 of file MagneticModel.h.
double NETGeographicLib::MagneticModel::MaxHeight [get] |
Because the model will typically provide useful results slightly outside the range of allowed heights, no check of t argument is made by MagneticModel::Field() or MagneticModel::Circle.
Definition at line 305 of file MagneticModel.h.
double NETGeographicLib::MagneticModel::MinTime [get] |
Because the model will typically provide useful results slightly outside the range of allowed times, no check of t argument is made by MagneticModel::Field() or MagneticModel::Circle.
Definition at line 316 of file MagneticModel.h.
double NETGeographicLib::MagneticModel::MaxTime [get] |
Because the model will typically provide useful results slightly outside the range of allowed times, no check of t argument is made by MagneticModel::Field() or MagneticModel::Circle.
Definition at line 327 of file MagneticModel.h.
double NETGeographicLib::MagneticModel::MajorRadius [get] |
Definition at line 334 of file MagneticModel.h.
double NETGeographicLib::MagneticModel::Flattening [get] |
Definition at line 340 of file MagneticModel.h.