def progvec_plot(x_model,y_model,mlat,mlon,depth_i,stime1,etime1): fig = plt.figure() fig.canvas.set_window_title('progvec') ax1 = fig.add_subplot(111) ax1.plot(x_model,y_model,"-") plt.xlabel('km') plt.ylabel('km') plt.title('The time from '+str(stime1)+' to '+str(etime1) +'\n'+'latitude:'+str(mlat)+' longitude:'+str(mlon)+' depth:'+str(depth_i)) plt.figure() lo,la=[],[] for k in range(len(x_model)): lo.append(mlon+x_model[k]/1.86/60/math.cos(mlat/180.*math.pi)) la.append(mlat+y_model[k]/1.86/60) basemap_usgs(la,lo,True) plt.plot(lo,la,'-') np.save('fcast.lat',la) np.save('fcast.lon',lo) plt.show()
def progvec_plot(x_model, y_model, mlat, mlon, depth_i, stime1, etime1): fig = plt.figure() fig.canvas.set_window_title('progvec') ax1 = fig.add_subplot(111) ax1.plot(x_model, y_model, "-") plt.xlabel('km') plt.ylabel('km') plt.title('The time from ' + str(stime1) + ' to ' + str(etime1) + '\n' + 'latitude:' + str(mlat) + ' longitude:' + str(mlon) + ' depth:' + str(depth_i)) plt.figure() lo, la = [], [] for k in range(len(x_model)): lo.append(mlon + x_model[k] / 1.86 / 60 / math.cos(mlat / 180. * math.pi)) la.append(mlat + y_model[k] / 1.86 / 60) basemap_usgs(la, lo, True) plt.plot(lo, la, '-') np.save('fcast.lat', la) np.save('fcast.lon', lo) plt.show()
lon = nc.variables['lon'][:] h = nc.variables['h'][:] # read connectivity array nv = nc.variables['nv'][:].T - 1 # create a triangulation object, specifying the triangle connectivity array tri = Tri.Triangulation(lon,lat, triangles=nv) # plot depth using tricontourf fig=plt.figure(figsize=(6,8)) ax1=fig.add_subplot(211) basemap_standard([latrng[0],latrng[1]],[lonrng[0],lonrng[1]],[0.2]) cont_range.reverse() tricontourf(tri,h*-1,list(np.array(cont_range)*-1))#contour range from fvcom_depth_ctl.py file colorbar() ylim(latrng) xlim(lonrng) plt.title('FVCOM GOM3 Depth (m)') plt.plot([-68.158,-67.327,-67.248],[44.127,44.485,44.487],'w*',markersize=10)#cases of bad depths in FVCOM plt.show() # now plot usgs depths for specified region ax2=fig.add_subplot(212) print 'Now running basemap_usgs' basemap_usgs([latrng[0],latrng[1]],[lonrng[0],lonrng[1]],True,True,[0.2],list(np.array(cont_range)*-1),1) plt.title('USGS GOM3_v1_0 Depth (m)') plt.plot([-68.158,-67.327,-67.248],[44.127,44.485,44.487],'w*',markersize=10)#bad depths plt.text(-68.32,44.21,'Cranberry Isles',style='italic') plt.show() plt.savefig('/net/nwebserver/epd/ocean/MainPage/modvsobs/figs/'+urlname+'fvcom_vs_usgs_'+case+'.png') plt.savefig('/net/nwebserver/epd/ocean/MainPage/modvsobs/figs/'+urlname+'fvcom_vs_usgs_'+case+'.eps')
df['lon'][i]=cc+(dd/60) latsize=[39.0,45.0] #40 lonsize=[-73.,-67.0] #-72 plt.figure(figsize=(7,6)) 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,1),labels=[1,0,0,0]) m.drawmeridians(np.arange(int(min(lonsize)),int(max(lonsize))+1,1),labels=[0,0,0,1]) m.drawcoastlines() m.fillcontinents(color='grey') m.drawmapboundary() # Now draw the isobaths (-200m) #basemap_usgs(lat,lon,bathy,draw_parallels,parallels_interval,cont_range,ss): basemap_usgs(latsize,lonsize,True,False,2,[-200],10) #x, y = m2(-df['lon'],df['lat']) x=-df['lon'] y=df['lat'] for i in range(len(df)): if df['mean'][i]>=np.float64(0): #print x[i],y[i] #m.scatter(x[i],y[i],50*df['mean'][i],marker='o',color='red') plt.scatter(x[i],y[i],50*df['mean'][i],marker='o',color='red') if 50*df['mean'][i]>=np.float64(70) and df.index[i]<>'TA15': plt.annotate(df.index[i],xy=(x[i],y[i]),xytext=(x[i]+0.51,y[i]+0.35),arrowprops=dict(frac=0.3,facecolor='red', shrink=0.2)) if df.index[i]=='TA15': plt.annotate(df.index[i],xy=(x[i],y[i]),xytext=(x[i]-0.31,y[i]+0.45),arrowprops=dict(frac=0.3,shrink=0.25,facecolor='red')) else: #print x[i],y[i]
(a,b)=divmod(float(df['LAT_DDMM'][i]),100) aa=int(a) bb=float(b) lat.append(aa+bb/60) (c,d)=divmod(float(df['LON_DDMM'][i]),100) cc=int(c) dd=float(d) lon.append(-1*(cc+dd/60)) latsize=[39.,45.0] lonsize=[-73.,-66.0] bathy=True draw_parallels=True parallels_interval=[2] cont_range=[-200,-100] ss=10 basemap_usgs(latsize,lonsize,bathy,draw_parallels,parallels_interval,cont_range,ss) basemap_standard(latsize,lonsize,[2]) #plt.figure(figsize=(7,6)) #x, y = m(-lon.values,lat.values) x, y = lon,lat plt.scatter(x,y,20,marker='o',color='r') for i in range(len(x)): if df.index[i] in threesite: #print df.index[i],lat[i],lon[i] plt.scatter(x[i],y[i],20,marker='o',color='blue') if df.index[i]=='BN01': plt.annotate(df.index[i],xy=(x[i],y[i]),xytext=(x[i]+0.81,y[i]-0.35),arrowprops=dict(facecolor='blue', shrink=0.1,frac=0.3))#facecolor='black',)); else: plt.annotate(df.index[i],xy=(x[i],y[i]),xytext=(x[i]-0.31,y[i]-0.65),arrowprops=dict(facecolor='blue', shrink=0.1,frac=0.3))#facecolor='black',)); #plt.annotate(df.index[i],xy=(x[i],y[i]),xytext=(x[i]-0.31,y[i]-0.75),arrowprops=dict(arrowstyle="-|>",shrink=0.1))#connectionstyle="arc3,rad=-0.2",fc="w")); if df.index[i] in surfacesite:
polygon=[] for j in range(len(deepest)): polygon.append([distance[j],deepest[j]]) polygon.append([distance[-1],max(deepest)+1]) polygon.append([distance[0],max(deepest)+1]) #plot white when it is solid pg=plt.Polygon(polygon,color='white') ax.add_patch(pg) depth_AB01=deepest[np.argmin(abs(distance_AB01-np.array(distance)))] plt.scatter(distance_AB01,depth_AB01) plt.annotate('AB01',xy=(distance_AB01,depth_AB01),xytext=(distance_AB01+1,depth_AB01+1),arrowprops=dict(frac=0.3,facecolor='red', shrink=0.2)) plt.ylim([max(deepest)+1,0]) plt.xlim([min(distance),max(distance)]) plt.title(str(time[q].date()),fontsize=20) cbar=plt.colorbar(CS) cbar.ax.tick_params(labelsize=15) plt.show() ''' latsize=[41.,42.5] lonsize=[-71.,-70.1] bathy=True draw_parallels=True parallels_interval=[0.5] cont_range=[-200,-100] ss=10 basemap_usgs(latsize,lonsize,bathy,draw_parallels,parallels_interval,cont_range,ss) basemap_standard(latsize,lonsize,[2]) plt.scatter(lon,lat,20,marker='o',color='r') plt.scatter(lon_AB01,lat_AB01,10,marker='o',color='b') plt.annotate('AB01',xy=(lon_AB01,lat_AB01),xytext=(lon_AB01,lat_AB01+0.1),arrowprops=dict(frac=0.3,shrink=0.25,facecolor='blue')) plt.show() '''
""" import getdata from drifter import plot_latlon,calculate_speedcolors,plot_speedcolors from basemap import basemap_usgs import matplotlib.pyplot as plt import pylab #id=raw_input("please input id,(example: 115361221 ): ") ids=[55201,55202,55203] #linecol=['red','green','blue'] linecol=['green','red','blue'] ndays_label=10 #basemap_JiM([40,43],[-72,-67],False,False) basemap_usgs([40.25,43],[-72,-67],True,True) for k in range(len(ids)): #get lat,lon,time use function "getdrift" (lat,lon,datet,dep)=getdata.getdrift(ids[k]) #plot lat,lon, and add text of time in the figure if ids[k]==55201: daymth=['5/10','5/21','5/22','7/3','7/16'] elif ids[k]==55202: daymth=['5/10','5/22','6/1','6/10'] elif ids[k]==55203: daymth=['5/18','6/1','6/10'] plot_latlon(lat,lon,datet,ids[k],ndays_label,linecol[k],daymth)
# position figure window on the screen thismanager1 = pylab.get_current_fig_manager() thismanager1.window.SetPosition((0, 0)) plt.title("basemap_standard") plt.show() # use the ascii files of coastline already on disk plt.figure(2, figsize=(5, 4)) bm.basemap_region("sne") thismanager2 = pylab.get_current_fig_manager() thismanager2.window.SetPosition((0, 500)) plt.title("basemap_region") plt.show() # extract coastline and bathymetry using pydap plt.figure(3, figsize=(5, 4)) bm.basemap_usgs([42.0, 43.0], [-71.0, -70.0], True, True, [0.5], [-50, 0], 5) thismanager3 = pylab.get_current_fig_manager() thismanager3.window.SetPosition((500, 0)) plt.title("basemap_usgs") plt.show() # extract coastline and bathymetry using pydap plt.figure(4, figsize=(5, 4)) bm.basemap_detail([40.0, 43.0], [-71.0, -65.0], True, True, 0.5) thismanager4 = pylab.get_current_fig_manager() thismanager4.window.SetPosition((500, 500)) plt.title("basemap_detail") plt.show()