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.

Unable to read NCEP MRMS grib2 files

See original GitHub issue

I’m on OSX and have installed xarray and cfgrib through Anaconda/conda-forge:

$ python --version
Python 3.8.0
$ conda env export
name: mypy3env
channels:
  - conda-forge
  - defaults
dependencies:
...
  - cfgrib=0.9.7.3=py_0
...
  - eccodes=2.14.1=ha74ff94_3
...
  - xarray=0.14.1=py_0

I’m trying to work with NCEP MultiRadar MultiSensor grib2s such as in https://mrms.ncep.noaa.gov/data/2D/MergedReflectivityQCComposite/ , and always getting the following output/traceback reading files in:

$ cfgrib to_netcdf MRMS_MergedReflectivityQCComposite_00.50_20191209-210032.grib2
libpng warning: Application built with libpng-1.4.12 but running with 1.6.37
ECCODES ERROR   :  unable to get values as double array (Decoding invalid)
ECCODES ERROR   :  unable to create iterator
Traceback (most recent call last):
  File "/Users/dian/work/anaconda/envs/mypy3env/bin/cfgrib", line 10, in <module>
    sys.exit(cfgrib_cli())
  File "/Users/dian/work/anaconda/envs/mypy3env/lib/python3.8/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/Users/dian/work/anaconda/envs/mypy3env/lib/python3.8/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/Users/dian/work/anaconda/envs/mypy3env/lib/python3.8/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/dian/work/anaconda/envs/mypy3env/lib/python3.8/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/dian/work/anaconda/envs/mypy3env/lib/python3.8/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/Users/dian/work/anaconda/envs/mypy3env/lib/python3.8/site-packages/cfgrib/__main__.py", line 56, in to_netcdf
    ds = xr.open_mfdataset(inpaths, engine=engine)
  File "/Users/dian/work/anaconda/envs/mypy3env/lib/python3.8/site-packages/xarray/backends/api.py", line 900, in open_mfdataset
    datasets = [open_(p, **open_kwargs) for p in paths]
  File "/Users/dian/work/anaconda/envs/mypy3env/lib/python3.8/site-packages/xarray/backends/api.py", line 900, in <listcomp>
    datasets = [open_(p, **open_kwargs) for p in paths]
  File "/Users/dian/work/anaconda/envs/mypy3env/lib/python3.8/site-packages/xarray/backends/api.py", line 516, in open_dataset
    store = backends.CfGribDataStore(
  File "/Users/dian/work/anaconda/envs/mypy3env/lib/python3.8/site-packages/xarray/backends/cfgrib_.py", line 43, in __init__
    self.ds = cfgrib.open_file(filename, **backend_kwargs)
  File "/Users/dian/work/anaconda/envs/mypy3env/lib/python3.8/site-packages/cfgrib/dataset.py", line 628, in open_file
    return Dataset(*build_dataset_components(index, read_keys=read_keys, **kwargs))
  File "/Users/dian/work/anaconda/envs/mypy3env/lib/python3.8/site-packages/cfgrib/dataset.py", line 542, in build_dataset_components
    dims, data_var, coord_vars = build_variable_components(
  File "/Users/dian/work/anaconda/envs/mypy3env/lib/python3.8/site-packages/cfgrib/dataset.py", line 476, in build_variable_components
    geo_dims, geo_shape, geo_coord_vars = build_geography_coordinates(index, encode_cf, errors)
  File "/Users/dian/work/anaconda/envs/mypy3env/lib/python3.8/site-packages/cfgrib/dataset.py", line 357, in build_geography_coordinates
    latitudes = np.array(first['distinctLatitudes'])
  File "/Users/dian/work/anaconda/envs/mypy3env/lib/python3.8/site-packages/cfgrib/messages.py", line 178, in __getitem__
    return super(ComputedKeysMessage, self).__getitem__(item)
  File "/Users/dian/work/anaconda/envs/mypy3env/lib/python3.8/site-packages/cfgrib/messages.py", line 130, in __getitem__
    return self.message_get(item)
  File "/Users/dian/work/anaconda/envs/mypy3env/lib/python3.8/site-packages/cfgrib/messages.py", line 92, in message_get
    values = eccodes.codes_get_array(self.codes_id, item, key_type)
  File "/Users/dian/work/anaconda/envs/mypy3env/lib/python3.8/site-packages/cfgrib/bindings.py", line 365, in codes_get_array
    size = codes_get_size(handle, key)
  File "/Users/dian/work/anaconda/envs/mypy3env/lib/python3.8/site-packages/cfgrib/bindings.py", line 216, in codes_get_size
    _codes_get_size(handle, key.encode(ENC), size)
  File "/Users/dian/work/anaconda/envs/mypy3env/lib/python3.8/site-packages/cfgrib/bindings.py", line 165, in wrapper
    raise GribInternalError(code)
cfgrib.bindings.GribInternalError: ('Decoding invalid (-13).', -13)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

1reaction
dmfaycommented, Dec 17, 2019

You’re right, I didn’t realize the final exception was ignored 🤦‍♀ Thanks!

1reaction
dmfaycommented, Dec 11, 2019

Will do, thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to read grib2 data with nctoolbox - MATLAB Answers
I grabbed a sample grib2 file. I've used nctoolbox for several years and this is the first time I've run into an issue...
Read more >
Dr. Ryan Lagerquist #BLM #QLM #TLM on Twitter: "Has ...
Has anyone on #WxTwitter read MRMS reflectivity data from grib2 files? I have a summer student trying to do this, and we can't...
Read more >
Climate Prediction Center - wgrib2: Problems
Wgrib2 is trying to read a f77-style binary file (-import_ieee). ... However, either the header is missing or the header has an unexpected...
Read more >
[pyngl-talk] how to use the new MRMS grib codetable
... with PyNIO being able to read in an un-gzipped version of the MRMS data file (I ... The MRMS data from NCEP's...
Read more >
Possible bug in GDAL? - python - Stack Overflow
The change log for 2.4.0 points to several fixes to the GRIB driver. ... read and write missing data values correctly for complex...
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