World Magnetic Model (WMM)

This documentation was generated with the assistance of AI. Please report any inaccuracies.

The com.irurueta.navigation.inertial.wmm package estimates the Earth’s magnetic flux density at a given position and date, using the U.S./U.K. World Magnetic Model (WMM) — see [wmm-site]. It is used both as an independent heading reference (see AttitudeEstimator) and as an input to magnetometer calibration (see IMU Calibration).

This library bundles a default WMM coefficient file (wmm.cof, currently WMM-2025, valid 2025.0-2030.0 — see The Spherical Harmonic Model). Every WMM release expires after 5 years: past its valid period, the model’s secular-variation extrapolation drifts and declination/dip estimates become unreliable. Applications running past 2030 (or bundling this library long-term) should download the current release from NOAA/NCEI’s WMM coefficients page and load it explicitly with WMMLoader, instead of relying on the bundled default — see The Spherical Harmonic Model for how to load a custom coefficient file.

What the WMM provides

At any given latitude, longitude, height, and date, the Earth’s magnetic field can be described by three independent quantities:

Element Meaning

Magnitude (intensity)

Total field strength, roughly 30 microtesla (µT) at the equator up to about 60 µT near the poles.

Declination

The bearing of the magnetic field from true north — the angle a compass needle’s reading must be corrected by to get true heading.

Dip (inclination)

The angle the field makes below the local horizontal plane — essentially the "magnetic latitude," typically within about 10° of the geodetic latitude.

Elements of the geomagnetic field: declination and dip versus horizontal and total intensity

Declination is the only one of the three needed to convert a magnetometer heading measurement into true heading (see AttitudeEstimator). It is not constant: it drifts slowly over years (secular variation) and varies significantly with location, which is why a global model like the WMM — rather than a single fixed value — is needed.

From position and date to field components

The evaluation chain used by WMMEarthMagneticFluxDensityEstimator has four stages. Each one is derived in detail in The Spherical Harmonic Model; this section only states the equations in order. The conventions follow the WMM technical report ([wmm-site]) and [book-groves], where the same NED quantities are used for navigation.

flowchart LR A["Geodetic position\n(latitude φ, longitude λ, height h)"] -->|"WGS84 ellipsoid\n(a, b)"| B["Geocentric spherical\n(radius r, latitude φ', same λ)"] B -->|"Gauss coefficients at\ndecimal year t"| C["Spherical field components\n(B_r, B_θ, B_φ)"] C -->|"rotate by ψ = φ - φ'"| D["Geodetic NED components\n(X, Y, Z)"] D --> E["H, F, declination D,\ndip I"]

1. Geodetic to geocentric spherical coordinates. The WGS84 ellipsoid has semi-major axis and semi-minor axis . For a point at geodetic latitude and ellipsoidal height , define

where is the geocentric latitude (the colatitude used by the harmonic sum is ) and is the distance to the Earth’s centre. Longitude is the same in both systems. The angle between the geodetic and geocentric vertical is

These are the quantities the implementation keeps as ct/st (cosine/sine of the colatitude) and ca/sa (cosine/sine of ). At sea level the latitude relation reduces to ; the two latitudes differ by at most about , at mid-latitudes.

2. Field in geocentric spherical components. With the coefficients evaluated at the requested time (see step 4 below), the harmonic sum of The Spherical Harmonic Model yields at .

3. Field components X, Y, Z. Rotating by about the east axis gives the north, east and down components (the geomagnetic elements , , , identical to , , ):

The elements in the table above follow from them:

where is the horizontal intensity, the total intensity (the Magnitude above), the declination (positive east of true north) and the dip (positive when the field points downward). The inverse relations, used when the three scalars are known and the vector is wanted, are , and ; see Earth Magnetic Flux Density Container and Simple Estimator.

4. Secular variation over time. Each Gauss coefficient is extrapolated linearly from the model epoch to the decimal year with its published yearly rate:

Because the harmonic sum is linear in the coefficients, the components , and also vary linearly in ( , , are the same sum evaluated with and ). The derived angles do not: differentiating the relations of step 3 gives

The estimator does not expose these rates as methods; evaluate it at two dates to obtain them numerically.

Classes

Class Role

WorldMagneticModel

Holds the loaded Gauss coefficients (main field + secular variation) and derived normalization factors for one 5-year WMM release.

WMMLoader

Parses a WMM coefficient file (.cof) — from a resource, file, or URL — into a WorldMagneticModel.

WMMEarthMagneticFluxDensityEstimator

Evaluates the spherical-harmonic model at a given position/date to get declination, dip, intensity, and the full NED magnetic flux density vector. This is the actual WMM algorithm.

EarthMagneticFluxDensityEstimator

A much simpler helper: builds a NED magnetic flux density vector directly from an already-known magnitude/declination/dip (e.g. supplied by the caller, without needing the full WMM coefficient set).

NEDMagneticFluxDensity

Data container for magnetic flux density resolved about north, east, down axes.

flowchart LR A[".cof coefficient file\n(NOAA/NGA/BGS release)"] -->|WMMLoader| B["WorldMagneticModel\n(Gauss coefficients)"] B --> C["WMMEarthMagneticFluxDensityEstimator\n(spherical harmonic evaluation)"] D["latitude, longitude,\nheight, date"] --> C C --> E["declination, dip, intensity,\nNEDMagneticFluxDensity"] E --> F["AttitudeEstimator\n(heading correction)"] E --> G["Magnetometer calibration"]

Where to go next