pub struct GRIB2Reader {
pub packets: RefCell<Vec<Grib2Sections>>,
pub idxs: Vec<Grib2SectionLocations>,
}Expand description
§GRIB2 Reader
§Description
This class reads a GRIB2 file and returns a list of GRIB2 products.
Implements the FeatureReader trait
§Usage
The methods you have access to:
GRIB2Reader::new: Create a new GRIB2ReaderGRIB2Reader::from_idx: Create a GRIB2Reader with filtered .idx file data (seeparse_idxandparsed_idx_from_url)GRIB2Reader::get_data: Get the Vector MultiPoint dataGRIB2Reader::get_feature: Get the VectorFeature data
Associated methods that are useful:
- [
fetch_gfs_data]: Fetch ATMOS or WAVE GFS data. parsed_idx_from_url: Given an input URL pointing to an IDX file, parse the sectionsparse_idx: Given an input string of an IDX file, parse the sections
§The recommended way to parse grib files is to filter out what you want:
use gistools::{parsers::{BufferReader, FeatureReader}, readers::{parse_idx, GRIB2Reader}};
use std::{fs, path::PathBuf};
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
path.push("tests/readers/grib2/fixtures/ref_sec0.gdas.t12z.pgrb2.1p00.anl.75r.grib2.txt");
// parse the .idx file and apply a filter that we only need 3 sections
let idx_data = fs::read_to_string(path).unwrap();
let sections = parse_idx(
idx_data,
vec![":DZDT:0.01 mb:".into(), ":TMP:0.4 mb:".into(), ":ABSV:0.4 mb:anl:".into()],
None,
);
// grab the grib2 file itself building with the filtered IDX sections
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
path.push("tests/readers/grib2/fixtures/ref_sec0.gdas.t12z.pgrb2.1p00.anl.75r.grib2");
let bytes = std::fs::read(path.clone()).unwrap();
let grib2_reader = GRIB2Reader::from_idx(&BufferReader::from(bytes), sections);
let features: Vec<_> = grib2_reader.iter().collect();
assert_eq!(features.len(), 1);§Parsing the entire grib file:
use gistools::{parsers::{BufferReader, FeatureReader}, readers::GRIB2Reader};
use std::{fs, path::PathBuf};
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
path.push("tests/readers/grib2/fixtures/ref_simple_packing.grib2");
let bytes = fs::read(path.clone()).unwrap();
let grib2_reader = GRIB2Reader::new(BufferReader::from(bytes).into(), vec![]);
let features: Vec<_> = grib2_reader.iter().collect();
assert_eq!(features.len(), 1);§Links
Fields§
§packets: RefCell<Vec<Grib2Sections>>The GRIB2 packets
idxs: Vec<Grib2SectionLocations>The list of section locations
Implementations§
Source§impl GRIB2Reader
impl GRIB2Reader
Sourcepub fn new<T: Reader>(
readers: GRIB2ReaderInput<T>,
idxs: Vec<Grib2SectionLocations>,
) -> Self
pub fn new<T: Reader>( readers: GRIB2ReaderInput<T>, idxs: Vec<Grib2SectionLocations>, ) -> Self
Sourcepub fn from_idx<T: Reader>(
source: &T,
idxs: Vec<Grib2SectionLocations>,
) -> GRIB2Reader
pub fn from_idx<T: Reader>( source: &T, idxs: Vec<Grib2SectionLocations>, ) -> GRIB2Reader
Sourcepub fn get_data(&self) -> Option<VectorMultiPoint>
pub fn get_data(&self) -> Option<VectorMultiPoint>
Get the Vector Point feature data
Sourcepub fn get_feature(&self) -> Option<GRIB2VectorFeature>
pub fn get_feature(&self) -> Option<GRIB2VectorFeature>
Get the Vector Point feature
Trait Implementations§
Source§impl Clone for GRIB2Reader
impl Clone for GRIB2Reader
Source§fn clone(&self) -> GRIB2Reader
fn clone(&self) -> GRIB2Reader
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for GRIB2Reader
impl Debug for GRIB2Reader
Source§impl FeatureReader<Vec<Grib2ProductDefinition>, Map<String, ValueType>, Map<String, ValueType>> for GRIB2Reader
A feature reader trait with a callback-based approach
impl FeatureReader<Vec<Grib2ProductDefinition>, Map<String, ValueType>, Map<String, ValueType>> for GRIB2Reader
A feature reader trait with a callback-based approach
Source§type FeatureIterator<'a> = GRIB2Iterator<'a>
type FeatureIterator<'a> = GRIB2Iterator<'a>
The Feature Reader should implement an iterator of some kind
Source§fn iter(&self) -> Self::FeatureIterator<'_>
fn iter(&self) -> Self::FeatureIterator<'_>
All readers have an iter function that returns a Iterator struct
Auto Trait Implementations§
impl !Freeze for GRIB2Reader
impl !RefUnwindSafe for GRIB2Reader
impl Send for GRIB2Reader
impl !Sync for GRIB2Reader
impl Unpin for GRIB2Reader
impl UnwindSafe for GRIB2Reader
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more