| 
 
	积分31贡献 精华在线时间 小时注册时间2021-8-16最后登录1970-1-1 
 | 
 
40金钱 
| 使用软件是Python,文件格式是nc,使用Xarray库读取数据,SST的时间保存以月为单位画图目的是读取一段时间的SST数据,并对这段时间内的所有SST数据求平均并绘图 
 以下是数据读取部分:
 nc_file=xr.open_dataset(r'D:\Download\HadISST_sst.nc\HadISST_sst.nc') #读取nc文件
 lat=nc_file.variables['latitude']#读取纬度
 lon=nc_file.variables['longitude']#读取经度
 sst=nc_file.sst #读取海温
 SST = sst.loc['1870-01-16T11:59:59.505615234':'1870-03-16T11:59:59.340820312'] #选择需要的时间段
 中间设置略过,以下是绘图部分:
 clevs_SST = np.arange(15, 30)
 cs2 = ax.contourf(lon, lat, SST, clevs_SST, cmap='RdBu_r',transform=ccrs.PlateCarree(),extend = 'both')
 cb = plt.colorbar(cs2, orientation='horizontal', pad=0.05, aspect=30)
 
 
 在运行程序后出现bug:TypeError: Input z must be 2D, not 3D
 
 
 有两个问题想要解决:
 1.如何解决该bug?
 2.如何对这段时间内的SST数据求平均?
 
 
 
 
 | 
 |