#magnetic #model #wmm #aerospace #wgs84 #geomagnetic #declination

no-std world_magnetic_model

Rust implementation of the NOAA World Magnetic Model (WMM)

5 releases (3 breaking)

0.4.0 Jun 15, 2025
0.3.0 Jun 8, 2025
0.2.0 Jan 19, 2025
0.1.1 Jan 12, 2025
0.1.0 Jan 1, 2025

#60 in Geospatial

Download history 9/week @ 2025-03-04 13/week @ 2025-03-11 6/week @ 2025-03-18 1/week @ 2025-03-25 2/week @ 2025-04-01 2/week @ 2025-04-08 50/week @ 2025-04-29 94/week @ 2025-05-06 143/week @ 2025-05-13 119/week @ 2025-05-20 106/week @ 2025-05-27 221/week @ 2025-06-03 302/week @ 2025-06-10 110/week @ 2025-06-17

746 downloads per month
Used in 2 crates

MIT/Apache

61KB
959 lines

world_magnetic_model

This crate is a Rust implementation of the NOAA World Magnetic Model (WMM), a mathematical representation of the Earth's core magnetic field and its temporal variations.

The crate's interface utilizes the uom (Units of Measurement) crate to represent physical quantities accurately. WMM coefficient files are converted into code constants to eliminate the need for file reading at runtime. This crate is compatible with no_std environments, meaning it does not depend on the Rust standard library and can be used in embedded, bare-metal, or other restricted contexts by relying on the core crate instead. The implemented models include WMM2020 and WMM2025.

Usage

let geomagnetic_field = GeomagneticField::new(
    Length::new::<meter>(100.0), // Height above the WGS 84 ellipsoid
    Angle::new::<degree>(37.03), // WGS 84 latitude (negative values for the Southern Hemisphere)
    Angle::new::<degree>(-7.91), // WGS 84 longitude (negative values for the Western Hemisphere)
    Date::from_ordinal_date(2029, 15)? // Date (15th day of 2029)
)?;

assert_eq!(
    geomagnetic_field.declination().get::<degree>(),
    -0.17367662
);
assert_eq!(
    geomagnetic_field.declination_uncertainty().get::<degree>(),
    0.32549456
);

World Magnetic Model

The World Magnetic Model is the standard model used by the U.S. Department of Defense, the U.K. Ministry of Defence, the North Atlantic Treaty Organization (NATO) and the International Hydrographic Organization (IHO), for navigation, attitude and heading referencing systems using the geomagnetic field. It is also used widely in civilian navigation and heading systems. The model is produced at 5-year intervals, with the current model expiring on December 31, 2029. The current model WMM2025 is produced jointly by the NCEI and the British Geological Survey (BGS). The model, associated software, and documentation are distributed by NCEI on behalf of US National Geospatial-Intelligence Agency and by BGS on behalf of UK Defence Geographic Centre. [source]

Please refer to World Magnetic Model Accuracy, Limitations, and Error Model.

NOAA License Statement

The WMM source code is in the public domain and not licensed or under copyright. The information and software may be used freely by the public. As required by 17 U.S.C. 403, third parties producing copyrighted works consisting predominantly of the material produced by U.S. government agencies must provide notice with such work(s) identifying the U.S. Government material incorporated and stating that such material is not subject to copyright protection.

The WMM model and associated data files are produced by the U.S. Government and are not subject to copyright.

Credit

This work was inspired from geomag-wmm.

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

License: MIT OR Apache-2.0

Dependencies

~3.5MB
~76K SLoC