Skip to main content

Crate grib_reader

Crate grib_reader 

Source
Expand description

Pure-Rust GRIB file reader.

The reader supports GRIB1 and GRIB2 regular geographic grids, GRIB2 rotated latitude/longitude, regular Gaussian, and common projected grids, simple and complex and IEEE packing, multi-field bitmap reuse, bounded allocation, and optional image-backed and CCSDS packing codecs.

Missing grid points from bitmaps and embedded complex-packing codes decode as NaN. Complex-packing substitute metadata remains available through ComplexPackingParams::primary_missing_substitute and ComplexPackingParams::secondary_missing_substitute for callers that need producer-specific replacement values.

§Example

use grib_reader::GribFile;

let file = GribFile::open("gfs.grib2")?;
println!("messages: {}", file.message_count());

for msg in file.messages() {
    println!(
        "  {} {:?} {:04}-{:02}-{:02}T{:02}:{:02}:{:02}Z",
        msg.parameter_name(),
        msg.grid_shape(),
        msg.reference_time().year,
        msg.reference_time().month,
        msg.reference_time().day,
        msg.reference_time().hour,
        msg.reference_time().minute,
        msg.reference_time().second,
    );
}

let data = file.message(0)?.read_data_as_f64()?;
println!("shape: {:?}", data.shape());

Re-exports§

pub use data::DecodeSample;

Modules§

data
Data Section (Section 7) decoding.
error
grib1
GRIB Edition 1 parsing.
grid
indicator
Section 0: Indicator Section parsing for GRIB1 and GRIB2.
metadata
parameter
product
sections
GRIB2 section scanning and logical field indexing.

Structs§

AlbersEqualAreaGrid
Template 3.31: Albers equal-area grid.
AnalysisOrForecastTemplate
Product Definition Template 4.0: analysis or forecast at a horizontal level.
BinaryDataSection
CcsdsBlockSize
Number of samples in a CCSDS/AEC coding block.
CcsdsFlags
CCSDS/AEC option mask stored by data representation template 5.42.
CcsdsPackingParams
Validated parameters for CCSDS 121.0 packing (template 5.42).
ComplexPackingParams
Parameters for complex packing (Templates 5.2 and 5.3).
DerivedForecastTemplate
Product Definition Template 4.2: forecast derived from all ensemble members.
DerivedStatisticalProcessTemplate
Product Definition Template 4.12: derived ensemble forecast over a time interval.
EnsembleStatisticalProcessTemplate
Product Definition Template 4.11: individual ensemble forecast over a time interval.
FixedSurface
A fixed surface from Product Definition templates.
Grib1ProductDefinition
GRIB1 product definition metadata.
Grib1SecondOrderPackingParams
Validated parameters for standard GRIB1 grid-point second-order packing.
GribFile
A GRIB file containing one or more logical fields.
GribFileBuilder
Builder for opening GRIB data with explicit scanning, allocation, and center-defined metadata policies.
GridDescription
Identification
Section 1: Identification Section.
IeeePackingParams
Parameters for IEEE floating-point packing (Template 5.4).
IndividualEnsembleForecastTemplate
Product Definition Template 4.1: individual ensemble forecast at a point in time.
Jpeg2000PackingParams
Parameters for JPEG 2000 code stream packing (Template 5.40).
LambertConformalGrid
Template 3.30: Lambert conformal grid.
LatLonGrid
Template 3.0: Regular latitude/longitude grid.
LocalParameterEntry
A user-authored or built-in GRIB2 local table entry.
LocalParameterTable
Owned GRIB2 local parameter table with file-authoring helpers.
MercatorGrid
Template 3.10: Mercator grid.
Message
A single logical GRIB field.
MessageIter
Iterator over fields in a GRIB file.
MessageMetadata
A parsed GRIB field.
OwnedLocalParameterEntry
Owned local table entry for authoring or loading table files.
Parameter
Edition-independent parameter identity.
PercentileForecastTemplate
Product Definition Template 4.6: percentile forecast at a point in time.
PercentileStatisticalProcessTemplate
Product Definition Template 4.10: percentile forecast over a time interval.
PngPackingParams
Parameters for PNG image packing (Template 5.41).
PolarStereographicGrid
Template 3.20: Polar stereographic projection.
PredefinedBitmap
Caller-supplied GRIB1 predefined bitmap.
ProbabilityForecastTemplate
Product Definition Template 4.5: probability forecast at a point in time.
ProbabilityLimit
A signed decimal threshold used by probability product templates.
ProbabilityStatisticalProcessTemplate
Product Definition Template 4.9: probability forecast over a time interval.
ProductDefinition
Section 4: Product Definition Section.
ProjectedGridCore
Fields shared by all supported projected grid templates.
ReferenceTime
Common reference time representation for GRIB fields.
RegularGaussianGrid
Template 3.40: regular Gaussian latitude/longitude grid.
RotatedLatLonGrid
Template 3.1: rotated latitude/longitude grid.
RunLengthPackingParams
Parameters for run-length packing with level values (Template 5.200).
ScaledPackingParams
Scaling parameters shared by GRIB1 and GRIB2 grid-point packing.
ScaledValue
The scale/value pair used to encode a fixed-surface numeric level.
SpatialDifferencingParams
Parameters specific to template 5.3 spatial differencing.
SpatialProcessTemplate
Product Definition Template 4.15: statistical processing over a spatial area.
StatisticalInterval
Time-interval metadata shared by statistically processed product templates.
StatisticalProcessTemplate
Product Definition Template 4.8: statistically processed field over a time interval.
StatisticalTimeRange
Statistical processing descriptor from GRIB2 Product Definition templates with one or more time range specifications.

Enums§

DataRepresentation
GRIB data representation and validated packing parameters.
Error
ForecastTimeUnit
Semantic forecast-time units shared across GRIB editions.
Grib1SecondOrderLayout
Standard GRIB1 second-order group layout.
GridDefinition
Grid definition extracted from Section 3.
IeeePrecision
IEEE floating-point precision from Code Table 5.7.
ParameterTableSource
Source table used to resolve a parameter name.
ProbabilityType
The event whose forecast probability is encoded by templates 4.5 and 4.9.
ProductDefinitionTemplate
Typed GRIB2 Product Definition templates.

Constants§

BUILTIN_LOCAL_PARAMETERS
Built-in local table entries shipped with the crate.
DEFAULT_MAX_AXIS_POINTS
DEFAULT_MAX_DECODED_POINTS
LOCAL_PARAMETER_TABLE_CSV_HEADER
Header for the line-oriented local parameter table CSV format.
MISSING_INCREMENT
Encoded value of a grid increment that the grid section does not give.

Type Aliases§

Result