我试图在曲线网格上选择一个点/切片,但是我不认为xarray支持它。有什么想法可以解决这个问题吗?一种方法是使用xesmf重新网格化为直线网格,但是还有其他方法吗?
import xarray as xr
ds = xr.tutorial.open_dataset('rasm').load()
print(ds)
ds.sel(xc=189.2, method='nearest')
# ds.sel(xc=slice(90, 189.2))
输出:
<xarray.Dataset>
Dimensions: (time: 36, x: 275, y: 205)
Coordinates:
* time (time) object 1980-09-16 12:00:00 ... 1983-08-17 00:00:00
xc (y, x) float64 189.2 189.4 189.6 189.7 ... 17.65 17.4 17.15 16.91
yc (y, x) float64 16.53 16.78 17.02 17.27 ... 28.26 28.01 27.76 27.51
Dimensions without coordinates: x, y
Data variables:
Tair (time, y, x) float64 nan nan nan nan nan ... 29.8 28.66 28.19 28.21
...
~/anaconda3/lib/python3.7/site-packages/xarray/core/indexing.py in get_dim_indexers(data_obj, indexers)
205 if invalid:
206 raise ValueError("dimensions or multi-index levels %r do not exist"
--> 207 % invalid)
208
209 level_indexers = defaultdict(dict)
ValueError: dimensions or multi-index levels ['xc'] do not exist