Skip to main content

Template3_20

Struct Template3_20 

Source
pub struct Template3_20 {
    pub earth_shape: EarthShape,
    pub ni: u32,
    pub nj: u32,
    pub first_point_lat: i32,
    pub first_point_lon: i32,
    pub resolution_and_component_flags: ResolutionAndComponentFlags,
    pub lad: i32,
    pub lov: i32,
    pub dx: u32,
    pub dy: u32,
    pub projection_centre: ProjectionCentreFlag,
    pub scanning_mode: ScanningMode,
}
Expand description

Grid definition template 3.20 - polar stereographic projection.

§Examples

use std::io::{BufReader, Read};

use grib::def::grib2::template::{Template3_20, param_set};
use grib_template_helpers::TryFromSlice;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut buf = Vec::new();

    let f = std::fs::File::open(
        "testdata/CMC_RDPA_APCP-024-0100cutoff_SFC_0_ps10km_2023121806_000.grib2.xz",
    )?;
    let f = BufReader::new(f);
    let mut f = xz2::bufread::XzDecoder::new(f);
    f.read_to_end(&mut buf)?;

    let mut pos = 0x33;
    let actual = Template3_20::try_from_slice(&buf, &mut pos)?;
    let expected = Template3_20 {
        earth_shape: param_set::EarthShape {
            shape: 6,
            spherical_earth_radius_scale_factor: 0xff,
            spherical_earth_radius_scaled_value: 0xffffffff,
            major_axis_scale_factor: 0xff,
            major_axis_scaled_value: 0xffffffff,
            minor_axis_scale_factor: 0xff,
            minor_axis_scaled_value: 0xffffffff,
        },
        ni: 935,
        nj: 824,
        first_point_lat: 18145030,
        first_point_lon: 217107456,
        resolution_and_component_flags: param_set::ResolutionAndComponentFlags(0b00001000),
        lad: 60000000,
        lov: 249000000,
        dx: 10000000,
        dy: 10000000,
        projection_centre: param_set::ProjectionCentreFlag(0b00000000),
        scanning_mode: param_set::ScanningMode(0b01000000),
    };
    assert_eq!(actual, expected);

    Ok(())
}

Fields§

§earth_shape: EarthShape§ni: u32

Nx - number of points along the x-axis.

§nj: u32

Ny - number of points along the y-axis.

§first_point_lat: i32

La1 - latitude of first grid point.

§first_point_lon: i32

Lo1 - longitude of first grid point.

§resolution_and_component_flags: ResolutionAndComponentFlags§lad: i32

LaD - latitude where Dx and Dy are specified.

§lov: i32

LoV - orientation of the grid (see Note 2).

§dx: u32

Dx - x-direction grid length (see Note 3).

§dy: u32

Dy - y-direction grid length (see Note 3).

§projection_centre: ProjectionCentreFlag§scanning_mode: ScanningMode

Trait Implementations§

Source§

impl Debug for Template3_20

Source§

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

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

impl Dump for Template3_20

Source§

fn dump<W: Write>( &self, parent: Option<&Cow<'_, str>>, pos: &mut usize, output: &mut W, ) -> Result<(), Error>

Perform dumping to output. Read more
Source§

impl GridPointIndex for Template3_20

Source§

fn grid_shape(&self) -> (usize, usize)

Returns the shape of the grid, i.e. a tuple of the number of grids in the i and j directions.
Source§

fn scanning_mode(&self) -> &ScanningMode

Returns ScanningMode used for the iteration.
Source§

fn ij(&self) -> Result<GridPointIndexIterator, GribError>

Returns an iterator over 2D index (i, j) of grid points.
Source§

impl GridShortName for Template3_20

Source§

fn short_name(&self) -> &'static str

Returns the grid type. Read more
Source§

impl LatLons for Template3_20

Available on crate feature gridpoints-proj only.
Source§

type Iter<'a> = IntoIter<(f32, f32)> where Self: 'a

Source§

fn latlons<'a>(&'a self) -> Result<Self::Iter<'a>, GribError>

Computes and returns an iterator over latitudes and longitudes of grid points in degrees. Read more
Source§

impl PartialEq for Template3_20

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 TryFromSlice for Template3_20

Source§

fn try_from_slice(slice: &[u8], pos: &mut usize) -> TryFromSliceResult<Self>

Performs reading. The pos argument is a variable storing the starting position for reading within the slice. Read more
Source§

impl Eq for Template3_20

Source§

impl StructuralPartialEq for Template3_20

Auto Trait Implementations§

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<T> DumpField for T
where T: Dump,

§

fn dump_field<W>( &self, name: &str, parent: Option<&Cow<'_, str>>, _doc: &str, pos: &mut usize, output: &mut W, ) -> Result<(), Error>
where W: Write,

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.

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.