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

Error merging and opening .nc files in projections-cmip6.ipynb #7

Open
maxduganknight opened this issue Mar 13, 2024 · 1 comment
Open

Comments

@maxduganknight
Copy link

In running through the projections-cmip6.ipynb file I get an error at the following line:

data_ds = xr.open_mfdataset(f'{DATADIR}cmip6_agg*.nc')

Here's the error:


ValueError Traceback (most recent call last)
Cell In[50], line 1
----> 1 data_ds = xr.open_mfdataset(f'{DATADIR}cmip6_agg*.nc')

File ~/.pyenv/versions/3.12.1/lib/python3.12/site-packages/xarray/backends/api.py:968, in open_mfdataset(paths, chunks, concat_dim, compat, preprocess, engine, lock, data_vars, coords, combine, parallel, join, attrs_file, **kwargs)
955 combined = _nested_combine(
956 datasets,
957 concat_dims=concat_dim,
(...)
963 combine_attrs="drop",
964 )
965 elif combine == "by_coords":
966 # Redo ordering from coordinates, ignoring how they were ordered
967 # previously
--> 968 combined = combine_by_coords(
969 datasets,
970 compat=compat,
971 data_vars=data_vars,
972 coords=coords,
973 join=join,
974 combine_attrs="drop",
975 )
976 else:
977 raise ValueError(
...
(...)
803 combine_attrs=combine_attrs,
804 )

ValueError: Resulting object does not have monotonic global indexes along dimension year

It seems like this may be an issue in the data downloaded from Copernicus. Any suggestions on how to get past this? Thanks

@myneur
Copy link

myneur commented Jun 18, 2024

I had the same problem. Identifying nesting dimensions solved it for me.

data_ds = xr.open_mfdataset(f'{DATADIR}cmip6_agg_*.nc', combine='nested', concat_dim='model')

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