簡體   English   中英

將 xarray.Dataset 的字典條目轉換為 numpy 數組(用於 xy 坐標等高線繪圖)

[英]Convert dictionary entry of xarray.Dataset to numpy array (for xy coord contour plotting)

我想要 plot,一個字典條目,其中包含 xy 坐標(經緯度)上的緯度坐標。 該變量如下所示:

 <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>>

我想 plot V,作為緯度和經度的輪廓,但是當我嘗試 plot 時,我收到以下錯誤:

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 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['Experiment'] 之類的事情並獲取 xarray.Dataset 我會做 ds['Experiment'] ['V'] 所以我會得到字典並從中取出特定的 V 值。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM