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.

cfgrib not reading multiple accumulated precipitation fields

See original GitHub issue

I have a GRIB2 file from the High-Resolution Rapid Refresh model that includes two accumulated precipitation fields. Here is the output of wgrib2:

1:0:d=2019070100:APCP Total Precipitation [kg/m^2]:surface:0-5 hour acc fcst:
2:320019:d=2019070100:APCP Total Precipitation [kg/m^2]:surface:4-5 hour acc fcst:

As you can see, this file has accumulated precipitation for two different hour ranges: 0-5 hours, and 4-5 hours.

When I read this file with cfgrib (cfgrib.open_datasets), it only shows one of the fields. I wonder if that is because the GRIB message for both is the same name, and so it overwrites the first with the second message when it reads. It appears that cfgrib doesn’t recognize that the two different fields should be two different xarray variables.

image

Is there any way to overcome this, or am I missing something? Thanks for any help.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
blaylockbkcommented, Dec 15, 2020

Thanks! This was the work around for now–open both GRIB messages separately:

xr.open_dataset(FILE, engine='cfgrib', 
                backend_kwargs=dict(read_keys=['stepRange'],
                                    filter_by_keys={'stepRange': '11-12'}))

and

xr.open_dataset(FILE, engine='cfgrib', 
                backend_kwargs=dict(read_keys=['stepRange'],
                                    filter_by_keys={'stepRange': '0-12'}))

would read both variables.

Would be nice if cfgrib could read both in the same open line, like Iain said by extending the dimension.

1reaction
alexamicicommented, Dec 16, 2020

@blaylockbk upcoming version 0.9.9.0 will not require to add read_keys. Thanks for you report!

Read more comments on GitHub >

github_iconTop Results From Across the Web

hrrrb · PyPI
NOTE: When cfgrib reads a grib file with more than one accumulated precipitation fields, it will not read all the fields.
Read more >
Newest 'grib' Questions - Stack Overflow
I'm trying to get data from a GFS APCP (Total Precipitation 'tp' accum), but only can access to time 2. Time 1 have...
Read more >
What is GRIB2? — Herbie 2022.9.0 documentation
There are two command-line tools for looking at GRIB file contents. ... cfgrib works well reading GRIB2 data as xarray datasets.
Read more >
HRRR Download Script Tips
If you have not already, please register as a user before downloading data. ... period of time on multiple nodes (you agreed to...
Read more >
cfgrib: easy and efficient grib file access in xarray - ecmwf
CDM-level API: Dataset and. Variable, inspired to h5netcdf and. netCDF4-Python xarray read-only backend ... and more. PRESENTING CFGRIB.
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