-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid try/except block in scan_grib
?
#446
Comments
We added this in #364 |
(Sorry for the delay. I am currently in GTC+2.) @emfdavid: Thanks for the reply. Let me understand you completely. When you say, "I see these errors when reading HRRR SUB Hourly grib2 files," are you saying you see I am also running with subhourly GRIB2 files, and I see Traceback
(Note, this is with Python 3.10, cfgrib 0.9.11.0, and eccodes 1.7.0.) I never see (Incidentally, I know that there is a PR currently in to |
I only ever see the
The first option pushes the changes to cfgrib (which is coming in ecmwf/cfgrib#371, but who knows when), and the second option hacks If you like, I can put together a PR that essentially deals with this edge case, something like: coord2 = {"latitude": "latitudes", "longitude": "longitudes", "step": "step:int"}.get(coord, coord)
try:
x = m.get(coord2)
except eccodes.WrongStepUnitError as e:
logger.warning(
"Ignoring coordinate '%s' for varname '%s', raises: eccodes.WrongStepUnitError(%s)",
coord2,
varName,
e,
)
continue |
That is cool - I poked around for a while and gave up. If I understand correctly, we can put your patch in place in kerchunk now, and it should be forward compatible with cfgrib after the problem is corrected there. Then we can leave your patch in kerchunk in place until most users are up to date with cfgrib and eccodes updates. |
Sounds like a plan! |
I just create PR #450. |
See comments in #450 for updates. TL;DR: This bug only comes up because of changes in the most recent versions of |
In the
kerchunk.grib2.scan_grib()
function, there is a loop when processing the coordinate variables for a message, and there is atry
/except
block in this loop:kerchunk/kerchunk/grib2.py
Lines 258 to 267 in a0c4f3b
that appears to be intended to skip coordinate variables that produce errors when retrieving the coordinate information with
cfgrib
(them
object is acfgrib.cfmessage.CfMessage
object). However, exceptions produced in thistry
block never get caught becausecfgrib
only ever raisesValueError
orAssertionError
exceptions (at least with the recent versions ofcfgrib
).Should this
try
block be modified to catchValueError
exceptions instead?The text was updated successfully, but these errors were encountered: