Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading NCEP GFS atmospheric data using Pygrib gives different output with wgrib2 #219

Open
Telemaharry opened this issue Jun 19, 2023 · 1 comment

Comments

@Telemaharry
Copy link

am trying to read NOAA's GFS weather data which is in .grb2 format with Pygrib in PYTHON. An example of the data can be found https://nomads.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/gfs.20230610/06/atmos/gfs.t06z.pgrb2.0p25.f000
The issue is that Pygrib output a 721 X 1440 array for the wind data.

I converted the file to NetCDF using wgrib2 (https://www.cpc.ncep.noaa.gov/products/wesley/wgrib2/netcdf.html) and the output of the .nc file is 1440 X 721.

I did a workaround with the following code and the output from pygrib and wgrib2 are now the same. Is this normal? I just wanted to make sure the output from Pygrib is consistent with that of wgrib2.

import pygrib
import numpy as np

file_name = 'my_grib_file.grb2'

wind_data = pygrib.open(file_name)
UGRD_950mb = wind_data[1].values
UGRD_1000mb = UGRD_1000mb.T
UGRD_1000mb = np.flip(UGRD_1000mb,1)

@jswhit
Copy link
Owner

jswhit commented Jul 15, 2023

wgrib2 is returning the data in fortran (column major) order, while pygrib is returning it in c order (row major). See https://en.wikipedia.org/wiki/Row-_and_column-major_order

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants