我正在尝试使用1,0 xarray数据数组来掩盖另一个datarray。两者具有相同的尺寸。我有一个名为odr的xarray数据数组:
odr
Out[283]:
<xarray.DataArray 'pr' (time: 366, lat: 99, lon: 111)>
array([[[ nan, nan, ..., 0.000000e+00, 0.000000e+00],
[ nan, nan, ..., 0.000000e+00, 0.000000e+00],
...,
[ nan, nan, ..., 0.000000e+00, 0.000000e+00],
[ nan, nan, ..., 0.000000e+00, 0.000000e+00]],
[[ nan, nan, ..., 0.000000e+00, 0.000000e+00],
[ nan, nan, ..., 0.000000e+00, 0.000000e+00],
...,
[ nan, nan, ..., 0.000000e+00, 0.000000e+00],
[ nan, nan, ..., 0.000000e+00, 0.000000e+00]],
...,
[[ nan, nan, ..., 2.467176e-10, 1.868555e-10],
[ nan, nan, ..., 0.000000e+00, 0.000000e+00],
...,
[ nan, nan, ..., 0.000000e+00, 0.000000e+00],
[ nan, nan, ..., 0.000000e+00, 0.000000e+00]],
[[ nan, nan, ..., 0.000000e+00, 0.000000e+00],
[ nan, nan, ..., 0.000000e+00, 0.000000e+00],
...,
[ nan, nan, ..., 0.000000e+00, 0.000000e+00],
[ nan, nan, ..., 0.000000e+00, 0.000000e+00]]])
Coordinates:
* time (time) datetime64[ns] 2016-01-01T12:00:00 ... 2016-12-31T12:00:00
* lon (lon) float64 147.5 147.6 147.6 147.7 ... 152.9 152.9 153.0 153.0
* lat (lat) float64 -36.4 -36.35 -36.3 -36.25 ... -31.6 -31.55 -31.5
Attributes:
regrid_method: conservative
我想使用另一个称为mask3d的数据数组来屏蔽:
mask3d
Out[289]:
<xarray.DataArray 'mask' (time: 366, lat: 99, lon: 111)>
array([[[0., 0., ..., 0., 0.],
[0., 0., ..., 0., 0.],
...,
[0., 0., ..., 0., 0.],
[0., 0., ..., 0., 0.]],
[[0., 0., ..., 0., 0.],
[0., 0., ..., 0., 0.],
...,
[0., 0., ..., 0., 0.],
[0., 0., ..., 0., 0.]],
...,
[[0., 0., ..., 0., 0.],
[0., 0., ..., 0., 0.],
...,
[0., 0., ..., 0., 0.],
[0., 0., ..., 0., 0.]],
[[0., 0., ..., 0., 0.],
[0., 0., ..., 0., 0.],
...,
[0., 0., ..., 0., 0.],
[0., 0., ..., 0., 0.]]], dtype=float32)
Coordinates:
* lat (lat) float64 -36.4 -36.35 -36.3 -36.25 ... -31.6 -31.55 -31.5
* lon (lon) float64 147.5 147.6 147.6 147.7 ... 152.8 152.9 152.9 153.0
* time (time) datetime64[ns] 2016-01-01T12:00:00 ... 2016-12-31T12:00:00
Attributes:
units: none
stagger: M
standard_name: MASK
long_name: Statistics mask for NARCliM2 evaluation
description: 1=USE, 0=DO NOT USE
当我尝试odr.where(mask3d> 0.5)时得到
odr.where(mask3d > 0.5)
Out[290]:
<xarray.DataArray 'pr' (time: 366, lat: 2, lon: 2)>
array([[[nan, nan],
[nan, nan]],
[[nan, nan],
[nan, nan]],
...,
[[nan, nan],
[nan, nan]],
[[nan, nan],
[nan, nan]]])
Coordinates:
* lat (lat) float64 -36.4 -36.35
* lon (lon) float64 147.5 147.6
* time (time) datetime64[ns] 2016-01-01T12:00:00 ... 2016-12-31T12:00:00
Attributes:
regrid_method: conservative
我希望数据集的尺寸与odr相同。谁能告诉我发生了什么事?