Closed juntyr closed 5 days ago
CC @SF-N
Hi @juntyr,
The reason for the problem is that there are two different variables here, whose geographical coordinates do not match (in fact q is on a reduced Gaussian grid, and t is a spectral field, not on a grid at all). Therefore they cannot form a nice hypercube.
% grib_ls ./_mars-bol-webmars-private-svc-blue-007-4a73a881a8d5eead47db9eff2f9935a4-LEW9gw.grib
./_mars-bol-webmars-private-svc-blue-007-4a73a881a8d5eead47db9eff2f9935a4-LEW9gw.grib
edition centre date dataType gridType stepRange typeOfLevel level shortName packingType
2 ecmf 20240811 cf sh 354 hybrid 1 t spectral_complex
2 ecmf 20240811 cf reduced_gg 354 hybrid 1 q grid_ccsds
2 ecmf 20240811 cf sh 354 hybrid 2 t spectral_complex
2 ecmf 20240811 cf reduced_gg 354 hybrid 2 q grid_ccsds
2 ecmf 20240811 cf sh 360 hybrid 1 t spectral_complex
2 ecmf 20240811 cf reduced_gg 360 hybrid 1 q grid_ccsds
2 ecmf 20240811 cf sh 360 hybrid 2 t spectral_complex
2 ecmf 20240811 cf reduced_gg 360 hybrid 2 q grid_ccsds
8 of 8 messages in ./_mars-bol-webmars-private-svc-blue-007-4a73a881a8d5eead47db9eff2f9935a4-LEW9gw.grib
You can, however, use a bit of built-in functionality from cfgrib to split the data into two datasets - one for each variable:
import cfgrib
ds = cfgrib.open_datasets('_mars-bol-webmars-private-svc-blue-007-4a73a881a8d5eead47db9eff2f9935a4-LEW9gw.grib')
Alternatively, to get more control, you can use the backend kwargs to load just selected fields according to their properties, e.g.
fname = "_mars-bol-webmars-private-svc-blue-007-4a73a881a8d5eead47db9eff2f9935a4-LEW9gw.grib"
ds = xr.open_dataset(fname, engine="cfgrib", backend_kwargs={'filter_by_keys': {'gridType': 'reduced_gg'}})
I hope this helps!
What happened?
xarray failed to open a GRIB file with xarray, erroring with a dimension mismatch
What are the steps to reproduce the bug?
Version
0.9.14.0
Platform (OS and architecture)
MacOS, also occurs on Pyodide
Relevant log output
Accompanying data
https://faubox.rrze.uni-erlangen.de/dl/fiVj21QV6ihsyWC8UEZYTT/_mars-bol-webmars-private-svc-blue-007-4a73a881a8d5eead47db9eff2f9935a4-LEW9gw.grib
Organisation
University of Helsinki