1

Using the xarray and cfgrib can open the grib file with the command ds=xr.open_dataset('a.grib',engine='cfgrib').

However, the dimensions of ds sometimes are different from those obtained from the offical.

For example, the dimension of ds should be [time(31),step(16),lon(2576),lat(1280)], but the result obtained from the xarray and cfgrib is [time(31),step(16),value(1661440)].

Is there any ways to solve this problem? Thanks in advance.

Yongwu Xiu
  • 125
  • 1
  • 9
  • do you have an example? my guess would be that the data is in a projection where lat, lon are indexed by value. what does `print(ds)` look like? – Michael Delgado Dec 10 '21 at 03:26
  • Hi, Michael @Michael. Yeah, the lon, lat are indexed by values, such as `latitude (values); longitude (values); Variable(time, values)`. But how do I plot the variable? In other language, such as NCL, the dimension of the Variable is (time,lon,lat) – Yongwu Xiu Dec 10 '21 at 03:35
  • see the xarray docs on [working with multidimensional coordinates](//xarray.pydata.org/en/stable/examples/multidimensional-coords.html), as well as the docs on [other related libraries](//xarray.pydata.org/en/stable/getting-started-guide/faq.html#what-other-netcdf-related-python-libraries-should-i-know-about). Iris, CDAT, and other libraries provide explicit support for common data patterns in climate and geosciences. But xarray chooses more portability/stability over convenience for a specific domain. If you have a specific plotting question feel free to create an [mre] and ask! – Michael Delgado Dec 10 '21 at 04:16

0 Answers0