question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

failed to set key 'endStep' in to_grib

See original GitHub issue

I read the temperature from GFS and tried to write the data to a new GRIB file .

from eccodes import *
import numpy as np
import xarray as xr 
from cfgrib.xarray_to_grib import to_grib

filename = "gfs.2022010500f24"
ds = xr.open_dataset(filename, engine='cfgrib',
                     backend_kwargs={'filter_by_keys': {'typeOfLevel': 'isobaricInhPa', 
                                                        'name'       : 'Temperature'}})

to_grib(ds, 'out1.grib', grib_keys={'edition': 2})

Running the script directly will result in an error

KeyError: 1641340800000000000

following #272 , it works with a warning :

failed to set key 'endStep' to numpy.timedelta64(24,'ns')

and the time information in the grib file is incorrect

1:0:d=2022010500:TMP Temperature [K]:1000 mb:anl:

which should be

542:117403445:d=2022010500:TMP Temperature [K]:1000 mb:24 hour fcst:

Environment: Python 3.8 from conda-forge on centos7

pandas 1.3.4 cfgrib 0.9.9.1 xarray 0.20.1

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jiaobfcommented, Mar 2, 2022

Also, make sure you’re using cfgrib from the master branch - this fix was important but is not yet in a release: 3cc01e3

It works!

1reaction
iainrussellcommented, Mar 1, 2022

Also, make sure you’re using cfgrib from the master branch - this fix was important but is not yet in a release: https://github.com/ecmwf/cfgrib/commit/3cc01e395cd66a376a279c0c603cbedcaeda7f50

Read more comments on GitHub >

github_iconTop Results From Across the Web

Conversion of netcdf file to grib - CDO
Hi As my data contain 21 levels of pressure and has gaussian Grid coordinates . I want to convert it into grib file....
Read more >
pyg2p/README.md at master - GitHub
Console logger level is INFO by default and can be optionally set by using -l (or –loggerLevel) input argument. Possible logger level values...
Read more >
GRIB decoding - ECMWF Confluence Wiki
Status of ECMWF migration to GRIB edition 2 ... The set of keys available changes from one message to another depending ... endStep...
Read more >
GRIB decoding. Computer User Training Course Paul Dando ...
The set of keys available changes from one message to another depending on: - the GRIB edition - the content of the message...
Read more >
Essential Fleet Manager - Issue 5 2021 by Essential ... - Issuu
Under its future fleet strategy, SPIE UK has set itself the target ... 450kgs and four cubic metres plus vehicle-togrid charging technology.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found