- 积分
- 237
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2018-10-24
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
python快速绘图,使用Argo网格数据绘制印尼海区的表层,100米,500米与1000米的温盐空间分布
- import netCDF4 as nc
- import numpy as np
- import matplotlib.pyplot as plt
- from mpl_toolkits.basemap import Basemap as mp
- indir = 'E:\\ocean_file\\BOA_Argo\\';
- data = nc.Dataset(indir+'BOA_Argo_annual.nc','r')
- for i in data.variables.keys():
- print (i)
- print('--------------------------')
- lon = data.variables['lon'][:]
- lat = data.variables['lat'][:]
- pres = data.variables['pres'][:]
- time = data.variables['time'][:]
- salt = data.variables['salt'][:]
- temp = data.variables['temp'][:]
- lons = 110;lone = 140;lats = -15;late = 15;
- x1s = np.argwhere(lon[:]>=lons);x1s1 = int(x1s[0])
- x1e = np.argwhere(lon[:]>=lone);x1e1 = int(x1e[0])
- y1s = np.argwhere(lat[:]>=lats);y1s1 = int(y1s[0])
- y1e = np.argwhere(lat[:]>=late);y1e1 = int(y1e[0])
- lon_IS = lon[x1s1:x1e1];lat_IS = lat[y1s1:y1e1]
- temp_IS = temp[0,:,y1s1:y1e1,x1s1:x1e1]
- salt_IS = salt[0,:,y1s1:y1e1,x1s1:x1e1]
- plt.figure(figsize=(10, 12))
- plt.subplot(221)
- m = mp(llcrnrlon=110., llcrnrlat=-15, urcrnrlon=140, urcrnrlat=15, resolution='c', projection='mill')
- m.drawcoastlines()
- m.drawparallels(np.arange(-90, 90, 10),labels=[1, 0, 0, 0])
- m.drawmeridians(np.arange(m.lonmin, m.lonmax+30, 10), labels=[0, 0, 0, 1])
- cmap = plt.cm.get_cmap('RdYlBu_r')
- levels = np.arange(32.8,34.5,0.1)
- x,y = np.meshgrid(lon_IS,lat_IS);x,y = m(x,y)
- m.contourf(x,y,salt_IS[0,:,:],alpha=0.75,cmap=cmap, levels=levels)
- m.colorbar(label='psu', location='bottom', pad=0.3)
- C = plt.contour(x,y,salt_IS[0,:,:],8,color='black',linewidth=0.5)
- plt.clabel(C,inline=1,fontsize=10)
- plt.title('Argo_annual_salt_@0m',loc='left', fontsize=18)
- plt.subplot(222)
- m = mp(llcrnrlon=110., llcrnrlat=-15, urcrnrlon=140, urcrnrlat=15, resolution='c', projection='mill')
- m.drawcoastlines()
- m.drawparallels(np.arange(-90, 90, 10),labels=[1, 0, 0, 0])
- m.drawmeridians(np.arange(m.lonmin, m.lonmax+30, 10), labels=[0, 0, 0, 1])
- cmap = plt.cm.get_cmap('RdYlBu_r')
- levels = np.arange(34.3,35.2,0.1)
- x,y = np.meshgrid(lon_IS,lat_IS);x,y = m(x,y)
- m.contourf(x,y,salt_IS[11,:,:],alpha=0.75,cmap=cmap, levels=levels)
- m.colorbar(label='psu', location='bottom', pad=0.3)
- C = plt.contour(x,y,salt_IS[11,:,:],8,color='black',linewidth=0.5)
- plt.clabel(C,inline=1,fontsize=10)
- plt.title('Argo_annual_salt_@100m',loc='left', fontsize=18)
- plt.subplot(223)
- m = mp(llcrnrlon=110., llcrnrlat=-15, urcrnrlon=140, urcrnrlat=15, resolution='c', projection='mill')
- m.drawcoastlines()
- m.drawparallels(np.arange(-90, 90, 10),labels=[1, 0, 0, 0])
- m.drawmeridians(np.arange(m.lonmin, m.lonmax+30, 10), labels=[0, 0, 0, 1])
- cmap = plt.cm.get_cmap('RdYlBu_r')
- levels = np.arange(34.3,34.7,0.02)
- x,y = np.meshgrid(lon_IS,lat_IS);x,y = m(x,y)
- m.contourf(x,y,salt_IS[34,:,:],alpha=0.75,cmap=cmap, levels=levels)
- m.colorbar(label='psu', location='bottom', pad=0.3)
- C = plt.contour(x,y,salt_IS[34,:,:],8,color='black',linewidth=0.5)
- plt.clabel(C,inline=1,fontsize=10)
- plt.title('Argo_annual_salt_@500m',loc='left', fontsize=18)
- plt.subplot(224)
- m = mp(llcrnrlon=110., llcrnrlat=-15, urcrnrlon=140, urcrnrlat=15, resolution='c', projection='mill')
- m.drawcoastlines()
- m.drawparallels(np.arange(-90, 90, 10),labels=[1, 0, 0, 0])
- m.drawmeridians(np.arange(m.lonmin, m.lonmax+30, 10), labels=[0, 0, 0, 1])
- cmap = plt.cm.get_cmap('RdYlBu_r')
- levels = np.arange(34.5,34.65,0.01)
- x,y = np.meshgrid(lon_IS,lat_IS);x,y = m(x,y)
- m.contourf(x,y,salt_IS[44,:,:],alpha=0.75,cmap=cmap, levels=levels)
- m.colorbar(label='psu', location='bottom', pad=0.3)
- C = plt.contour(x,y,salt_IS[44,:,:],8,color='black',linewidth=0.5)
- plt.clabel(C,inline=1,fontsize=10)
- plt.title('Argo_annual_salt_@1000m',loc='left', fontsize=18)
- plt.savefig('IS_salt.png',dpi=520)
复制代码
|
-
-
|