Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
NETGeographicLib::MagneticModel Class Reference

.NET wrapper for GeographicLib::MagneticModel. More...

#include <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 DefaultMagneticName ()
 
static System::String DefaultMagneticPath ()
 

Public Attributes

Inspector functions
property System::String Description { System::String^ get()
 
property System::String DateTime { System::String^ get()
 
property System::String MagneticFile { System::String^ get()
 
property System::String MagneticModelName { System::String^ get()
 
property System::String MagneticModelDirectory { System::String^ get()
 
property double MinHeight { double get()
 
property double MaxHeight { double get()
 
property double MinTime { double get()
 
property double MaxTime { double get()
 
property double MajorRadius { double get()
 
property double Flattening { double get()
 

Private Member Functions

 !MagneticModel (void)
 

Private Attributes

const GeographicLib::MagneticModelm_pMagneticModel
 

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)
 

Detailed Description

.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 for details of how to install the magnetic model and the data format.

See

C# Example:

using System;
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:

// Example of using the GeographicLib::MagneticModel class
#include <iostream>
#include <exception>
using namespace std;
using namespace GeographicLib;
int main() {
try {
MagneticModel mag("wmm2010");
double lat = 27.99, lon = 86.93, h = 8820, t = 2012; // Mt Everest
double Bx, By, Bz;
mag(t, lat,lon, h, Bx, By, Bz);
double H, F, D, I;
cout << H << " " << F << " " << D << " " << I << "\n";
}
catch (const exception& e) {
cerr << "Caught exception: " << e.what() << "\n";
return 1;
}
}

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 63 of file MagneticModel.h.

Constructor & Destructor Documentation

◆ !MagneticModel()

MagneticModel::!MagneticModel ( void  )
private

Definition at line 24 of file dotnet/NETGeographicLib/MagneticModel.cpp.

◆ MagneticModel() [1/2]

MagneticModel::MagneticModel ( System::String^  name,
System::String^  path,
Geocentric earth 
)

Construct a magnetic model.

Parameters
[in]namethe name of the model.
[in]path(optional) directory for data file.
[in]earth(optional) Geocentric object for converting coordinates.
Exceptions
GeographicErrif the data file cannot be found, is unreadable, or is corrupt.
std::bad_allocif 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 34 of file dotnet/NETGeographicLib/MagneticModel.cpp.

◆ MagneticModel() [2/2]

MagneticModel::MagneticModel ( System::String^  name,
System::String^  path 
)

Construct a magnetic model that assumes the WGS84 ellipsoid.

Parameters
[in]namethe name of the model.
[in]path(optional) directory for data file.
Exceptions
GeographicErrif the data file cannot be found, is unreadable, or is corrupt.
GeographicErrif 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 64 of file dotnet/NETGeographicLib/MagneticModel.cpp.

◆ ~MagneticModel()

NETGeographicLib::MagneticModel::~MagneticModel ( )
inline

The destructor calls the finalizer.

Definition at line 138 of file MagneticModel.h.

Member Function Documentation

◆ Circle()

MagneticCircle 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.

Parameters
[in]tthe time (years).
[in]latlatitude of the point (degrees).
[in]hthe height of the point above the ellipsoid (meters).
Exceptions
std::bad_allocif the memory necessary for creating a MagneticCircle can't be allocated.
Returns
a MagneticCircle object whose MagneticCircle::Field(double 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 120 of file dotnet/NETGeographicLib/MagneticModel.cpp.

◆ DefaultMagneticName()

System::String 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 209 of file dotnet/NETGeographicLib/MagneticModel.cpp.

◆ DefaultMagneticPath()

System::String 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 203 of file dotnet/NETGeographicLib/MagneticModel.cpp.

◆ Field() [1/2]

void 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.

Parameters
[in]tthe time (years).
[in]latlatitude of the point (degrees).
[in]lonlongitude of the point (degrees).
[in]hthe height of the point above the ellipsoid (meters).
[out]Bxthe easterly component of the magnetic field (nanotesla).
[out]Bythe northerly component of the magnetic field (nanotesla).
[out]Bzthe vertical (up) component of the magnetic field (nanotesla).

Definition at line 88 of file dotnet/NETGeographicLib/MagneticModel.cpp.

◆ Field() [2/2]

void 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

Parameters
[in]tthe time (years).
[in]latlatitude of the point (degrees).
[in]lonlongitude of the point (degrees).
[in]hthe height of the point above the ellipsoid (meters).
[out]Bxthe easterly component of the magnetic field (nanotesla).
[out]Bythe northerly component of the magnetic field (nanotesla).
[out]Bzthe vertical (up) component of the magnetic field (nanotesla).
[out]Bxtthe rate of change of Bx (nT/yr).
[out]Bytthe rate of change of By (nT/yr).
[out]Bztthe rate of change of Bz (nT/yr).

Definition at line 101 of file dotnet/NETGeographicLib/MagneticModel.cpp.

◆ FieldComponents() [1/2]

void 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.

Parameters
[in]Bxthe x (easterly) component of the magnetic field (nT).
[in]Bythe y (northerly) component of the magnetic field (nT).
[in]Bzthe z (vertical, up positive) component of the magnetic field (nT).
[out]Hthe horizontal magnetic field (nT).
[out]Fthe total magnetic field (nT).
[out]Dthe declination of the field (degrees east of north).
[out]Ithe inclination of the field (degrees down from horizontal).

Definition at line 133 of file dotnet/NETGeographicLib/MagneticModel.cpp.

◆ FieldComponents() [2/2]

void 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.

Parameters
[in]Bxthe x (easterly) component of the magnetic field (nT).
[in]Bythe y (northerly) component of the magnetic field (nT).
[in]Bzthe z (vertical, up positive) component of the magnetic field (nT).
[in]Bxtthe rate of change of Bx (nT/yr).
[in]Bytthe rate of change of By (nT/yr).
[in]Bztthe rate of change of Bz (nT/yr).
[out]Hthe horizontal magnetic field (nT).
[out]Fthe total magnetic field (nT).
[out]Dthe declination of the field (degrees east of north).
[out]Ithe inclination of the field (degrees down from horizontal).
[out]Htthe rate of change of H (nT/yr).
[out]Ftthe rate of change of F (nT/yr).
[out]Dtthe rate of change of D (degrees/yr).
[out]Itthe rate of change of I (degrees/yr).

Definition at line 148 of file dotnet/NETGeographicLib/MagneticModel.cpp.

Member Data Documentation

◆ DateTime

property System::String NETGeographicLib::MagneticModel::DateTime { System::String^ get()
Returns
date of the model, if available, from the ReleaseDate field in the data file; if absent, return "UNKNOWN".

Definition at line 270 of file MagneticModel.h.

◆ Description

property System::String NETGeographicLib::MagneticModel::Description { System::String^ get()
Returns
the description of the magnetic model, if available, from the Description file in the data file; if absent, return "NONE".

Definition at line 264 of file MagneticModel.h.

◆ Flattening

property double NETGeographicLib::MagneticModel::Flattening { double get()
Returns
f the flattening of the ellipsoid. This is the value inherited from the Geocentric object used in the constructor.

Definition at line 343 of file MagneticModel.h.

◆ m_pMagneticModel

const GeographicLib::MagneticModel* NETGeographicLib::MagneticModel::m_pMagneticModel
private

Definition at line 67 of file MagneticModel.h.

◆ MagneticFile

property System::String NETGeographicLib::MagneticModel::MagneticFile { System::String^ get()
Returns
full file name used to load the magnetic model.

Definition at line 275 of file MagneticModel.h.

◆ MagneticModelDirectory

property System::String NETGeographicLib::MagneticModel::MagneticModelDirectory { System::String^ get()
Returns
directory used to load the magnetic model.

Definition at line 286 of file MagneticModel.h.

◆ MagneticModelName

property System::String NETGeographicLib::MagneticModel::MagneticModelName { System::String^ get()
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 281 of file MagneticModel.h.

◆ MajorRadius

property double NETGeographicLib::MagneticModel::MajorRadius { double get()
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 337 of file MagneticModel.h.

◆ MaxHeight

property double NETGeographicLib::MagneticModel::MaxHeight { double get()
Returns
the maximum height above the ellipsoid (in meters) for which this MagneticModel should be used.

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 308 of file MagneticModel.h.

◆ MaxTime

property double NETGeographicLib::MagneticModel::MaxTime { double get()
Returns
the maximum time (in years) for which this MagneticModel should be used.

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 330 of file MagneticModel.h.

◆ MinHeight

property double NETGeographicLib::MagneticModel::MinHeight { double get()
Returns
the minimum height above the ellipsoid (in meters) for which this MagneticModel should be used.

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 297 of file MagneticModel.h.

◆ MinTime

property double NETGeographicLib::MagneticModel::MinTime { double get()
Returns
the minimum time (in years) for which this MagneticModel should be used.

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 319 of file MagneticModel.h.


The documentation for this class was generated from the following files:
H
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy y set format x g set format y g set format x2 g set format y2 g set format z g set angles radians set nogrid set key title set key left top Right noreverse box linetype linewidth samplen spacing width set nolabel set noarrow set nologscale set logscale x set set pointsize set encoding default set nopolar set noparametric set set set set surface set nocontour set clabel set mapping cartesian set nohidden3d set cntrparam order set cntrparam linear set cntrparam levels auto set cntrparam points set size set set xzeroaxis lt lw set x2zeroaxis lt lw set yzeroaxis lt lw set y2zeroaxis lt lw set tics in set ticslevel set tics set mxtics default set mytics default set mx2tics default set my2tics default set xtics border mirror norotate autofreq set ytics border mirror norotate autofreq set ztics border nomirror norotate autofreq set nox2tics set noy2tics set timestamp bottom norotate set rrange[*:*] noreverse nowriteback set trange[*:*] noreverse nowriteback set urange[*:*] noreverse nowriteback set vrange[*:*] noreverse nowriteback set xlabel matrix size set x2label set timefmt d m y n H
Definition: gnuplot_common_settings.hh:74
MagneticModel.hpp
Header for GeographicLib::MagneticModel class.
D
MatrixXcd D
Definition: EigenSolver_EigenSolver_MatrixType.cpp:14
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
NETGeographicLib::MagneticModel::FieldComponents
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)
Definition: dotnet/NETGeographicLib/MagneticModel.cpp:133
GeographicLib
Namespace for GeographicLib.
Definition: JacobiConformal.hpp:15
GeographicLib::MagneticModel
Model of the earth's magnetic field.
Definition: MagneticModel.hpp:69
h
const double h
Definition: testSimpleHelicopter.cpp:19
main
int main(int argc, char **argv)
Definition: cmake/example_cmake_find_gtsam/main.cpp:63
I
#define I
Definition: main.h:112
NETGeographicLib::MagneticModel::MagneticModel
MagneticModel(System::String^ name, System::String^ path, Geocentric^ earth)
Definition: dotnet/NETGeographicLib/MagneticModel.cpp:34
gtsam::symbol_shorthand::F
Key F(std::uint64_t j)
Definition: inference/Symbol.h:153
out
std::ofstream out("Result.txt")
std
Definition: BFloat16.h:88
args
Definition: pytypes.h:2210
lon
static const double lon
Definition: testGeographicLib.cpp:34
align_3::t
Point2 t(10, 10)
NETGeographicLib
Definition: Accumulator.h:13
lat
static const double lat
Definition: testGeographicLib.cpp:34


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:16:46