dask - 为什么将 eofs.xarray.Eof 应用于分块数组时会引发错误?
问题描述
我有一个v
带有空间和时间坐标的分块数组,它沿时间维度分块,我希望计算它的经验正交函数。代码如下所示:
import xarray
from eofs.xarray import Eof
v = xarray.DataArray( data=np.zeros((481,77359)), coords={'time':u.time}, dims=['time', 'node'], name='ssh' )
v = v.chunk({'time':24, 'node':77359})
solver = Eof(v)
这会导致以下错误:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
~/.conda/envs/py363/lib/python3.6/site-packages/eofs/standard.py in __init__(self, dataset, weights, center, ddof)
164 # Use the parallel Dask algorithm
--> 165 dsvd = dask.array.linalg.svd(dataNoMissing)
166 A, Lh, E = (x.compute() for x in dsvd)
~/.conda/envs/py363/lib/python3.6/site-packages/dask/array/linalg.py in svd(a, coerce_signs)
961 if coerce_signs:
--> 962 u, v = svd_flip(u, v)
963 return u, s, v
~/.conda/envs/py363/lib/python3.6/site-packages/dask/array/utils.py in svd_flip(u, v, u_based_decision)
541 # Force all singular vectors into same half-space
--> 542 u, v = u * signs, v * signs.T
543 return u, v
~/.conda/envs/py363/lib/python3.6/site-packages/dask/array/core.py in wrapper(self, other)
210 else:
--> 211 return f(self, other)
212
~/.conda/envs/py363/lib/python3.6/site-packages/dask/array/core.py in __mul__(self, other)
2046 def __mul__(self, other):
-> 2047 return elemwise(operator.mul, self, other)
2048
~/.conda/envs/py363/lib/python3.6/site-packages/dask/array/core.py in elemwise(op, *args, **kwargs)
4254 out_ndim = len(
-> 4255 broadcast_shapes(*shapes)
4256 ) # Raises ValueError if dimensions mismatch
~/.conda/envs/py363/lib/python3.6/site-packages/dask/array/core.py in broadcast_shapes(*shapes)
4215 "operands could not be broadcast together with "
-> 4216 "shapes {0}".format(" ".join(map(str, shapes)))
4217 )
ValueError: operands could not be broadcast together with shapes (481, 481) (1, nan)
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
<ipython-input-96-6bb6625c8486> in <module>
----> 1 solver = Eof(v)
~/.conda/envs/py363/lib/python3.6/site-packages/eofs/xarray.py in __init__(self, array, weights, center, ddof)
131 weights=wtarray,
132 center=center,
--> 133 ddof=ddof)
134 # Name of the input DataArray.
135 self._name = array.name
~/.conda/envs/py363/lib/python3.6/site-packages/eofs/standard.py in __init__(self, dataset, weights, center, ddof)
175
176 except (np.linalg.LinAlgError, ValueError):
--> 177 raise ValueError('error encountered in SVD, check that missing '
178 'values are in the same places at each time and '
179 'that all the values are not missing')
ValueError: error encountered in SVD, check that missing values are in the same places at each time and that all the values are not missing
如果我使用未分块的v
.
我知道已经询问了一个类似的问题(如果某些块仅包含 NaN 值,则 Dask 分布式不会运行 SVD),但建议仅沿时间维度对数组进行分块。我已经这样做了,并且我的数组不包含 NaN,那么为什么仍然存在错误?
解决方案
推荐阅读
- android - 不能让 listview 它说数组为空
- javascript - Node.js 在函数中查看对象以及为什么对象的属性未定义
- java - 如何从 URI 中删除片段
- python - 登录并下载 - Python 请求
- python - 分组和组合字符串
- node.js - electron-forge:缺少依赖项 = git 和节点,但我可以选择哪个 git?
- c# - 如何将用户选择的值存储到由 SharePoint Web 部件呈现的 n DropDown 中?
- r - nnfor 包中的 elm 函数无法识别 xreg 的输入
- sql - 在 T-SQL 中将 24 小时分成 96 个相等的 15 分钟间隔
- node.js - 如何在 NodeJS/Express 中验证 base64 图像?