GeographicLib: Magnetic models (original) (raw)

Back to Normal gravity. Forward to Geodesics on an ellipsoid of revolution. Up to Contents.

GeographicLib can compute the earth's magnetic field by a magnetic model using the MagneticModel and MagneticCircle classes and with the MagneticField utility. These models expand the internal magnetic potential of the earth as sum of spherical harmonics. They neglect magnetic fields due to the ionosphere, the magnetosphere, nearby magnetized materials, electric machinery, etc. Users of MagneticModel are advised to read the "Health Warning" this is provided with igrf. Although the advice is specific to the igrf models, many of the comments apply to all magnetic field models.

The supported models are

Go to

Installing the magnetic field models

These magnetic models are available for download from this directoy https://sourceforge.net/projects/geographiclib/files/magnetic-distrib

Available magnetic models

name max degree time interval size(kB) Download Links (size, kB)
tar file Windows installer zip file
wmm2010 12 2010–2015 3 link (2) link (300) link (2)
wmm2015 12 2015–2020 3 link (2) link (300) link (2)
wmm2015v2 12 2015–2020 3 link (2) link (300) link (2)
wmm2020 12 2020–2025 3 link (2) link (1390) link (2)
wmm2025 12 2025–2030 3 link (2) link (1759) link (2)
wmmhr2025 133 2025–2030 281 link (37) link (1792) link (46)
igrf11 13 1900–2015 25 link (7) link (310) link (8)
igrf12 13 1900–2020 26 link (7) link (310) link (8)
igrf13 13 1900–2025 28 link (7) link (1420) link (8)
igrf14 13 1900–2030 29 link (8) link (1764) link (9)
emm2010 739 2010–2015 4400 link (3700) link (3000) link (4100)
emm2015 729 2000–2020 4300 link (660) link (990) link (1030)
emm2017 790 2000–2022 5050 link (1740) link (1700) link (2750)

The "size" column is the size of the uncompressed data. N.B., the wmm2015 model is deprecated; use wmm2015v2 instead.

For Linux and Unix systems, GeographicLib provides a shell script geographiclib-get-magnetic (typically installed in /usr/local/sbin) which automates the process of downloading and installing the magnetic models. For example

geographiclib-get-magnetic all # install all available models geographiclib-get-magnetic -h # for help

This script should be run as a user with write access to the installation directory, which is typically /usr/local/share/GeographicLib (this can be overridden with the -p flag), and the data will then be placed in the "magnetic" subdirectory.

Windows users should download and run the Windows installers. These will prompt for an installation directory with the default being

C:/ProgramData/GeographicLib

(which you probably should not change) and the data is installed in the "magnetic" sub-directory. (The second directory name is an alternate name that Windows 7 uses for the "Application Data" directory.)

Otherwise download either the tar.bz2 file or the zip file (they have the same contents). To unpack these, run, for example

mkdir -p /usr/local/share/GeographicLib tar xofjC wmm2025.tar.bz2 /usr/local/share/GeographicLib tar xofjC emm2010.tar.bz2 /usr/local/share/GeographicLib etc.

and, again, the data will be placed in the "magnetic" subdirectory.

However you install the magnetic models, all the datasets should be installed in the same directory. MagneticModel and MagneticField uses a compile time default to locate the datasets. This is

consistent with the examples above. This may be overridden at run-time by defining the GEOGRAPHICLIB_MAGNETIC_PATH or the GEOGRAPHIC_DATA environment variables; see MagneticModel::DefaultMagneticPath() for details. Finally, the path may be set using the optional second argument to the MagneticModel constructor or with the "-d" flag to MagneticField. Supplying the "-h" flag to MagneticField reports the default path for magnetic models for that utility. The "-v" flag causes MagneticField to report the full path name of the data file it uses.

The format of the magnetic model files

The constructor for MagneticModel reads a file called NAME.wmm which specifies various properties for the magnetic model. It then opens a binary file NAME.wmm.cof to obtain the coefficients of the spherical harmonic sum.

The first line of the .wmm file must consist of "WMMF-v" where WMMF stands for "World Magnetic Model Format" and v is the version number of the format (currently "2").

The rest of the file is read a line at a time. A # character and everything after it are discarded. If the result is just white space it is discarded. The remaining lines are of the form "KEY WHITESPACE VALUE". In general, the KEY and the VALUE are case-sensitive.

MagneticModel only pays attention to the following keywords

Other keywords are ignored.

The coefficient file NAME.wmm.cof is a binary file in little endian order. The first 8 bytes of this file must match the ID given in

NAME.wmm. This is followed by NumModels + 1 + NumConstants sets of spherical harmonic coefficients. The first NumModels of these model the magnetic field at Epoch + i * DeltaEpoch for 0 ≤ i < NumModels. The next set of coefficients model the rate of change of the magnetic field at Epoch + (NumModels − 1) * DeltaEpoch. If NumConstants > 0, the last set of coefficients model the constant short wavelength contributions to the magnetic field.

The format for each set of coefficients is:

Although the coefficient file is in little endian order, GeographicLib can read it on big endian machines. It can only be read on machines which store doubles in IEEE format.

As an illustration, here is igrf11.wmm:

WMMF-1

A World Magnetic Model (Format 1) file. For documentation on the

format of this file see

https://geographiclib.sourceforge.io/C++/doc/magnetic.html#magneticformat

Name igrf11 Description International Geomagnetic Reference Field 11th Generation URL https://ngdc.noaa.gov/IAGA/vmod/igrf.html Publisher National Oceanic and Atmospheric Administration ReleaseDate 2009-12-15 DataCutOff 2009-10-01 ConversionDate 2011-11-04 DataVersion 1 Radius 6371200 NumModels 23 Epoch 1900 DeltaEpoch 5 MinTime 1900 MaxTime 2015 MinHeight -1000 MaxHeight 600000

The coefficients are stored in a file obtained by appending ".cof" to

the name of this file. The coefficients were obtained from IGRF11.COF

in the geomag70 distribution.

ID IGRF11-A

Back to Normal gravity. Forward to Geodesics on an ellipsoid of revolution. Up to Contents.