【问题标题】:Error when using xarray's built in interp function with dask将 xarray 的内置 interp 函数与 dask 一起使用时出错
【发布时间】:2019-12-25 14:23:36
【问题描述】:

我正在尝试将 xarray 的 interp 函数与 chunk 函数一起使用,这是一个 dask 数组功能。

http://xarray.pydata.org/en/stable/interpolation.html 的“示例”下的示例为例,我可以很好地使用 interp 函数。我用来执行此操作的简化代码是:

at = xr.tutorial.open_dataset('air_temperature').isel(time=0)

x = np.linspace(240, 300, 100)
z = np.linspace(20, 70, 100)
lat = xr.DataArray(z, dims=['z'], coords={'z': z})
lon = xr.DataArray((x[:, np.newaxis]-270)/np.cos(z*np.pi/180)+270,
                    dims=['x', 'z'], coords={'x': x, 'z': z})

dsi = at.interp(lon=lon, lat=lat)

当我尝试通过以下方式修改上述代码来将此 interp 函数与 xarray 块组合时出现问题:

at = xr.tutorial.open_dataset('air_temperature').isel(time=0)
at = at.chunk({'lat':10})        # added chunking inducing a dask array

x = np.linspace(240, 300, 100)
z = np.linspace(20, 70, 100)
lat = xr.DataArray(z, dims=['z'], coords={'z': z})
lon = xr.DataArray((x[:, np.newaxis]-270)/np.cos(z*np.pi/180)+270,
                    dims=['x', 'z'], coords={'x': x, 'z': z})

dsi = at.interp(lon=lon, lat=lat)

代码在行失败

dsi = at.interp(lon=lon, lat=lat)

我得到的错误是:

ValueError: 不能同时指定 drop_axis 和 new_axis

我认为正在发生的事情是 interp 函数正在替换坐标,而 dask 无法处理这个问题。这是需要在 xarray 中修复的错误还是我做错了什么?

【问题讨论】:

    标签: interpolation dask python-xarray


    【解决方案1】:

    此问题现已解决。事实证明,问题是使用过时的 dask (0.13) 版本引起的。通过更新到 dask 版本 0.24.0,上述错误不再发生。

    请参阅 github 线程以获得更多说明:

    https://github.com/pydata/xarray/issues/3342

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-28
      • 2017-01-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-06
      • 1970-01-01
      相关资源
      最近更新 更多