Struct grib::SubMessage
source · pub struct SubMessage<'a, R>(pub SubMessageSection<'a>, pub SubMessageSection<'a>, pub Option<SubMessageSection<'a>>, pub SubMessageSection<'a>, pub SubMessageSection<'a>, pub SubMessageSection<'a>, pub SubMessageSection<'a>, pub SubMessageSection<'a>, pub SubMessageSection<'a>, _);
Tuple Fields§
§0: SubMessageSection<'a>
§1: SubMessageSection<'a>
§2: Option<SubMessageSection<'a>>
§3: SubMessageSection<'a>
§4: SubMessageSection<'a>
§5: SubMessageSection<'a>
§6: SubMessageSection<'a>
§7: SubMessageSection<'a>
§8: SubMessageSection<'a>
Implementations§
source§impl<'a, R> SubMessage<'a, R>
impl<'a, R> SubMessage<'a, R>
pub fn indicator(&self) -> &Indicator
pub fn grid_def(&self) -> &GridDefinition
pub fn prod_def(&self) -> &ProdDefinition
pub fn repr_def(&self) -> &ReprDefinition
pub fn describe(&self) -> String
sourcepub fn ij(&self) -> Result<GridPointIndexIterator, GribError>
pub fn ij(&self) -> Result<GridPointIndexIterator, GribError>
Computes and returns an iterator over (i, j)
of grid points.
The order of items is the same as the order of the grid point values,
defined by the scanning mode (ScanningMode
)
in the data.
This iterator allows users to perform their own coordinate calculations for unsupported grid systems and map the results to grid point values.
§Examples
use std::{
fs::File,
io::{BufReader, Read},
};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut buf = Vec::new();
let f = File::open("testdata/gdas.t12z.pgrb2.0p25.f000.0-10.xz")?;
let f = BufReader::new(f);
let mut f = xz2::bufread::XzDecoder::new(f);
f.read_to_end(&mut buf)?;
let f = std::io::Cursor::new(buf);
let grib2 = grib::from_reader(f)?;
let mut iter = grib2.iter();
let (_, message) = iter.next().ok_or_else(|| "first message is not found")?;
let mut latlons = message.ij()?;
assert_eq!(latlons.next(), Some((0, 0)));
assert_eq!(latlons.next(), Some((1, 0)));
Ok(())
}
sourcepub fn latlons(&self) -> Result<GridPointIterator, GribError>
pub fn latlons(&self) -> Result<GridPointIterator, GribError>
Computes and returns an iterator over latitudes and longitudes of grid points.
The order of lat/lon data of grid points is the same as the order of the
grid point values, defined by the scanning mode
(ScanningMode
) in the data.
§Examples
use std::{
fs::File,
io::{BufReader, Read},
};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut buf = Vec::new();
let f = File::open("testdata/gdas.t12z.pgrb2.0p25.f000.0-10.xz")?;
let f = BufReader::new(f);
let mut f = xz2::bufread::XzDecoder::new(f);
f.read_to_end(&mut buf)?;
let f = std::io::Cursor::new(buf);
let grib2 = grib::from_reader(f)?;
let mut iter = grib2.iter();
let (_, message) = iter.next().ok_or_else(|| "first message is not found")?;
let mut latlons = message.latlons()?;
assert_eq!(latlons.next(), Some((90.0, 0.0)));
assert_eq!(latlons.next(), Some((90.0, 0.25000003)));
Ok(())
}
Auto Trait Implementations§
impl<'a, R> !RefUnwindSafe for SubMessage<'a, R>
impl<'a, R> !Send for SubMessage<'a, R>
impl<'a, R> !Sync for SubMessage<'a, R>
impl<'a, R> Unpin for SubMessage<'a, R>
impl<'a, R> !UnwindSafe for SubMessage<'a, R>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more