Python 3.x Cartopy IllegalArgumentException详细

Python 3.x Cartopy IllegalArgumentException详细,python-3.x,cartopy,Python 3.x,Cartopy,我对cartopy是新手。当我在一个欧洲域中绘制一个基本的数据图时,我会得到重复的错误消息 IllegalArgumentException: Invalid number of points in LinearRing found 3 - must be 0 or >= 4 Shell is not a LinearRing 当我设置Data=np.zero((7211440))时,这种行为不会发生。下面的代码(Anaconda、did clean install、python 3)

我对cartopy是新手。当我在一个欧洲域中绘制一个基本的数据图时,我会得到重复的错误消息

IllegalArgumentException: Invalid number of points in LinearRing found 3 - must be 0 or >= 4
Shell is not a LinearRing
当我设置
Data=np.zero((7211440))
时,这种行为不会发生。下面的代码(Anaconda、did clean install、python 3)


数据位于

这是cartopy中的一个缺陷,已在2018年2月21日发布的v0.16版本中修复(请参阅:)。升级将消除警告。

我仍然得到
IllegalArgumentException:LinearRing中的无效点数发现3-必须为0或>=4
,然后
分段错误(堆芯转储)
有时(Conda,cartopy v0.16.0 build py36hf32a85a_0)更新;避免对坐标数据使用
np.linspace(-180180720)、np.linspace(-90,90360)
,而是使用
np.linspace(-179.99179.99720)、np.linspace(-89.99,89.99360)
解决了这个问题
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
import numpy as np
import pygrib

File = pygrib.open('GFS_0.25.grb2')

Data = File.select(name='Temperature',level=850)[0].values

Lon = np.linspace(-180,180,1440)
Lat = np.linspace(-90,90,721)


crs = ccrs.LambertConformal(central_longitude=0, central_latitude=45.0)
bounds = [(-50, 50, 25., 65)]

ax1 = plt.subplot(111,projection=crs)
ax1.set_extent(*bounds)
ax1.coastlines('50m', edgecolor='black', linewidth=0.75)
ax1.contourf(Lon,Lat,Data,transform=ccrs.PlateCarree())