jswhit / pygrib

Python interface for reading and writing GRIB data
https://jswhit.github.io/pygrib
MIT License
328 stars 97 forks source link

pygrib fails to read Rapid Refresh output files #134

Open logi opened 4 years ago

logi commented 4 years ago

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 :-)

jswhit commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 3 years ago

Sent an email to Software.Support@ecmwf.int 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 commented 3 years ago

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

jswhit commented 3 years ago

@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?

logi commented 3 years ago

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 ;-)