【问题标题】:ValueError when displaying cartopy facet-grid map with NaN values in xarray在xarray中显示带有NaN值的cartopy facet-grid map时出现ValueError
【发布时间】:2020-12-26 10:28:10
【问题描述】:

我试图使用带有 NaN 值的 xarray 显示季节性面网格图(对于海域),代码如下:

ds = xr.open_dataset("../data/full_data_monthly_v2018_025.nc")
prKepri = ds['precip'].sel(lat = slice(-0.49, -4.7), lon = slice(103.37, 109.1))
data = prKepri.groupby('time.season').mean(dim='time', skipna = False)
proj = ccrs.PlateCarree()
p = data.plot(col = 'season', robust = True, cmap = 'magma_r', col_wrap =2,
             subplot_kws=dict(projection=proj), transform=ccrs.PlateCarree())
for ax in p.axes.flat:
    ax.coastlines();

然后 xarray 给我一个错误:

ValueError: zero-size array to reduction operation minimum which has no identity

我尝试使用skipna = False 参数。但问题仍然存在。 我使用 GPCC 再分析数据:https://opendata.dwd.de/climate_environment/GPCC/full_data_2018/full_data_monthly_v2018_025.nc.gz。

我使用 xarray v 0.16.0

【问题讨论】:

    标签: python matplotlib python-xarray cartopy


    【解决方案1】:

    这是 matplotlib 3.3.1 中的 bug,它会导致 CartoPy 0.18 出现问题。在 matplotlib 3.3.2 发布之前,最简单的解决方法可能是安装 matplotlib 3.3.0。

    【讨论】:

      猜你喜欢
      • 2022-06-28
      • 2020-09-17
      • 2021-12-12
      • 2021-01-06
      • 1970-01-01
      • 2019-04-12
      • 2019-09-26
      • 2021-09-14
      • 1970-01-01
      相关资源
      最近更新 更多