Skip to main content

Grid

Struct Grid 

Source
#[non_exhaustive]
pub struct Grid { pub ni: u32, pub nj: u32, pub earth: Earth, pub south_to_north: bool, pub winds_grid_relative: bool, pub projection: Projection, }
Expand description

A field’s grid: its size, its projection and how its points are ordered.

Points are numbered i + ni · j, i along a row (east on a latitude/longitude grid, +x on a Lambert grid) and j from row to row. Rows run south to north when Grid::south_to_north, else north to south; the reader refuses other scanning modes.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§ni: u32

Points along a row.

§nj: u32

Rows.

§earth: Earth

The figure of the Earth.

§south_to_north: bool

Whether rows run south to north (+j, scanning mode bit 2); otherwise north to south.

§winds_grid_relative: bool

Whether vector components (winds) are along the grid’s x and y axes rather than east and north (flag table 3.3, bit 5).

§projection: Projection

The projection.

Implementations§

Source§

impl Grid

Source

pub fn points(&self) -> u64

The points, ni · nj.

Source

pub fn point_deg(&self, index: u64) -> Option<(f64, f64)>

Grid point index’s latitude (degrees north) and longitude (degrees east, in [0, 360)), or None outside the grid.

Source

pub fn circles_the_earth(&self) -> bool

Whether a latitude/longitude grid’s rows go all the way round the Earth: ni steps of di make 360°, so the point after the last in a row is the row’s first. A step is written in millionths of a degree, so a 1/12° grid’s 4,320 steps of 0.083333° make 359.9986°: the test allows a millionth of a degree a step, for an encoder that truncates.

Source

pub fn index_at(&self, latitude_deg: f64, longitude_deg: f64) -> (f64, f64)

The fractional grid indices (i, j) of a place, such that grid point (⌊i⌋, ⌊j⌋) and its neighbours at +1 surround it; the place may be outside the grid.

Source

pub fn north_to_grid_y_rad(&self, longitude_deg: f64) -> f64

The angle from true north to the grid’s +y axis at a place, clockwise positive, rad: θ = n (λ − λ₀) on a Lambert grid (Snyder eq. 14-4), 0 on a latitude/longitude grid, whose axes point east and north. West of the central meridian θ < 0: the meridians lean toward the cone’s apex, so north is turned toward +x and the grid’s +y west of north.

Source

pub fn earth_relative_wind( &self, u_m_s: f64, v_m_s: f64, longitude_deg: f64, ) -> (f64, f64)

A wind’s east and north components, m/s, from its components as the field gives them: unchanged unless Grid::winds_grid_relative, else turned from the grid’s axes.

On a Lambert grid true north is (−sin θ, cos θ) in grid axes and east (cos θ, sin θ), with θ = n (λ − λ₀), so u_east = u cos θ + v sin θ and v_north = −u sin θ + v cos θ.

Trait Implementations§

Source§

impl Clone for Grid

Source§

fn clone(&self) -> Grid

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Grid

Source§

impl Debug for Grid

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Grid

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Grid

Source§

fn eq(&self, other: &Grid) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Grid

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Grid

Auto Trait Implementations§

§

impl Freeze for Grid

§

impl RefUnwindSafe for Grid

§

impl Send for Grid

§

impl Sync for Grid

§

impl Unpin for Grid

§

impl UnsafeUnpin for Grid

§

impl UnwindSafe for Grid

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.