是否可以删除 xarray 数据集中包含的 DataArrays 值,以便在下面的示例代码中xr_dataset
转换为?xr_flat
import xarray as xr
import numpy as np
n = np.nan
a = np.array([[n,n,1],
[1,2,2],
[2,n,n]], dtype='float32')
b = np.random.rand(3,3)
xr_dataset = xr.Dataset({'a': xr.DataArray(a, dims=['x', 'y']),
'b': xr.DataArray(b, dims=['x', 'y'])})
a_flat = a[np.isfinite(a)]
b_flat = b[np.isfinite(a)]
xr_flat = xr.Dataset({'a': xr.DataArray(a_flat),
'b': xr.DataArray(b_flat)})