问题描述
我想绘制一个字典条目,其中包含 xy 坐标 (lat-lon) 上的 lat,on 坐标。变量看起来像:
<class 'method'>
<bound method Mapping.values of <xarray.Dataset>
Dimensions: (lat: 96,lon: 144)
Coordinates:
lev_p int32 200
Dimensions without coordinates: lat,on
Data variables:
V (lat,lon) float32 dask.array<chunksize=(96,144),Meta=np.ndarray>>
我想绘制 V,作为对 lat 和 lon 的轮廓,但是当我尝试绘制它时,出现以下错误:
TypeError: cannot directly convert an xarray.Dataset into a numpy array. Instead,create an xarray.DataArray first,either with indexing on the Dataset or by invoking the
to_array() method.
我尝试使用 .to_array 以及使用 map(float,variable) 将字典值转换为数组,但没有成功。 我无法弄清楚发生了什么。对此有何建议或帮助? 谢谢
解决方法
这实际上是一个简单的 - 提取字典值然后我们的提取变量就足够了,所以我会做 ds['实验']['V'] 这样我就可以得到字典并从中得到特定的 V 值。