Editor’s note: Last week, the PyAOS mailing list had a discussion about ways of reading GRIB files using Python on Windows. Here is a synthesis of portions from posts by Scott Collis, Patrick Marsh, Jack Settelmaier, and Bryan Woods. The archives have the full thread; you need to be a member of the mailing list to access the archives.
Q: How do you read GRIB files using Python on a Windows machine?
A: Here are a number of ways of doing so. A number of them are actually non-Python ways of reading GRIB files on Windows (which you could couple to Python via operating system calls from Python), and the rest are either strategies that may work with a Python program or a Python package:
- NOAA Weather and Climate Toolkit: Can readily read GRIB, netCDF, NOMADS, etc. It will convert GRIB to shapefiles, or export to KML, images, etc. It currently has a very limited scripting/command line.
- DeGRIB: Works well, in many cases, and is highly scriptable, but may not be supported going forward.
- ESRI’s ArcGIS Desktop: Starting at version 9.3?, started supporting reading GRIB and CF-compliant netCDF. It’s kind of buried in the geoprocessing code, but given ArcGIS is already built on Python, and is thus highly scriptable, it makes a great bridge decoder/displayer/scripter, that perhaps can be integrated in existing Python code on other platforms. See Page 17 here.
- Browser-based pulls from THREDDS servers: Can translate/pull GRIB/GRIB2 and return in certain formats, KML, etc. or be pumped through IDV; as an example, check out the Access options on this model output stream.
- IDV: Will read GRIB, but its scripting capabilities are limited.
- GDAL: I was told that you can read GRIB data with GDAL, however I never got around to trying.
- Cygwin: If you need scripting capabilities, your best bet is to just do a Cygwin install. From there you need to look into the NCL libraries. PyNio will allow you to read it in Python. NCL reads it natively and has a nice utility to convert it to netCDF.
- pygrib: The pygrib documentation has instructions to building pygrib on Windows using Cygwin.