magnetic_field
Calculate Earth's magnetic field parameters (declination, inclination, intensity) for any location and time using WMM2025 instead of inaccurate recall.
Instructions
Earth's magnetic field from the official World Magnetic Model 2025.
Call this instead of recalling declination or field values from memory: they require a degree-12 spherical-harmonic synthesis and are not reliably predictable token-by-token.
Args: lat: Geodetic latitude in degrees, -90 to 90. lon: Longitude in degrees, -180 to 180. altitude_km: Height above the WGS84 ellipsoid, -1 to 850 km (WMM validity). Defaults to 0 (sea level). when: ISO date/datetime, a bare decimal year (e.g. "2026.5"), or "now". Defaults to "now" (UTC). Must fall in 2025.0–2030.0.
Returns:
JSON-serializable dict with:
- declination_deg (compass angle off true north, + = east) and
compass_note (nearest named point)
- inclination_deg, total_intensity_nT, horizontal_intensity_nT and the
north/east/down (X/Y/Z) field components in nT
- secular_variation: annual rate of change per component
- query: echoed inputs and the resolved decimal year
- units, model, model_epoch, valid_range, engine, deterministic
The payload's own units map documents the unit of every field.
Raises: ValueError: lat/lon/altitude out of range, or a date outside WMM2025 validity [2025.0, 2030.0).
Deterministic and verifiable: a faithful synthesis of NOAA's WMM2025 that reproduces all 100 of NOAA's own published test values to printed precision. Re-run the open-source core to check any answer: github.com/savecharlie/almanac
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lat | Yes | ||
| lon | Yes | ||
| when | No | ||
| altitude_km | No |