I’m trying to crack into the National Digital Forecast Database (NDFD) GRIB2 files, specifically the unique Local Use Section (in Section 2) containing the Weather Lookup Table unique to each forecast time.
While I have tried using the NOAA MDL’s DeGRIB GUI software, but I’ve had difficulty compiling it’s unix build.
I also need a solution that can be automated (preferably Python-based since that is what the rest of my project is using). I have tried working with pygrib and I can only get so far as to it returning the size of Section 2 of the pertinent message record and no further into Section 2. XArray with cfgrib presumes uniformity for a variable rather than one that varies per GRIB message, nor have I found a resolution with wgrib2 or eecodes.
Are there options in Python or command line UNIX that will permit access to the details within a GRIB2 message’s Section 2?
Sorry so late. There is grib2io which I have contributed a little bit to. It does what you want, as described in this Jupyter notebook.
This is untried, but something like:
import grib2io
msgs = grib2io.open("file.grib2")
# The following selects the first HGT at 500 mb.
msg = msgs.select(shortName="HGT", level="500 mb")[0]
# Section 2 is usually empty.
print(msg.section2)
# Section 2: b''
# Section 3 is a bit more interesting...
print(msg.section3)
# Section 3: [ 0 1038240 0 0 0
# 6 0
# 0 0 0 0 0 1440 721
# 0 -1 90000000 0 48 -90000000 359750000
# 250000 250000 0]
We have pip and conda packages for grib2io. The conda package is in conda-forge and installed by "conda install -c conda-forge grib2io".