As geoscientists, one of the hardest things we deal with is how highly dimensional our data are. We deal with systems that are three-dimensional, evolve with time, and have many parameters. Atmospheric science is especially burdened by some of the legacy formats that data were transmitted in like GRIB (GRIdded Binary or General Regularly-distributed Information in Binary form). There are tools out there, but Python’s very popular XArray package is making working with GRIB and dealing with all of its problems as easy as possible.
Ways to Traditionally Deal with GRIB
GRIB has a long history of tools as it has been around for quite awhile. GRIB version 0 is no longer used, version 1 is still in decently wide use, but most everyone is converting to GRIB 2. Tools such as wgrib, GRaDS, GEMPAK, and NWS Degrib have been some of the more popular programs used, but many of these are being sunset in favor of newer and more feature rich programming languages. These tools served us well and are still running on thousands of servers today, but I wouldn’t base a new project around them.
Using Python to Read GRIB Files
Python has been a huge hit in the sciences and it is not secret that we LOVE it and use it for just about everything we can. Unidata, the caretakers of GEMPAK, have invested huge amounts of programmer time in creating MetPy, the Python meteorlogical toolkit. MetPy is great for doing calculations, making special plots, and more. For years there were requests to work with GRIB data, but for a variety of reasons it was decided MetPy wasn’t going to solve that problem.
In fact, tools like PyGrib exist and work very well. CFGrib is another popular package used in Python land. These packages made dealing with GRIB possible. MetPy started settling on XArray Data Sets (analogous to the NetCDF structure developed by Unidata) as a pseudo data-model. The development team has built an accessor for XArray to use and XArray can use CFGrib to create a really nice way to turn messy GRIB into nicer DataSet objects. While it isn’t seamless, it beats about anything else I’ve used for dealing with GRIB. Checkout the MetPy Monday video showing how to read and work with files from the US National Weather Service.
We love open source here and try to contribute when we can! Using open source tools can help take any software project from zero to sixty in so much less time than has ever been possible before. If you’re grappling with a complex data set, need some help making visualizations, or want to run distributed calculations on a cluster, we’re here to help. Don’t hesitate to ask us for a free quote on your next big idea!
- GEARS 2023 Now in November! - September 5, 2023
- Unraveling RTD Sensor Mysteries: The Ultimate Guide to 2, 3, and 4 Wire Variants - June 27, 2023
- In Experts We Trust: The Importance of Trusting Fellow Experts - June 6, 2023