首页 > 解决方案 > 如何在 python 中使用 xarray 将气候数据集相乘?

问题描述

输入 :

tws = ds1.lwe_thickness
print(tws.size)
print(tws.shape)
# tws

# vectorization
stacked1 = tws.stack(space =("latitude", "longitude"))    # 
stacked
print(stacked1.shape)

# standardization
Y = (stacked1-stacked1.mean())/(stacked1.std())
print(Y)
print(Y.shape) 

print(Xt.shape)  # precipitation dataset
print(Y.shape)   # total water storage dataset

 # co-variance between precipitation and total water storage
Cxy = (Xt*Y)/(72)
print(Cxy.shape)
print(Cxy)
print(Cxy.dims)

输出 :

(64800, 72) (72, 64800) (64800, 0) <xarray.DataArray (space: 64800, time: 0)> array([], shape=(64800, 0), dtype=float64) 坐标:*时间(time) datetime64[ns] * space (space) MultiIndex

  • 纬度(空间) float64 -90.0 -90.0 -90.0 -90.0 ... 89.0 89.0 89.0 89.0
  • 经度(空间) float64 0.0 1.0 2.0 3.0 4.0 ... 356.0 357.0 358.0 359.0('空间','时间')

最初 Xt 矩阵的大小是 64800 72,Y 是 72 64800。这两个矩阵相乘后,大小应该是 64800 64800,但我得到 64800 0。为什么会这样?帮我解决这个问题。基本上我在这里使用 xarray 。

图片附在这里

标签: pythonmatrix-multiplicationpython-xarraycode-climate

解决方案


推荐阅读