Function grib::utils::compute_gaussian_latitudes

source ·
pub fn compute_gaussian_latitudes(
    div: usize,
) -> impl Iterator<Item = Option<f64>>
Expand description

Computes Gaussian latitudes in radians.

The Newton-Raphson method is used for the computation. If the computation does not converge and no solution is obtained after the predefined number of iterations (10), the solution will have the value None.

§Examples

let mut iter = grib::utils::compute_gaussian_latitudes(0);
assert_eq!(iter.next(), None);

let mut iter = grib::utils::compute_gaussian_latitudes(1);
assert_eq!(iter.next(), Some(Some(0.0)));
assert_eq!(iter.next(), None);

let mut iter = grib::utils::compute_gaussian_latitudes(2);
assert!((iter.next().unwrap().unwrap() - (1.0 / 3.0_f64.sqrt()).asin()).abs() < 1e-15);
assert!((iter.next().unwrap().unwrap() - (-1.0 / 3.0_f64.sqrt()).asin()).abs() < 1e-15);
assert_eq!(iter.next(), None);