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

Are these lines written backwards in this GRIB file, and can cfgrib correct this? #240

Closed blaylockbk closed 2 years ago

blaylockbk commented 3 years ago

I download a GRIB2 file from NOAA's National Blend of Models from NOMADS and plotted some fields. It looks like the data is written backwards in some rows! Can cfgrib fix this and read the lines correctly? Here is an example of 2-m temperature

import xarray as xr
import cfgrib
import urllib

# to reproduce, you'll need to change the URL to a recent path from 
# https://nomads.ncep.noaa.gov/pub/data/nccf/com/blend/prod/
url = 'https://nomads.ncep.noaa.gov/pub/data/nccf/com/blend/prod/blend.20210728/00/core/blend.t00z.core.f001.co.grib2'
file = url.split('/')[-1]
urllib.request.urlretrieve(url, file)

z = xr.open_dataset(
    file,
    engine='cfgrib', 
    backend_kwargs={'filter_by_keys': {'shortName': '2t', 'typeOfLevel': 'heightAboveGround'}}
)

z.t2m.plot(x='longitude', y='latitude')
z.t2m.plot()

image image

blaylockbk commented 2 years ago

Same issue as #276

shahramn commented 2 years ago

This will be fixed in ecCodes v2.25.0