Skip to main content

Crate kinavis_wmm

Crate kinavis_wmm 

Source
Expand description

World Magnetic Model as a MagneticModel for the KINAVIS crates.

WMM is the standard main-field model: a spherical harmonic expansion to degree 12 with linear secular variation, issued every five years by NOAA/NCEI and the British Geological Survey. Magnetic variation (declination) is the angle between its horizontal component and true north.

The wmm2025 feature embeds the WMM2025 coefficients (valid 2025.0–2030.0) and implements the kernel’s MagneticModel port. A date outside the validity interval returns KernelError::OutsideValidity instead of extrapolating: coefficients five years out of date can be a degree off.

use kinavis_kernel::environment::MagneticModel;
use kinavis_kernel::{Civil, Distance, GeodeticPoint, Height, Instant, Position, Utc};
use kinavis_wmm::Wmm;

// Off Ushant, midsummer 2026.
let point = GeodeticPoint::new(
    Position::from_degrees(48.5, -5.5)?,
    Height::above_mean_sea_level(Distance::ZERO),
);
let when = Instant::<Utc>::from_civil(Civil::date(2026, 6, 21))?;

let field = Wmm::WMM2025.field_at(point, when)?;
assert_eq!(format!("{:.1}", field.declination()), "0.4°W");
assert!(field.horizontal_intensity_nanotesla() > 20_000.0);

// Before the epoch the model has nothing to say.
let too_early = Instant::<Utc>::from_civil(Civil::date(2024, 12, 31))?;
assert!(Wmm::WMM2025.field_at(point, too_early).is_err());

§Accuracy

The synthesis reproduces NOAA’s hundred published test values to better than 0.01 nT per component and 0.01° in declination and inclination — the resolution of the published values. The model itself has a global RMS error of about 0.5° in declination, larger near the magnetic poles where the horizontal field is weak. Local anomalies, ship’s magnetism and space weather are not modelled.

§Height

The model takes height above the WGS-84 ellipsoid. Heights above MSL or chart datum differ by the geoid undulation (≤ ~100 m), which changes the field by less than 3 nT, two orders below the model error; every Height is therefore used as is, whatever its datum.

§Feature flags

  • std (default) — standard library maths in the kernel.
  • libm — for no_std targets: --no-default-features --features libm.
  • wmm2025 (default) — embeds the WMM2025 coefficients as Wmm::WMM2025. Without it, only the synthesis and Wmm::new for caller-supplied coefficients.

No allocation; builds for bare-metal targets.

Structs§

Coefficient
Gauss coefficient pair with its secular variation.
DecimalYear
Time in the model’s coordinate: decimal year.
Wmm
One issue of the World Magnetic Model: coefficients, epoch, name.

Constants§

MAX_COEFFICIENTS
Maximum number of coefficients: every (n, m) with 1 ≤ m ≤ n up to MAX_DEGREE.
MAX_DEGREE
Maximum degree and order of the expansion.
REFERENCE_RADIUS_METRES
Geomagnetic reference radius a, in metres.
VALIDITY_YEARS
Validity span of one model issue, in years.