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.

Metadata inconsistency betweene cfgrib/xarray and pygrib

See original GitHub issue

I am not sure if it’s a cfgrib issue or xarray issue but I will start off here and then move it to xarray if it’s not a cfgrib issue.

I am trying to read one of these files - https://nomads.ncep.noaa.gov/pub/data/nccf/com/cfs/prod/cfs/cfs.20210426/00/6hrly_grib_01/ - let’s assume I want to read this file - -
flxf2021042600.01.2021042600.grb2 and this is the code I have

` import xarray as xr

ds = xr.open_dataset(‘./flxf2021042600.01.2021042600.grb2’,engine=‘cfgrib’,backend_kwargs={‘errors’: ‘ignore’,‘filter_by_keys’: {‘typeOfLevel’: ‘heightAboveGround’}})`

When I print out the value of ds I encounter two issues

  1. I am looking for these three variables - UGRD:10 m above ground:anl:, VGRD:10 m above ground:anl: and TMP:2 m above ground:anl: as indicated in the indx file - https://nomads.ncep.noaa.gov/pub/data/nccf/com/cfs/prod/cfs/cfs.20210426/00/6hrly_grib_01/flxf2021042600.01.2021042600.grb2.idx

I only obtain what it appears to be ugrd and vgrd. Even here it prints out it as u10 and v10. Are u10 and v10 the same as UGRD and VGRD ?

  1. I am unable to obtain TMP completely. When I try to do the same with pygrib I obtain all 3 completely.

Where am I going wrong ?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
winash12commented, Apr 28, 2021

@alexamici I eventually had to go with this

ds1 = xr.open_dataset('./flxf2021042100.01.2021042100.grb2',engine='cfgrib',backend_kwargs={'errors': 'ignore','filter_by_keys': {'shortName': '2t'}})

0reactions
alexamicicommented, Apr 28, 2021

@winash12 cfgrib can’t access variables at 10m at the same time of variables at 2m. You may try filtering by short name 'filter_by_keys': {'shortName': 't2m'}}.

Read more comments on GitHub >

github_iconTop Results From Across the Web

API — pygrib documentation - GitHub Pages
Create a gribmessage instance from a python bytes object representing a binary grib message (the reverse of gribmessage.tostring() ). pygrib. gaulats (nlats)¶.
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