Skip to content

MAGFit: use full WMM2025 model with date and altitude - #373

Open
j-w9 wants to merge 1 commit into
ArduPilot:mainfrom
j-w9:magfit-wmm
Open

j-w9 wants to merge 1 commit into
ArduPilot:mainfrom
j-w9:magfit-wmm

Conversation

@j-w9

@j-w9 j-w9 commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #226.

"Use full WMM with date and altitude" from #81.

wmm.js now evaluates the WMM2025 spherical harmonic model (degree 12, with secular variation) instead of interpolating the 10 deg declination/inclination/intensity tables. The coefficients are embedded from NOAA's WMM2025.COF, which is public domain. The implementation was checked against both published test sets: the 12 points in WMM2025_TEST_VALUES.txt match to the 0.1 nT rounding, and the 100 points in the .COF zip's WMM2025_TestValues.txt (lat -87 to 89, 2025.0 to 2029.5, 0 to 100 km) match to within 0.001 nT.

  • The Location box gains Altitude and Date. Altitude comes from the same source as the location (ORGN, POS or AHRS_ORIGIN_ALT). The date comes from the first GPS week/time in the log, or is the current date if there is none. All can be edited.
  • expected_earth_field() returns the same fields as before (vector in mGauss NED, intensity, declination, inclination), so the fit code is unchanged.

Compared with the tables on three logs, the expected field differs by about 2 mGauss (0.4%) and declination by 0.1 to 0.25 deg, so fitted offsets move by 1 to 2 mGauss. This also moves MAGFit away from the firmware's AP_Declination tables. Logs from before 2025 use the model extrapolated backwards.

Position throughout the flight (the next item on the list) will follow separately on top of this.

Location box

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MAGFit: new WMM2025 model

1 participant