Skip to content

Igrf

Defined in: mod.rs:28

pub struct Igrf

IGRF (International Geomagnetic Reference Field) model.

Evaluates the geomagnetic field using spherical harmonic expansion.

By default uses built-in IGRF-14 Gauss coefficients (2020 DGRF + 2025 IGRF + SV). Custom coefficients can be injected at runtime via Igrf::from_coefficients.

fn earth() -> Self

Create an IGRF model with built-in IGRF-14 coefficients (degree 13).


fn with_max_degree(max_degree: usize) -> Self

Create an IGRF model truncated to the given maximum degree.

Lower degrees are faster but less accurate. Degree 1 gives a dipole.

Panics if max_degree is 0 or exceeds IGRF_MAX_DEGREE.


fn from_coefficients(epoch_a: GaussCoefficients, epoch_b: GaussCoefficients, sv: GaussCoefficients, max_degree: usize) -> Self

Create an IGRF model with custom coefficient data injected at runtime.

This allows using coefficient sets from different IGRF generations, or coefficients downloaded/parsed externally.

epoch_a and epoch_b define the two bracketing epochs for interpolation. sv contains the secular variation for extrapolation beyond epoch_b.