Skip to main content

Module magnetic

Module magnetic 

Source
Expand description

The Earth’s main magnetic field from the World Magnetic Model, WMM2025: declination (the angle from true north to magnetic north), inclination, intensity and their yearly change.

A compass points along the horizontal part of the field, not at true north. Declination D is the angle between the two, positive when magnetic north lies east of true north, so a magnetic heading converts to a true one by adding D.

Source: A. Chulliat, W. Brown, M. Nair et al., The US/UK World Magnetic Model for 2025–2030: Technical Report, NCEI, NOAA, 2025, https://doi.org/10.25923/prbc-s316, section 1.2, equations 3 to 20. The coefficients are NCEI’s WMM2025.COF, in the public domain. Details and tests are in the guide’s magnetic-field page.

The model is valid from 2025.0 to 2030.0 and from 1 km below the WGS 84 ellipsoid to 850 km above it (report, sections 1.3 and 3); MagneticModel::field refuses anything outside.

Two departures from the report’s printed text, both checked by NOAA’s test values:

  • Equation 15 prints ġ cos mλ − ḣ sin mλ for the rate of Z′. The potential (equation 4) and equation 12 give +, and NOAA’s 100 test values of Ż need +.
  • Equation 16, the derivative of P̆ₙᵐ, and equation 11 divide by cos φ′, which is zero at a pole. Here every Legendre function is written P̆ₙᵐ = cₙₘ cosᵐφ′ qₙᵐ(sin φ′), with qₙᵐ = dᵐPₙ/dμᵐ a polynomial, so both divisions cancel exactly and the field is finite at the poles (report, section 1.4).

Structs§

MagneticField
The magnetic elements at one place and time, and their rates of change.
MagneticModel
A spherical-harmonic model of the main field: Gauss coefficients at an epoch and their linear secular variation, to degree 12.

Enums§

CompassZone
How far a compass, and so the declination, can be trusted at a place (report, section 1.8).

Constants§

BLACKOUT_HORIZONTAL_NT
Below this horizontal intensity, 2,000 nT, the report’s blackout zone begins: declination can be wrong by up to 180° (report, section 1.8).
CAUTION_HORIZONTAL_NT
Below this horizontal intensity, 6,000 nT, the report’s caution zone around a magnetic pole begins (report, section 1.8).
MAX_HEIGHT_M
The highest height the WMM is specified for: 850 km above the WGS 84 ellipsoid (report, section 3, after MIL-PRF-89500B).
MIN_HEIGHT_M
The lowest height the WMM is specified for: 1 km below the WGS 84 ellipsoid (report, section 3, after MIL-PRF-89500B).
REFERENCE_RADIUS_M
The geomagnetic reference radius a, m (report, equation 4).
WMM2025
WMM2025, the World Magnetic Model for 2025.0 to 2030.0 (NOAA NCEI and the British Geological Survey, released 2024-12-17).

Functions§

decimal_year
A calendar date as a decimal year: year + (d − 1) / L, where d is the day of the year (1 for January 1) and L is 365 or 366. This is the start of the day. Outside the blackout zones around the magnetic poles (CompassZone), the declination changes within a day by a few thousandths of a degree at most, far below the model’s own error.