Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a grib/grib2 reader #411

Open
jrleeman opened this issue Apr 29, 2017 · 13 comments
Open

Add a grib/grib2 reader #411

jrleeman opened this issue Apr 29, 2017 · 13 comments
Assignees
Labels
Area: IO Pertains to reading data Type: Feature New functionality

Comments

@jrleeman
Copy link
Contributor

A highly requested feature to be able to natively read grib and grib2.

@dopplershift dopplershift added Area: IO Pertains to reading data Type: Feature New functionality labels Apr 29, 2017
@darothen
Copy link

I'd +1 this; currently, you can ingest grib files in xarray via PyNIO. If PyNIO can be updated to Python 3 (see NCAR/pynio#10) then I think all the work is done and everyone (MetPy and beyond) can lean on that.

@dopplershift
Copy link
Member

I want to do a pure Python version regardless, but that's because I'm a broken individual--I like solving the puzzle that is decoding a binary file format.

@darothen
Copy link

@dopplershift you're a brave soul :) I did that for darothen/xbpch and I'll be very happy to not touch any similar job for quite some time.

@dopplershift
Copy link
Member

We'll see how I feel when I get to it...I'm about 50%-60% done on BUFR.

@nawendt
Copy link
Contributor

nawendt commented Sep 26, 2017

This is something I have played around with a little bit and think I could help get finished. I'd be interested in seeing what sort of structure you had in mind for a reader like this.

@dopplershift dopplershift added this to the Spring 2018 milestone Nov 15, 2017
@dopplershift dopplershift removed this from the 0.8 milestone Jan 25, 2018
@dopplershift
Copy link
Member

@nawendt (sorry this response got lost in my inbox) I think the structure I'm looking for is something that integrates well with Xarray. In general this means:

  1. Scanning through the big grib file to see what message are available (forming an index)
  2. Setting up Xarray with the appropriate variables
  3. Getting the binary data from one or more messages when the variable is indexed
  4. Translating GRIB time/coordinate information into proper xarry dimensions and coordinates

@nawendt
Copy link
Contributor

nawendt commented Jan 25, 2018

@dopplershift Thanks. I've also been thinking about how to implement GRIB tables. Dictionaries would be straight-forward, but with some tables referencing other tables for given parameters, that may not work well. Could a database type structure work where tables are linked? I am not too familiar with what is available in that regard. Ultimately, users will have to be able to add their own custom tables no matter what the solution is.

@dopplershift
Copy link
Member

I think probably best to have an explicit function/method call to point to a custom table, rather than any kind of "autoload". It's supporting formatting for those different tables that's going to be the real challenge.

My inclination is to be able to read directly the GRIB tables from the WMO so that we can upgrade easily. If this is too slow for too many tables, we could look at storing in an sqlite database, since that's built into Python. Would probably be best to have MetPy build that locally and cache on a user's machine.

As far as the actual data structures for tables are concerned...maybe sqlite would actually be best. It's probably going to take some experimentation there. Would be a useful first start just to get the table management and access API squared away.

@eliteuser26
Copy link
Contributor

Accessing the Pynio module will not be a good solution as there is no Windows version made of the module. Also according to the Pynio group they won't develop a Windows version which is unfair. The better solution would be to decode the binary data for the Grib/Grib2 files. In this case the data can be converted into an XArray to be used in Metpy if it is possible. I have done the research on this. I am able to decode a Grib2 binary data in Python where I can visualize all the different codes in each table. I started to convert the different tables into dictionaries into a single python file where I can load them as necessary.

@blaylockbk
Copy link
Contributor

Check out this project: https://github.com/ecmwf/cfgrib

@dopplershift dopplershift self-assigned this Aug 21, 2018
@zbruick
Copy link
Contributor

zbruick commented Sep 3, 2019

Is this still on the list to add to MetPy, now that Xarray can handle GRIB? Tangentially, this should probably be an example in the Gallery.

@dopplershift
Copy link
Member

I would still love to have a pure Python reader, but this is certainly less of a priority given that cfgrib exists.

@eliteuser26
Copy link
Contributor

There are still limitations as seen from the documentation. Still no Conda or pip version. It is indicating as work in progress. No Windows version only Linux or MacOS version with Linux. I did find a way to decode the Grib data with Python only but having problems reading Jpeg2000 data. Only supported under OpenJPEG library for Linux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: IO Pertains to reading data Type: Feature New functionality
Projects
None yet
Development

No branches or pull requests

7 participants