| 
 
	积分137贡献 精华在线时间 小时注册时间2018-3-2最后登录1970-1-1 
 | 
 
| 
用python画风场图时出现如下错误
x
登录后查看更多精彩内容~您需要 登录 才可以下载或查看,没有帐号?立即注册 
  import numpy
 from metpy.units import units
 from scipy.ndimage import gaussian_filter
 data = xr.open_dataset('presure2020.nc').metpy.parse_cf()
 u=data['u'][0,0,:,:]
 v=data['v'][0,0,:,:]
 q1=data['r'][0,:,:,:]
 lon = data['longitude']
 lat= data['latitude']
 lon,lat =np.meshgrid(lon,lat)
 fig = plt.figure(figsize=(10, 5))
 ax = fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree())
 ax.set_extent([0, 140, 10, 85], crs=ccrs.PlateCarree())
 ax.coastlines()
 magnitude = (u ** 2 + v ** 2) ** 0.5
 ax.streamplot(lon, lat, u, v, transform=ccrs.PlateCarree(),
 linewidth=2, density=2, color=magnitude)
 plt.show()
 fig = plt.figure(figsize=(10, 5))
 ax = fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree())
 ax.set_extent([0, 140, 10, 85], crs=ccrs.PlateCarree())
 ax.coastlines()
 
 # x, y, u, v, vector_crs = sample_data(shape=(80, 100))
 magnitude = (u ** 2 + v ** 2) ** 0.5
 ax.streamplot(lon, lat, u, v, transform=ccrs.PlateCarree(),
 linewidth=2, density=2, color=magnitude)
 plt.show()
 错误如下:
 AttributeError: 'DataArray' object has no attribute 'ravel'求助,我找了好久就是不知道问题出在哪里了。求助
 
 | 
 |