import numpy as np
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import datetime
import netCDF4 as nc
file=nc.Dataset('sst.wkmean.1990-present.nc')
lon=file.variables['lon'][:]
lat=file.variables['lat'][:]
sst=file.variables['sst'][:]
time=file.variables['time'][:]
time1=datetime.date(2000,1,1)-datetime.date(1800,1,1)
time2=datetime.date(2000,12,31)-datetime.date(1800,1,1)
trange=np.where((time>=time1.days)&(time<=time2.days),1,0)
sst2000=np.mean(sst[trange==1,:,:],0)
lon0=lon.mean()
lat0=lat.mean()
m = Basemap(llcrnrlon=280, llcrnrlat=-60, urcrnrlon=400, urcrnrlat=0)
lons,lats=np.meshgrid(lon,lat)
lons=np.concatenate((lons[2160:], lons[:2160]+180))
sst2000=np.concatenate((sst2000[:, 2160:], sst2000[:, :2160]), axis=1)
cs=m.contourf(lons,lats,sst2000,range(0,35,1),cmap='jet')
cbar=m.colorbar(cs,pad="10%",label='Sea Surface Temperature(degC)')
m.drawparallels(np.arange(-90.,91.,20.),labels=[1,0,0,0],fontsize=10)
m.drawmeridians(np.arange(-180.,181.,40.),labels=[0,0,0,1],fontsize=10)
m.drawcoastlines()
m.fillcontinents()
plt.title('Sea Surface Temperature of China in 2000')
plt.show()