pygrib icon indicating copy to clipboard operation
pygrib copied to clipboard

pygrib fails to read Rapid Refresh output files

Open logi opened this issue 4 years ago • 7 comments

I am doing exactly as described in the merged pull request https://github.com/jswhit/pygrib/pull/35 by @bschwedler nearly 4 years ago, reading Rapid Refresh output files, but opening the files is failing with this error repeated about 3300 times:

Unable to find template gridDefinitionSection from grib2/template.3.32769.def

Should pygrib not come with these template files? If not, do they exist anywhere and might it be worth documenting where and how to get them? Or at least to tell me :-)

logi avatar Apr 02 '20 13:04 logi

those template files are part of the eccodes library - they exist in /usr/local/share/eccodes/definitions/grib2 (if eccodes is installed in /usr/local). If you can create the correct template file (based on info here https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-32769.shtml) and drop it in there, it might work

jswhit avatar Nov 27 '20 14:11 jswhit

I added a template.3.32769.def file containing this

# (C) Copyright 2005- ECMWF.

# TEMPLATE 3.32769, Rotated Latitude/longitude (Arakawa Non-E Staggered)

include "grib2/template.3.shape_of_the_earth.def";
include "grib2/template.3.latlon.def";

and added this line to section.3.def

 "rotated_arakawa_none"       = { gridDefinitionTemplateNumber=32679; PLPresent=0; }

in the concept gridType structure, and now it reads the files. I doubt the latlons method will work correctly with more work though.

jswhit avatar Nov 27 '20 14:11 jswhit

If you don't have permission to add those files, you can copy the directory somewhere can write to, add the files there and then use ECCODES_DEFINITION_PATH to tell eccodes where they are.

jswhit avatar Nov 27 '20 14:11 jswhit

Sent an email to [email protected] about adding support for this grid in eccodes. Will post here if I receive a reply.

Note that pull request #35 is no longer helpful in this case since pygrib isn't using the NCEP g2clib any longer.

jswhit avatar Dec 19 '20 15:12 jswhit

version 2.1.2 (PR #169) will have this workaround included (if you install a binary wheel with pip)

jswhit avatar Dec 22 '20 04:12 jswhit

@logi would you mind installing a binary wheel for 2.1.2 using pip install and see if you then can read a RAP grib file?

jswhit avatar Dec 22 '20 18:12 jswhit

I ended up using a lower-level library and constructing the projection and the lat/lon values by hand and don't want to ever touch that code again... However, I'll give this change a spin for the benefit of mankind ;-)

logi avatar Dec 30 '20 09:12 logi