set(idg3))) #get index for codar data based on edge and id(time) png_num = png_num + 1 #for save movie picture if len(idg) <> 0: fig = plt.figure() ax = fig.add_subplot(111) plt.title( str(num2date(datetime_wanted).strftime("%d-%b-%Y %H")) + 'h') #plot title pylab.ylim([minlat - 0.02, maxlat + 0.02]) #limit edge pylab.xlim([minlon - 0.02, maxlon + 0.02]) plot_getsst(ask_input, utc, gbox) #plot sst #plot codar codar_scale_index = np.average( np.average(np.reshape(u, np.size(u))[idg]), np.average(np.reshape(v, np.size(v))[idg])) q = plt.quiver(np.reshape(lon_vel, np.size(lon_vel))[idg], np.reshape(lat_vel, np.size(lat_vel))[idg], np.reshape(u, np.size(u))[idg], np.reshape(v, np.size(v))[idg], angles='xy', scale=1, color='b', label='codar') p = plt.quiverkey(q, minlon - 0.01, maxlat + 0.06,
temp=database.variables['temp'][int(id):(int(id)+1)] temp=temp[0][layer] return lat,lon,temp lat_r,lon_r,temp=getroms(TIME,layer) ax1=fig.add_subplot(312) m = Basemap(projection='cyl',llcrnrlat=min(latsize)-0.01,urcrnrlat=max(latsize)+0.01,\ llcrnrlon=min(lonsize)-0.01,urcrnrlon=max(lonsize)+0.01,resolution='h')#,fix_aspect=False) m.drawparallels(np.arange(int(min(latsize)),int(max(latsize))+1,3),labels=[1,0,0,0]) m.drawmeridians(np.arange(int(min(lonsize)),int(max(lonsize))+1,3),labels=[0,0,0,1]) m.drawcoastlines() m.drawmapboundary() CS = plt.contourf(lon_r,lat_r,temp,np.arange(6,26,3.0)) plt.colorbar(CS,format='%1.0f'+'C') #tricontourf(tri,temperature,np.arange(12,32,3)) #colorbar(format='%1.0f'+'C') ax1.text(0.95, 0.1,'ROM',fontsize=17, horizontalalignment='right',verticalalignment='bottom',transform=ax1.transAxes) ax2=fig.add_subplot(313) m = Basemap(projection='cyl',llcrnrlat=min(latsize)-0.01,urcrnrlat=max(latsize)+0.01,\ llcrnrlon=min(lonsize)-0.01,urcrnrlon=max(lonsize)+0.01,resolution='h')#,fix_aspect=False) m.drawparallels(np.arange(int(min(latsize)),int(max(latsize))+1,3),labels=[1,0,0,0]) m.drawmeridians(np.arange(int(min(lonsize)),int(max(lonsize))+1,3),labels=[0,0,0,1]) m.drawcoastlines() #m.fillcontinents(color='grey') m.drawmapboundary() ask_input=datetime_wanted plot_getsst(ask_input,utc,gbox) #colorbar() ax2.text(0.95, 0.1,'OBSERVED',fontsize=17, horizontalalignment='right',verticalalignment='bottom',transform=ax2.transAxes) #plt.title(urlname+' real sea surface temp data:'+' Time:'+str(TIME)[0:-9]) plt.show() plt.savefig('sst'+TIME[0:-4]+'.png')
pydir='../' sys.path.append(pydir) sys.path.append('/net/home3/ocn/jmanning/py/mygit/modules/') from basemap import basemap_region utc = pytz.timezone('UTC') #################Input values############################################# input_time=[dt.datetime(2012,1,30,0,0,0,0,pytz.UTC),dt.datetime(2012,9,1,0,0,0,0,pytz.UTC)] # start time and end time gbox=[-68.0,-72.0,45.0,38.0] # maxlon, minlon,maxlat,minlat id=[] # id list, if you are not clear dedicated id, let id=[] #'125450842''125450841' #↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑Input values↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑# #fig = plt.figure() #ax = fig.add_subplot(111) ask_input=input_time[0] plot_getsst(ask_input,utc,sorted(gbox)) # get sst data and polt it if id==[]: time,ids,lats,lons=getobs_drift_byrange(gbox,input_time) id=list(set(ids)) rgbcolors=colors(len(id)) # set different colors to different drifter for k in range(len(id)): time,ids,lat_d,lon_d=getobs_drift_byidrange(id[k],gbox,input_time) #get drifters' data plt.plot(lon_d[0],lat_d[0],'.',markersize=30,color=rgbcolors[k+1],label=str(id[k])) plt.plot(np.reshape(lon_d,np.size(lon_d)),np.reshape(lat_d,np.size(lat_d)),color=rgbcolors[k+1]) #plot else: lats,lons=[],[] rgbcolors=colors(len(id)) # set different colors to different drifter for m in range(len(id)): time,ids,lat_d,lon_d=getobs_drift_byid(id[m],input_time) #get drifters' data by id