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.
- 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
| Operation | Gives |
|---|---|
field |
The magnetic field at a place and timeIn: latitudeInDegrees, longitudeInDegrees, heightInKilometers, decimalYearOut: magneticDeclinationInDegrees, inclinationInDegrees, northIntensityInNanoteslas, eastIntensityInNanoteslas, downIntensityInNanoteslas, horizontalIntensityInNanoteslas, totalIntensityInNanoteslas, gridVariationInDegrees, blackout |
decimalYear |
The decimal year for a dateIn: dateOut: decimalYear |
Fields
| Field | Meaning |
|---|---|
latitudeInDegrees | −90 to 90, geodetic on WGS84, north positive |
longitudeInDegrees | −180 to 360, east positive. NOAA's own test values use 240. |
heightInKilometers | Above the WGS84 ellipsoid, −1 to 850 |
decimalYear | The 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. |
date | A calendar date, YYYY-MM-DD. One that doesn't exist, like 2027-02-29, is invalidInput. |
magneticDeclinationInDegrees | D, the angle from true north to magnetic north, east positive, −180 to 180 |
inclinationInDegrees | I, the field's dip below the horizontal, down positive |
northIntensityInNanoteslas | X, the field's north component |
eastIntensityInNanoteslas | Y, the field's east component |
downIntensityInNanoteslas | Z, the field's down component |
horizontalIntensityInNanoteslas | H, the field's horizontal strength |
totalIntensityInNanoteslas | F, the field's total strength |
gridVariationInDegrees | GV, 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. |
blackout | none, caution (H under 6000 nT) or unreliable (H under 2000 nT), NOAA's blackout zones around the magnetic poles |
Edge cases
| Case | What it tests |
|---|---|
noaa-table-1field | NOAA's Table 6. Grid variation equals declination on the prime meridian. |
noaa-table-2field | At the equator grid variation is null: NOAA prints NaN. |
noaa-table-3field | Longitude 240 is −120: grid variation is declination plus longitude, wrapped to −180 to 180. |
noaa-points-1field | Near the north magnetic pole: horizontal intensity under 2000 nT, blackout unreliable, declination still given. |
noaa-points-2field | Horizontal intensity under 6000 nT: blackout caution. |
reference-north-pole-2026field | The geographic north pole: longitude is undefined, so NOAA takes the limit along longitude 0. Blackout unreliable. |
reference-south-pole-2026field | The geographic south pole, along longitude 0. |
reference-first-instantfield | 2025.0, the model's first instant. |
reference-last-instantfield | 2030.0, the model's last instant: still computed. |
reference-grid-variation-55nfield | Exactly 55° N, where grid variation starts: declination minus longitude. |
reference-grid-variation-55sfield | Exactly 55° S: declination plus longitude. |
reference-date-2025-01-01decimalYear | 1 January is a whole year. |
reference-date-2028-02-29decimalYear | A leap day: 2028 + 59/366. |
reference-date-2028-12-31decimalYear | The last day of a leap year: 2028 + 365/366. |
reference-date-2000-03-01decimalYear | 2000 was a leap year: 2000 + 60/366. |
reference-date-2100-03-01decimalYear | 2100 isn't a leap year: 2100 + 59/365. |
reference-date-2027-02-29decimalYear | Doesn't exist: invalidInput. |
invalid-before-2025field | Before the model's first instant: outOfRange, as NOAA's software refuses it. |
invalid-after-2030field | After 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.
| Operation | Cases |
|---|---|
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.
| Field | Tolerance |
|---|---|
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
| Implementation | Status |
|---|---|
| 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
| Standard | The 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 |
| Coefficients | WMM.COF for WMM2025NOAA NCEI. Copied to /wmm/sources/WMM.COF · Public domain |
| Test values | WMM2025_TEST_VALUES.txt, Table 6 of the reportNOAA NCEI. Cases noaa-table-1 to 12. Copied to /wmm/sources/ · Public domain |
| Test values | WMM2025_TestValues.txt, in the coefficient zipNOAA NCEI. Cases noaa-points-1 to 100. Copied to /wmm/sources/ · Public domain |
| Reference program | WMM2025 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 |