- 积分
 - 9
 
	- 贡献
 -  
 
	- 精华
 
	- 在线时间
 -  小时
 
	- 注册时间
 - 2020-10-28
 
	- 最后登录
 - 1970-1-1
 
 
 
 
 
 
 | 
	
 
Python
| 系统平台: | 
  | 
 
| 问题截图: | 
- | 
 
| 问题概况: | 
python cartopy画SSTA图中,该怎么进行坐标转换?  | 
 
| 我看过提问的智慧: | 
没看过(看完再来提问)  | 
 
| 自己思考时长(天): | 
1  | 
 
 
 
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册 
 
 
 
x
 
本人刚刚学习cartopy不太明白怎么将数据集中的坐标,映射到我画的底图上? 
我练习了一下2016SSTA的图,代码如下: 
import cartopy.crs as ccrs 
import cartopy.feature as cfeature 
import matplotlib.pyplot as plt 
import cartopy.mpl.ticker as cticker 
import xarray as xr 
import numpy as np  
 
f=xr.open_dataset('precip.mon.mean.nc') 
precip=f['precip'] 
precip_avg_ds=precip.loc['1979-01-01':'2009-01-01'] 
precip_avg=np.nanmean(precip_avg_ds,0) 
precip_2016=precip.loc['2016-07-01'] 
 
precip_2016a=precip_2016-precip_avg 
 
lat=f['lat_bnds'] 
lon=f['lon_bnds'] 
 
#===画图 
fig = plt.figure(figsize=(12,8)) 
ax = fig.add_subplot(1,1,1,projection = ccrs.PlateCarree(central_longitude=180)) 
ax.set_extent([0,360,-90,90], crs=ccrs.PlateCarree()) 
ax.add_feature(cfeature.COASTLINE.with_scale('50m')) 
ax.set_xticks(np.arange(0,360+30,144), crs=ccrs.PlateCarree()) 
ax.set_yticks(np.arange(-90,90+30,72), crs=ccrs.PlateCarree()) 
 
lon_formatter = cticker.LongitudeFormatter() 
lat_formatter = cticker.LatitudeFormatter() 
ax.xaxis.set_major_formatter(lon_formatter) 
ax.yaxis.set_major_formatter(lat_formatter) 
ax.set_title('2016aSSTA',loc='center',fontsize=18) 
ax.set_title('unit: dagc',loc='right',fontsize=18) 
 
cp=ax.contourf(lon,lat,precip_2016a,transform=ccrs.PlateCarree(),cmap='jet') 
plt.colorbar(cp) 
 
 
=====error===== 
F:\anaconda\lib\site-packages\cartopy\mpl\geoaxes.py:704: UserWarning: Attempting to set identical left==right resultsin singular transformations; automatically expanding.left=-180.0, right=-180.0  self.set_xlim([x1, x2])TypeError: Shape of x does not match that of z: found (144, 2) instead of (72, 144) 
 
请大神看看哪里错了? 
 |   
 
 
 
 |