- 积分
- 5344
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2012-8-28
- 最后登录
- 1970-1-1
|
发表于 2020-6-30 21:34:05
|
显示全部楼层
这个挺简单的啊...
- import numpy as np
- import netCDF4 as nc
- import matplotlib.pyplot as plt
- from mpl_toolkits.basemap import Basemap
- raw=nc.Dataset('sst.nc')
- print(raw)
- lat=raw.variables['latitude'][:]
- lon=raw.variables['longitude'][:]
- sst=raw.variables['sst'][0]
- lon_leftup=100;lat_leftup=50
- lon_rightdown=170;lat_rightdown=0
- fig, ax = plt.subplots(figsize=(10,9))
- m = Basemap(projection='cyl', llcrnrlat=lat_rightdown, urcrnrlat=lat_leftup, llcrnrlon=lon_leftup, urcrnrlon=lon_rightdown, resolution='l')
- m.drawcoastlines(linewidth=0.6, color='black')
- m.fillcontinents(color='w',lake_color='w')
- m.drawmapboundary(fill_color='w')
- parallels = np.arange(0,60,10)
- m.drawparallels(parallels,labels=[True,False,False,False],linewidth=0.4,dashes=[1,4],size=12)
- meridians = np.arange(100,180,10)
- m.drawmeridians(meridians,labels=[False,False,False,True],linewidth=0.4,dashes=[1,4],size=12)
- plt.yticks(parallels,len(parallels)*[''])
- plt.xticks(meridians,len(meridians)*[''])
- lons, lats = np.meshgrid(lon,lat)
- x, y = m(lons, lats)
- cf=m.contourf(x,y,sst-273.15,levels=np.arange(0,33,1),cmap='jet',extend='both')
- cb = plt.colorbar(cf, ax=ax, shrink=0.6, aspect=20, orientation='vertical')
- plt.savefig('sst.png', dpi=200, bbox_inches='tight')
- plt.show()
复制代码
|
|