Magnetic declination

WMM2025, NOAA and BGS · checked against NOAA's published test values

What it is

A compass doesn’t point to true north. True north is fixed: along a meridian to the North Pole, the north on a map. Magnetic north is where a compass needle points, lined up with the Earth’s magnetic field. Almost everywhere the two differ, and the angle between them is magnetic declination.

True north straight up, magnetic north 15 degrees to its right, the angle between them labelled declination 15° E
  • East is positive. Declination is east when the needle points east of true north, as it does across most of western North America.
  • To turn a compass bearing into a true bearing, add the declination. With 15° E, a compass reading of 100° is 115° true.
  • It changes with place and over time. The field drifts, so the model is replaced every five years. WMM2025 is good from 2025 to the end of 2029.
  • Near the magnetic poles a compass is unreliable. The field’s horizontal part is too weak to steer a needle. The model flags these areas.

Operations

OperationGives
field The magnetic field at a place and timeIn: latitudeInDegrees, longitudeInDegrees, heightInKilometers, decimalYear
Out: magneticDeclinationInDegrees, inclinationInDegrees, northIntensityInNanoteslas, eastIntensityInNanoteslas, downIntensityInNanoteslas, horizontalIntensityInNanoteslas, totalIntensityInNanoteslas, gridVariationInDegrees, blackout
decimalYear The decimal year for a dateIn: date
Out: decimalYear

Fields

FieldMeaning
latitudeInDegrees−90 to 90, geodetic on WGS84, north positive
longitudeInDegrees−180 to 360, east positive. NOAA's own test values use 240.
heightInKilometersAbove the WGS84 ellipsoid, −1 to 850
decimalYearThe year plus the days before the date over the days in its year, so 1 January is a whole year. The field operation takes 2025.0 to 2030.0 and refuses anything else as outOfRange.
dateA calendar date, YYYY-MM-DD. One that doesn't exist, like 2027-02-29, is invalidInput.
magneticDeclinationInDegreesD, the angle from true north to magnetic north, east positive, −180 to 180
inclinationInDegreesI, the field's dip below the horizontal, down positive
northIntensityInNanoteslasX, the field's north component
eastIntensityInNanoteslasY, the field's east component
downIntensityInNanoteslasZ, the field's down component
horizontalIntensityInNanoteslasH, the field's horizontal strength
totalIntensityInNanoteslasF, the field's total strength
gridVariationInDegreesGV, magnetic north measured from polar stereographic grid north, −180 to 180: D minus longitude at 55° N and above, D plus longitude at 55° S and below. null between.
blackoutnone, caution (H under 6000 nT) or unreliable (H under 2000 nT), NOAA's blackout zones around the magnetic poles

Edge cases

CaseWhat it tests
noaa-table-1fieldNOAA's Table 6. Grid variation equals declination on the prime meridian.
noaa-table-2fieldAt the equator grid variation is null: NOAA prints NaN.
noaa-table-3fieldLongitude 240 is −120: grid variation is declination plus longitude, wrapped to −180 to 180.
noaa-points-1fieldNear the north magnetic pole: horizontal intensity under 2000 nT, blackout unreliable, declination still given.
noaa-points-2fieldHorizontal intensity under 6000 nT: blackout caution.
reference-north-pole-2026fieldThe geographic north pole: longitude is undefined, so NOAA takes the limit along longitude 0. Blackout unreliable.
reference-south-pole-2026fieldThe geographic south pole, along longitude 0.
reference-first-instantfield2025.0, the model's first instant.
reference-last-instantfield2030.0, the model's last instant: still computed.
reference-grid-variation-55nfieldExactly 55° N, where grid variation starts: declination minus longitude.
reference-grid-variation-55sfieldExactly 55° S: declination plus longitude.
reference-date-2025-01-01decimalYear1 January is a whole year.
reference-date-2028-02-29decimalYearA leap day: 2028 + 59/366.
reference-date-2028-12-31decimalYearThe last day of a leap year: 2028 + 365/366.
reference-date-2000-03-01decimalYear2000 was a leap year: 2000 + 60/366.
reference-date-2100-03-01decimalYear2100 isn't a leap year: 2100 + 59/365.
reference-date-2027-02-29decimalYearDoesn't exist: invalidInput.
invalid-before-2025fieldBefore the model's first instant: outOfRange, as NOAA's software refuses it.
invalid-after-2030fieldAfter the model's last instant: outOfRange.

Their inputs and expected values are in vectors.json; search for the case's id.

For agents

Implement WMM2025 from WMM.COF (in sources) as the spherical harmonic expansion to degree 12 in the report’s notation. Advance the coefficients linearly from 2025.0 with their secular variation. Convert geodetic latitude and height to geocentric before the expansion, and rotate the result back after. At a geographic pole, where the usual formulas divide by zero, use the report’s special case. The report’s Table 3 gives every intermediate value for one point, which finds most bugs. Take decimalYear as the year plus (day of year − 1) over the days in that year. gridVariationInDegrees is declination minus longitude from 55° N and plus longitude from 55° S, wrapped to −180 to 180, and null between. blackout comes from the horizontal intensity. Pass every case in vectors.json within its tolerance; never loosen a tolerance to pass.

Test data

vectors.json holds 137 cases, published 2026-11-04. Earth model: WGS84. How to read it: Test data format.

OperationCases
field 125112 published · 8 reference · 17 edge · 24 polar · 5 invalid
decimalYear 1212 reference · 11 edge · 1 invalid

Tags say where each value came from: what they mean.

FieldTolerance
magneticDeclinationInDegrees± 0.01
inclinationInDegrees± 0.01
northIntensityInNanoteslas± 1
eastIntensityInNanoteslas± 1
downIntensityInNanoteslas± 1
horizontalIntensityInNanoteslas± 1
totalIntensityInNanoteslas± 1
gridVariationInDegrees± 0.01
decimalYear± 0.0001

Every other field is compared exactly.

Implementations

ImplementationStatus
gshaw/algorithms-swiftSwift Passes
gshaw/algorithms-typescriptTypeScript Passes

Each implementation's CI grades it against this page's test data on every push, and again when the data changes. The code isn't public yet. See how implementations work.

Source

StandardThe US/UK World Magnetic Model for 2025-2030: Technical ReportChulliat, A., W. Brown, M. Nair, N. Gomez Perez, L.-Y. Young, C. Watson, N. Boneh, C. Beggan, B. Meyer and M. Paniccia, 2025. NOAA NCEI and the British Geological Survey. https://doi.org/10.25923/prbc-s316 · Public domain
CoefficientsWMM.COF for WMM2025NOAA NCEI. Copied to /wmm/sources/WMM.COF · Public domain
Test valuesWMM2025_TEST_VALUES.txt, Table 6 of the reportNOAA NCEI. Cases noaa-table-1 to 12. Copied to /wmm/sources/ · Public domain
Test valuesWMM2025_TestValues.txt, in the coefficient zipNOAA NCEI. Cases noaa-points-1 to 100. Copied to /wmm/sources/ · Public domain
Reference programWMM2025 C software for LinuxNOAA NCEI. Its library, run by scripts/wmm/generate.sh, gives the reference cases. Output in /wmm/sources/reference-output.txt · Public domain