Skip to content

Latest commit

 

History

History
88 lines (56 loc) · 3.16 KB

README.md

File metadata and controls

88 lines (56 loc) · 3.16 KB

gribberish python

Read GRIB 2 files with Python. This package is a Python wrapper around the Rust library gribberish.

There is support for xarray and kerchunk integration, as well as just reading the data directly into numpy arrays.

Installing

With pip

pip install gribberish

or install with git:

pip install -e "gribberish@git+https://github.com/mpiannucci/gribberish.git#egg=gribberish\&subdirectory=python"

With optional xarray support:

pip install "gribberish[xarray]"

With optional kerchunk support:

pip install "gribberish[kerchunk]"

With optional zarr support:

pip install "gribberish[zarr]"

Manually

With pip:

pip install -e .

or with maturin

pip install maturin
maturin develop

Usage

This module can be used directly, or via xarray.

For direct usage, see dump_dataset.py or compare with eccodes usage and performance in bench.py.

xarray

To use with xarray, simply specify the gribberish backend when loading a grib2 file:

import xarray as xr
ds = xr.open_dataset('gfswave.20210826.t12z.atlocn.0p16.f000.grib2', engine='gribberish')

Some examples are provided:

  • xarray_usage.ipynb shows how to load a single GFS Wave model grib2 file
  • hrrr.ipynb shows how to load a single HRRR model grib2 file. There are multiple time and vertical coordinates in this file so it shows how the full dataset can be loaded or filtered down to only what is desired. It also demonstrates how to select data at a given point in space using the non regular gridded coordinate system.
  • nwps.ipynb shows how to load an entire NWPS model output that is distributed in a single grib2 file.
  • gfs.ipynb shows how to load a single GFS grib2 output file.
  • read_radar.ipynb shows how to load a single radar file from a single uncompressed MRMS grib2 file.

kerchunk

This package also supports building virtual datasets with kerchunk. Two examples are provided:

  • kerchunk_gefs_wave.ipynb shows how to build a single virtual dataset from an entire GEFS Wave Ensemble model run (30 ensemble members, 384 hour time horizon)
  • kerchunk_hrrr_subhourly.ipynb shows how to build a single virtual dataset from an entire HRRR subhourly surface model run. This results in a virtual dataset with data at 15 minute time intervals over the following 18 hours.

zarr

This package also supports use with zarr for reading unmodified GRIB2 messages (arrays) as chunks using the gribberish.zarr.GribberishCodec codec. This usually will not be used directly, but with VirtualiZarr or kerchunk

Examples to come soon.