Error on using xarray open_mfdataset function

雨燕双飞 提交于 2019-12-06 09:23:06

This error message is probably arising because you have two files with the same variables and coordinate values, and xarray doesn't know whether it should stack them together along a new dimension or simply check to make sure none of the values conflict.

It would be nice if explicitly calling open_mfdataset with concat_dim=None disabled all attempts at concatenation. This change should make it into the next release of xarray (v0.9.0).

In the meantime, you can work around this by opening the files individually and merging them explicitly, e.g.,

def open_mfdataset_merge_only(paths, **kwargs):
    if isinstance(paths, basestring):
        paths = sorted(glob(paths))
    return xr.merge([xr.open_dataset(path, **kwargs) for path in paths])

Under the covers, this is basically all that open_mfdataset is doing.

http://xarray.pydata.org/en/stable/generated/xarray.open_mfdataset.html

xarray.open_mfdataset(paths, chunks=None, concat_dim=None, preprocess=None, engine=None, lock=None, **kwargs)

It looks like it needs you to give a concat_dim parameter. It's having problems inferring it from your data.

Dimension to concatenate files along. This argument is passed on to xarray.auto_combine() along with the dataset objects. You only need to provide this argument if the dimension along which you want to concatenate is not a dimension in the original datasets, e.g., if you want to stack a collection of 2D arrays along a third dimension.

Are these 3d arrays that you want to stack along a new, 4th, dimension?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!