ecmwf / cfgrib

A Python interface to map GRIB files to the NetCDF Common Data Model following the CF Convention using ecCodes
Apache License 2.0
400 stars 77 forks source link

Problems with NOAA NDFD data #295

Closed dopplershift closed 2 years ago

dopplershift commented 2 years ago

When opening some NDFD (National Digital Forecast Database) data from NOAA like:

from urllib.request import urlopen

import matplotlib.pyplot as plt
import xarray as xr

url = 'https://noaa-ndfd-pds.s3.amazonaws.com/opnl/AR.conus/VP.001-003/ds.temp.bin'
fname = 'forecast.bin'
with open(fname, 'wb') as cache_file:
    cache_file.write(urlopen(url).read())

ds = xr.open_dataset(fname, engine='cfgrib')
plt.imshow(ds.t2m[0])

The result is:

image

This contrasts with the same message opened with pygrib:

import pygrib
grb = pygrib.open(fname)
msg = grb.message(1)
plt.imshow(msg.values)
image

This seems to be caused by the fact that the "alternativeRowScanning" key is not considered at all by cfgrib, and it is set for this data:

>>> print(msg['alternativeRowScanning'])
1
shahramn commented 2 years ago

Which version of the ecCodes library are you using? I just tried the Geoiterator on the first message of the file ds.temp.bin and it looks fine ( I am using ecCodes v2.25.0 )

dopplershift commented 2 years ago

That's interesting. I have eccodes 2.25.0 installed, and I still had problems when going through cfgrib. I'll continue the discussion over on #296 .

iainrussell commented 2 years ago

Fixed with #296