Skip to content

SphericalHarmonicCoefficients

Defined in: mod.rs:199

Available on crate feature alloc only.

pub struct SphericalHarmonicCoefficients

A static, fully normalized spherical-harmonic coefficient set with its constants and source metadata.

Pure data: it evaluates nothing. Build a SphericalHarmonicField over it to evaluate a degree × order window; several fields share one set through Arc. It is deliberately not Clone (a set is shared, up to 38 MB for degree 2190, never duplicated) and not PartialEq (bitwise equality of the arrays is the wrong notion of “same model”: the same EGM2008 from two distributors can differ in the last bit).

fn from_icgem(text: &str, max_degree: Option<usize>) -> [Result<Self, IcgemParseError>](https://doc.rust-lang.org/std/result/enum.Result.html)

Parse a static ICGEM .gfc text, keeping degrees ≤ max_degree (None: everything the file has).

See IcgemParseError for what is rejected. With a cap the parser stops at the line that completes the requested triangle and returns IcgemParseError::DegreeUnavailable if the file has fewer degrees than asked for. The whole text must already be in memory; on std, from_icgem_reader(Self::from_icgem_reader) avoids that.


fn from_icgem_reader(reader: impl std::io::BufRead, max_degree: Option<usize>) -> [Result<Self, IcgemFileError>](https://doc.rust-lang.org/std/result/enum.Result.html)

Available on crate feature std only.

Parse a static ICGEM .gfc stream line by line, keeping degrees ≤ max_degree (None: everything the file has).

Reading stops once the requested triangle is complete, so a 70×70 request on the degree-2190 EGM2008 file (~132 MB of text, 2.4 M coefficients) reads the header plus ~2600 records and allocates the 2556-entry arrays — neither the rest of the file nor the 38 MB full set is ever in memory.


fn from_icgem_file(path: &std::path::Path, max_degree: Option<usize>) -> [Result<Self, IcgemFileError>](https://doc.rust-lang.org/std/result/enum.Result.html)

Available on crate feature std only.

Open a static ICGEM .gfc file and parse it with from_icgem_reader(Self::from_icgem_reader).


fn from_normalized_coefficients(gm_km3_s2: f64, radius_km: f64, max_degree: usize, coefficients: &[(usize, usize, f64, f64)]) -> [Result<Self, CoefficientError>](https://doc.rust-lang.org/std/result/enum.Result.html)

Build a set from explicit fully normalized coefficients.

coefficients are (n, m, C̄nm, S̄nm); any (n, m) not listed is zero. Degree 0/1 entries are ignored by the evaluator (see module docs).


fn gm(&self) -> f64

Gravitational parameter of the set [km³/s²].

Use this same value for the point-mass term. EGM2008’s GM (398600.4415) differs from WGS-84’s (398600.4418) by 7.5e-10 — only ~0.3 m/day along-track at LEO, but the central term and the harmonics are one model, so do not mix two GMs.


fn radius(&self) -> f64

Reference radius the coefficients are scaled to [km] (not necessarily the WGS-84 equatorial radius).


fn max_degree(&self) -> usize

Highest degree the set carries (every m ≤ n ≤ max_degree is stored).


fn tide_system(&self) -> TideSystem

Permanent-tide convention declared by the source file.


fn model_name(&self) -> Option<&str>

modelname from the source file, if any.


fn coefficient(&self, n: usize, m: usize) -> Option<(f64, f64)>

(C̄nm, S̄nm) for m ≤ n ≤ max_degree, else None.