赞
踩
from scipy.io import loadmat import numpy as np address = 'G:/work2022/python/SCF_month_1966-2018_observation/' matfn = address + '01.mat'#读取mat文件名 data = loadmat(matfn) w1 = data['scf'] matfn = address + '02.mat'#读取mat文件名 data = loadmat(matfn) w2 = data['scf'] matfn = address + '12.mat'#读取mat文件名 data = loadmat(matfn) w3 = data['scf'] w = np.zeros((360,1440,26,3)) w[0:360,0:1440,0:26,0]=w1[0:360,0:1440,14:40] w[0:360,0:1440,0:26,1]=w2[0:360,0:1440,14:40] w[0:360,0:1440,0:26,2]=w3[0:360,0:1440,13:39] wmean=np.nanmean(w,axis=3) wm=np.nanmean(wmean,axis=2) ## 绘图 lon=np.arange(0.125-180,180,0.25) lat=np.arange(90-0.125,0,-0.25) import matplotlib.pyplot as plt import cartopy.crs as ccrs import cartopy.feature as cfeature from cartopy.mpl.ticker import LongitudeFormatter, LatitudeFormatter from cartopy.io.shapereader import Reader Alberts_China = ccrs.AlbersEqualArea(central_longitude=105, standard_parallels=(25.0, 47.0)) # 1 fig = plt.figure() proj = ccrs.PlateCarree(central_longitude=0) extents = [65, 105, 25, 40] ax = plt.subplot(111, projection=proj) ax.set_extent(extents, crs=proj) ax.set_xticks(np.arange(65, 106, 10), crs=proj) ax.set_yticks(np.arange(25, 45, 5), crs=proj) ax.xaxis.set_major_formatter(LongitudeFormatter()) ax.yaxis.set_major_formatter(LatitudeFormatter()) reader = Reader('G:/work2022/python/SCF_month_1966-2018_observation/TPBoundary_new(2021).shp') ax.add_geometries(reader.geometries(), crs=ccrs.PlateCarree(), # 坐标系需要对应,不然可能会出现坐标不对应的情况哦 edgecolor='r', linewidths=2,facecolor='none') c2 = ax.contourf(lon,lat,wm, levels=np.arange(0,1.1,0.1), cmap=plt.cm.jet,zorder=0) cbar = fig.colorbar(c2, orientation='horizontal', fraction=0.5, pad=0.12, aspect=20, shrink=0.65) cbar.set_ticks([0,0.2,0.4,0.6,0.8,1.0]) cbar.set_label('SCF') ax.set_title('(a) Winter',loc='left') cbar.set_label('SCF',fontsize=15) ax.set_title('(a)Winter',loc='left',fontsize=15) # 设置刻度字体大小 plt.xticks(fontsize=15) plt.yticks(fontsize=15) cbar.ax.tick_params(labelsize=15) plt.show();
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。