-
Notifications
You must be signed in to change notification settings - Fork 5
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
Multiple latitude, longitude grids not supported. #27
Comments
Hi @lupemba, Thank you very much for this thorough report! >>> import xarray as xr
>>> ds = xr.load_dataset("multi_grid_data.grib", engine="cfgrib")
skipping variable: paramId==34 shortName='sst'
Traceback (most recent call last):
File "/home/tcarion/miniconda3/lib/python3.9/site-packages/cfgrib/dataset.py", line 660, in build_dataset_components
dict_merge(variables, coord_vars)
File "/home/tcarion/miniconda3/lib/python3.9/site-packages/cfgrib/dataset.py", line 591, in dict_merge
raise DatasetBuildError(
cfgrib.dataset.DatasetBuildError: key present and new value is different: key='latitude' value=Variable(dimensions=('latitude',), data=array([ 90. , 89.5, 89. , 88.5, 88. , 87.5, 87. , 86.5, 86. But I think the behaviour you propose is more advisable. I will try to implement it. In the meantime, a workaround is to filter on the variables: using GRIBDatasets
file_path = "multi_grid_data.grib"
ds_sst = GRIBDataset(file_path; filter_by_values=Dict("cfVarName" => "sst"))
ds_mwp = GRIBDataset(file_path; filter_by_values=Dict("cfVarName" => "mwp")) By doing so, you get 2 properly built datasets. In case you have more than 2 variables, you can also regroup them by filtering on the resolution, for example: ds_corse = GRIBDataset(file_path; filter_by_values=Dict("Nx" => "720"))
ds_high = GRIBDataset(file_path; filter_by_values=Dict("Nx" => "1440")) |
I have a tried to read a .grib file that has variables defined on two different latitude on longitude grid. (link to file https://we.tl/t-varf2JJHwN ) This file has sea surface temperatures on a 0.25 degree X 0.25 degree grid and Mean wave period on a 0.5 degree X 0.5 degree grid.
This causes an error in the
getone
function. I am able to read the file if I simply remove this error using type piracy but this results in some warnings.Example code
Proposal
Can we allow there to be multiple lat and lon dimensions so that this case would result in.
Then
lon2
andlat2
should be added as variables and the dimension of "sst" should be using the second grid.The text was updated successfully, but these errors were encountered: