[GIS] Converting a large set of GRIB2 files to a spreadsheet format

gribgrib-2noaapython

I have a large set of .pgrbf.grb2 files downloaded from the Climate Prediction Center, and I need to run statistical analyses comparing them to data that was produced locally in .csv format. I'm not very familiar with the GRIB2 format, so I'm not really sure how to best go about this.

My dataset from the CPC consisted of ~250 separate files, so I'm trying to script something to easily process them all. (My .csv data was taken every hour and the CPC data is every six hours, so I'll need to ultimately remove most of my data, compare to the relevant CPC data, and then perform the analyses. Getting the CPC data into one large output file would therefore be superb.) I tried using wgrib2 in the below code, but it returns "FATAL ERROR: packing type 40 not supported" for each file (the script is written correctly; manually running wgrib2 <filename> -csv output returns the same error).

#!/bin/bash
FILES=GRIBFiles/*
CNT=0
for f in $FILES
do
    filename="${f##*/}"
    wgrib2 GRIBFiles/"$filename" -csv GRIBFiles/CSVFiles/$CNT.csv
    let "CNT++"
done

I'm also trying pygrib, but I'll be honest: I don't really understand what's going on in the documentation so I don't know how to get the data into a more usable format.

I'll be using various Python modules to conduct the statistical analyses, so as long as the format the data are converted to is general-use (Excel, CSV, etc.) then I'll be able to manipulate it for the statistics.

Best Answer

"FATAL ERROR: packing type 40 not supported"

wgrib2 was compiled without support for jpeg2000 compression (packing 40). You tried reading a grib record that was compressed with jpeg2000.